/* Counter — an app for selling by chat. Tokens first; see DESIGN.md. */
:root {
  color-scheme: light;
  --ground: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --surface-3: #eef0ec;
  --line: #e3e6e0;
  --line-2: #d2d6cf;
  --ink: #121714;
  --ink-2: #3c443f;
  --ink-3: #5f6862;
  --ink-4: #949b96;
  --rail: #13201b;
  --rail-2: #1d2c26;
  --rail-ink: #a7b5ae;
  --rail-ink-on: #ffffff;
  --accent: #c2410c;
  --accent-hover: #a5370a;
  --accent-soft: #fdf1eb;
  --accent-line: #f3cbb7;
  --accent-ink: #a3360a;
  --on-accent: #ffffff;
  --ok: #177245;  --ok-soft: #e7f4ed;  --ok-line: #bfe2cd;
  --warn: #8f560a; --warn-soft: #fcf2e1; --warn-line: #efd7a6;
  --danger: #b92d23; --danger-soft: #fcecea; --danger-line: #f3c5c0;
  --muted-soft: #eef0ec; --muted-line: #d9ddd6;
  --note: #fbf5de; --note-line: #ebdfab;
  --bubble-out: #e9efea;
  --scrim: rgba(10, 16, 13, .42);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--accent) 70%, transparent);
  --shadow-float: 0 1px 2px rgba(16, 24, 20, .06), 0 8px 24px -6px rgba(16, 24, 20, .16), 0 24px 48px -12px rgba(16, 24, 20, .14);
  --shadow-raise: 0 1px 2px rgba(16, 24, 20, .05), 0 2px 6px -2px rgba(16, 24, 20, .08);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --t-11: 11px; --t-12: 12px; --t-13: 13px; --t-14: 14px; --t-16: 16px; --t-20: 20px; --t-28: 28px; --t-40: 40px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 48px;
  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --rail-w: 72px; --list-w: 340px; --panel-w: 320px; --bar-h: 56px; --row-h: 48px; --ctrl-h: 34px;
  --ease: cubic-bezier(.2, 0, 0, 1); --dur-1: 120ms; --dur-2: 180ms; --dur-3: 240ms;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0b0e0d; --surface: #111514; --surface-2: #151a18; --surface-3: #1c2220;
    --line: #232a27; --line-2: #313935;
    --ink: #eceeec; --ink-2: #bcc3be; --ink-3: #8e9691; --ink-4: #5f6763;
    --rail: #070a09; --rail-2: #16201c; --rail-ink: #8e9a94; --rail-ink-on: #ffffff;
    --accent: #ff8a5c; --accent-hover: #ffa47f; --accent-soft: #2a1911; --accent-line: #5a2f1b; --accent-ink: #ffac8b; --on-accent: #1f0c04;
    --ok: #5ccf91; --ok-soft: #0f2419; --ok-line: #1f4a33;
    --warn: #e8b15c; --warn-soft: #291f0f; --warn-line: #54401c;
    --danger: #f38479; --danger-soft: #2b1412; --danger-line: #5a2a25;
    --muted-soft: #1c2220; --muted-line: #2c3431;
    --note: #241f10; --note-line: #4a3f1c; --bubble-out: #1b2521;
    --scrim: rgba(0, 0, 0, .6);
    --shadow-float: 0 0 0 1px var(--line-2), 0 12px 32px -8px rgba(0, 0, 0, .6);
    --shadow-raise: 0 0 0 1px var(--line);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0b0e0d; --surface: #111514; --surface-2: #151a18; --surface-3: #1c2220;
  --line: #232a27; --line-2: #313935;
  --ink: #eceeec; --ink-2: #bcc3be; --ink-3: #8e9691; --ink-4: #5f6763;
  --rail: #070a09; --rail-2: #16201c; --rail-ink: #8e9a94; --rail-ink-on: #ffffff;
  --accent: #ff8a5c; --accent-hover: #ffa47f; --accent-soft: #2a1911; --accent-line: #5a2f1b; --accent-ink: #ffac8b; --on-accent: #1f0c04;
  --ok: #5ccf91; --ok-soft: #0f2419; --ok-line: #1f4a33;
  --warn: #e8b15c; --warn-soft: #291f0f; --warn-line: #54401c;
  --danger: #f38479; --danger-soft: #2b1412; --danger-line: #5a2a25;
  --muted-soft: #1c2220; --muted-line: #2c3431;
  --note: #241f10; --note-line: #4a3f1c; --bubble-out: #1b2521;
  --scrim: rgba(0, 0, 0, .6);
  --shadow-float: 0 0 0 1px var(--line-2), 0 12px 32px -8px rgba(0, 0, 0, .6);
  --shadow-raise: 0 0 0 1px var(--line);
}

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface); color: var(--ink);
  font: 400 var(--t-14)/1.45 var(--font); font-feature-settings: "ss01";
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { top: 8px; }
.icon { width: 18px; height: 18px; flex: none; }
.icon--sm { width: 16px; height: 16px; }
.icon--xs { width: 14px; height: 14px; }

