/* ═══════════════════════════════════════════════════════════════════════════
   IIKO Assistant — Design System CSS
   v1.0 · mobile-first · adaptive to desktop
   ─────────────────────────────────────────────────────────────────────────
   Drop this file into frontend/css/iiko.css and link before any feature
   stylesheets. All visual language is token-driven: redefine variables in
   :root to re-skin the whole app.
═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* ── Tokens ────────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --surface-sunken:   #efe9d8;
  --surface-page:     #f5f1e8;
  --surface:          #ffffff;
  --surface-raised:   #faf7ef;
  --surface-inverse:  #1a1a1a;

  /* Ink */
  --ink:         #1a1a1a;
  --ink-muted:   #6b6356;
  --ink-subtle:  #8a7e6b;
  --ink-faint:   #a39b8e;
  --ink-inverse: #ffffff;

  /* Accent — terracotta */
  --accent-soft: #faf4e8;
  --accent:      #d97757;
  --accent-deep: #b75d3f;

  /* Semantic */
  --success-bg: #e6f4ea;
  --success:    #2e7d32;
  --warning-bg: #fff3d8;
  --warning:    #8a6a00;
  --warning-dot:#c48a00;
  --danger-bg:  #fdecea;
  --danger:     #c53030;

  /* Lines */
  --hairline:        #f0ead9;
  --hairline-strong: #e8e1d1;

  /* Spacing (4pt) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* Radii */
  --r-xs: 5px; --r-sm: 9px; --r-md: 12px; --r-lg: 14px;
  --r-xl: 18px; --r-2xl: 24px; --r-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.04), 0 2px 8px rgba(26, 26, 26, 0.04);
  --shadow-md: 0 4px 16px rgba(26, 26, 26, 0.08);
  --shadow-lg: 0 -8px 32px rgba(26, 26, 26, 0.12);

  /* Type */
  --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --font-handwritten: 'Caveat', 'Comic Sans MS', cursive;

  /* Layout */
  --header-h: 56px;
  --content-max: 720px;       /* single-column centered max (tablet-ish) */
  --sidebar-w: 280px;         /* desktop */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
}

/* ── Base ──────────────────────────────────────────────────────────── */
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface-page);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── Icons ─────────────────────────────────────────────────────────── */
.ic     { width: 20px; height: 20px; flex-shrink: 0; color: currentColor; }
.ic-12  { width: 12px; height: 12px; }
.ic-14  { width: 14px; height: 14px; }
.ic-16  { width: 16px; height: 16px; }
.ic-18  { width: 18px; height: 18px; }
.ic-20  { width: 20px; height: 20px; }
.ic-24  { width: 24px; height: 24px; }
.ic-32  { width: 32px; height: 32px; }

/* ── Type utilities (optional shortcuts) ─────────────────────────── */
.t-display  { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.t-title    { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.t-heading  { font-size: 17px; font-weight: 700; line-height: 1.3; }
.t-body     { font-size: 15px; line-height: 1.55; }
.t-strong   { font-size: 15px; font-weight: 600; line-height: 1.5; }
.t-label    { font-size: 13px; font-weight: 600; line-height: 1.4; }
.t-caption  { font-size: 12px; line-height: 1.5; color: var(--ink-muted); }
.t-mono     { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }

/* ── Eyebrow ───────────────────────────────────────────────────────── */
.eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--ink-subtle);
}
.eyebrow-accent { color: var(--accent-deep); }

/* Form stack primitives — flex-column, children stretch full-width */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-tight { display: flex; flex-direction: column; gap: 10px; }

/* ═══════════════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  padding: 12px 18px;
  border-radius: var(--r-lg);
  font-size: 15px; font-weight: 600; line-height: 1;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  border: 1px solid transparent;
  white-space: nowrap;
  min-height: 44px;          /* tap target */
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(0.98); }
.btn[hidden] { display: none; }
.btn.is-spinning .ic { animation: spin 0.9s linear infinite; }

.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; border-radius: var(--r-sm); }
.btn-lg { padding: 16px 22px; font-size: 16px; min-height: 52px; }

/* Primary — dark with terracotta text */
.btn-primary {
  background: var(--ink);
  color: var(--accent);
}
.btn-primary:not(:disabled):hover { background: #2a2a2a; }

/* Secondary — sand surface, dark text */
.btn-secondary {
  background: var(--surface-raised);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-secondary:not(:disabled):hover {
  background: var(--hairline);
  border-color: var(--hairline-strong);
}

/* Ghost — no fill */
.btn-ghost {
  background: transparent;
  color: var(--ink);
}
.btn-ghost:not(:disabled):hover { background: var(--surface-raised); }

/* Danger */
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:not(:disabled):hover { background: #fbdad5; }

/* Success — commit/save action */
.btn-success {
  background: #e2efe5;
  color: #2c8a3e;
  border-color: transparent;
}
.btn-success:not(:disabled):hover { background: #cfe6d5; }

/* Icon-only */
.btn-icon-only {
  width: 40px; height: 40px; min-height: 40px;
  padding: 0; border-radius: var(--r-full);
}
.btn-icon-only.btn-sm { width: 32px; height: 32px; min-height: 32px; }
.btn-icon-only.btn-lg { width: 48px; height: 48px; min-height: 48px; }

/* Back — чёрная круглая кнопка с белым шевроном, без текста (шапки экранов) */
.btn-back {
  background: var(--ink);
  color: var(--ink-inverse);
}
.btn-back:not(:disabled):hover { background: #2a2a2a; }

.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:not(:disabled):hover { background: var(--danger-bg); }

/* Send button — accent fill */
.btn-send {
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-full);
}
.btn-send:not(:disabled):hover { background: var(--accent-deep); }

/* ═══════════════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════════════ */
.field {
  display: flex; flex-direction: column; gap: 6px;
  width: 100%;
}
.field-label {
  font-size: 12px; font-weight: 600; color: var(--ink-muted);
  letter-spacing: 0.2px;
}
.field-hint {
  font-size: 12px; color: var(--ink-subtle); line-height: 1.5;
}
.field-error-msg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--danger);
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-raised);
  border: 1.5px solid transparent;
  font-size: 15px;
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
  outline: none;
  min-height: 44px;
}
.input::placeholder { color: var(--ink-faint); }
.input:hover { background: var(--hairline); }
.input:focus {
  background: var(--surface);
  border-color: var(--accent);
}
/* Chrome/Safari autofill — keep cream background, dark text */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--surface-raised) inset;
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  transition: background-color 9999s ease-in-out 0s;
}
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
}

.field-error .input,
.input.is-invalid {
  border-color: var(--danger);
  background: var(--surface);
}

.form-error {
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
  min-height: 18px;
}
.form-error:empty { display: none; }

