/* ============ Токены — фирменный стиль SD INSTAL ============
   Teal #008F87 (бренд) · Deep Teal #006D68 (кнопки) · Graphite #252B30 · Concrete #F5F7F6 · Steel #AEBBBE */
:root {
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --surface-2: #F7F9F8;
  --surface-3: #EBEFEE;
  --ink: #252B30;
  --ink-2: #4E575D;
  --ink-3: #7C878C;
  --line: #E2E7E6;
  --line-strong: #CCD4D4;
  --steel: #AEBBBE;
  --brand: #008F87;
  --accent: #006D68;
  --accent-hover: #005853;
  --accent-soft: #E3F1EF;
  --accent-text: #006D68;
  --on-accent: #FFFFFF;
  --ok: #1E7F4E;
  --ok-soft: #E4F4EA;
  --info: #2F6A9E;
  --info-soft: #E8F0F7;
  --danger: #C8402F;
  --danger-soft: #FBEBE8;
  --mute-soft: #EBEFEE;
  --shadow: 0 1px 2px rgba(37, 43, 48, 0.05);
  --shadow-lg: 0 24px 60px -24px rgba(37, 43, 48, 0.4);
  --backdrop: rgba(37, 43, 48, 0.45);
  --radius: 16px;
  --radius-sm: 12px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --side-w: 248px;
  --col: 780px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --kb: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181B; --surface: #1C2226; --surface-2: #222A2F; --surface-3: #2A3338;
    --ink: #EEF2F2; --ink-2: #B7C2C4; --ink-3: #7E8B8F;
    --line: #2A3338; --line-strong: #38444A; --steel: #6E7C80;
    --brand: #38C5B8; --accent: #38C5B8; --accent-hover: #5AD3C7; --accent-soft: #143532; --accent-text: #5AD3C7; --on-accent: #0B2421;
    --ok: #4CC287; --ok-soft: #142D20;
    --info: #7FB0DD; --info-soft: #172A3B;
    --danger: #FF7A66; --danger-soft: #3A1D18;
    --mute-soft: #2A3338;
    --shadow: none;
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
    --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181B; --surface: #1C2226; --surface-2: #222A2F; --surface-3: #2A3338;
  --ink: #EEF2F2; --ink-2: #B7C2C4; --ink-3: #7E8B8F;
  --line: #2A3338; --line-strong: #38444A; --steel: #6E7C80;
  --brand: #38C5B8; --accent: #38C5B8; --accent-hover: #5AD3C7; --accent-soft: #143532; --accent-text: #5AD3C7; --on-accent: #0B2421;
  --ok: #4CC287; --ok-soft: #142D20;
  --info: #7FB0DD; --info-soft: #172A3B;
  --danger: #FF7A66; --danger-soft: #3A1D18;
  --mute-soft: #2A3338;
  --shadow: none;
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --backdrop: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ============ База ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.grow { flex: 1; }
.block { display: flex; width: 100%; }

.eyebrow { margin: 0 0 2px; font-size: 14px; font-weight: 500; color: var(--ink-3); }
.h1 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.h2 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.25; }

