/* ============================================================
   MODS Finance — application layer on top of the MODS Design System
   (tokens: css/mods/tokens.css, components: css/mods/components.css).
   Layout follows the Claude Design canvas «MODS — финансовый модуль v1».
   ============================================================ */

:root {
  --sidebar: 240px;
  --topbar: 60px;
  --tabbar: 64px;
  --brand-text: var(--brand-700);   /* brand text on light surfaces (≥4.5:1) */
  --success-text: #16803F;
  --danger-text: #C03F44;
  --warning-text: #935F07;
}

html, body { height: 100%; }
body { font-variant-numeric: tabular-nums lining-nums; }
a { color: inherit; }
a:hover { color: var(--brand-text); }
[x-cloak] { display: none !important; }
.i { flex: none; }

/* ---------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: var(--sidebar); flex: none;
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: var(--surface-card); border-right: 1px solid var(--border-subtle);
}
.brand { display: flex; align-items: center; padding: var(--space-1) var(--space-2) var(--space-4); }
.brand img { height: 30px; width: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 var(--space-3);
  border-radius: var(--radius-md); color: var(--text-secondary); font-weight: 600; font-size: var(--fs-body);
  transition: var(--transition-colors);
}
.nav-link .i { color: var(--icon-muted); }
.nav-link:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand-text); }
.nav-link.is-active .i { color: var(--brand-600); }
.nav-link.is-sub { height: 34px; padding-left: 42px; font-size: var(--fs-sm); }
.nav-group { padding: var(--space-4) var(--space-3) var(--space-1); font-size: var(--fs-micro); font-weight: 700; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-muted); }
.nav-future { margin-top: auto; padding: var(--space-3); font-size: var(--fs-caption); color: var(--text-muted); line-height: 1.5; }
.nav-future b { display: block; font-size: var(--fs-micro); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.userbox { display: flex; align-items: center; gap: var(--space-2-5); padding: var(--space-3) var(--space-2) var(--space-1); border-top: 1px solid var(--border-subtle); }
.userbox .who { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.userbox .who b { font-size: var(--fs-sm); }
.userbox .who span { font-size: var(--fs-micro); color: var(--text-tertiary); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--space-4);
  height: var(--topbar); padding: 0 var(--space-6);
  background: var(--surface-card); border-bottom: 1px solid var(--border-subtle);
}
.topbar .mobile-brand { display: none; }
.search { flex: 1; max-width: 440px; display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 var(--space-3); background: var(--surface-sunken); border-radius: var(--radius-md); color: var(--icon-muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font: inherit; font-size: var(--fs-body); color: var(--text-primary); }
.topbar .spacer { flex: 1; }
.cashpill { display: inline-flex; align-items: baseline; gap: var(--space-2); height: 38px; padding: 0 var(--space-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); align-items: center; }
.cashpill .mods-money { font-size: var(--fs-body-lg); font-weight: 700; }
.content { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }

.tabbar { display: none; }

/* ---------------------------------------------------------- page header */
.page-head { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); }
.page-head h1 { font-size: var(--fs-h1); font-weight: 800; letter-spacing: var(--tracking-tight); }
.page-head .sub { color: var(--text-tertiary); font-size: var(--fs-sm); }
.page-head .actions { margin-left: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.crumbs { display: flex; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text-tertiary); }
.crumbs a:hover { color: var(--brand-text); }

