/* =====================================================================
   КАР ДИЛЕР СЕРВИС — дизайн-система приложения.
   Источник истины: brand/brandbook-kar-diler-servis.html (v2.0). См. BRAND.md.
   ПРАВИЛО: цвета, шрифты и радиусы задаются ТОЛЬКО токенами ниже.
   Вне блоков :root / [data-theme] нет ни одного HEX-цвета (проверяет tools/brand_check.py).
   ===================================================================== */

/* ---------- Токены бренда (одинаковы в обеих темах) ---------- */
:root {
  --graphite: #20252B;   /* графитовый: основа */
  --ink: #14181D;        /* фон тёмной темы */
  --ink-2: #1A1F25;
  --blue: #0066FF;       /* синий: кнопки, срез, активный статус; на тёмном только крупно */
  --blue-lt: #3D8BFF;    /* синий светлый: текст и значки на графите */
  --steel: #A7B0BB;      /* стальной серый: вторичный текст на графите */
  --light: #F5F7FA;      /* светлый */
  --font: 'Montserrat', 'Segoe UI', Arial, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;   /* VIN, номера актов, суммы */
  --r: 2px;              /* радиус брендбука: острые углы */
  --r-pill: 99px;        /* только для статусов-пилюль */
  --slash: -24deg;       /* угол фирменного среза */
  --paper: #FFFFFF;      /* белая подложка под печать и подпись */
  /* боковая панель всегда тёмная — свои токены */
  --sb-text: var(--light); --sb-muted: var(--steel); --sb-line: rgba(167, 176, 187, .18);
  --sb-hover: rgba(167, 176, 187, .1); --sb-active: rgba(61, 139, 255, .16);
}

