/* ==========================================================================
   Components — built only from tokens.css variables.
   Naming: .component, .component--variant, .component__part, .is-state
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--leading-tight); font-weight: var(--weight-semibold); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-height); padding: 0 var(--space-4);
  border: var(--border-width) solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: var(--weight-medium); white-space: nowrap;
  cursor: pointer; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-hover); }
.btn:disabled, .btn.is-loading { opacity: 0.55; cursor: not-allowed; }
.btn.is-loading::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: color-mix(in oklab, var(--danger) 86%, black); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-hover); }
.btn--sm { height: calc(var(--control-height) - 8px); padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn--icon { width: var(--control-height); padding: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ---------- Form controls ---------- */
.field { display: grid; gap: var(--space-1); }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); }
.field__help { font-size: var(--text-xs); color: var(--text-subtle); }
.field__error { font-size: var(--text-xs); color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: var(--control-height); padding: 0 var(--space-3);
  border: var(--border-width) solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: var(--space-2) var(--space-3); resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input--color { padding: 3px; width: 64px; cursor: pointer; }
.input--color + .btn-row { margin-top: var(--space-1); }
.form { display: grid; gap: var(--space-4); }
.form__grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form__error { padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-size: var(--text-sm); }

/* Toggle (checkbox styled as a switch) */
.toggle { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; user-select: none; }
.toggle input { appearance: none; margin: 0; width: 34px; height: 20px; border-radius: var(--radius-pill);
  background: var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur) var(--ease); }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(14px); }

.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Card / stat tile ---------- */
.card { background: var(--surface); border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: var(--border-width) solid var(--border); }
.card__title { font-size: var(--text-md); }
.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }
.stats { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { padding: var(--space-4) var(--space-5); }
.stat__label { font-size: var(--text-sm); color: var(--text-muted); }
.stat__value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); margin-top: var(--space-1); font-variant-numeric: tabular-nums; }
.stat__hint { font-size: var(--text-xs); color: var(--text-subtle); margin-top: var(--space-1); }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--space-2);
  border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-medium);
  background: var(--neutral-soft); color: var(--text-muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--plain::before { display: none; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: var(--text-xs); font-weight: var(--weight-medium); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-subtle); padding: var(--space-2) var(--space-4);
  border-bottom: var(--border-width) solid var(--border); white-space: nowrap; }