/* ============ Каркас ============ */
.shell { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.sidebar { display: none; }
.view { min-width: 0; }
.view-inner {
  width: 100%;
  max-width: calc(var(--col) + 32px);
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px 32px;
}
body[data-bar="tabbar"] .view-inner { padding-bottom: calc(100px + var(--safe-b)); }
body[data-bar="editor"] .view-inner,
body[data-bar="preview"] .view-inner { padding-top: 0; padding-bottom: calc(110px + var(--safe-b)); }

.tabbar {
  position: fixed; z-index: 30;
  left: 0; right: 0; bottom: 0;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
body[data-bar="tabbar"] .tabbar { display: grid; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0;
  border-radius: 12px;
  font-size: 12px; font-weight: 500;
  color: var(--ink-3);
}
.tab .ic { width: 24px; height: 24px; }
.tab.active { color: var(--accent); font-weight: 600; }

@media (min-width: 960px) {
  .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 20px;
    position: sticky; top: 0; height: 100dvh;
    padding: 22px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    overflow: auto;
  }
  body[data-bar] .tabbar { display: none; }
  .view-inner { padding: 36px 32px 48px; max-width: calc(var(--col) + 64px); }
  body[data-bar="editor"] .view-inner, body[data-bar="preview"] .view-inner { padding-left: 32px; padding-right: 32px; }
  .hide-lg { display: none !important; }
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--accent); color: var(--on-accent);
  font-size: 20px; font-weight: 700;
  overflow: hidden;
}
.brand-mark.has-img { background: #fff; border: 1px solid var(--line); padding: 3px; }
.brand-mark img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand-txt b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-txt small { font-size: 13px; color: var(--ink-3); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  font-weight: 500; color: var(--ink-2);
}
.side-link:hover { background: var(--surface-2); }
.side-link.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.side-foot { margin-top: auto; }

/* ============ Кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px; font-weight: 600;
  white-space: nowrap;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost, .btn-dark { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover:not(:disabled), .btn-dark:hover:not(:disabled) { background: var(--surface-2); }
.btn-soft { background: var(--accent-soft); color: var(--accent-text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn.danger, .icon-btn.danger { color: var(--danger); }
.btn-lg { min-height: 54px; font-size: 17px; border-radius: 14px; }
.btn.sq { width: 48px; padding: 0; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px;
  background: transparent; color: var(--ink-2);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); }
.icon-btn:disabled { opacity: 0.3; }
.icon-btn.sm { width: 36px; height: 36px; border-radius: 10px; }
.icon-btn.sm .ic { width: 19px; height: 19px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; padding: 4px 0; background: none;
  color: var(--accent-text); font-size: 15px; font-weight: 500;
}
.link-btn .ic { width: 17px; height: 17px; }
.lang-chip {
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface);
  font-size: 14px; font-weight: 600;
}
.fab {
  position: fixed; z-index: 25;
  right: 16px; bottom: calc(84px + var(--safe-b));
  display: inline-flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 22px 0 18px;
  border-radius: 16px;
  background: var(--accent); color: var(--on-accent);
  font-size: 16px; font-weight: 600;
  box-shadow: 0 10px 24px -10px rgba(0, 109, 104, 0.55);
}
.fab .ic { width: 24px; height: 24px; }

/* ============ Поля ============ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field-head {
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.field input, .field select, .field textarea, .input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; line-height: 1.45; min-height: 90px; }
.field select, .sel {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868C98' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field small { font-size: 13px; }

/* Дата: на iPhone Safari рисует поле по-своему (текст по центру, своя высота) — выравниваем с остальными полями */
.field input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  height: 50px;
  min-height: 50px;
  padding: 0 46px 0 14px;
  line-height: 48px;
  text-align: left;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868C98' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='3.5' y='5' width='17' height='15.5' rx='2.5'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
}
.field input[type="date"]::-webkit-date-and-time-value { margin: 0; text-align: left; }
.field input[type="date"]::-webkit-datetime-edit { padding: 0; line-height: 48px; }
/* значок браузера прозрачный и на всё поле — нажатие в любом месте открывает календарь */
.field input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0;
  width: auto; height: auto;
  margin: 0; padding: 0;
  opacity: 0;
  cursor: pointer;
}
input.invalid, textarea.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }
.input.num { text-align: right; }
.w-sm { width: 110px !important; }
.w-xs { width: 80px !important; }
::placeholder { color: var(--ink-3); opacity: 0.8; }

