/* Колорит CRM. Палитра из пользовательского референса:
   чёрный фон, прозрачные строки, графитовые поверхности, синий акцент.
   Компоновка, данные и взаимодействия сохранены. */

/* ---------- tokens (лист accent-ladder) ---------- */
:root {
  color-scheme: dark;
  --ground: #000000;
  --surface: rgba(28, 28, 30, 0.78);
  --raised: rgba(255, 255, 255, 0.09);
  --active: rgba(255, 255, 255, 0.07);
  --border: #29292b;
  --rule: rgba(255, 255, 255, 0.08);
  --control: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --muted: #a6a6ad;
  --faint: #98989f;
  --overlay-surface: rgba(34, 34, 36, 0.90);
  --hover-primary: #3a6bcf;

  --accent: #5288f5;
  --accent-soft: rgba(82, 136, 245, 0.10);
  --accent-track: rgba(82, 136, 245, 0.20);
  --accent-ink: #82acff;

  --primary: #3465c9;
  --primary-ink: #ffffff;

  --positive: #74d7a0;
  --negative: #ff8089;
  --warning: #edc674;

  --pill-positive-bg: rgba(116, 215, 160, 0.12); --pill-positive-ink: #74d7a0;
  --pill-negative-bg: rgba(255, 128, 137, 0.12); --pill-negative-ink: #ff949c;
  --pill-warning-bg: rgba(237, 198, 116, 0.12); --pill-warning-ink: #edc674;
  --pill-neutral-bg: rgba(255, 255, 255, 0.08); --pill-neutral-ink: #c7c7cc;
  --pill-accent-bg: rgba(82, 136, 245, 0.15); --pill-accent-ink: #82acff;

  --chart-1: var(--accent);

  --font: "Golos Text", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-title: 24px; --fs-section: 16px; --fs-kpi: 24px; --fs-body: 14px; --fs-small: 12px;

  --sidebar-width: 230px;
  --pad: 24px;
  --gap: 16px;
  --card-pad: 20px;
  --radius-card: 22px;
  --radius-control: 16px;
  --control-height: 32px;
  --row-height: 45px;
  --nav-row: 32px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms; --t-hover: 150ms; --t-ui: 200ms;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: var(--fs-body)/20px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num, .kpi-value { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100svh; }
.sidebar { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; gap: 2px; padding: 16px 14px; overflow: auto; border-right: 1px solid var(--rule); background: rgba(20, 20, 22, 0.72); }
.sidebar .group-label { margin: 20px 8px 6px; font-size: var(--fs-small); color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 10px; height: var(--nav-row); padding: 0 8px; border-radius: 8px; color: var(--muted); transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.nav-item svg { width: 16px; height: 16px; flex: none; stroke-width: 1.5; }
.nav-item:hover { background: var(--raised); color: var(--text); }
/* accent-ladder: активная строка — бледный тон оттенка с тёмными чернилами того же тона, иконка в полную силу */
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-item[aria-current="page"] svg { color: var(--accent); }
.nav-count { margin-left: auto; display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 500; background: var(--primary); color: var(--primary-ink); }
.sidebar .bottom { margin-top: auto; }
.canvas { min-width: 0; padding: var(--pad); }

/* бренд и быстрые действия вверху меню */
.brand { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 8px 16px; }
.brand-logo { display: block; width: 100%; max-width: 186px; min-width: 0; height: auto; flex: 1 1 0; object-fit: contain; }
.quick-row { display: flex; align-items: center; justify-content: space-around; gap: 12px; padding: 4px 8px; }
.qa { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #d8d8df; cursor: pointer; transition: background-color var(--t-hover) ease, color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.qa svg { width: 21px; height: 21px; stroke-width: 1.6; color: currentColor; }
.qa:hover { background: var(--raised); color: var(--accent-ink); }
.qa:active { transform: translateY(1px); }

.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; border-top: 1px solid var(--rule); margin-top: 12px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-track); color: var(--accent-ink); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.user-name { font-weight: 500; font-size: 13px; }
.user-role { font-size: var(--fs-small); color: var(--faint); }

/* ---------- заголовок экрана ---------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.title-group { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.menu-toggle { margin-top: 4px; }
.title-row h1 { font-size: var(--fs-title); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.title-row .sub { margin-top: 5px; color: var(--muted); }
.title-row .sub b { color: var(--negative); font-weight: 500; }
.title-actions { display: flex; gap: 8px; }

/* ---------- поиск по базе клиентов ---------- */
.client-search { margin-bottom: 20px; min-width: 0; }
.client-search > label { display: block; margin-bottom: 8px; color: var(--muted); font-size: var(--fs-small); }
.client-search-control { display: flex; align-items: center; min-width: 0; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); }
.client-search-control:focus-within { border-color: var(--accent); }
.client-search-control input { flex: 1; min-width: 0; width: 100%; height: 48px; padding: 0 14px; background: transparent; border: 0; border-radius: inherit; font-size: 16px; }
.client-search-control input::placeholder { color: var(--faint); opacity: 1; }
.client-search-control input:focus-visible { outline: none; }
.client-search-control input::-webkit-search-cancel-button { -webkit-appearance: none; }
.client-search-control button { flex: none; min-height: 44px; margin: 2px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--accent-ink); cursor: pointer; font-size: 13px; }
.client-search-control button:hover { background: var(--raised); }
.client-search-results { margin-top: 8px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface); }
.client-search-status { color: var(--muted); font-size: var(--fs-small); }
#clientSearchList { margin: 0; padding: 0; list-style: none; max-height: 360px; overflow-y: auto; overscroll-behavior: contain; }
.client-result { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding: 12px 0 4px; min-width: 0; }
.client-result + .client-result { border-top: 1px solid var(--rule); }
.client-result-info { flex: 1 1 280px; min-width: 0; }
.client-result-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.client-result-deals { display: block; margin-top: 4px; color: var(--muted); font-size: var(--fs-small); overflow-wrap: anywhere; }
.client-result-contacts { display: flex; flex-wrap: wrap; gap: 0 16px; min-width: 0; }
.client-result-contacts a { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; color: var(--accent-ink); font-size: 13px; overflow-wrap: anywhere; }
.client-result-contacts a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- сетка: основная колонка + правая колонка ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 384px; gap: var(--gap); align-items: start; }
.main-col { display: grid; gap: var(--gap); min-width: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); grid-column: 1 / -1; }
.rail { display: grid; gap: 8px; }
.rail-block { display: grid; gap: 8px; min-width: 0; }
.rail-h { font-size: var(--fs-small); color: var(--faint); margin: 8px 0 0; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--card-pad); min-width: 0; }
.panel-list { background: transparent; border-color: transparent; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel h2 { font-size: var(--fs-section); line-height: 1.3; font-weight: 600; }
.panel .meta { color: var(--faint); font-size: var(--fs-small); }
.panel-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 13px; }
.panel-foot .total b { font-weight: 600; white-space: nowrap; }

