/* Platestead admin demo. Brand tokens match the Platestead marketing site.
   No inline styles anywhere: the CSP is style-src 'self'. */
:root {
  --ink: #0b1020;
  --ink-soft: #1b2338;
  --body: #333b52;
  --muted: #5d6680;
  --line: #e2e5ee;
  --surface: #ffffff;
  --surface-alt: #f6f7fb;
  --accent: #e2643c;
  --accent-dark: #b14828;
  --accent-darker: #963d22;
  --accent-soft: #fdeee8;
  --ok: #1d7a4a; --ok-soft: #e4f4ea;
  --warn: #8a5a00; --warn-soft: #fff3d6;
  --bad: #b3261e; --bad-soft: #fde8e6;
  --info: #2457a6; --info-soft: #e7eefb;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11,16,32,.06), 0 4px 16px rgba(11,16,32,.06);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 236px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eef0f6; --ink-soft: #d5d9e6; --body: #c3c8d6; --muted: #9aa2b8;
    --line: #283049; --surface: #121829; --surface-alt: #0b1020;
    --accent: #ef8058; --accent-dark: #f08a64; --accent-darker: #f7a586; --accent-soft: #3a2119;
    --ok: #5fcf93; --ok-soft: #13301f; --warn: #f2c260; --warn-soft: #33280d;
    --bad: #f28b82; --bad-soft: #3a1714; --info: #8db4f5; --info-soft: #152541;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--sans); color: var(--body); background: var(--surface-alt); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 1.55rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 8px; }
.mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Disclosure bar: always visible, never dismissible. */
.disclosure { position: sticky; top: 0; z-index: 50; background: var(--ink); color: #fff; font-size: .82rem; display: flex; gap: 12px; align-items: center; justify-content: center; padding: 6px 16px; text-align: center; flex-wrap: wrap; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .disclosure { background: #000; } }
.disclosure strong { font-weight: 600; }
.disclosure .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.disclosure button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 999px; padding: 2px 10px; cursor: pointer; font-size: .8rem; }
.disclosure button:hover { background: rgba(255,255,255,.12); }

/* Layout */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: calc(100vh - 34px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 34px; height: calc(100vh - 34px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand svg { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--body); text-decoration: none; font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav a:hover { background: var(--surface-alt); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-darker); }
.nav a .count { margin-left: auto; font-size: .75rem; background: var(--accent-dark); color: #fff; border-radius: 999px; padding: 0 7px; min-width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.persona { display: flex; gap: 10px; align-items: center; padding: 4px 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink-soft); color: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.persona .name { color: var(--ink); font-weight: 600; font-size: .9rem; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 34px; z-index: 20; }
.topbar .menu-btn { display: none; }
.unit-switch { display: flex; align-items: center; gap: 8px; }
.unit-switch label { font-size: .8rem; color: var(--muted); }
.unit-switch select { border: 1px solid var(--line); border-radius: 999px; padding: 6px 30px 6px 12px; background: var(--surface-alt); font-weight: 600; color: var(--ink); }
.topbar .spacer { flex: 1; }
.content { padding: 24px 28px 64px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.breadcrumb { font-size: .85rem; margin-bottom: 6px; }
.breadcrumb a { text-decoration: none; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: .82rem; }
.kpi .value { font-size: 1.6rem; color: var(--ink); font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi .sub { font-size: .8rem; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .88rem; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-alt); }
.btn.primary { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn.primary:hover { background: var(--accent-darker); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #1a0d07; } }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.small { padding: 4px 10px; font-size: .8rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Forms */
.field { display: grid; gap: 4px; }
.field label, .field .label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.input, .select, textarea.input { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 7px 10px; min-width: 0; width: 100%; }
.input:focus, .select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.field-error { color: var(--bad); font-size: .8rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .input { max-width: 280px; }
.toolbar .select { width: auto; }
.price-input { width: 96px; text-align: right; }
.qty-input { width: 80px; text-align: right; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .85rem; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; width: 16px; height: 16px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 18px; }
.switch input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: 0; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--surface-alt); }
td a.rowlink { color: var(--ink); font-weight: 600; text-decoration: none; }
td a.rowlink:hover { text-decoration: underline; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--surface-alt); color: var(--muted); border: 1px solid var(--line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-darker); border-color: transparent; }
.badge.plain::before { display: none; }
.sim-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--info); background: var(--info-soft); border-radius: 6px; padding: 1px 7px; }

/* Notices */
.notice { border-radius: var(--radius-sm); padding: 10px 14px; font-size: .88rem; border: 1px solid var(--line); background: var(--surface-alt); }
.notice.info { background: var(--info-soft); border-color: transparent; color: var(--ink-soft); }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--ink-soft); }
.notice.bad { background: var(--bad-soft); border-color: transparent; color: var(--ink-soft); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h3 { margin-bottom: 4px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); align-items: center; }
.list li:last-child { border-bottom: 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .9rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; color: var(--ink); }

