:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #1d1b18;
  --muted: #6b665e;
  --line: #e2ded6;
  --brand: #c2410c;
  --brand-ink: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --info: #1d4ed8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --surface: #1f1e1b; --surface-2: #2a2824; --text: #f2efe9; --muted: #a9a398;
    --line: #36332e; --brand: #f97316; --brand-ink: #1a0f06; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --info: #93c5fd;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* layout */
.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .3px; color: var(--brand); font-size: 18px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.on { background: var(--surface-2); color: var(--text); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.grid { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
h2 { margin: 4px 0 14px; font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* controls */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; min-height: 40px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 56px; font-size: 17px; padding: 12px 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.scroll { overflow-x: auto; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.b-ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.b-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.b-bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.b-info { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }

/* messages */
.msg { padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.msg.err { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.msg.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 50; max-width: 420px; box-shadow: var(--shadow); }

/* login */
.login { max-width: 380px; margin: 10vh auto; }
.login .brand { font-size: 28px; text-align: center; margin-bottom: 4px; }

/* POS */
.pos { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 980px) { .pos { grid-template-columns: 1.4fr 1fr; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.products { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.product { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px; text-align: left; cursor: pointer; min-height: 84px; display: grid; gap: 4px; }
.product:hover { border-color: var(--brand); }
.product:disabled { cursor: not-allowed; opacity: .45; }
.product .name { font-weight: 700; }
.product .price { color: var(--muted); font-variant-numeric: tabular-nums; }
.tables { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.table-btn { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 6px; background: var(--surface); cursor: pointer; font-weight: 700; display: grid; gap: 2px; text-align: center; }
.table-btn.on { outline: 2px solid var(--brand); }
.table-btn .st { font-size: 11px; font-weight: 600; color: var(--muted); }
.t-OCCUPIED { border-color: var(--warn); }
.t-CLEANING { border-color: var(--info); }
.t-RESERVED { border-color: var(--muted); border-style: dashed; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 800; }
.total { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.orders { display: grid; gap: 8px; }
.order { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); cursor: pointer; display: grid; gap: 2px; text-align: left; }
.order.on { outline: 2px solid var(--brand); }

/* KDS */
body.kds { --bg: #0f0e0d; --surface: #1c1a17; --surface-2: #2a2723; --text: #f6f3ee; --muted: #a8a196; --line: #34302b; color-scheme: dark; }
.kds-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
.ticket { background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 8px; }
.ticket.late { border-color: var(--warn); }
.ticket.very-late { border-color: var(--bad); }
.ticket .head { display: flex; justify-content: space-between; align-items: baseline; }
.ticket .num { font-size: 22px; font-weight: 900; text-align: left; }
.ticket .clock { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kitem { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 8px; border-radius: 10px; background: var(--surface-2); border: 0; text-align: left; cursor: pointer; color: var(--text); min-height: 52px; }
.kitem .q { font-size: 22px; font-weight: 900; }
.kitem .p { font-size: 17px; font-weight: 700; }
.kitem .n { display: block; font-size: 14px; color: var(--warn); font-weight: 600; }
.kitem.s-PREPARING { box-shadow: inset 4px 0 0 var(--warn); }
.kitem.s-READY { box-shadow: inset 4px 0 0 var(--ok); opacity: .7; }
.kitem.s-PENDING { box-shadow: inset 4px 0 0 var(--muted); }

/* modal */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; padding: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; display: grid; gap: 12px; }
.modal h3 { margin: 0; }