/* Password input with visibility toggle */
.password-wrapper {
  position: relative;
  display: block;
}
.input.has-toggle {
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.password-toggle:hover { color: var(--ink); background: var(--hairline); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.password-toggle .ic-eye-slash { display: none; }
.password-toggle.is-visible .ic-eye { display: none; }
.password-toggle.is-visible .ic-eye-slash { display: inline-block; }

/* Select trigger (opens a sheet) */
.select-trigger {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface-raised);
  border: 1.5px solid transparent;
  text-align: left;
  min-height: 44px;
  transition: background var(--dur-fast) var(--ease);
}
.select-trigger:not(:disabled):hover { background: var(--hairline); }
.select-trigger:disabled { opacity: 0.6; cursor: not-allowed; }

.select-value {
  flex: 1; min-width: 0;
  font-size: 14px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.select-empty .select-value { color: var(--ink-faint); font-weight: 400; }
.select-chevron { color: var(--ink-faint); flex-shrink: 0; }

/* Search input */
.search-input {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 12px;
  background: var(--surface-raised);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  min-height: 44px;
  transition: border-color var(--dur-fast) var(--ease);
}
.search-input:focus-within {
  background: var(--surface);
  border-color: var(--accent);
}
.search-input .search-icon { color: var(--ink-faint); flex-shrink: 0; }
.search-input input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  font-size: 15px;
  padding: 12px 0;
}
.search-input input::placeholder { color: var(--ink-faint); }
.search-clear {
  width: 24px; height: 24px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint);
}
.search-clear:hover { background: var(--hairline); color: var(--ink); }

/* Radio card */
.radio-card {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1.5px solid var(--hairline);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.radio-card:hover { border-color: var(--hairline-strong); }
.radio-card input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--hairline-strong);
  flex-shrink: 0; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
  position: relative;
}
.radio-card input[type="radio"]:checked {
  border-color: var(--ink);
  background: var(--ink);
  box-shadow: inset 0 0 0 4px var(--surface);
}
.radio-card:has(input:checked) {
  border-color: var(--ink);
  background: var(--accent-soft);
}
.radio-card-body { flex: 1; min-width: 0; }
.radio-card-title { display: block; font-size: 15px; font-weight: 600; color: var(--ink); }
.radio-card-sub   { display: block; font-size: 12px; color: var(--ink-muted); margin-top: 2px; font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════════════
   CHIPS / STATUS
═══════════════════════════════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-xs);
  background: var(--surface-raised);
  border: 1px solid var(--hairline);
  font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
  color: var(--ink);
}
.chip-accent  { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; }
.chip-inverse { background: var(--ink);         color: var(--accent);      border-color: transparent; text-transform: uppercase; letter-spacing: 0.7px; font-size: 10px; padding: 3px 7px; }

.status-strip {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.status-ok      { background: var(--success-bg); color: var(--success); }
.status-ok      .status-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.status-warning { background: var(--warning-bg); color: var(--warning); }
.status-warning .status-dot { background: var(--warning-dot); }
.status-error   { background: var(--danger-bg); color: var(--danger); }
.status-error   .status-dot { background: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
}

/* Menu card — big tap target */
.menu-card {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  transition: border-color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  color: var(--ink);
  min-height: 76px;
}
.menu-card:hover  { border-color: var(--ink); }
.menu-card:active { transform: scale(0.99); }
.menu-card-icon {
  width: 48px; height: 48px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.menu-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.menu-card-title { font-size: 16px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.menu-card-sub   { font-size: 13px; color: var(--ink-muted); }
.menu-card-chevron { color: var(--ink-faint); flex-shrink: 0; }

/* Concept card */
.concept-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.concept-card.is-default {
  border: 1.5px solid var(--ink);
  box-shadow: var(--shadow-sm);
}
.concept-card-head { display: flex; align-items: flex-start; gap: var(--sp-3); }
.concept-card-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.concept-card-icon.is-default { background: var(--ink); color: var(--accent); }
.concept-card-head-body { flex: 1; min-width: 0; }
.concept-card-title-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.concept-card-title { font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -0.1px; }
.concept-card-host {
  font-size: 12px; color: var(--ink-muted);
  font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}
.concept-card-login { font-size: 11px; color: var(--ink-subtle); margin-top: 2px; }
.concept-card-actions { display: flex; gap: 6px; }

/* Warehouse row inside concept card */
.concept-warehouse {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--accent-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
}
.concept-warehouse-icon {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--surface); color: var(--accent-deep);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.concept-warehouse-body { flex: 1; min-width: 0; }
.concept-warehouse-name {
  font-size: 12px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 2px;
}

/* Summary card — dark */
.summary-card {
  background: var(--surface-inverse); color: var(--ink-inverse);
  border-radius: var(--r-xl);
  position: relative; overflow: hidden;
}
.summary-card::before {
  content: ''; position: absolute;
  top: -30px; right: -20px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(217,119,87,0.28), transparent 70%);
  pointer-events: none;
}
.summary-concept {
  display: flex; align-items: center; gap: 6px;
  padding: 12px var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: var(--ink-faint);
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}
.summary-concept svg { color: var(--accent); flex-shrink: 0; }
.summary-concept-label {
  font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  margin-right: 2px;
}
.summary-concept-value {
  color: var(--ink-inverse); font-weight: 500; font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.summary-body {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  padding: var(--sp-4) var(--sp-5) var(--sp-4);
  position: relative;
}
.summary-amount-block { min-width: 0; }
.summary-eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 4px;
}
.summary-amount {
  font-size: 30px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--ink-inverse);
  font-variant-numeric: tabular-nums;
}
.summary-count-block { text-align: right; flex-shrink: 0; }
.summary-count-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.7px; text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 2px;
}
.summary-count-value {
  font-size: 20px; font-weight: 700;
  color: var(--ink-inverse);
  font-variant-numeric: tabular-nums;
}
.summary-items {
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.2);
  position: relative;
}
.summary-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--sp-5);
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.summary-item:first-child { border-top: none; }
.summary-item-name {
  flex: 1; min-width: 0;
  color: var(--ink-inverse); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.summary-item-qty {
  color: var(--ink-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.summary-item-total {
  width: 78px; text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-inverse);
  flex-shrink: 0;
}
.summary-meta {
  font-size: 12px; color: var(--ink-faint);
  padding: 0 var(--sp-5) var(--sp-4);
}

/* ═══════════════════════════════════════════════════════════════════
   BOTTOM SHEET
═══════════════════════════════════════════════════════════════════ */
#sheet-host { position: relative; z-index: 9000; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(26, 26, 26, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: sheet-fade var(--dur) var(--ease);
}
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: var(--content-max);  /* на десктопе шит держится ширины рабочей области (720px), backdrop его центрирует; на узком экране width:100% */
  max-height: 88vh;
  background: var(--surface);
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  display: flex; flex-direction: column;
  padding: var(--sp-2) var(--sp-4) var(--sp-4);
  padding-bottom: calc(var(--sp-4) + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  animation: sheet-up var(--dur) var(--ease);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-handle {
  width: 36px; height: 4px; border-radius: 999px;
  background: var(--hairline-strong);
  margin: 0 auto var(--sp-3);
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--hairline);
  margin-bottom: var(--sp-3);
}
.sheet-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.sheet-body {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  margin: 0 calc(var(--sp-4) * -1 + var(--sp-2)) 0;
  padding: 0 var(--sp-2);
}

/* Option row inside a sheet */
.option-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 12px 10px;
  border-radius: var(--r-sm);
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
  min-height: 48px;
}
.option-row:hover { background: var(--surface-raised); }
.option-row.is-selected { background: var(--accent-soft); }
.option-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.option-title { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.option-sub   { font-size: 12px; color: var(--ink-muted); }
.option-check { color: var(--ink); flex-shrink: 0; }

/* Demo sheet (for the DS page only) */
.sheet-demo { max-width: 420px; border-radius: var(--r-2xl); margin: 20px auto; animation: none; }

/* ═══════════════════════════════════════════════════════════════════
   STEPPER
═══════════════════════════════════════════════════════════════════ */
.stepper {
  display: flex; align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
}
.stepper-step {
  display: flex; align-items: center; gap: var(--sp-2);
  color: var(--ink-faint); font-size: 12px; font-weight: 600;
}
.stepper-step:not(:last-child)::after {
  content: ""; flex: 1; height: 1.5px; background: var(--hairline-strong);
  margin-left: var(--sp-2); min-width: 12px;
}
.stepper-dot {
  width: 22px; height: 22px; border-radius: var(--r-full);
  background: var(--surface); border: 1.5px solid var(--hairline-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--ink-faint);
  flex-shrink: 0;
}
.stepper-label { display: none; }
.stepper-step.is-done    .stepper-dot { background: var(--ink); border-color: var(--ink); color: var(--accent); }
.stepper-step.is-done::after { background: var(--ink); }
.stepper-step.is-current .stepper-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper-step.is-current .stepper-label { display: inline; color: var(--accent-deep); }

/* On wider viewports, show all labels */
@media (min-width: 640px) {
  .stepper-label { display: inline; }
  .stepper-step.is-done .stepper-label { color: var(--ink-muted); }
}

/* ═══════════════════════════════════════════════════════════════════
   CHAT
═══════════════════════════════════════════════════════════════════ */
.msg {
  display: flex; flex-direction: column;
  max-width: 85%;
  min-width: 0;
}
.msg-user      { align-self: flex-end; align-items: flex-end; }
.msg-assistant { align-self: flex-start; align-items: flex-start; max-width: 100%; width: 100%; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--r-lg);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.msg-user .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

/* Composer */
.composer {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
}
.composer-input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  font-size: 15px;
  padding: 8px 6px;
  min-height: 36px;
}
.composer-input::placeholder { color: var(--ink-faint); }

