/* Финрасчёт — тёмная тема «Стена» и токены для «Графита». */

@font-face {
  font-family: 'Golos Text';
  src: url('../fonts/golos-cyrillic.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Golos Text';
  src: url('../fonts/golos-latin-ext.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Golos Text';
  src: url('../fonts/golos-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0e0f13;
  --surface: #16181f;
  --surface-2: #1e212a;
  --line: #2a2e39;
  --text: #f2f3f7;
  --text-2: #a3a8b8;
  --text-3: #8a90a3;
  --accent: #5b61f0;
  --accent-ink: #8f94ff;
  --pos: #3dd68c;
  --neg: #ff7a7a;
  --danger-solid: #c43c3c; /* заливка кнопки удаления: белый текст читается во всех темах */
  --star: #f4d35e;
  --accent-on: #fff;
  --accent-press: #4d53dc;
  --accent-soft: rgba(143, 148, 255, 0.12);
  --accent-soft-2: rgba(143, 148, 255, 0.2);
  --accent-line: rgba(143, 148, 255, 0.3);
  --pos-line: rgba(61, 214, 140, 0.35);
  --derived: #e0a43a; /* «подобрано, а не введено» */
  --selection: rgba(143, 148, 255, 0.35);
  --bar-bg: rgba(14, 15, 19, 0.94);
  --bg-clear: rgba(14, 15, 19, 0);
  --toast-action-bg: rgba(14, 15, 19, 0.08);
  --shadow-tile: 0 10px 24px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.4);
  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --seg-purchase: #4c5bd4;
  --seg-sbaFee: #e0a43a;
  --seg-logistics: #2fb3c6;
  --seg-profit1: #3dd68c;
  --seg-vat: #5d6377;
  --seg-customsFee: #b07ce8;
  --seg-lcmMarkup: #f0795a;
  --seg-rtmMarkup: #f4d35e;

  --radius: 14px;
  --gutter: 16px;
  --tabbar-h: 48px;
  --savebar-h: 72px; /* место под круглой кнопкой сохранения */
  /* Под полоской «домой» хватает части отступа: полный (34px) давал пустую полосу под меню */
  --safe-bottom: max(6px, calc(env(safe-area-inset-bottom, 0px) - 14px));
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.4 var(--font);
  font-variant-numeric: tabular-nums;
  caret-color: var(--accent-ink);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--selection); color: var(--text); }

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

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

input, textarea, select, button { font: inherit; color: inherit; }
input, textarea { font-size: 16px; }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }

button, a, [role="button"], summary, .tab {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ——— Меню темы (кнопка в шапке рядом с ★) ——— */

.theme-menu { position: relative; }
.theme-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  min-width: 228px;
  padding: 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
}
.theme-pop button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.theme-pop button span { flex: 1; white-space: nowrap; }
.theme-pop button svg { width: 18px; height: 18px; }
.theme-pop .tick { visibility: hidden; color: var(--accent-ink); }
.theme-pop button[aria-checked="true"] { background: var(--accent-soft); color: var(--text); }
.theme-pop button[aria-checked="true"] .tick { visibility: visible; }
.theme-pop button:active { transform: scale(0.98); }

/* «+ Новый расчёт» — заметная кнопка цвета акцента */
.new-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: 6px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 160ms var(--ease-out);
}
.new-btn svg { width: 24px; height: 24px; stroke-width: 2.4; }
.new-btn:active { transform: scale(0.94); background: var(--accent-press); }

/* Иконки и шкалы метрик есть только в «Графите» */
.m-icon, .meter { display: none; }

/* ——— Каркас ——— */

.view {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 0px) 0 calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}

.view.calc { padding-bottom: calc(var(--tabbar-h) + var(--savebar-h) + var(--safe-bottom) + 24px); }
.view.wall { max-width: 1080px; }

.appbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 10px var(--gutter) 6px;
}
.appbar-text { flex: 1; min-width: 0; }
.appbar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar-status { font-size: 13px; color: var(--text-3); min-height: 18px; }
.appbar-actions { display: flex; align-items: center; gap: 2px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { color: var(--star); }
.icon-btn[aria-pressed="true"] svg { fill: var(--star); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 160ms var(--ease-out), opacity 160ms;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { cursor: default; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-on); min-height: 52px; }
.btn-primary:active:not(:disabled) { background: var(--accent-press); }
.btn-primary:disabled { background: var(--surface-2); color: var(--text-3); }
.btn-quiet { background: var(--surface-2); color: var(--text); }
.btn-quiet:active:not(:disabled) { background: var(--line); }
.btn-danger { color: var(--neg); }
.btn svg { width: 18px; height: 18px; }

/* ——— Обложка: полосы структуры цены ——— */

.cover { display: flex; gap: 2px; overflow: hidden; background: var(--bg); }
.seg { display: block; flex: 1 1 0; min-width: 0; }
.seg-purchase { background: var(--seg-purchase); }
.seg-sbaFee { background: var(--seg-sbaFee); }
.seg-logistics { background: var(--seg-logistics); }
.seg-profit1 { background: var(--seg-profit1); }
.seg-vat { background: var(--seg-vat); }
.seg-customsFee { background: var(--seg-customsFee); }
.seg-lcmMarkup { background: var(--seg-lcmMarkup); }
.seg-rtmMarkup { background: var(--seg-rtmMarkup); }

/* ——— Экран «Расчёт» ——— */

.hero { padding: 6px var(--gutter) 8px; }
.hero-label { margin-top: 14px; font-size: 14px; color: var(--text-2); }
.hero-price {
  display: block;
  margin-top: 2px;
  font-size: clamp(34px, 10.5vw, 44px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  white-space: nowrap;
}
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
}
.chip-label { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-value { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-total {
  grid-column: 1 / -1;
  order: -1;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--pos-line);
}
.chip-total .chip-label { font-size: 14px; }
.chip-total .chip-value { font-size: 20px; font-weight: 700; }
.chip-total .chip-value { color: var(--pos); }
.chip-annual { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.chip-annual .chip-value { color: var(--accent-ink); }
.neg, .chip-total .chip-value.neg, .chip-annual .chip-value.neg { color: var(--neg); }

.price-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--derived);
}
.link-btn {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.row.is-derived .money input { color: var(--derived); }
.row.is-derived .row-hint { color: var(--derived); }

/* .row объявлен ниже и иначе перебивает выравнивание — отсюда прежний сдвиг строки срока */
.row.row-days { flex-direction: column; align-items: stretch; gap: 10px; cursor: default; }
.row-days-main { display: flex; align-items: center; gap: 12px; cursor: text; }
.row-days .money { flex-basis: 40%; }
.day-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.day-chip {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 120ms var(--ease-out);
}
.day-chip:active { transform: scale(0.96); }
.day-chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-on); }
.hero-label.neg { color: var(--neg); }
.price-unit { margin-top: 2px; font-size: 15px; font-weight: 600; color: var(--text-2); }
/* Справка в рублях: коротко крупнее, полностью — мелко; длинные суммы переносятся целиком */
.price-rub { margin-top: 2px; font-size: 13px; color: var(--text-3); }
.price-rub b { font-size: 15px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.price-rub span { white-space: nowrap; }
/* «× N шт. = …» — отдельной строкой на всю ширину, под подписью и полем */
.row:has(> .row-total:not([hidden])) { flex-wrap: wrap; row-gap: 2px; }
.row > .row-total { flex: 1 1 100%; margin-top: -4px; font-size: 13px; font-weight: 600; color: var(--accent-ink); white-space: nowrap; }
.unit-tag { font-size: 12px; font-weight: 500; color: var(--text-3); white-space: nowrap; }

/* ——— Сравнение своей цены с расчётной: боксы «было» сбоку ——— */

.is-up { color: var(--pos); }
.is-down { color: var(--neg); }
.is-flat { color: var(--text-3); }
.chip-delta { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.price-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }
.price-row .hero-price { flex: 0 1 auto; min-width: 0; }
/* Своя цена на телефоне: цена чуть меньше, чтобы бокс «было» встал рядом, а не под ней */
.price-row:has(#was-price:not([hidden])) .hero-price { font-size: clamp(26px, 8.2vw, 44px); }
.was-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  padding: 7px 11px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: right;
  line-height: 1.3;
}
.was-label { font-size: 11px; color: var(--text-3); }
.was-value { font-size: 15px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.was-delta { font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-total { position: relative; align-items: center; justify-content: space-between; }
.chip-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chip-total .was-box { background: var(--surface); }
.was-side { display: none; } /* бокс у инвойса — только на широком экране; на телефоне подпись */
.row.is-manual .money input { color: var(--derived); }
.row-text .link-btn { align-self: flex-start; padding: 2px 0 0; }

.revert-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 100%;
  justify-content: center;
  margin-top: 2px;
  min-height: 40px;
  padding: 0 12px;
  white-space: nowrap;
  border: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out), transform 120ms var(--ease-out);
}
.revert-btn svg { width: 16px; height: 16px; }
.revert-btn:active { transform: scale(0.97); }
.revert-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

.toast { display: flex; align-items: center; gap: 14px; }
#row-target { flex-wrap: wrap; row-gap: 8px; }
.toast-action {
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--toast-action-bg);
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

/* Широкий экран: боксы «было» выносятся вправо от колонки, как на эскизе */
@media (min-width: 1000px) {
  .price-row .was-box, .chip-total .was-box, .row .was-side {
    position: absolute;
    left: calc(100% + 24px);
    top: 50%;
    width: 190px;
    transform: translateY(-50%);
    align-items: flex-start;
    text-align: left;
  }
  .row .was-side { display: flex; }
  .row { position: relative; }
  .calc-form .list { overflow: visible; }
  .calc-form .list > .row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
  .calc-form .list > .row:last-of-type { border-radius: 0 0 var(--radius) var(--radius); }
  .hint-was { display: none; } /* «было» уже в боксе справа */
}

.calc-form { padding: 0 var(--gutter); }
.group { margin-top: 26px; }
.group-title { display: block; margin-bottom: 10px; font-size: 15px; font-weight: 600; color: var(--text-2); }

.list { border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px 16px;
  cursor: text;
  transition: background-color 160ms var(--ease-out);
}
.row + .row { box-shadow: inset 0 1px 0 var(--line); }
.row:focus-within { background: var(--surface-2); }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-label { font-size: 16px; }
.row-hint { font-size: 13px; color: var(--text-3); }
.money { display: flex; align-items: baseline; gap: 4px; flex: 0 1 52%; min-width: 0; }
.money input {
  width: 100%;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  background: transparent;
  text-align: right;
  font-size: 20px;
  font-weight: 600;
  outline: none;
}
.unit { color: var(--text-3); font-size: 17px; }

.row-stack { flex-direction: column; align-items: stretch; gap: 2px; }
.row-stack .row-label { font-size: 13px; color: var(--text-2); }
.row-stack input, .row-stack textarea {
  width: 100%;
  padding: 4px 0;
  border: 0;
  background: transparent;
  outline: none;
  resize: none;
  line-height: 1.4;
}

/* Раскрывающиеся блоки */
.disclosure { border-radius: var(--radius); background: var(--surface); }
.disclosure-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 16px;
  list-style: none;
  cursor: pointer;
}
.disclosure-head::-webkit-details-marker { display: none; }
.disclosure-head .group-title { margin: 0; color: var(--text); font-size: 16px; font-weight: 500; }
.disclosure-summary {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.disclosure.is-changed .disclosure-summary { color: var(--derived); }
.chev { margin-left: auto; color: var(--text-3); transition: transform 200ms var(--ease-out); }
.disclosure-summary + .chev { margin-left: 0; }
.disclosure[open] .chev { transform: rotate(180deg); }

.rates-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px 16px 4px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; color: var(--text-2); line-height: 1.25; min-height: 2.5em; display: flex; align-items: flex-end; }
.field input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  outline: none;
  font-weight: 500;
  transition: border-color 160ms var(--ease-out);
}
.field input:focus { border-color: var(--accent-ink); }
.disclosure .btn-quiet { margin: 14px 16px 16px; width: calc(100% - 32px); }