.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 12px; }
.form-grid > .span-2 { grid-column: 1 / -1; }
@media (max-width: 399.98px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 599.98px) { .form-grid.stack-sm { grid-template-columns: minmax(0, 1fr); } }
.field textarea.autogrow { min-height: 50px; resize: none; overflow: hidden; }
.field-row { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.opt-ctrl { display: flex; align-items: center; gap: 8px; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  border-radius: 12px;
  background: var(--surface-3);
}
.seg button {
  min-height: 38px; padding: 0 14px;
  border: 0; border-radius: 9px;
  background: transparent;
  font-size: 15px; font-weight: 500; color: var(--ink-2);
}
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12); }
.seg-dark { display: flex; }
.seg-dark button { flex: 1; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; user-select: none; }
.switch input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.switch-ui {
  width: 48px; height: 28px; flex: none;
  border-radius: 99px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.2s;
}
.switch-ui::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.search {
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .ic { color: var(--ink-3); width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 16px; }

.chips { display: flex; gap: 8px; }
.scroll-x { overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
  font-size: 15px; font-weight: 500; white-space: nowrap;
  color: var(--ink-2);
}
.chip b { font-weight: 500; font-size: 13px; color: var(--ink-3); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip.on b { color: inherit; opacity: 0.7; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.s-draft { --st: var(--ink-3); --st-bg: var(--mute-soft); }
.s-sent { --st: var(--accent-text); --st-bg: var(--accent-soft); }
.s-accepted { --st: var(--ok); --st-bg: var(--ok-soft); }
.s-rejected { --st: var(--danger); --st-bg: var(--danger-soft); }
.dot[class*="s-"] { color: var(--st); }
.badge, .status {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: 99px;
  background: var(--st-bg); color: var(--st);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.sec-title, .card-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 16px;
  font-size: 18px; font-weight: 700;
}
.sec-title .ic { display: none; }
.sec-hint { margin: -10px 0 16px; font-size: 14px; color: var(--ink-3); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.card-head .card-title { margin: 0; }

.saved-ind {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500; color: var(--ok);
  opacity: 0;
}
.saved-ind .ic { width: 15px; height: 15px; }
.saved-ind.show { animation: saved 1.6s ease; }
@keyframes saved { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ============ Заголовки ============ */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px;
}
.page-head .sub { margin: 4px 0 0; font-size: 15px; color: var(--ink-3); }
.head-actions { display: flex; align-items: center; gap: 8px; }
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.sticky-tools {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px 12px; padding: 10px 16px;
  background: var(--bg);
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 6px;
  margin: 0 -16px 14px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 6px;
  background: var(--bg);
}
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-title small { font-size: 13px; color: var(--ink-3); line-height: 1.2; display: flex; gap: 8px; align-items: center; }
.topbar-title b, .ed-number {
  font-size: 19px; font-weight: 700; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ed-number { width: 100%; min-width: 0; border: 0; background: none; padding: 0; border-radius: 6px; }
.ed-number:focus { outline: none; box-shadow: 0 0 0 2px var(--accent); background: var(--surface); }
@media (min-width: 960px) {
  .topbar { margin: 0 -32px 18px; padding: 16px 32px 12px 22px; }
}

.banner {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 15px;
}
.banner-txt { flex: 1; }
.banner-go { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; white-space: nowrap; }
.banner-go .ic { width: 18px; height: 18px; }

/* ============ Список смет ============ */
.dv-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.dv {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
.dv:hover { border-color: var(--line-strong); }
.dv-link { display: flex; flex-direction: column; gap: 4px; padding: 16px; }
.dv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dv-client, .dv-obj { min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dv-client { font-size: 17px; font-weight: 600; line-height: 1.3; }
.dv-total { font-size: 17px; font-weight: 700; white-space: nowrap; }
.dv-obj { font-size: 15px; line-height: 1.35; color: var(--ink-2); }
.dv-row:first-child { align-items: flex-start; }
.dv-meta { font-size: 14px; color: var(--ink-3); }
.dv-row + .dv-row { margin-top: 6px; }

.no-results {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 48px 16px; color: var(--ink-3);
  grid-column: 1 / -1;
}
.no-results .ic { width: 28px; height: 28px; }

.empty-hero {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
  padding: 40px 12px;
  max-width: 420px; margin: 0 auto;
}
.empty-hero p { margin: 0 0 10px; color: var(--ink-2); }
.empty-ic {
  display: grid; place-items: center;
  width: 80px; height: 80px; margin-bottom: 6px;
  border-radius: 24px;
  background: var(--accent-soft); color: var(--accent);
}
.empty-ic .ic { width: 38px; height: 38px; stroke-width: 1.6; }

/* ============ Редактор ============ */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 6px 0 12px;
  border: 0; border-radius: 99px;
  background: var(--st-bg); color: var(--st);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.status-pill .ic { width: 16px; height: 16px; }
.status-pill .dot { width: 7px; height: 7px; }

.works { padding-bottom: 16px; }
.lines { margin: 8px -16px 16px; }
.grp-label {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 14px 16px 8px;
  font-size: 14px; font-weight: 600; color: var(--ink-3);
}
.line {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 13px 12px 13px 16px;
  border: 0; border-top: 1px solid var(--line);
  background: none; text-align: left;
  transition: background 0.15s;
}
.grp-label + .line { border-top-color: transparent; }
.line:hover { background: var(--surface-2); }
.line:active { background: var(--surface-3); }
.line.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }
.line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.line-name { font-size: 16px; font-weight: 500; line-height: 1.3; }
.line-name.empty { color: var(--ink-3); font-style: italic; }
.line-calc { font-size: 14px; color: var(--ink-3); }
.line-calc .changed { color: var(--accent-text); }
.line-sum { font-size: 16px; font-weight: 600; white-space: nowrap; }
.line .ic { width: 18px; height: 18px; color: var(--line-strong); margin-left: -4px; }

.lines-empty { padding: 20px 16px 8px; text-align: center; color: var(--ink-3); font-size: 15px; }
.add-custom { display: flex; justify-content: center; margin-top: 10px; }

.totals { padding-top: 6px; padding-bottom: 6px; }
.trow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px;
  border-top: 1px solid var(--line);
}
.trow:first-child { border-top: 0; }
.trow > span:first-child { color: var(--ink-2); }
.trow-val { font-weight: 500; white-space: nowrap; }
.trow.grand { min-height: 64px; flex-wrap: wrap; row-gap: 0; padding: 8px 0; }
.trow.grand span:first-child { font-size: 18px; font-weight: 700; color: var(--ink); }
.trow.grand strong { margin-left: auto; font-size: clamp(20px, 6.2vw, 24px); font-weight: 700; white-space: nowrap; }
.mini { display: flex; align-items: center; gap: 6px; }
.mini input {
  width: 92px; height: 42px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface);
  font-size: 16px; text-align: right;
}
.mini input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.unit-toggle {
  height: 42px; min-width: 54px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2);
  font-size: 15px; font-weight: 600;
}
details.notes { border-top: 1px solid var(--line); }
details.notes summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 56px;
  list-style: none; cursor: pointer;
  color: var(--ink-2);
}
details.notes summary::-webkit-details-marker { display: none; }
details.notes summary .ic { width: 18px; height: 18px; color: var(--ink-3); transition: transform 0.2s; }
details.notes[open] summary .ic { transform: rotate(180deg); }
details.notes .field { padding-bottom: 14px; }

.bottombar {
  position: fixed; z-index: 30;
  left: 0; right: 0; bottom: 0;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px -20px rgba(17, 24, 39, 0.35);
}
.bottombar-in { display: flex; align-items: center; gap: 12px; max-width: var(--col); margin: 0 auto; }
.bb-total { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bb-total span { font-size: 13px; color: var(--ink-3); }
.bb-total strong { font-size: clamp(17px, 5.4vw, 22px); font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:not([data-bar="editor"]) .ed-bar { display: none; }
@media (min-width: 960px) { .bottombar { left: var(--side-w); } }

/* Редактирование строки */
.le { display: flex; flex-direction: column; gap: 16px; }
.le-qty { display: flex; gap: 8px; align-items: flex-end; }
.input-group {
  display: flex; align-items: stretch;
  height: 56px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-group input {
  flex: 1; min-width: 0; width: 100%;
  border: 0 !important; box-shadow: none !important; background: none; outline: none;
  min-height: 0 !important; padding: 0 14px !important;
  font-size: 20px !important; font-weight: 600;
}
.input-group select {
  flex: none; width: auto; min-height: 0 !important;
  border: 0 !important; border-left: 1px solid var(--line) !important; border-radius: 0 !important;
  background-color: var(--surface-2) !important;
  box-shadow: none !important;
  font-weight: 500;
}
.input-group .affix { display: grid; place-items: center; padding: 0 14px; color: var(--ink-3); background: var(--surface-2); border-left: 1px solid var(--line); font-size: 15px; }
.le-qty .calc-btn { width: 56px; height: 56px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm); }
.le-sum {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface-2);
}
.le-sum span { color: var(--ink-2); }
.le-sum strong { font-size: 24px; font-weight: 700; }

/* ============ Выбор из каталога ============ */
.picker { display: flex; flex-direction: column; }
.pk-top {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-direction: column; gap: 10px;
  padding: 2px 0 10px;
  background: var(--surface);
}
.pk-top .scroll-x { margin: 0 -18px; padding: 2px 18px; }
.pk-cat {
  padding: 16px 4px 6px;
  font-size: 14px; font-weight: 600; color: var(--ink-3);
}
.pk-item { border-top: 1px solid var(--line); border-radius: 12px; transition: background 0.2s; }
.pk-cat + .pk-item { border-top-color: transparent; }
.pk-item.open { background: var(--accent-soft); border-top-color: transparent; }
.pk-item.open + .pk-item { border-top-color: transparent; }
.pk-item.just { animation: flash 0.7s ease; }
.pk-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
  width: 100%; padding: 13px 8px;
  border: 0; background: none; text-align: left;
}
.pk-name { font-weight: 500; line-height: 1.3; }
.pk-meta { font-size: 14px; color: var(--ink-3); white-space: nowrap; text-align: right; }
.pk-meta b { font-size: 16px; font-weight: 600; color: var(--ink); }
.pk-badge { grid-column: 1 / -1; }
.pk-badge:empty { display: none; }
.pk-in {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 4px; padding: 2px 9px 2px 6px;
  border-radius: 99px;
  background: var(--ok-soft); color: var(--ok);
  font-size: 13px; font-weight: 600;
}
.pk-in .ic { width: 15px; height: 15px; }
.pk-form { display: flex; gap: 8px; padding: 0 8px 12px; }
.pk-form.shake { animation: shake 0.35s; }
.qty-field {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  height: 52px; padding: 0 14px;
  border: 1.5px solid var(--accent); border-radius: 12px;
  background: var(--surface);
}
.qty-field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 19px; font-weight: 600; }
.qty-field span { color: var(--ink-3); font-weight: 500; }
.pk-form .calc-btn { width: 52px; height: 52px; border: 1px solid var(--line-strong); background: var(--surface); }
.pk-form .btn { min-height: 52px; }
@media (max-width: 400px) { .pk-form .btn span { display: none; } .pk-form .btn { width: 52px; padding: 0; } }
.pk-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 8px; color: var(--ink-3); text-align: center; }
.pk-empty p { margin: 0; }
.pk-empty .ic { width: 26px; height: 26px; }
.pk-empty .btn { white-space: normal; text-align: left; }
.pk-hint { flex: 1; font-size: 14px; color: var(--ink-3); }
.pk-hint.ok { color: var(--ok); font-weight: 600; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ============ Калькулятор ============ */
.calc-hint { margin: 0 0 14px; font-size: 15px; }
.calc-rows { display: flex; flex-direction: column; gap: 8px; }
.calc-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 12px minmax(0, 1fr) minmax(54px, auto) 36px;
  align-items: center; gap: 6px;
}
.calc-row input {
  width: 100%; height: 50px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface);
  font-size: 17px; text-align: right;
}
.calc-row input::placeholder { font-size: 13px; text-align: left; }
.calc-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.calc-row output { font-size: 15px; font-weight: 600; text-align: right; }
.calc-row .op { color: var(--ink-3); text-align: center; }
.calc-sign { font-size: 18px; font-weight: 700; color: var(--ok); text-align: center; }
.calc-row.neg .calc-sign, .calc-row.neg output { color: var(--danger); }
.calc-add { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.calc-add .btn { min-height: 44px; font-size: 15px; font-weight: 500; }
.calc-add .minus { font-size: 20px; font-weight: 700; color: var(--danger); }
.calc-total {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 14px; padding: 16px;
  border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-text);
}
.calc-total span { font-weight: 500; }
.calc-total strong { font-size: 26px; font-weight: 700; }

