/* Owner dashboard + platform admin + login. Light by default, dark when the OS prefers it. */
:root {
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.1);
  --bg: #f6f5f9;
  --panel: #ffffff;
  --panel-2: #faf9fc;
  --line: #e8e5ef;
  --text: #17141f;
  --muted: #6b6578;
  --faint: #9a94a8;
  --good: #059669;
  --good-soft: rgba(5, 150, 105, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, 0.1);
  --shadow: 0 1px 2px rgba(20, 10, 40, 0.05), 0 8px 24px rgba(20, 10, 40, 0.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --accent: #a78bfa;
    --accent-soft: rgba(167, 139, 250, 0.14);
    --bg: #0d0c12;
    --panel: #16141d;
    --panel-2: #1b1924;
    --line: #2a2735;
    --text: #f1eff6;
    --muted: #a39db3;
    --faint: #6f6a80;
    --good: #34d399;
    --good-soft: rgba(52, 211, 153, 0.12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
h1, h2, h3, h4 { letter-spacing: -0.02em; margin: 0; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 16px; }
.logo .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 15px; flex: none; }
.logo small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 550; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.side-foot button { background: none; border: 0; color: var(--muted); padding: 0; text-decoration: underline; }
.main { min-width: 0; padding: 26px 30px 60px; max-width: 1240px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.impersonate { background: var(--warn-soft); color: var(--warn); padding: 8px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; font-size: 13px; }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 60; transform: translateX(-105%); transition: transform 0.2s; height: 100vh; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
  .main { padding: 18px 16px 60px; }
}

/* ---------- Components ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h3 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .g2, .g4 { grid-template-columns: 1fr; } }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi .value { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin-top: 4px; line-height: 1.1; }
.kpi .hint { color: var(--faint); font-size: 12px; margin-top: 4px; }
.kpi.hero { background: linear-gradient(135deg, var(--accent), #5b21b6); color: #fff; border: 0; }
.kpi.hero .label, .kpi.hero .hint { color: rgba(255, 255, 255, 0.8); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.big { padding: 13px 22px; font-size: 15px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input, select, textarea { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); outline: 0; transition: border-color 0.15s, box-shadow 0.15s; }
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 84px; resize: vertical; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
label.f small { color: var(--faint); font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 550; margin-bottom: 10px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.2s; flex: none; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
td .sub { color: var(--muted); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 999px; font-weight: 550; color: var(--muted); font-size: 13px; }
.chips button.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.notice { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13px; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice.good { background: var(--good-soft); color: var(--good); }
.notice b { color: inherit; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.spacer { flex: 1; }

/* Chart */
.chart { width: 100%; height: 220px; }
.chart .bar-s { fill: var(--line); }
.chart .bar-m { fill: var(--accent); }
.chart text { fill: var(--faint); font-size: 10px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Activity */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; }
.feed li:last-child { border: 0; }
.feed .ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); flex: none; font-size: 15px; }
.feed .t { flex: 1; min-width: 0; }
.feed .t b { font-weight: 600; }
.feed time { color: var(--faint); font-size: 12px; white-space: nowrap; }

/* Loop */
.loop { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.loop div { text-align: center; padding: 12px 6px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.loop b { display: block; font-size: 20px; letter-spacing: -0.02em; }
.loop span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
@media (max-width: 900px) { .loop { grid-template-columns: repeat(4, 1fr); } }

/* Drawer & modal */
.scrim { position: fixed; inset: 0; background: rgba(10, 6, 20, 0.45); z-index: 80; display: flex; justify-content: flex-end; animation: dim 0.15s; }
.scrim.center { justify-content: center; align-items: center; padding: 20px; }
@keyframes dim { from { background-color: rgba(10, 6, 20, 0); } }
.drawer { width: min(620px, 100%); height: 100%; background: var(--bg); overflow-y: auto; padding: 22px; box-shadow: var(--shadow); animation: slide 0.2s ease-out; }
@keyframes slide { from { transform: translateX(30px); } }
.dialog { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; background: var(--panel); border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3); }
.dialog h2, .drawer h2 { font-size: 20px; margin-bottom: 4px; }
.close-x { float: right; background: none; border: 0; font-size: 22px; color: var(--muted); line-height: 1; padding: 4px 8px; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.stats-row div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stats-row b { display: block; font-size: 20px; }
.stats-row span { font-size: 11.5px; color: var(--muted); }

/* Redeem */
.redeem-box { max-width: 560px; }
.code-input { font-size: 30px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; text-align: center; padding: 16px; border-radius: 14px; }
.reward-card { border: 2px dashed var(--accent); border-radius: 16px; padding: 20px; margin-top: 16px; background: var(--accent-soft); }
.reward-card .title { font-size: 22px; font-weight: 800; }

/* Menu editor */
.cat-block { margin-bottom: 18px; }
.cat-block .cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cat-block .cat-head h3 { margin: 0; font-size: 16px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.menu-item:last-child { border: 0; }
.menu-item .grow { flex: 1; min-width: 0; }
.menu-item.off { opacity: 0.55; }
.tags-edit { display: flex; gap: 8px; flex-wrap: wrap; }
.tags-edit label { display: flex; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.tags-edit input { accent-color: var(--accent); }

/* QR */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.qr-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.qr-card .qr { width: 100%; aspect-ratio: 1; border-radius: 8px; background: #fff; padding: 6px; }
.qr-card .qr svg { width: 100%; height: 100%; display: block; }
.qr-card b { display: block; margin-top: 6px; }

/* Automations */
.auto { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); margin-bottom: 14px; overflow: hidden; }
.auto-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.auto-head .ico { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; font-size: 19px; flex: none; }
.auto-head .t { flex: 1; min-width: 0; }
.auto-head .t b { display: block; font-size: 15px; }
.auto-head .t span { color: var(--muted); font-size: 13px; }
.auto-body { padding: 0 18px 18px 72px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 14px; }
.auto-body .wide { grid-column: 1 / -1; }
.preview { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 10px 13px; font-size: 13px; margin-top: 6px; white-space: pre-wrap; }
.vars { font-size: 12px; color: var(--faint); margin-top: 4px; }
@media (max-width: 700px) { .auto-body { padding-left: 18px; } }

/* Feedback */
.stars-txt { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }
.dist { display: grid; grid-template-columns: 28px 1fr 34px; gap: 8px; align-items: center; font-size: 12.5px; margin-bottom: 6px; }
.dist .bar { height: 8px; background: var(--panel-2); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.dist .bar i { display: block; height: 100%; background: #f59e0b; }

/* Orders */
.order-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.order-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; border-top: 4px solid #f59e0b; }
.order-card.preparing { border-top-color: #3b82f6; }
.order-card.ready { border-top-color: var(--good); }
.order-card.served { border-top-color: var(--line); opacity: 0.75; }
.order-card ul { margin: 8px 0; padding-left: 18px; }

/* Toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); max-width: 360px; animation: slide 0.2s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(800px 400px at 50% -100px, var(--accent-soft), transparent), var(--bg); }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { font-size: 22px; margin-bottom: 4px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
