:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e3e8ef;
  --line-2: #d3dae4;
  --ink: #1b2430;
  --ink-2: #4a5768;
  --muted: #7a8698;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --warn: #b26a00;
  --warn-soft: #fdf1dc;
  --bad: #c2312b;
  --bad-soft: #fbe5e4;
  --side: #17202c;
  --side-ink: #c5cfdc;
  --side-active: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161d; --panel: #18202a; --panel-2: #1d2631; --line: #283342; --line-2: #34414f;
    --ink: #e6ebf2; --ink-2: #b4bfcd; --muted: #8492a5;
    --accent: #6c8ff0; --accent-ink: #0d1220; --accent-soft: #1f2b47;
    --ok: #4cc27f; --ok-soft: #173326; --warn: #e2a648; --warn-soft: #3a2d15; --bad: #ef6b64; --bad-soft: #3d1d1c;
    --side: #0c1117; --side-ink: #9eabbb;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Каркас ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #4f7cf0, #2f5bd3);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand b { font-size: 16px; display: block; }
.brand span { font-size: 11px; color: var(--side-ink); display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.1); color: var(--side-active); }
.nav .count { margin-left: auto; font-size: 11px; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.side-foot { margin-top: auto; padding: 10px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot a { color: var(--side-ink); }
.side-foot a:hover { color: #fff; }

.main { min-width: 0; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 240px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* ---------- Панели ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { flex: 1; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: inherit; display: block; }
a.tile:hover { text-decoration: none; border-color: var(--line-2); }
.tile .lbl { color: var(--muted); font-size: 12px; }
.tile .val { font-size: 28px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.bad .val { color: var(--bad); }
.tile.warn .val { color: var(--warn); }

.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  background: var(--warn-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner svg { width: 20px; height: 20px; color: var(--warn); flex: none; }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.banner.info svg { color: var(--accent); }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 30px; padding: 0; height: 30px; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
textarea { width: 100%; resize: vertical; line-height: 1.5; }
textarea:read-only, input:read-only { background: var(--panel-2); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 550; }
label.field > input, label.field > select, label.field > textarea { font-weight: 400; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.search { position: relative; }
.search input { padding-left: 32px; width: 280px; max-width: 100%; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 550; color: var(--ink-2); padding: 5px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--panel-2); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.t td.cb, .t th.cb { width: 36px; padding-right: 0; }
.t .title-cell { font-weight: 550; }
.t .desc { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: pre-line; }
.t tr.done .title-cell { text-decoration: line-through; color: var(--muted); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; opacity: .5; display: block; margin: 0 auto 8px; }

/* ---------- Метки ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge svg { width: 12px; height: 12px; }
.task-edit tr.done textarea { text-decoration: line-through; color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.icons { display: inline-flex; gap: 6px; color: var(--muted); }
.icons svg { width: 16px; height: 16px; }
.icons .on { color: var(--ok); }
.due-bad { color: var(--bad); font-weight: 600; }
.due-warn { color: var(--warn); font-weight: 600; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a .badge { margin-left: 4px; }

/* ---------- Протокол ---------- */
.proto-sec { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.proto-sec:last-child { border-bottom: 0; }
.proto-sec h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.proto-sec .read { white-space: pre-wrap; color: var(--ink); }
.proto-sec .read:empty::before { content: "—"; color: var(--muted); }
.people-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px 2px 3px; font-size: 13px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none; }

.task-edit td { padding: 6px 8px; }
.task-edit input[type="text"], .task-edit select, .task-edit input[type="date"] { width: 100%; padding: 5px 8px; }
.task-edit textarea { min-height: 34px; padding: 5px 8px; font-size: 13px; resize: none; overflow: hidden; }

.dropzone { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.dropzone svg { width: 32px; height: 32px; display: block; margin: 0 auto 8px; color: var(--accent); }
.progress { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
audio { width: 100%; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); white-space: nowrap; font-size: 12px; min-width: 104px; }

.transcript { min-height: 420px; font-size: 14px; }

/* ---------- Модальные окна ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 28, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(760px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.picklist { border: 1px solid var(--line-2); border-radius: 8px; max-height: 220px; overflow-y: auto; }
.picklist label { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 400; color: var(--ink); }
.picklist label:last-child { border-bottom: 0; }
.picklist label:hover { background: var(--panel-2); }
.picklist .pos { color: var(--muted); font-size: 12px; margin-left: auto; }
@keyframes fade { from { opacity: 0; } }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); max-width: 380px; animation: fade .15s; }
.toast.err { background: var(--bad); color: #fff; }

.secret-set { display: flex; gap: 8px; align-items: center; }
.secret-set code { background: var(--panel-2); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; font-size: 13px; }
.steps { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 13px; }
.steps li { margin-bottom: 4px; }

/* ---------- Вход ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.auth .card { width: min(380px, 100%); padding: 28px; }
.auth .brand { color: var(--ink); padding: 0 0 20px; }
.auth .brand span { color: var(--muted); }
.auth .err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- Мобильные ---------- */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 248px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px 16px 40px; }
  .grid-2, .grid-main { grid-template-columns: 1fr; }
  .search input { width: 100%; }
  .hide-m { display: none; }
}

/* ---------- Печать протокола ---------- */
.print-area { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .shell, .toasts, .modal-back { display: none !important; }
  .print-area { display: block; }
  .print-area h1 { font-size: 16pt; text-align: center; margin-bottom: 4pt; }
  .print-area .pmeta { text-align: center; margin-bottom: 14pt; color: #333; }
  .print-area h2 { font-size: 12pt; margin: 14pt 0 5pt; }
  .print-area .ptext { white-space: pre-wrap; }
  .print-area table { width: 100%; border-collapse: collapse; font-size: 10pt; }
  .print-area th, .print-area td { border: 1px solid #888; padding: 4pt 6pt; text-align: left; vertical-align: top; }
  .print-area th { background: #eee; }
  .print-area .psign { margin-top: 28pt; }
  @page { margin: 16mm 14mm; }
}
