/* КСК-Проєкт — стилі. Без фреймворків. Світла й темна теми. */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #16202c;
  --ink-2: #4a5b6d;
  --ink-3: #6b7d90;
  --line: #d7dfe8;
  --line-2: #e6ecf2;
  --brand: #1f3864;
  --brand-ink: #ffffff;
  --accent: #2e75b6;
  --focus: #2e75b6;

  --s-red-bg: #fde8e7;    --s-red-ink: #8d1a12;    --s-red-bar: #c0392b;
  --s-violet-bg: #efe6f7; --s-violet-ink: #5a2a86; --s-violet-bar: #7b3fb5;
  --s-amber-bg: #fdf1d9;  --s-amber-ink: #7a4d00;  --s-amber-bar: #d08700;
  --s-green-bg: #e0f2e6;  --s-green-ink: #17603c;  --s-green-bar: #1f7a5a;
  --s-grey-bg: #eceff3;   --s-grey-ink: #4d5b69;   --s-grey-bar: #8fa3b8;
  --s-blue-bg: #e2edf9;   --s-blue-ink: #14497e;   --s-blue-bar: #2e75b6;

  --shadow: 0 1px 2px rgba(22, 32, 44, .06), 0 4px 14px rgba(22, 32, 44, .06);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c;
    --panel: #19212a;
    --panel-2: #1e2732;
    --ink: #e8eef5;
    --ink-2: #aebccb;
    --ink-3: #8497a9;
    --line: #2d3a47;
    --line-2: #26313c;
    --brand: #2b4f8c;
    --brand-ink: #ffffff;
    --accent: #6ba8e6;
    --focus: #6ba8e6;

    --s-red-bg: #3c1b18;    --s-red-ink: #ffb3ab;    --s-red-bar: #e05c4c;
    --s-violet-bg: #2e2140; --s-violet-ink: #d9bcf5; --s-violet-bar: #a273d8;
    --s-amber-bg: #3a2d10;  --s-amber-ink: #f7ce7e;  --s-amber-bar: #d9a020;
    --s-green-bg: #12332a;  --s-green-ink: #8fe0b8;  --s-green-bar: #35a377;
    --s-grey-bg: #242c35;   --s-grey-ink: #9fb0c0;   --s-grey-bar: #6b7d90;
    --s-blue-bg: #172c44;   --s-blue-ink: #a7cbf0;   --s-blue-bar: #4a8fd4;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #11161c; --panel: #19212a; --panel-2: #1e2732;
  --ink: #e8eef5; --ink-2: #aebccb; --ink-3: #8497a9;
  --line: #2d3a47; --line-2: #26313c;
  --brand: #2b4f8c; --brand-ink: #fff; --accent: #6ba8e6; --focus: #6ba8e6;
  --s-red-bg: #3c1b18; --s-red-ink: #ffb3ab; --s-red-bar: #e05c4c;
  --s-violet-bg: #2e2140; --s-violet-ink: #d9bcf5; --s-violet-bar: #a273d8;
  --s-amber-bg: #3a2d10; --s-amber-ink: #f7ce7e; --s-amber-bar: #d9a020;
  --s-green-bg: #12332a; --s-green-ink: #8fe0b8; --s-green-bar: #35a377;
  --s-grey-bg: #242c35; --s-grey-ink: #9fb0c0; --s-grey-bar: #6b7d90;
  --s-blue-bg: #172c44; --s-blue-ink: #a7cbf0; --s-blue-bar: #4a8fd4;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ каркас */
#app { display: flex; flex-direction: column; min-height: 100vh; }

header.top {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px; height: 52px;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
header.top .brand { font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
header.top .brand small { font-weight: 500; opacity: .8; display: block; font-size: 10px; letter-spacing: 0; }
header.top .spacer { flex: 1; }
header.top .who { font-size: 12px; opacity: .95; text-align: right; line-height: 1.25; }
header.top .who b { display: block; }
header.top button {
  background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 7px; padding: 6px 10px; cursor: pointer;
}
header.top button:hover:not(:disabled) { background: rgba(255, 255, 255, .26); }
header.top button:disabled { opacity: .38; cursor: default; }
#backbtn { white-space: nowrap; }

nav.tabs {
  position: sticky; top: 52px; z-index: 35;
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: thin;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 8px;
}
nav.tabs a {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; color: var(--ink-2); text-decoration: none;
  border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; font-size: 13px;
}
nav.tabs a:hover { color: var(--ink); background: var(--panel-2); }
nav.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
nav.tabs .pill {
  background: var(--s-red-bar); color: #fff; border-radius: 10px;
  padding: 0 6px; font-size: 11px; font-weight: 700; min-width: 18px; text-align: center;
}

main { flex: 1; padding: 16px; max-width: 100%; }
.wrap { max-width: 1680px; margin: 0 auto; }

h1 { font-size: 19px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; }
.sub { color: var(--ink-3); font-size: 12.5px; margin: 0 0 14px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 14px 16px; }

/* ------------------------------------------------------------------ кнопки */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px;
  text-decoration: none;
}
.btn:hover { background: var(--panel-2); border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--s-red-ink); border-color: var(--s-red-bar); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 4px 9px; font-size: 12px; }

