/* Проблематика ВК — interface styles.
   Two sides, two inks: CC7 (stamp violet) raises a problem, PESCO / IPMT (teal) answers it.
   Document numbers are set in a monospace face because they are compared character by character. */

@font-face {
  font-family: "Golos";
  src: url("fonts/golos-text-cyrillic-wght-normal.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-text-latin-wght-normal.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+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Doc Mono";
  src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Doc Mono";
  src: url("fonts/jetbrains-mono-cyrillic-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Doc Mono";
  src: url("fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Doc Mono";
  src: url("fonts/jetbrains-mono-cyrillic-500-normal.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  color-scheme: light;
  --paper: #eef0f4;
  --sheet: #ffffff;
  --sheet-2: #f7f8fa;
  --sheet-3: #f1f3f6;
  --ink: #161a22;
  --ink-2: #545c6c;
  --ink-3: #848b9a;
  --rule: #d9dde5;
  --rule-2: #e8ebf0;
  --stamp: #5b3e9e;
  --stamp-strong: #48307f;
  --stamp-tint: #f0ebf9;
  --stamp-line: #cdbfe9;
  --pesco: #0b6a64;
  --pesco-strong: #08534e;
  --pesco-tint: #e1f2ef;
  --pesco-line: #a9d7d0;
  --amber: #8f5208;
  --amber-tint: #fdf0d8;
  --green: #1f7046;
  --green-tint: #e2f3e8;
  --olive: #6f600c;
  --olive-tint: #f4efd2;
  --grey: #626a7b;
  --grey-tint: #eceef2;
  --danger: #b3261e;
  --danger-tint: #fbe9e7;
  --row-hover: #f6f4fb;
  --row-active: #efeaf9;
  --overlay: rgba(22, 20, 40, 0.32);
  --shadow-pop: 0 10px 30px rgba(24, 22, 48, 0.16), 0 2px 6px rgba(24, 22, 48, 0.08);
  --shadow-drawer: -18px 0 50px rgba(24, 22, 48, 0.18);
  --font: "Golos", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Doc Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 6px;
  --header-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #15171d;
    --sheet: #1c1f27;
    --sheet-2: #20242d;
    --sheet-3: #252a34;
    --ink: #e8eaf0;
    --ink-2: #a8afbd;
    --ink-3: #7d8494;
    --rule: #333946;
    --rule-2: #2a2f3a;
    --stamp: #a891e6;
    --stamp-strong: #c2b2f0;
    --stamp-tint: #2b2541;
    --stamp-line: #4d4176;
    --pesco: #5cc2b6;
    --pesco-strong: #86d6cc;
    --pesco-tint: #18332f;
    --pesco-line: #2c5a54;
    --amber: #f0b45e;
    --amber-tint: #3a2b14;
    --green: #74cf98;
    --green-tint: #183424;
    --olive: #d8c867;
    --olive-tint: #33301a;
    --grey: #a3aaba;
    --grey-tint: #2a2e38;
    --danger: #ff8a80;
    --danger-tint: #3b1f1d;
    --row-hover: #232633;
    --row-active: #2a2540;
    --overlay: rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-drawer: -18px 0 50px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #15171d;
  --sheet: #1c1f27;
  --sheet-2: #20242d;
  --sheet-3: #252a34;
  --ink: #e8eaf0;
  --ink-2: #a8afbd;
  --ink-3: #7d8494;
  --rule: #333946;
  --rule-2: #2a2f3a;
  --stamp: #a891e6;
  --stamp-strong: #c2b2f0;
  --stamp-tint: #2b2541;
  --stamp-line: #4d4176;
  --pesco: #5cc2b6;
  --pesco-strong: #86d6cc;
  --pesco-tint: #18332f;
  --pesco-line: #2c5a54;
  --amber: #f0b45e;
  --amber-tint: #3a2b14;
  --green: #74cf98;
  --green-tint: #183424;
  --olive: #d8c867;
  --olive-tint: #33301a;
  --grey: #a3aaba;
  --grey-tint: #2a2e38;
  --danger: #ff8a80;
  --danger-tint: #3b1f1d;
  --row-hover: #232633;
  --row-active: #2a2540;
  --overlay: rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-drawer: -18px 0 50px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--stamp); }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 0.93em; letter-spacing: -0.01em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- brand stamp ---------- */
.mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 30px;
  border: 2px solid var(--stamp);
  border-radius: 6px;
  color: var(--stamp);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
  transform: rotate(-5deg);
  position: relative;
  flex: none;
}
.mark::after { content: ""; position: absolute; inset: 2px; border: 1px solid var(--stamp); border-radius: 3px; opacity: 0.55; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: var(--r);
  background: var(--sheet); color: var(--ink);
  font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--stamp); border-color: var(--stamp); color: #fff; }
.btn.primary:hover { background: var(--stamp-strong); border-color: var(--stamp-strong); }
:root[data-theme="dark"] .btn.primary { color: #17131f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #17131f; } }
.btn.pesco { background: var(--pesco); border-color: var(--pesco); color: #fff; }
.btn.pesco:hover { background: var(--pesco-strong); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--sheet-3); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-tint); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255, 255, 255, 0.9) transparent rgba(255, 255, 255, 0.9) transparent;
  animation: spin 0.7s linear infinite;
}
.btn:not(.primary):not(.pesco).busy::after { border-color: var(--ink-2) transparent var(--ink-2) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: grid; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.lbl-hint { font-weight: 400; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; min-width: 0; height: 36px; padding: 0 11px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; min-height: 92px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--stamp); box-shadow: 0 0 0 3px var(--stamp-tint);
}
.input[readonly] { background: var(--sheet-2); color: var(--ink-2); }
.input.mono { font-family: var(--mono); font-size: 13px; }
.select { padding-right: 30px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.field.invalid .input, .field.invalid .textarea, .field.invalid .select { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--stamp); margin: 0; flex: none; }
.check-block { align-items: flex-start; line-height: 1.4; }
.check-block input { margin-top: 2px; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 22px;
  padding: 0 20px;
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand-name { font-weight: 650; font-size: 15px; line-height: 1.15; }
.brand-name span { display: block; font-weight: 400; font-size: 12px; color: var(--ink-2); }
.nav { display: flex; gap: 2px; height: 100%; }
.nav a {
  display: flex; align-items: center; padding: 0 12px; height: 100%;
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); border-bottom-color: var(--stamp); }
.topbar .spacer { flex: 1; }
.userbtn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px;
  border: 1px solid transparent; background: none; cursor: pointer; }