.breakdown { padding: 0 16px 12px; }
.bd-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.bd-row dt { display: flex; align-items: baseline; gap: 8px; color: var(--text-2); min-width: 0; }
.bd-row dd { white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; transform: translateY(-1px); }
.bd-sub dt, .bd-sub dd { color: var(--text-3); }
.bd-total { box-shadow: inset 0 1px 0 var(--line); font-weight: 600; }
.bd-total dt { color: var(--text); }
.bd-grand { box-shadow: inset 0 1px 0 var(--line); font-size: 17px; font-weight: 700; padding-top: 12px; }
.bd-grand dt { color: var(--text); }
.bd-grand dd { color: var(--pos); }
.bd-grand dd.neg { color: var(--neg); }
.bd-head { margin-top: 14px; padding-top: 14px; box-shadow: inset 0 1px 0 var(--line); }
.bd-head dt { color: var(--text); font-size: 15px; font-weight: 600; }

.saved-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }

/* Круглая кнопка сохранения справа внизу: экран под ней не перекрыт полосой */
.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  pointer-events: none;
}
.save-fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-on);
  box-shadow: 0 6px 18px rgb(0 0 0 / 35%), 0 1px 3px rgb(0 0 0 / 25%);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms var(--ease-out), opacity 160ms;
}
.save-fab svg { width: 24px; height: 24px; stroke-width: 2; }
.save-fab:active { transform: scale(0.92); background: var(--accent-press); }
.save-fab.is-busy { opacity: 0.6; }
.save-fab.is-busy svg { animation: pulse 900ms ease-in-out infinite; }
.save-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--star);
  box-shadow: 0 0 0 2px var(--bg);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.save-fab.has-changes .save-dot { opacity: 1; transform: none; }