:is(input, select, textarea).f {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; min-width: 0; width: 100%;
}
:is(input, select, textarea).f:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
label.lbl { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 0 0 4px; }
.field { margin-bottom: 12px; }

/* ------------------------------------------------------------------ головна */
.obj-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.obj-card { padding: 16px; }
.obj-card h2 { margin: 0 0 2px; font-size: 17px; }
.obj-card .code { color: var(--ink-3); font-size: 12px; font-family: var(--mono); }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; margin-top: 14px; }
.kpi {
  border-radius: 9px; padding: 10px; border: 1px solid var(--line-2); background: var(--panel-2);
  cursor: pointer; text-align: left; display: block; width: 100%; text-decoration: none; color: inherit;
}
.kpi:hover { border-color: var(--accent); }
.kpi .n { font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .t { font-size: 11px; color: var(--ink-3); margin-top: 2px; line-height: 1.25; }
.kpi.red { background: var(--s-red-bg); border-color: var(--s-red-bar); }
.kpi.red .n { color: var(--s-red-ink); }
.kpi.violet { background: var(--s-violet-bg); border-color: var(--s-violet-bar); }
.kpi.violet .n { color: var(--s-violet-ink); }
.kpi.amber { background: var(--s-amber-bg); border-color: var(--s-amber-bar); }
.kpi.amber .n { color: var(--s-amber-ink); }
.kpi.green { background: var(--s-green-bg); border-color: var(--s-green-bar); }
.kpi.green .n { color: var(--s-green-ink); }
.kpi.grey .n { color: var(--ink-2); }

.bar { height: 10px; border-radius: 5px; background: var(--line-2); overflow: hidden; display: flex; margin-top: 6px; }
.bar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11.5px; color: var(--ink-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.feed { max-height: 420px; overflow: auto; }
.feed .row {
  display: grid; grid-template-columns: 120px 130px 1fr; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; align-items: baseline;
}
.feed .row:last-child { border-bottom: 0; }
.feed .t { color: var(--ink-3); font-family: var(--mono); font-size: 11.5px; }
.feed .u { font-weight: 700; }
.feed del { color: var(--ink-3); text-decoration-color: var(--s-red-bar); }
.feed ins { text-decoration: none; font-weight: 600; color: var(--s-green-ink); background: var(--s-green-bg); padding: 0 3px; border-radius: 3px; }

/* ------------------------------------------------------------------ таблиця */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0;
}
.toolbar select.f, .toolbar input.f { width: auto; min-width: 120px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar .cnt { color: var(--ink-3); font-size: 12px; margin-left: auto; white-space: nowrap; }

.tablewrap {
  overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  /* Точну висоту виставляє JS від фактичного положення таблиці на екрані —
     інакше нижній край зі смугою горизонтальної прокрутки ховається під вікном. */
  max-height: 60vh;
  scrollbar-width: auto;
  scrollbar-color: var(--ink-3) var(--panel-2);
}
/* Смуги прокрутки мають бути видно завжди: таблиці ширші за екран. */
.tablewrap::-webkit-scrollbar { width: 14px; height: 14px; }
.tablewrap::-webkit-scrollbar-track { background: var(--panel-2); border-radius: 7px; }
.tablewrap::-webkit-scrollbar-thumb {
  background: var(--ink-3); border-radius: 7px; border: 3px solid var(--panel-2);
}
.tablewrap::-webkit-scrollbar-thumb:hover { background: var(--ink-2); }
.tablewrap::-webkit-scrollbar-corner { background: var(--panel-2); }

.scrollhint {
  display: none; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-3); padding: 4px 12px 0;
}
.scrollhint.on { display: flex; }

table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
table.grid thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel-2); color: var(--ink-2);
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  padding: 8px 8px; border-bottom: 2px solid var(--line); white-space: nowrap;
  cursor: pointer; user-select: none;
}
/* Перша колонка (ID) не їде при горизонтальній прокрутці — інакше на 15 колонках
   неможливо зрозуміти, в якому ти рядку. */
