/* RemBrat — graphite + orange */
:root {
  --bg: #0f1115;
  --bg-elev: #161a21;
  --surface: #1c212b;
  --surface-2: #242a36;
  --border: #2e3544;
  --border-soft: #252b38;
  --text: #e8eaed;
  --text-dim: #a8b0bd;
  --muted: #7d8796;
  --accent: #f97316;
  --accent-hover: #fb923c;
  --accent-dim: rgba(249, 115, 22, 0.15);
  --ok: #22c55e;
  --warn: #eab308;
  --error: #ef4444;
  --info: #38bdf8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --sidebar: 260px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0 0 0.6rem; font-weight: 650; letter-spacing: -0.02em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); font-size: 0.9em; }
.center { text-align: center; }

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--text);
  font-weight: 700;
}
.brand:hover { color: var(--text); }
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1rem; }
.org-name { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.brand-center { justify-content: center; margin-bottom: 1.25rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #2c3342; color: var(--text); }
.btn-primary {
  background: var(--accent);
  color: #111;
  border-color: transparent;
}
.btn-primary:hover { background: var(--accent-hover); color: #111; }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); background: var(--surface); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-lg { padding: 0.75rem 1.35rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field > span { font-size: 0.82rem; color: var(--text-dim); font-weight: 500; }
.field > span em { font-style: normal; color: var(--muted); font-weight: 400; }
.field-inline { flex-direction: row; align-items: center; gap: 0.6rem; }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.input-compact { padding: 0.35rem 0.5rem; font-size: 0.9rem; }
.w-100 { width: 100px; }
.w-80 { width: 80px; }
.check { flex-direction: row; align-items: center; gap: 0.5rem; }
.check.tiny { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }
.check input { width: auto; }
.topic-picks { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
.topic-picks .check { display: flex; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1rem;
}
.form-grid.tight { gap: 0.7rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 0.6rem; align-items: end; }
.inline-form { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.inline-form input { width: auto; min-width: 180px; }
.inline-form select { width: auto; min-width: 10rem; }
.inline-form input.num, input.num { width: 6rem; min-width: 0; }
.line-staff { margin: 0; }
.line-staff select { min-width: 8rem; }
.table tr.group td { color: var(--text-dim); font-weight: 600; padding-top: 0.9rem; }
.price-type {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 0.7rem;
  box-shadow: var(--shadow);
}
.price-type > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.price-type > summary::-webkit-details-marker { display: none; }
.price-type > summary::before {
  content: "▸";
  color: var(--muted);
  margin-right: 0.55rem;
}
.price-type[open] > summary::before { content: "▾"; }
.price-type > summary span:first-child { flex: 1; }
.price-count { color: var(--muted); font-weight: 500; }
.price-body { padding: 0 1.1rem 1rem; }
.price-origin { margin: 0.35rem 0 0.45rem; font-size: 1rem; }
.price-class { margin: 0.7rem 0 0.35rem; color: var(--muted); font-size: 0.92rem; font-weight: 650; }
.price-place { white-space: nowrap; }
.price-edit { margin: 0; }
.rule-edit { margin-bottom: 0.35rem; }
form.inline { margin: 0 0 0.8rem; }
form.inline { display: inline; }

/* Cards / alerts */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; }
.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.alert-error { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.12); color: #fecaca; }
.alert-ok { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.1); color: #bbf7d0; }
.alert-warn { border-color: rgba(234, 179, 8, 0.4); background: rgba(234, 179, 8, 0.1); color: #fde68a; }
.flash { margin: 0.75rem 1rem; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge-role { background: var(--accent-dim); border-color: rgba(249, 115, 22, 0.35); color: var(--accent); }
.badge-ok { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.35); color: #86efac; }
.badge-warn { background: rgba(234, 179, 8, 0.12); border-color: rgba(234, 179, 8, 0.35); color: #fde047; }

.badge-status.status-lead { background: rgba(56, 189, 248, 0.12); border-color: rgba(56, 189, 248, 0.35); color: #7dd3fc; }
.badge-status.status-waiting_parts { background: rgba(234, 179, 8, 0.12); border-color: rgba(234, 179, 8, 0.4); color: #fde047; }
.badge-status.status-in_progress { background: rgba(249, 115, 22, 0.15); border-color: rgba(249, 115, 22, 0.45); color: #fdba74; }
.badge-status.status-done { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.4); color: #86efac; }
.badge-status.status-cancelled { background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.35); color: #cbd5e1; }

.badge-booking.booking-pending { background: rgba(234, 179, 8, 0.12); border-color: rgba(234, 179, 8, 0.4); color: #fde047; }
.badge-booking.booking-confirmed { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.4); color: #86efac; }
.badge-booking.booking-rejected,
.badge-booking.booking-cancelled { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }

/* Layout: cabinet */
.cabinet-layout {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-bar { display: block; }
.sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.nav-toggle { display: none; }
.nav-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}
.sidebar .brand { padding: 0.35rem 0.5rem 1rem; }
.side-nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 550;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.nav-icon { opacity: 0.8; width: 1.2rem; text-align: center; }
.door-switch {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0.35rem 0.75rem;
}
.door-switch select { flex: 1; min-width: 0; max-width: 16rem; }
.top-actions .door-switch { margin: 0; }
.side-foot {
  border-top: 1px solid var(--border-soft);
  padding-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.user-chip { display: flex; flex-direction: column; gap: 0.25rem; padding: 0 0.35rem; }
.user-name { font-size: 0.9rem; color: var(--text-dim); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem 0.4rem;
  flex-wrap: wrap;
}
.page-head.compact { padding-left: 0; padding-right: 0; }
.page-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.page-body { padding: 0.6rem 1.4rem 2rem; }

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat-card.accent { border-color: rgba(249, 115, 22, 0.35); background: linear-gradient(160deg, var(--accent-dim), var(--surface)); }
.stat-label { color: var(--muted); font-size: 0.8rem; margin-bottom: 0.35rem; }
.stat-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; }
.stat-value.small { font-size: 1.2rem; padding-top: 0.35rem; }
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
}

/* Calendar */
.calendar-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  align-items: start;
}
.cal-col {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  min-height: 280px;
  display: flex;
  flex-direction: column;
}
.cal-col-head {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.cal-col-body { padding: 0.65rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.cal-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  color: var(--text);
}
.cal-card:hover { border-color: var(--accent); color: var(--text); }
.cal-card.status-done { border-left-color: var(--ok); }
.cal-card.status-waiting_parts { border-left-color: var(--warn); }
.cal-card.status-lead { border-left-color: var(--info); }
.cal-card.status-cancelled { border-left-color: var(--muted); opacity: 0.7; }
.cal-card-top { display: flex; justify-content: space-between; gap: 0.4rem; margin-bottom: 0.25rem; font-size: 0.85rem; }
.cal-empty { padding: 1rem 0.5rem; text-align: center; font-size: 0.9rem; }

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  align-items: start;
}
.kanban-col {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  min-height: 240px;
}
.kanban-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border-soft);
}
.kanban-body { padding: 0.55rem; display: flex; flex-direction: column; gap: 0.45rem; }
.kanban-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  color: var(--text);
}
.kanban-card:hover { border-color: var(--accent); color: var(--text); }
.kanban-sum { margin-top: 0.35rem; font-weight: 650; color: var(--accent); }

.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tab { padding: 0.45rem 0.9rem; color: var(--text-dim); font-weight: 600; }
.tab.active, .tab:hover { background: var(--accent-dim); color: var(--accent); }
.toolbar { margin-bottom: 0.85rem; display: flex; gap: 0.6rem; }
.toolbar select { width: auto; min-width: 180px; }

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.scheme-block {
  border-top: 1px solid var(--border-soft);
  padding-top: 0.85rem;
  margin-top: 0.85rem;
}
.rule-list { margin: 0.4rem 0 0.7rem; padding-left: 1.1rem; color: var(--text-dim); }
.preview-box {
  margin-top: 1rem;
  padding: 0.85rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.preview-json {
  margin: 0.6rem 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  color: var(--muted);
}
.token-box {
  display: block;
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  word-break: break-all;
  font-family: var(--mono);
}
.list-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.list-row:last-child { border-bottom: 0; }

/* Landing */
.topbar, .topbar-public {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(15, 17, 21, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-actions { display: flex; gap: 0.5rem; align-items: center; }
.top-nav { display: flex; gap: 0.35rem; }
.top-nav a {
  color: var(--text-dim);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.top-nav a:hover, .top-nav a.active { background: var(--accent-dim); color: var(--accent); }

.landing-intro { padding-top: 2.2rem; }
.landing-intro h1 { margin-bottom: 0.4rem; }
.landing-hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2rem;
  padding: 3rem 1.5rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
  align-items: center;
}
.eyebrow {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  margin-bottom: 0.6rem;
}
.lead { color: var(--text-dim); font-size: 1.05rem; max-width: 36rem; }
.hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.hero-card {
  background: linear-gradient(165deg, var(--surface), var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}
.hero-card-title {
  font-weight: 700;
  margin-bottom: 0.85rem;
  color: var(--accent);
}
.feature-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.feature-list strong { color: var(--text); }
.landing-audiences {
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
}
.audience h2 { margin: 0.35rem 0 0.6rem; }
.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
}
.landing-section {
  max-width: 1100px;
  margin: 0 auto 0.85rem;
  padding: 0 1.5rem;
}
.landing-section h2 { margin: 0 0 0.35rem; }
.landing-section .section-lead {
  color: var(--text-dim);
  max-width: 44rem;
  margin: 0;
}
.landing-footer {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--border-soft);
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(ellipse at top, rgba(249, 115, 22, 0.08), transparent 50%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 560px; }
.auth-paths {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.auth-path {
  display: block;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: inherit;
}
.auth-path strong { display: block; }
.auth-path span { color: var(--text-dim); font-size: 0.92rem; }
.auth-path.is-current { border-color: var(--accent); background: var(--accent-dim); }
.auth-card h1 { text-align: center; margin-bottom: 1rem; }

/* Client */
.container { max-width: 980px; margin: 0 auto; padding: 0 1.25rem; }
.client-main { padding-bottom: 3rem; }

/* Agent chat */
.agent-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: start;
}
.agent-chat { display: flex; flex-direction: column; gap: 0.75rem; min-height: 420px; }
.agent-intro { margin: 0; }
.agent-thread {
  flex: 1;
  max-height: 52vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.25rem;
}
.agent-bubble {
  max-width: 92%;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
}
.agent-bubble.user {
  align-self: flex-end;
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.35);
}
.agent-bubble.assistant { align-self: flex-start; }
.agent-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.agent-text { white-space: pre-wrap; line-height: 1.45; }
.agent-trace { margin-top: 0.45rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #1f2937;
  color: #e5e7eb;
}
.chip-ok { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.chip-bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.agent-compose {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: end;
}
.agent-voice[aria-pressed="true"] { color: #fca5a5; }
.agent-compose textarea {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #0b0f14;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
}
.agent-hints h3 { margin-top: 0; }
.agent-hints .small { font-size: 0.8rem; }
@media (max-width: 960px) {
  .agent-layout { grid-template-columns: 1fr; }
  .agent-compose { grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 960px) {
  html { -webkit-text-size-adjust: 100%; }
  .cabinet-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    max-height: 100vh;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    padding: 0.45rem 0.75rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
  .sidebar-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
  }
  .sidebar-bar .door-switch {
    order: 3;
    flex: 1 1 100%;
    margin: 0.35rem 0 0;
  }
  .sidebar-bar .door-switch select { max-width: none; }
  .sidebar .brand { padding: 0.15rem 0; min-width: 0; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    flex: 0 0 auto;
  }
  .nav-toggle .when-open { display: none; }
  .nav-toggle-input:checked ~ .sidebar-bar .when-closed { display: none; }
  .nav-toggle-input:checked ~ .sidebar-bar .when-open { display: inline; }
  .sidebar-panel { display: none; }
  .nav-toggle-input:checked ~ .sidebar-panel {
    display: flex;
    max-height: calc(100vh - 4.5rem);
    overflow: auto;
    margin-top: 0.45rem;
    padding-bottom: 0.35rem;
  }
  .side-nav { flex-direction: column; flex-wrap: nowrap; overflow: visible; flex: 0 0 auto; }
  .sidebar-panel { scrollbar-color: var(--border) transparent; }
  .nav-item { font-size: 1rem; min-height: 44px; padding: 0.6rem 0.75rem; }
  .side-foot { flex-direction: column; align-items: stretch; }
  .landing-hero, .landing-grid { grid-template-columns: 1fr; }
  .landing-hero { padding: 1.6rem 0.9rem 1rem; gap: 1.25rem; }
  .landing-grid { padding: 0 0.9rem; margin-bottom: 2rem; }
  .landing-section { padding: 0 0.9rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .topbar, .topbar-public { flex-wrap: wrap; padding: 0.7rem 0.85rem; }
  .client-layout .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "nav nav";
    align-items: center;
    gap: 0.35rem 0.6rem;
  }
  .client-layout .brand { grid-area: brand; min-width: 0; }
  .client-layout .top-actions { grid-area: actions; }
  .client-layout .top-nav {
    grid-area: nav;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
  }
  .client-layout .top-nav a {
    white-space: nowrap;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  .client-layout .user-name { display: none; }
  .topbar-public .top-actions { width: 100%; }
  .topbar-public .top-actions .btn { flex: 1 1 auto; }
  .page-head { padding: 0.85rem 0.9rem 0.2rem; align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn,
  .page-actions form .btn {
    flex: 1 1 9rem;
    width: auto;
    min-height: 44px;
  }
  .page-body {
    padding: 0.45rem 0.75rem calc(2rem + env(safe-area-inset-bottom));
  }
  .flash { margin: 0.55rem 0.75rem; }
  .card { padding: 0.9rem; }
  h1 { font-size: 1.35rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.3rem; }
  .cal-col { min-height: 0; }
  .split { grid-template-columns: 1fr; }
  .list-row { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
  .toolbar { flex-direction: column; }
  .toolbar select { width: 100%; }
  .field-inline { flex-direction: column; align-items: stretch; }
  .topic-picks .check { min-height: 44px; }
  .article-tools .btn { min-height: 44px; }
  .picker-results button { min-height: 44px; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input:not([type="checkbox"]):not([type="radio"]),
  .inline-form select,
  .inline-form .input-compact,
  .line-staff select {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }
  .inline-form .check input { width: auto !important; min-width: 0 !important; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  input, select, textarea { font-size: 16px; }
  .kanban {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 0.75rem;
    padding-bottom: 0.4rem;
  }
  .kanban-col {
    flex: 0 0 86%;
    scroll-snap-align: start;
    max-height: 70vh;
    overflow: auto;
  }
  table.table-cards thead,
  table.table-stack thead { display: none; }
  table.table-stack tr.group td { padding: 0.85rem 0.2rem 0.2rem; }
  .price-type > summary { padding: 0.85rem 0.9rem; min-height: 44px; }
  .price-body { padding: 0 0.9rem 0.9rem; }
  table.table-cards,
  table.table-cards tbody { display: block; width: 100%; }
  table.table-cards tr {
    display: block;
    margin: 0 0 0.7rem;
    padding: 0.3rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
  }
  table.table-cards td {
    display: block;
    border: 0;
    padding: 0.4rem 0.75rem;
    text-align: left;
  }
  table.table-cards td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: left;
    margin-bottom: 0.12rem;
  }
  table.table-cards td:first-child { font-weight: 700; font-size: 1.05rem; }
  table.table-cards td:not([data-label])::before { content: none; }
  table.table-cards td.row-actions form,
  table.table-cards td.row-actions .btn { width: 100%; min-height: 40px; }
  table.table-cards td:has(.inline-form),
  table.table-cards td:has(.line-staff) {
    display: block;
    text-align: left;
  }
  table.table-cards td:has(.inline-form)::before,
  table.table-cards td:has(.line-staff)::before {
    display: block;
    margin-bottom: 0.35rem;
  }
  table.table-cards td { overflow-wrap: anywhere; }
}

.shop-page { max-width: 960px; margin: 0 auto; }

.form-section { margin: 0.2rem 0 0; font-size: 1.05rem; }
.stack-inputs { display: flex; flex-direction: column; gap: 0.4rem; }
.kind-switch { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.kind-switch label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}
.kind-switch input { width: auto; }
.kind-switch label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.car-picker { flex: 1 1 14rem; }
.table-wrap:has(.car-picker) { overflow: visible; }
.picker { position: relative; }
.picker-results {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  top: calc(100% - 0.15rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 16rem;
  overflow: auto;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.picker-results button {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  color: inherit;
  padding: 0.5rem 0.65rem;
  text-align: left;
  cursor: pointer;
}
.picker-results button span:last-child { color: var(--text-dim); white-space: nowrap; }
.picker-empty { padding: 0.55rem 0.65rem; color: var(--muted); }
.car-lookup-results { display: flex; flex-direction: column; gap: 0.25rem; }
.car-lookup-results[hidden] { display: none; }
.car-lookup-results button { text-align: left; }

.doc-screen { background: #d5d5d5; color: #111; }
.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  max-width: 210mm;
  margin: 0 auto;
  padding: 0.8rem 0;
}
.doc-kinds { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.doc-kinds a {
  color: #222;
  text-decoration: none;
  border: 1px solid #bbb;
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  background: #fff;
}
.doc-kinds a[aria-current="page"] { border-color: #111; font-weight: 700; }
.sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 16px;
  background: #fff;
  color: #111;
  padding: 12mm 14mm;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
.sheet-top { display: flex; justify-content: space-between; gap: 1rem; }
.sheet-org { font-size: 14pt; font-weight: 700; }
.sheet-kicker { color: #444; margin-top: 0.15rem; }
.sheet-meta { text-align: right; }
.sheet h1 { font-size: 18pt; margin: 6mm 0 4mm; }
.sheet h2 { font-size: 12pt; margin: 6mm 0 2mm; }
.sheet-facts, .sheet-lines { width: 100%; border-collapse: collapse; }
.sheet-facts th, .sheet-facts td, .sheet-lines th, .sheet-lines td {
  border: 1px solid #222;
  padding: 1.5mm 2mm;
  font-size: 10.5pt;
  vertical-align: top;
}
.sheet-facts th { width: 42mm; text-align: left; font-weight: 650; background: #f4f4f4; }
.sheet-lines th { text-align: left; background: #f4f4f4; }
.sheet-lines .num, .sheet .num { text-align: right; white-space: nowrap; }
.sheet-sum { margin: 1.5mm 0; text-align: right; }
.sheet-total { margin: 3mm 0 1mm; text-align: right; font-size: 13pt; font-weight: 700; }
.sheet .pre { white-space: pre-wrap; }
.doc-blank { display: inline-block; min-width: 55mm; border-bottom: 1px solid #111; }
.work-names { margin: 0; padding-left: 5mm; }
.legal { margin-top: 5mm; font-size: 9.5pt; }
.signs { display: grid; grid-template-columns: 1fr 1fr; gap: 12mm; margin-top: 10mm; }
.sign-role { font-weight: 700; }
.sign-line { border-bottom: 1px solid #111; height: 9mm; margin-top: 6mm; }
.sign-hint { margin-top: 1mm; font-size: 9pt; color: #333; }
@media print {
  .doc-toolbar { display: none !important; }
  .doc-screen { background: #fff; }
  .sheet { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  @page { size: A4; margin: 12mm; }
}
@media (max-width: 800px) {
  .sheet { width: auto; min-height: 0; margin: 0 0.5rem 1rem; padding: 0.8rem; }
  .signs { grid-template-columns: 1fr; }
}

.journal { max-width: 860px; margin: 0 auto; }
.journal .page-head { margin-bottom: 0.4rem; }
.search-line { display: flex; gap: 0.4rem; margin: 0.4rem 0 0.2rem; }
.search-line input[type="search"], .search-line input[name="q"] { flex: 1; min-width: 0; }
.faq-item { margin: 0 0 0.8rem; }
.faq-item h2 { font-size: 1.15rem; margin: 0 0 0.35rem; }
.topic-bar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.7rem 0 1rem; }
.topic-chip {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  color: var(--text-dim);
  text-decoration: none;
  background: var(--surface);
}
.topic-chip.active, .topic-chip:hover { color: var(--accent); border-color: var(--accent); }
.story-card h2 { margin: 0.2rem 0 0.4rem; font-size: 1.25rem; }
.story-card h2 a { color: inherit; text-decoration: none; }
.story-meta { color: var(--muted); font-size: 0.92rem; }
.reaction-row, .share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.6rem 0;
}
.reaction-row form.inline { margin: 0; }
.reaction-row .is-on,
.reaction-row .is-on:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.story-body { white-space: pre-wrap; margin: 0.7rem 0; }
.story-article .story-body:first-child { margin-top: 0; }
.story-inline { margin: 0.7rem 0 1rem; }
.story-inline img, .story-inline video {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 10px;
  background: var(--surface-2, #111);
}
.story-inline form { margin-top: 0.35rem; }
.article-block {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  margin: 0.5rem 0;
  background: var(--bg);
}
.article-block textarea { min-height: 7rem; }
.article-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.45rem; }
.article-preview img, .article-preview video {
  display: block;
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
  background: var(--surface-2, #111);
}
.stars { color: var(--accent); letter-spacing: 0.04em; }
.story-comment { border-top: 1px solid var(--border-soft); padding-top: 0.7rem; margin-top: 0.7rem; }
.journal fieldset { border: 0; padding: 0; margin: 0; }
.journal legend { font-weight: 650; margin-bottom: 0.35rem; }
.story-cover { width: 100%; max-height: 420px; object-fit: cover; border-radius: 10px; background: var(--surface-2, #111); margin: 0.4rem 0 0.6rem; }
.avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--surface-2, #111); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.7rem; margin: 0.6rem 0; }
.media-item img, .media-item video { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; background: var(--surface-2, #111); }
.media-item form { margin-top: 0.3rem; }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.plan-price { font-size: 1.35rem; font-weight: 750; margin: 0.2rem 0 0.6rem; }
.ad-card { border-color: var(--accent); }
.stack-form { display: flex; flex-direction: column; gap: 0.7rem; max-width: 36rem; }
@media (max-width: 800px) {
  .plan-grid { grid-template-columns: 1fr; }
}
