/* Лекс CRM — accent ladder (taste-skill app style, seed 693926459).
   Один оттенок — оранжевый Лекса: полный цвет только на мелких отметках (основная кнопка, данные, активная иконка),
   его бледные тона — на площадях (активный пункт меню, мягкие кнопки, дорожки). Без теней, без градиентов.
   Сетка десктопа: сайдбар 230 + холст (1440 − 230 = 1210, поля 29 → 1152); заказ: 1fr + 384, зазор 24 → 744 + 24 + 384 = 1152. */

@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/manrope-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }

:root {
  --ground: #f9fafb;
  --surface: #ffffff;
  --raised: #f3f4f6;
  --border: #e5e7eb;
  --rule: #f0f1f3;
  --control: #d1d5db;
  --text: #111827;
  --muted: #5f6672;
  --accent: #c2410c;
  --accent-soft: #fdf1ed;
  --accent-track: #f9d6c8;
  --accent-ink: #7c2d12;
  --positive: #247b50;
  --negative: #c4242a;
  --warning: #92400e;
  --chart-1: #c2410c;
  --chart-2: #6b7280;
  --chart-muted: #d1d5db;
  --grid: #e5e5e5;
  --axis-ink: #5f6672;
  --ink: #111827;
  --pill-positive-bg: #dcfce7; --pill-positive-ink: #14532d;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fffbeb; --pill-warning-ink: #92400e; --pill-warning-line: #fde68a;
  --pill-neutral-bg: #f3f4f6; --pill-neutral-ink: #374151;
  --pill-accent-bg: #fdf1ed; --pill-accent-ink: #7c2d12;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-chip: 4px;
  --row-height: 45px;
  --sidebar-width: 230px;
  --gap: 24px;
  --pad: 24px;
  --control-height: 36px;
  --fs-title: 32px;
  --fs-section: 18px;
  --fs-kpi: 24px;
  --fs-body: 14px;
  --fs-small: 12px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 var(--fs-body)/20px var(--font); }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, table, .price, .kpi-value, .figure { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); line-height: 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Shell: ruled T-frame ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: 64px 1fr; min-height: 100vh; }
