/* СураВеб — интерфейс кабинета и панели (и экран ноутбука на главной).
   Светлая тема по умолчанию, тёмная — по системной настройке. Без градиентов и теней-«облаков». */

@font-face {
  font-family: "Golos";
  src: url("../fonts/golos-cyrillic.2b8fbbb33a14.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos";
  src: url("../fonts/golos-latin.f57df9832ab8.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root, .theme-light {
  --font: "Golos", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #ffffff;
  --bg-side: #f2f2f2;
  --bg-card: #f6f6f6;
  --bg-hover: #ececec;
  --bg-pill: #e8e8e8;
  --bg-input: #ffffff;
  --line: #e3e3e3;
  --line-strong: #d2d2d2;
  --ink: #000000;
  --on-ink: #ffffff;
  --text: #000000;
  --muted: #6f6f6f;
  --faint: #a0a0a0;
  --green: #2f9e62;
  --amber: #c98a1b;
  --red: #d9483b;
  --blue: #3b7be0;
  --violet: #7a5af0;
  --note: #fbf6e6;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --r-xl: 28px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--blue) 45%, transparent);
  color-scheme: light;
}

.theme-light { color: var(--text); }

.theme-dark,
.theme-auto-dark {
  --bg: #2b2b2b;
  --bg-side: #262626;
  --bg-card: #333333;
  --bg-hover: #3b3b3b;
  --bg-pill: #3e3e3e;
  --bg-input: #2f2f2f;
  --line: #3e3e3e;
  --line-strong: #4c4c4c;
  --ink: #ffffff;
  --on-ink: #000000;
  --text: #ffffff;
  --muted: #a6a6a6;
  --faint: #7c7c7c;
  --note: #3a3527;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  .theme-auto {
    --bg: #1f1f1f;
    --bg-side: #262626;
    --bg-card: #2a2a2a;
    --bg-hover: #333333;
    --bg-pill: #383838;
    --bg-input: #242424;
    --line: #363636;
    --line-strong: #474747;
    --ink: #ffffff;
    --on-ink: #000000;
    --text: #f2f2f2;
    --muted: #a3a3a3;
    --faint: #777777;
    --note: #35301f;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern", "liga";
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: 28px; letter-spacing: -0.025em; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.i { display: inline-block; vertical-align: -0.2em; width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-s { width: 14px; height: 14px; }
.i-l { width: 22px; height: 22px; }

/* --- Кнопки ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  background: var(--bg-pill); color: var(--text); font: inherit; font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s, transform .1s;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 84%, var(--bg)); }
.btn-outline { background: transparent; border-color: var(--line-strong); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-danger { color: var(--red); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 17px; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

/* --- Формы ------------------------------------------------------------------------ */
input:where(:not([type=checkbox], [type=radio], [type=hidden], [type=file], [type=range])),
select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: var(--r-s);
  border: 1px solid var(--line-strong); background: var(--bg-input); color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.4; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 96px; }
textarea.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 13px; line-height: 1.55; }
select { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type=file] { font: inherit; font-size: 14px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; border: 0; border-radius: 999px; background: var(--bg-pill); color: var(--text); padding: 8px 14px; margin-right: 10px; cursor: pointer; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field-label { font-size: 14px; font-weight: 600; }
.field .help { font-size: 13px; color: var(--muted); }
.field .errors, .form-errors { color: var(--red); font-size: 14px; margin: 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.form-errors { background: color-mix(in srgb, var(--red) 10%, transparent); padding: 10px 14px; border-radius: var(--r-s); margin-bottom: 16px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.fields-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }

.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.45; cursor: pointer; margin-bottom: 12px; }
.check input { appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0; border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--bg-input); cursor: pointer; display: grid; place-content: center; }
.check input::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { opacity: 1; }
.check a { text-decoration: underline; }

/* Переключатель как в системных настройках */
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { appearance: none; width: 52px; height: 30px; border-radius: 999px; background: var(--bg-pill); border: 1.5px solid var(--line-strong); cursor: pointer; transition: background-color .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--line-strong); transition: transform .2s; }
.switch input:checked { background: var(--ink); border-color: var(--ink); }
.switch input:checked::after { transform: translateX(22px); border-color: var(--ink); }

.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.radio-card { position: relative; display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--r-m); border: 1.5px solid var(--line); background: var(--bg-card); cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card strong { font-size: 15px; }
.radio-card span { font-size: 13px; color: var(--muted); }
.radio-card:has(input:checked) { border-color: var(--ink); background: var(--bg); }
.radio-card:has(input:focus-visible) { box-shadow: var(--focus); }
.segmented-input { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--bg-pill); gap: 2px; flex-wrap: wrap; }
.segmented-input label { position: relative; padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted); }
.segmented-input input { position: absolute; opacity: 0; }
.segmented-input label:has(input:checked) { background: var(--bg); color: var(--text); }