/* Order timeline */
.steps { display: flex; gap: 0; list-style: none; padding: 0; margin: 0; }
.steps li { flex: 1; text-align: center; font-size: .78rem; color: var(--muted); position: relative; padding-top: 22px; }
.steps li::before { content: ""; position: absolute; top: 6px; left: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--line); transform: translateX(-50%); z-index: 1; }
.steps li::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.steps li:first-child::after { display: none; }
.steps li.done { color: var(--ink); }
.steps li.done::before, .steps li.done::after { background: var(--ok); }
.steps li.current { color: var(--accent-darker); font-weight: 700; }
.steps li.current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* Charts (SVG) */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: color-mix(in srgb, var(--accent) 35%, var(--surface)); }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter svg { display: block; width: 100%; height: 8px; }
.meter rect.fill { fill: var(--ok); }
.meter rect.fill.low { fill: var(--warn); }
.meter rect.fill.out { fill: var(--bad); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent-darker); border-color: var(--accent); }

/* Modifier preview */
.mod-group { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 12px; }
.mod-group legend { font-weight: 700; color: var(--ink); padding: 0 6px; }
.mod-group .rule { font-size: .78rem; color: var(--muted); margin-left: 6px; font-weight: 500; }
.mod-group[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-soft); }
.choice { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.choice .price { margin-left: auto; color: var(--muted); font-size: .85rem; }

/* Dialog */
dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: 560px; width: calc(100% - 32px); background: var(--surface); color: var(--body); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(11,16,32,.5); }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dialog-body { padding: 16px 20px; display: grid; gap: 12px; max-height: 70vh; overflow-y: auto; }
.dialog-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 90; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .88rem; display: flex; gap: 10px; align-items: flex-start; animation: toast-in .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok::before { content: "✓"; font-weight: 700; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } * { transition: none !important; } }

/* POS log */
.log { font-family: var(--mono); font-size: .8rem; background: var(--surface-alt); border-radius: var(--radius-sm); padding: 10px 12px; max-height: 260px; overflow-y: auto; margin: 0; list-style: none; }
.log li { padding: 2px 0; display: flex; gap: 10px; }
.log .t { color: var(--muted); flex: none; }
.log .lvl-error { color: var(--bad); }
.log .lvl-warn { color: var(--warn); }
.log .lvl-ok { color: var(--ok); }

/* Welcome / login */
.welcome { min-height: calc(100vh - 34px); display: grid; place-items: center; padding: 32px 16px; background: linear-gradient(160deg, #0b1020, #131b31); }
.welcome-card { background: var(--surface); border-radius: 20px; max-width: 520px; width: 100%; padding: 32px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.welcome-card .brand { padding: 0 0 18px; }
.welcome-card h1 { font-size: 1.6rem; margin-bottom: 8px; }
.welcome-card ul { padding-left: 18px; margin: 12px 0 20px; }
.persona-card { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 14px 0; }
.welcome-card .btn { padding: 10px 18px; font-size: .95rem; }

/* Tour */
.tour-pop { position: fixed; z-index: 95; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 48px rgba(0,0,0,.25); padding: 16px 18px; right: 24px; bottom: 24px; }
.tour-pop h2 { font-size: 1rem; margin-bottom: 6px; }
.tour-pop .meta { font-size: .75rem; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.tour-target { outline: 3px solid var(--accent) !important; outline-offset: 3px; border-radius: 10px; }

/* Responsive */
@media (max-width: 1080px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  /* Closed: hidden as well as moved off-screen, so its links leave the tab order. */
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: 270px; z-index: 80; transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility 0s linear .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: none; visibility: visible; transition: transform .2s; }
  .scrim { position: fixed; inset: 0; background: rgba(11,16,32,.45); z-index: 70; }
  .topbar { padding: 10px 16px; top: 0; position: relative; flex-wrap: wrap; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px 16px 64px; }
  .grid.halves { grid-template-columns: minmax(0, 1fr); }
  .tour-pop { left: 16px; right: 16px; bottom: 16px; max-width: none; }
  th, td { padding: 9px 12px; }
  .hide-sm { display: none; }
  .toolbar .input { max-width: none; flex: 1 1 100%; }
}
@media (max-width: 480px) {
  .grid.kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 1.3rem; }
  .welcome-card { padding: 22px; }
  .disclosure { font-size: .75rem; gap: 6px; }
}

/* Vertical rhythm between top-level page sections. */
.content > * + * { margin-top: 16px; }
.content > .page-head + * { margin-top: 0; }
.order-items td .mods { font-size: .82rem; color: var(--muted); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; padding: 14px 20px; border-top: 1px solid var(--line); font-size: .92rem; }
.totals .grand { font-weight: 700; color: var(--ink); font-size: 1rem; }
.timeline { list-style: none; margin: 0; padding: 12px 20px; }
.timeline li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 6px 0; font-size: .88rem; border-bottom: 1px dashed var(--line); }
.timeline li:last-child { border-bottom: 0; }
.result-count { margin-left: auto; font-size: .85rem; color: var(--muted); }
@media (max-width: 820px) { .result-count { margin-left: 0; } .timeline li { grid-template-columns: 1fr; gap: 0; } }