.table td { padding: var(--space-3) var(--space-4); border-bottom: var(--border-width) solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover td { background: var(--surface-hover); }
.table .num { text-align: right; }
.table .muted { color: var(--text-muted); }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------- Tabs / segmented filters ---------- */
.tabs { display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; }
.tab { height: calc(var(--control-height) - 4px); padding: 0 var(--space-3); border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--text-muted); font: inherit; font-weight: var(--weight-medium); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab.is-active { background: var(--accent-soft); color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.toolbar > * { min-width: 0; max-width: 100%; }
.toolbar__group { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.search { flex: 1 1 220px; max-width: 360px; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-top: var(--border-width) solid var(--border); font-size: var(--text-sm); color: var(--text-muted); }

/* ---------- Dialog & drawer (native <dialog>) ---------- */
.dialog { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.dialog::backdrop { background: var(--overlay); }
.dialog[open] { animation: pop var(--dur) var(--ease); }
.dialog__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: var(--border-width) solid var(--border); }
.dialog__title { font-size: var(--text-lg); }
.dialog__body { padding: var(--space-5); overflow-y: auto; max-height: calc(100vh - 200px); }
.dialog__body:focus { outline: none; }
.dialog__footer { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-5);
  border-top: var(--border-width) solid var(--border); }
.dialog__footer .spacer { flex: 1; }
.dialog__footer:has(> .btn-row:empty) { display: none; }
.dialog--drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(560px, 100vw); border-radius: 0;
  display: flex; flex-direction: column; }
@supports (height: 100dvh) { .dialog--drawer { height: 100dvh; max-height: 100dvh; } }  /* phones: fits above the keyboard / toolbar */
.dialog--drawer[open] { display: flex; animation: slide var(--dur) var(--ease); }
.dialog--drawer .dialog__body { flex: 1; max-height: none; }

/* ---------- Toast ---------- */
#toasts { position: fixed; z-index: 100; right: var(--space-4); bottom: var(--space-4); display: grid; gap: var(--space-2); }
.toast { min-width: 240px; max-width: 380px; padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-size: var(--text-sm);
  animation: pop var(--dur) var(--ease); }
.toast--error { background: var(--danger); color: #fff; }
.toast--success { background: var(--success); color: #fff; }

/* ---------- States: empty / loading / error ---------- */
.state { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); text-align: center; color: var(--text-muted); }
.state__title { color: var(--text); font-weight: var(--weight-semibold); }
.state--error .state__title { color: var(--danger); }
.skeleton { height: 14px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2), var(--surface-hover), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton[data-w="1"] { width: 82%; }
.skeleton[data-w="2"] { width: 64%; }
.skeleton-list { display: grid; gap: var(--space-3); padding: var(--space-5); }

/* ---------- Description list (detail views) ---------- */
.dl { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.dl dt { color: var(--text-muted); font-size: var(--text-sm); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.stack { display: grid; gap: var(--space-5); align-content: start; }
.section__actions { margin-top: var(--space-3); }
.swatch { width: 24px; height: 24px; padding: 0; border-radius: 50%; cursor: pointer; background: var(--swatch);
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.swatch:hover { transform: scale(1.1); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.section + .section { margin-top: var(--space-6); }
.section__title { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-subtle); margin-bottom: var(--space-3); }
.callout { padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--accent-soft); font-size: var(--text-sm); }
.callout--warning { background: var(--warning-soft); }
.secret { display: block; padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); font-family: var(--font-mono); overflow-wrap: anywhere; user-select: all; }

/* ---------- Bot text editor ---------- */
.text-toolbar { margin-bottom: 0; }
.text-list { display: grid; border: var(--border-width) solid var(--border); border-radius: var(--radius); overflow: hidden; }
.text-list__group { padding: var(--space-2) var(--space-4); background: var(--surface-2); font-size: var(--text-xs);
  font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-subtle);
  border-bottom: var(--border-width) solid var(--border); }
.text-list__more { padding: var(--space-3); display: flex; justify-content: center; }
.text-row { display: grid; gap: var(--space-1); width: 100%; padding: var(--space-3) var(--space-4); text-align: left;
  background: var(--surface); color: var(--text); font: inherit; border: 0; border-bottom: var(--border-width) solid var(--border); cursor: pointer; }
.text-row:hover { background: var(--surface-hover); }
.text-row--open { cursor: default; gap: var(--space-3); background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.text-row--open:hover { background: var(--surface); }
.text-row__meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.text-row__key { font-size: var(--text-xs); color: var(--text-subtle); }
.text-row__preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.text-editor__input { font-family: var(--font); line-height: var(--leading); }
.text-editor__tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.tool { min-width: 32px; height: 28px; padding: 0 var(--space-2); border: var(--border-width) solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm);
  font-weight: var(--weight-semibold); cursor: pointer; }
.tool:hover { background: var(--surface-hover); }
.tool-sep { width: 1px; height: 20px; background: var(--border); margin: 0 var(--space-1); }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 var(--space-2); border-radius: var(--radius-pill);
  border: 0; background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); font-size: var(--text-xs); cursor: pointer; }
.chip--static { height: auto; padding: 0 6px; cursor: default; vertical-align: baseline; }
.tg-bubble { max-width: 420px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); border-bottom-left-radius: var(--radius-sm);
  background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.tg-bubble--muted { color: var(--text-muted); }