/* ---------- Светлая тема: светлое поле данных + графитовая боковая панель (как CRM в брендбуке) ---------- */
:root, [data-theme="light"] {
  --bg: var(--light); --surface: #FFFFFF; --surface-2: #EEF1F5; --sidebar: var(--graphite);
  --text: var(--graphite); --muted: #5A6470; --line: #E3E7ED; --line-strong: #D6DBE2;
  --accent: var(--blue); --accent-2: var(--blue-lt); --accent-soft: #E3EEFF; --accent-ink: #FFFFFF; --brand: var(--blue);
  --ok: #17794A; --ok-soft: #DDF5E8; --warn: #8A5A00; --warn-bg: #FFF1D6; --err: #C9253A; --err-soft: #FDE8EB;
  --wait: #4B5563; --wait-soft: #EEF1F5;
  --shadow: none; --shadow-pop: 0 12px 32px rgba(20, 24, 29, .18);
  --input-bg: #FFFFFF; --chip: #EEF1F5; --zebra: #F5F7FA; --scrim: rgba(20, 24, 29, .5);
  color-scheme: light;
}
/* ---------- Тёмная тема: графит на чёрном, синий светлый для текста ---------- */
[data-theme="dark"] {
  --bg: var(--ink); --surface: var(--graphite); --surface-2: var(--ink-2); --sidebar: var(--ink-2);
  --text: var(--light); --muted: var(--steel); --line: rgba(167, 176, 187, .18); --line-strong: rgba(167, 176, 187, .32);
  --accent: var(--blue-lt); --accent-2: var(--blue-lt); --accent-soft: rgba(61, 139, 255, .16); --accent-ink: #FFFFFF; --brand: var(--blue);
  --ok: #58D68D; --ok-soft: rgba(47, 191, 113, .16); --warn: #F5B84A; --warn-bg: rgba(245, 165, 36, .16);
  --err: #FF6B7A; --err-soft: rgba(255, 77, 94, .16);
  --wait: var(--steel); --wait-soft: rgba(167, 176, 187, .14);
  --shadow: none; --shadow-pop: 0 12px 32px rgba(0, 0, 0, .5);
  --input-bg: var(--ink); --chip: rgba(167, 176, 187, .14); --zebra: rgba(167, 176, 187, .06); --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 400 13.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "tnum"; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 800; line-height: 1.15; letter-spacing: -.015em; margin: 0 0 14px; text-wrap: balance; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
h3 { font-size: 13.5px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: .02em; }
.eyebrow { display: flex; align-items: center; gap: 12px; font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.eyebrow::before { content: ""; width: 28px; height: 2px; background: var(--brand); }
.ico { flex-shrink: 0; }
*, *::before, *::after { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
:focus-visible { outline: 2px solid var(--blue-lt); outline-offset: 2px; }

/* ============ Каркас: графитовая боковая панель + закреплённая верхняя строка ============ */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 236px; background: var(--sidebar); color: var(--sb-text); border-right: 1px solid var(--sb-line);
  display: flex; flex-direction: column; padding: 18px 12px 14px; z-index: 40; overflow: hidden; }
.sidebar > * { position: relative; z-index: 1; }
/* фирменный срез 24° — один на экран, за пределами текста */
.sidebar::before, .sidebar::after { content: ""; position: absolute; top: 34%; bottom: -10%; background: var(--blue); transform: skewX(var(--slash)); z-index: 0; pointer-events: none; }
.sidebar::before { right: 16px; width: 12px; opacity: .95; }
.sidebar::after { right: 2px; width: 4px; opacity: .5; }
.logo { display: flex; align-items: center; gap: 12px; color: var(--sb-text); padding: 2px 8px 20px; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 46px; height: auto; flex: none; color: var(--light); }
.logo-text { display: flex; flex-direction: column; line-height: 1.05; }
.logo-text b { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.logo-text span { font-size: 9px; font-weight: 400; letter-spacing: .5em; color: var(--sb-muted); margin-top: 3px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r); color: var(--sb-muted);
  font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.sidebar nav a:hover { background: var(--sb-hover); color: var(--sb-text); text-decoration: none; }
.sidebar nav a.on { background: var(--sb-active); color: var(--sb-text); box-shadow: inset 3px 0 0 var(--blue-lt); }
.sidebar nav a.on .ico { color: var(--blue-lt); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 2px; border-top: 1px solid var(--sb-line); }
.avatar { width: 32px; height: 32px; border-radius: var(--r); display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: var(--blue); color: var(--accent-ink); flex-shrink: 0; }
.side-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-user-text b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text span { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--sb-muted); }
.main-col { flex: 1; min-width: 0; margin-left: 236px; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; flex: 0 1 380px; height: 34px; padding: 0 10px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted); }
.search input { border: 0; background: transparent; padding: 0; height: 100%; font-size: 13px; box-shadow: none; outline: none; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.top-actions form { margin: 0; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r); border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--surface); border-color: var(--line-strong); color: var(--text); text-decoration: none; }
[data-theme="dark"] .i-sun, [data-theme="light"] .i-moon { display: none; }
.burger { display: none; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 35; }
.content { padding: 24px 24px 48px; max-width: 1280px; width: 100%; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.content.auth { max-width: 420px; margin: 0 auto; padding-top: 10vh; position: relative; z-index: 1; }
.auth-theme { position: fixed; top: 14px; right: 14px; z-index: 2; }
/* экран входа: фон-срез за карточкой */
.auth-slash { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.auth-slash i { position: absolute; top: -10%; bottom: -10%; background: var(--blue); transform: skewX(var(--slash)); }
.auth-slash i:first-child { right: 12%; width: 34px; }
.auth-slash i:last-child { right: calc(12% - 64px); width: 10px; opacity: .55; }
.brand-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; color: var(--text); }
.brand-hero .logo-mark { width: 84px; color: var(--text); }
.brand-hero .logo-text b { font-size: 26px; }
.brand-hero .logo-text span { font-size: 14px; letter-spacing: .5em; color: var(--muted); margin-top: 6px; }
.brand-slogan { margin: 0 0 18px; }

/* ============ Карточки, сетки, статы (плоские, с тонкой линией — без теней) ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 0 1 auto; }
.grow { flex: 1 1 220px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--text); border-radius: var(--r); padding: 14px 16px; }
.stat > .muted:first-child { display: block; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; }
.stat b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .small { display: block; margin-top: 2px; }
.page-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }

/* ============ Формы и кнопки ============ */
label { display: block; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { font: inherit; font-size: 13.5px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--input-bg); color: var(--text); width: 100%; }
textarea { min-height: 140px; font-family: var(--mono); font-size: 13px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: var(--r); cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--accent-ink); }   /* белый на синем 4.83:1 */
.btn.primary:hover { background: var(--blue-lt); border-color: var(--blue-lt); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:active { transform: translateY(1px); }
.title-input { font-size: 22px; font-weight: 800; border-color: transparent; background: transparent; padding-left: 0; }
.title-input:hover, .title-input:focus { border-color: var(--line); padding-left: 8px; }

/* ============ Таблицы (шапка с жирной графитовой линией, цифры — моноширинные) ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; background: transparent; border-bottom: 2px solid var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--zebra); }
td.num, th.num { text-align: right; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
th.num { font-family: var(--font); font-size: 10.5px; }
td.vin, .vin { font-family: var(--mono); letter-spacing: .04em; }
tr.hl td { background: var(--accent-soft); }
/* короткие значения (номер, дата) не переносим — Montserrat шире прежнего шрифта */
@media (min-width: 721px) { td[data-label="№"], td[data-label="Дата"] { white-space: nowrap; } }

/* ============ Чипы, статусы-пилюли (цвет + слово вместе), сообщения ============ */
.chip { display: inline-block; background: var(--chip); border-radius: var(--r); padding: 1px 8px; font-size: 11.5px; margin: 1px 3px 1px 0; color: var(--text); }
.chip.deal-buyout { background: var(--accent-soft); color: var(--accent); }
.chip.deal-commission { background: var(--warn-bg); color: var(--warn); }
.st { display: inline-flex; align-items: center; gap: 7px; border-radius: var(--r-pill); padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-new { background: var(--wait-soft); color: var(--wait); }            /* Ожидает / Новая */
.st-issued { background: var(--accent-soft); color: var(--accent); }     /* В работе / Выставлен */
.st-done, .st-paid { background: var(--ok-soft); color: var(--ok); }     /* Готово / Оплачен */
.st-cancelled { background: var(--wait-soft); color: var(--muted); text-decoration: line-through; }
.st-qc { background: var(--warn-bg); color: var(--warn); }               /* Контроль */
.flash { padding: 10px 14px; border-radius: var(--r); margin-bottom: 12px; border: 1px solid transparent; border-left-width: 3px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.flash.error { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, transparent); }
.warn-text { color: var(--warn); font-size: 12px; }
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--err); font-weight: 600; }
.secret { background: var(--surface-2); border: 1px solid var(--line); padding: 12px 14px; border-radius: var(--r); font-family: var(--mono); white-space: pre-wrap; }