.userbtn:hover { background: var(--sheet-3); }
.userbtn .who { text-align: left; line-height: 1.2; }
.userbtn .who b { display: block; font-weight: 600; font-size: 13px; }
.userbtn .who small { color: var(--ink-2); font-size: 12px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--grey);
}
.avatar.cc7 { background: var(--stamp); }
.avatar.pesco { background: var(--pesco); }
:root[data-theme="dark"] .avatar { color: #121418; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: #121418; } }

.org {
  display: inline-flex; align-items: center; height: 19px; padding: 0 6px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em; vertical-align: 1px;
  background: var(--grey-tint); color: var(--grey);
}
.org.cc7 { background: var(--stamp-tint); color: var(--stamp); }
.org.pesco { background: var(--pesco-tint); color: var(--pesco); }

.menu {
  position: absolute; z-index: 60; min-width: 230px; padding: 6px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; box-shadow: var(--shadow-pop);
}
.menu button, .menu a {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 5px;
  background: none; text-align: left; cursor: pointer; color: var(--ink); text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--sheet-3); }
.menu hr { border: 0; border-top: 1px solid var(--rule-2); margin: 6px 0; }
.menu .menu-note { padding: 6px 10px 8px; font-size: 12.5px; color: var(--ink-2); }
.menu-period { width: 300px; }
.period { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 0 8px 8px; }
.period .input { height: 32px; padding: 0 6px; font-size: 13px; }
.period-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 2px 4px 4px; }
.menu .period-actions .btn { width: auto; display: inline-flex; justify-content: center; padding: 0 12px; border: 1px solid var(--rule); }
.menu .period-actions .btn.primary { background: var(--stamp); border-color: var(--stamp); }
.menu .period-actions .btn.primary:hover { background: var(--stamp-strong); }