/* ═══════════════════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════════════════ */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh; /* iOS Safari: 100vh включает зону за нижним баром → паразитный скролл */
  background: var(--surface-page);
  display: flex;
}

/* On desktop/tablet landscape: center the app as a phone-shaped column,
   decorative beige fills the sides. Mobile/tablet portrait: full width. */
@media (min-width: 768px) {
  body { background: var(--surface-page); }
  .app-shell {
    max-width: 720px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    box-shadow: 0 0 48px rgba(26, 26, 26, 0.08);
  }
}

/* Sidebar disabled for production app (only used in design system preview) */
.app-sidebar { display: none !important; }

/* Screen visibility toggle (SPA with multiple pre-mounted screens) */
[data-screen] { display: none; }
[data-screen].is-active { display: block; }
/* Screens that use app-shell layout need flex column to fill viewport */
[data-screen].is-active.uses-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* Auth tab panes: only active one visible */
.auth-tab-pane { display: none; }
.auth-tab-pane.is-active { display: block; }

.app-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  flex-shrink: 0;
  height: var(--header-h);
  padding: var(--safe-top) var(--sp-4) 0;
  display: flex; align-items: center; gap: var(--sp-3);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-page);
  position: sticky; top: 0; z-index: 10;
}
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header { height: calc(var(--header-h) + var(--safe-top)); }
}
.app-title {
  flex: 1; min-width: 0;
  font-size: 16px; font-weight: 700;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-avatar {
  width: 40px; height: 40px; border-radius: var(--r-full);
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.app-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.app-scroll-inner {
  width: 100%; max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4);
  box-sizing: border-box;
  min-width: 0;
}
/* Fill available height — lets content (e.g. empty-block) stretch to footer */
.app-scroll-inner.is-fill {
  min-height: 100%;
  display: flex; flex-direction: column;
}
.stack.is-fill { flex: 1; min-height: 0; }

.app-footer {
  flex-shrink: 0;
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-3) + var(--safe-bottom));
  background: var(--surface-page);
  border-top: 1px solid var(--hairline);
}
.app-footer-inner { max-width: var(--content-max); margin: 0 auto; }