/* ============ Навигация внутри разделов ============ */
.subnav { display: inline-flex; gap: 0; margin: -4px 0 16px; border-bottom: 1px solid var(--line-strong); flex-wrap: wrap; }
.subnav a { padding: 8px 16px; color: var(--muted); font-weight: 600; font-size: 12.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a.on { color: var(--text); border-bottom-color: var(--brand); }
.tabs { display: inline-flex; gap: 0; margin-bottom: 14px; border-bottom: 1px solid var(--line-strong); }
.tabs button { border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; padding: 8px 16px; cursor: pointer; font: inherit; font-weight: 600; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--brand); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar select { width: auto; min-width: 220px; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface-2); margin-left: 6px; }
.seg a { padding: 4px 12px; border-radius: var(--r); color: var(--muted); font-weight: 600; }
.seg a.on { background: var(--brand); color: var(--accent-ink); text-decoration: none; }
.scope-form { margin-bottom: 8px; }
.scope-form select { max-width: 520px; }

/* ============ Формы заявок ============ */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.svc { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 9px 12px; cursor: pointer; margin: 0; color: var(--text); font-family: var(--font); font-size: 13px; letter-spacing: 0; text-transform: none; font-weight: 400; }
.svc:has(input:checked) { border-color: var(--brand); background: var(--accent-soft); }
.svc .name { flex: 1; }
.svc .price { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.svc input.qty { width: 56px; padding: 4px 6px; }
.svc.off { opacity: .45; cursor: not-allowed; }
.deal-switch { display: inline-flex; padding: 2px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r); }
.deal-opt { display: flex; align-items: center; margin: 0; padding: 6px 16px; border-radius: var(--r); color: var(--muted); font-family: var(--font); font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; cursor: pointer; }
.deal-opt:has(input:checked) { background: var(--brand); color: var(--accent-ink); }
.deal-opt input { display: none; }
.login { max-width: 380px; margin: 0 auto; }
details summary { cursor: pointer; }
details.le { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin-bottom: 8px; background: var(--surface-2); }