/* ============ Каталог ============ */
.cat-list { display: flex; flex-direction: column; gap: 14px; }
.ci-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ci-cat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px 6px;
  font-size: 14px; font-weight: 600; color: var(--ink-3);
}
.ci { display: flex; align-items: center; gap: 10px; padding: 4px 12px 4px 4px; border-top: 1px solid var(--line); }
.ci-cat + .ci { border-top-color: transparent; }
.ci-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 11px 12px; border: 0; border-radius: 10px;
  background: none; text-align: left;
}
.ci-main:hover { background: var(--surface-2); }
.ci-name { font-weight: 500; line-height: 1.3; }
.ci-alt { font-size: 14px; color: var(--ink-3); line-height: 1.3; }
.ci-price {
  display: flex; align-items: center; gap: 6px; flex: none;
  height: 44px; padding: 0 12px 0 4px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2);
}
.ci-price:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.ci-price input { width: 70px; border: 0; background: none; outline: none; font-size: 16px; font-weight: 600; text-align: right; }
.ci-unit { font-size: 13px; color: var(--ink-3); white-space: nowrap; min-width: 46px; }

.cats-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.cat-row { display: flex; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.cat-row-names { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cat-row-names input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); font-size: 16px;
}
.cat-row-names input:focus { outline: none; border-color: var(--accent); }
.cat-row-btns { display: flex; flex-direction: column; gap: 2px; }
@media (min-width: 560px) { .cat-row-names, .cat-row-btns { flex-direction: row; } }