/* ── Shell ─────────────────────────────── */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--rail);
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 0; z-index: 30;
}
.rail__brand { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--rail-2); color: #f3cbb7; margin-bottom: 14px; }
.rail__brand svg { width: 22px; height: 22px; }
.rail__nav, .rail__foot { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.rail__foot { margin-top: auto; }
.rail-item {
  position: relative; width: 60px; padding: 8px 0 6px; border-radius: var(--r-md); border: 0; background: none;
  color: var(--rail-ink); display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 500; letter-spacing: .01em;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.rail-item .icon { width: 20px; height: 20px; }
.rail-item:hover { background: var(--rail-2); color: var(--rail-ink-on); }
.rail-item[aria-current="page"] { background: var(--rail-2); color: var(--rail-ink-on); }
.rail-item[aria-current="page"]::before { content: ""; position: absolute; left: -6px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.rail-item:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.rail-badge { position: absolute; top: 3px; left: 34px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent); font-size: 10.5px; font-weight: 600; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--rail); }
.rail-item--icon { padding: 9px 0; }
.rail-item--icon .rail-label { display: none; }
.avatar-btn { width: 34px; height: 34px; margin-top: 8px; border-radius: 50%; border: 0; background: #f3cbb7; color: #5b1f06; font-weight: 600; font-size: 12px; }
.tip {
  position: absolute; left: calc(100% + 10px); top: 50%; translate: 0 -50%; white-space: nowrap; pointer-events: none;
  background: var(--ink); color: var(--surface); font-size: 12px; padding: 5px 8px; border-radius: var(--r-sm); opacity: 0;
  transition: opacity var(--dur-1) var(--ease); display: flex; gap: 6px; align-items: center; z-index: 50;
}
.rail-item:hover .tip, .rail-item:focus-visible .tip { opacity: 1; transition-delay: 300ms; }
.tip kbd { background: color-mix(in srgb, var(--surface) 18%, transparent); color: inherit; border-color: transparent; }

.main { min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--bar-h); display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-6); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--t-14); color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); }
.crumbs .icon { color: var(--ink-4); width: 14px; height: 14px; }
.crumbs [aria-current] { color: var(--ink); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.search-trigger {
  display: flex; align-items: center; gap: 8px; height: var(--ctrl-h); width: 260px; padding: 0 8px 0 10px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-3); font-size: var(--t-13);
}
.search-trigger:hover { border-color: var(--line-2); color: var(--ink-2); }
.search-trigger span { flex: 1; text-align: left; }
kbd {
  font-family: var(--mono); font-size: 11px; line-height: 1; min-width: 20px; height: 20px; padding: 0 5px; display: inline-grid; place-items: center;
  border-radius: var(--r-xs); border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface); color: var(--ink-3);
}
.page { padding: var(--s-6) var(--s-6) var(--s-9); max-width: 1320px; width: 100%; }
.page--narrow { max-width: 1080px; }
.page-head { display: flex; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-head h1 { font-size: var(--t-28); font-weight: 600; letter-spacing: -.025em; line-height: 1.1; }
.page-head p { color: var(--ink-3); margin-top: 6px; font-size: var(--t-14); }
.page-head__actions { margin-left: auto; display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ── Buttons, fields, pills ─────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctrl-h); padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: var(--t-13); font-weight: 550; white-space: nowrap; box-shadow: 0 1px 0 rgba(16, 24, 20, .03);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 2px rgba(120, 40, 6, .25); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { border-color: var(--danger-line); background: var(--danger-soft); }
.btn--sm { height: 28px; padding: 0 9px; font-size: var(--t-12); }
.btn--icon { width: var(--ctrl-h); padding: 0; }
.btn--icon.btn--sm { width: 28px; }
.btn kbd { height: 18px; min-width: 18px; font-size: 10.5px; margin-left: 2px; }
.btn--primary kbd { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .25); color: inherit; }
.btn[aria-busy="true"] { pointer-events: none; opacity: .8; }
.btn[aria-busy="true"] .icon { animation: spin .8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

.input, .select, .textarea {
  width: 100%; height: var(--ctrl-h); padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface); font-size: var(--t-14); transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 10px; color: var(--ink-4); pointer-events: none; }