/* ─── Login screen helper ─────────────────────────── */
.auth-stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6) var(--sp-4);
  padding-top: calc(var(--sp-6) + var(--safe-top));
  padding-bottom: calc(var(--sp-6) + var(--safe-bottom));
  background: var(--surface-page);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  display: flex; flex-direction: column; gap: var(--sp-5);
}
.auth-logo {
  text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: var(--sp-2);
}
.auth-logo-mark {
  width: 56px; height: 56px; border-radius: var(--r-xl);
  background: var(--ink); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.auth-logo h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.auth-logo p  { font-size: 13px; color: var(--ink-muted); }

/* Keyboard-focus styling */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:focus-visible, .radio-card:focus-visible, .option-row:focus-visible {
  outline-offset: 3px;
}

/* ═══════════════════════════════════════════════════════════════════
   LOGIN — hero + sheet (v2: warm hi-fi treatment)
═══════════════════════════════════════════════════════════════════ */
.auth-stage.auth-stage {
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  padding: 0;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-page);
}
.auth-stage.auth-stage > .auth-hero,
.auth-stage.auth-stage > .auth-sheet { width: 100%; align-self: stretch; flex-shrink: 0; }
.auth-hero {
  background: linear-gradient(180deg, #1a1a1a 0%, #2b2622 100%);
  color: #fefdf9;
  padding: calc(40px + var(--safe-top)) 28px 72px;
  position: relative; overflow: hidden;
}
.auth-hero-glow {
  position: absolute; border-radius: 50%;
  pointer-events: none;
}
.auth-hero-glow-1 {
  top: -40px; right: -50px;
  width: 220px; height: 220px;
  background: radial-gradient(circle at 30% 30%, rgba(217,119,87,0.35), transparent 70%);
}
.auth-hero-glow-2 {
  bottom: 20px; left: -30px;
  width: 140px; height: 140px;
  background: radial-gradient(circle at 50% 50%, rgba(217,119,87,0.12), transparent 70%);
}
.auth-hero-body { position: relative; }
.auth-hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(217,119,87,0.15);
  border: 1px solid rgba(217,119,87,0.3);
  border-radius: 100px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  letter-spacing: 0.3px;
}
.auth-hero-badge-dot {
  width: 6px; height: 6px;
  background: var(--accent); border-radius: 50%;
}
.auth-hero-salute {
  font-family: var(--font-handwritten);
  font-size: 36px; margin-top: 28px;
  color: var(--accent); letter-spacing: -0.5px; line-height: 1;
}
.auth-hero-title {
  font-size: 30px; font-weight: 800; margin-top: 6px;
  letter-spacing: -0.8px; line-height: 1.1;
}
.auth-hero-sub {
  font-size: 15px; opacity: 0.65; margin-top: 14px;
  line-height: 1.5; max-width: 280px;
}
.auth-sheet {
  background: var(--surface-page);
  margin-top: -28px;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding: 28px 22px 28px;
  padding-bottom: calc(28px + var(--safe-bottom));
  position: relative; z-index: 2;
  box-shadow: 0 -2px 20px rgba(40,30,20,0.06);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.auth-tabs {
  display: flex; background: var(--surface-raised);
  border-radius: 12px; padding: 4px;
  margin-bottom: 8px;
}
.auth-tab {
  flex: 1; padding: 10px 8px;
  background: transparent; border: none;
  border-radius: 9px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  color: var(--ink-muted);
  transition: all 0.15s;
}
.auth-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.auth-forgot {
  color: var(--accent); font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.auth-forgot:hover { text-decoration: underline; }
.auth-fineprint {
  font-size: 11px; color: var(--ink-subtle);
  text-align: center; line-height: 1.5; margin-top: 2px;
}
.auth-legal {
  font-size: 11px; color: var(--ink-subtle);
  text-align: center; line-height: 1.6; margin-top: 14px;
}
.auth-legal u { text-decoration: underline; }

/* Версия прижата к низу экрана; политики остаются под кнопкой логина.
   Экран логина — flex-колонка на всю высоту, stage (flex:1) заполняет её,
   sheet занимает остаток (переопределяет flex-shrink:0 из общего правила
   hero/sheet), а margin-top:auto на .app-version отталкивает её вниз. */
#screen-login.is-active {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
}
.auth-stage.auth-stage > .auth-sheet { flex: 1 0 auto; }
.auth-sheet .app-version { margin-top: auto; padding-top: 14px; }

/* ═══════════════════════════════════════════════════════════════════
   MENU — Caveat salute
═══════════════════════════════════════════════════════════════════ */
.greeting-salute {
  font-family: var(--font-handwritten);
  font-size: 30px; color: var(--accent);
  line-height: 1; letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.greeting .greeting-title {
  font-size: 26px; font-weight: 800;
  color: var(--ink); letter-spacing: -0.5px;
  line-height: 1.15;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   STEP 1 — upload buttons in footer
═══════════════════════════════════════════════════════════════════ */
.app-footer-stack {
  display: flex; flex-direction: column; gap: var(--sp-2);
  width: 100%; align-self: stretch;
}
.upload-row {
  display: flex; gap: 10px;
}
.upload-btn {
  flex: 1; padding: 14px 12px;
  border-radius: 14px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.upload-btn:hover { transform: translateY(-1px); }
.upload-btn-primary {
  background: var(--ink); color: var(--surface);
  border: none;
}
.upload-btn-secondary {
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--ink);
}

.empty-block {
  padding: 32px 20px; text-align: center;
  background: var(--surface);
  border: 1px dashed var(--hairline-strong);
  border-radius: 14px;
  color: var(--ink-muted);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty-block svg { color: var(--ink-subtle); margin-bottom: 4px; }
.empty-block-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.empty-block-sub { font-size: 12px; color: var(--ink-muted); line-height: 1.45; }
.empty-block-cta { margin-top: 14px; gap: 8px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.section-head-meta {
  font-size: 12px; color: var(--accent-deep); font-weight: 600;
}
.section-head-action {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent;
  border: 0;
  color: var(--accent-deep);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-md);
}
.section-head-action:hover { background: var(--surface-elev); }

.status-dot-ok {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success); display: inline-block;
}

/* ═══════════════════════════════════════════════════════════════════
   CONCEPT EDIT SHEET
═══════════════════════════════════════════════════════════════════ */
.sheet-tall { max-height: 92vh; }
.sheet-subtitle {
  font-size: 12px; color: var(--ink-muted);
  margin-top: 2px;
}
.sheet-actions {
  display: flex; gap: 10px; margin-top: 18px;
}
.confirm-text {
  font-size: 14px; line-height: 1.5; color: var(--ink);
  margin: 0 0 10px;
}
.confirm-text:last-child { margin-bottom: 0; }
.confirm-text-muted { color: var(--ink-subtle); font-size: 13px; }
.field-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}

.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-strip.status-danger {
  background: #fdecea; color: #c53030;
}
.status-strip.status-danger .status-dot { background: #c53030; }

.concept-wh-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 12px;
  transition: all 0.15s;
}
.concept-wh-card.is-disabled {
  background: var(--surface-raised);
  opacity: 0.75;
}
.concept-wh-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.concept-wh-body { flex: 1; min-width: 0; }
.concept-wh-title {
  font-size: 13px; font-weight: 700; color: var(--ink);
}
.concept-wh-sub {
  font-size: 11px; color: var(--ink-muted);
  margin-top: 1px; line-height: 1.4;
}

/* Stacked sheet (warehouse picker on top of concept edit) */
.sheet-stack {
  position: fixed; inset: 0; z-index: 9100;
}
.sheet-stack .sheet-backdrop {
  background: rgba(0,0,0,0.3);
}

/* Concept card action — make default */
.concept-make-default {
  width: 100%; margin-top: 10px;
  padding: 9px 10px;
  background: var(--surface-raised); border: none;
  border-radius: 10px;
  font-size: 12px; font-weight: 600; color: var(--ink);
  cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.concept-make-default:hover { background: var(--hairline); }

/* Concept add/edit — numbered steps */
.step-block {
  position: relative;
  padding: 14px 14px 14px 14px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--surface);
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.step-block + .step-block { margin-top: 12px; }
.step-block.is-locked {
  background: var(--surface-raised);
  opacity: 0.7;
}
.step-block.is-locked .step-num { background: var(--hairline); color: var(--ink-faint); }
.step-block.is-active { border-color: var(--accent-soft); }
.step-block.is-done .step-num {
  background: var(--success-bg); color: var(--success);
}
.step-head {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
}
.step-num {
  flex: 0 0 22px;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700;
  margin-top: 1px;
}
.step-head-body { flex: 1; min-width: 0; }
.step-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
  line-height: 1.25;
}
.step-sub {
  font-size: 12px; color: var(--ink-muted);
  margin-top: 2px; line-height: 1.4;
}
.select-trigger-icon {
  display: inline-flex; color: var(--ink-muted);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   STEP 3 — QUANTITY & PRICE (frozen name col + scrollable grid)
═══════════════════════════════════════════════════════════════════ */
.qty-scroll-inner { padding-bottom: 20px; }

.qty-table {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--hairline);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(40, 30, 20, 0.03);
  width: 100%; max-width: 100%;
}
.qty-table-inner { display: flex; min-width: 0; }

/* Frozen name column */
.qty-frozen {
  flex: 0 0 132px;
  border-right: 1px solid var(--hairline);
  background: var(--surface);
  position: relative; z-index: 2;
  box-shadow: 2px 0 6px rgba(40, 30, 20, 0.04);
}
.qty-head-cell,
.qty-head-row {
  height: 42px;
  padding: 0 12px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--hairline);
  font-size: 10px; font-weight: 700;
  color: var(--ink-subtle);
  text-transform: uppercase; letter-spacing: 0.8px;
  display: flex; align-items: center;
}
.qty-name-cell {
  height: 68px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center;
  overflow: hidden;
}
.qty-frozen .qty-name-cell:last-child { border-bottom: none; }
.qty-name-cell span {
  font-size: 13px; font-weight: 600; color: var(--ink);
  line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}

/* Scrollable columns */
.qty-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.qty-scroll-grid {
  --col-qty: 60px;
  --col-unit: 50px;
  --col-price: 60px;
  --col-sum: 80px;
  min-width: max-content;
}

.qty-head-row {
  display: grid;
  grid-template-columns: var(--col-qty) var(--col-unit) var(--col-price) var(--col-sum) 56px;
  gap: 12px;
  padding: 0 16px 0 12px;
}
.qty-data-row {
  display: grid;
  grid-template-columns: var(--col-qty) var(--col-unit) var(--col-price) var(--col-sum) 56px;
  gap: 12px;
  padding: 0 16px 0 12px;
  height: 68px;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
  position: relative;
}
.qty-scroll-grid > .qty-data-row:last-child { border-bottom: none; }

.ta-right  { text-align: right; }
.ta-center { text-align: center; }

/* Qty number cell with split button + info */
.qty-num-wrap { position: relative; min-width: 0; }
.qty-num-btn {
  display: inline-flex; align-items: stretch;
  max-width: 100%;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.qty-num-value {
  padding: 7px 8px;
  background: transparent; border: none;
  font-size: 13px; font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  cursor: pointer;
  min-width: 0; text-align: left;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto;
}
.qty-num-info {
  padding: 0 7px;
  background: transparent;
  border: none; border-left: 1px solid var(--hairline-strong);
  cursor: pointer;
  display: flex; align-items: center;
  color: var(--accent);
  flex: 0 0 auto;
  position: relative; z-index: 1;
}

/* Info tooltip */
.qty-info-tooltip {
  position: absolute;
  top: 36px; left: 0;
  z-index: 20;
  background: var(--ink); color: #fff;
  padding: 10px 28px 10px 12px;
  border-radius: 10px;
  font-size: 11px; line-height: 1.6;
  width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  font-family: var(--font-mono);
}
.qty-info-arrow {
  position: absolute; top: -5px; left: 24px;
  width: 10px; height: 10px;
  background: var(--ink);
  transform: rotate(45deg);
}
.qty-info-close {
  position: absolute; top: 4px; right: 4px;
  background: transparent; border: none; color: #fff;
  font-size: 12px; cursor: pointer; opacity: 0.6;
  padding: 4px;
}

/* Unit pill */
.qty-unit-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 9px;
  border: 1px solid var(--hairline-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px; color: var(--ink);
  font-weight: 500;
  max-width: 100%;
  min-width: 0;
}
.qty-unit-pill > span:first-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qty-unit-caret { color: var(--ink-faint); font-size: 10px; }

.qty-price {
  font-variant-numeric: tabular-nums;
  color: var(--ink); font-size: 12px;
}
.qty-sum {
  font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--ink); font-size: 13px;
}
.qty-vat {
  font-size: 11px; color: var(--ink-subtle);
  font-feature-settings: 'tnum';
}

/* Total bar */
.qty-total-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--ink); color: #fefdf9;
}
.qty-total-bar-label {
  font-size: 12px; opacity: 0.6;
  letter-spacing: 0.5px; text-transform: uppercase; font-weight: 600;
}
.qty-total-bar-value {
  font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.qty-scroll-hint {
  margin-top: 10px;
  padding-left: 6px;
  font-size: 11px; color: var(--ink-subtle);
  display: flex; align-items: center; gap: 6px;
}

/* App header badge (shared) */
.app-header-badge {
  margin-left: auto;
  font-size: 12px; font-weight: 600; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* Qty edit sheet */
.qty-edit-sheet .sheet-sub {
  font-size: 12px; color: var(--ink-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.qty-edit-wrap {
  display: flex; align-items: stretch; gap: 10px;
  margin: 6px 0 10px;
}
.qty-edit-step {
  width: 52px;
  background: var(--surface-raised);
  border: 1.5px solid var(--hairline-strong);
  border-radius: var(--r-md);
  font-size: 24px; font-weight: 700;
  color: var(--ink); cursor: pointer;
  font-family: inherit;
}
.qty-edit-step:hover { background: var(--hairline); }
.qty-edit-input {
  flex: 1;
  border: 1.5px solid var(--ink);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 28px; font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-ui);
  color: var(--ink);
  padding: 10px;
  outline: none;
}
.qty-edit-unit {
  text-align: center;
  font-size: 12px; font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-bottom: 4px;
}

/* Menu header with concept switcher */
.menu-header {
  flex-shrink: 0;
  padding: calc(var(--safe-top) + 12px) var(--sp-4) 12px;
  display: flex; align-items: center; gap: var(--sp-3);
  justify-content: space-between;
  background: var(--surface-page);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 10;
}
.concept-switch {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px;
  background: transparent; border: 0; padding: 4px 6px;
  border-radius: var(--r-md);
  cursor: pointer;
  max-width: calc(100% - 56px);
  text-align: left;
}
.concept-switch:hover { background: var(--surface-elev); }
.concept-switch-eyebrow {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--ink-muted);
}
.concept-switch-name {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 16px; font-weight: 700;
  color: var(--ink);
  max-width: 100%;
}
.concept-switch-name > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: calc(100% - 20px);
}

/* Greeting block */
.greeting { margin-bottom: 20px; }
.greeting-salute {
  font-family: var(--font-handwritten);
  font-size: 28px; font-weight: 600;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}
.greeting-title {
  font-size: 24px; font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

/* Radio-card — for the concept picker */
.radio-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--hairline);
  border-radius: var(--r-lg);
  cursor: pointer;
  position: relative;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.radio-card input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2px solid var(--hairline);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.radio-card input[type="radio"]:checked {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 40%, transparent 45%);
}
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--surface-elev);
}
.radio-card-body {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1;
}
.radio-card-title {
  font-size: 15px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.radio-card-sub {
  font-size: 12px; color: var(--ink-muted);
  font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Toast */
#app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translate(-50%, 24px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-lg);
  font-size: 14px; font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
  z-index: 10000;  /* выше bottom-sheet (#sheet-host z-index:9000) */
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-md);
}
#app-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
#app-toast.toast-error { background: var(--danger, #c0392b); }