main.page { padding: 18px 20px 40px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin: 4px 0 16px; flex-wrap: wrap; }
.page-head .grow { flex: 1; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }

/* ---------- register ---------- */
.register { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.views-row { display: flex; align-items: center; gap: 12px; padding-right: 12px; border-bottom: 1px solid var(--rule); }
.views-row > .btn { flex: none; }
.views { flex: 1; min-width: 0; display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.views button {
  display: flex; align-items: baseline; gap: 8px; padding: 13px 10px 11px; border: 0; background: none;
  color: var(--ink-2); font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap;
}
.views button:hover { color: var(--ink); }
.views button.on { color: var(--ink); border-bottom-color: var(--stamp); }
.views .n { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.views button.on .n { color: var(--stamp); }
.views .dot { width: 7px; height: 7px; border-radius: 50%; align-self: center; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.search { position: relative; flex: 1 1 280px; max-width: 460px; }
.search .input { padding-left: 34px; }
.search svg { position: absolute; left: 11px; top: 10px; color: var(--ink-3); }
.search kbd { position: absolute; right: 9px; top: 8px; }
kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--rule); background: var(--sheet-2); color: var(--ink-3); font: 500 11px var(--font);
}
.toolbar .select, .toolbar .input.date { width: auto; height: 34px; }
.toolbar .select { max-width: 220px; }
.toggle {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--rule); background: var(--sheet); cursor: pointer; font-weight: 500; color: var(--ink-2);
}
.toggle[aria-pressed="true"] { border-color: var(--stamp-line); background: var(--stamp-tint); color: var(--stamp); }
.toolbar .grow { flex: 1; }
.filters-note { padding: 8px 14px; font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--rule-2); background: var(--sheet-2); }
.filters-note button { border: 0; background: none; color: var(--stamp); cursor: pointer; padding: 0; font-weight: 500; }

