/* Смета — дизайн-система v2
   Раскладка: парящая боковая панель + рабочая область из бенто-карточек.
   На телефоне — верхняя панель и плавающее нижнее меню (320–480 px). */

:root {
  /* Цвет: почти чёрный графит + сигнальный оранжевый */
  --bg: #0c0c0d;
  --surface: #141416;
  --surface-2: #1b1b1e;
  --surface-3: #242428;
  --line: #26262a;
  --line-2: #34343a;
  --text: #f3f2ef;
  --muted: #8e8c87;
  --faint: #5a5955;
  --accent: #ff7a1a;
  --accent-hover: #ff8f3d;
  --accent-ink: #120a04;
  --accent-soft: rgba(255, 122, 26, 0.12);
  --accent-glow: rgba(255, 122, 26, 0.22);
  --danger: #f2655d;
  --danger-soft: rgba(242, 101, 93, 0.12);
  --ok: #5ccb86;
  --ok-soft: rgba(92, 203, 134, 0.12);
  --warn: #f0b545;
  --warn-soft: rgba(240, 181, 69, 0.12);
  --paper: #fbfaf7;
  --paper-ink: #1a1a1a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);

  /* Шрифты */
  --f-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  /* Размеры */
  --r-xl: 28px;
  --r: 20px;
  --r-sm: 14px;
  --r-xs: 10px;
  --tap: 44px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eeede9;
  --surface: #ffffff;
  --surface-2: #f5f4f1;
  --surface-3: #e9e7e2;
  --line: #e3e0da;
  --line-2: #d3cfc7;
  --text: #17171a;
  --muted: #67655f;
  --faint: #a19e96;
  --accent: #e8620a;
  --accent-hover: #cf5506;
  --accent-ink: #ffffff;
  --accent-soft: rgba(232, 98, 10, 0.1);
  --accent-glow: rgba(232, 98, 10, 0.14);
  --danger: #d43c33;
  --danger-soft: rgba(212, 60, 51, 0.1);
  --ok: #2b9a55;
  --ok-soft: rgba(43, 154, 85, 0.1);
  --warn: #b97c07;
  --warn-soft: rgba(185, 124, 7, 0.12);
  --shadow: 0 24px 60px rgba(40, 30, 20, 0.14);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex: none; }
h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 600; letter-spacing: -0.025em; }
p { margin: 0; }
em.serif, .serif { font-family: var(--f-serif); font-style: italic; font-weight: 500; letter-spacing: -0.01em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Каркас ---------- */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  gap: 12px;
  padding: 12px;
}

.workspace { min-width: 0; display: flex; flex-direction: column; }

.main {
  min-width: 0;
  width: 100%;
  max-width: 1240px;
  padding: 8px 12px 64px;
  outline: none;
}

.logo { display: flex; align-items: center; font-size: 26px; }
.logo-sm { font-size: 22px; }

/* Логотип: слово «смета» и оранжевая точка над «а».
   Цвет слова — currentColor (белый на тёмном, чёрный на светлом), цвет точки — --brand-dot. */
.brand {
  --brand-dot: #ff5a1f;
  display: inline-flex;
  align-items: baseline;
  font: 600 1em/1 "Golos Text", "Onest", system-ui, sans-serif;
  letter-spacing: -0.035em;
  white-space: nowrap;
}
.brand i {
  display: inline-block;
  width: 0.26em;
  height: 0.26em;
  margin-left: 0.04em;
  border-radius: 50%;
  background: var(--brand-dot);
  transform: translateY(-0.62em);
}
.brand.mono i { background: currentColor; }
.brand-short { display: none; }