/* Danger button variant used for logout */
.btn-danger {
  background: var(--danger, #c0392b);
  color: #fff;
  border: 0;
}
.btn-danger:not(:disabled):hover { background: #a8311f; }

/* Spinner used in sheet action buttons */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ═══════════════════════════════════════════════════════════════════
   WIZARD FLOW (invoice creation) — 5-step wizard inside #screen-chat
═══════════════════════════════════════════════════════════════════ */

.flow-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.flow-host > * { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* Footer takes natural height, not flex:1 — scroll area fills remainder */
.flow-host > footer.app-footer { flex: 0 0 auto; }

.step-title { font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.step-sub   { font-size: 13px; color: var(--ink-muted); margin-top: -4px; }

/* ── Step 1: drop-zone & file chips ──────────────────────────────── */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 32px 20px;
  background: var(--surface); border: 2px dashed var(--hairline-strong);
  border-radius: var(--r-xl); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover, .drop-zone.is-drag {
  border-color: var(--accent); background: var(--accent-soft);
}
.drop-zone-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.drop-zone-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.drop-zone-sub   { font-size: 12px; color: var(--ink-muted); }

.file-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.file-chip img {
  width: 36px; height: 36px; border-radius: var(--r-sm); object-fit: cover; flex-shrink: 0;
}
.file-chip-icon {
  color: var(--accent-deep);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.file-chip-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-chip-name {
  font-size: 13px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-chip-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-muted); font-family: var(--font-mono);
}

.file-chip--loading { opacity: 0.85; }
.file-chip-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.7s linear infinite;
}
.file-chip-progress {
  margin-top: 6px;
  height: 3px;
  background: var(--hairline);
  border-radius: 2px;
  overflow: hidden;
  transition: opacity 200ms ease;
}
.file-chip-progress[data-done="1"] { opacity: 0; }
.file-chip-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 120ms linear;
}

.flow-progress {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--accent-soft);
  border-radius: var(--r-md); color: var(--accent-deep);
  font-size: 13px;
}
.flow-progress-spinner {
  width: 16px; height: 16px; border: 2px solid var(--accent);
  border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
.flow-progress-text { flex: 1; min-width: 0; }

/* ── Flow loader (between-step full-screen spinner/error) ───────── */
.flow-loader-screen {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 32px 24px; text-align: center;
  min-height: 60vh;
}
.flow-loader-spinner {
  width: 56px; height: 56px;
  border: 4px solid var(--hairline);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.flow-loader-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-deep);
}
.flow-loader-icon.flow-loader-error {
  background: rgba(220, 60, 60, 0.12); color: var(--danger, #d64545);
}
.flow-loader-text {
  font-size: 16px; font-weight: 600; color: var(--ink);
  max-width: 320px; line-height: 1.4;
}
.flow-loader-sub {
  font-size: 13px; color: var(--ink-muted);
  max-width: 320px; line-height: 1.5;
}

/* Loader stage-list (consumables dashboard) — timed sequential animation
   that mirrors the backend phases of pull_all(). */
.flow-loader-stages {
  display: flex; flex-direction: column;
  gap: 10px; margin-top: 12px;
  text-align: left; min-width: 240px;
}
.flow-loader-stages .stage {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink-muted);
  transition: color 0.25s var(--ease);
}
.flow-loader-stages .stage.is-active { color: var(--ink); font-weight: 600; }
.flow-loader-stages .stage-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--hairline-strong);
  background: transparent; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.flow-loader-stages .stage.is-active .stage-dot {
  background: var(--accent); border-color: var(--accent);
}
.flow-loader-stages .stage.is-done .stage-dot {
  background: var(--ink); border-color: var(--ink);
}
.flow-loader-stages .stage.is-done .stage-dot::before {
  content: '✓'; color: var(--accent);
  font-size: 9px; font-weight: 800; line-height: 1;
}

