/* ═════ Themes ═════ */
:root, [data-theme="light"] {
  --bg: #F7F7F5; --panel: #FFFFFF; --panel-2: #F2F2EF; --text: #17181B; --muted: #6B6E76; --faint: #9A9CA3;
  --line: #E6E6E1; --line-2: #EFEFEB; --primary: #C4532D; --primary-ink: #fff; --hover: rgba(23, 24, 27, .05);
  --ok: #1C7A40; --ok-bg: #E2F3E7; --warn: #985E00; --warn-bg: #FFF0D3; --info: #2A5BD7; --info-bg: #E5ECFC; --bad: #B4232C; --bad-bg: #FCE4E5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #111214; --panel: #18191C; --panel-2: #202125; --text: #EDEDEC; --muted: #9A9CA3; --faint: #6E7077;
  --line: #2A2B30; --line-2: #222327; --primary: #E2683F; --primary-ink: #fff; --hover: rgba(237, 237, 236, .06);
  --ok: #57C985; --ok-bg: rgba(87, 201, 133, .12); --warn: #F0B14A; --warn-bg: rgba(240, 177, 74, .12); --info: #7FA2FF; --info-bg: rgba(127, 162, 255, .12); --bad: #FF7A80; --bad-bg: rgba(255, 122, 128, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root { --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "Geist Mono", ui-monospace, Menlo, monospace; --ease: cubic-bezier(.23, 1, .32, 1); --drawer: cubic-bezier(.32, .72, 0, 1); --row: 52px; }
[data-density="compact"] { --row: 40px; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.015em; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; font: 500 11px var(--mono); color: var(--muted); background: var(--panel-2); box-shadow: inset 0 -1px 0 var(--line); }
.muted { color: var(--muted); }
.theme-swap, .theme-swap * { transition: none !important; }   /* no colour fades when switching themes */

/* ═════ Buttons ═════ */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 500; font-size: 14px; transition: transform .14s var(--ease), background-color .15s, box-shadow .15s; user-select: none; }
.btn:active { transform: scale(.97); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary kbd { background: rgba(255, 255, 255, .18); color: inherit; box-shadow: none; }
.btn-ghost { box-shadow: inset 0 0 0 1px var(--line); }
.btn-inverse { background: rgba(255, 255, 255, .12); color: #fff; }
.btn:disabled { opacity: .4; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter: brightness(1.06); }
  .btn-ghost:hover:not(:disabled) { background: var(--hover); }
  .btn-inverse:hover { background: rgba(255, 255, 255, .2); }
}
.icon-btn { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); transition: background-color .15s, color .15s; }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn svg, .side-nav svg, .search svg, .search-trigger svg, .cmd-input svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { background: var(--hover); color: var(--text); } }

