/* MenuMate — дизайн-система.
   Палитра: молоко (фон), шалфей (основной), терракота (акцент). */

@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest";
  src: url("/static/fonts/onest-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #F5F1E8;
  --surface: #FFFCF6;
  --surface-2: #EFE9DD;
  --line: #E6DECF;
  --text: #243028;
  --muted: #7B8379;
  --sage: #5A8767;
  --sage-strong: #44694F;
  --sage-soft: #E3EBDF;
  --on-sage: #FFFCF6;
  --clay: #D2845F;
  --clay-soft: #F6E3D7;
  --clay-text: #A55C3A;
  --danger: #C0533E;
  --danger-soft: #F5DED7;
  --shadow: 0 1px 2px rgba(36, 48, 40, .04), 0 8px 24px rgba(36, 48, 40, .05);
  --shadow-lift: 0 10px 30px rgba(68, 105, 79, .28);
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #131815;
  --surface: #1B211D;
  --surface-2: #242B26;
  --line: #2D3530;
  --text: #ECE7DC;
  --muted: #959D93;
  --sage: #8DB898;
  --sage-strong: #AACDB2;
  --sage-soft: #233129;
  --on-sage: #101D15;
  --clay: #E29C7B;
  --clay-soft: #3A2A22;
  --clay-text: #EBAB8C;
  --danger: #E3846F;
  --danger-soft: #3B241F;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-lift: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { -webkit-user-select: none; user-select: none; }

.i { display: block; flex: none; }

.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

.screen { max-width: 600px; margin: 0 auto; padding: 18px 16px calc(120px + var(--safe-bottom)); animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

/* ---------- заголовок ---------- */
.head { display: flex; align-items: flex-start; gap: 12px; margin: 2px 0 20px; }
.head .titles { flex: 1; min-width: 0; }
.head h1 { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 650; letter-spacing: -.02em; }
.head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.round-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); flex: none;
}
.round-btn:active { transform: scale(.94); }

/* ---------- секции и карточки ---------- */
.label {
  display: flex; align-items: center; gap: 8px; margin: 24px 4px 10px;
  font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .01em;
}
.label .grow { flex: 1; }
.label .count-pill { font-weight: 600; font-size: 12px; color: var(--sage-strong); background: var(--sage-soft); border-radius: 99px; padding: 1px 8px; }

.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.card.pad { padding: 16px; }
.card + .card { margin-top: 12px; }

.row {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 12px 16px;
  background: none; border: 0; text-align: left; position: relative; color: inherit;
}
.row + .row::before, .row + .panel::before, .panel + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 16px; height: 1px; background: var(--line);
}
button.row { cursor: pointer; transition: background .12s; }
button.row:active { background: var(--surface-2); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.row .end { color: var(--muted); display: flex; align-items: center; gap: 6px; font-size: 14px; }
.row .num { font-size: 20px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; }
.row.off { opacity: .45; }
.row.selected { background: var(--sage-soft); }

.panel { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.panel.top { padding-top: 14px; }

/* бейдж с иконкой */
.badge {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: var(--sage-soft); color: var(--sage-strong);
}
.badge.sm { width: 34px; height: 34px; border-radius: 11px; }
.badge.lg { width: 48px; height: 48px; border-radius: 16px; }
.badge.clay { background: var(--clay-soft); color: var(--clay-text); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

/* отметка выбора */
.check {
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line); flex: none;
  display: grid; place-items: center; color: transparent; transition: all .15s;
  background: var(--surface);
}
.check.on { background: var(--sage); border-color: var(--sage); color: var(--on-sage); transform: scale(1.04); }

/* ---------- кнопки ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 52px; padding: 12px 18px; border: 0; border-radius: var(--r-md); cursor: pointer;
  background: var(--sage); color: var(--on-sage); font-weight: 600; font-size: 16px; letter-spacing: -.005em;
  transition: transform .12s, opacity .12s, background .12s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.soft { background: var(--sage-soft); color: var(--sage-strong); }
.btn.clay { background: var(--clay-soft); color: var(--clay-text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: none; color: var(--sage-strong); font-weight: 500; min-height: 44px; }
.btn.ghost.danger-text { color: var(--danger); }
.btn.sm { min-height: 40px; padding: 8px 14px; font-size: 14px; border-radius: 12px; width: auto; }
.btn.icon-only { width: 44px; min-height: 44px; padding: 0; flex: none; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.inline > .btn { flex: 1; }

.text-btn {
  background: none; border: 0; padding: 6px 4px; cursor: pointer; color: var(--sage-strong);
  font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 0; background: none; color: var(--muted);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.danger { color: var(--danger); }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.bottom-bar .btn { max-width: 568px; margin: 0 auto; box-shadow: var(--shadow-lift); }
.bottom-bar .btn:disabled { box-shadow: none; }

.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- поля ---------- */
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1.5px solid transparent; border-radius: 12px;
  background: var(--surface-2); outline: none; transition: border-color .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .85; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--sage); background: var(--surface); }