/* ── Step 2: match-rows ──────────────────────────────────────────── */
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-row {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.match-row.is-deleted { opacity: 0.7; background: var(--surface-raised); }
.match-row-title-deleted { text-decoration: line-through; color: var(--ink-muted); font-weight: 500; }
.match-row-header { display: flex; align-items: flex-start; gap: 10px; }
.match-row-title {
  flex: 1; min-width: 0;
  font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.4;
}
.match-row-qty {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted);
  white-space: nowrap; flex-shrink: 0;
  padding: 3px 8px; background: var(--surface-raised); border-radius: 6px;
}

.match-stats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.match-stats-bar {
  height: 6px; background: var(--hairline); border-radius: 3px; overflow: hidden;
}
.match-stats-fill {
  height: 100%; background: var(--accent); transition: width 0.3s ease;
}
.match-stats-text { font-size: 12px; color: var(--ink-muted); font-weight: 600; }

/* ── Sheet: search input + options list ──────────────────────────── */
.sheet-search {
  width: 100%; padding: 10px 12px;
  background: var(--surface-raised); border: 1px solid var(--hairline);
  border-radius: var(--r-md); font-size: 14px; margin-bottom: 10px;
}
.sheet-search:focus { outline: none; border-color: var(--accent); }
.sheet-options { display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow-y: auto; }
.option-empty { padding: 20px; text-align: center; color: var(--ink-muted); font-size: 13px; }
.option-score {
  font-size: 11px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; margin-left: 8px; flex-shrink: 0;
}

/* ── Step 3: qty table with frozen first column ──────────────────── */
.qty-wrap {
  display: flex; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  overflow: hidden; max-width: 100%;
}
.qty-wrap .qty-frozen {
  flex-shrink: 0; width: 140px;
  border-right: 1px solid var(--hairline); background: var(--surface-raised);
  display: flex; flex-direction: column;
}
.qty-wrap .qty-frozen .qty-head {
  padding: 10px 12px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-muted);
  border-bottom: 1px solid var(--hairline); background: var(--surface-raised);
}
.qty-cell-name {
  padding: 10px 12px; font-size: 13px; font-weight: 500; color: var(--ink);
  border-bottom: 1px solid var(--hairline);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  height: 44px; display: flex; align-items: center;
}
.qty-cell-name:last-child { border-bottom: none; }

.qty-wrap .qty-scroll { flex: 1; min-width: 0; overflow-x: auto; }
.qty-wrap .qty-table { width: 100%; border-collapse: collapse; min-width: 360px; }
.qty-wrap .qty-table th {
  padding: 10px; text-align: left;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--ink-muted);
  border-bottom: 1px solid var(--hairline); background: var(--surface-raised);
  white-space: nowrap;
}
.qty-wrap .qty-table td {
  padding: 10px; font-size: 13px; color: var(--ink);
  border-bottom: 1px solid var(--hairline);
  font-variant-numeric: tabular-nums; height: 44px;
}
.qty-wrap .qty-table tr:last-child td { border-bottom: none; }
.qty-cell-edit { cursor: pointer; color: var(--accent-deep); font-weight: 600; border-radius: var(--r-sm); }
.qty-cell-edit:hover { background: var(--accent-soft); }
.qty-cell-sum { font-weight: 700; }
.qty-cell-vat, .qty-cell-unit { color: var(--ink-muted); font-weight: 500; }
.qty-unit-select {
  padding: 4px 6px; font-size: 13px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-xs); color: var(--ink);
}
.qty-unit-label { font-size: 13px; color: var(--ink-muted); }
.qty-info { display: inline-block; margin-left: 4px; font-size: 11px; color: var(--ink-muted); font-weight: 400; }

.qty-total-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface-inverse); color: var(--ink-inverse);
  border-radius: var(--r-md);
}
.qty-total-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-faint);
}
.qty-total-value {
  font-size: 22px; font-weight: 800; color: var(--ink-inverse);
  font-variant-numeric: tabular-nums;
}