.tg-bubble code, .tg-bubble pre { font-family: var(--font-mono); background: var(--surface); padding: 0 4px; border-radius: 4px; }
.tg-bubble blockquote { margin: 0; padding-left: var(--space-3); border-left: 3px solid var(--accent); }
.tg-spoiler { background: var(--text-subtle); color: transparent; border-radius: 3px; }
.text-editor__original summary { cursor: pointer; font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--space-2); }
.text-editor__actions .spacer { flex: 1; }

/* ---------- Checkout workflow builder ---------- */
.wf-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.wf-step { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: center;
  padding: var(--space-3); border: var(--border-width) solid var(--border); border-radius: var(--radius); background: var(--surface); }
.wf-step.is-off { background: var(--surface-2); }
.wf-step.is-off .wf-step__body { opacity: 0.6; }
.wf-step__num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft);
  color: var(--accent); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.wf-step__body { display: grid; gap: 4px; min-width: 0; padding: 0; border: 0; background: none; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.wf-step__top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.wf-step__title { font-weight: var(--weight-semibold); }
.wf-step__prompt { color: var(--text-muted); font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-step__cond { font-size: var(--text-xs); color: var(--info); }
.wf-step__actions { display: flex; align-items: center; gap: var(--space-1); }
.tool:disabled { opacity: 0.35; cursor: default; }
.options-editor { display: grid; gap: var(--space-2); }
.option-row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2); padding: var(--space-3);
  border: var(--border-width) solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.option-row__fields { display: grid; gap: var(--space-2); min-width: 0; }
.option-row__actions { display: flex; flex-direction: column; gap: var(--space-1); align-items: center; }
.checks { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-2); }
.type-picker { display: grid; gap: var(--space-2); }
.type-option { display: grid; gap: 2px; text-align: left; padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  border: var(--border-width) solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.type-option:hover { border-color: var(--accent); background: var(--accent-soft); }
.advanced summary { cursor: pointer; font-size: var(--text-sm); color: var(--text-muted); }
.advanced[open] summary { margin-bottom: var(--space-3); }
.save-bar { position: sticky; bottom: var(--space-4); z-index: 5; display: flex; flex-wrap: wrap; gap: var(--space-3);
  align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  background: var(--surface); border: var(--border-width) solid var(--accent); box-shadow: var(--shadow-lg); }
.save-bar__text { font-weight: var(--weight-medium); }
@media (max-width: 600px) {
  .wf-step { grid-template-columns: auto 1fr; }
  .wf-step__actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ---------- Product photos ---------- */
.product-cell { display: flex; align-items: center; gap: var(--space-3); }
.thumb { width: 44px; height: 44px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2); }
.thumb--empty { display: grid; place-items: center; color: var(--text-subtle); }
.photo-preview { display: grid; place-items: center; min-height: 160px; border-radius: var(--radius);
  background: var(--surface-2); overflow: hidden; }
.photo-preview img { max-width: 100%; max-height: 320px; display: block; }
.photo-preview--small { min-height: 90px; }
.photo-preview--small img { max-height: 160px; }
.order-photo img { max-width: 220px; max-height: 220px; border-radius: var(--radius); display: block; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Numbered setup steps (Settings → Management bot) */
.field__help.is-ok { color: var(--success); }
.steps { margin: 0; padding-left: 1.25rem; display: grid; gap: var(--space-2); }

/* Phones: 16px text in fields so iOS doesn't zoom the page when you tap one */
@media (pointer: coarse) { .input, .select, .textarea { font-size: 16px; } }

/* AI assistant drawer */
.assistant { display: flex; flex-direction: column; gap: var(--space-2); min-height: 100%; }
.assistant__log { display: flex; flex-direction: column; gap: var(--space-2); }
.assistant__msg { padding: var(--space-2) var(--space-3); border-radius: var(--radius); white-space: pre-wrap;
  max-width: 92%; font-size: var(--text-sm); }
.assistant__msg--assistant { background: var(--surface-2); border: var(--border-width) solid var(--border); align-self: flex-start; }
.assistant__msg--user { background: var(--accent); color: var(--on-accent); align-self: flex-end; }
.assistant__plan { border: var(--border-width) solid var(--border); border-radius: var(--radius);
  padding: var(--space-3); display: grid; gap: var(--space-2); }
.assistant__actions { margin: 0; padding-left: 0; list-style: none; display: grid; gap: var(--space-1); font-size: var(--text-sm); }
.assistant__compose { display: grid; gap: var(--space-2); width: 100%; }
.assistant__compose .textarea { min-height: 64px; max-height: 30dvh; }
.dialog--drawer .dialog__body { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.assistant__compose .btn-row { justify-content: space-between; align-items: center; }

/* Product photo tile: hover/tap shows "Add photo / Change"; drop a picture on it to upload */
.photo-tile { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--radius-sm);
  overflow: hidden; flex: none; line-height: 0; }
.photo-tile__overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-size: 11px; line-height: 1.2; font-weight: 600; color: #fff; background: rgb(0 0 0 / 0.55);
  opacity: 0; transition: opacity 0.15s; padding: 2px; }
.photo-tile:hover .photo-tile__overlay, .photo-tile:focus-visible .photo-tile__overlay,
.photo-tile.is-dragging .photo-tile__overlay, .photo-tile.is-loading .photo-tile__overlay { opacity: 1; }
.photo-tile.is-dragging { outline: 2px dashed var(--accent); outline-offset: 2px; }
.photo-tile.is-loading { pointer-events: none; }
.photo-tile.is-loading .photo-tile__overlay::after { content: "…"; }
.thumb--empty + .photo-tile__overlay { opacity: 0.85; background: rgb(0 0 0 / 0.35); }
@media (hover: none) { .photo-tile .thumb--empty + .photo-tile__overlay { opacity: 1; } }
.photo-tile--large { border-radius: var(--radius); width: 100%; max-width: 280px; aspect-ratio: 1; background: var(--surface-2); }
.photo-tile--large img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile--large .photo-tile__overlay { font-size: var(--text-sm); }
.photo-tile__empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--text-subtle); }
.photo-tile__empty + .photo-tile__overlay { opacity: 1; background: rgb(0 0 0 / 0.25); }
.stock-exact { align-items: flex-end; }