/* Боковая панель */
.sidebar {
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 14px 14px;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar .logo { padding: 0 10px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav .nav-group { padding: 16px 12px 6px; font-size: 11px; color: var(--faint); font-weight: 500; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 0 8px;
  border-radius: 99px;
  color: var(--muted);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.side-nav a .nav-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; transition: background 0.15s, color 0.15s; }
.side-nav a:hover { color: var(--text); background: var(--surface-2); }
.side-nav a.active { color: var(--text); background: var(--surface-3); }
.side-nav a.active .nav-ico { background: var(--accent); color: var(--accent-ink); }
.side-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.nav-badge {
  margin-left: auto;
  margin-right: 6px;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text);
  font: 500 11px/18px var(--f-mono);
  text-align: center;
}
.side-nav a.active .nav-badge { background: var(--accent-soft); color: var(--accent); }
.nav-badge:empty { display: none; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-project {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  border-radius: var(--r);
  background:
    radial-gradient(120% 120% at 100% 0%, var(--accent-glow), transparent 60%),
    var(--surface-2);
  border: 1px solid var(--line);
}
.side-project b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 4px; }
.side-total { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.side-project:hover b { color: var(--accent); }

.theme-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.theme-btn:hover { color: var(--text); border-color: var(--line-2); }

/* Верхняя панель */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 4px 12px 12px;
}
.topbar #top-logo, .topbar #back-btn, .topbar-title { display: none; }
.global-search { position: relative; flex: 1 1 auto; max-width: 440px; }
.global-search > svg { position: absolute; left: 16px; top: 14px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.global-search input {
  width: 100%;
  min-height: 46px;
  padding: 0 16px 0 44px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  outline: none;
}
.global-search input:focus { border-color: var(--line-2); }
.gs-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 8px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
}
.gs-results a, .gs-results button { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--r-xs); border: none; background: none; text-align: left; cursor: pointer; }
.gs-results a:hover, .gs-results button:hover, .gs-results .hl { background: var(--surface-3); }
.gs-results small { margin-left: auto; color: var(--muted); font-size: 12px; }
.gs-empty { padding: 12px; color: var(--muted); font-size: 14px; }
.top-total { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; padding: 10px 16px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.top-total:empty { display: none; }

.tabbar { display: none; }

/* ---------- Кнопки ---------- */

/* Таблетка со стрелкой в кружке */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 6px 6px 6px 24px;
  border-radius: 99px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.pill-btn i { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-ink); color: var(--accent); transition: transform 0.2s; }
.pill-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pill-btn:hover { background: var(--accent-hover); }
.pill-btn:hover i { transform: rotate(-45deg); }
.pill-btn:active { transform: scale(0.98); }
.pill-btn.dark { background: var(--text); color: var(--bg); }
.pill-btn.dark i { background: var(--bg); color: var(--text); }
.pill-sm { min-height: 46px; padding-left: 18px; gap: 10px; font-size: 14px; }
.pill-sm i { width: 34px; height: 34px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 99px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--surface-3); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* Сегментный переключатель (как Д / Н / М) */
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); flex-wrap: wrap; }
.segmented button {
  min-height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 99px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--text); color: var(--bg); }
.segmented b { font: 500 11px var(--f-mono); margin-left: 4px; opacity: 0.6; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Карточки и страницы ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head > div { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.page-head h1 { font-size: 36px; line-height: 1.1; }
.page-head p { color: var(--muted); max-width: 62ch; }
.crumbs { display: flex; gap: 8px; color: var(--muted); font-size: 13px; }
.crumbs a:hover { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 24px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 18px; }
.card-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); color: var(--text); }
.card-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-title { display: flex; align-items: center; gap: 12px; }
.card-title h3 { font-size: 18px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.section { display: flex; flex-direction: column; gap: 16px; }
.section + .section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 22px; }
.link { color: var(--accent); font-weight: 500; }
.link:hover { color: var(--accent-hover); }

