/*
 * Hachi Console — the operations website's styles.
 *
 * Hachi's own tokens (packages/ui/src/tokens.ts), adapted for a desktop tool:
 * denser type, flatter cards, the ink sidebar echoing the app's tab bar, and
 * orange kept for the one primary action on a page and the current section.
 * Order stages use the app's status colours, so an order looks the same in
 * the app and here.
 *
 * A plain file rather than a build: the console is served by a 1 GB box that
 * should never need Node to deploy.
 */
:root {
  --primary: #f2662f; --primary-deep: #c44a1c; --ink: #1f1f1f; --body: #5f5f63; --muted: #8a8a8e;
  --hairline: #ededed; --control: #d9d9dd; --surface: #fff; --app: #f2f2f2; --fill: #f6f6f7;
  --success: #3f9147; --success-s: #eef7ee; --danger: #ee4b3c; --danger-s: #fdeaea; --warm: #fdece3;
  --st-wait: #3f6ea8; --st-wait-s: #e9f1fb; --st-cook: #a8621f; --st-cook-s: #fdece3;
  --st-move: #c44a1c; --st-move-s: #ffe3d6; --st-done: #3f9147; --st-done-s: #eef7ee;
  --st-closed: #7c7570; --st-closed-s: #f2f1ef;
  --r-card: 12px; --r-input: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Poppins, system-ui, sans-serif; font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--app); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-deep); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