.table-wrap { overflow: auto; max-height: calc(100vh - var(--header-h) - 190px); min-height: 240px; }
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; min-width: 100%; }
.grid th, .grid td { padding: 9px 12px; border-bottom: 1px solid var(--rule-2); text-align: left; vertical-align: top; }
.grid th {
  position: sticky; top: 0; z-index: 2; background: var(--sheet-2); font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); white-space: nowrap; border-bottom: 1px solid var(--rule); padding-top: 10px; padding-bottom: 10px;
  user-select: none;
}
.grid th.sortable { cursor: pointer; }
.grid th.sortable:hover { color: var(--ink); }
.grid th .arrow { color: var(--stamp); margin-left: 4px; }
.grid th:nth-child(1), .grid td:nth-child(1) { position: sticky; left: 0; z-index: 1; }
.grid th:nth-child(2), .grid td:nth-child(2) { position: sticky; left: 58px; z-index: 1; box-shadow: 1px 0 0 var(--rule-2); }
.grid th:nth-child(1), .grid th:nth-child(2) { z-index: 3; }
.grid td:nth-child(1), .grid td:nth-child(2) { background: var(--sheet); }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: var(--row-hover); }
.grid tbody tr.active td { background: var(--row-active); }
.grid td { font-size: 13.5px; }
.cell-id { color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.cell-id .unread { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--stamp); margin-right: 6px; vertical-align: 1px; }
.cell-doc { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; line-height: 1.4; }
.cell-doc.lead { font-weight: 500; color: var(--ink); }
.cell-doc .more { font-family: var(--font); color: var(--ink-3); font-size: 12px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { -webkit-line-clamp: 3; }
.cell-date { white-space: nowrap; color: var(--ink-2); }
.cell-chat { white-space: nowrap; color: var(--ink-3); }
.cell-chat.has { color: var(--ink-2); }
.cell-chat.new { color: var(--stamp); font-weight: 600; }
.ns { display: inline-block; margin-top: 3px; font: 500 11.5px var(--font); color: var(--olive); }
.empty { padding: 56px 24px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; font-weight: 600; }
.loadmore { padding: 14px; text-align: center; border-top: 1px solid var(--rule-2); }
.list-foot { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; font-size: 12.5px;
  color: var(--ink-3); border-top: 1px solid var(--rule-2); }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; background: var(--grey-tint); color: var(--grey);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.requested { background: var(--amber-tint); color: var(--amber); }
.chip.resolved, .chip.done { background: var(--green-tint); color: var(--green); }
.chip.partial { background: var(--olive-tint); color: var(--olive); }
.chip.cancelled { background: var(--grey-tint); color: var(--grey); }
.chip.in_work { background: var(--pesco-tint); color: var(--pesco); }
.chip.none { background: transparent; color: var(--ink-3); padding-left: 0; }
.chip.none::before { display: none; }

/* cards for narrow screens */
.cards { display: none; }
.card {
  display: block; width: 100%; text-align: left; padding: 13px 14px; border: 0; border-bottom: 1px solid var(--rule-2);
  background: var(--sheet); cursor: pointer;
}
.card:hover { background: var(--row-hover); }
.card-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.card .doc { font-family: var(--mono); font-size: 13px; font-weight: 500; word-break: break-all; }
.card .sup { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.card .prob { margin: 6px 0 8px; font-size: 13.5px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12.5px; color: var(--ink-2); }

/* ---------- drawer ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: var(--overlay); animation: fade 0.16s ease-out; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(1120px, 94vw); background: var(--paper); box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column; animation: slidein 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slidein { from { transform: translateX(28px); opacity: 0.4; } }
.d-head {
  display: flex; gap: 18px; align-items: flex-start; padding: 16px 20px 16px 24px;
  background: var(--sheet); border-bottom: 1px solid var(--rule);
}
.d-title { flex: 1; min-width: 0; }
.d-num { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.d-avk { margin: 5px 0 3px; font: 500 21px/1.3 var(--mono); letter-spacing: -0.02em; word-break: break-all; }
.d-avk.none { font-family: var(--font); font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); }
.d-sup { color: var(--ink-2); font-size: 14px; }
.d-actions { display: flex; gap: 6px; align-items: center; }
.d-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr); }
.d-main { overflow-y: auto; padding: 18px 20px 28px 24px; }
.d-side { min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--rule); background: var(--sheet); }

/* the status stamp: the one loud element */
.stamp {
  position: relative; flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 150px; padding: 7px 14px 6px; margin: 4px 6px 0 0;
  border: 2.5px solid currentColor; border-radius: 9px; color: var(--amber);
  transform: rotate(-4deg); text-align: center; line-height: 1.15;
}
.stamp::after { content: ""; position: absolute; inset: 3px; border: 1px solid currentColor; border-radius: 6px; opacity: 0.6; }
.stamp b { font-size: 15px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.stamp small { margin-top: 2px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; }
.stamp.requested { color: var(--amber); }
.stamp.resolved { color: var(--green); }
.stamp.partial { color: var(--olive); }
.stamp.cancelled { color: var(--grey); }
.stamp.press { animation: press 0.42s cubic-bezier(0.25, 0.9, 0.3, 1.25); }
@keyframes press {
  0% { transform: rotate(-4deg) scale(1.55); opacity: 0; }
  55% { transform: rotate(-4deg) scale(0.95); opacity: 1; }
  100% { transform: rotate(-4deg) scale(1); }
}

.side-block { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; margin-bottom: 16px; }
.side-block > header {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px 11px 16px; border-bottom: 1px solid var(--rule-2);
}
.side-block > header h2 { margin: 0; font-size: 14.5px; font-weight: 650; flex: 1; }
.side-block > header .who { font-size: 12.5px; color: var(--ink-2); }
.side-block.cc7 { border-left: 3px solid var(--stamp); }
.side-block.pesco { border-left: 3px solid var(--pesco); }
.side-block .inner { padding: 14px 16px 16px; display: grid; gap: 14px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.kv .wide { grid-column: 1 / -1; }
.kv dt { font-size: 12.5px; color: var(--ink-2); margin-bottom: 3px; }
.kv dd { margin: 0; min-width: 0; }
.doc-val { display: flex; align-items: flex-start; gap: 6px; font-family: var(--mono); font-size: 13px; word-break: break-all; }
.doc-val .copy { margin-top: -4px; opacity: 0; }
.doc-val:hover .copy, .doc-val .copy:focus-visible { opacity: 1; }
.text-val { white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.text-val.collapsed { max-height: 10.9em; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent); mask-image: linear-gradient(to bottom, #000 62%, transparent); }
.more-btn { margin: 4px 0 0 -10px; color: var(--stamp); }
.d-avk .btn { vertical-align: 2px; opacity: 0.55; }
.d-avk .btn:hover, .d-avk .btn:focus-visible { opacity: 1; }
.text-val.empty-val, .empty-val { color: var(--ink-3); }
.ref-extra { margin-top: 4px; font-size: 12px; color: var(--ink-3); white-space: pre-wrap; font-family: var(--mono); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.hint { font-size: 12.5px; color: var(--ink-2); }
.hint.pesco-hint { color: var(--pesco); }
.lock-note { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-3); }

.seg { display: inline-flex; justify-self: start; max-width: 100%; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; background: var(--sheet); }
.seg button { height: 34px; padding: 0 14px; border: 0; border-right: 1px solid var(--rule); background: none; cursor: pointer;
  font-weight: 500; color: var(--ink-2); }
.seg button:last-child { border-right: 0; }
.seg button:hover:not(:disabled) { background: var(--sheet-3); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--pesco); color: #fff; }
.seg button[aria-pressed="true"][data-v="done"] { background: var(--green); }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { color: #10151a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button[aria-pressed="true"] { color: #10151a; } }
.seg button:disabled { cursor: default; }

/* AVK autocomplete */
.ac { position: relative; }
.ac-list {
  position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 4px); max-height: 330px; overflow-y: auto;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; box-shadow: var(--shadow-pop); padding: 4px;
}
.ac-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 5px; background: none; cursor: pointer; }
.ac-item[aria-selected="true"], .ac-item:hover { background: var(--stamp-tint); }
.ac-item .a { font-family: var(--mono); font-size: 13px; font-weight: 500; word-break: break-all; }
.ac-item .b { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.ac-item .used { color: var(--danger); font-weight: 500; }
.ac-empty { padding: 10px; color: var(--ink-2); font-size: 13px; }
.ref-box { border: 1px dashed var(--stamp-line); border-radius: 8px; padding: 12px 14px; background: var(--stamp-tint); }
.ref-box.manual { border-color: var(--rule); background: var(--sheet-2); }
.ref-box .kv dt { color: var(--stamp); }
.ref-box.manual .kv dt { color: var(--ink-2); }
.ref-state { font-size: 12.5px; color: var(--stamp); margin-bottom: 10px; display: flex; gap: 6px; align-items: center; }
.ref-box.manual .ref-state { color: var(--ink-2); }

/* chat */
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule-2); }
.chat-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; flex: 1; }
.chat-head .check { font-size: 12.5px; color: var(--ink-2); }
.timeline { flex: 1; overflow-y: auto; padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
.msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg-head b { font-weight: 600; font-size: 13.5px; }
.msg-head time { font-size: 12px; color: var(--ink-3); }
.msg-body { margin-top: 3px; padding: 8px 11px; border-radius: 3px 10px 10px 10px; background: var(--sheet-3);
  white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.msg.cc7 .msg-body { background: var(--stamp-tint); }
.msg.pesco .msg-body { background: var(--pesco-tint); }
.msg.mine .msg-body { box-shadow: inset 0 0 0 1px var(--rule); }
.ev { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; font-size: 12.5px; color: var(--ink-2); }
.ev .ev-ico { display: grid; place-items: center; width: 30px; height: 22px; color: var(--ink-3); }
.ev .ev-text b { color: var(--ink); font-weight: 600; }
.ev time { color: var(--ink-3); margin-left: 6px; }
.ev details { margin-top: 3px; }
.ev summary { cursor: pointer; color: var(--stamp); width: max-content; }
.ev .diff { margin: 6px 0 0; display: grid; gap: 6px; }
.ev .diff div { padding: 6px 8px; border-radius: 5px; background: var(--sheet-2); white-space: pre-wrap; word-break: break-word; }
.ev .diff del { color: var(--ink-3); }
.ev .diff ins { text-decoration: none; color: var(--ink); }
.day-sep { align-self: center; font-size: 12px; color: var(--ink-3); padding: 2px 10px; border-radius: 999px; background: var(--sheet-2); }
.new-sep { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--stamp); font-weight: 600; }
.new-sep::before, .new-sep::after { content: ""; flex: 1; border-top: 1px solid var(--stamp-line); }
.composer { border-top: 1px solid var(--rule); padding: 10px 12px 12px; display: grid; gap: 8px; background: var(--sheet); }
.composer textarea { min-height: 44px; max-height: 220px; resize: none; }
.composer-row { display: flex; align-items: center; gap: 10px; }
.composer-row .hint { flex: 1; font-size: 12px; color: var(--ink-3); }

/* ---------- dialogs ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: var(--overlay);
  animation: fade 0.14s ease-out; }
.dialog { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--sheet); border-radius: 10px;
  box-shadow: var(--shadow-pop); border: 1px solid var(--rule); }
.dialog.wide { width: min(640px, 100%); }
.dialog > header { padding: 18px 20px 6px; }
.dialog > header h2 { margin: 0; font-size: 17px; font-weight: 650; }
.dialog > header p { margin: 6px 0 0; color: var(--ink-2); }
.dialog .body { padding: 12px 20px; display: grid; gap: 14px; }
.dialog > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.secret { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 6px; background: var(--sheet-2);
  border: 1px dashed var(--rule); font: 500 16px var(--mono); letter-spacing: 0.04em; }
.secret span { flex: 1; user-select: all; }
.choice { display: grid; gap: 8px; }
.choice label { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 7px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--stamp-line); background: var(--stamp-tint); }
.choice input { accent-color: var(--stamp); margin-top: 3px; }
.choice b { display: block; font-weight: 600; }
.choice small { color: var(--ink-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 20px; bottom: 20px; z-index: 90; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 8px; background: var(--ink); color: var(--sheet);
  box-shadow: var(--shadow-pop); animation: toastin 0.18s ease-out; font-size: 13.5px; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); }
.login-art { position: relative; overflow: hidden; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--sheet); border-right: 1px solid var(--rule); }
.login-art h1 { margin: 0; max-width: 620px; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.08; letter-spacing: -0.025em; font-weight: 700; }
.login-art p { max-width: 520px; color: var(--ink-2); font-size: 15px; line-height: 1.55; margin: 18px 0 0; }
.login-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 18px; margin-top: 34px; }
.login-sides div { padding-left: 12px; border-left: 3px solid var(--stamp); }
.login-sides div + div { border-left-color: var(--pesco); }
.login-sides b { display: block; font-size: 14px; }
.login-sides span { font-size: 13px; color: var(--ink-2); }
.big-stamp {
  position: absolute; right: 64px; bottom: 96px; padding: 16px 30px 12px; border: 5px solid var(--stamp); border-radius: 20px;
  color: var(--stamp); transform: rotate(-9deg); opacity: 0.12; font-weight: 900; font-size: 78px; letter-spacing: 0.06em; line-height: 1;
  pointer-events: none; user-select: none;
}
.big-stamp::after { content: ""; position: absolute; inset: 8px; border: 2px solid var(--stamp); border-radius: 14px; }
.login-form { display: flex; flex-direction: column; justify-content: center; padding: 40px; }
.login-form form { display: grid; gap: 16px; width: 100%; max-width: 340px; margin: 0 auto; }
.login-form h2 { margin: 0 0 4px; font-size: 20px; font-weight: 650; }
.login-form .btn { height: 40px; }
.login-foot { margin-top: 26px; font-size: 12.5px; color: var(--ink-3); text-align: center; }
.form-error { padding: 10px 12px; border-radius: 6px; background: var(--danger-tint); color: var(--danger); font-size: 13px; }

/* ---------- admin pages ---------- */
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; }
.panel + .panel { margin-top: 16px; }
.panel > header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--rule-2); flex-wrap: wrap; }
.panel > header h2 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; }
.panel .inner { padding: 16px; }
.stats { display: flex; flex-wrap: wrap; gap: 28px; }
.stat b { display: block; font-size: 24px; font-weight: 650; letter-spacing: -0.01em; }
.stat span { font-size: 12.5px; color: var(--ink-2); }
table.plain { width: 100%; border-collapse: collapse; }
.plain th, .plain td { padding: 9px 14px; border-bottom: 1px solid var(--rule-2); text-align: left; vertical-align: top; font-size: 13.5px; }
.plain th { font-size: 12.5px; color: var(--ink-2); font-weight: 600; background: var(--sheet-2); white-space: nowrap; }
.plain tr.off td { color: var(--ink-3); }
.plain td.actions { white-space: nowrap; text-align: right; }
.status-line { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 7px; background: var(--sheet-2); }
.status-line.ok { background: var(--green-tint); color: var(--green); }
.status-line.bad { background: var(--danger-tint); color: var(--danger); }
.status-line div { color: var(--ink); }
.upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.matrix td, .matrix th { font-size: 13px; }
.matrix td:not(:first-child), .matrix th:not(:first-child) { text-align: center; }
.yes { color: var(--green); font-weight: 600; }
.no { color: var(--ink-3); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .d-body { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .d-main { overflow: visible; }
  .d-side { border-left: 0; border-top: 1px solid var(--rule); min-height: 520px; }
}
@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .brand-name span { display: none; }
  .nav { display: none; }
  .userbtn .who { display: none; }
  main.page { padding: 12px 12px 32px; }
  .table-wrap { display: none; }
  .cards { display: block; }
  .views-row { flex-wrap: wrap; padding: 0 0 10px; }
  .views-row > .btn { margin-left: 12px; }
  .views { flex-basis: 100%; }
  .toolbar .adv { display: none; }
  .toolbar.expanded .adv { display: inline-flex; }
  .toolbar.expanded .select.adv { display: block; }
  .search { flex-basis: 100%; max-width: none; }
  .drawer { width: 100vw; }
  .d-head { position: relative; padding: 12px 12px 14px 16px; flex-wrap: wrap; gap: 10px; }
  .d-title { flex: 1 1 100%; padding-right: 84px; }
  .d-avk { font-size: 16px; }
  .d-actions { position: absolute; top: 8px; right: 8px; }
  .d-main { padding: 14px 12px 20px; }
  .stamp { min-width: 0; padding: 5px 12px 4px; margin-left: 2px; }
  .stamp b { font-size: 13px; }
  .side-block > header .who { display: none; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { padding: 28px 20px 24px; border-right: 0; border-bottom: 1px solid var(--rule); }
  .big-stamp { display: none; }
  .login-sides { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 20px; }
  .login-form { padding: 28px 20px; }
  .toolbar .select { max-width: none; flex: 1 1 140px; }
  .plain { display: block; overflow-x: auto; }
}
@media (min-width: 901px) {
  .mobile-only { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
