:root {
  --bg: #f6f1e8; --card: #ffffff; --text: #2b2118; --muted: #8a7b6a; --line: #ece3d4;
  --primary: #c8821e; --primary-2: #e8a73c; --primary-soft: #fbefd6;
  --green: #2f8f5b; --green-soft: #def3e7; --red: #d24a3c; --red-soft: #fbe3df;
  --blue: #3a74c9; --blue-soft: #e0ebfa; --shadow: 0 6px 20px rgba(80, 55, 20, .08);
  --radius: 18px;
}
[data-theme="dark"] {
  --bg: #16130f; --card: #231f19; --text: #f4ecdd; --muted: #a39682; --line: #352e25;
  --primary: #e0993a; --primary-2: #f0b95b; --primary-soft: #3a2c15;
  --green: #4cc183; --green-soft: #173325; --red: #f0705f; --red-soft: #3b1e1a;
  --blue: #6fa3f0; --blue-soft: #1b2a42; --shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif; font-size: 15px; }
body { min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
#view { padding: 0 14px 16px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Шапка */
.hero { margin: 0 0 14px; padding: 22px 18px 22px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #8a5311 0%, #c8821e 55%, #ecb04a 100%);
  border-radius: 0 0 28px 28px; box-shadow: var(--shadow); }
.hero::after { content: "🌾"; position: absolute; right: -6px; bottom: -22px; font-size: 110px; opacity: .18; }
.hero small { opacity: .85; font-size: 13px; }
.hero h1 { margin: 2px 0 0; font-size: 22px; line-height: 1.2; }
.hero .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pill { background: rgba(255,255,255,.22); border: 0; color: #fff; padding: 7px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }

/* Нижня навігація */
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(80,55,20,.07); }
#tabbar .inner { display: flex; width: 100%; max-width: 640px; }
.tab { flex: 1; background: none; border: 0; padding: 6px 2px; color: var(--muted); display: flex;
  flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; position: relative; cursor: pointer; }
.tab .ic { font-size: 22px; line-height: 1; filter: grayscale(.9); transition: .2s; }
.tab.active { color: var(--primary); }
.tab.active .ic { filter: none; transform: translateY(-2px) scale(1.12); }
.badge { position: absolute; top: 0; left: 55%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

/* Картки */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line); }
.card.tap { cursor: pointer; transition: transform .12s; }
.card.tap:active { transform: scale(.985); }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; margin: 18px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bold { font-weight: 700; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.gap { height: 10px; }

.ico { width: 48px; height: 48px; border-radius: 14px; background: var(--primary-soft);
  display: grid; place-items: center; font-size: 26px; flex: none; }
.price { font-size: 17px; font-weight: 800; color: var(--primary); }

/* Кнопки */
.btn { border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 700; cursor: pointer; width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
  box-shadow: 0 6px 14px rgba(200,130,30,.3); transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn.sec { background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.btn.green { background: var(--green); box-shadow: none; }
.btn.red { background: var(--red-soft); color: var(--red); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; border: 1px solid var(--line); }
.btn.sm { padding: 9px 12px; font-size: 14px; width: auto; border-radius: 12px; }
.btns { display: flex; gap: 8px; margin-top: 10px; }
.btns .btn { flex: 1; }

/* Бейджі статусів */
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag.new { background: var(--blue-soft); color: var(--blue); }
.tag.confirmed { background: var(--primary-soft); color: var(--primary); }
.tag.done { background: var(--green-soft); color: var(--green); }
.tag.cancelled { background: var(--red-soft); color: var(--red); }
.tag.off { background: var(--line); color: var(--muted); }
.tag.low { background: var(--red-soft); color: var(--red); }

/* Форми */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 5px 3px; }
.input { width: 100%; padding: 13px 14px; border-radius: 13px; border: 1.5px solid var(--line);
  background: var(--bg); outline: none; transition: border .2s; }
.input:focus { border-color: var(--primary); }
textarea.input { min-height: 110px; resize: vertical; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.chip { border: 1.5px solid var(--line); background: var(--card); padding: 7px 13px; border-radius: 999px;
  font-weight: 600; font-size: 13px; cursor: pointer; color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.segment { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.segment::-webkit-scrollbar { display: none; }
.segment .chip { white-space: nowrap; }

.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 14px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }

/* Статистика */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 16px; padding: 13px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 3px; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat.accent { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border: 0; }
.stat.accent .l { color: rgba(255,255,255,.85); }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 6px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 5px; }
.bar i { display: block; width: 100%; border-radius: 8px 8px 4px 4px; min-height: 4px;
  background: linear-gradient(180deg, var(--primary-2), var(--primary)); }
.bar span { font-size: 11px; color: var(--muted); font-weight: 600; }
.bar b { font-size: 10px; color: var(--muted); }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 4px; }
.rank { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; font-weight: 800; font-size: 18px; }

/* Кошик */
.cartbar { position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 15;
  max-width: 616px; margin: 0 auto; background: var(--text); color: var(--bg); border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; box-shadow: 0 10px 30px rgba(0,0,0,.3); cursor: pointer; }
.cartbar b { font-size: 16px; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--bg); border-radius: 12px; padding: 3px; }
.stepper button { width: 32px; height: 32px; border: 0; border-radius: 10px; background: var(--card);
  font-size: 18px; font-weight: 700; cursor: pointer; color: var(--primary); }
.stepper span { min-width: 44px; text-align: center; font-weight: 700; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 54px; margin-bottom: 8px; }
.skeleton { height: 76px; border-radius: var(--radius); margin-bottom: 12px;
  background: linear-gradient(90deg, var(--line) 25%, var(--card) 50%, var(--line) 75%); background-size: 200% 100%;
  animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.link { color: var(--blue); text-decoration: none; font-weight: 600; }

/* Модальне вікно */
.overlay { position: fixed; inset: 0; background: rgba(20,12,0,.5); z-index: 40; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--bg); max-width: 640px; margin: 0 auto;
  border-radius: 26px 26px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto;
  animation: up .25s ease; box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
@keyframes up { from { transform: translateY(60%); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 4px 0 12px; font-size: 19px; }
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 100; background: var(--text);
  color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 600; max-width: 90%; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: fade .2s; }
.toast.err { background: var(--red); color: #fff; }
.fab { position: fixed; right: 18px; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 15; width: 56px; height: 56px;
  border-radius: 50%; border: 0; font-size: 28px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 8px 20px rgba(200,130,30,.45); }