/* Rich text editor (ui.js richText): slim toolbar, live Telegram preview */
.rte { display: grid; gap: var(--space-2); }
.rte__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.rte__bar .tool { min-width: 30px; height: 28px; font-size: var(--text-sm); }
.rte__b { font-weight: 700; } .rte__i { font-style: italic; } .rte__u { text-decoration: underline; } .rte__s { text-decoration: line-through; }
.rte__toggle { opacity: 0.75; }
.rte__input { min-height: 72px; }
.rte__preview-box { display: grid; gap: 6px; padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); }
.rte__preview-box[hidden] { display: none; }
.rte__preview-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); }
.rte__preview { white-space: pre-wrap; word-break: break-word; }
.tg-spoiler { background: color-mix(in oklab, var(--text) 18%, transparent); border-radius: 3px; }

/* Settings: links beside a toggle; phone-frame preview dialog */
.inline-links { display: inline-flex; gap: var(--space-1); margin-left: var(--space-2); vertical-align: middle; }
.dialog--phone { width: auto; }
.dialog--phone .dialog__body { max-height: none; display: grid; place-items: center; }
.phone-frame { position: relative; width: 390px; max-width: calc(100vw - 64px); height: min(780px, calc(100vh - 220px));
  padding: 14px; border-radius: 44px; background: #0b0b0f; box-shadow: var(--shadow-lg), inset 0 0 0 2px #2a2a33; }
.phone-frame__notch { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: 120px; height: 24px;
  border-radius: 0 0 14px 14px; background: #0b0b0f; z-index: 1; }
.phone-frame__screen { width: 100%; height: 100%; border: 0; border-radius: 32px; background: var(--bg); }

/* Checkout branching */
.wf-step__branch { color: var(--accent); }
.field--inline { display: flex; align-items: center; gap: var(--space-2); }
.field--inline .field__label { margin: 0; white-space: nowrap; }
.field--inline .select { max-width: 280px; }

/* Agent order panel editor */
.panel-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: var(--space-6); align-items: start; }
.panel-editor__preview { position: sticky; top: calc(var(--topbar-height, 56px) + var(--space-4)); display: grid; gap: var(--space-3); }
.panel-editor__preview-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
@media (max-width: 960px) { .panel-editor { grid-template-columns: 1fr; } .panel-editor__preview { position: static; } }
.panel-preview { display: grid; gap: var(--space-2); }
.panel-preview__card { max-width: none; white-space: pre-wrap; }
.panel-preview__buttons { display: grid; gap: 6px; }
.panel-preview__row { display: flex; gap: 6px; }
.panel-preview__btn { flex: 1; padding: 8px 10px; border-radius: var(--radius); background: var(--surface-2);
  border: var(--border-width) solid var(--border); font-size: var(--text-sm); text-align: center; }
.option-row--compact { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) 0; }
.option-row--compact .input { max-width: 220px; }
.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius); background: var(--surface-2); }
.segmented__btn { border: 0; background: none; padding: 4px 10px; border-radius: calc(var(--radius) - 2px); font: inherit;
  font-size: var(--text-sm); color: var(--text-muted); cursor: pointer; }