.card-link { display: inline-flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; color: var(--text); font-weight: 500; font-size: 13px; cursor: pointer; text-underline-offset: 3px; }
.card-link::after { content: ""; width: 12px; height: 12px; flex: none; background: currentColor; -webkit-mask: var(--chevron) center / 12px no-repeat; mask: var(--chevron) center / 12px no-repeat; }
.card-link:hover { text-decoration: underline; }
:root { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.5 2.5 8 6l-3.5 3.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* ---------- задачи: вкладки-даты и строки ---------- */
.tabs { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 22px; background: var(--raised); padding: 5px; margin-bottom: 4px; }
.tabs button.tab { position: relative; padding: 8px 10px; border-radius: 999px; color: var(--muted); font-size: var(--fs-body); border: 0; background: none; cursor: pointer; transition: color var(--t-hover) ease, background-color var(--t-hover) ease; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.tab:hover { color: var(--text); }
.tabs button.tab[aria-selected="true"] { color: var(--text); background: var(--ground); }
.tabs .tab-count { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tabs .tab[aria-selected="true"] .tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-weight: 500; padding: 0 4px; }
.tabs .date-wrap { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; white-space: nowrap; }
.task-date-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 6px 9px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.task-date-toggle:hover, .task-date-toggle[aria-expanded="true"], .task-date-toggle[aria-pressed="true"] { background: var(--ground); color: var(--text); }
.task-date-toggle svg { width: 16px; height: 16px; color: var(--accent); stroke-width: 1.5; flex: none; }
.task-date-chevron { transition: transform var(--t-hover) ease; }
.task-date-toggle[aria-expanded="true"] .task-date-chevron { transform: rotate(180deg); }
.task-calendar[hidden] { display: none; }
.task-calendar { position: fixed; z-index: 30; width: min(344px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 16px; border: 1px solid var(--control); border-radius: 20px; background: rgba(28,28,30,.97); box-shadow: 0 18px 50px rgba(0,0,0,.6); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
.task-calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.task-calendar-heading h3 { font-size: 14px; font-weight: 600; text-transform: capitalize; }
.task-calendar-heading button, .task-calendar-day, .task-calendar-footer button { border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.task-calendar-heading button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; }
.task-calendar-heading svg { width: 18px; height: 18px; stroke-width: 1.5; color: var(--accent); }
.task-calendar-weekdays, .task-calendar-days { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); }
.task-calendar-weekdays { margin-bottom: 6px; color: var(--muted); font-size: 11px; text-align: center; }
.task-calendar-weekdays span { padding-block: 6px; }
.task-calendar-day { position: relative; display: flex; align-items: center; justify-content: center; height: 44px; border-radius: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.task-calendar-day[aria-current="date"] { color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.task-calendar-day[aria-pressed="true"] { background: var(--accent-track); box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }
.task-calendar-heading button:hover, .task-calendar-day:hover, .task-calendar-footer button:hover { background: var(--raised); }
.task-calendar-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: none; }
.task-calendar-day .task-calendar-dot { position: absolute; bottom: 5px; left: calc(50% - 2.5px); }
.task-calendar-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--rule); margin-top: 10px; padding-top: 8px; font-size: 11px; color: var(--muted); }
.task-calendar-footer > span { display: inline-flex; align-items: center; gap: 7px; }
.task-calendar-footer button { min-height: 44px; border-radius: 10px; padding: 6px 8px; color: var(--accent-ink); font-size: 11px; }
@media (max-width: 860px) { .task-date-toggle { min-height: 44px; } }

.task { display: flex; align-items: center; gap: 14px; padding: 11px 0; min-height: 46px; background: transparent; transition: background-color var(--t-hover) ease; }
.task:hover, .inv-row:hover, .pay-row:hover, .advice:hover { background: rgba(255, 255, 255, 0.025); }
.task + .task { border-top: 1px solid var(--rule); }
.t-time { width: 42px; flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.t-body { flex: 1; min-width: 0; }
.t-title { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-deal { display: block; font-size: var(--fs-small); color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-deal a { color: var(--accent-ink); }
.t-deal a:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-small); font-weight: 500; background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); white-space: nowrap; flex: none; }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.pill.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.pos { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.t-done { flex: none; height: 26px; padding: 0 10px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); font-size: var(--fs-small); font-weight: 500; color: var(--muted); cursor: pointer; transition: background-color var(--t-hover) ease, color var(--t-hover) ease; }
.t-done:hover { background: var(--raised); color: var(--text); }
.task.done .t-title { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.task.done .t-done { color: var(--positive); border-color: var(--pill-positive-bg); background: var(--pill-positive-bg); }

.empty { display: grid; place-items: center; min-height: 96px; padding: 16px; border: 1px dashed var(--control); border-radius: var(--radius-control); color: var(--muted); text-align: center; font-size: 13px; }

/* ---------- счета и поступления ---------- */
.inv-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.inv-row + .inv-row { border-top: 1px solid var(--rule); }
.inv-body { flex: 1; min-width: 0; }
.inv-no { display: block; font-weight: 500; }
.inv-no .inv-client { font-weight: 400; color: var(--muted); }
.inv-sub { display: block; font-size: var(--fs-small); color: var(--muted); margin-top: 2px; }
.inv-sum { flex: none; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.inv-sum .pill { margin-top: 4px; }

.pay-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.pay-row + .pay-row { border-top: 1px solid var(--rule); }
.pay-body { flex: 1; min-width: 0; }
.pay-client { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-sub { display: block; font-size: var(--fs-small); color: var(--muted); margin-top: 2px; }
.pay-sum { flex: none; font-variant-numeric: tabular-nums; font-weight: 500; }
.pay-sum .plus { color: var(--positive); }
.pay-row.is-fresh { background: rgba(110, 215, 183, 0.08); border-radius: 8px; }
.pay-row.is-fresh .pay-client, .pay-row.is-fresh .pay-sum { color: var(--positive); }
.pay-fresh-label { font-size: 11px; color: var(--positive); }
.sync-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--accent-ink); font-size: 13px; }
.sync-notice[hidden] { display: none; }
.sync-notice > span { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }

/* ---------- карточка плана продаж (бледный тон оттенка) ---------- */
.plan-card { background: var(--surface); border-color: var(--border); }
.plan-card .plan-label { font-size: var(--fs-small); color: var(--accent-ink); }
.plan-card .plan-value { font-size: var(--fs-kpi); font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; }
.plan-track { position: relative; height: 8px; border-radius: 999px; background: var(--raised); border: 1px solid var(--border); margin: 14px 0 8px; overflow: hidden; }
.plan-track .fill { position: absolute; inset: -1px auto -1px 0; border-radius: 999px; background: var(--accent); }
.plan-track .forecast-fill { position: absolute; top: -1px; bottom: -1px; border-radius: 0 999px 999px 0; background: rgba(82,136,245,.32); }
.plan-scale { display: flex; justify-content: space-between; font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-forecast { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.plan-forecast-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.plan-forecast-row > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.plan-forecast-row strong { color: var(--accent-ink); font-weight: 500; }
.plan-forecast-label::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 2px; background: rgba(82,136,245,.32); border: 1px solid rgba(82,136,245,.35); }
.plan-forecast-hint { margin: 9px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.plan-note { margin-top: 12px; font-size: 13px; color: var(--muted); }
.plan-note b { color: var(--positive); font-weight: 500; }

/* ---------- советы ассистента ---------- */
.advice { display: flex; gap: 10px; padding: 11px 0; }
.advice + .advice { border-top: 1px solid var(--rule); }
.advice-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }
.advice-body { flex: 1; min-width: 0; font-size: 13px; line-height: 18px; }
.advice-body .card-link { margin-top: 6px; font-size: var(--fs-small); color: var(--accent-ink); }
.advice.applied .advice-body { color: var(--muted); }
.advice.applied .advice-body .card-link { visibility: hidden; }
.advice.applied .advice-dot { background: var(--pill-positive-bg); }

/* ---------- кнопки и формы ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-height); padding: 0 12px; border-radius: var(--radius-control); border: 1px solid var(--control); background: var(--surface); font-weight: 500; cursor: pointer; transition: background-color var(--t-hover) ease, transform var(--t-press) var(--ease-out); }
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover { background: var(--hover-primary); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 15px; height: 15px; stroke-width: 1.5; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 500; }
.input, select.input { height: 36px; padding: 0 10px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); width: 100%; min-width: 0; max-width: 100%; }
.input:is([type="date"], [type="time"], [type="datetime-local"], [type="month"]) { display: block; min-inline-size: 0; max-inline-size: 100%; color-scheme: dark; }
.input::-webkit-datetime-edit { min-width: 0; }
.input::placeholder { color: var(--faint); }

/* ---------- всплывающее меню быстрых действий ---------- */
.pop { position: fixed; z-index: 30; width: min(360px, calc(100vw - 24px)); max-height: min(600px, calc(100dvh - 140px)); background: var(--overlay-surface); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); padding: 12px; display: none; }
.pop.open { display: flex; flex-direction: column; }
.pop-heading { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex: none; }
.pop-heading h2 { font-size: 14px; font-weight: 600; }
.pop-heading .icon-close { width: 44px; height: 44px; }
.qa-search { flex: none; margin-top: 8px; }
.qa-search label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.qa-search .input { height: 44px; font-size: 16px; }
.qa-status, .qa-hint { color: var(--muted); font-size: 12px; line-height: 18px; flex: none; }
.qa-status { margin: 10px 0; }
.qa-hint { padding-top: 10px; border-top: 1px solid var(--rule); }
.qa-results { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.pi-contact { display: block; color: var(--accent-ink); font-size: 12px; margin-top: 3px; }
.pop-head { padding: 8px 10px 6px; font-size: var(--fs-small); color: var(--faint); }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-control); background: none; text-align: left; cursor: pointer; }
.pop-item:hover { background: var(--raised); }
.pop-item .pi-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pop-item .pi-name { display: block; font-weight: 500; font-size: 13px; }
.pop-item .pi-sub { display: block; font-size: var(--fs-small); color: var(--muted); }
.pop-item svg { width: 15px; height: 15px; stroke-width: 1.5; color: var(--muted); flex: none; }

/* ---------- модальные окна (тень только у плавающего) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.60); display: none; place-items: center; padding: 16px; z-index: 40; }
.overlay.open { display: grid; }
.modal { width: min(440px, 100%); min-width: 0; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; background: var(--overlay-surface); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.40); padding: var(--card-pad); }
.modal h3 { font-size: var(--fs-section); font-weight: 600; margin-bottom: 14px; }
.modal form { display: grid; gap: 14px; }
.modal .modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.calc-total { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 12px 14px; background: var(--accent-soft); border-radius: var(--radius-control); }
.calc-total .ct-label { font-size: 13px; color: var(--accent-ink); }
.calc-total .ct-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.calc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.calc-grid > *, .form-grid > * { min-width: 0; }
.calc-product-select { position: relative; min-width: 0; }
.calc-product-trigger { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.calc-product-trigger:focus-visible { border-radius: var(--radius-control); }
.calc-product-trigger::after { content: ""; width: 14px; height: 14px; flex: none; background: var(--muted); -webkit-mask: var(--chevron) center / 14px no-repeat; mask: var(--chevron) center / 14px no-repeat; transform: rotate(90deg); }
.calc-product-trigger[aria-expanded="true"] { border-color: var(--accent); }
.calc-product-trigger[aria-expanded="true"]::after { transform: rotate(-90deg); }
.calc-product-list { position: absolute; z-index: 5; top: calc(100% + 8px); left: 0; right: 0; padding: 6px; background: rgba(20, 20, 22, 0.98); color: var(--text); border: 1px solid var(--control); border-radius: var(--radius-control); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.calc-product-option { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; text-align: left; cursor: pointer; }
.calc-product-option:hover, .calc-product-option[data-active="true"] { background: var(--raised); color: var(--text); }
.calc-product-option[aria-selected="true"] { color: var(--text); }
.calc-product-option[aria-selected="true"]::after { content: ""; flex: none; width: 6px; height: 10px; margin: 0 4px 3px 0; border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* ---------- уведомление ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 8px); background: var(--overlay-surface); color: var(--text); border: 1px solid var(--border); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border-radius: 999px; padding: 9px 16px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity var(--t-ui) ease, transform var(--t-ui) var(--ease-out); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- телефон: меню выкатывается с левого края, ширина — четверть окна ---------- */
.menu-toggle { display: none; }
.drawer-close { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.48); z-index: 19; opacity: 0; pointer-events: none; visibility: hidden; transition: opacity var(--t-ui) ease, visibility 0s var(--t-ui); }
.scrim.open { opacity: 1; pointer-events: auto; visibility: visible; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { display: contents; }
  .main-col { order: -1; }
  .advice-block { order: 0; }
  .plan-block, .cash-block { order: 1; }
  .pair { order: 2; }
  .rail { grid-template-columns: 1fr 1fr; gap: var(--gap); }
  .rail-h { grid-column: 1 / -1; margin-top: 16px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  /* выкатная панель: узкая, с правой границей и тенью плавающего слоя */
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; height: 100%; width: clamp(232px, 25vw, 320px); z-index: 20; background: var(--overlay-surface); -webkit-backdrop-filter: blur(28px); backdrop-filter: blur(28px); transform: translateX(-100%); transition: transform var(--t-ui) var(--ease-out); border-right: 1px solid var(--border); box-shadow: 8px 0 24px rgba(0, 0, 0, 0.40); }
  .sidebar.open { transform: none; }
  .brand { padding-right: 4px; }
  .drawer-close { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); color: var(--muted); cursor: pointer; flex: none; }
  .drawer-close:hover { background: var(--raised); color: var(--text); }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface); cursor: pointer; flex: none; }
  .canvas { padding: 16px; }
  .title-row { flex-wrap: wrap; align-items: flex-start; }
  .title-actions { width: 100%; }
  .title-actions .btn { flex: 1; }
  .pair { grid-template-columns: 1fr; }
  .rail { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs .date-wrap { margin-left: 0; padding-bottom: 12px; }
}
/* строки задач на телефоне: заголовок и сделка получают ширину и переносятся, тип уходит второй строкой */
@media (max-width: 640px) {
  .tabs button.tab { padding: 8px 6px; font-size: 13px; gap: 4px; }
  .task { flex-wrap: wrap; align-items: flex-start; gap: 3px 10px; }
  .t-time { margin-top: 2px; }
  .t-body { flex: 1 1 calc(100% - 90px); }
  .t-title, .t-deal { white-space: normal; overflow: visible; }
  .t-done { order: 5; margin-left: auto; }
  .task .pill { order: 4; margin-left: 52px; }
  .pay-client { white-space: normal; overflow: visible; }
  .tabs { flex-wrap: wrap; overflow: visible; }
  .tabs .date-wrap { flex-basis: 100%; margin: 0; padding: 8px 8px 5px; }
  .inv-row, .pay-row { flex-wrap: wrap; }
  .inv-sum, .pay-sum { margin-left: auto; }
}
@media (max-width: 600px) {
  .calc-grid { grid-template-columns: minmax(0, 1fr); }
  .title-actions .btn { height: auto; min-height: 44px; padding-block: 8px; }
  .title-actions .btn svg { flex-shrink: 0; }
  .modal-actions > .btn { height: auto; min-height: var(--control-height); max-width: 100%; padding-block: 8px; white-space: normal; }
  .input:is([type="date"], [type="time"], [type="datetime-local"], [type="month"]) { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; } }