/* ---------------------------------------------------------- text helpers */
.cap { font-size: var(--fs-micro); font-weight: 700; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-tertiary); }
.hint { font-size: var(--fs-caption); color: var(--text-tertiary); }
.muted { color: var(--text-tertiary); }
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); text-align: right; white-space: nowrap; letter-spacing: -0.01em; }
.pos { color: var(--success-text); }
.neg { color: var(--danger-text); }
.warn { color: var(--warning-text); }
.big { font-size: var(--fs-display); font-weight: 800; letter-spacing: var(--tracking-tight); line-height: 1.05; }
.h3 { font-size: var(--fs-h3); font-weight: 700; letter-spacing: var(--tracking-snug); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------- cards and grids */
.card { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); }
.card-pad { padding: var(--space-5); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); }
.card-head h2, .card-head .h3 { font-size: var(--fs-h3); font-weight: 700; letter-spacing: var(--tracking-snug); }
.card-head .end { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }
.card-body { padding: var(--space-4) var(--space-5); }
.card-foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-subtle); }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-5); align-items: start; }
.split > * { min-width: 0; }
.split.split-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.split > aside { position: sticky; top: calc(var(--topbar) + var(--space-4)); display: flex; flex-direction: column; gap: var(--space-4); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); }
.kpi { padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.kpi .value { font-family: var(--font-mono); font-size: var(--fs-h1); font-weight: 700; letter-spacing: -0.02em; }

/* ---------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.t { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.t th { padding: var(--space-2) var(--space-3); font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border-default); }
.t td { padding: var(--space-2-5) var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.t th.num, .t td.num { text-align: right; }
.t tr.is-link { cursor: pointer; }
.t tr.is-link:hover td { background: var(--surface-hover); }
.t tr.total td { font-weight: 700; border-top: 2px solid var(--text-primary); border-bottom: 0; }
.t tr.group td { font-weight: 700; background: var(--surface-sunken); }
.t tr.sub td:first-child { padding-left: var(--space-8); color: var(--text-secondary); }
.t .internal { color: var(--text-tertiary); background: var(--gray-25); }
.t .lines { margin-top: 2px; font-size: var(--fs-caption); color: var(--text-tertiary); line-height: 1.5; }
.t tr.is-reversed td { color: var(--text-muted); text-decoration: line-through; }
/* Records list: a block per section («В сервисе», «Предстоящие»…), a heading per day inside it. */
.t tr.t-section td { padding: var(--space-5) var(--space-3) var(--space-2); font-size: var(--fs-micro); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); border-bottom: 1px solid var(--border-default); }
.t tbody:first-of-type tr.t-section td { padding-top: var(--space-3); }
.t tr.t-section .count { margin-left: var(--space-1); color: var(--text-tertiary); }
.t tr.t-section.is-danger td { color: var(--danger-text); }
.t tr.t-day td { padding: var(--space-2) var(--space-3); background: var(--surface-sunken); font-size: var(--fs-sm); font-weight: 600; color: var(--text-primary); }
.t tr.t-more td { padding: var(--space-1) var(--space-3); }
.empty { padding: var(--space-10) var(--space-5); text-align: center; color: var(--text-tertiary); display: flex; flex-direction: column; gap: var(--space-3); align-items: center; }