.textarea { resize: none; min-height: 84px; }
.field { display: flex; gap: 8px; align-items: center; }
.field .input { flex: 1; min-width: 0; }
.hint { font-size: 13px; color: var(--muted); }
.search { position: relative; }
.search .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 42px; background: var(--surface); box-shadow: var(--shadow); }

/* ---------- уведомления на экране ---------- */
.notice { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 4px; }
.notice .txt { flex: 1; min-width: 0; }
.notice b { display: block; font-weight: 600; }
.notice span { color: var(--muted); font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted);
}
.chip.sage { background: var(--sage-soft); color: var(--sage-strong); }
.chip.clay { background: var(--clay-soft); color: var(--clay-text); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
button.chip { border: 1.5px solid var(--line); background: none; padding: 7px 14px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--muted); }
button.chip.on { border-color: var(--sage); background: var(--sage-soft); color: var(--sage-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* сегменты */
.seg { display: flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 14px; margin-bottom: 16px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 11px; padding: 9px 8px; cursor: pointer;
  font-weight: 500; font-size: 14px; color: var(--muted); line-height: 1.25; transition: all .15s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.seg small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 1px; }

/* ---------- главный экран ---------- */
.hero {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer; padding: 20px;
  border-radius: 24px; background: var(--sage); color: var(--on-sage); position: relative; overflow: hidden;
  box-shadow: var(--shadow-lift); margin-bottom: 8px;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: color-mix(in srgb, var(--on-sage) 10%, transparent);
}
.hero .kicker { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; opacity: .85; }
.hero .big { font-size: 21px; font-weight: 650; letter-spacing: -.015em; margin-top: 10px; line-height: 1.25; position: relative; z-index: 1; padding-right: 44px; }
.hero .small { font-size: 14px; opacity: .85; margin-top: 6px; position: relative; z-index: 1; padding-right: 44px; }
.hero .go { position: absolute; right: 18px; bottom: 18px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--on-sage) 16%, transparent); }
.hero.calm { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.hero.calm::after { background: var(--sage-soft); }
.hero.calm .go { background: var(--sage-soft); color: var(--sage-strong); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  background: var(--surface); border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 16px;
  min-height: 118px; text-align: left; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between;
  gap: 14px; position: relative; color: inherit; transition: transform .12s;
}
.tile:active { transform: scale(.97); }
.tile .name { font-weight: 600; font-size: 16px; }
.tile .desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.dot-count {
  position: absolute; top: 14px; right: 14px; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px;
  background: var(--clay); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center;
}

/* статистика */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 650; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat.sage .n { color: var(--sage-strong); }
.stat.clay .n { color: var(--clay-text); }

.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; border-radius: 99px; background: var(--sage); transition: width .3s; }

/* пусто */
.empty { text-align: center; padding: 40px 24px; color: var(--muted); }
.empty .badge { margin: 0 auto 16px; }
.empty b { display: block; color: var(--text); font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.empty p { margin: 0; font-size: 14px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.small { font-size: 13px; }
.strike { text-decoration: line-through; opacity: .55; }

/* тост */
.toast {
  position: fixed; left: 16px; right: 16px; z-index: 50; bottom: calc(92px + var(--safe-bottom));
  max-width: 520px; margin: 0 auto; display: flex; gap: 10px; align-items: center;
  padding: 13px 16px; border-radius: 16px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 500; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); animation: pop .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

@media (max-width: 350px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .head h1 { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