.segmented__btn.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Business hours */
.hours { display: grid; gap: 2px; }
.hours.is-off { opacity: 0.55; }
.hours__row { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: var(--space-3); min-height: 40px; }
.hours__times { display: flex; align-items: center; gap: var(--space-2); }
.hours__times .input { width: 130px; }
@media (max-width: 520px) { .hours__row { grid-template-columns: 1fr; } }

/* Command palette (Ctrl+K) */
.kbd-search { display: inline-flex; align-items: center; gap: var(--space-2); height: 34px; padding: 0 var(--space-3);
  border: var(--border-width) solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text-muted); font: inherit; font-size: var(--text-sm); cursor: pointer; }
.kbd-search:hover { background: var(--surface-hover); color: var(--text); }
.kbd-search kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 4px;
  border: var(--border-width) solid var(--border); background: var(--surface-2); }
@media (max-width: 720px) { .kbd-search__text, .kbd-search kbd { display: none; } }
.palette { position: fixed; inset: 0; z-index: 90; display: grid; place-items: start center; padding-top: 12vh;
  background: var(--overlay); animation: pop var(--dur) var(--ease); }
.palette__box { width: min(560px, calc(100vw - 32px)); border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: var(--shadow-lg); overflow: hidden; }
.palette__input { width: 100%; height: 52px; padding: 0 var(--space-4); border: 0; border-bottom: var(--border-width) solid var(--border);
  background: transparent; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.palette__list { max-height: 50vh; overflow-y: auto; padding: var(--space-2); }
.palette__item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 10px var(--space-3); border: 0; border-radius: var(--radius); background: none; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; }
.palette__item.is-active { background: var(--accent-soft); color: var(--accent); }
.palette__hint { font-size: var(--text-xs); color: var(--text-subtle); }
.palette__empty { padding: var(--space-4); color: var(--text-muted); text-align: center; }
.palette__foot { padding: 8px var(--space-4); border-top: var(--border-width) solid var(--border); font-size: var(--text-xs);
  color: var(--text-subtle); }

/* Clickable toasts (new-order alerts) */
.toast--action { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); border: 0;
  font: inherit; cursor: pointer; text-align: left; }
.toast__hint { font-size: var(--text-xs); opacity: 0.8; text-decoration: underline; }