table.grid thead th:first-child { left: 0; z-index: 7; }
table.grid tbody td:first-child { position: sticky; left: 0; z-index: 3; background: var(--panel); }
table.grid thead th:first-child::after,
table.grid tbody td:first-child::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 1px;
  background: var(--line); box-shadow: 2px 0 6px rgba(0, 0, 0, .10);
}
table.grid tr.detail td:first-child::after { display: none; }
table.grid td {
  padding: 5px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top;
  font-size: 13px; max-width: 460px;
}
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.mono { font-family: var(--mono); font-size: 12px; }
table.grid td.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

tr.st-not_covered td:first-child, tr.st-crit td:first-child { box-shadow: inset 4px 0 0 var(--s-red-bar); }
tr.st-blocked td:first-child { box-shadow: inset 4px 0 0 var(--s-violet-bar); }
tr.st-in_progress td:first-child, tr.st-work td:first-child, tr.st-draft td:first-child,
tr.st-issued td:first-child, tr.st-new td:first-child { box-shadow: inset 4px 0 0 var(--s-amber-bar); }
tr.st-covered td:first-child, tr.st-approved td:first-child, tr.st-done td:first-child,
tr.st-ok td:first-child, tr.st-received td:first-child { box-shadow: inset 4px 0 0 var(--s-green-bar); }
tr.st-n_a td:first-child, tr.st-cancelled td:first-child, tr.st-closed td:first-child { box-shadow: inset 4px 0 0 var(--s-grey-bar); }

tr.st-not_covered td, tr.st-crit td { background: var(--s-red-bg); }
tr.st-blocked td { background: var(--s-violet-bg); }
tr.st-in_progress td, tr.st-work td { background: var(--s-amber-bg); }
tr.st-covered td, tr.st-approved td { background: var(--s-green-bg); }
tr.st-n_a td, tr.st-cancelled td { background: var(--s-grey-bg); color: var(--ink-2); }
tr.overdue td { outline: 1px solid var(--s-red-bar); outline-offset: -1px; }

td.ed { cursor: text; border-radius: 4px; }
td.ed:hover { background: color-mix(in srgb, var(--accent) 14%, transparent) !important; }
td.ed:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--panel) !important; }
td.ed.saving { opacity: .55; }
td.ed.saved { animation: flash .9s ease-out; }
td.ro { cursor: default; }
@keyframes flash { from { background: var(--s-green-bg) !important; } to { background: transparent; } }