.input-wrap > .input { padding-left: 34px; }
.input-wrap > .affix { position: absolute; left: 11px; color: var(--ink-3); font-weight: 500; pointer-events: none; }
.input-wrap > .affix + .input { padding-left: 28px; }
.input-wrap > kbd { position: absolute; right: 7px; }
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .field .label { font-size: var(--t-13); font-weight: 550; color: var(--ink); }
.field .help { font-size: var(--t-12); color: var(--ink-3); }
.field .error { font-size: var(--t-12); color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.field .error .icon { width: 14px; height: 14px; margin-top: 1px; }
.field .error[hidden] { display: none; }
.opt { color: var(--ink-4); font-weight: 400; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 7px; border-radius: var(--r-pill);
  font-size: var(--t-12); font-weight: 550; white-space: nowrap; border: 1px solid var(--muted-line); background: var(--muted-soft); color: var(--ink-2);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill--ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.pill--warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.pill--danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.pill--accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.pill--hollow { background: transparent; }
.pill--hollow::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.pill--sm { height: 20px; font-size: 11.5px; padding: 0 7px 0 6px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--ink-2); font-size: var(--t-12); font-weight: 500; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: var(--t-13); font-weight: 500; white-space: nowrap;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip .count { font-size: var(--t-12); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .count, .chip[aria-selected="true"] .count { color: color-mix(in srgb, var(--surface) 70%, transparent); }

.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); letter-spacing: .01em; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }
.avatar--xs { width: 20px; height: 20px; font-size: 9.5px; }

.panel { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.panel__head { display: flex; align-items: center; gap: var(--s-2); padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 48px; }
.panel__head h2 { font-size: var(--t-14); font-weight: 600; }
.panel__head .btn { margin-left: auto; }
.panel__body { padding: 16px; }

/* ── Inbox ─────────────────────────────── */
.inbox { display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr) var(--panel-w); height: 100vh; height: 100dvh; min-height: 0; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane--list { border-right: 1px solid var(--line); background: var(--surface-2); }
.pane--side { border-left: 1px solid var(--line); background: var(--surface-2); }
.pane__head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.pane__title { display: flex; align-items: center; gap: 8px; }
.pane__title h1 { font-size: var(--t-20); font-weight: 600; letter-spacing: -.02em; }
.pane__title .count { color: var(--ink-3); font-size: var(--t-13); font-variant-numeric: tabular-nums; }
.pane__title .btn:first-of-type { margin-left: auto; }
.pane__scroll { overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { height: 28px; padding: 0 9px; font-size: var(--t-12); }

.convo { position: relative; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 12px 16px 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background var(--dur-1) var(--ease); }
.convo:hover { background: var(--surface-3); }
.convo[aria-current="true"] { background: var(--surface); }
.convo[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.convo__top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.convo__name { font-weight: 550; font-size: var(--t-14); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo__link::after { content: ""; position: absolute; inset: 0; }
.convo__link:focus-visible { box-shadow: none; }
.convo__link:focus-visible::after { box-shadow: inset 0 0 0 2px var(--accent); }
.convo__channel { color: var(--ink-4); display: inline-flex; }
.convo__channel .icon { width: 13px; height: 13px; }
.convo__time { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.convo__preview { color: var(--ink-3); font-size: var(--t-13); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.convo__meta { display: flex; gap: 6px; align-items: center; margin-top: 7px; flex-wrap: wrap; }
.convo__meta .mono { font-size: 11px; color: var(--ink-3); }
.convo--unread .convo__name { font-weight: 650; }
.convo--unread .convo__preview { color: var(--ink); }
.convo--unread .convo__time { color: var(--accent-ink); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; align-self: center; }
.reply-flag { display: inline-flex; gap: 4px; align-items: center; font-size: 11.5px; font-weight: 550; color: var(--ink-2); }
.reply-flag .icon { width: 13px; height: 13px; color: var(--accent); }

.thread-head { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); flex: none; }
.thread-head h2 { font-size: var(--t-16); font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .sub { font-size: var(--t-12); color: var(--ink-3); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.thread-head__who { min-width: 0; }
.thread-head__actions { margin-left: auto; display: flex; gap: 4px; }
.back-btn { display: none; }
.thread { flex: 1; overflow-y: auto; padding: 24px 24px 12px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); }
.thread > * { max-width: 640px; }
.day { align-self: center; max-width: none; margin: 14px 0 10px; font-size: var(--t-12); color: var(--ink-3); font-weight: 500; display: flex; align-items: center; gap: 10px; width: 100%; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 10px; }
.msg + .msg--cont { margin-top: 0; }
.msg--out { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 9px 13px; border-radius: 16px 16px 16px 6px; border: 1px solid var(--line); background: var(--surface);
  max-width: min(100%, 520px); font-size: var(--t-14); line-height: 1.5; overflow-wrap: anywhere; box-shadow: 0 1px 0 rgba(16, 24, 20, .03);
}
.msg--out .bubble { background: var(--bubble-out); border-color: transparent; border-radius: 16px 16px 6px 16px; }
.msg--cont .bubble { border-top-left-radius: 6px; }
.msg--out.msg--cont .bubble { border-top-left-radius: 16px; border-top-right-radius: 6px; }
.msg--note .bubble { background: var(--note); border-color: var(--note-line); border-radius: var(--r-md); }
.msg__meta { font-size: 11px; color: var(--ink-3); margin-top: 4px; display: flex; gap: 5px; align-items: center; padding: 0 4px; }
.msg__meta .icon { width: 13px; height: 13px; }
.msg__meta .tick { color: var(--ok); }
.msg__meta .pending { color: var(--ink-4); }
.msg__meta .note-label { display: inline-flex; gap: 4px; align-items: center; color: var(--warn); font-weight: 550; }
.event { align-self: center; max-width: none; margin: 12px 0; display: inline-flex; gap: 8px; align-items: center; font-size: var(--t-12); color: var(--ink-3); padding: 4px 10px 4px 8px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); }
.event .icon { width: 14px; height: 14px; }
.event strong { color: var(--ink-2); font-weight: 550; }
.event--ok .icon { color: var(--ok); }

.card-msg { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); width: 320px; max-width: 100%; text-align: left; box-shadow: var(--shadow-raise); }
.card-msg img { width: 64px; height: 64px; border-radius: 7px; object-fit: cover; }
.card-msg__name { font-weight: 550; font-size: var(--t-13); }
.card-msg__sub { font-size: var(--t-12); color: var(--ink-3); }
.card-msg__price { font-weight: 600; font-size: var(--t-14); margin-top: 2px; }
.invoice { width: 340px; max-width: 100%; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-raise); overflow: hidden; }
.invoice__head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px dashed var(--line-2); }
.invoice__head .icon { color: var(--ink-3); }
.invoice__head strong { font-size: var(--t-13); }
.invoice__head .pill { margin-left: auto; }
.invoice__lines { padding: 8px 12px; display: grid; gap: 4px; font-size: var(--t-13); }
.invoice__line, .ticket__line, .sum__row { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; }
.invoice__line span:last-child, .sum__row span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice__total { display: flex; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--line); font-weight: 600; font-variant-numeric: tabular-nums; }
.invoice__foot { padding: 8px 12px 10px; display: flex; gap: 8px; align-items: center; font-size: var(--t-12); color: var(--ink-3); background: var(--surface-2); border-top: 1px solid var(--line); }
.invoice__foot .btn { margin-left: auto; }

.composer { flex: none; border-top: 1px solid var(--line); padding: 10px 16px 14px; background: var(--surface); }
.quick { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 10px; }
.quick::-webkit-scrollbar { display: none; }
.quick button { flex: none; height: 26px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface-2); font-size: var(--t-12); color: var(--ink-2); font-weight: 500; }
.quick button:hover { border-color: var(--line-2); color: var(--ink); background: var(--surface); }
.composer__box { border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--surface); transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); }
.composer__box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.composer[data-mode="note"] .composer__box { background: var(--note); border-color: var(--note-line); }
.composer__tabs { display: flex; gap: 2px; padding: 6px 6px 0; }
.composer__tabs button { height: 26px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; font-size: var(--t-12); font-weight: 550; color: var(--ink-3); }
.composer__tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--ink); }
.composer[data-mode="note"] .composer__tabs button[aria-selected="true"] { background: var(--note-line); }
.composer textarea { display: block; width: 100%; border: 0; background: transparent; resize: none; padding: 8px 12px; min-height: 44px; max-height: 160px; line-height: 1.5; font-size: var(--t-14); }
.composer textarea:focus { outline: none; }
.composer__tools { display: flex; align-items: center; gap: 2px; padding: 4px 6px 6px; }
.composer__tools .btn--primary { margin-left: auto; }
.composer__hint { font-size: 11px; color: var(--ink-4); margin-left: 8px; }