.side { grid-row: 1 / 3; border-right: 1px solid var(--rule); display: flex; flex-direction: column; padding: 0 12px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 8px; text-decoration: none; font-weight: 700; font-size: 16px; flex: none; }
.brand svg { flex: none; }
.brand small { display: block; font-weight: 500; font-size: 12px; line-height: 14px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: var(--radius-control); text-decoration: none; color: #374151; }
.nav a svg { flex: none; color: #6b7280; }
.nav a:hover { background: var(--raised); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav a small.nav-note { display: block; font-size: 12px; line-height: 14px; font-weight: 400; color: var(--muted); }
.nav a:has(.nav-note) { padding-top: 6px; padding-bottom: 6px; }
.flash a { color: inherit; font-weight: 700; }
.box-card.locked { background: var(--raised); border-style: dashed; justify-content: center; }
.box-card.locked .car { color: var(--muted); font-weight: 600; font-size: 16px; }
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.plan { display: flex; flex-direction: column; gap: 6px; }
.plan.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan .price { font-size: 28px; line-height: 34px; }
.plan .price small { font-size: 14px; font-weight: 500; color: var(--muted); }
.plan form { margin-top: auto; padding-top: 12px; }
.plan .hint { font-size: 14px; line-height: 20px; color: #374151; }
.usage { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nav-group { margin: 28px 10px 8px; font-size: var(--fs-small); color: var(--muted); }
.nav-visit { display: block; padding: 8px 10px; border-radius: var(--radius-control); text-decoration: none; line-height: 18px; }
.nav-visit:hover { background: var(--raised); }
.nav-visit[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav-visit b { display: block; font-weight: 600; }
.nav-visit span { font-size: var(--fs-small); color: var(--muted); }
.nav-empty { padding: 4px 10px; font-size: var(--fs-small); color: var(--muted); }
.side-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-foot b { display: block; font-weight: 600; }
.side-foot span { font-size: var(--fs-small); color: var(--muted); }

.top { display: flex; align-items: center; gap: 16px; padding: 0 29px; border-bottom: 1px solid var(--rule); min-width: 0; }
.top > .brand { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--muted); }
.crumbs a { text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; height: 100%; }
.top-right .stamp { font-size: var(--fs-small); color: var(--muted); white-space: nowrap; }
.switcher { display: flex; align-items: center; gap: 10px; height: 100%; padding-left: 16px; border-left: 1px solid var(--rule); font-size: 14px; white-space: nowrap; }
.switcher span { color: var(--muted); }
.canvas { padding: 32px 29px 64px; min-width: 0; }

/* Мобильное меню: лист на весь экран */
.menu { display: none; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu:not([open]) .menu-sheet { display: none; }

/* No-sidebar shell — клиент и вход */
.solo-top { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--rule); background: var(--ground); }
.solo-top .brand { height: 56px; padding: 0; }
.solo-top .ref { font-size: var(--fs-small); color: var(--muted); text-align: right; line-height: 16px; }
.solo { max-width: 720px; margin: 0 auto; padding: 28px 20px 64px; }

/* ---------- Title row ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.title-row > div:first-child { min-width: 0; }
h1 { font-size: var(--fs-title); line-height: 38px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h1 .plate { font-weight: 500; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.sub { margin: 6px 0 0; font-size: 15px; line-height: 22px; color: var(--muted); }
.sub b { color: var(--text); font-weight: 600; }
.finding { color: var(--accent-ink); font-weight: 600; }
h2 { font-size: var(--fs-section); line-height: 24px; font-weight: 600; margin: 0; }
h3 { font-size: 15px; line-height: 20px; font-weight: 600; margin: 0; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--pad); min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head .muted { font-size: 13px; }
.panel-head a { font-size: 13px; color: var(--accent-ink); text-decoration: none; font-weight: 600; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.stack > .panel + .panel { margin-top: 0; }
details.panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-top: -4px; flex: none; }
details.panel[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
details.panel[open] > summary { margin-bottom: 16px; }
.summary-line { font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* ---------- Controls ---------- */
label { display: block; font-size: 13px; font-weight: 500; margin: 16px 0 6px; }
label .muted { font-weight: 400; }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff; }
textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 20px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #6b6b6b; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px auto; gap: 12px; align-items: end; margin-top: 16px; }
.add-row label { margin-top: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-height); padding: 0 14px;
  border: 1px solid var(--control); border-radius: var(--radius-control); background: #fff; color: var(--text);
  font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .12s, border-color .12s, transform .08s; }
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn svg { flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #a3360a; border-color: #a3360a; }
/* «Начать приём» — зелёная по просьбе владельца, чтобы свободный бокс был виден сразу */
.btn.go { background: #1f7a4a; border-color: #1f7a4a; color: #fff; }
.btn.go:hover { background: #17633b; border-color: #17633b; }
.btn.soft { background: var(--accent-soft); border-color: var(--accent-track); color: var(--accent-ink); }
.btn.soft:hover { background: var(--accent-track); }
.btn.text { border-color: transparent; background: transparent; padding: 0 8px; color: var(--muted); }
.btn.text:hover { color: var(--text); background: var(--raised); }
.btn.danger { color: var(--negative); }
.btn.big { height: 48px; font-size: 15px; padding: 0 18px; }
.btn.block { width: 100%; }
.btn[disabled] { background: var(--raised); border-color: var(--border); color: #6b6b6b; cursor: not-allowed; }
.btn.rec { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn.busy { cursor: progress; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn-row form { margin: 0; }

/* Сегментированный переключатель статуса */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 2px; background: var(--raised); border-radius: 8px; margin: 14px 0 0; }
.seg button { height: 34px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #374151; font-weight: 500; font-size: 13px; cursor: pointer; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button:hover:not([disabled]):not([aria-pressed="true"]) { background: #e9eaee; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--text); font-weight: 600; border-color: var(--border); }
.seg button[disabled] { color: #6b6b6b; cursor: not-allowed; }
.hint { margin: 8px 0 0; font-size: var(--fs-small); line-height: 16px; color: var(--muted); }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-chip); font-size: 12px; font-weight: 600; white-space: nowrap; flex: none;
  background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.pill.in_progress, .pill.open { background: var(--pill-accent-bg); color: var(--pill-accent-ink); }
.pill.parts { background: var(--pill-warning-bg); color: var(--pill-warning-ink); box-shadow: inset 0 0 0 1px var(--pill-warning-line); }
.pill.done, .pill.approved { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.declined { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.waiting { background: #fff; color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- Signature: лента заказа ---------- */
.strip-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 32px; align-items: end; }
.strip { display: flex; gap: 3px; height: 14px; margin-top: 4px; }
.strip a, .strip span { flex: 1 1 0; border-radius: 3px; background: var(--border); min-width: 10px; }
.strip .s-done { background: var(--accent); }
.strip .s-in_progress { background: var(--accent-track); }
.strip .s-parts { background: #fcd34d; }
.strip .s-new { background: #d1d5db; }
.strip .s-waiting { background: #fff; box-shadow: inset 0 0 0 1.5px var(--accent); }
.strip .s-noprice { background: #fff; box-shadow: inset 0 0 0 1.5px #9ca3af; }
.strip .s-declined { background: var(--raised); }
.strip a:hover { filter: brightness(.92); }
.strip-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.strip-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.strip-legend b { color: var(--text); font-weight: 600; }
.figure { text-align: right; }
.figure .v { font-size: 28px; line-height: 32px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.figure .l { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- Visit detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 384px; grid-template-areas: "works rail" "log rail"; gap: var(--gap); align-items: start; margin-top: var(--gap); }
.detail > .works { grid-area: works; }
.detail > .rail { grid-area: rail; }
.detail > .log { grid-area: log; }
.works { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rail { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

.work { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 18px 20px; min-width: 0; }
.work-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.work-title { font-weight: 600; font-size: 16px; line-height: 22px; }
.price { font-weight: 700; font-size: 16px; line-height: 22px; white-space: nowrap; }
.price.none { color: #6b6b6b; font-weight: 500; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.quote { margin-top: 10px; font-size: 13px; line-height: 19px; color: #374151; }
.quote span { color: var(--muted); }
.parts { margin-top: 10px; padding: 10px 12px; border-radius: 6px; background: var(--pill-warning-bg); box-shadow: inset 0 0 0 1px var(--pill-warning-line); color: #78350f; font-size: 13px; line-height: 19px; white-space: pre-line; }
.answer { margin-top: 10px; font-size: 13px; line-height: 19px; color: #374151; }
.answer audio { width: 100%; height: 36px; margin-top: 6px; }
.work.s-declined .work-title, .work.s-declined .price { text-decoration: line-through; color: var(--muted); }
.work.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); border-color: var(--accent); } to { background: var(--surface); border-color: var(--border); } }
details.more { margin-top: 12px; }
details.more > summary { display: inline-flex; align-items: center; gap: 6px; height: 32px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin-top: -3px; }
details.more[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
details.more > summary:hover { color: var(--text); }
.more-body { border-top: 1px solid var(--rule); margin-top: 8px; padding-top: 4px; }
.more-body h3 { margin-top: 16px; }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.qr { width: 220px; max-width: 100%; margin: 12px auto 8px; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-card); }
.link-line { font-size: 12px; text-align: center; overflow-wrap: anywhere; color: var(--muted); }
.vin-photo { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; margin-bottom: 12px; }
.vin { font-variant-numeric: tabular-nums; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photos figure { margin: 0; min-width: 0; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.photos figcaption { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 4px; }
.photos form { margin: 2px 0 0; }
.notice { padding: 12px 14px; border-radius: 6px; background: var(--pill-warning-bg); box-shadow: inset 0 0 0 1px var(--pill-warning-line); color: var(--warning); font-size: 13px; line-height: 19px; margin-top: 16px; }
.notice a { color: var(--warning); font-weight: 600; }
.flash { padding: 12px 14px; border-radius: 6px; background: var(--pill-warning-bg); box-shadow: inset 0 0 0 1px var(--pill-warning-line); color: var(--warning); margin-bottom: 16px; }
.flash.error { background: var(--pill-negative-bg); box-shadow: none; color: var(--pill-negative-ink); }
.total-line { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; font-size: 14px; }
.total-line b { font-size: 18px; font-weight: 700; }
.total-line + .total-line { margin-top: 6px; }
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--rule); font-size: 13px; line-height: 19px; }
.log-list li:first-child { border-top: 0; }
.log-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.next-visit, .rating-box { margin-top: 20px; padding-top: 4px; border-top: 1px solid var(--rule); }
.date-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.date-presets .btn { height: 30px; font-size: 13px; font-weight: 500; padding: 0 10px; }

/* Звёзды оценки: SVG, чтобы не путать с эмодзи */
.stars { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.stars input { position: absolute; opacity: 0; pointer-events: none; }
.stars label { margin: 0; padding: 2px; cursor: pointer; color: #d1d5db; line-height: 0; }
.stars label svg { width: 30px; height: 30px; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: var(--accent); }
.stars input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }
.rating-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.no-rating { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--muted); }
.star-view { display: inline-flex; gap: 1px; vertical-align: -2px; color: var(--accent); }
.star-view .off { color: #d1d5db; }

/* ---------- Home ---------- */
.boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--gap); }
.box-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); text-decoration: none; transition: border-color .12s; }
.box-card:hover { border-color: var(--control); }
.box-card .box-name { font-size: 13px; color: var(--muted); font-weight: 600; }
.box-card .car { font-size: 18px; line-height: 24px; font-weight: 700; }
.box-card .who { font-size: 13px; color: var(--muted); }
.box-card .strip { height: 8px; }
.box-card .foot { margin-top: auto; padding-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.box-card.free { background: transparent; border-style: dashed; justify-content: center; align-items: flex-start; }
.box-card.free .car { color: var(--muted); font-weight: 600; font-size: 16px; }
.box-card.free .btn.go { margin-top: 8px; height: 44px; padding: 0 20px; font-size: 15px; }
.box-card.free:hover .btn.go { background: #17633b; border-color: #17633b; }
.home-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin-top: var(--gap); align-items: start; }
.box-card .next { font-size: 13px; line-height: 18px; color: var(--accent-ink); font-weight: 600; }
.box-card .client { font-size: 14px; }
.day { margin-bottom: var(--gap); }

/* ---------- Tables, lists ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 0 10px 10px; white-space: nowrap; }
td { padding: 12px 10px; border-top: 1px solid var(--rule); vertical-align: top; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td a { text-decoration: none; font-weight: 600; }
td a:hover { color: var(--accent-ink); }
td .line2 { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 400; }
.table-scroll { overflow-x: auto; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 11px 0; border-top: 1px solid var(--rule); font-size: 14px; line-height: 20px; }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li > span:first-child { min-width: 0; }
.rows a { text-decoration: none; font-weight: 600; }
.rows a:hover { color: var(--accent-ink); }
.rows .line2 { display: block; font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.rows .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { padding: 12px 14px; border: 1px dashed var(--control); border-radius: 8px; font-size: 13px; color: var(--muted); }

/* ---------- Dashboard ---------- */
.scope { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: var(--gap); }
.tabs-seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--raised); border-radius: 8px; }
.tabs-seg a { display: inline-flex; align-items: center; height: 32px; border: 1px solid transparent; padding: 0 14px; border-radius: 6px; text-decoration: none; color: #374151; font-weight: 500; font-size: 13px; }
.tabs-seg a[aria-current="page"] { background: #fff; color: var(--text); font-weight: 600; border-color: var(--border); }
.range { display: flex; align-items: center; gap: 8px; margin: 0; }
.range input { height: 36px; width: 150px; }
.range span { color: var(--muted); }
.overview { display: grid; grid-template-columns: minmax(0, 1fr) 384px; gap: var(--gap); align-items: start; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); }
.kpi { padding: 18px 20px; border-left: 1px solid var(--border); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .kpi-value { font-size: var(--fs-kpi); line-height: 30px; font-weight: 600; margin-top: 4px; white-space: nowrap; }
.kpi.lead .kpi-value { font-size: 32px; line-height: 36px; font-weight: 700; }
.kpi .c { font-size: 12px; color: var(--muted); margin-top: 4px; }
.chart { min-height: 220px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; }
.share { display: flex; height: 12px; gap: 2px; margin: 4px 0 16px; }
.share i { display: block; border-radius: 2px; min-width: 4px; }
.legend-table td { padding: 8px 0; font-size: 13px; }
.legend-table td:first-child i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: -1px; }

/* ---------- Settings ---------- */
.settings-row { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; padding: 32px 0; border-top: 1px solid var(--border); }
.settings-row:first-of-type { border-top: 0; padding-top: 0; }
.settings-row p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 0; flex-wrap: wrap; }
.inline-form input { width: 120px; height: 32px; }
.inline-form .btn { height: 32px; }

/* ---------- Client ---------- */
.approve-all { background: var(--accent-soft); border-color: var(--accent-track); }
.approve-all .sum { font-size: 13px; color: var(--accent-ink); margin: 10px 0 0; text-align: center; }
.next-date { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 16px 18px; border-radius: var(--radius-card); background: var(--accent-soft); margin-bottom: 16px; }
.next-date .v { font-size: 24px; font-weight: 700; white-space: nowrap; }

/* ---------- Login / small pages ---------- */
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 18px 0 0; font-weight: 400; font-size: 14px; line-height: 20px; color: var(--text); cursor: pointer; }
.consent input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--accent); }
.consent a, .legal a { color: var(--accent-ink); }
.legal { margin: 40px auto 0; max-width: 720px; text-align: center; font-size: 13px; line-height: 18px; color: var(--muted); }
.legal nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.legal p { margin: 10px 0 0; }
.center-card { max-width: 400px; margin: 64px auto; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; width: min(560px, calc(100% - 32px));
  background: var(--text); color: #fff; padding: 12px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 14px; }

/* ---------- Tablet & phone ---------- */
@media (max-width: 1100px) {
  .detail, .overview { grid-template-columns: minmax(0, 1fr); }
  .home-grid { grid-template-columns: 1fr 1fr; }
  .home-grid > :last-child { grid-column: 1 / -1; }
  /* Планшет и телефон: машина и клиент сверху, работы, потом завершение */
  .detail { grid-template-columns: 1fr 1fr; grid-template-areas: "car client" "works works" "finish finish" "log log"; }
  .rail { display: contents; }
  .detail #car { grid-area: car; } .detail #client { grid-area: client; } .detail #finish { grid-area: finish; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56px 1fr; }
  .side { display: none; }
  .top { padding: 0 8px 0 16px; position: sticky; top: 0; z-index: 20; background: var(--ground); }
  .top > .brand { display: flex; height: 56px; padding: 0; }
  .top .crumbs, .top .switcher, .top .stamp { display: none; }
  .menu { display: block; margin-left: auto; }
  .menu > summary { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: var(--radius-control); font-weight: 600; }
  .menu-sheet { position: fixed; inset: 56px 0 0 0; z-index: 30; background: var(--ground); padding: 8px 16px 24px; overflow-y: auto; border-top: 1px solid var(--rule); }
  .canvas { padding: 20px 16px 48px; }
  h1 { font-size: 24px; line-height: 30px; }
  .title-row { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .detail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "car" "client" "works" "finish" "log"; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--border); }
  .split, .home-grid, .plans { grid-template-columns: minmax(0, 1fr); }
  .usage { grid-template-columns: 1fr 1fr; }
  .usage .kpi:nth-child(3) { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--border); }
  .settings-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
@media (max-width: 640px) {
  :root { --pad: 18px; --gap: 16px; }
  .strip-panel { grid-template-columns: minmax(0, 1fr); }
  .figure { text-align: left; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .figure .v { font-size: 24px; line-height: 28px; }
  .work { padding: 16px; }
  .seg { grid-template-columns: 1fr 1fr; }
  .seg button { height: 40px; }
  .add-row { grid-template-columns: minmax(0, 1fr) 110px; }
  .add-row .btn { grid-column: 1 / -1; }
  .field-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .btn { height: 44px; }
  .btn.big { height: 52px; }
  .date-presets .btn { height: 36px; }
  .photos { grid-template-columns: repeat(2, 1fr); }
  .log-list li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .solo { padding: 20px 16px 48px; }
  .scope { flex-direction: column; align-items: stretch; }
  .range { flex-wrap: wrap; }
  .range input { width: auto; flex: 1; min-width: 0; }
  .range .btn { width: 100%; }
  .line2, th, .kpi .c, .hint, .summary-line, .pill, .small, .figure .l, .strip-legend, .link-line, .nav-visit span, .side-foot span, .box-card .box-name, .photos figcaption, .meta { font-size: 13px; }
  .rows .line2, td .line2 { font-size: 13px; line-height: 18px; }
  table.wide thead { display: none; }
  table.wide tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
  table.wide td { border: 0; padding: 0; }
  table.wide td.hide-m { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