/* ── Wheel picker (inside Sheet) ──────────────────────────────────── */
.qty-picker { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.qty-picker-preview {
  text-align: center; font-size: 28px; font-weight: 800;
  color: var(--ink); font-variant-numeric: tabular-nums; padding: 8px 0;
}
.qty-picker-preview-value { display: inline-block; }
.qty-picker-wheels {
  position: relative; display: flex; align-items: center; justify-content: center;
  gap: 12px; height: 200px;
  background: var(--surface-raised); border-radius: var(--r-md);
  overflow: hidden;
}
.wheel {
  position: relative; width: 80px; height: 100%;
  overflow: hidden; user-select: none; touch-action: none; cursor: grab;
}
.wheel:active { cursor: grabbing; }
.wheel-inner { position: absolute; inset: 0; }
.wheel-item {
  position: absolute; top: 80px; left: 0; right: 0;
  height: 40px; line-height: 40px;
  text-align: center; font-size: 22px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; transition: color 0.1s;
}
.wheel-item--selected { color: var(--accent-deep); font-weight: 700; }
.wheel-sep { font-size: 22px; font-weight: 700; color: var(--ink); align-self: center; }
.wheel-highlight {
  position: absolute; left: 0; right: 0; top: 80px; height: 40px;
  border-top: 1px solid var(--hairline-strong);
  border-bottom: 1px solid var(--hairline-strong);
  background: rgba(217,119,87,0.06);
  pointer-events: none;
}
.qty-picker-input-row { display: flex; flex-direction: column; gap: 6px; }
.qty-picker-input-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--ink-muted);
}
.qty-picker-input {
  padding: 10px 12px; background: var(--surface-raised);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  font-size: 14px; font-variant-numeric: tabular-nums;
}
.qty-picker-input:focus { outline: none; border-color: var(--accent); }
.qty-picker-total {
  text-align: center; font-size: 13px; color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Step 4: picker-field (supplier) ─────────────────────────────── */
.picker-field { display: flex; flex-direction: column; gap: 4px; }
.picker-field-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--ink-muted);
}
.picker-field-button {
  width: 100%; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  text-align: left; font-size: 15px; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.picker-field-button:hover { border-color: var(--hairline-strong); }
.picker-field-button.is-empty { color: var(--ink-muted); font-weight: 400; font-style: italic; }
.picker-field-readonly {
  padding: 12px 14px; background: var(--surface-raised);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  font-size: 14px; color: var(--ink);
}
.picker-field-sub { font-size: 12px; color: var(--ink-muted); }
.picker-field-input {
  width: 100%; padding: 12px 14px; background: var(--surface-raised);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  font-size: 14px; color: var(--ink); font-family: inherit;
}
.picker-field-input:focus { outline: none; border-color: var(--accent); }

/* ── Step 5: light summary list ──────────────────────────────────── */
.summary-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 16px; color: var(--ink-inverse); font-size: 13px;
}
.summary-row span { color: var(--ink-faint); }
.summary-row strong {
  color: var(--ink-inverse); font-weight: 600;
  font-variant-numeric: tabular-nums;
  max-width: 60%; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.summary-row--total { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.summary-row--total span {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--accent);
}
.summary-row--total strong { font-size: 22px; font-weight: 800; }
.summary-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 4px 16px; }
.summary-items {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); padding: 12px;
  /* override dark summary-items style in Step 5 list (details element) */
}
details.summary-items { color: var(--ink); }
details.summary-items summary {
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--ink); list-style: none;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 4px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease);
}
details.summary-items summary:hover { background: var(--surface-raised); }
details.summary-items summary::-webkit-details-marker { display: none; }
.summary-items-title { flex: 1; min-width: 0; }
.summary-items-count {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted);
  padding: 2px 8px; background: var(--surface-raised);
  border-radius: 6px; font-weight: 500;
}
.summary-items-caret {
  color: var(--ink-muted); flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease);
}
details.summary-items[open] .summary-items-caret { transform: rotate(180deg); }
.summary-items-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.summary-items-list .summary-item {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  padding: 6px 0; border-top: 1px solid var(--hairline);
  font-size: 13px; color: var(--ink); background: transparent;
}
.summary-items-list .summary-item-name { color: var(--ink); font-weight: 500; }
.summary-items-list .summary-item-qty { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.summary-item-sum {
  font-weight: 700; font-variant-numeric: tabular-nums; min-width: 78px; text-align: right;
}

/* ── Success screen ──────────────────────────────────────────────── */
.success-hero {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 20px 28px;
  text-align: center;
}
.success-mark {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--success-bg); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.success-title { font-size: 22px; font-weight: 800; color: var(--ink); }
.success-sub   { font-size: 14px; color: var(--ink-muted); }
.success-details {
  background: var(--surface-inverse);
  border-radius: var(--r-xl);
  padding: 12px 0;
  display: flex; flex-direction: column; gap: 2px;
}

/* ── Stepper (FlowModule uses .stepper-dot + .stepper-line directly) ─ */
#flow-stepper {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px; background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
#flow-stepper .stepper-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 2px solid var(--hairline-strong);
  background: var(--surface); color: var(--ink-muted);
}
#flow-stepper .stepper-dot--done { background: var(--ink); border-color: var(--ink); color: var(--accent); }
#flow-stepper .stepper-dot--active { background: var(--accent); border-color: var(--accent); color: var(--ink-inverse); }
#flow-stepper .stepper-dot--pending { background: var(--surface); border-color: var(--hairline-strong); color: var(--ink-faint); }
#flow-stepper .stepper-dot-num { font-size: 12px; font-weight: 700; line-height: 1; }
#flow-stepper .stepper-dot-label { display: none; }
.stepper-line {
  flex: 1; height: 2px; background: var(--hairline-strong); align-self: center;
}

/* ── Toast ───────────────────────────────────────────────────────── */
#app-toast.flow-toast {
  position: fixed; left: 50%; bottom: 80px;
  transform: translateX(-50%);
  padding: 10px 16px; background: var(--ink); color: var(--ink-inverse);
  border-radius: var(--r-full);
  font-size: 13px; z-index: 1000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#app-toast.flow-toast.is-visible { opacity: 1; }
#app-toast.flow-toast.is-error { background: var(--danger); }

/* ── Doc-type badge & segmented selector (step 1) ─────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; line-height: 1.4;
  letter-spacing: 0.02em; text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-receipt   { background: #fff4e0; color: #a66200; border-color: #f3d99a; }
.badge-waybill   { background: #e6f1ff; color: #1c4a92; border-color: #b9d2f3; }
.badge-loading   { background: #f1efe9; color: var(--ink-faint); border-color: var(--hairline-strong); }
.badge-unknown   { background: #fbe9e9; color: #9a3a3a; border-color: #ecc7c7; }

.seg-group { display: flex; gap: 6px; }
.seg {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--ink); cursor: pointer;
}
.seg.is-active {
  background: var(--ink); color: var(--ink-inverse);
  border-color: var(--ink);
}

/* ── Consumables ──────────────────────────────────────────── */
/* Fix the screen to the viewport so the cards list scrolls internally
   instead of growing the document — required for finger-scroll on iOS,
   where html/body are pinned to 100%. */
#screen-consumables.is-active.uses-shell {
  height: 100dvh; min-height: 0; max-height: 100dvh;
}
#screen-consumables > .screen-header,
#screen-consumables > .consumables-window-pills,
#screen-consumables > .consumables-toolbar,
#screen-consumables > .consumables-empty { flex-shrink: 0; padding: 8px 16px 16px; }

.detail-hero {
  margin: var(--sp-2) var(--sp-4) var(--sp-5);
  padding: var(--sp-5) var(--sp-6);
  background: #fdfbf4;
  border-color: #ece5d2;
}
.detail-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: -.005em;
  color: #1a1a1a;
  word-break: break-word;
  hyphens: auto;
}

.consumables-window-pills { display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto; }
.consumables-window-pills .pill {
  padding: 4px 12px; border-radius: 16px; background: #eee; border: 0; cursor: pointer;
}
.consumables-window-pills .pill.is-active { background: #2c6cff; color: #fff; }

.consumables-toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px; }

.consumables-filters {
  display: flex; gap: 8px; padding: 0 16px 8px;
  align-items: stretch;
}
.consumables-text-filter {
  height: 36px; padding: 0 10px; font-size: 13px;
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  background: var(--surface-raised); color: var(--ink);
  box-sizing: border-box;
  flex: 1 1 auto; min-width: 0;
}
.consumables-text-filter::placeholder { color: var(--ink-muted); }