/* customer panel */
.side-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.side-sec { padding: 16px; border-bottom: 1px solid var(--line); }
.side-sec h3 { font-size: var(--t-12); font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; display: flex; align-items: center; }
.side-sec h3 a, .side-sec h3 button { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 550; color: var(--accent-ink); font-size: var(--t-12); background: none; border: 0; padding: 0; }
.who { display: flex; gap: 12px; align-items: center; }
.who h2 { font-size: var(--t-16); font-weight: 600; letter-spacing: -.01em; }
.who p { font-size: var(--t-12); color: var(--ink-3); }
.kv { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px 8px; font-size: var(--t-13); margin-top: 14px; align-items: center; }
.kv .icon { color: var(--ink-4); width: 15px; height: 15px; }
.kv span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.facts > div { padding: 8px 10px; }
.facts > div + div { border-left: 1px solid var(--line); }
.facts dt { font-size: 11px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: var(--t-14); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-orders li { display: flex; gap: 8px; align-items: center; padding: 6px 0; font-size: var(--t-13); }
.mini-orders li + li { border-top: 1px solid var(--line); }
.mini-orders .mono { color: var(--ink-2); }
.mini-orders .num { margin-left: auto; font-weight: 550; }
.note-text { font-size: var(--t-13); color: var(--ink-2); line-height: 1.5; }

/* The running ticket */
.ticket { margin: 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-raise); flex: none; }
.ticket__head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px dashed var(--line-2); }
.ticket__head strong { font-size: var(--t-13); }
.ticket__head .mono { color: var(--ink-3); font-size: 11.5px; }
.ticket__head .pill { margin-left: auto; }
.ticket__lines { padding: 6px 12px; display: grid; }
.ticket__line { padding: 6px 0; font-size: var(--t-13); align-items: center; }
.ticket__line + .ticket__line { border-top: 1px solid var(--line); }
.ticket__line .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket__line .num { min-width: 62px; text-align: right; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); height: 24px; }
.stepper button { width: 22px; height: 22px; border: 0; background: none; color: var(--ink-3); display: grid; place-items: center; border-radius: 5px; }
.stepper button:hover { background: var(--surface-3); color: var(--ink); }
.stepper button .icon { width: 12px; height: 12px; }
.stepper output { min-width: 18px; text-align: center; font-size: var(--t-12); font-weight: 600; font-variant-numeric: tabular-nums; }
.ticket__delivery { display: flex; align-items: center; gap: 8px; padding: 6px 12px 8px; font-size: var(--t-13); }
.ticket__delivery .select { height: 28px; font-size: var(--t-12); flex: 1; min-width: 0; background-position: calc(100% - 15px) 11px, calc(100% - 10px) 11px; }
.ticket__total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; border-top: 1px solid var(--line); }
.ticket__total span:first-child { font-size: var(--t-13); color: var(--ink-3); }
.ticket__total strong { font-size: var(--t-20); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ticket__actions { display: flex; gap: 6px; padding: 0 12px 12px; }
.ticket__actions .btn--primary { flex: 1; }
.ticket__empty { padding: 14px 12px; font-size: var(--t-13); color: var(--ink-3); display: grid; gap: 8px; justify-items: start; }

/* ── Tables ─────────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: var(--s-5); }
.metric { position: relative; text-align: left; display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease); }
.metric:hover { border-color: var(--line-2); box-shadow: var(--shadow-raise); }
.metric:has([aria-pressed="true"]) { border-color: var(--accent-line); background: var(--accent-soft); }
.metric:has(.metric__go:focus-visible) { box-shadow: var(--focus); }
.metric__label { font-size: var(--t-13); color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.metric__label .icon { width: 15px; height: 15px; }
.metric__value { font-size: 26px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric__sub { font-size: var(--t-12); color: var(--ink-3); }
.metric__go { font-size: var(--t-12); color: var(--accent-ink); font-weight: 550; display: inline-flex; gap: 4px; align-items: center; border: 0; background: none; padding: 0; justify-self: start; }
.metric__go::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-md); }
.metric__go:focus-visible { box-shadow: none; }
.metric__go .icon { width: 13px; height: 13px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; height: 40px; padding: 0 12px; border: 0; background: none; color: var(--ink-3); font-size: var(--t-13); font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.tab .count { font-size: var(--t-12); color: var(--ink-4); font-variant-numeric: tabular-nums; }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 0; flex-wrap: wrap; }
.toolbar .input-wrap { width: 280px; max-width: 100%; }
.toolbar__end { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--ink-3); font-size: var(--t-13); }

.table-wrap { border: 1px solid var(--line); border-radius: var(--r-md); overflow: clip; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--t-13); }
.data th { position: sticky; top: var(--bar-h); z-index: 2; height: 38px; padding: 0 12px; text-align: left; font-size: var(--t-12); font-weight: 550; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.data td { height: var(--row-h); padding: 6px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr { transition: background var(--dur-1) var(--ease); }
.data tbody tr:hover { background: var(--surface-2); }
.data tbody tr[aria-selected="true"] { background: var(--accent-soft); }
.data .r { text-align: right; }
.data .c-check { width: 44px; padding-right: 0; }
.data .c-num { font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }
.data .c-items { color: var(--ink-3); max-width: 0; width: 30%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data .c-date { color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.data .row-link { font-weight: 550; color: var(--ink); }
.data .row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.data .person { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.data .person small { display: block; color: var(--ink-3); font-size: var(--t-12); }
.sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.sort .icon { width: 13px; height: 13px; opacity: .6; }
.check { appearance: none; width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line-2); background: var(--surface); display: grid; place-items: center; margin: 0; cursor: pointer; transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease); }
.check:hover { border-color: var(--ink-4); }
.check:checked, .check:indeterminate { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: ""; width: 8px; height: 4px; border: solid var(--on-accent); border-width: 0 0 2px 2px; rotate: -45deg; translate: 0 -1px; }
.check:indeterminate::after { content: ""; width: 8px; height: 2px; background: var(--on-accent); border-radius: 1px; }
.table-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); font-size: var(--t-12); color: var(--ink-3); background: var(--surface-2); }
.table-foot .btn:first-of-type { margin-left: auto; }

.bulk {
  position: fixed; left: calc(50% + var(--rail-w) / 2); bottom: 24px; translate: -50% 0; z-index: 40; display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 14px; border-radius: var(--r-md); background: var(--ink); color: var(--surface); box-shadow: var(--shadow-float); max-width: calc(100vw - var(--rail-w) - 32px);
}
.bulk[hidden] { display: none; }
.bulk__count { font-size: var(--t-13); font-weight: 600; margin-right: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bulk .btn { background: transparent; border-color: transparent; color: inherit; box-shadow: none; }
.bulk .btn:hover { background: color-mix(in srgb, var(--surface) 14%, transparent); }
.bulk .sep { width: 1px; height: 20px; background: color-mix(in srgb, var(--surface) 22%, transparent); margin: 0 4px; }

.empty { padding: 56px 24px; display: grid; justify-items: center; text-align: center; gap: 8px; }
.empty[hidden] { display: none; }
.empty__icon { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface-3); color: var(--ink-3); margin-bottom: 6px; }
.empty__icon .icon { width: 20px; height: 20px; }
.empty h3 { font-size: var(--t-16); font-weight: 600; }
.empty p { color: var(--ink-3); max-width: 36ch; font-size: var(--t-13); }
.empty .btn { margin-top: 8px; }

/* ── Order page ─────────────────────────── */
.record-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 20px; }
.record-head h1 { font-size: var(--t-28); font-weight: 600; letter-spacing: -.025em; line-height: 1.1; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.record-head h1 .mono { font-size: .86em; letter-spacing: -.03em; }
.record-head p { color: var(--ink-3); margin-top: 6px; font-size: var(--t-13); }
.record-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 20px; }
.progress li { display: grid; gap: 6px; font-size: var(--t-12); color: var(--ink-3); }
.progress li::before { content: ""; height: 4px; border-radius: 2px; background: var(--line); transition: background var(--dur-3) var(--ease); }
.progress li.done::before { background: var(--ink-2); }
.progress li.now::before { background: var(--accent); }
.progress li.now, .progress li.done { color: var(--ink); font-weight: 550; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; min-width: 0; }
.items { width: 100%; border-collapse: collapse; font-size: var(--t-13); }
.items td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.items tr:last-child td { border-bottom: 0; }
.items .thumb { width: 72px; padding-right: 0; }
.items .thumb img, .thumb-empty { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; box-shadow: inset 0 0 0 1px var(--line); }
.items .qty { color: var(--ink-3); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.items .amt { text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; white-space: nowrap; width: 110px; }
.items small { display: block; color: var(--ink-3); font-size: var(--t-12); }
.sum { padding: 12px 16px 14px; border-top: 1px solid var(--line); display: grid; gap: 6px; font-size: var(--t-13); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }
.sum__row span:first-child { color: var(--ink-3); }
.sum__row--total { padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--line); font-size: var(--t-16); font-weight: 600; }
.sum__row--total span:first-child { color: var(--ink); }
.sum__row--paid span:last-child { color: var(--ok); font-weight: 550; }
.pay-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pay-box .kvs { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: var(--t-13); flex: 1; min-width: 220px; }
.kvs dt { color: var(--ink-3); }
.kvs dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.timeline { padding: 4px 16px 16px; }
.timeline__compose { display: flex; gap: 8px; padding: 12px 0 16px; }
.timeline__compose .input { flex: 1; }
.tl { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; padding: 0 0 18px; font-size: var(--t-13); }
.tl::before { content: ""; position: absolute; left: 11px; top: 22px; bottom: 0; width: 1px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl__node { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--ink-3); display: grid; place-items: center; box-shadow: 0 0 0 3px var(--surface); }
.tl__node .icon { width: 13px; height: 13px; }
.tl--ok .tl__node { background: var(--ok-soft); color: var(--ok); }
.tl--accent .tl__node { background: var(--accent-soft); color: var(--accent-ink); }
.tl__body strong { font-weight: 550; }
.tl__body p { color: var(--ink-3); margin-top: 2px; }
.tl__time { font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; padding-top: 2px; }