/* ---------------------------------------------------------- status, plate, money */
.mods-plate.is-lg { height: auto; padding: 2px 12px; font-size: 30px; line-height: 1.2; letter-spacing: 0.06em; }
.mods-plate.is-xl { height: auto; padding: 2px 14px; font-size: 36px; line-height: 1.2; letter-spacing: 0.06em; }
.mods-status { color: var(--_text, color-mix(in srgb, var(--_c) 82%, var(--text-primary))); }
.mods-status.is-booked { --_text: #2A5FC8; }
.mods-status.is-onsite { --_text: #5B3FD6; }
.mods-status.is-waiting { --_text: #0B6178; }
.mods-status.is-progress { --_text: var(--warning-text); }
.mods-status.is-ready { --_text: var(--success-text); }
.mods-status.is-delivered { --_text: #5B626E; }
.mods-status.is-noshow { --_text: var(--danger-text); }
.mods-badge.is-internal { background: var(--surface-active); color: var(--text-secondary); }
.mods-badge.is-warning { color: var(--warning-text); }
.mods-badge.is-success { color: var(--success-text); }
.mods-badge.is-danger { color: var(--danger-text); }
.mods-money.is-pos { color: var(--success-text); }
.mods-money.is-neg { color: var(--danger-text); }

/* ---------------------------------------------------------- buttons */
.mods-btn { text-decoration: none; }
.mods-btn:hover { color: inherit; }
.mods-btn.is-primary, .mods-btn.is-primary:hover { color: #fff; }
.mods-btn.is-danger, .mods-btn.is-danger:hover { color: #fff; }
.mods-btn.is-link { background: transparent; color: var(--brand-text); padding: 0 var(--space-1); height: auto; }
.mods-btn.is-wa { background: #25A55A; color: #fff; }
.mods-btn.is-wa:hover { filter: brightness(0.95); color: #fff; }
.mods-iconbtn { text-decoration: none; }
form.inline { display: inline; }

/* ---------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3) var(--space-4); }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid.is-car { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr) 104px; align-items: end; }
.form-grid.is-visit { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.mods-field__label .optional { font-weight: 500; color: var(--text-muted); }
.errorlist { list-style: none; margin: 0; padding: 0; font-size: var(--fs-caption); color: var(--danger-text); }
.form-error { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger-text); font-size: var(--fs-sm); font-weight: 600; }
.money { font-family: var(--font-mono); text-align: right; font-weight: 600; }
.amount-wrap { position: relative; }
.amount-wrap .money { padding-right: 34px; }
.amount-wrap .unit { position: absolute; right: 12px; top: 0; bottom: 0; display: flex; align-items: center; color: var(--text-tertiary); font-weight: 600; pointer-events: none; }
.mods-input.is-xl { height: 56px; font-size: 26px; }
.plate-input { text-transform: uppercase; font-weight: 700; letter-spacing: 0.06em; }

/* Segmented radio (DS tabs look) */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-sunken); border-radius: var(--radius-md); }
.seg.is-block { display: flex; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; height: 34px; padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 600; color: var(--text-tertiary); cursor: pointer; white-space: nowrap; transition: var(--transition-colors); }
.seg input:checked + span { background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-xs); }
.seg input:focus-visible + span { box-shadow: var(--ring-brand); }
.seg.is-sm span { height: 24px; padding: 0 var(--space-2); font-size: var(--fs-caption); }

/* Chips (radio / link) */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span, a.chip, button.chip {
  display: inline-flex; align-items: center; gap: var(--space-1-5); min-height: 36px; padding: 0 var(--space-3);
  border: 1px solid var(--border-default); border-radius: var(--radius-pill); background: var(--surface-card);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.chip input:checked + span, a.chip.is-active, button.chip.is-active { background: var(--brand-soft); color: var(--brand-text); border-color: var(--brand-600); }
.chip input:focus-visible + span { box-shadow: var(--ring-brand); }
button.chip:disabled { opacity: 0.4; cursor: not-allowed; }
/* Multi-select chips (price list): a tick appears when checked */
.chip.is-check span { white-space: normal; text-align: left; padding-top: 6px; padding-bottom: 6px; line-height: 1.3; }
.chip.is-check span svg { display: none; flex: none; }
.chip.is-check input:checked + span svg { display: block; }
.chip.is-check small { margin-left: var(--space-1); font-size: var(--fs-caption); font-weight: 600; color: var(--text-tertiary); }
.chip.is-check input:checked + span small { color: inherit; }
.chip.is-filtered-out { display: none; }
button.chip.is-more { border-style: dashed; color: var(--brand-text); }
button.chip.is-more:hover { border-color: var(--brand-600); background: var(--brand-soft); }
.search.is-field { max-width: none; border: 1px solid var(--border-default); background: var(--surface-card); }
.chips.is-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chips.is-grid .chip span { width: 100%; justify-content: center; min-height: 48px; border-radius: var(--radius-md); }

/* Mechanic avatar: two letters on the mechanic's colour (Справочники → Механики) */
.mech-avatar { font-size: 11px; letter-spacing: 0.02em; }

/* Suggestions under an input (plates, car makes and models) */
.suggest { position: relative; }
.suggest-list { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: min(360px, 80vw); max-height: 280px; overflow-y: auto; padding: var(--space-1); background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.suggest-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; }
.suggest-item.is-active { background: var(--brand-soft); }
.suggest-main { font-weight: 600; color: var(--text-primary); }
.suggest-main.mono { font-family: var(--font-mono); letter-spacing: 0.04em; }

/* Option cards (radio) */
.opts { display: flex; flex-direction: column; gap: var(--space-2); }
.opt { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--border-default); border-radius: var(--radius-md); cursor: pointer; }
.opt:has(input:checked) { border-color: var(--brand-600); background: var(--brand-soft); }
.opt input { accent-color: var(--brand-600); }
.opt .grow { flex: 1; display: flex; flex-direction: column; }

/* Underline tabs as links */
.tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--border-subtle); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: var(--space-1-5); height: 42px; padding: 0 2px; border-bottom: 2px solid transparent; font-size: var(--fs-sm); font-weight: 600; color: var(--text-tertiary); white-space: nowrap; }
.tabs a:hover { color: var(--text-primary); }
.tabs a.is-active { color: var(--brand-text); border-bottom-color: var(--brand-600); }
.tabs .count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-active); color: var(--text-secondary); font-size: var(--fs-micro); display: inline-flex; align-items: center; justify-content: center; }
.tabs a.is-active .count { background: var(--brand-600); color: #fff; }

/* ---------------------------------------------------------- alerts */
.alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); font-size: var(--fs-sm); }
.alert .grow { flex: 1; }
.alert.is-warning { background: var(--warning-soft); color: var(--warning-text); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); }
.alert.is-success { background: var(--success-soft); color: var(--success-text); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }
.alert.is-danger { background: var(--danger-soft); color: var(--danger-text); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.is-info { background: var(--surface-sunken); color: var(--text-secondary); }
.messages { display: flex; flex-direction: column; gap: var(--space-2); }

/* ---------------------------------------------------------- order card */
.order-head { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: center; }
.order-head .car { display: flex; flex-direction: column; gap: 2px; }
.order-head .car b { font-size: var(--fs-h2); font-weight: 800; letter-spacing: var(--tracking-tight); }
.order-meta { display: flex; flex-wrap: wrap; gap: var(--space-6); align-items: flex-start; }
.order-meta > div { display: flex; flex-direction: column; gap: 2px; }
.stepper { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.step { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-tertiary); }
.step .n { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-caption); font-weight: 700; }
.step.is-done { color: var(--text-primary); }
.step.is-done .n { background: var(--gray-900); border-color: var(--gray-900); color: #fff; }
.step.is-current { color: var(--text-primary); }
.step.is-current .n { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: var(--shadow-flame); }
.step-line { width: 32px; height: 2px; background: var(--border-default); }
.step-line.is-done { background: var(--gray-900); }
/* Order status track: one row of dot + label like the cash-close stepper, every step is a button.
   A narrow card puts labels under the dots; a phone-width card goes 3×2. */
.status-steps { container-type: inline-size; padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }
.status-steps .track { display: flex; align-items: center; gap: 2px; }
.status-steps .step { flex: none; gap: 6px; margin: 0; padding: 3px 7px 3px 3px; border: 0; border-radius: var(--radius-pill); background: none; font-family: inherit; white-space: nowrap; cursor: pointer; transition: var(--transition-colors); }
.status-steps .step-line { flex: 1 1 24px; width: auto; min-width: 8px; }
.status-steps .step:not(.is-done):not(.is-current) .n { background: var(--surface-card); }
.status-steps .step:not(:disabled):hover { background: var(--surface-hover); color: var(--text-primary); }
.status-steps .step:focus-visible { outline: none; box-shadow: var(--ring-brand); }
.status-steps .step:disabled { cursor: default; }
@container (max-width: 720px) {
  .status-steps .track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: start; gap: 0; }
  .status-steps .step-line { display: none; }
  .status-steps .step { position: relative; flex-direction: column; padding: 4px 2px 6px; border-radius: var(--radius-md); white-space: normal; line-height: 1.25; text-align: center; }
  .status-steps .step-line + .step::before { content: ""; position: absolute; top: 15px; left: calc(-50% + 16px); right: calc(50% + 16px); height: 2px; background: var(--border-default); }
  .status-steps .step-line.is-done + .step::before { background: var(--gray-900); }
}
@container (max-width: 400px) {
  .status-steps .track { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: var(--space-2); }
  .status-steps .step::before { display: none; }
}