/* ═════ Layout ═════ */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 6px; padding: 16px 12px; border-right: 1px solid var(--line); background: var(--bg); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 600; font-size: 15px; }
.side-brand em { font-style: normal; color: var(--muted); font-weight: 400; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-weight: 500; transition: background-color .15s, color .15s; }
.side-nav a kbd, .side-nav .count { margin-left: auto; }
.side-nav a kbd { opacity: 0; transition: opacity .15s; }
.side-nav .count { font: 500 11.5px var(--mono); padding: 1px 7px; border-radius: 999px; background: var(--panel-2); font-variant-numeric: tabular-nums; }
.side-nav a[aria-current="page"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
@media (hover: hover) and (pointer: fine) { .side-nav a:hover { color: var(--text); background: var(--hover); } .side-nav a:hover kbd { opacity: 1; } }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding: 8px; }
.kbd-hint { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.demo-note { margin: 0; font-size: 12px; color: var(--faint); line-height: 1.45; }
.demo-note a { text-decoration: underline; text-underline-offset: 2px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.menu-toggle { display: none; }
.search-trigger { flex: 1; max-width: 460px; height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 8px 0 12px; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); color: var(--faint); text-align: left; transition: box-shadow .15s; }
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .search-trigger:hover { box-shadow: inset 0 0 0 1px var(--faint); } }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: block; } [data-theme="dark"] .i-moon { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font: 600 12px var(--sans); }
.content { padding: 28px 24px 120px; max-width: 1280px; width: 100%; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.view-head h1 { font-size: 24px; }
.sub { margin: 4px 0 0; color: var(--muted); }

/* Segmented */
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--panel-2); gap: 2px; }
.seg button { height: 30px; padding: 0 12px; border-radius: 7px; font-weight: 500; font-size: 13px; color: var(--muted); transition: color .15s, background-color .15s; }
.seg button[aria-checked="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

/* ═════ Overview ═════ */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: var(--panel); border-radius: 14px; padding: 16px; box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 4px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font: 600 26px/1.15 var(--sans); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.delta { font: 500 12px var(--mono); padding: 2px 6px; border-radius: 6px; }
.delta.up { color: var(--ok); background: var(--ok-bg); }
.delta.down { color: var(--bad); background: var(--bad-bg); }
.spark { width: 84px; height: 26px; }
.spark path { fill: none; stroke: var(--primary); stroke-width: 1.6; stroke-linejoin: round; }
.panels { display: grid; grid-template-columns: 1.7fr 1fr; gap: 12px; margin-top: 12px; }
.panel { background: var(--panel); border-radius: 14px; padding: 18px; box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; }
.panel-head.mt { margin-top: 22px; }
.link { color: var(--primary); font-weight: 500; font-size: 13px; }
.chart { position: relative; }
#chart { display: block; width: 100%; height: 260px; overflow: visible; }
#chart .gl { stroke: var(--line-2); }
#chart .ax { fill: var(--faint); font: 500 11px var(--mono); }
#chart .area { fill: url(#gArea); }
#chart .ln { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
#chart .cross { stroke: var(--faint); stroke-dasharray: 3 3; }
#chart .dot { fill: var(--panel); stroke: var(--primary); stroke-width: 2; }
.tip { position: absolute; pointer-events: none; padding: 8px 10px; border-radius: 9px; background: var(--text); color: var(--bg); font: 500 12px/1.45 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; }
.bars b { font-weight: 500; }
.bars span { font: 500 12.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.bars i { grid-column: 1 / -1; height: 8px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.bars i::after { content: ""; display: block; height: 100%; width: 100%; border-radius: 6px; background: var(--c); transform-origin: left; transform: scaleX(var(--v, 0)); transition: transform .3s var(--ease); }
.queue { list-style: none; margin: 0; padding: 0; }
.queue li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-2); font-size: 13.5px; }
.queue li span:last-child { color: var(--muted); font-family: var(--mono); font-size: 12.5px; }

/* ═════ Orders ═════ */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.search { flex: 1; min-width: 220px; max-width: 360px; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 10px; border-radius: 9px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); color: var(--faint); }
.search:focus-within { box-shadow: inset 0 0 0 2px var(--primary); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: 16px var(--sans); }  /* 16px avoids iOS zoom */
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); transition: background-color .15s, color .15s; display: inline-flex; align-items: center; gap: 6px; }
.filters button span { font: 500 11px var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }
.filters button[aria-selected="true"] { background: var(--text); color: var(--bg); box-shadow: none; }
.filters button[aria-selected="true"] span { color: inherit; opacity: .7; }
.table-wrap { background: var(--panel); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); overflow-x: auto; overscroll-behavior-x: contain; }
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; text-align: left; font: 500 12px var(--sans); color: var(--muted); height: 40px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.table th button { display: inline-flex; align-items: center; gap: 4px; height: 28px; border-radius: 6px; color: inherit; }
.table th button::after { content: "↕"; font-size: 11px; opacity: 0; }
.table th button[aria-sort="ascending"]::after { content: "↑"; opacity: 1; }
.table th button[aria-sort="descending"]::after { content: "↓"; opacity: 1; }
@media (hover: hover) and (pointer: fine) { .table th button:hover::after { opacity: .5; } .table th button:hover { color: var(--text); } }
.table td { height: var(--row); padding: 0 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table tbody tr { cursor: pointer; transition: background-color .12s; }
@media (hover: hover) and (pointer: fine) { .table tbody tr:hover { background: var(--hover); } }
.table tbody tr.sel { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num button { flex-direction: row-reverse; }
.c-check { width: 44px; }
.table input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.table .oid { font: 500 13px var(--mono); }
.cust { display: flex; align-items: center; gap: 10px; }
.cust i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 600 10.5px var(--sans); font-style: normal; color: #fff; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-Roasting { color: var(--warn); background: var(--warn-bg); }
.s-Shipped { color: var(--info); background: var(--info-bg); }
.s-Delivered { color: var(--ok); background: var(--ok-bg); }
.s-Refunded { color: var(--bad); background: var(--bad-bg); }
.row-flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 0% { background: color-mix(in srgb, var(--primary) 22%, transparent); } }
.empty { display: grid; justify-items: center; gap: 10px; padding: 50px 20px; color: var(--muted); text-align: center; }
.empty p { margin: 0; }
.empty b { color: var(--text); font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 13px; }
.pager-btns { display: flex; gap: 6px; }
.bulk {
  position: fixed; z-index: 30; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 16px; border-radius: 14px; background: #17181B; color: #fff; box-shadow: 0 16px 40px rgba(0, 0, 0, .3);
  transform: translateX(-50%); animation: bulkIn .18s var(--ease);
}
[data-theme="dark"] .bulk { background: #2A2B30; }
.bulk span { font-size: 13.5px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.bulk .icon-btn { color: rgba(255, 255, 255, .7); }
@keyframes bulkIn { from { transform: translate(-50%, 16px); opacity: 0; } }

/* ═════ Settings ═════ */
.settings { background: var(--panel); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); max-width: 760px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line-2); }
.setting:last-child { border-bottom: 0; }
.setting h2 { font-size: 15px; }
.setting p { margin: 2px 0 0; font-size: 13.5px; }
.switch { width: 44px; height: 26px; border-radius: 999px; padding: 3px; background: var(--line); transition: background-color .2s; flex: none; }
.switch i { display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .3s cubic-bezier(.34, 1.3, .64, 1); }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"] i { transform: translateX(18px); }

/* ═════ Detail sheet ═════ */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 10, 12, .35); opacity: 0; transition: opacity .35s var(--drawer); }
.scrim.on { opacity: 1; }
.detail { position: fixed; z-index: 50; top: 8px; right: 8px; bottom: 8px; width: min(440px, calc(100% - 16px)); border-radius: 16px; background: var(--panel); box-shadow: 0 20px 60px rgba(0, 0, 0, .25), inset 0 0 0 1px var(--line); display: flex; flex-direction: column; transform: translateX(calc(100% + 16px)); transition: transform .3s var(--drawer); }
.detail.on { transform: none; }
.detail-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line-2); }
.detail-head h2 { font-size: 17px; }
.detail-body { padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 18px; align-content: start; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.d-grid div { padding: 12px; border-radius: 10px; background: var(--panel-2); }
.d-grid span { display: block; font-size: 12px; color: var(--muted); }
.d-grid b { font-weight: 500; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.timeline li::after { content: ""; position: absolute; left: 7.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--primary); }
.timeline small { display: block; color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ═════ Command menu (opens instantly: it's keyboard-driven) ═════ */
.cmd-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(10, 10, 12, .35); display: grid; justify-items: center; align-items: start; padding: 12vh 16px 16px; }
.cmd, .help { width: min(560px, 100%); border-radius: 14px; background: var(--panel); box-shadow: 0 24px 70px rgba(0, 0, 0, .3), inset 0 0 0 1px var(--line); overflow: hidden; }
.cmd-input { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; border-bottom: 1px solid var(--line-2); color: var(--faint); }
.cmd-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 16px var(--sans); color: var(--text); }
.cmd-list { list-style: none; margin: 0; padding: 6px; max-height: 360px; overflow-y: auto; }
.cmd-list .grp { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 500; color: var(--faint); }
.cmd-list [role="option"] { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 8px; cursor: pointer; }
.cmd-list [role="option"] kbd { margin-left: auto; }
.cmd-list [role="option"] .k { margin-left: auto; color: var(--faint); font: 500 12px var(--mono); }
.cmd-list [aria-selected="true"] { background: var(--hover); }
.cmd-list mark { background: none; color: var(--primary); font-weight: 600; }
.cmd-empty { padding: 26px; text-align: center; color: var(--muted); }
.keys { margin: 0; padding: 10px 20px 18px; display: grid; }
.keys div { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.keys div:last-child { border-bottom: 0; }
.keys dt { display: flex; gap: 4px; }
.keys dd { margin: 0; color: var(--muted); }

/* ═════ Toasts ═════ */
.toasts { position: fixed; z-index: 70; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: min(360px, calc(100% - 32px)); list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 12px; background: var(--panel); box-shadow: 0 14px 40px rgba(0, 0, 0, .18), inset 0 0 0 1px var(--line); font-size: 13.5px; transition: transform .3s var(--ease), opacity .3s var(--ease); }
.toast.pre, .toast.out { transform: translateY(14px); opacity: 0; }
.toast .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-bg); color: var(--ok); font-size: 11px; font-weight: 700; }
.toast span:not(.ic) { flex: 1; }
.toast button { font-weight: 500; color: var(--primary); padding: 6px 8px; border-radius: 6px; }


/* ═════ Responsive ═════ */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .panels { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 45; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .3s var(--drawer); box-shadow: 20px 0 50px rgba(0, 0, 0, .15); }
  .side.open { transform: none; }
  .menu-toggle { display: grid; }
  .topbar { padding: 0 14px; }
  .search-trigger kbd { display: none; }
  .content { padding: 22px 14px 120px; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi b { font-size: 21px; } .spark { width: 60px; } .search { max-width: none; } .setting { flex-wrap: wrap; } }
/* Reduced motion means gentler, not none: panels and toasts fade instead of sliding;
   colour changes, the row highlight and the switch stay as quick feedback. */
@media (prefers-reduced-motion: reduce) {
  .detail, .detail.on { transform: none; transition: opacity .2s ease; }
  .detail:not(.on) { opacity: 0; }
  .side { transition: none; }
  .toast, .toast.pre, .toast.out { transform: none; transition: opacity .2s ease; }
  .bulk { animation: none; }
  .bars i::after { transition: none; }
}
