/* Заготовка демо. Цвета клиента приходят из config.js через --accent. */
:root {
  --accent: #7c4dff;
  --accent-text: #fff;
  --accent-rgb: 124, 77, 255;
  --accent-dark: #4d2fa0;
  --accent-soft: rgba(var(--accent-rgb), .14);
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #15171a;
  --muted: #687080;
  --border: #e1e4e9;
  --ok: #1f9d55;
  --warn: #c27c0e;
  --bad: #d64545;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1114;
  --surface: #181b20;
  --surface-2: #22262d;
  --text: #eceef1;
  --muted: #9aa3b2;
  --border: #2b3038;
  --ok: #3ccf7f;
  --warn: #e9a43a;
  --bad: #ff6b6b;
  --accent-soft: rgba(var(--accent-rgb), .22);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- Каркас ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.demo-banner {
  position: sticky; top: 0; z-index: 30;
  padding: calc(6px + var(--safe-t)) 14px 6px;
  background: #ffe9a8; color: #4a3800;
  font-size: 12px; line-height: 1.35; text-align: center;
  border-bottom: 1px solid #f1d27a;
}
:root[data-theme="dark"] .demo-banner { background: #3a3110; color: #ffe08a; border-bottom-color: #54471a; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: var(--banner-h, 30px); z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar-title { flex: 1; font-weight: 650; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; font-size: 20px; line-height: 1;
}
.screen { flex: 1; padding: 4px 14px calc(var(--tabbar-h) + var(--safe-b) + 24px); outline: none; width: 100%; max-width: 760px; margin: 0 auto; }
.sidebar { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; overflow-x: auto; scrollbar-width: none;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: var(--muted); font-size: 11px; cursor: pointer; position: relative; padding: 0 4px;
}
.tab svg, .side-link svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--bad); color: #fff; font-size: 10px; line-height: 17px; font-weight: 700; text-align: center;
}

/* ---------- ПК ---------- */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; }
  .demo-banner { grid-column: 1 / -1; font-size: 13px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; padding: 18px 12px;
    position: sticky; top: var(--banner-h, 30px); height: calc(100vh - var(--banner-h, 30px));
    border-right: 1px solid var(--border); background: var(--surface);
  }
  .side-brand { font-weight: 700; font-size: 17px; padding: 4px 10px 14px; }
  .side-link {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 0;
    background: none; cursor: pointer; text-align: left; color: var(--text); position: relative;
  }
  .side-link:hover { background: var(--surface-2); }
  .side-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .side-link .badge { position: static; margin-left: auto; }
  .tabbar { display: none; }
  .screen { padding: 8px 28px 48px; max-width: 980px; margin: 0; }
  .topbar { padding: 16px 28px 8px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .items { grid-template-columns: 1fr 1fr; }
}

/* ---------- Блоки ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 2px 0; }

.hero {
  border-radius: 20px; padding: 22px 18px; color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}
.hero h1 { font-size: 23px; margin-bottom: 8px; }
.hero p { opacity: .92; margin-bottom: 16px; }
.hero .btn { background: var(--accent-text); color: var(--accent); }

.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.quick button {
  display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 14px; cursor: pointer; text-align: left;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600;
}
.quick svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-text); font-weight: 650; font-size: 15px;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; white-space: nowrap; font-size: 14px;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.items { display: grid; gap: 10px; }
.item { display: flex; flex-direction: column; gap: 10px; }
.item-head { display: flex; justify-content: space-between; gap: 12px; }
.price { font-weight: 700; white-space: nowrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; }

.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  flex: none; width: 58px; padding: 8px 0; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); text-align: center; cursor: pointer;
}
.day b { display: block; font-size: 18px; }
.day span { font-size: 12px; color: var(--muted); }
.day.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.day.active span { color: inherit; opacity: .85; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.slot { padding: 10px 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.slot.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.slot:disabled { opacity: .35; text-decoration: line-through; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); outline: none;
}
.textarea { min-height: 80px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); background: var(--surface); }
.input.error { border-color: var(--bad); }
.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; background: none; cursor: pointer; }
.seg button.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.qty button { width: 34px; height: 34px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 18px; }
.qty span { min-width: 32px; text-align: center; font-weight: 600; }
.total { display: flex; justify-content: space-between; font-weight: 700; font-size: 17px; }
.line { display: flex; justify-content: space-between; gap: 12px; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }

.success { text-align: center; padding: 28px 18px; }
.success .check {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center;
  background: rgba(31, 157, 85, .16); color: var(--ok); font-size: 32px;
}
.demo-note { margin-top: 10px; font-size: 12px; color: var(--muted); }

.profile { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 22px;
}
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }

.status { display: inline-block; padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-0 { background: var(--accent-soft); color: var(--accent); }
.st-1 { background: rgba(214, 141, 20, .16); color: var(--warn); }
.st-2 { background: rgba(31, 157, 85, .16); color: var(--ok); }
.st-3 { background: rgba(214, 69, 69, .14); color: var(--bad); }
.req { display: flex; flex-direction: column; gap: 8px; }
.req .select { min-height: 38px; padding: 6px 10px; width: auto; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 900px) { .metrics { grid-template-columns: repeat(4, 1fr); } }
.metric .value { font-size: 22px; font-weight: 750; margin-top: 4px; }
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar-label { fill: var(--muted); font-size: 11px; }
.chart .bar-value { fill: var(--text); font-size: 11px; font-weight: 600; }
.chart .grid-line { stroke: var(--border); }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); transform: translate(-50%, 20px);
  background: #15171a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
:root[data-theme="dark"] .toast { background: #eceef1; color: #15171a; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* Доработки концепта «Раковая» */
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.loyalty h2 { margin-top: 2px; }
.lcode { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.bubble { background: var(--accent-soft); border-radius: 14px 14px 14px 4px; padding: 10px 12px; }
.bubble + .bubble { margin-top: 2px; }