/* --- Каркас приложения ------------------------------------------------------------ */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; background: var(--bg-side); }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  padding: 18px 14px 14px; background: var(--bg-side); border-right: 1px solid var(--line);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; text-decoration: none; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.side-brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0; }
.logo { width: 32px; height: 32px; flex: none; }
.side-search { position: relative; margin-bottom: 10px; }
.side-search input { min-height: 36px !important; padding: 6px 12px 6px 34px !important; border-radius: var(--r-s) !important; background: var(--bg-pill) !important; border-color: transparent !important; font-size: 14px !important; }
.side-search .i { position: absolute; left: 11px; top: 9px; color: var(--muted); }
.nav-label { padding: 14px 10px 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 12px;
  text-decoration: none; font-size: 15px; font-weight: 500; color: var(--text); min-height: 40px;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.is-active { background: var(--ink); color: var(--on-ink); font-weight: 700; }
.nav-item.is-active .ibadge { background: var(--on-ink); color: var(--ink); }
.nav-item .count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.nav-item.is-active .count { background: var(--on-ink); color: var(--ink); }
.ibadge { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--ink); color: var(--on-ink); }
.ibadge .i { width: 15px; height: 15px; stroke-width: 2.2; }
.side-foot { margin-top: auto; padding-top: 14px; }
.status-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-m); background: var(--bg); border: 1px solid var(--line); }
.status-card b { display: block; font-size: 14px; }
.status-card small { display: block; font-size: 12px; color: var(--muted); }
.status-card form { margin-left: auto; }

.main { padding: 28px clamp(16px, 3vw, 40px) 64px; min-width: 0; background: var(--bg); }
.main-narrow > * { max-width: 980px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--text); }

/* --- Карточки и строки ------------------------------------------------------------- */
.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px; }
.card + .card, .card + .section-title, .rows + .section-title { margin-top: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 17px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 22px 4px 8px; }
.note-line { font-size: 13px; color: var(--muted); margin: 8px 4px 0; }

.hero-card { display: flex; align-items: center; gap: 20px; padding: 22px 24px; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-l); flex-wrap: wrap; }
.hero-card h1 { margin: 0 0 6px; font-size: 26px; }
.hero-card .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.dots-avatar { width: 68px; height: 68px; flex: none; color: var(--text); }

.rows { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; min-height: 56px; text-decoration: none; color: inherit; }
.row + .row { border-top: 1px solid var(--line); }
a.row:hover, button.row:hover { background: var(--bg-hover); }
.row .label { font-weight: 600; font-size: 15px; min-width: 0; }
.row .label small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 1px; }
.row .value { margin-left: auto; color: var(--muted); font-size: 15px; text-align: right; overflow-wrap: anywhere; }
.row .value strong { color: var(--text); }
.row .chev { color: var(--faint); margin-left: auto; }
.row .value ~ .chev, .row .btn ~ .chev, .row .pill ~ .chev { margin-left: -4px; }
.row .switch, .row .btn { margin-left: auto; }
button.row { width: 100%; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }

/* --- Статусы ------------------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 9px; border-radius: 999px; background: var(--bg-pill); font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill-plain { background: transparent; padding-left: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot-ring { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; }
.dot-ring::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.tone-green .dot, .dot.tone-green { background: var(--green); }
.tone-amber .dot, .dot.tone-amber { background: var(--amber); }
.tone-red .dot, .dot.tone-red { background: var(--red); }
.tone-blue .dot, .dot.tone-blue { background: var(--blue); }
.tone-ink .dot, .dot.tone-ink { background: var(--text); }
.tone-grey .dot, .dot.tone-grey { background: var(--faint); }
.t-green { color: var(--green); } .t-red { color: var(--red); } .t-amber { color: var(--amber); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--bg-pill); font-size: 12px; font-weight: 600; color: var(--muted); }

/* --- Этапы ------------------------------------------------------------------------------ */
.steps { display: grid; grid-template-columns: repeat(var(--n, 9), minmax(0, 1fr)); gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.steps li { display: grid; gap: 8px; font-size: 12px; color: var(--faint); font-weight: 500; min-width: 0; }
.steps li::before { content: ""; height: 6px; border-radius: 999px; background: var(--bg-pill); }
.steps li.done { color: var(--muted); }
.steps li.done::before { background: var(--text); }
.steps li.current { color: var(--text); font-weight: 700; }
.steps li.current::before { background: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 18%, transparent); }
.steps li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-m); background: var(--bg); border: 1px solid var(--line); margin-top: 16px; font-size: 15px; }
.hint .i { margin-top: 2px; color: var(--muted); }