/* ── Customers ──────────────────────────── */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.profile-head h1 { font-size: var(--t-28); font-weight: 600; letter-spacing: -.025em; line-height: 1.1; }
.profile-head p { color: var(--ink-3); margin-top: 4px; font-size: var(--t-13); }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 20px; background: var(--surface); }
.stat-strip > div { padding: 12px 16px; }
.stat-strip > div + div { border-left: 1px solid var(--line); }
.stat-strip dt { font-size: var(--t-12); color: var(--ink-3); }
.stat-strip dd { margin: 2px 0 0; font-size: var(--t-20); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.convo-hist li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: var(--t-13); }
.convo-hist li:last-child { border-bottom: 0; }
.convo-hist .icon { color: var(--ink-4); margin-top: 1px; width: 16px; height: 16px; }
.convo-hist p { color: var(--ink-3); }

/* ── Products ───────────────────────────── */
.grid-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.product { position: relative; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-2) var(--ease); }
.product:hover { border-color: var(--line-2); box-shadow: var(--shadow-float); transform: translateY(-2px); }
.product__img { aspect-ratio: 1 / 1; background: var(--surface-3); position: relative; }
.product__img img { width: 100%; height: 100%; object-fit: cover; }
.product__img .pill { position: absolute; left: 10px; top: 10px; }
.product__noimg { width: 100%; height: 100%; display: grid; place-content: center; justify-items: center; gap: 6px; color: var(--ink-3); font-size: var(--t-12); background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface-3) 10px 11px); }
.product__noimg .icon { width: 22px; height: 22px; }
.product__body { padding: 12px 14px 14px; display: grid; gap: 2px; }
.product__name { font-weight: 550; font-size: var(--t-14); }
.product__name a::after { content: ""; position: absolute; inset: 0; }
.product__name a:focus-visible { box-shadow: none; }
.product:has(.product__name a:focus-visible) { box-shadow: var(--focus); }
.product__sub { font-size: var(--t-12); color: var(--ink-3); }
.product__price { font-size: var(--t-16); font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.product__stock { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.product__stock .stepper { position: relative; z-index: 1; margin-left: auto; }
.meter { display: grid; gap: 5px; flex: 1; min-width: 0; }
.meter__label { font-size: var(--t-12); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter__label strong { font-weight: 600; color: var(--ink); }
.meter__bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.meter__bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--ink-2); border-radius: 2px; transition: width var(--dur-3) var(--ease), background var(--dur-2) var(--ease); }
.meter--low .meter__bar i { background: var(--warn); }
.meter--low .meter__label strong { color: var(--warn); }
.meter--out .meter__label strong { color: var(--danger); }
.product--hidden .product__img img { opacity: .55; filter: grayscale(.4); }

/* ── Forms (product, settings) ──────────── */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.form-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.form-card + .form-card { margin-top: 20px; }
.form-card__head { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.form-card__head h2 { font-size: var(--t-14); font-weight: 600; }
.form-card__head p { font-size: var(--t-12); color: var(--ink-3); margin-top: 2px; }
.form-card__body { padding: 20px; display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 16px; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; }
.error-summary { border: 1px solid var(--danger-line); background: var(--danger-soft); color: var(--ink); border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 20px; display: grid; gap: 6px; font-size: var(--t-13); }
.error-summary[hidden] { display: none; }
.error-summary h2 { font-size: var(--t-14); font-weight: 600; color: var(--danger); display: flex; align-items: center; gap: 8px; }
.error-summary ul { list-style: disc; padding-left: 40px; display: grid; gap: 2px; }
.error-summary a { text-decoration: underline; text-underline-offset: 3px; }
.photos-edit { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.photos-edit figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.photos-edit figure img { width: 100%; height: 100%; object-fit: cover; }
.photos-edit figure:first-child::after { content: "Cover"; position: absolute; left: 6px; bottom: 6px; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: var(--r-xs); background: rgba(10, 14, 12, .7); color: #fff; }
.photos-edit .upload { aspect-ratio: 1; border-radius: 8px; border: 1.5px dashed var(--line-2); background: var(--surface-2); display: grid; place-content: center; justify-items: center; gap: 6px; color: var(--ink-3); font-size: var(--t-12); font-weight: 500; }
.photos-edit .upload:hover { border-color: var(--accent); color: var(--accent-ink); }
.variants { width: 100%; border-collapse: collapse; font-size: var(--t-13); }
.variants th { text-align: left; font-size: var(--t-12); color: var(--ink-3); font-weight: 550; padding: 0 8px 8px 0; }
.variants td { padding: 4px 8px 4px 0; }
.variants td:last-child { width: 36px; padding-right: 0; }
.switch-row { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.switch-row + .switch-row { padding-top: 16px; border-top: 1px solid var(--line); }
.switch-row strong { font-weight: 550; font-size: var(--t-14); display: block; }
.switch-row span { font-size: var(--t-12); color: var(--ink-3); }
.switch { appearance: none; flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line-2); position: relative; margin: 0; cursor: pointer; transition: background var(--dur-2) var(--ease); }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: translate var(--dur-2) var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { translate: 14px 0; }
.switch:focus-visible { box-shadow: var(--focus); }
.savebar {
  position: fixed; left: calc(50% + var(--rail-w) / 2); bottom: 20px; translate: -50% 0; z-index: 40; width: min(640px, calc(100vw - var(--rail-w) - 32px));
  display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--surface); box-shadow: var(--shadow-float);
}
.savebar[hidden] { display: none; }
.savebar p { font-size: var(--t-13); font-weight: 550; flex: 1; display: flex; gap: 8px; align-items: center; }
.savebar .btn--ghost { color: inherit; }
.savebar .btn--ghost:hover { background: color-mix(in srgb, var(--surface) 14%, transparent); }

.settings { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--bar-h) + 24px); display: grid; gap: 2px; }
.settings-nav a { display: flex; gap: 10px; align-items: center; height: 34px; padding: 0 10px; border-radius: var(--r-sm); color: var(--ink-2); font-size: var(--t-13); font-weight: 500; }
.settings-nav a:hover { background: var(--surface-3); color: var(--ink); }
.settings-nav a[aria-current="true"] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.settings-nav .icon { width: 16px; height: 16px; color: var(--ink-3); }
.settings section { scroll-margin-top: calc(var(--bar-h) + 20px); }
.settings section + section { margin-top: 40px; }
.section-head { margin-bottom: 14px; display: flex; align-items: flex-end; gap: 12px; }
.section-head h2 { font-size: var(--t-20); font-weight: 600; letter-spacing: -.02em; }
.section-head p { font-size: var(--t-13); color: var(--ink-3); margin-top: 2px; }
.section-head .btn { margin-left: auto; }
.team li { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.team li:last-child { border-bottom: 0; }
.team .who-t { flex: 1; min-width: 0; }
.team .who-t strong { font-weight: 550; display: block; }
.team .who-t span { color: var(--ink-3); font-size: var(--t-12); }
.team .select { width: 130px; height: 30px; font-size: var(--t-13); background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px; }
.notif { width: 100%; border-collapse: collapse; font-size: var(--t-13); }
.notif th { text-align: center; font-size: var(--t-12); color: var(--ink-3); font-weight: 550; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.notif th:first-child { text-align: left; }
.notif td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: center; }
.notif td:first-child { text-align: left; }
.notif tr:last-child td { border-bottom: 0; }
.notif td strong { font-weight: 550; display: block; }
.notif td span { color: var(--ink-3); font-size: var(--t-12); }
.saved-tick { display: inline-flex; gap: 4px; align-items: center; color: var(--ok); font-size: var(--t-12); font-weight: 550; }

/* ── Overlays ───────────────────────────── */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: calc(100vw - 32px); }
dialog::backdrop { background: var(--scrim); }
.palette { width: 640px; margin-top: 12vh; }
.palette__box { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-float); border: 1px solid var(--line); overflow: hidden; }
.palette__search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette__search .icon { color: var(--ink-3); }
.palette__search input { flex: 1; height: 52px; border: 0; background: none; font-size: var(--t-16); }
.palette__search input:focus { outline: none; }
.palette__list { max-height: min(420px, 56vh); overflow-y: auto; padding: 6px; }
.palette__group { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; padding: 10px 10px 4px; }
.palette__item { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; font-size: var(--t-14); color: var(--ink); }
.palette__item .icon { color: var(--ink-3); width: 16px; height: 16px; }
.palette__item small { color: var(--ink-3); font-size: var(--t-12); margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__item .keys { margin-left: auto; display: flex; gap: 3px; }
.palette__item[aria-selected="true"] { background: var(--surface-3); }
.palette__item[aria-selected="true"] .icon { color: var(--accent); }
.palette__foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: var(--t-12); color: var(--ink-3); background: var(--surface-2); }
.palette__foot span { display: inline-flex; gap: 5px; align-items: center; }
.palette__empty { padding: 32px; text-align: center; color: var(--ink-3); font-size: var(--t-13); }
.sheet { width: 560px; }
.sheet__box { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-float); border: 1px solid var(--line); }
.sheet__head { display: flex; align-items: center; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.sheet__head h2 { font-size: var(--t-16); font-weight: 600; }
.sheet__head .btn { margin-left: auto; }
.sheet__body { padding: 16px 20px 20px; }
.keys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; }
.keys-grid h3 { grid-column: 1 / -1; font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 12px 0 4px; }
.keys-grid h3:first-child { margin-top: 0; }
.keys-grid div { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: var(--t-13); padding: 5px 0; border-bottom: 1px solid var(--line); }
.keys-grid div span:last-child { display: flex; gap: 3px; }
.sheet__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.popover { position: absolute; z-index: 60; width: 340px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-float); padding: 6px; }
.popover[hidden] { display: none; }
.popover .input-wrap { margin: 2px 2px 6px; }
.pick { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; font-size: var(--t-13); }
.pick:hover, .pick:has(.pick__go:focus-visible) { background: var(--surface-3); }
.pick:has(.pick__go:focus-visible) { box-shadow: inset 0 0 0 2px var(--accent); }
.pick__go { position: absolute; inset: 0; width: 100%; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; }
.pick__go:focus-visible { box-shadow: none; }
.pick:has(.pick__go[disabled]) { opacity: .5; }
.pick__go[disabled] { cursor: not-allowed; }
.pick img, .pick .thumb-empty { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
.pick small { display: block; color: var(--ink-3); font-size: var(--t-12); }
.pick .num { font-weight: 550; }
.thumb-empty { display: grid; place-items: center; background: var(--surface-3); color: var(--ink-4); }

.toasts { position: fixed; left: calc(var(--rail-w) + 16px); bottom: 16px; z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: min(420px, calc(100vw - 32px)); padding: 10px 10px 10px 14px; border-radius: var(--r-md); background: var(--ink); color: var(--surface); box-shadow: var(--shadow-float); font-size: var(--t-13); }
.toast .icon { width: 16px; height: 16px; color: #7fdcaa; flex: none; }
.toast p { flex: 1; }
.toast button { border: 0; background: color-mix(in srgb, var(--surface) 14%, transparent); color: inherit; font-weight: 600; font-size: var(--t-12); height: 26px; padding: 0 10px; border-radius: var(--r-sm); }
.toast button:hover { background: color-mix(in srgb, var(--surface) 24%, transparent); }

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 44; }
.scrim[hidden] { display: none; }

body:has(.bulk:not([hidden])) .toasts, body:has(.savebar:not([hidden])) .toasts { bottom: 80px; }
/* entrance: only hidden when JS has added .js and .pre */
.pre [data-enter] { opacity: 0; }
.panel-toggle { display: none; }
.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-sun { display: block; }
  :root:not([data-theme="light"]) .theme-moon { display: none; }
}
.composer { position: relative; }
.composer .popover { left: 12px; bottom: calc(100% - 4px); max-height: 380px; overflow-y: auto; }
.collapsing { overflow: hidden; }
.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { from { background: var(--accent-soft); } }
.attach-file { display: inline-flex; gap: 8px; align-items: center; }