/* Сменили Клиента или заметку — кнопка с подписью: сохранится новым расчётом */
.save-label { display: none; }
.save-fab.is-copy { display: flex; align-items: center; gap: 8px; width: auto; padding: 0 20px 0 16px; border-radius: 28px; }
.save-fab.is-copy .save-dot { display: none; }
.save-fab.is-copy .save-label { display: inline; font-size: 15px; font-weight: 600; white-space: nowrap; }
.field-hint { font-size: 12px; color: var(--text-3); line-height: 1.3; }
#markup2-actual { color: var(--accent-ink); font-weight: 500; }
/* Под ставкой инвойса — к какой цене она приводит (меняется сразу при вводе) */
.field-effect { display: grid; gap: 1px; line-height: 1.3; }
.fe-price { font-size: 13px; font-weight: 600; color: var(--accent-ink); }
.fe-sub, .fe-off { font-size: 12px; color: var(--text-3); }

/* ——— Нижняя навигация ——— */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 0 var(--gutter) var(--safe-bottom);
  background: var(--bar-bg);
  box-shadow: 0 -1px 0 var(--line);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.tab {
  display: flex;
  flex: 0 1 220px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  margin-top: 6px;
  border-radius: 10px;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.tab svg { width: 20px; height: 20px; transition: transform 120ms var(--ease-out); }
.tab:active svg { transform: scale(0.92); }
.tab[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }

/* ——— Экран «Сохранённые» ——— */

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px var(--gutter) 6px;
  padding: 0 14px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-3);
}
.search:focus-within { box-shadow: inset 0 0 0 1px var(--accent-ink); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; color: var(--text); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); }