.num, td.num, .figure { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.console { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--ink); color: #fff; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 14px; }
.mark { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; flex: none; }
.mark svg { width: 18px; height: 18px; }
.brand b { font-size: 16px; display: block; line-height: 1.2; }
.brand small { display: block; color: rgba(255,255,255,.55); font-size: 11.5px; }
.nav-group { margin-top: 14px; }
.nav-group h2 { margin: 0 10px 6px; font-size: 10.5px; letter-spacing: .08em; color: rgba(255,255,255,.4); font-weight: 600; text-transform: uppercase; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 10px; color: rgba(255,255,255,.75); cursor: pointer; text-align: left; font-size: 13.5px; }
.nav::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.nav:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav[aria-current="page"] { background: var(--primary); color: #fff; font-weight: 600; }
.me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 12.5px; color: rgba(255,255,255,.7); }
.me .who { color: #fff; font-weight: 500; }
.me button { margin-top: 10px; width: 100%; background: rgba(255,255,255,.08); color: #fff; border: 0; border-radius: 8px; padding: 7px; cursor: pointer; }
.me button:hover { background: rgba(255,255,255,.14); }
.main { flex: 1; min-width: 0; }
.content { padding: 26px 30px 60px; max-width: 1240px; }

/* ---------- page furniture ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
section, .card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-card); padding: 18px; margin: 0 0 16px; }
section > h2, .card > h2, section h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
section section { border: 0; padding: 0; margin: 14px 0 0; }
h3 { font-size: 14px; margin: 14px 0 8px; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.toolbar, .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar { justify-content: space-between; }
.muted, small { color: var(--muted); }
small { font-size: 12px; }
p { margin: .4rem 0; }

/* ---------- controls ---------- */
button, .btn { border: 1px solid var(--control); background: #fff; border-radius: var(--r-input); padding: 8px 14px; cursor: pointer; font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; }
button:hover { border-color: var(--muted); }
button.primary, button[type=submit]:not(.secondary):not(.danger) { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover, button[type=submit]:not(.secondary):not(.danger):hover { background: var(--primary-deep); border-color: var(--primary-deep); }
button.secondary { background: #fff; color: var(--ink); }
button.danger { color: var(--danger); border-color: #f3c2bd; background: #fff; }
button.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
button.small, .btn.small { padding: 5px 10px; font-size: 12.5px; }
button[disabled] { opacity: .45; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--primary-deep); font-weight: 500; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { width: 100%; padding: 8px 11px; border: 1px solid var(--control); border-radius: var(--r-input); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(242,102,47,.25); border-color: var(--primary); }
label { display: block; margin: 12px 0 5px; font-size: 12.5px; font-weight: 500; color: var(--body); }
label.inline { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; color: var(--ink); font-weight: 400; }
.chip { border: 1px solid var(--control); background: #fff; border-radius: 20px; padding: 5px 12px; font-size: 12.5px; }
.chip[aria-pressed="true"], .chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- messages ---------- */
.status { padding: 10px 14px; border-radius: 10px; background: var(--success-s); color: #2d6b33; margin: 0 0 14px; font-size: 13px; }
.errors, [role=alert] { padding: 10px 14px; border-radius: 10px; background: var(--danger-s); color: #9b2c22; margin: 8px 0 14px; font-size: 13px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }
.note { display: flex; gap: 10px; align-items: flex-start; background: var(--fill); border: 1px dashed var(--control); padding: 12px 14px; border-radius: 10px; color: var(--body); font-size: 13px; margin: 0 0 14px; }
.allergy { background: var(--danger-s); color: #b8342a; border-radius: 8px; padding: 6px 9px; font-size: 12px; font-weight: 600; margin: 0 0 8px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
caption { text-align: left; font-weight: 600; margin-bottom: 8px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td ul { margin: 0; padding-left: 16px; }
.table-wrap { overflow-x: auto; }

/* ---------- pills & figures ---------- */
.pill { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill.wait { color: var(--st-wait); background: var(--st-wait-s); } .pill.cook { color: var(--st-cook); background: var(--st-cook-s); }
.pill.move { color: var(--st-move); background: var(--st-move-s); } .pill.done { color: var(--st-done); background: var(--st-done-s); }
.pill.closed { color: var(--st-closed); background: var(--st-closed-s); } .pill.danger { color: var(--danger); background: var(--danger-s); }
.figure-label { margin: 0; font-size: 12.5px; color: var(--muted); }
.figure { margin: 4px 0 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.figure-note { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--warm); color: var(--primary-deep); display: inline-grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.row { display: flex; align-items: center; gap: 10px; }

/* ---------- permission matrix ---------- */
.matrix th, .matrix td { text-align: center; vertical-align: middle; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .group td { background: #fafafa; font-size: 11px; letter-spacing: .06em; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.matrix td.changed { background: #fff6ef; }
.matrix input[disabled] { opacity: .55; }

/* ---------- dialog ---------- */
.dialog-scrim { position: fixed; inset: 0; background: rgba(20,20,20,.4); z-index: 30; display: grid; place-items: center; padding: 20px; }
.dialog { width: min(480px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); }
.dialog h2 { font-size: 17px; margin: 0 0 6px; }
.dialog .actions { justify-content: flex-end; margin-top: 18px; }
.copy { display: flex; gap: 8px; } .copy input { font-size: 12px; }

/* ---------- side panel (order, customer, ticket) ---------- */
.panel-scrim { position: fixed; inset: 0; background: rgba(20,20,20,.3); z-index: 20; }
.panel { position: fixed; top: 0; right: 0; height: 100vh; width: min(640px, 96vw); background: #fff; box-shadow: -18px 0 40px -20px rgba(0,0,0,.4); z-index: 21; display: flex; flex-direction: column; }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-body { padding: 18px 22px; overflow: auto; flex: 1; }
.panel-foot { padding: 14px 22px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.close { margin-left: auto; border: 0; background: var(--fill); width: 32px; height: 32px; border-radius: 50%; justify-content: center; padding: 0; font-size: 16px; }
.timeline { border-left: 2px solid var(--hairline); margin: 4px 0 0 6px; padding-left: 16px; }
.timeline > div { position: relative; padding-bottom: 12px; font-size: 13px; }
.timeline > div::before { content: ""; position: absolute; left: -22px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); }
.timeline small { display: block; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.bubble { max-width: 80%; border-radius: 12px; padding: 9px 12px; background: var(--fill); font-size: 13px; }
.bubble.mine { align-self: flex-end; background: var(--warm); }
.bubble.system { align-self: center; background: none; color: var(--muted); font-size: 12px; padding: 2px; }
.thread { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafafa; }
tr.selected td { background: #fff6ef; }
.badge { margin-left: auto; background: rgba(255,255,255,.16); border-radius: 9px; padding: 0 7px; font-size: 11px; }
.nav[aria-current="page"] .badge { background: rgba(255,255,255,.3); }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth .mark { width: 44px; height: 44px; margin-bottom: 14px; }
.auth button[type=submit] { width: 100%; justify-content: center; margin-top: 18px; padding: 11px; }

@media (max-width: 900px) {
  .console { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; }
  .nav-group { margin: 0; display: contents; } .nav-group h2 { display: none; }
  .nav { width: auto; } .me { margin: 0 0 0 auto; border: 0; padding: 0; }
  .content { padding: 18px; } .split { grid-template-columns: 1fr; }
}