/* ============ График смен ============ */
table.schedule { width: auto; border-collapse: separate; border-spacing: 0; }
table.schedule th, table.schedule td { padding: 4px 3px; text-align: center; border-bottom: 1px solid var(--line); font-size: 12px; }
table.schedule th.day { cursor: pointer; min-width: 30px; line-height: 1.1; text-transform: none; letter-spacing: 0; }
table.schedule th.day span { font-weight: 400; font-size: 10px; }
table.schedule .we { background: var(--surface-2); }
table.schedule th.today { color: var(--accent); }
table.schedule .sticky { position: sticky; left: 0; background: var(--surface); text-align: left; white-space: nowrap; padding-right: 10px; z-index: 1; }
table.schedule td.emp { cursor: pointer; font-weight: 600; }
table.schedule td.warn { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
table.schedule tr.load td { font-size: 11px; color: var(--muted); }
table.schedule td.other { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--chip) 4px 8px); }
table.schedule input[type=checkbox] { width: 16px; height: 16px; }

/* ============ Отчёты ============ */
table.report td.indent { padding-left: 26px; color: var(--muted); }
table.report tr.strong td { font-weight: 600; }
table.report tr.total td { font-weight: 800; border-top: 2px solid var(--text); }
.balance { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.balance h3 { margin: 6px 0; }

/* ============ Главная: KPI, график, воронка ============ */
.kpi-delta { font-size: 11.5px; font-weight: 600; margin-top: 4px; display: inline-block; }
.dash { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.dash .card { margin-bottom: 0; }
.dash-col { display: flex; flex-direction: column; gap: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.chart { width: 100%; height: 210px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .stop1 { stop-color: var(--accent); stop-opacity: .22; }
.chart .stop2 { stop-color: var(--accent); stop-opacity: 0; }
.funnel-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; font-size: 12.5px; }
.funnel-bar { height: 6px; background: var(--accent-soft); overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--brand); }
.today-list { display: flex; flex-direction: column; }
.today-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.today-item:last-child { border-bottom: 0; }
.today-time { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 64px; }

/* ============ Планшет и телефон ============ */
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-pop); }
  .sidebar.open { transform: none; }
  .main-col { margin-left: 0; }
  .burger { display: inline-grid; }
  .topbar { padding: 0 14px; }
}
@media (max-width: 800px) { .balance { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  body { font-size: 14px; }
  .content { padding: 14px 12px 40px; }
  h1 { font-size: 22px; margin-bottom: 12px; }
  .card { padding: 14px; margin-bottom: 12px; }
  .search { flex: 1 1 auto; }
  input, select, textarea { font-size: 16px; }   /* iOS не увеличивает страницу */
  .row > *, .row > .grow { flex: 1 1 100%; }
  .row > div:has(> input[type=date]) { flex: 1 1 40%; }
  .row > div > input, .row > div > select { width: 100% !important; }
  .form-grid { grid-template-columns: 1fr; }
  .btn { padding: 9px 14px; }
  .btn.sm { padding: 6px 10px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat { padding: 11px 12px; }
  .stat b { font-size: 19px; }
  .svc-grid { grid-template-columns: 1fr; }
  .tabs, .subnav, .deal-switch { display: flex; width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .tabs button, .deal-opt { flex: 1; justify-content: center; white-space: nowrap; }
  .subnav a { white-space: nowrap; }
  .toolbar select, .scope-form select { width: 100%; min-width: 0; }
  .secret { font-size: 13px; word-break: break-all; }
  .funnel-row { grid-template-columns: 100px 1fr auto; }
  .brand-hero .logo-mark { width: 64px; }
  .brand-hero .logo-text b { font-size: 21px; }
  .auth-slash i:first-child { right: 6%; }
  .auth-slash i:last-child { right: calc(6% - 40px); }

  /* таблицы-карточки: каждая строка — карточка «подпись — значение» */
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr:first-child:has(th) { display: none; }
  table.cards tr { border: 1px solid var(--line); border-radius: var(--r); padding: 6px 12px; margin-bottom: 10px; background: var(--surface); position: relative; }
  table.cards tbody tr:hover td { background: transparent; }
  table.cards td { border: 0; padding: 5px 0; display: flex; gap: 12px; justify-content: space-between; align-items: baseline; text-align: right; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: 0 0 auto; }
  table.cards td:not([data-label])::before { content: none; }
  table.cards td:not([data-label]) { justify-content: flex-end; }
  table.cards td > input:not([type=checkbox]), table.cards td > select { max-width: 62%; }
  table.cards td.works, table.cards td.vin, table.cards td[data-label="Работа"], table.cards td[data-label="Сотрудник"] { display: block; text-align: left; }
  table.cards td.works::before, table.cards td.vin::before, table.cards td[data-label="Работа"]::before, table.cards td[data-label="Сотрудник"]::before { display: block; margin-bottom: 2px; }
  table.cards td.sel { position: absolute; right: 10px; top: 8px; width: auto; padding: 0; }
  table.cards td.sel input { width: 22px; height: 22px; }
  table.cards.orders td[data-label="№"] { padding-right: 40px; }
  table.cards tr:last-child:has(td[colspan]) { border: 0; background: none; padding: 4px 2px; }
  table.cards tr:last-child td[colspan] { justify-content: flex-start; }
  table.cards details { text-align: left; }
  .pw-form { width: 100%; }
  .pw-form input[name=password] { width: 100% !important; flex: 1 1 100%; }

  .table-wrap { margin: 0 -14px; padding: 0 14px; -webkit-overflow-scrolling: touch; }
  table.report td, table.report th { padding: 7px 6px; font-size: 13px; }
  table.report td:first-child { min-width: 150px; }
  table.report.pnl th:nth-child(3), table.report.pnl td:nth-child(3) { display: none; }
  table.report.pnl td:first-child { min-width: 0; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============ iOS/Safari: поля дат и выпадающие списки не распирают строки ============ */
input, select, textarea { min-width: 0; max-width: 100%; }
input[type=date], input[type=month], input[type=time] { -webkit-appearance: none; appearance: none; display: block;
  min-height: 36px; line-height: 1.25; text-align: left; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
.row > *, .form-grid > *, .toolbar > *, .actions > * { min-width: 0; }
.main-col, .content { overflow-x: clip; }
.content { overflow-wrap: anywhere; }
.content .mono { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .row > div:has(> input[type=date]) { flex: 1 1 calc(50% - 6px); max-width: calc(50% - 6px); }
  .row > div:has(> input[type=date]):only-child { max-width: 100%; }
  .card { max-width: 100%; }
}

/* ============ Доступы и кабинет сотрудника ============ */
.dept-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 8px; }
.dept-checks label { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-family: var(--font); font-size: 12.5px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.perm-form select { width: auto; margin-bottom: 4px; }
.pw { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 2px 8px; margin-right: 6px; font-family: var(--mono); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-day { border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; min-height: 56px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.cal-day.we { background: var(--surface-2); }
.cal-day.on { border-color: var(--brand); background: var(--accent-soft); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--brand); }
.cal-n { font-weight: 700; }
.cal-dept { color: var(--accent); font-weight: 600; font-size: 11.5px; overflow-wrap: anywhere; }
@media (max-width: 720px) { .cal { gap: 3px; } .cal-day { min-height: 46px; padding: 4px; font-size: 11px; } .cal-n .muted { display: none; } .cal-dept { font-size: 10px; } }
.sign-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.sign-box { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
/* белая подложка нужна: печать и подпись загружаются на светлом фоне */
.sign-preview { height: 130px; display: grid; place-items: center; background: var(--paper); border-radius: var(--r); border: 1px dashed var(--line-strong); }
.sign-preview img { max-height: 120px; max-width: 100%; }
/* поле синонимов в прайсе: обычный шрифт, не моно */
table textarea { font-family: var(--font); font-size: 13px; }