/* --- Сетки ---------------------------------------------------------------------------- */
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack > * + * { margin-top: 20px; }
.stack-s > * + * { margin-top: 10px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* --- Сводка ---------------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { padding: 16px 18px; border-radius: var(--r-l); background: var(--bg-card); border: 1px solid var(--line); text-decoration: none; display: grid; gap: 2px; }
a.kpi:hover { background: var(--bg-hover); }
.kpi b { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 14px; color: var(--muted); }
.meter { height: 8px; border-radius: 999px; background: var(--bg-pill); overflow: hidden; margin: 10px 0 6px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--text); }
.meter.tone-amber i { background: var(--amber); }
.meter.tone-red i { background: var(--red); }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 150px; margin-top: 12px; }
.bars .bar { display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; text-align: center; font-size: 11px; color: var(--muted); }
.bars .bar { position: relative; }
.bars .bar i { align-self: end; display: block; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--text) 22%, transparent); min-height: 2px; }
.bars .bar:hover i { background: color-mix(in srgb, var(--text) 45%, transparent); }
.bars .bar::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); padding: 4px 8px; border-radius: 8px; background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; }
.bars .bar:hover::after, .bars .bar:focus-visible::after { opacity: 1; }
.bars .bar.current i { background: var(--text); }
.bars .bar.current { color: var(--text); font-weight: 700; }

/* --- Таблицы --------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--bg-card); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-hover); }
.table a { text-decoration: none; font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .muted { font-size: 13px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 180px; min-height: 38px; padding: 6px 12px; font-size: 14px; }
.filters select { padding-right: 34px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--bg-pill); font-size: 14px; font-weight: 600; text-decoration: none; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--ink); color: var(--on-ink); }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; font-size: 14px; }

/* --- Канбан -------------------------------------------------------------------------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 236px; gap: 12px; overflow-x: auto; padding-bottom: 14px; align-items: start; min-height: 60vh; }
.col { background: var(--bg-side); border: 1px solid var(--line); border-radius: var(--r-l); padding: 10px; min-height: 120px; }
.col.drop-target { border-color: var(--text); border-style: dashed; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-size: 14px; font-weight: 700; }
.col-head .count { margin-left: auto; color: var(--muted); font-weight: 600; }
.kcard { display: block; padding: 12px 14px; border-radius: var(--r-m); background: var(--bg); border: 1px solid var(--line); text-decoration: none; margin-bottom: 8px; cursor: grab; }
.kcard:hover { border-color: var(--line-strong); }
.kcard.dragging { opacity: .5; }
.kcard b { display: block; font-size: 14px; line-height: 1.3; }
.kcard small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.kcard .meta { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.kcard .meta .badge { margin-left: auto; }
.kcard.prio-high { box-shadow: inset 3px 0 0 var(--red); }

/* --- Переписка ----------------------------------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: 12px; max-height: 620px; overflow-y: auto; padding: 4px 2px 8px; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; max-width: 86%; }
.msg .avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--bg-pill); }
.msg .bubble { padding: 10px 14px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); font-size: 15px; min-width: 0; }
.msg .bubble p:last-child { margin-bottom: 0; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--ink); color: var(--on-ink); border-color: var(--ink); border-bottom-right-radius: 6px; }
.msg.mine .who { color: color-mix(in srgb, var(--on-ink) 65%, transparent); }
.msg:not(.mine) .bubble { border-bottom-left-radius: 6px; }
.msg.internal .bubble { background: var(--note); color: var(--text); border: 1px dashed var(--line-strong); }
.msg.internal .who { color: var(--muted); }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg .file { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: color-mix(in srgb, currentColor 10%, transparent); font-size: 13px; text-decoration: none; }
.msg .thumb { width: 160px; border-radius: 10px; overflow: hidden; }
.unread-sep { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--blue); font-weight: 600; }
.unread-sep::before, .unread-sep::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .4; }
.composer { margin-top: 12px; border: 1px solid var(--line-strong); border-radius: var(--r-l); background: var(--bg); padding: 8px; }
.composer textarea { border: 0; min-height: 64px; box-shadow: none !important; padding: 8px 10px; background: transparent; }
.composer-bar { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0; flex-wrap: wrap; }
.composer-bar .btn-primary { margin-left: auto; }
.composer-bar label.attach { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.composer-bar label.attach input { position: absolute; opacity: 0; width: 1px; }
.composer-bar .picked { font-size: 13px; color: var(--muted); }

/* --- Лента событий -------------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--text); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 1px; background: var(--line-strong); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; font-size: 12px; color: var(--muted); }
.timeline .private::before { background: var(--faint); }

/* --- Ссылки окружений ------------------------------------------------------------------ */
.env { padding: 14px 16px; border-radius: var(--r-m); background: var(--bg); border: 1px solid var(--line); }
.env + .env { margin-top: 10px; }
.env-top { display: flex; align-items: center; gap: 10px; }
.env-top .label { font-weight: 700; font-size: 14px; }
.env-url { display: block; margin-top: 4px; font-size: 14px; overflow-wrap: anywhere; color: var(--muted); }
.env-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); }
.env details { margin-top: 10px; }
.env summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none; }
.env summary::-webkit-details-marker { display: none; }
details.inline-form > summary { list-style: none; cursor: pointer; }
details.inline-form > summary::-webkit-details-marker { display: none; }
details.inline-form[open] > summary { margin-bottom: 12px; }