.totals { display: flex; flex-direction: column; gap: var(--space-1-5); font-size: var(--fs-body); }
.totals .row .num { font-weight: 500; }
.totals .sep { border-top: 1px solid var(--border-subtle); padding-top: var(--space-1-5); }
.totals .grand { border-top: 2px solid var(--text-primary); padding-top: var(--space-2); margin-top: var(--space-1); align-items: center; }
.totals .grand .num { font-size: var(--fs-display); font-weight: 700; letter-spacing: -0.03em; }
.totals .due .num { font-size: var(--fs-h2); font-weight: 700; }
details.profit summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); font-weight: 600; }
details.profit summary::-webkit-details-marker { display: none; }

.history { display: grid; grid-template-columns: 110px 1fr; gap: var(--space-1-5) var(--space-4); font-size: var(--fs-sm); }

.mobile-bar { display: none; }

/* ---------------------------------------------------------- dashboard */
.bars { display: flex; flex-direction: column; gap: var(--space-3); }
.bar-row { display: flex; flex-direction: column; gap: var(--space-1-5); }
.bar { height: 8px; border-radius: var(--radius-pill); background: var(--surface-sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--brand-gradient); }
.trend { font-size: var(--fs-caption); font-weight: 700; }
.trend.is-up { color: var(--success-text); }
.trend.is-down { color: var(--danger-text); }
.notice { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-caption); color: var(--warning-text); }