/* Крупная цифра с маленькой единицей */
.big { font-size: 56px; line-height: 0.95; font-weight: 600; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.big small { font-size: 20px; font-weight: 500; letter-spacing: -0.01em; color: var(--muted); margin-left: 4px; }
.mid { font-size: 32px; line-height: 1; font-weight: 600; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.mid small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }

/* Полосы-деления (шкала) */
.ticks { display: flex; gap: 4px; height: 40px; align-items: stretch; }
.ticks span { flex: 1; border-radius: 3px; background: var(--surface-3); }
.ticks span.on { background: var(--accent); }

.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.4s; }

.cat-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-3); gap: 3px; }
.cat-bar span { display: block; height: 100%; border-radius: 99px; }
.cat-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.cat-legend div { display: flex; align-items: center; gap: 8px; }
.cat-legend i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cat-legend b { margin-left: auto; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Главная: бенто ---------- */

.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 40px;
  overflow: hidden;
  background:
    radial-gradient(80% 90% at 85% 40%, var(--accent-glow), transparent 65%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--surface);
}
.hero-text { position: relative; display: flex; flex-direction: column; gap: 18px; }
.hero h1 { font-size: 54px; line-height: 1.02; letter-spacing: -0.045em; }
.hero h1 .serif { color: var(--accent); font-size: 1.06em; }
.hero p { color: var(--muted); font-size: 16px; max-width: 42ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.hero-art { position: relative; width: 100%; max-width: 440px; justify-self: center; }
.hero-art svg { width: 100%; height: auto; display: block; overflow: visible; }

/* Изометрическая комната */
.iso-wall { fill: var(--surface-3); stroke: var(--line-2); stroke-width: 1; }
.iso-wall.side { fill: var(--surface-2); }
.iso-floor { fill: var(--surface-2); stroke: var(--line-2); }
.iso-tile { fill: var(--accent); stroke: var(--accent-ink); stroke-width: 0.6; opacity: 0; animation: tile-in 0.35s ease-out forwards; }
.iso-tile.wall { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 0.6; opacity: 0; }
.iso-grid { fill: none; stroke: var(--line-2); stroke-width: 0.6; }
.iso-hole { fill: var(--bg); stroke: var(--line-2); }
.iso-dim { stroke: var(--muted); stroke-width: 1; fill: none; }
.iso-dim-text { fill: var(--text); font: 500 11px var(--f-mono); }
.iso-badge rect { fill: var(--text); }
.iso-badge text { fill: var(--bg); font: 600 12px var(--f-body); }
@keyframes tile-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.stat-card { display: flex; flex-direction: column; gap: 18px; }
.stat-card .foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: auto; }
.stat-card .foot div { display: flex; flex-direction: column; }
.stat-card .foot b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-card .foot span { font-size: 12px; color: var(--muted); }
.card.accent-card {
  background:
    radial-gradient(100% 100% at 100% 0%, rgba(255, 255, 255, 0.18), transparent 60%),
    var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.accent-card .muted, .accent-card .label { color: rgba(18, 10, 4, 0.66); }
:root[data-theme="light"] .accent-card .muted, :root[data-theme="light"] .accent-card .label { color: rgba(255, 255, 255, 0.78); }
.accent-card .big small { color: inherit; opacity: 0.7; }
.accent-card .card-ico { border-color: currentColor; color: inherit; }
.accent-card .ticks span { background: rgba(0, 0, 0, 0.14); }
.accent-card .ticks span.on { background: var(--accent-ink); }

.reminder { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 14px 16px; border-radius: var(--r-sm); background: var(--surface-2); }
.reminder + .reminder { margin-top: 8px; }
.reminder .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.reminder .dot.late { background: var(--danger); }
.reminder b { font-weight: 500; }
.reminder span { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }

.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step { display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.step-n { font: 500 12px var(--f-mono); color: var(--accent); }
.step b { font-weight: 600; }
.step span { color: var(--muted); font-size: 14px; }

/* Плитки калькуляторов */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.calc-tile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.calc-tile:hover { border-color: var(--line-2); background: var(--surface-2); transform: translateY(-2px); }
.calc-tile .row { display: flex; justify-content: space-between; align-items: flex-start; }
.calc-tile .go { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-2); color: var(--muted); transition: all 0.2s; }
.calc-tile .go svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(-45deg); }
.calc-tile:hover .go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.calc-tile b { font-weight: 600; font-size: 16px; display: block; }
.calc-tile span.d { color: var(--muted); font-size: 13px; line-height: 1.4; }
.sym {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 500 14px var(--f-mono);
}
.cat-group + .cat-group { margin-top: 28px; }
.cat-group h3 { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-bottom: 12px; }