/* ============ Настройки ============ */
.set-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.set-grid .card + .card { margin-top: 0; }
.logo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.logo-box {
  width: 80px; height: 80px; flex: none;
  display: grid; place-items: center;
  border: 1px dashed var(--line-strong); border-radius: 16px;
  background: #fff; color: #A3A9B5;
  overflow: hidden; padding: 6px;
}
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.logo-btns .btn { min-height: 44px; font-size: 15px; }
.data-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.settings .card > .btn.danger { margin-top: 8px; }

/* ============ Предпросмотр ============ */
.pv-actions { display: flex; gap: 8px; }
.topbar .seg button { min-height: 34px; padding: 0 12px; }
.pv-warn { margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font-size: 15px; }
.pv-desk { padding: 4px 0 8px; }
.pv-pages { --s: 0.45; display: flex; flex-direction: column; align-items: center; gap: 16px; transition: opacity 0.2s; }
.pv-pages.dim { opacity: 0.4; }
.pv-page {
  width: calc(794px * var(--s));
  height: calc(1123px * var(--s));
  flex: none;
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px -18px rgba(17, 24, 39, 0.35);
  overflow: hidden;
  background: #fff;
}
.pv-scale { width: 794px; height: 1123px; transform: scale(var(--s)); transform-origin: 0 0; }
.pv-loading { display: grid; place-items: center; height: 50vh; }

.pv-bar {
  position: fixed; z-index: 30;
  left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px -20px rgba(17, 24, 39, 0.35);
}
.pv-bar-total { display: flex; justify-content: space-between; align-items: baseline; }
.pv-bar-total span { font-size: 14px; color: var(--ink-3); }
.pv-bar-total { gap: 12px; }
.pv-bar-total strong { min-width: 0; font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.pv-bar-btns { display: flex; gap: 8px; }
.pv-bar-btns .btn { flex: 1; padding: 0 10px; }
.pv-bar-btns [data-act="print"] { flex: none; width: 52px; }
.pv-bar-btns [data-act="print"] span { display: none; }
.pv-busy { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--accent-text); }
body:not([data-bar="preview"]) .pv-bar { display: none; }
body[data-bar="preview"] .view-inner { padding-bottom: calc(160px + var(--safe-b)); }
@media (min-width: 720px) {
  .pv-bar { display: none; }
  body[data-bar="preview"] .view-inner { padding-bottom: 40px; }
}