/* Фильтр «Все / Избранное» и кнопка «Выбрать» */
.wall-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px var(--gutter) 0; }
.wall-tools .select-btn { margin-left: auto; }
/* Фильтр по менеджеру: нативный select под видом кнопки */
.manager-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  height: 42px;
  border-radius: 10px;
  background: var(--track, var(--surface));
  border: 1px solid var(--line);
  color: var(--text-3);
}
.manager-filter svg { position: absolute; width: 16px; height: 16px; pointer-events: none; }
.manager-filter svg:first-child { left: 11px; }
.manager-filter .chev { right: 9px; }
.manager-filter select {
  min-width: 0;
  max-width: 220px;
  height: 100%;
  padding: 0 30px 0 34px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  appearance: none;
  cursor: pointer;
}
.manager-filter:focus-within { box-shadow: inset 0 0 0 1px var(--accent-ink); }
.manager-filter select option { color: initial; }
.select-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.select-btn svg { width: 16px; height: 16px; stroke-width: 2.4; }
.wall-filter {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--track, var(--surface));
  border: 1px solid var(--line);
}
.wall-filter button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.wall-filter button svg { width: 15px; height: 15px; }
.wall-filter b { font-weight: 600; color: var(--text-3); }
.wall-filter button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow, none); }
.wall-filter button[aria-pressed="true"] b { color: var(--accent-ink); }
:root[data-theme="graphite-light"] .wall-filter button[aria-pressed="true"] { background: #fff; }

/* Группы по Клиентам: шапка сворачивает список */
.wall-groups { display: grid; gap: 14px; padding-top: 10px; }
.cg-head { display: flex; align-items: center; gap: 8px; padding: 0 var(--gutter); }
.cg-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.cg-chev { width: 18px; height: 18px; color: var(--text-3); transition: transform 160ms var(--ease-out); }
.cg-toggle[aria-expanded="false"] .cg-chev { transform: rotate(-90deg); }
.cg-name { min-width: 0; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cg-count { flex-shrink: 0; font-size: 13px; font-weight: 600; color: var(--text-3); }
.cg-select {
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Список расчётов: компактные карточки без графиков */
.calc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 10px;
  padding: 4px var(--gutter) 0;
}
.calc-card {
  position: relative;
  min-width: 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), opacity 160ms;
}
/* Сама карточка — ссылка, а в режиме выбора — кнопка-отметка */
.cc-main {
  display: grid;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease-out);
}
.cc-main:active { background: var(--surface-2); }
.cc-head { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
/* Место справа под ★ и 🗑 (или под кружок выбора) */
.calc-card:has(.cc-actions) .cc-head { padding-right: 38px; }
.calc-card:has(.cc-del) .cc-head { padding-right: 78px; }
.calc-card:has(.cc-check) .cc-head { padding-right: 34px; }
.cc-star { width: 18px; height: 18px; flex-shrink: 0; fill: var(--star); stroke: var(--star); }
.cc-note {
  display: -webkit-box;
  flex: 1;
  min-width: 0;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.cc-note.is-empty { color: var(--text-3); font-weight: 500; font-style: italic; }
.cc-actions { position: absolute; top: 4px; right: 4px; display: flex; }
.cc-fav, .cc-del {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}
.cc-fav svg, .cc-del svg { width: 18px; height: 18px; }
.cc-fav svg { transition: transform 160ms var(--ease-out); }
.cc-fav[aria-pressed="true"] svg { fill: var(--star); stroke: var(--star); }
.cc-fav:active svg { transform: scale(0.85); }
.cc-del:active { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.cc-check {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--text-3);
  border-radius: 50%;
  color: transparent;
}
.cc-check svg { width: 14px; height: 14px; stroke-width: 3; }
.calc-card.is-selected { border-color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-ink); }
.calc-card.is-selected .cc-check { background: var(--accent); border-color: var(--accent); color: var(--accent-on); }
.calc-card.is-locked { opacity: 0.45; }
.calc-card.is-locked .cc-main { cursor: default; }
.calc-card.is-locked .cc-main:active { background: transparent; }
.cc-figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 2px;
  padding-top: 8px;
  box-shadow: inset 0 1px 0 var(--line);
}
.cc-fig { display: grid; gap: 1px; min-width: 0; }
.cc-k { font-size: 12px; color: var(--text-3); }
.cc-v { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.cc-v.pos { color: var(--pos); }
.cc-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.cc-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.cc-pill {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.cc-pill-accent { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent-line); }
.cc-pill-derived { color: var(--derived); }
.cc-meta { display: grid; gap: 1px; margin-left: auto; font-size: 12px; color: var(--text-3); text-align: right; white-space: nowrap; }
.cc-edited { opacity: 0.8; }
.calc-card.is-skeleton { height: 140px; animation: pulse 1.4s ease-in-out infinite; }

/* Режим выбора: панель «Отмена · Выбрано N · Удалить» над нижней навигацией */
.selectbar {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 10px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 528px;
  margin: 0 auto;
  padding: 8px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
}
.selectbar .btn { min-height: 44px; padding: 0 14px; }
.select-count { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; text-align: center; color: var(--text-2); }
.btn-delete { background: var(--danger-solid); color: #fff; }
.btn-delete:disabled { background: var(--surface-2); color: var(--text-3); }
body.is-selecting .view.wall { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 96px); }

/* Обязательные поля «Для кого» */
.req { font-size: 11px; font-weight: 500; color: var(--text-3); }
.row.is-invalid { background: color-mix(in srgb, var(--neg) 12%, var(--surface)); }
.row.is-invalid .req { color: var(--neg); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  margin: 40px auto 0;
  padding: 0 var(--gutter);
  text-align: center;
}
.empty-title { font-size: 18px; font-weight: 600; }
.empty-text { color: var(--text-2); font-size: 15px; margin-bottom: 8px; }

/* ——— Вход ——— */

.login { display: grid; place-items: center; min-height: 100dvh; padding: 24px var(--gutter); }
.login-card { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 380px; }
.login-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { margin-top: -10px; color: var(--text-2); font-size: 15px; }
.login .field-label { min-height: 0; }
.form-error { color: var(--neg); font-size: 14px; }

/* ——— Пояснение ⓘ у показателя ——— */

.info-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -8px -6px -8px 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  vertical-align: middle;
  cursor: pointer;
}
.info-btn svg { width: 15px; height: 15px; }
.info-btn[aria-expanded="true"] { color: var(--accent-ink); }
.info-pop {
  position: fixed;
  z-index: 50;
  width: min(300px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
}
.info-title { font-size: 14px; font-weight: 600; color: var(--text); }
.info-text { margin-top: 4px; font-size: 13px; line-height: 1.4; color: var(--text-2); }

/* ——— Уведомление ——— */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--savebar-h) + var(--safe-bottom) + 8px);
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.noscript { padding: 24px; text-align: center; }