/* ---------- Формы ---------- */

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 500; color: var(--muted); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input, .select, .textarea {
  width: 100%;
  min-height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 16px;
  transition: border-color 0.15s, background 0.15s;
  appearance: none;
}
.textarea { padding: 12px 16px; min-height: 90px; resize: vertical; line-height: 1.5; }
.input.n { font-variant-numeric: tabular-nums; padding-right: 54px; font-weight: 500; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.select {
  cursor: pointer;
  padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 22px, calc(100% - 17px) 22px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.unit { position: absolute; right: 16px; color: var(--faint); font-size: 14px; pointer-events: none; }
.field.invalid .input { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; }
.field-error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Калькулятор ---------- */

.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 12px; align-items: start; }
.formula { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.formula summary { cursor: pointer; color: var(--muted); font-weight: 500; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 10px; }
.formula summary::-webkit-details-marker { display: none; }
.formula summary::before { content: "+"; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--accent); font-family: var(--f-mono); }
.formula[open] summary::before { content: "−"; }
.formula p { margin-top: 12px; color: var(--muted); font-size: 14px; line-height: 1.65; }

.result { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 18px; }
.result-main { display: flex; flex-direction: column; gap: 10px; }
.summary { display: flex; flex-direction: column; margin: 0; }
.summary div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.summary div:last-child { border-bottom: none; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.res-items { display: flex; flex-direction: column; gap: 8px; }
.res-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; font-size: 14px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); }
.res-item small { color: var(--muted); font-size: 12px; }
.res-item .num { text-align: right; font-weight: 500; }
.res-total { display: flex; justify-content: space-between; align-items: baseline; }
.res-total b { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.res-empty { color: var(--muted); padding: 32px 8px; text-align: center; }

/* ---------- Смета ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .select { width: auto; min-width: 240px; max-width: 100%; border-radius: 99px; min-height: 46px; }
.toolbar .spacer { flex: 1; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; align-items: start; margin-top: 12px; }
.est-table { padding: 8px; }
.est-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 120px 116px 44px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--r-sm);
}
.est-row[data-id]:hover { background: var(--surface-2); }
.est-row.head { padding-block: 10px 6px; }
.est-row.head span { font-size: 12px; color: var(--faint); font-weight: 500; }
.est-name b { display: block; font-weight: 500; }
.est-name small { color: var(--muted); font-size: 12px; }
.est-row .input { min-height: 40px; font-size: 14px; padding: 0 10px; padding-right: 40px; border-radius: var(--r-xs); }
.est-row .unit { font-size: 12px; right: 10px; }
.est-sum { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.est-cat-title { display: flex; align-items: center; gap: 8px; padding: 16px 14px 6px; font-size: 13px; font-weight: 600; }
.est-cat-title i { width: 8px; height: 8px; border-radius: 50%; }
.m-sum { display: none; color: var(--text); font-weight: 600; }

.totals { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 12px; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-xl);
}
.empty b { font-size: 17px; }
.empty p { color: var(--muted); max-width: 42ch; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form .input { flex: 1 1 220px; }
.confirm { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 12px 12px 20px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; margin-top: 12px; }
.confirm span { flex: 1 1 200px; }

/* ---------- Справочник ---------- */

.search { position: relative; }
.search .input { padding-left: 46px; border-radius: 99px; }
.search svg { position: absolute; left: 16px; top: 15px; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }

.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mat-card { display: flex; flex-direction: column; gap: 10px; padding: 22px; text-align: left; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.mat-card:hover { border-color: var(--line-2); background: var(--surface-2); }
.mat-card b { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.mat-card p { color: var(--muted); font-size: 14px; line-height: 1.45; }
.mat-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; }
.mat-price { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.mat-price small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }

/* Модальное окно */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); animation: fade 0.15s; }
.modal-box { width: min(580px, 100%); max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-xl); padding: 28px; display: flex; flex-direction: column; gap: 18px; box-shadow: var(--shadow); }
.modal-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-top h2 { font-size: 24px; line-height: 1.15; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; font-size: 14px; margin: 0; padding: 16px; border-radius: var(--r-sm); background: var(--surface-2); }
.specs dt { color: var(--muted); }
.specs dd { margin: 0; font-weight: 500; }
.pc { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pc ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.pc .plus { color: var(--ok); }
.pc .minus { color: var(--danger); }
.add-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.add-row .field { flex: 1 1 140px; }

/* ---------- Цены и покупки ---------- */

.split.picker-split { grid-template-columns: 320px minmax(0, 1fr); margin-top: 0; }
.store-list { display: flex; flex-direction: column; gap: 8px; }
.store-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 12px 12px 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid transparent; }
.store-row.best { border-color: var(--accent); background: var(--accent-soft); }
.store-logo { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 700; font-size: 14px; color: #1a1a1a; overflow: hidden; flex: none; }
.store-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.sym svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sym.sm { width: 32px; height: 32px; }
.sym.sm svg { width: 16px; height: 16px; }
.store-row b { display: block; font-weight: 600; }
.store-row small { color: var(--muted); font-size: 12px; }
.store-price { font-size: 20px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; text-align: right; }
.store-price small { display: block; font-size: 12px; font-weight: 500; letter-spacing: 0; }

.mat-picker { display: flex; flex-direction: column; gap: 4px; max-height: 460px; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.mat-picker button { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); border: none; background: none; text-align: left; cursor: pointer; font-size: 14px; }
.mat-picker button:hover { background: var(--surface-2); }
.mat-picker button.active { background: var(--surface-3); }
.mat-picker small { color: var(--muted); white-space: nowrap; }

.shop-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border-radius: var(--r-sm); }
.shop-item:hover { background: var(--surface-2); }
.shop-item.done .shop-name { text-decoration: line-through; color: var(--faint); }
.shop-name b { font-weight: 500; display: block; }
.shop-name small { color: var(--muted); font-size: 12px; }
.shop-price { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.shop-price a { display: block; font-size: 12px; font-weight: 500; color: var(--accent); }
.store-totals { display: flex; flex-direction: column; gap: 8px; }
.store-total { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 14px; }
.store-total .store-logo { width: 32px; height: 32px; font-size: 11px; }
.store-total b { margin-left: auto; font-variant-numeric: tabular-nums; }
.store-total.best { outline: 1px solid var(--accent); }

/* ---------- План работ ---------- */

.task-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.task-col { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.task-col h3 { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; font-size: 15px; }
.task-col h3 b { font: 500 12px var(--f-mono); color: var(--muted); margin-left: auto; }
.task-col h3 i { width: 8px; height: 8px; border-radius: 50%; }
.task {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.task-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.task-top b { font-weight: 600; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.task-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.task-actions .btn { min-height: 34px; padding: 0 12px; font-size: 13px; }
.task-col .empty-col { padding: 20px 8px; text-align: center; color: var(--faint); font-size: 14px; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: 12px; color: var(--faint); text-align: center; padding-bottom: 4px; }
.cal .day { min-height: 92px; padding: 8px; border-radius: var(--r-sm); background: var(--surface-2); display: flex; flex-direction: column; gap: 4px; font-size: 12px; min-width: 0; }
.cal .day.out { background: none; color: var(--faint); }
.cal .day.today { outline: 1px solid var(--accent); }
.cal .day > span { font-weight: 600; font-size: 13px; }
.cal .ev { padding: 2px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev.done { background: var(--ok-soft); color: var(--ok); text-decoration: line-through; }
.cal .ev.late { background: var(--danger-soft); color: var(--danger); }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.cal-head h3 { font-size: 18px; min-width: 160px; text-transform: capitalize; }

/* ---------- Документы ---------- */

.doc-layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 12px; align-items: start; }
.doc-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 4px; }
.doc-type { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); text-align: left; cursor: pointer; }
.doc-type b { font-size: 14px; font-weight: 600; }
.doc-type small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.doc-type.active { border-color: var(--accent); background: var(--accent-soft); }
.doc-form { display: flex; flex-direction: column; gap: 14px; }

.paper-wrap { padding: 28px; border-radius: var(--r-xl); background: var(--surface-2); border: 1px solid var(--line); overflow-x: auto; }
.paper {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  min-width: 520px;
  padding: 48px 52px;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  font: 400 13px/1.55 var(--f-body);
}
.paper h2 { font-size: 20px; text-align: center; letter-spacing: -0.01em; margin-bottom: 4px; }
.paper .sub { text-align: center; color: #666; margin-bottom: 24px; }
.paper .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.paper .parties div { display: flex; flex-direction: column; gap: 2px; }
.paper .parties span { color: #777; font-size: 11px; }
.paper table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 12px; }
.paper th, .paper td { border: 1px solid #d6d3cc; padding: 6px 8px; text-align: left; vertical-align: top; }
.paper th { background: #f0eee9; font-weight: 600; }
.paper td.r, .paper th.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper .total-row td { font-weight: 700; background: #f7f5f1; }
.paper p { margin: 8px 0; }
.paper ol { padding-left: 18px; margin: 8px 0; }
.paper ol li { margin: 4px 0; }
.paper .signs { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 36px; }
.paper .signs div { border-top: 1px solid #999; padding-top: 6px; font-size: 11px; color: #555; }
.paper .stamp { margin-top: 28px; font-size: 10px; color: #999; text-align: center; }
.paper .doc-brand { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; margin-bottom: 22px; border-bottom: 1px solid #e4e1da; color: #141416; }
.paper .doc-brand .brand { font-size: 20px; }
.paper .doc-brand small { font-size: 10px; color: #8a8a8a; }

.note { display: flex; gap: 12px; padding: 16px 18px; border-radius: var(--r); background: var(--warn-soft); color: var(--text); font-size: 14px; }
.note::before { content: "!"; display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--warn); color: var(--accent-ink); font-weight: 700; font-size: 13px; }

/* ---------- Анализатор ---------- */

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 24px;
  text-align: center;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-xl);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .card-ico { width: 56px; height: 56px; }
.drop .card-ico svg { width: 24px; height: 24px; }
.drop p { color: var(--muted); max-width: 46ch; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); }
.stat .mid.danger { color: var(--danger); }
.stat .mid.warn { color: var(--warn); }
.stat .mid.ok { color: var(--ok); }
.table-wrap { overflow-x: auto; }
.atable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 680px; }
.atable th { text-align: left; font-size: 12px; font-weight: 500; color: var(--faint); padding: 8px 12px; }
.atable td { padding: 12px; border-top: 1px solid var(--line); vertical-align: top; }
.atable td.r, .atable th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.atable tr.bad td { background: var(--danger-soft); }
.atable tr.warn td { background: var(--warn-soft); }
.atable .issues { display: flex; flex-direction: column; gap: 4px; }
.atable .issues span { font-size: 12px; }

/* ---------- Ещё ---------- */

.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.more-link { display: flex; flex-direction: column; gap: 14px; padding: 22px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); transition: border-color 0.15s; }
.more-link:hover { border-color: var(--line-2); }
.more-link b { font-size: 17px; }
.more-link p { color: var(--muted); font-size: 14px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 0; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: none; }
.settings-row small { display: block; color: var(--muted); font-size: 13px; }

/* ---------- Работы и цены (документы) и «Мои расценки» ---------- */

.we { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.we-head { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0 4px; }
.we-head b { font-size: 16px; }
/* Колонка формы узкая, поэтому название работы — отдельной строкой, под ним объём, цена и сумма */
.we-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto 32px;
  grid-template-areas: "name name name del" "qty price sum sum";
  gap: 6px 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.we-row > :nth-child(1) { grid-area: name; }
.we-row > :nth-child(2) { grid-area: qty; }
.we-row > :nth-child(3) { grid-area: price; }
.we-row > :nth-child(4) { grid-area: sum; min-width: 76px; }
.we-row > :nth-child(5) { grid-area: del; justify-self: end; }
.we-cap { display: none; }
.we .input.n[data-f="price"] { padding-right: 52px; }
.we-name { font-size: 14px; font-weight: 500; min-width: 0; }
.we .input { min-height: 40px; font-size: 14px; padding: 0 10px; padding-right: 36px; border-radius: var(--r-xs); }
.we .input.we-name { padding-right: 10px; }
.we .unit { right: 10px; font-size: 12px; }
.we-unit { position: absolute; right: 4px; width: 34px; border: none; background: transparent; color: var(--faint); font-size: 12px; text-align: right; outline: none; }
.we-sum { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.we .icon-btn { width: 32px; height: 32px; }
.we .icon-btn svg { width: 16px; height: 16px; }
.we > .btn { align-self: flex-start; }
.rates-row { grid-template-columns: minmax(0, 1fr) 48px 140px 90px; }

@media (max-width: 760px) {
  .est-row.rates-row { grid-template-columns: minmax(0, 1fr) 130px; grid-template-areas: none; }
  .est-row.rates-row > * { grid-area: auto; }
  .rates-row > :nth-child(2), .rates-row > :nth-child(4) { display: none; }
}

/* ---------- Пользователь в боковой панели ---------- */

.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 4px 6px 8px; }
.side-user > div { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.side-user b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Вход ---------- */

.auth-box { width: min(440px, 100%); gap: 16px; }
.btn-google { min-height: 50px; background: #fff; color: #1f1f1f; border-color: #dadce0; gap: 12px; }
.btn-google:hover { background: #f4f4f4; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.auth-foot { text-align: center; }
.auth-foot .link { background: none; border: none; cursor: pointer; font-size: 14px; }
#a-error { text-align: center; }

/* ---------- Тост ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translate(-50%, 20px);
  padding: 12px 20px;
  border-radius: 99px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade { from { opacity: 0; } }
.view-enter > * { animation: rise 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.view-enter > *:nth-child(2) { animation-delay: 0.04s; }
.view-enter > *:nth-child(3) { animation-delay: 0.08s; }
.view-enter > *:nth-child(4) { animation-delay: 0.12s; }
@keyframes rise { from { opacity: 0.3; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .iso-tile { opacity: 1; }
}

/* ---------- Печать документа (Сохранить как PDF) ---------- */

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; }
  .paper { position: absolute; left: 0; top: 0; min-width: 0; max-width: none; padding: 0; box-shadow: none; }
  .paper-wrap { padding: 0; border: none; background: none; }
}

/* ---------- Ноутбук / планшет ---------- */

@media (max-width: 1180px) {
  .span-8, .span-6, .span-4 { grid-column: span 6; }
  .hero.span-8 { grid-column: span 12; }
  .split, .split.picker-split, .doc-layout { grid-template-columns: 1fr; }
  .mat-picker { max-height: 240px; }
  .totals { position: static; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .app { grid-template-columns: 92px minmax(0, 1fr); }
  .sidebar { align-items: center; padding-inline: 10px; }
  .sidebar .brand-full { display: none; }
  .sidebar .brand-short { display: inline-flex; font-size: 30px; }
  .sidebar .logo { padding: 0; }
  .side-nav .nav-text, .side-nav .nav-group, .nav-badge, .side-foot { display: none; }
  .side-nav a { padding: 0; justify-content: center; width: 52px; height: 52px; }
  .side-nav a .nav-ico { width: 40px; height: 40px; }
  .side-nav a.active { background: none; }
  .calc-layout { grid-template-columns: 1fr; }
  .result { position: static; }
  .task-cols { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-art { max-width: 380px; }
}

/* ---------- Телефон ---------- */

@media (max-width: 760px) {
  .app { display: block; padding: 0; }
  .sidebar { display: none; }

  .topbar {
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 20;
    min-height: 60px;
    padding-block: 8px;
    padding-left: var(--gutter-l);
    padding-right: var(--gutter-r);
    background: var(--bg);
  }
  body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: env(safe-area-inset-top, 0px);
    z-index: 10;
    background: var(--bg);
  }
  .topbar #top-logo { display: flex; }
  .topbar #back-btn:not([hidden]) { display: inline-grid; margin-left: -10px; }
  .topbar #back-btn:not([hidden]) ~ #top-logo { display: none; }
  .topbar #back-btn:not([hidden]) ~ .topbar-title { display: block; }
  .topbar-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .global-search, .top-cta { display: none; }
  .top-total { padding: 8px 14px; font-size: 14px; background: var(--accent-soft); color: var(--accent); border-color: transparent; }

  .tabbar {
    position: fixed;
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px;
    border-radius: 99px;
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    box-shadow: var(--shadow);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 54px;
    border-radius: 99px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
  }
  .tabbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.active { background: var(--accent); color: var(--accent-ink); }

  .main {
    padding-block: 8px calc(110px + env(safe-area-inset-bottom, 0px));
    padding-left: var(--gutter-l);
    padding-right: var(--gutter-r);
  }

  .card { padding: 18px; border-radius: var(--r); }
  .page-head h1 { font-size: 28px; }
  .crumbs { display: none; }
  .span-8, .span-6, .span-4, .span-12 { grid-column: span 12; }
  .hero { padding: 26px 20px 20px; }
  .hero h1 { font-size: 36px; }
  .big { font-size: 46px; }
  .steps { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .calc-tile { padding: 14px; gap: 14px; }
  .calc-tile span.d, .calc-tile .go { display: none; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }

  .toolbar .select { flex: 1 1 100%; min-width: 0; }
  .toolbar .spacer { display: none; }
  .toolbar .btn { flex: 1 1 auto; }
  .est-table { padding: 4px; }
  .est-row.head { display: none; }
  .est-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    grid-template-areas: "name name del" "qty price price";
    padding: 12px;
  }
  .est-name { grid-area: name; }
  .est-qty { grid-area: qty; }
  .est-price { grid-area: price; }
  .est-sum { display: none; }
  .est-del { grid-area: del; justify-self: end; }
  .m-sum { display: inline; }
  .pc { grid-template-columns: 1fr; }
  .modal { align-items: end; padding: 0; }
  .modal-box { border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 22px 16px calc(22px + env(safe-area-inset-bottom, 0px)); }
  .store-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .store-row .btn { grid-column: 1 / -1; }
  .cal .day { min-height: 56px; padding: 4px; }
  .cal .ev { font-size: 0; height: 6px; padding: 0; }
  .doc-types { grid-template-columns: 1fr 1fr; }
  .paper-wrap { padding: 12px; }
  .paper { padding: 28px 24px; }
  .stats { gap: 8px; }
  .stat { padding: 16px; border-radius: var(--r); }
  .confirm { border-radius: var(--r); }
}

@media (max-width: 380px) {
  .form { grid-template-columns: 1fr; }
  .hero h1 { font-size: 31px; }
}