/* --- Уведомления -------------------------------------------------------------------------- */
.flashes { position: fixed; right: 20px; top: 20px; z-index: 50; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px 12px 16px; border-radius: var(--r-m); background: var(--ink); color: var(--on-ink); font-size: 14px; font-weight: 500; animation: flash-in .25s ease-out; }
.flash.error { background: var(--red); color: #fff; }
.flash button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; padding: 0; }
@keyframes flash-in { from { transform: translateY(-8px); opacity: 0; } }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--r-m); background: var(--bg-card); border: 1px solid var(--line); margin-bottom: 18px; font-size: 14px; flex-wrap: wrap; }
.banner .btn { margin-left: auto; }

.empty { text-align: center; padding: 48px 20px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-l); }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 18px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.sum-line { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 15px; }
.sum-line.total { font-weight: 800; font-size: 18px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.prose { max-width: 72ch; }
.prose h2 { font-size: 20px; margin-top: 1.6em; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 1em 0; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

dialog.confirm { border: 1px solid var(--line); border-radius: var(--r-l); padding: 24px; max-width: 400px; background: var(--bg); color: var(--text); }
dialog.confirm::backdrop { background: rgb(0 0 0 / .45); }
dialog.confirm p { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
dialog.confirm .cluster { justify-content: flex-end; }

/* --- Адаптив ----------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 290px; transform: translateX(-100%); transition: transform .25s; }
  .side.is-open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .topbar b { font-weight: 800; }
  .main { padding-top: 20px; }
  .grid-2, .grid-3, .fields-2, .fields-3 { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(var(--n, 9), minmax(0, 1fr)); }
  .steps li span { display: none; }
  .steps li.current span { display: block; overflow: visible; }
  .msg { max-width: 100%; }
  .hero-card .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .hero-card .actions .btn, .hero-card .actions form { flex: 1 1 auto; }
  .hero-card .actions form .btn { width: 100%; }
  .row { flex-wrap: wrap; }
  .row .label { flex: 1 1 60%; }
  .page-head .actions { margin-left: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .side, .topbar, .flashes, .page-head .actions, .crumbs, .btn { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .card, .table-wrap { border-color: #ccc; background: #fff; }
  body { background: #fff; color: #000; }
}

/* --- Служебные сообщения в переписке (как в мессенджере) ---------------------------- */
.svc { align-self: center; display: flex; align-items: center; gap: 8px; max-width: 92%; padding: 5px 12px; border-radius: 999px; background: var(--bg-pill); color: var(--muted); font-size: 13px; font-weight: 500; text-align: center; }
.svc time { font-size: 11px; color: var(--faint); }
.svc-card { align-self: center; width: min(420px, 100%); padding: 16px 18px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line-strong); }
.svc-card-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.svc-card-head time { margin-left: auto; font-weight: 500; font-size: 12px; color: var(--faint); }
.svc-card h4 { margin: 0 0 4px; font-size: 16px; letter-spacing: -0.01em; }
.svc-amount { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.svc-card .desc { font-size: 14px; color: var(--muted); margin: 4px 0 0; white-space: pre-wrap; }
.svc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.svc-actions form { display: contents; }
.svc-card details { margin-top: 8px; width: 100%; }
.svc-card details summary { cursor: pointer; font-size: 13px; color: var(--muted); }

/* Дополнительные этапы на шкале */
.steps li.extra span::before { content: "+ "; }
.steps li.extra.pending::before { background: transparent; border: 1.5px dashed var(--text); height: 6px; box-sizing: border-box; opacity: .55; }
.steps li.extra.pending { color: var(--muted); }
.stage-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-m); background: var(--bg); border: 1px solid var(--line); }
.stage-row + .stage-row { margin-top: 8px; }
.stage-row .grow { flex: 1; min-width: 0; }
.stage-row b { font-size: 15px; }
.stage-row .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.stage-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.step-toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.step-toggles .check { margin: 0; }
.qr { width: 200px; height: 200px; border-radius: 14px; overflow: hidden; background: #fff; padding: 6px; }
.qr svg { width: 100%; height: 100%; }
.copy-field { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-m); background: var(--bg); border: 1px solid var(--line); }
.copy-field + .copy-field { margin-top: 8px; }
.copy-field span { color: var(--muted); font-size: 13px; min-width: 110px; }
.copy-field b { flex: 1; font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.btn.is-done { background: var(--green); color: #fff; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