/* ── Responsive ─────────────────────────── */
@media (max-width: 1240px) {
  .js .inbox { grid-template-columns: var(--list-w) minmax(0, 1fr); }
  .js .pane--side { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 92vw); z-index: 45; box-shadow: var(--shadow-float); translate: 100% 0; visibility: hidden; transition: translate var(--dur-3) var(--ease), visibility 0s linear var(--dur-3); }
  .js .inbox[data-panel="open"] .pane--side { translate: 0 0; visibility: visible; transition: translate var(--dur-3) var(--ease); }
  .panel-toggle { display: inline-flex; }
  .two-col, .form-layout { grid-template-columns: minmax(0, 1fr) 280px; }
}
@media (min-width: 1241px) { .panel-toggle--close { display: none; } }
@media (max-width: 1040px) {
  :root { --list-w: 300px; }
  .two-col, .form-layout { grid-template-columns: 1fr; }
  .data .c-items, .data .c-channel { display: none; }
  .settings { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings > * { min-width: 0; }
  .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .settings-nav a { flex: none; }
}
@media (max-width: 860px) {
  .js .inbox { grid-template-columns: 1fr; }
  .js .inbox .pane--thread { display: none; }
  .js .inbox[data-view="thread"] .pane--list { display: none; }
  .js .inbox[data-view="thread"] .pane--thread { display: flex; }
  .back-btn { display: inline-flex; }
  .search-trigger { width: auto; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .metrics { grid-template-columns: 1fr; gap: 8px; }
  .metric { grid-template-columns: auto 1fr auto; align-items: center; gap: 2px 12px; padding: 12px 14px; }
  .metric__label { grid-column: 1 / -1; }
  .metric__value { font-size: var(--t-20); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > div:nth-child(3) { border-left: 0; }
  .stat-strip > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  :root { --rail-w: 0px; --bar-h: 52px; --gutter: 16px; }
  .app { grid-template-columns: 1fr; padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: calc(60px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around; padding: 4px 4px env(safe-area-inset-bottom); }
  .rail__brand, .rail__foot > :not(.rail-item--settings), .tip { display: none; }
  .rail__nav, .rail__foot { flex-direction: row; gap: 0; margin: 0; flex: 4; justify-content: space-around; }
  .rail__foot { flex: 1; }
  .rail-item--settings .rail-label { display: block; }
  .rail-item--settings { padding: 8px 0 6px; }
  .rail-item { width: 64px; }
  .rail-item[aria-current="page"]::before { left: 18px; right: 18px; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .rail-item[aria-current="page"] { background: none; }
  .inbox { height: calc(100dvh - 60px - env(safe-area-inset-bottom)); }
  html:not(.js) .inbox { display: block; height: auto; }
  .topbar { padding: 0 16px; }
  .page { padding: 16px 16px 96px; }
  .page-head h1, .record-head h1, .profile-head h1 { font-size: var(--t-20); }
  .page-head__actions .btn-label { display: none; }
  .thread { padding: 16px 14px 8px; }
  .thread-head { padding: 0 8px; height: 58px; gap: 6px; }
  .thread-head__actions .hide-sm { display: none; }
  .composer { padding: 8px 10px 10px; }
  .composer__hint { display: none; }
  .toolbar .input-wrap { width: 100%; }
  .toolbar__end { margin-left: 0; }
  .table-wrap { border: 0; border-radius: 0; margin: 0 -16px; border-top: 1px solid var(--line); }
  table.data thead { display: none; }
  table.data, .data tbody { display: block; }
  .data tbody tr { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: relative; }
  .data td { display: block; height: auto; padding: 0; border: 0; }
  .data td.c-check { grid-row: 1 / span 3; padding-top: 2px; width: auto; }
  .data .c-hide-sm { display: none; }
  .data .m-1 { grid-column: 2; }
  .data .m-r { grid-column: 3; text-align: right; }
  .data .m-2 { grid-column: 2 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
  .data.no-check tbody tr { grid-template-columns: minmax(0, 1fr) auto; }
  .data.no-check .m-1 { grid-column: 1; }
  .data.no-check .m-r { grid-column: 2; }
  .data.no-check .m-2 { grid-column: 1 / -1; }
  .table-foot { margin: 0 -16px; }
  .bulk { left: 12px; right: 12px; translate: none; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; padding-left: 12px; }
  .bulk .btn-label { display: none; }
  .bulk .btn { width: 36px; padding: 0; }
  .savebar { left: 12px; right: 12px; translate: none; width: auto; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .toasts { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
  .progress { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .progress li { font-size: 11px; }
  .items .thumb { width: 60px; padding-left: 12px; }
  .items td { padding: 10px 12px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .span-4, .span-6 { grid-column: 1 / -1; }
  .form-card__body { padding: 16px; }
  .field:has(#s-link), .field:has(#s-email) { grid-column: 1 / -1; }
  .btn--primary kbd { display: none; }
  .photos-edit { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product__body { padding: 10px 10px 12px; }
  .product__stock { flex-wrap: wrap; gap: 8px; }
  .product__stock .stepper { margin-left: 0; }
  .palette { margin-top: 8px; width: calc(100vw - 16px); max-width: none; }
  .palette__foot { display: none; }
  .keys-grid { grid-template-columns: 1fr; }
  .js .pane--side { top: auto; width: 100%; height: 86dvh; border-radius: 16px 16px 0 0; border-left: 0; translate: 0 100%; }
  .js .inbox[data-panel="open"] .pane--side { translate: 0 0; }
  .facts dd { font-size: var(--t-13); }
  .record-head__actions { margin-left: 0; width: 100%; }
  .record-head__actions .btn--primary { flex: 1; }
  .notif th, .notif td { padding: 10px 8px; }
  .notif td:first-child, .notif th:first-child { padding-left: 16px; }
  .team .select { width: 104px; }
  .two-col .panel, .stack > .panel { border-radius: var(--r-md); }
}
@media (max-width: 760px) {
  body:has(.bulk:not([hidden])) .toasts, body:has(.savebar:not([hidden])) .toasts { bottom: calc(128px + env(safe-area-inset-bottom)); }
}
@media (max-width: 400px) {
  .grid-products { grid-template-columns: 1fr 1fr; }
  .product__price { font-size: var(--t-14); }
  .thread-head__actions .btn--icon:not(.panel-toggle):not(.keep) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; scroll-behavior: auto !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