/* Help: "Need help?" links, setup guide, help center */
.card__heading { display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; flex-wrap: wrap; }
.help-link { font-size: var(--text-xs); color: var(--text-subtle); text-decoration: none; white-space: nowrap; }
.help-link:hover { color: var(--accent); text-decoration: underline; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress__bar { height: 100%; border-radius: inherit; background: var(--accent); transition: width var(--dur) var(--ease); }
.setup-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.setup-step { display: grid; grid-template-columns: 36px 1fr; gap: var(--space-3); padding: var(--space-4);
  border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.setup-step.is-next { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.setup-step.is-done { opacity: 0.72; }
.setup-step__num { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); font-weight: var(--weight-semibold); }
.setup-step.is-done .setup-step__num { background: color-mix(in oklab, var(--success, #16a34a) 18%, transparent); color: var(--success, #16a34a); }
.setup-step.is-next .setup-step__num { background: var(--accent); color: var(--on-accent); }
.setup-step__body { display: grid; gap: var(--space-2); min-width: 0; }
.setup-step__top { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.help__search { max-width: 560px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); align-items: start; }
.help-list { display: grid; }
.help-row { display: grid; gap: 2px; padding: var(--space-2) 0; border-bottom: var(--border-width) solid var(--border);
  color: var(--text); text-decoration: none; }
.help-row:last-child { border-bottom: 0; }
.help-row:hover .help-row__title { color: var(--accent); }
.help-row__title { font-weight: var(--weight-medium, 500); }
.help-article-wrap { display: grid; grid-template-columns: minmax(0, 720px) minmax(200px, 260px); gap: var(--space-6); align-items: start; }
@media (max-width: 960px) { .help-article-wrap { grid-template-columns: 1fr; } }
.help-article { padding: var(--space-6); display: grid; gap: var(--space-3); }
.help-article__cat { margin: 0; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); }
.help-article__title { margin: 0; font-size: 1.4rem; }
.help-related { display: grid; gap: var(--space-2); }
.help-related__link { font-size: var(--text-sm); white-space: normal; }
.help-contact { font-size: var(--text-md, 1rem); }
.doc { display: grid; gap: var(--space-3); line-height: 1.6; }
.doc h3 { margin: var(--space-3) 0 0; font-size: var(--text-md, 1rem); }
.doc p, .doc ul, .doc ol { margin: 0; }
.doc ul, .doc ol { padding-left: 1.3rem; display: grid; gap: 4px; }
.doc code { font-family: var(--font-mono); font-size: 0.92em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); word-break: break-all; }

/* Notices (account page, banners) */
.notice { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  background: var(--accent-soft); border: var(--border-width) solid color-mix(in oklab, var(--accent) 30%, transparent); }
.notice--danger { background: color-mix(in oklab, var(--danger, #dc2626) 10%, transparent);
  border-color: color-mix(in oklab, var(--danger, #dc2626) 35%, transparent); }
.report-details { max-width: 420px; white-space: pre-wrap; word-break: break-word; }
.banner { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius); background: color-mix(in oklab, var(--danger, #dc2626) 12%, var(--surface));
  border: var(--border-width) solid color-mix(in oklab, var(--danger, #dc2626) 40%, transparent); }
.main > .banner { margin: var(--space-4) var(--space-6) 0; }
@media (max-width: 720px) { .main > .banner { margin: var(--space-3) var(--space-3) 0; } }

/* Typography polish: steadier numbers, tighter headings, nicer rendering */
body { text-rendering: optimizeLegibility; font-feature-settings: "kern", "liga", "calt"; }
h1, h2, h3, .card__title, .topbar__title { letter-spacing: -0.012em; }
.num, .stat__value, td.num, th.num, .money, .progress + .field__help { font-variant-numeric: tabular-nums; }
::selection { background: color-mix(in oklab, var(--accent) 28%, transparent); }


/* Plugins: the card a link jumped to (#/plugins/<id>) */
.card.is-focus { box-shadow: 0 0 0 2px var(--accent); }
.card { scroll-margin-top: 72px; }

/* Small screens: the AI buttons in the top bar show just their emoji */
@media (max-width: 720px) { .topbar__label { display: none; } }