/* ---------------------------------------------------------- dialog */
.dlg { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); width: 640px; max-height: calc(100vh - 48px); overflow: visible; }
.dlg.is-wide { width: 860px; }
.dlg::backdrop { background: rgba(12, 14, 17, 0.45); }
.dlg-box { display: flex; flex-direction: column; max-height: calc(100vh - 48px); background: var(--surface-card); border-radius: var(--radius-xl); box-shadow: var(--shadow-xl); overflow: hidden; }
.dlg-head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); }
.dlg-head .title { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.dlg-head .title b { font-size: var(--fs-h3); font-weight: 800; letter-spacing: var(--tracking-snug); }
.dlg-head, .dlg-foot { flex: none; }
.dlg-body { flex: 1 1 auto; min-height: 0; padding: var(--space-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-4); }
.dlg-foot { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border-subtle); background: var(--gray-25); }
.dlg-foot .grow { flex: 1; }
.dlg-split { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 250px; }
.dlg-split > .dlg-body { overflow: visible; min-height: auto; }
.dlg-split > .side { padding: var(--space-5); background: var(--gray-25); border-left: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: var(--space-1-5); font-size: var(--fs-sm); }
.htmx-request .spin-on-load { opacity: 0.6; }

/* Mobile «+» and «Ещё» sheets */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; background: rgba(12, 14, 17, 0.45); }
.sheet-box { width: 100%; background: var(--surface-card); border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: var(--space-3) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--space-2); }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--gray-300); align-self: center; margin-bottom: var(--space-2); }
.sheet-link { display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: 0 var(--space-3); border-radius: var(--radius-md); font-weight: 600; background: none; border: 0; font: inherit; font-weight: 600; text-align: left; color: var(--text-primary); cursor: pointer; }
.sheet-link:hover { background: var(--surface-hover); }

/* ---------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login .brandside { background: var(--gray-900); color: #fff; padding: var(--space-12); display: flex; flex-direction: column; justify-content: space-between; }
.login .brandside img { height: 44px; width: auto; align-self: flex-start; }
.login .brandside h1 { font-size: var(--fs-display-lg); font-weight: 800; letter-spacing: var(--tracking-tight); color: #fff; line-height: 1.1; }
.login .brandside h1 i { font-style: normal; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login .formside { display: flex; align-items: center; justify-content: center; padding: var(--space-8) var(--space-4); }
.login form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: var(--space-4); }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .split, .split.split-2 { grid-template-columns: minmax(0, 1fr); }
  .split > aside { position: static; }
}

@media (max-width: 860px) {
  .form-grid.is-car { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { display: none; }
  .topbar { padding: 0 var(--space-4); gap: var(--space-3); }
  .topbar .mobile-brand { display: flex; }
  .topbar .mobile-brand img { height: 24px; }
  .topbar .search, .topbar .new-order { display: none; }
  .content { padding: var(--space-4) var(--space-4) calc(var(--tabbar) + var(--space-8) + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: var(--fs-h2); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: stretch;
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface-card); border-top: 1px solid var(--border-subtle);
  }
  .tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600; color: var(--text-tertiary); cursor: pointer; }
  .tabbar .is-active { color: var(--brand-text); }
  .tabbar .fab span { width: 48px; height: 48px; border-radius: 50%; background: var(--brand-600); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-flame); }
  .t.responsive thead { display: none; }
  .t.responsive tr { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); }
  .t.responsive td { padding: 0; border: 0; }
  .t.responsive td.m-hide { display: none; }
  .t.responsive td.m-full { grid-column: 1 / -1; }
  .t.responsive tr.t-section, .t.responsive tr.t-day, .t.responsive tr.t-more { display: block; padding: 0; border-bottom: 0; }
  .t.responsive tr.t-section td, .t.responsive tr.t-day td, .t.responsive tr.t-more td { display: block; padding-left: var(--space-4); padding-right: var(--space-4); }
  .history { grid-template-columns: 1fr; gap: 0 0; }
  .history > span:nth-child(odd) { margin-top: var(--space-2); }
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: calc(100vh - 40px); }
  .dlg-box { border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: calc(100vh - 40px); }
  .dlg-split { grid-template-columns: 1fr; }
  .dlg-split > .side { border-left: 0; border-top: 1px solid var(--border-subtle); }
  .dlg-foot { padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); }
  .dlg-foot .mods-btn { flex: 1; height: 48px; }
  .dlg-foot label.grow { flex-basis: 100%; }
  .mobile-bar { display: flex; flex-direction: column; gap: var(--space-2); position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 25; padding: var(--space-3) var(--space-4); background: var(--surface-card); border-top: 1px solid var(--border-subtle); box-shadow: 0 -4px 12px rgba(15, 18, 25, 0.08); }
  .has-mobile-bar .content { padding-bottom: calc(var(--tabbar) + 150px); }
  .login { grid-template-columns: 1fr; }
  .login .brandside { padding: var(--space-8) var(--space-5); gap: var(--space-6); }
  .login .brandside h1 { font-size: var(--fs-h1); }
  .hide-mobile { display: none !important; }
}

@media (min-width: 861px) {
  .show-mobile { display: none !important; }
}