td select.cell {
  border: 1px solid transparent; background: transparent; border-radius: 5px;
  padding: 2px 4px; width: 100%; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
td select.cell:hover { border-color: var(--line); background: var(--panel); }
td select.cell:focus { outline: 2px solid var(--focus); background: var(--panel); }

.chip {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.chip.A { background: var(--s-red-bg); color: var(--s-red-ink); }
.chip.B { background: var(--s-amber-bg); color: var(--s-amber-ink); }
.chip.C { background: var(--s-grey-bg); color: var(--s-grey-ink); }
.chip.obj { background: var(--s-blue-bg); color: var(--s-blue-ink); font-family: var(--mono); }

tr.detail td { background: var(--panel-2) !important; padding: 10px 14px 14px 20px; box-shadow: none !important; position: static; }
.detail dl { display: grid; grid-template-columns: 170px 1fr; gap: 4px 14px; margin: 0; }
.detail dt { color: var(--ink-3); font-size: 12px; font-weight: 600; }
.detail dd { margin: 0; font-size: 13px; }
.detail .body { white-space: pre-wrap; line-height: 1.55; }

/* ------------------------------------------------- функціональна схема (ФС) */
.fs-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.fs-layout { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; }
/* Схема намальована під білий аркуш — у темній темі лишаємо її на білому,
   інакше підписи всередині блоків стають нечитабельними. */
.fs-stage { overflow: auto; background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.fs-stage svg { display: block; max-width: 100%; height: auto; }

.fs-hit { cursor: pointer; fill: transparent; stroke: transparent; stroke-width: 3; transition: fill .12s; }
.fs-hit:hover { fill: rgba(46, 117, 182, .16); stroke: var(--accent); }
.fs-hit.sel { fill: rgba(46, 117, 182, .2); stroke: var(--accent); stroke-width: 4; }
.fs-flag { pointer-events: none; }
.fs-dim { opacity: .28; }

.fs-panel { position: sticky; top: 110px; max-height: calc(100vh - 130px); overflow: auto; }
.fs-panel .hd { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.fs-panel .hd h3 { margin: 0 0 4px; font-size: 15px; }
.fs-panel .bd { padding: 12px 14px; }
.fs-stat { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.fs-stat.crit { background: var(--s-red-bg); color: var(--s-red-ink); }
.fs-stat.blocked { background: var(--s-violet-bg); color: var(--s-violet-ink); }
.fs-stat.work { background: var(--s-amber-bg); color: var(--s-amber-ink); }
.fs-stat.ok { background: var(--s-green-bg); color: var(--s-green-ink); }
.fs-stat.n_a { background: var(--s-grey-bg); color: var(--s-grey-ink); }

.minilist { margin: 6px 0 0; padding: 0; list-style: none; }
.minilist li { padding: 5px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.minilist li:last-child { border-bottom: 0; }
.minilist .k { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

/* ----------------------------------------------------------- план-графік */
.gantt { overflow-x: auto; }
.gantt table { border-collapse: collapse; width: 100%; min-width: 900px; }
.gantt th, .gantt td { padding: 4px 6px; font-size: 12px; border-bottom: 1px solid var(--line-2); }
.gantt th { color: var(--ink-3); font-weight: 700; text-align: left; }
.gantt .track { position: relative; height: 22px; background: var(--panel-2); border-radius: 5px; }
.gantt .plan { position: absolute; top: 3px; height: 16px; background: var(--s-blue-bg); border: 1px solid var(--s-blue-bar); border-radius: 4px; }
.gantt .done { position: absolute; top: 5px; height: 12px; background: var(--s-green-bar); border-radius: 3px; }
.gantt .gate { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--s-red-bar); }
.gantt .todayline { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--accent); }

/* ------------------------------------------------------------------ скринька */
.inbox-grid { display: grid; grid-template-columns: 380px 1fr; gap: 14px; align-items: start; }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center;
  color: var(--ink-3); cursor: pointer; background: var(--panel-2);
}
.drop.hot { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--ink); }
.filelist { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; }
.filelist li { display: flex; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line-2); }
.filelist .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .sz { color: var(--ink-3); font-family: var(--mono); font-size: 11.5px; }
.meter { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------------------------ довідка */
.help { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.help nav { position: sticky; top: 110px; font-size: 13px; }
.help nav a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--ink-2); text-decoration: none; }
.help nav a:hover { background: var(--panel-2); color: var(--ink); }
.help article { line-height: 1.65; }
.help article h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; scroll-margin-top: 110px; }
.help article p, .help article li { max-width: 78ch; }
.help article code { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.help ol.steps { padding-left: 20px; }
.help ol.steps li { margin-bottom: 8px; }
table.dict { border-collapse: collapse; width: 100%; margin: 8px 0 18px; }
table.dict th, table.dict td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; font-size: 13px; }
table.dict th { color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; }
table.dict td:first-child { font-weight: 700; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
table.dict td:nth-child(2) { width: 34%; }

/* ------------------------------------------- глобальний перемикач об'єкта */
.objsw {
  display: flex; gap: 2px; padding: 2px;
  background: rgba(255, 255, 255, .13); border-radius: 9px;
}
.objsw button {
  background: transparent; border: 0; color: rgba(255, 255, 255, .82);
  padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.objsw button:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.objsw button.on { background: #fff; color: var(--brand); }
:root[data-theme="dark"] .objsw button.on { color: #10203a; }

.scopehint {
  font-size: 12px; color: var(--ink-3); margin: -8px 0 12px;
}

/* ------------------------------------------------------------------- чат */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: stretch; }
.chat-side { display: flex; flex-direction: column; overflow: hidden; }
.chat-side-hd { padding: 10px; border-bottom: 1px solid var(--line); }
.chat-list { overflow: auto; flex: 1; }
.chat-item {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  cursor: pointer; border-bottom: 1px solid var(--line-2);
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.on { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.chat-item .ava {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: var(--s-blue-bar); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.chat-item .ava.grp { background: var(--s-green-bar); border-radius: 10px; }
.chat-item .ttl { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .prev { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .pill {
  background: var(--s-red-bar); color: #fff; border-radius: 10px;
  padding: 0 6px; font-size: 11px; font-weight: 700; flex: none;
}

.chat-thread { display: flex; flex-direction: column; overflow: hidden; }
.chat-hd { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-hd h3 { margin: 0; font-size: 15px; }
.chat-msgs { flex: 1; overflow: auto; padding: 14px; background: var(--panel-2); }
.chat-day { text-align: center; font-size: 11.5px; color: var(--ink-3); margin: 14px 0 8px; }
.chat-msgs .row { display: flex; margin-bottom: 6px; }
.chat-msgs .row.mine { justify-content: flex-end; }
.bub {
  max-width: min(680px, 78%);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 11px; box-shadow: var(--shadow);
}
.bub.mine { background: var(--s-blue-bg); border-color: var(--s-blue-bar); }
.bub .who { font-size: 11.5px; font-weight: 800; color: var(--s-blue-ink); margin-bottom: 3px; }
.bub .txt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.45; }
.bub .meta { display: flex; align-items: center; gap: 6px; justify-content: flex-end; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }
.bub .meta .del { background: none; border: 0; color: var(--ink-3); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.bub .meta .del:hover { color: var(--s-red-ink); }
.bub .filelist { margin-top: 6px; }
.bub .fico { flex: none; }

.chat-composer { border-top: 1px solid var(--line); padding: 10px 12px; background: var(--panel); }
.chat-composer.hot { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.chat-composer textarea { resize: vertical; min-height: 42px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-file {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 8px; font-size: 12px;
}
.chip-file .sz { color: var(--ink-3); font-size: 11px; }
.chip-file button { background: none; border: 0; cursor: pointer; color: var(--ink-3); font-size: 15px; line-height: 1; }

/* ------------------------------------------------------------------ дрібне */
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px;
  animation: slidein .18s ease-out;
}
.toast.err { border-left-color: var(--s-red-bar); }
.toast.ok { border-left-color: var(--s-green-bar); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

dialog.modal {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3); padding: 0; max-width: 560px; width: calc(100% - 32px);
}
dialog.modal::backdrop { background: rgba(10, 16, 22, .55); }
dialog.modal .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
dialog.modal .bd { padding: 16px 18px; }
dialog.modal .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login .logo { text-align: center; margin-bottom: 18px; }
.login .logo b { font-size: 20px; display: block; color: var(--brand); }
:root[data-theme="dark"] .login .logo b, :root:not([data-theme="light"]) .login .logo b { color: var(--accent); }

.err { color: var(--s-red-ink); background: var(--s-red-bg); border-radius: 7px; padding: 8px 11px; font-size: 13px; }
.ok { color: var(--s-green-ink); background: var(--s-green-bg); border-radius: 7px; padding: 8px 11px; font-size: 13px; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: var(--mono); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.rowflex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ мобільне */
@media (max-width: 1100px) {
  .fs-layout { grid-template-columns: 1fr; }
  .fs-panel { position: static; max-height: none; }
  .inbox-grid { grid-template-columns: 1fr; }
  .help { grid-template-columns: 1fr; }
  .help nav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .chat-layout { grid-template-columns: 260px 1fr; }
}
@media (max-width: 820px) {
  .chat-layout { grid-template-columns: 1fr; height: auto !important; }
  .chat-side { max-height: 260px; }
  .chat-thread { min-height: 60vh; }
  .bub { max-width: 90%; }
}
@media (max-width: 720px) {
  main { padding: 10px; }
  .obj-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .feed .row { grid-template-columns: 1fr; gap: 2px; }
  header.top .brand small { display: none; }
  header.top .who span { display: none; }
  .tablewrap { max-height: calc(100vh - 250px); }
  nav.tabs a { padding: 9px 9px; font-size: 12.5px; }
  .objsw button { padding: 5px 8px; font-size: 11.5px; }
  #backbtn { padding: 6px 7px; font-size: 12px; }
}
@media (max-width: 520px) {
  header.top { gap: 8px; padding: 0 8px; }
  header.top .brand { font-size: 13px; }
  .objsw button { padding: 4px 6px; font-size: 11px; }
}

@media print {
  header.top, nav.tabs, .toolbar, .btn { display: none !important; }
  body { background: #fff; }
  .tablewrap { max-height: none; overflow: visible; border: 0; }
}