/* Рабочий стол: задачи по дням, открытие задачи по клику */
.tabs { flex-wrap: wrap; row-gap: 4px; overflow: visible; }
.tabs button.tab { white-space: nowrap; }
.task { padding: 0; }
.t-open { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 46px; padding: 11px 6px 11px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 10px; }
.t-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.t-chevron { width: 16px; height: 16px; flex: none; color: var(--faint); }
.task.done .t-title { color: var(--muted); text-decoration: line-through; }
.task-view-facts { display: grid; gap: 10px; margin: 14px 0; }
.task-view-facts > div { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 12px; }
.task-view-facts dt { color: var(--muted); }
.task-view-facts dd { margin: 0; overflow-wrap: anywhere; }
.task-view-note { color: var(--faint); font-size: var(--fs-small); margin: 0 0 8px; }
@media (max-width: 640px) {
  .t-open { flex-wrap: wrap; align-items: flex-start; gap: 3px 10px; }
  .t-open .pill { order: 4; margin-left: 52px; }
  .t-chevron { position: absolute; right: 2px; top: 14px; }
  .task { position: relative; }
  .t-open { padding-right: 22px; }
}
.tabs { flex-wrap: nowrap; }
.tab-days { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; }
.tabs .date-wrap { flex: none; }
@media (max-width: 640px) {
  .tabs { flex-wrap: wrap; }
  .tab-days { flex-basis: 100%; }
}