.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--line-strong); border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.ready { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 8px 0; }
.ready p { margin: 0; color: var(--ink-2); }
.ready-ic { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.ready-ic .ic { width: 30px; height: 30px; }

/* ============ Шторки и диалоги ============ */
dialog.sheet {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  margin: 0; padding: 0 0 var(--kb);
  border: 0; background: transparent; color: var(--ink);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; align-items: flex-end; justify-content: center; }
dialog.sheet::backdrop { background: rgba(37, 43, 48, 0.45); animation: fade 0.2s both; }
dialog.sheet.closing::backdrop { animation: fade 0.18s reverse both; }
.sheet-panel {
  display: flex; flex-direction: column;
  width: 100%; max-width: 620px;
  max-height: calc(100% - 28px);
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheetUp 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  padding-bottom: var(--safe-b);
}
dialog.sheet.closing .sheet-panel { animation: sheetDown 0.18s ease-in both; }
.sheet-tall .sheet-panel { height: calc(100% - 28px); }
.sheet-grab { width: 40px; height: 5px; margin: 8px auto 0; border-radius: 9px; background: var(--line-strong); flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 18px; flex: none; }
.sheet-title { flex: 1; margin: 0; font-size: 19px; font-weight: 700; line-height: 1.3; min-width: 0; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px 18px; }
.sheet-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line);
  flex: none;
}
.sheet-foot .btn { min-height: 50px; }
.sheet-confirm .sheet-head { display: none; }
.sheet-confirm .sheet-panel { max-width: 440px; }
.sheet-confirm .sheet-body { padding-top: 22px; }
.sheet-confirm .sheet-foot .btn { flex: 1; }
.confirm-msg { margin: 0; font-size: 17px; line-height: 1.45; }
.sheet-actions .sheet-panel { max-width: 460px; }
.sheet-actions .sheet-title { font-size: 15px; font-weight: 500; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-list { display: flex; flex-direction: column; padding-bottom: 6px; }
.action-item {
  display: flex; align-items: center; gap: 14px;
  min-height: 56px; padding: 0 12px;
  border: 0; border-radius: 12px;
  background: none; text-align: left;
  font-size: 17px;
}
.action-item:hover { background: var(--surface-2); }
.action-item .ic { color: var(--ink-3); }
.action-item.danger, .action-item.danger .ic { color: var(--danger); }

@media (min-width: 720px) {
  dialog.sheet[open] { align-items: center; padding: 24px; }
  .sheet-panel { border-radius: 20px; max-height: min(760px, 100%); animation: pop 0.2s ease-out both; }
  dialog.sheet.closing .sheet-panel { animation: fade 0.16s reverse both; }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 12px; }
  .sheet-tall .sheet-panel { height: min(760px, 100%); }
}

