:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #e2e8f0;
  --ink: #1b2130;
  --muted: #6b7687;
  --accent: #2c7cc0;
  --accent-soft: #eaf3fb;
  --warn: #e08a1e;
  --danger: #d04545;
  --ok: #2e9e6b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20,30,50,.07), 0 6px 18px rgba(20,30,50,.05);
}

* { box-sizing: border-box; }

/* The browser hides [hidden] elements with a UA rule of `display: none`, but ANY author
   rule that sets `display` outranks it — so `.login-wrap { display: grid }` would keep the
   login screen on-screen even after el.hidden = true. Everything here toggles visibility
   via the hidden attribute, so make it win outright. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}
button { font: inherit; cursor: pointer; border-radius: 7px; border: 1px solid transparent; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  background: var(--surface); padding: 32px; border-radius: 14px;
  box-shadow: var(--shadow); width: 100%; max-width: 360px;
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 20px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card input { margin-top: 5px; }
.primary { background: var(--accent); color: #fff; padding: 10px 16px; width: 100%; font-weight: 600; }
.primary:hover { filter: brightness(1.07); }
.ghost { background: transparent; border-color: var(--line); color: var(--muted); padding: 6px 12px; }
.ghost:hover { background: var(--bg); color: var(--ink); }
.small { font-size: 12px; padding: 4px 8px; }

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: var(--muted); padding: 7px 14px; font-weight: 500; }
.tab:hover { background: var(--bg); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bell { position: relative; background: transparent; font-size: 17px; padding: 5px 8px; }
.bell:hover { background: var(--bg); }
.badge {
  position: absolute; top: -2px; right: -3px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px;
  display: grid; place-items: center; padding: 0 4px;
}

/* ── Notifications ─────────────────────────────────────────────────────── */
.notif-panel {
  position: absolute; right: 20px; top: 60px; width: 340px; max-height: 420px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 30;
}
.notif-head { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.notif-list { padding: 6px; }
.notif { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.notif:hover { background: var(--bg); }
.notif.unread { background: var(--accent-soft); }
.notif b { display: block; font-size: 13px; }
.notif span { font-size: 12px; color: var(--muted); }

/* ── Views ─────────────────────────────────────────────────────────────── */
.view { padding: 20px; max-width: 1500px; margin: 0 auto; }

.stats { display: flex; gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 20px; min-width: 110px;
}
.stat span { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: var(--surface); border: 1px solid var(--line); color: var(--muted); padding: 5px 12px; font-size: 13px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.layout { display: grid; grid-template-columns: minmax(0,1fr) 400px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }

.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex;
  align-items: center; gap: 14px;
}
.order-card:hover { border-color: var(--accent); }
.order-card.selected { border-color: var(--accent); box-shadow: var(--shadow); }
.order-card.unseen { border-left-color: var(--danger); background: #fffaf9; }
.order-card .num { font-weight: 700; min-width: 66px; }
.order-card .who { flex: 1; min-width: 0; }
.order-card .who b { display: block; font-size: 13px; }
.order-card .who span { font-size: 12px; color: var(--muted); }
.order-card .amt { font-weight: 600; white-space: nowrap; }
.new-tag { background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 4px; letter-spacing: .4px; }

.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  letter-spacing: .3px; white-space: nowrap; }
.s-PLACED           { background: #fdeee0; color: #a8621a; }
.s-CONFIRMED        { background: #e5f0fb; color: #2159a8; }
.s-PREPARING        { background: #f0e9fb; color: #6236a8; }
.s-READY            { background: #e3f6ec; color: #1e7a50; }
.s-OUT_FOR_DELIVERY { background: #e0f3f7; color: #14697d; }
.s-DELIVERED        { background: #eceff3; color: #566173; }
.s-CANCELLED        { background: #fbe6e6; color: #a83232; }

/* ── Detail ────────────────────────────────────────────────────────────── */
.detail {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; position: sticky; top: 76px;
}
.detail .empty { color: var(--muted); text-align: center; padding: 40px 0; }
.detail h2 { margin: 0 0 2px; font-size: 19px; }
.detail .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 4px 10px; font-size: 13px; margin-bottom: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.lines { border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 12px; }
.line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; }
.line .qty { color: var(--muted); min-width: 26px; }
.line .nm { flex: 1; }
.totals { border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.totals .row { display: flex; justify-content: space-between; padding: 2px 0; }
.totals .grand { font-weight: 700; font-size: 15px; border-top: 1px solid var(--line);
  margin-top: 6px; padding-top: 8px; }
.status-actions { margin-top: 16px; }
.status-actions h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); }
.status-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.status-btn { background: var(--surface); border: 1px solid var(--line); padding: 6px 11px; font-size: 12.5px; }
.status-btn:hover { border-color: var(--accent); color: var(--accent); }
.status-btn.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.status-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.history { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.history h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); }
.hist { font-size: 12px; color: var(--muted); padding: 3px 0; }
.hist b { color: var(--ink); }

/* ── Items ─────────────────────────────────────────────────────────────── */
.items-toolbar { display: flex; gap: 10px; margin-bottom: 16px; max-width: 640px; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.item-card { background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; }
.item-card.off { opacity: .55; }
.item-card .hd { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.item-card b { font-size: 14px; }
.item-card .price { font-weight: 700; white-space: nowrap; }
.item-card .cat { font-size: 11px; color: var(--accent); text-transform: uppercase;
  letter-spacing: .4px; margin: 3px 0 6px; }
.item-card p { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); }
.toggle { font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); background: var(--surface); }
.toggle.on { border-color: var(--ok); color: var(--ok); }
.toggle.off { border-color: var(--danger); color: var(--danger); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