/* ——— Наведение только для мыши ——— */

@media (hover: hover) and (pointer: fine) {
  .theme-pop button:hover:not([aria-checked="true"]) { background: var(--surface); color: var(--text); }
  .new-btn:hover, .save-fab:hover { background: var(--accent-press); }
  .info-btn:hover { color: var(--text); }
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .btn-primary:hover:not(:disabled) { background: var(--accent-press); }
  .btn-quiet:hover:not(:disabled) { background: var(--line); }
  .tab:hover { color: var(--text-2); }
  .tab[aria-current="page"]:hover { color: var(--accent-ink); }
  .calc-card:not(.is-locked):hover { background: var(--surface-2); }
  .cc-del:hover { color: var(--neg); }
  .cc-fav:hover { color: var(--star); }
  .select-btn:hover, .cg-select:hover { background: var(--accent-soft); }
  .cg-toggle:hover .cg-name { color: var(--accent-ink); }
  .btn-delete:hover:not(:disabled) { filter: brightness(1.08); }
  .wall-filter button:hover:not([aria-pressed="true"]) { color: var(--text); }
  .day-chip:hover:not([aria-pressed="true"]) { background: var(--line); color: var(--text); }
  .link-btn:hover { color: var(--text); }
  .revert-btn:hover { background: var(--accent-soft-2); }
  .disclosure-head:hover .group-title { color: var(--accent-ink); }
}

/* Телефон: тема, ★, ⇪, выход и «+» помещаются рядом с заголовком «Новый расчёт» */
@media (max-width: 430px) {
  .appbar { gap: 4px; }
  .appbar-title { font-size: 20px; }
  .appbar-actions .icon-btn { width: 38px; }
  .new-btn { margin-left: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}