/* Custom severity dropdown — native <select> can't render coloured dots
   cross-platform (iOS Safari ignores option styling), so we ship a
   button-popup that visually matches a native select. */
.sev-select { position: relative; flex: 0 0 auto; }
.sev-select-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 10px; font-size: 13px;
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  background: var(--surface-raised); color: var(--ink);
  cursor: pointer; box-sizing: border-box;
}
.sev-select-trigger:hover { background: var(--hairline); }
.sev-select-arrow { color: var(--ink-muted); font-size: 11px; margin-left: 2px; }
.sev-chip-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.sev-chip-dot.sev-red     { background: #c0392b; }
.sev-chip-dot.sev-orange  { background: #ffd60a; }
.sev-chip-dot.sev-green   { background: #2c8a3e; }
.sev-chip-dot.sev-unknown { background: #bbb; }
.sev-chip-dot[hidden]     { display: none; }

.sev-select-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  min-width: 180px;
  display: flex; flex-direction: column;
  padding: 4px; gap: 2px;
  background: var(--surface-raised);
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  box-shadow: 0 4px 14px rgba(26,26,26,0.08);
}
.sev-select-menu[hidden] { display: none; }
.sev-option {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px; font-size: 13px;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--ink); cursor: pointer; text-align: left;
  white-space: nowrap;
}
.sev-option:hover     { background: var(--hairline); }
.sev-option.is-active { background: var(--ink); color: var(--surface-page); }

.consumables-cards {
  display: flex; flex-direction: column; gap: 8px;
  padding: 0 16px 24px;
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.consumable-card {
  position: relative; padding: 8px 12px; border-radius: 10px;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06);
  border-left: 4px solid #ccc;
  line-height: 1.25;
}
.consumable-card.sev-red     { border-left-color: #c0392b; }
.consumable-card.sev-orange  { border-left-color: #ffd60a; }
.consumable-card.sev-green   { border-left-color: #2c8a3e; }
.consumable-card.sev-unknown { border-left-color: #bbb; }
.card-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: #c0392b; color: #fff; cursor: pointer;
  font-size: 12px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.card-remove.is-undo {
  background: #555;       /* neutral — signals "click to revert" */
  font-size: 13px;
}
.consumable-card.is-pending-delete {
  opacity: 0.45;
}
.consumable-card.is-pending-delete .card-title {
  text-decoration: line-through;
}
.card-title { margin: 0 0 4px; font-size: 14px; font-weight: 600; line-height: 1.25; }
.card-line  { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.card-stock { font-weight: 600; }
.card-stock .muted { color: #888; font-weight: 400; font-size: 12px; }
.card-days  { color: #555; white-space: nowrap; }

.badge { padding: 2px 8px; border-radius: 10px; color: #fff; font-size: 12px; }

.banner-warn  { padding: 8px; background: #fff4d6; border-radius: 8px; margin-top: 8px; font-size: 13px; }
.banner-error { padding: 8px; background: #ffd6d6; border-radius: 8px; font-size: 13px; }

.detail-block { padding: 14px 16px; }
.detail-block + .detail-block {
  padding-top: 14px;
  border-top: 1px dashed #d8d2c4;
  margin-top: 4px;
}
.velocity-row {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed #e6dfcc;
}
.velocity-num { font-weight: 600; font-size: 15px; }

/* Skeleton placeholders for the detail view */
.sk {
  display: block;
  background: linear-gradient(90deg, #ece5d2 0%, #f3ecdc 50%, #ece5d2 100%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: sk-pulse 1.2s ease-in-out infinite;
}
.sk-label { height: 11px; width: 50%; margin-bottom: 10px; }
.sk-big   { height: 32px; width: 70%; margin-bottom: 10px; }
.sk-line  { display: inline-block; height: 15px; vertical-align: middle; }
.sk-h3    { height: 14px; width: 35%; margin-bottom: 12px; }
.sk-row   { height: 13px; width: 100%; margin: 8px 0; }
.sk-row + .sk-row { margin-top: 13px; }
@keyframes sk-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.tl-cutoff {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #d8d2c4;
  font-size: 12px;
  color: #999;
  text-align: center;
}
.detail-block h3 { font-size: 14px; color: #666; margin: 0 0 8px;
  text-transform: uppercase; letter-spacing: 0.5px; }
.big-num { font-size: 32px; font-weight: 700; margin-bottom: 10px; }

.dow-table { width: 100%; border-collapse: collapse; }
.dow-table th, .dow-table td { padding: 4px; text-align: center; border: 1px solid #eee; }

.anchor-row { display: flex; justify-content: space-between; padding: 6px 0; }
.tag { padding: 1px 6px; border-radius: 6px; font-size: 11px; margin-right: 4px; }
.tag-iiko   { background: #e6f0ff; color: #2c6cff; }
.tag-manual { background: #fce4ec; color: #c2185b; }

.hol-row { display: flex; justify-content: space-between; padding: 4px 0; }

/* ── Add-item sheet (consumables) ────────────────────────── */
.sheet-filters { display: grid; gap: 8px; padding: 12px 16px; }
.sheet-filters .search-input { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 8px; box-sizing: border-box; }
.used-only { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #555; cursor: pointer; }
.used-only input { margin: 0; }

/* ── Профиль концепта: секция «Честный знак» (AI-2937) ───── */
.cz-group-list { display: flex; flex-direction: column; gap: 6px; }
.cz-group-row { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.cz-group-row input { margin: 0; }

/* ── Detail-screen timeline (4 columns: дата / тип / значение / остаток) */
.tl { display: flex; flex-direction: column; gap: 2px; }
.tl-row {
  display: grid;
  grid-template-columns: 78px 92px 1fr 1fr;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px dashed #eee;
  align-items: center;
  font-size: 13px;
}
.tl-row:last-child { border-bottom: 0; }
.tl-head {
  font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid #ccc; padding-bottom: 4px;
}
.tl-date { color: #666; font-size: 12px; }
.tl-tag { display: inline-block; padding: 2px 6px; border-radius: 6px; font-size: 11px; white-space: nowrap; }
.tl-tag-iiko     { background: #e6f0ff; color: #2c6cff; }
.tl-tag-manual   { background: #fce4ec; color: #c2185b; }
.tl-tag-incoming { background: #e8f5e9; color: #2c8a3e; }
.tl-bal-est { color: #888; font-style: italic; }

/* ── Stock grid (наша оценка / по iiko) ──────────────────── */
.stock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.stock-grid .small { font-size: 11px; }
.stock-grid .big-num.iiko { color: #888; }
.sheet-list { padding: 8px 16px 16px; max-height: 50vh; overflow-y: auto; }
.list-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: #fff; border: 1px solid #eee;
  border-radius: 8px; margin-bottom: 6px; cursor: pointer; width: 100%; text-align: left;
}
.list-row .muted { color: #888; font-size: 12px; }

/* Версия сборки в футерах (логин, профиль) — мелко, но читаемо */
.app-version {
  margin-top: 10px; text-align: center;
  font-size: 11px; font-family: var(--font-mono, monospace);
  color: var(--ink-subtle); letter-spacing: 0.3px;
  min-height: 14px; /* не прыгает при асинхронной подстановке */
}