/* ============ Тосты ============ */
.toasts {
  position: fixed; z-index: 100;
  left: 50%; transform: translateX(-50%);
  bottom: calc(16px + var(--safe-b));
  width: min(440px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
body[data-bar="tabbar"] .toasts { bottom: calc(92px + var(--safe-b)); }
body[data-bar="editor"] .toasts { bottom: calc(96px + var(--safe-b)); }
body[data-bar="preview"] .toasts { bottom: calc(140px + var(--safe-b)); }
@media (min-width: 720px) { body[data-bar="preview"] .toasts { bottom: 24px; } }
@media (min-width: 960px) {
  body[data-bar] .toasts { left: calc(50% + var(--side-w) / 2); }
  body[data-bar="tabbar"] .toasts { bottom: 24px; }
}
.toasts.in-dialog { left: 50% !important; bottom: calc(96px + var(--safe-b) + var(--kb)) !important; }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px 13px 16px;
  border-radius: 14px;
  background: #252B30; color: #F5F7F6;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.45);
  font-size: 15px;
  pointer-events: auto;
  animation: toastIn 0.22s ease-out both;
}
.toast span { flex: 1; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { animation: fade 0.2s reverse both; }
.toast-act { border: 0; background: none; padding: 6px 4px; color: #6FD6CB; font-weight: 600; font-size: 15px; white-space: nowrap; }

/* ============ Анимации ============ */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============ Видимость по ширине ============ */
@media (max-width: 719.98px) {
  .hide-sm { display: none !important; }
  .page-head { flex-wrap: nowrap; align-items: center; }
  .page-head > div:first-child { flex: 1; min-width: 0; }
  .head-actions .btn { min-height: 44px; padding: 0 14px; }
  .head-actions .btn-ghost:has(.hide-sm) { width: 44px; padding: 0; }
  .page-head .sub { font-size: 14px; }
  .page.list { padding-bottom: 72px; }
}
@media (min-width: 720px) {
  .show-sm { display: none !important; }
  .view-inner { padding-left: 24px; padding-right: 24px; }
  .topbar { margin-left: -24px; margin-right: -24px; padding-left: 14px; padding-right: 24px; }
  .scroll-x { margin-left: -24px; margin-right: -24px; padding-left: 24px; padding-right: 24px; }
  .sticky-tools { margin-left: -24px; margin-right: -24px; padding-left: 24px; padding-right: 24px; }
  .card { padding: 22px 22px; }
  .lines { margin-left: -22px; margin-right: -22px; }
  .line, .grp-label { padding-left: 22px; padding-right: 18px; }
  .toolbar:not(.sticky-tools) { flex-direction: row; align-items: center; }
  .toolbar:not(.sticky-tools) .search { flex: 0 1 340px; }
  .toolbar:not(.sticky-tools) .scroll-x { margin: 0; padding: 2px; flex: 1; }
}
@media (min-width: 960px) {
  .topbar { margin-left: -32px; margin-right: -32px; padding-left: 22px; padding-right: 32px; }
  .scroll-x { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .sticky-tools { margin-left: -32px; margin-right: -32px; padding-left: 32px; padding-right: 32px; }
}
@media (max-width: 380px) { .hide-xs { display: none !important; } }
@media (max-width: 419.98px) {
  .cat-row { flex-direction: column; align-items: stretch; }
  .cat-row-btns { flex-direction: row; justify-content: flex-end; }
}
@media (max-width: 374.98px) {
  .status-pill { padding: 0 10px; }
  .status-pill .ic { display: none; }
  .input-group input { font-size: 18px !important; }
  .sheet-foot { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .sheet-foot .btn { padding: 0 14px; }
}
@media (max-width: 350px) {
  .view-inner { padding-left: 12px; padding-right: 12px; }
  .topbar, .sticky-tools { margin-left: -12px; margin-right: -12px; }
  .scroll-x { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .sticky-tools { padding-left: 12px; padding-right: 12px; }
  .card { padding: 16px 14px; }
  .lines { margin-left: -14px; margin-right: -14px; }
  .line, .grp-label { padding-left: 14px; padding-right: 10px; }
  .sheet-body { padding-left: 14px; padding-right: 14px; }
  .pk-top .scroll-x { margin: 0 -14px; padding: 2px 14px; }
}

/* ============ Фирменные детали SD INSTAL ============ */
.h1 { font-weight: 800; letter-spacing: -0.025em; }
.brand-mark.is-symbol { background: transparent; border: 0; padding: 0; }
.tab.active { color: var(--brand); }
.list-brand { margin: 0 0 14px; }
.list-brand img { display: block; height: 30px; width: auto; max-width: 70%; }
:root[data-theme="dark"] .list-brand img.is-brand { content: url("../brand/sd-logo-dark.svg"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .list-brand img.is-brand { content: url("../brand/sd-logo-dark.svg"); }
}
.logo-box.wide { width: 150px; }
.logo-row { flex-wrap: wrap; }
.logo-btns { min-width: 0; }
@media (max-width: 399.98px) { .logo-box.wide { width: 100%; height: 72px; } }
.s-sent { --st: var(--info); --st-bg: var(--info-soft); }
@media (max-width: 479.98px) {
  .sheet-foot { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .sheet-foot .btn { padding: 0 14px; }
  .sheet-foot .btn.danger { width: 50px; padding: 0; flex: none; }
  .sheet-foot .btn.danger span { display: none; }
}

/* ============ Вход ============ */
body[data-bar="login"] .sidebar { display: none; }
body[data-bar="login"] .shell { grid-template-columns: minmax(0, 1fr); }
.login { min-height: calc(100dvh - 60px); display: grid; place-items: center; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; padding: 28px 22px; }
.login-card .h2, .login-text { margin: 0; }
.login-text { margin-top: -8px; }
.login-brand { margin: 0 0 4px; }
.login-brand img { height: 34px; }
.login-err { margin: -4px 0 0; color: var(--danger); font-weight: 600; }
.boot-wait { padding: 48px 16px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ============ Объекты ============ */
.fab { border: 0; }
button.banner { width: 100%; border: 0; text-align: left; font: inherit; cursor: pointer; }
.s-active { --st: var(--info); --st-bg: var(--info-soft); }
.s-done { --st: var(--ok); --st-bg: var(--ok-soft); }

.ob-new > p { margin: 0 0 8px; }
.ob-new .btn { margin-top: 8px; }
.ob-pick .grow { display: flex; flex-direction: column; min-width: 0; }
.ob-pick b { font-weight: 600; line-height: 1.3; }
.ob-pick small { font-size: 14px; color: var(--ink-3); }

.sum-big { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 8px; }
.sum-big > div { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 14px; background: var(--surface-2); min-width: 0; }
.sum-big span { font-size: 14px; color: var(--ink-2); line-height: 1.3; }
.sum-big strong { font-size: clamp(19px, 5.6vw, 24px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-big strong.neg { color: var(--danger); }
.sum-big small { font-size: 12px; color: var(--ink-3); }
.ob-sum .trow { min-height: 48px; }
.ob-sum .trow small { font-weight: 400; }

details.ob-det { border-top: 0; }
.ob-det summary { min-height: 44px; }
.ob-det-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--ink); }
.ob-det-head b { font-size: 18px; font-weight: 700; }
.ob-det-head small { font-size: 14px; }
.ob-det .field { padding-bottom: 0; }
.ob-form { padding: 14px 0 6px; }

.mv-chips { margin-top: 10px; }
.mv-ic { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--surface-3); color: var(--ink-2); }
.line .mv-ic .ic { width: 18px; height: 18px; margin: 0; color: inherit; }
.mv-ic.t-income { background: var(--ok-soft); color: var(--ok); }
.mv-ic.t-extra { background: var(--accent-soft); color: var(--accent-text); }
.mv-ic.t-expense { background: var(--danger-soft); color: var(--danger); }
.mv-ic.t-pay { background: var(--info-soft); color: var(--info); }
.line-sum.t-income { color: var(--ok); }
.line-sum.t-extra { color: var(--accent-text); }
.line .mv-rc { width: 15px; height: 15px; margin: 0; vertical-align: -2px; color: var(--ink-3); }

.tm-rest { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.tm-rest small { font-size: 12px; color: var(--ink-3); }
.tm-rest b { font-size: 16px; font-weight: 600; }
.tm-rest.ok b { color: var(--ok); }
.tm-given { margin: -4px 0 0; }
.tm-hint { margin-top: -8px; }

.stepper { display: flex; gap: 8px; }
.stepper input { flex: 1; min-width: 0; text-align: center; font-size: 19px; font-weight: 600; }
.stepper .btn { font-size: 22px; font-weight: 500; }
.le .seg { display: flex; }
.le .seg button { flex: 1; padding: 0 6px; white-space: nowrap; }
@media (max-width: 419.98px) { .le .seg button { font-size: 14px; } }

.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.ph { aspect-ratio: 1; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--surface-3); }
.ph img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ph-grid .ph-empty { grid-column: 1 / -1; padding: 8px 0; }
.ph-add.busy, .rc-add.busy { pointer-events: none; opacity: 0.6; }
.ph-view { display: flex; flex-direction: column; gap: 16px; }
.ph-view img { display: block; width: 100%; max-height: 62dvh; object-fit: contain; border-radius: 12px; background: var(--surface-3); }

.rc { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rc-thumb { width: 72px; height: 72px; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-3); }
.rc-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ============ Чек: чтение ИИ ============ */
.rc-hint { flex-basis: 100%; }
.ai-box { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: 15px; }
.ai-box p { margin: 0; }
.ai-busy { flex-direction: row; align-items: center; gap: 10px; color: var(--accent-text); }
.ai-err { background: var(--surface-2); color: var(--ink-2); }
.ai-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-head .ic { width: 18px; height: 18px; color: var(--accent-text); }
.ai-head span { color: var(--ink-2); }
.ai-head span::before { content: '·'; margin-right: 6px; }
.ai-items { width: 100%; }
.ai-items summary { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; list-style: none; color: var(--accent-text); font-weight: 600; }
.ai-items summary::-webkit-details-marker { display: none; }
.ai-items summary .ic { width: 16px; height: 16px; transition: transform 0.2s; }
.ai-items[open] summary .ic { transform: rotate(180deg); }
.ai-items ul { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ai-items li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 6px; }
.ai-items li span:last-child { white-space: nowrap; color: var(--ink-2); }
.ai-note { font-size: 14px; color: var(--ink-2); }
.ai-warn { font-size: 14px; font-weight: 600; color: var(--danger); }

/* ============ Итоги объекта ============ */
.ob-res .card-head { align-items: center; }
.ob-res .card-head .link-btn .ic { width: 16px; height: 16px; }
.res-main { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0 0; }
.res-main strong, .rp-profit { font-size: clamp(24px, 7vw, 30px); font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.res-main span { color: var(--ink-2); }
.res-days { margin: 6px 0 0; font-size: 15px; }
.pos { color: var(--ok); }
.neg, .tm-rest.neg b { color: var(--danger); }

.rp-hero p { margin: 0; }
.rp-hero { display: flex; flex-direction: column; gap: 6px; }
.rp-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--ink-2); margin-bottom: 8px !important; }
.rp-label { font-size: 15px; color: var(--ink-2); }
.rp-meta { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.rp-sec .card-title { margin-bottom: 4px; }
.trow.rp-total { font-weight: 700; }
.trow.rp-total > span:first-child { color: var(--ink); }
.rp-person { padding: 10px 0; align-items: flex-start; }
.rp-person > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rp-person > .trow-val { align-items: flex-end; }
.rp-person small { font-size: 13px; font-weight: 400; color: var(--ink-3); white-space: normal; }
.rp-note { margin: 10px 0 0; }

.rz-years { margin-bottom: 14px; }
.rz-person { display: flex; flex-direction: column; gap: 12px; }
.rz-person .lines { margin: 0 -18px; }
.rz-person .line { padding-left: 18px; padding-right: 18px; }
@media (max-width: 350px) { .rz-person .lines { margin: 0 -14px; } .rz-person .line { padding-left: 14px; padding-right: 14px; } }
a.line { color: inherit; }

/* Печать отчёта: светлые цвета при любой теме */
#print-stage .rp-print {
  --ink: #1d2226; --ink-2: #3c444a; --ink-3: #6b767c; --line: #d9dfde; --surface: #fff; --surface-2: #f3f5f4;
  --ok: #1e7f4e; --danger: #c8402f; --info: #2f6a9e; --info-soft: #e8f0f7; --ok-soft: #e4f4ea; --accent-soft: #e3f1ef; --accent-text: #006d68;
  padding: 14mm 16mm; color: var(--ink); background: #fff; font: 400 11pt/1.4 var(--font);
}
#print-stage .rp-print .card { border: 0; box-shadow: none; padding: 0; margin: 0 0 7mm; background: none; break-inside: avoid; }
#print-stage .rp-print .trow { min-height: 0; padding: 2.2mm 0; }
#print-stage .rp-print .card-title { font-size: 13pt; margin: 0 0 2mm; }
.rp-head { display: flex; flex-direction: column; gap: 1mm; margin-bottom: 8mm; padding-bottom: 4mm; border-bottom: 2px solid var(--ink); }
.rp-head b { font-size: 12pt; }
.rp-head span { color: var(--ink-3); }
.rp-head h1 { margin: 2mm 0 0; font-size: 18pt; }
