/* Кабинет СВ-Строй — первый срез. Своя зелёная система, связанная с публичной витриной
   (docs/reference/DESIGN.md): хвойный, светлые поверхности, умеренный lime, Golos; Oswald — только знак и заголовки страниц.
   Без декоративных номеров, плюсов, подчёркиваний и стрелок на кнопках. */

@font-face { font-family: "Golos"; src: url("assets/fonts/GolosText.ttf") format("truetype"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Oswald"; src: url("assets/fonts/Oswald.ttf") format("truetype"); font-weight: 200 700; font-display: swap; }

:root {
  --green: #173e36;
  --green-soft: #24564b;
  --green-ink: #e8efe4;
  --ink: #1b302b;
  --muted: #56635e;
  --bg: #eef1ec;
  --surface: #ffffff;
  --field: #f8faf5;
  --stone: #eeeee8;
  --line: #dbe0d8;
  --line-strong: #b7c0b8;
  --lime: #d5e9a2;
  --lime-soft: #eef5dc;
  --lime-line: #c3dc86;
  --focus: #52763e;
  --warn-bg: #fbf0d6;
  --warn-ink: #6b4800;
  --danger-bg: #fbe7e3;
  --danger-ink: #8e2a1c;
  --note-bg: #f3f0e7;
  --note-line: #cfc4a6;
  --r-btn: 12px;
  --r-field: 10px;
  --r-card: 14px;
  --sidebar: 240px;
  --gutter: 28px;
  --shadow: 0 1px 2px rgb(23 62 54 / 6%), 0 8px 24px rgb(23 62 54 / 8%);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 15px/1.45 "Golos", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
.icon { flex-shrink: 0; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--surface); padding: 10px 14px; border-radius: var(--r-btn); }
.skip-link:focus { top: 12px; }
.noscript { padding: 24px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sidebar :focus-visible, .btn-primary:focus-visible { outline-color: var(--lime); }
.btn-primary:focus-visible { outline-color: var(--focus); }

/* ---------- shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100vh;
  height: var(--vvh, 100dvh);
}
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.main:focus { outline: none; }

.sidebar {
  background: var(--green);
  color: var(--green-ink);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 18px;
  gap: 26px;
  min-height: 0;
  overflow: auto;
}
.brand { display: inline-flex; align-items: flex-end; gap: 7px; padding: 0 10px; color: inherit; border-radius: 8px; }
.brand-sv { font: 600 34px/0.9 "Oswald", sans-serif; letter-spacing: -0.5px; color: #fff; }
.brand-rest { display: flex; flex-direction: column; line-height: 1.1; padding-bottom: 1px; }
.brand-rest span { font-weight: 600; font-size: 15px; color: #fff; }
.brand-rest small { font-size: 12px; opacity: .75; }

.side-nav ul { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 46px; padding: 0 12px; border-radius: var(--r-btn);
  font-weight: 500; color: var(--green-ink);
}
.nav-item:hover { background: rgb(255 255 255 / 8%); }
.nav-item[aria-current="page"] { background: var(--lime); color: var(--green); font-weight: 600; }
.nav-badge { margin-left: auto; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--lime); color: var(--green); font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.nav-item[aria-current="page"] .nav-badge { background: var(--green); color: var(--lime); }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.side-role { display: grid; gap: 2px; padding: 0 12px; font-size: 13px; }
.side-role-label { opacity: .7; }
.side-role-name { font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar { display: none; }
.bottom-nav { display: none; }

.training-strip {
  padding: 7px var(--gutter);
  font-size: 13px;
  background: var(--lime-soft);
  border-bottom: 1px solid var(--lime-line);
  color: var(--ink);
}
.strip-short { display: none; }

/* ---------- buttons, fields, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-btn);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 600; font-size: 15px; line-height: 1.2; text-align: center; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-soft); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--green); }
.btn-quiet { color: var(--ink); padding: 0 12px; }
.btn-quiet:hover:not(:disabled) { background: var(--stone); }
.btn-on-dark { justify-content: flex-start; color: var(--green-ink); border-color: rgb(255 255 255 / 22%); }
.btn-on-dark:hover { background: rgb(255 255 255 / 8%); }
.btn-small { min-height: 40px; padding: 0 12px; font-size: 14px; }
@media (pointer: coarse) { .btn-small { min-height: 44px; } }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0;
  border: 1px solid transparent; border-radius: var(--r-btn); background: none; cursor: pointer; color: var(--ink);
}
.icon-btn:hover:not(:disabled) { background: var(--stone); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn-small { width: 36px; height: 36px; }
@media (pointer: coarse) { .icon-btn-small { width: 44px; height: 44px; } }

.input, .select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font-size: 16px; line-height: 1.4;
  border: 1px solid var(--line-strong); border-radius: var(--r-field);
  background: var(--surface);
}
.input:focus, .select:focus, textarea:focus { border-color: var(--green); }
.input-lg { min-height: 50px; }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 42px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%231b302b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 15px center / 12px 8px;
}
.chip {
  display: inline-flex; align-items: center; min-height: 24px; padding: 2px 9px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.2;
  background: var(--stone); color: var(--ink); white-space: nowrap;
}
.chip-new { background: var(--lime); color: var(--green); }
.chip-warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip-muted { background: var(--stone); color: var(--muted); }

/* ---------- pages ---------- */
.page { padding: 28px var(--gutter) 40px; max-width: 1240px; }
.page-head { display: grid; gap: 4px; margin-bottom: 22px; }
.page-head h1, .ws-title h1, .empty-page h1 { font: 500 30px/1.12 "Oswald", sans-serif; letter-spacing: 0.1px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: none; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.empty { color: var(--muted); padding: 14px 0; }
.empty-block { padding: 28px 0; display: grid; gap: 6px; }
.state-title { font-weight: 600; font-size: 16px; }
.empty-page { display: grid; gap: 14px; justify-items: start; }

/* journal */
.journal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.journal-main { display: grid; gap: 10px; }
.journal-main .section-title { margin-bottom: 0; }
.event {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
}
.event-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--stone); color: var(--green); }
.event-body { display: grid; gap: 3px; min-width: 0; }
.event-object { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.event-quote { color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.event-meta { font-size: 13px; color: var(--muted); }
.event-lead { background: var(--lime-soft); border-color: var(--lime-line); padding: 20px; grid-template-columns: 44px minmax(0, 1fr) auto; }
.event-lead .event-icon { background: var(--lime); width: 44px; height: 44px; }
.event-lead .event-title { font-size: 19px; }
.journal-side { display: grid; gap: 26px; position: sticky; top: 0; }
.journal-side section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; }
.journal-side .section-title { margin-top: 0; }
.mini-list { display: grid; }
.mini-list li { border-top: 1px solid var(--line); }
.mini-list li:first-child { border-top: 0; }
.mini-list a, .mini-list li > .mini-title:first-child { display: grid; gap: 2px; padding: 10px 0; }
.mini-list li { display: grid; gap: 2px; }
.mini-list li:has(> .mini-title) { padding: 10px 0; }
.mini-list a { justify-items: start; }
.mini-list a:hover .mini-title { color: var(--green-soft); }
.mini-title { font-weight: 600; overflow-wrap: anywhere; }
.mini-meta { font-size: 13px; color: var(--muted); }

/* objects */
.object-list { display: grid; gap: 10px; }
.object-row {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 18px; align-items: center;
  padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
}
.object-row:hover { border-color: var(--line-strong); }
.object-main, .object-step { display: grid; gap: 3px; min-width: 0; }
.object-title { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.object-meta, .object-step small { font-size: 13px; color: var(--muted); }

/* documents */
.search-row { position: relative; display: flex; align-items: center; max-width: 620px; }
.search-row .icon { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search-row .input { padding-left: 44px; }
.page > .muted.small { margin: 8px 0 18px; }
.doc-results { display: grid; gap: 10px; max-width: 820px; }
.doc-list { display: grid; gap: 8px; }
.doc-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 14px; align-items: center;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
}
.doc-row:hover { border-color: var(--line-strong); }
.doc-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; display: block; }
.doc-icon { width: 56px; height: 56px; border-radius: 10px; background: var(--stone); color: var(--green); display: grid; place-items: center; align-content: center; gap: 2px; }
.doc-icon small { font-size: 10.5px; font-weight: 700; letter-spacing: .3px; }
.doc-text { display: grid; gap: 2px; min-width: 0; }
.doc-title { font-weight: 600; overflow-wrap: anywhere; }
.doc-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.doc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
.doc-badges:empty { display: none; }

/* notifications */
.notice { display: flex; gap: 12px; align-items: flex-start; max-width: 820px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); margin-bottom: 18px; }
.notice .icon { color: var(--green); margin-top: 1px; }
.notify-list { display: grid; gap: 8px; max-width: 820px; }
.notify-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.notify-main { display: grid; gap: 2px; min-width: 0; }
.notify-event { font-weight: 600; }
.notify-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.notify-status { display: grid; justify-items: end; gap: 4px; font-size: 13px; color: var(--muted); }

/* ---------- workspace ---------- */
body[data-view="object"] .main { overflow: hidden; display: flex; flex-direction: column; }
.ws { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ws-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(260px, 380px); gap: 8px 18px; align-items: start;
  padding: 16px var(--gutter) 16px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.ws-back { margin-top: 0; }
.ws-title { display: grid; gap: 6px; min-width: 0; padding-top: 4px; }
.ws-title h1 { font-size: 26px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ws-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13.5px; color: var(--muted); }
.ws-meta span { overflow-wrap: anywhere; }
.step {
  display: flex; gap: 8px; align-items: flex-start; justify-content: space-between;
  padding: 10px 10px 10px 14px; border-radius: var(--r-card); background: var(--field); border: 1px solid var(--line);
}
.step-body { display: grid; gap: 3px; min-width: 0; }
.step-label { display: flex; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.step-text { font-weight: 600; overflow-wrap: anywhere; }
.step-edit { display: grid; gap: 8px; width: 100%; }
.step-conflict { display: grid; gap: 8px; padding: 10px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r-field); }
.step-conflict blockquote { margin: 0; padding: 8px 10px; background: var(--surface); color: var(--ink); border-radius: 8px; }
.state-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.ws-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr); }
.ws-main { min-height: 0; overflow: auto; padding: 18px var(--gutter) 28px; border-right: 1px solid var(--line); overscroll-behavior: contain; }
.ws-main:has(.viewer) { padding: 0; overflow: hidden; }
.ws-main:has(.viewer) > .pane { height: 100%; }
.pane-head { display: flex; align-items: baseline; gap: 10px; }
.pane-head h2, .chat-head h2 { font-size: 16px; font-weight: 600; }
.pane-foot { font-size: 13px; }

.ws-chat { min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.chat-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 14px 20px 10px; border-bottom: 1px solid var(--line); }
.chat-head .muted { font-size: 13px; }
.thread-wrap { position: relative; flex: 1; min-height: 0; }
.thread {
  height: 100%; overflow: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 16px 20px 20px;
}
.thread > * { flex-shrink: 0; }
.thread:focus { outline: none; }
.thread-day { align-self: flex-start; font-size: 12.5px; font-weight: 600; color: var(--muted); padding-top: 8px; }
.msg { max-width: min(560px, 86%); padding: 10px 14px 12px; border-radius: 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; background: var(--field); border: 1px solid var(--line); align-self: flex-start; }
.msg-mine { align-self: flex-end; background: var(--lime-soft); border-color: var(--lime-line); }
.msg-internal { align-self: stretch; max-width: none; background: var(--note-bg); border: 1px dashed var(--note-line); }
.msg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: 12.5px; color: var(--muted); }
.msg-author { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.msg-flag { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: #5d5030; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-notify { font-size: 12.5px; color: var(--muted); }
.msg-audio { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.msg-audio audio { width: 100%; max-width: 320px; height: 40px; }
.msg-arrived { animation: arrive 1.6s ease-out; }
@keyframes arrive { from { box-shadow: 0 0 0 3px var(--lime); } to { box-shadow: 0 0 0 0 transparent; } }
.ref-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 34px; padding: 4px 10px;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--line-strong);
  font-size: 13.5px; font-weight: 500; cursor: pointer; justify-self: start; text-align: left;
}
.ref-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-chip:hover { border-color: var(--green); }
@media (pointer: coarse) { .ref-chip { min-height: 44px; } }
.new-pill { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--green); color: #fff; font-weight: 600; box-shadow: var(--shadow); cursor: pointer; }

/* composer */
.composer { border-top: 1px solid var(--line); padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 8px; background: var(--surface); }
.composer[data-target="internal"] { background: var(--note-bg); }
.composer-targets { display: grid; grid-template-columns: 1fr 1fr; gap: 0; padding: 3px; border-radius: var(--r-btn); background: var(--stone); }
.target { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 10px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted); }
.target input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.target:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(23 62 54 / 14%); }
.target-internal:has(input:checked) { background: var(--green); color: #fff; }
.target:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }
.target:has(input:disabled) { cursor: not-allowed; opacity: .6; }
@media (pointer: coarse) { .target { min-height: 44px; } }
.composer-hint { font-size: 13px; color: var(--muted); }
/* The client destination is named by the switch, the placeholder and «Получит: …»; the internal note keeps its warning. */
.composer[data-target="client"] .composer-hint { display: none; }
.composer-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.composer-ref { display: flex; align-items: center; gap: 4px; min-width: 0; }
.composer-ref .ref-chip { min-width: 0; flex: 0 1 auto; }
.composer-ref[hidden], .composer-voice[hidden], .composer-error[hidden] { display: none; }
.composer-text { resize: none; min-height: 76px; max-height: 220px; }
.composer[data-target="internal"] .composer-text { background: #fffdf7; border-color: var(--note-line); }
.composer-row { display: flex; align-items: center; gap: 10px; }
.composer-status { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); }
.composer-send { margin-left: auto; }
.composer-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 9px 12px; border-radius: var(--r-field); background: var(--danger-bg); color: var(--danger-ink); font-size: 14px; }
.clip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 10px; border-radius: var(--r-field); background: var(--surface); border: 1px solid var(--line-strong); }
.clip audio { height: 40px; flex: 1 1 200px; min-width: 0; }
.clip-label { font-size: 14px; font-weight: 600; }
.clip-dest { font-size: 13px; }
.clip-live { border-color: var(--danger-ink); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #c0392b; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* viewer */
.viewer { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); }
.viewer-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.viewer-title { display: grid; gap: 2px; min-width: 0; }
.viewer-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.ws-main { container-type: inline-size; }
/* Next to the conversation the document pane is narrow: actions go under the title. */
@container (max-width: 820px) {
  .viewer-head { grid-template-columns: auto minmax(0, 1fr); }
  .viewer-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.viewer-title h2 { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title .muted { font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.viewer-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.viewer-version { min-width: 0; flex: 0 1 300px; }
.viewer-version .select { min-height: 44px; font-size: 16px; }
.viewer-version-one { font-size: 14px; color: var(--muted); }
.viewer-pager, .viewer-zoomer { display: flex; align-items: center; gap: 2px; }
.viewer-pager[hidden], .viewer-zoomer[hidden] { display: none; }
.viewer-zoomer { margin-left: auto; }
.viewer-page, .viewer-zoom-value { min-width: 64px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.viewer-zoom-value { min-width: 48px; }
.viewer-note { padding: 8px 16px; font-size: 13.5px; background: var(--lime-soft); border-bottom: 1px solid var(--lime-line); }
.viewer-body { position: relative; flex: 1; min-height: 0; }
.viewer-canvas { height: 100%; overflow: auto; padding: 12px; background: #e4e8e2; overscroll-behavior: contain; }
.viewer-canvas:focus-visible { outline-offset: -3px; }
.pdf-page { display: block; margin: 0 auto; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 14%); }
.doc-image { display: block; width: 100%; height: auto; margin: 0 auto; border-radius: 6px; }
.viewer-skeleton { width: min(100%, 640px); aspect-ratio: 1 / 1.414; margin: 0 auto; background: #f4f6f2; border-radius: 4px; }
.viewer-status { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); padding: 6px 12px; border-radius: 999px; background: var(--surface); font-size: 13px; box-shadow: var(--shadow); }
.viewer-status:empty { display: none; }
.viewer-state { max-width: 440px; margin: 40px auto; padding: 24px; background: var(--surface); border-radius: var(--r-card); display: grid; gap: 10px; justify-items: start; color: var(--ink); }
.viewer-state > .icon { color: var(--green); }
.viewer-strip { display: flex; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); overflow-x: auto; border-top: 1px solid var(--line); }
.strip-item { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; max-width: 220px; min-height: 52px; padding: 5px 10px 5px 5px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; }
.strip-item[aria-current="true"] { border-color: var(--green); background: var(--lime-soft); }
.strip-item img, .strip-icon { width: 40px; height: 40px; border-radius: 7px; object-fit: cover; flex-shrink: 0; }
.strip-icon { display: grid; place-items: center; background: var(--stone); color: var(--green); }
.strip-text { display: grid; font-size: 13px; font-weight: 500; line-height: 1.25; min-width: 0; }
.strip-text { overflow: hidden; }
.strip-text > :first-child, .strip-text { white-space: nowrap; text-overflow: ellipsis; }
.strip-text small { color: var(--muted); font-weight: 400; }

/* training dialog, toast */
.training { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 48px); padding: 20px; border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.training::backdrop { background: rgb(16 34 30 / 45%); }
.training[open] { display: grid; gap: 14px; }
.training-head { display: flex; align-items: center; justify-content: space-between; }
.training-head h2 { font: 500 24px/1.1 "Oswald", sans-serif; }
.training fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.training legend { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-field); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--green); background: var(--lime-soft); }
.choice input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--green); flex-shrink: 0; }
.choice > span { display: grid; gap: 2px; min-width: 0; }
.choice-label { font-weight: 600; overflow-wrap: anywhere; }
.choice small { font-size: 13px; color: var(--muted); }
.training-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 10px 12px 10px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 14px; }
.toast[hidden] { display: none; }
.toast-action { min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--lime); color: var(--green); font-weight: 700; cursor: pointer; }

/* sign-in */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); overflow: auto; background: var(--green); }
body[data-view="login"] { overflow: auto; }
.login-card { width: min(440px, 100%); display: grid; gap: 14px; padding: 28px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h1 { font: 500 30px/1.12 "Oswald", sans-serif; }
.brand.brand-login { color: var(--green); padding: 0; margin-bottom: 4px; flex-direction: row; align-items: flex-end; justify-self: start; gap: 7px; }
.brand-login .brand-rest { align-items: flex-start; }
.brand-login .brand-rest small { display: block; }
.brand-login .brand-sv, .brand-login .brand-rest span { color: var(--green); }
.brand-login .brand-rest small { color: var(--muted); opacity: 1; }
.login-form form, .login-step { display: grid; gap: 10px; }
.field { font-size: 14px; font-weight: 600; }
.btn-wide { width: 100%; min-height: 50px; }
.login-email { font-weight: 600; overflow-wrap: anywhere; }
.login-message:empty { display: none; }
.login-note { padding: 10px 12px; border-radius: var(--r-field); background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; margin-bottom: 4px; }
.login-message { padding: 10px 12px; border-radius: var(--r-field); background: var(--lime-soft); font-size: 14px; }
.login-message.is-error { background: var(--danger-bg); color: var(--danger-ink); }
.code-input { letter-spacing: 6px; font-variant-numeric: tabular-nums; }
.login .state-actions .btn { padding: 0 10px; }
.training-strip[hidden] { display: none; }

/* ---------- CRM and portal (22.10) ---------- */
.chip-done { background: #e3efe6; color: #1e5a3c; }
.chip-danger { background: var(--danger-bg); color: var(--danger-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.is-late { color: var(--danger-ink) !important; font-weight: 600; }
.btn-danger { background: var(--danger-ink); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #74200f; }
.btn-danger-text { color: var(--danger-ink); }
.btn[aria-busy="true"] { cursor: progress; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
.row-end { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-size: 14.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--green); margin: 0; flex-shrink: 0; }
.check-list { display: grid; gap: 2px; }
.page-narrow { max-width: 760px; }
.page > section + section, .page > details + section { margin-top: 18px; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back-link { margin: -6px 0 8px -12px; }
.side-role { text-decoration: none; border-radius: 10px; padding: 8px 12px; }
.side-role:hover { background: rgb(255 255 255 / 8%); }
.side-role-link { font-size: 12.5px; opacity: .75; }
.topbar-role { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border-radius: 10px; color: var(--green-ink); }

/* toolbar and filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar .search-row { flex: 1 1 320px; max-width: none; }
.toolbar .select { width: auto; min-width: 190px; flex: 0 1 220px; }
.filter-tabs { display: flex; gap: 4px; margin: 4px 0 14px; overflow-x: auto; scrollbar-width: none; }
.filter-tab { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.filter-tab[aria-selected="true"] { background: var(--green); border-color: var(--green); color: #fff; }

/* leads */
.rows { display: grid; gap: 8px; }
.lead-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 300px); gap: 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.lead-row:hover { border-color: var(--line-strong); }
.lead-row-main, .lead-row-side { display: grid; gap: 4px; min-width: 0; align-content: start; }
.lead-row-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-ref { font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.lead-row-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.lead-row-text { color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.lead-row-side { font-size: 13px; color: var(--muted); }
.lead-page { max-width: 1240px; }
.lead-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px 24px; align-items: start; margin-bottom: 18px; }
.lead-title { display: grid; gap: 6px; min-width: 0; }
.lead-title h1 { font: 500 28px/1.12 "Oswald", sans-serif; overflow-wrap: anywhere; }
.lead-kicker { font-size: 13px; color: var(--muted); }
.contact-card { display: grid; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); min-width: 240px; }
.contact-line { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 600; font-size: 16px; color: var(--green); overflow-wrap: anywhere; }
.contact-meta { font-size: 13.5px; color: var(--muted); }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.lead-main { display: grid; gap: 14px; min-width: 0; }
.lead-side { position: sticky; top: 0; }
.request-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15.5px; }
.transcript { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.transcript li { display: grid; gap: 2px; padding: 8px 12px; border-radius: 12px; background: var(--field); max-width: 92%; }
.transcript .t-human { justify-self: end; background: var(--lime-soft); }
.t-author { font-size: 12px; font-weight: 700; color: var(--muted); }
.timeline { margin: 0; padding: 0; list-style: none; display: grid; gap: 0; }
.tl { display: grid; gap: 2px; padding: 9px 0 9px 16px; border-left: 2px solid var(--line); position: relative; }
.tl::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.tl-note { background: var(--note-bg); border-radius: 0 10px 10px 0; padding-right: 12px; }
.tl-note::before { background: var(--note-line); }
.tl-created::before, .tl-converted::before { background: var(--green); }
.tl-meta { font-size: 12.5px; color: var(--muted); }
.tl-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-box { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.note-box textarea { background: #fffdf7; border-color: var(--note-line); }
.work-panel { display: grid; gap: 10px; }
.work-panel .form-field { gap: 4px; }
.close-box { display: grid; gap: 8px; }
.close-box[hidden] { display: none; }
.panel-subtitle { font-size: 14px; font-weight: 600; }
.task-mini { display: grid; gap: 6px; }
.task-mini li { display: grid; gap: 1px; }

/* panels and forms */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-content: start; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-head .btn:last-child, .pane-action { margin-left: auto; }
.panel-title { font-size: 15px; font-weight: 700; }
.panel-details > summary { cursor: pointer; font-weight: 700; min-height: 32px; display: flex; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.form-field > label, .field-label { font-size: 13.5px; font-weight: 600; }
.form-field-wide { grid-column: 1 / -1; }
.form-field > .btn { justify-self: start; }
.field-hint { font-size: 12.5px; color: var(--muted); }
.form-error { padding: 9px 12px; border-radius: var(--r-field); background: var(--danger-bg); color: var(--danger-ink); font-size: 14px; }
.form-error[hidden] { display: none; }
.inline-field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
input[type="date"].input, input[type="datetime-local"].input { min-height: 44px; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r-btn); background: var(--stone); }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(23 62 54 / 14%); }

/* dialogs */
.sheet { width: min(620px, calc(100% - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overflow: auto; }
.sheet::backdrop { background: rgb(16 34 30 / 45%); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 14px 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-head h2 { font: 500 22px/1.15 "Oswald", sans-serif; overflow-wrap: anywhere; }
.sheet-form { display: grid; gap: 14px; padding: 16px 20px calc(18px + env(safe-area-inset-bottom)); }
.sheet-intro { font-size: 14px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.copy-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.copy-input { font-size: 14px; font-family: ui-monospace, Menlo, monospace; }

/* files and uploads */
.upload-list, .file-list, .composer-files { display: grid; gap: 6px; }
.upload-list:empty, .composer-files:empty { display: none; }
.upload-item, .composer-file { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--r-field); border: 1px solid var(--line); background: var(--field); font-size: 14px; min-width: 0; }
.upload-item.is-error, .composer-file.is-error { border-color: #e5b4aa; background: var(--danger-bg); color: var(--danger-ink); }
.upload-name { min-width: 0; flex: 1 1 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.upload-state { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.is-error .upload-state { color: var(--danger-ink); }
.file-row { display: flex; align-items: center; gap: 6px; }
.file-open { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-field); background: var(--surface); cursor: pointer; text-align: left; }
.file-open:hover { border-color: var(--green); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* workspace: tabs, rail, panes */
.ws-tabs { display: flex; gap: 2px; padding: 0 calc(var(--gutter) - 8px); background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ws-tabs::-webkit-scrollbar { display: none; }
.ws-tabs button { display: flex; align-items: center; gap: 7px; min-height: 46px; padding: 0 12px; border: 0; border-bottom: 3px solid transparent; background: none; font-weight: 600; font-size: 14.5px; color: var(--muted); cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.ws-tabs button:hover { color: var(--ink); }
.ws-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--green); }
.tab-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--lime); color: var(--green); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.tab-count[hidden] { display: none; }
.ws-rail { display: grid; gap: 4px; margin-top: 2px; max-width: 520px; border-radius: 8px; }
.ws-rail[hidden] { display: none; }
.rail-label { font-size: 13px; font-weight: 600; color: var(--green-soft); }
.rail { display: flex; gap: 3px; height: 8px; }
.rail-compact { height: 6px; max-width: 260px; margin: 4px 0 2px; }
.rail-seg { flex: 1; border-radius: 3px; background: var(--stone); box-shadow: inset 0 0 0 1px var(--line); }
.rail-done { background: var(--green); box-shadow: none; }
.rail-active { background: var(--lime); box-shadow: inset 0 0 0 1.5px var(--green); }
.object-stage { font-size: 13px; color: var(--muted); }
.object-flags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.object-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; }
.object-step > span { display: grid; gap: 2px; }
.step-label.is-late { color: var(--danger-ink); }
.ws-loading { padding: 28px var(--gutter); }
.pane { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; }
.pane-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pane-head h2 { font-size: 17px; font-weight: 700; }
.docs-pane { display: flex; flex-direction: column; gap: 12px; }
.doc-row-compact { grid-template-columns: 44px minmax(0, 1fr); padding: 8px 10px; }
.doc-row-compact img, .doc-row-compact .doc-icon { width: 44px; height: 44px; }

/* overview */
.ov-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.ov-now { grid-column: 1 / -1; }
.ov-stage { display: grid; gap: 2px; }
.ov-stage-title { font: 500 24px/1.15 "Oswald", sans-serif; color: var(--green); }
.ov-events { display: grid; gap: 6px; }
.ov-events li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 4px 8px; align-items: start; font-size: 14.5px; }
.ov-events li > .icon { color: var(--green); margin-top: 3px; }
.ov-events li > .chip { grid-column: 2; justify-self: start; }
.ov-wait.is-active { border-color: var(--lime-line); background: var(--lime-soft); }
.ov-list { display: grid; gap: 4px; }
.ov-list li > a, .ov-list li > span { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.ov-list li:first-child > a, .ov-list li:first-child > span { border-top: 0; padding-top: 0; }
.ov-docs { display: grid; gap: 6px; }
.ov-report { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: center; }
.ov-report img { width: 112px; height: 80px; object-fit: cover; border-radius: 10px; background: var(--stone); }
.ov-report-text { display: grid; gap: 2px; }
.ov-chat-link { justify-self: start; }
.panel > .btn-quiet.btn-small { justify-self: start; margin-left: -10px; }

/* plan */
.stages { margin: 0; padding: 0; list-style: none; display: grid; }
.stage { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; position: relative; }
.stage + .stage { border-top: 1px solid var(--line); }
.stage-mark { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; margin-top: 1px; background: var(--surface); }
.stage-done .stage-mark { background: var(--green); border-color: var(--green); color: #fff; }
.stage-active .stage-mark { border-color: var(--green); background: var(--lime); }
.stage-body { display: grid; gap: 3px; min-width: 0; }
.stage-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage-title { font-weight: 600; overflow-wrap: anywhere; }
.stage-done .stage-title { color: var(--muted); }
.stage-note { font-size: 14px; }
.event-list { display: grid; gap: 0; }
.event-item { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.event-item:first-child { border-top: 0; }
.event-item.is-off { opacity: .6; }
.event-when { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.event-what { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.past > summary { cursor: pointer; color: var(--muted); font-size: 14px; min-height: 36px; display: flex; align-items: center; }

/* tasks */
.task-list { display: grid; }
.task-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; border-top: 1px solid var(--line); }
.task-row:first-child { border-top: 0; }
.task-check { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; }
.task-check input { width: 20px; height: 20px; accent-color: var(--green); }
.task-text { display: grid; gap: 2px; padding: 8px 4px; border: 0; background: none; text-align: left; cursor: pointer; min-width: 0; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task-row.is-done .task-title { color: var(--muted); text-decoration: line-through; }

/* people and team */
.person-list { display: grid; gap: 8px; }
.person-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.panel .person-row { padding: 10px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; }
.panel .person-row:first-child { border-top: 0; }
.person-row.is-off { opacity: .7; }
.person-main { display: grid; gap: 2px; min-width: 0; }
.person-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.person-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.person-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rights { margin-bottom: 18px; max-width: 820px; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.rights-table { border-collapse: collapse; width: 100%; min-width: 420px; font-size: 14px; }
.rights-table th, .rights-table td { text-align: left; padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.rights-table thead th { border-top: 0; color: var(--muted); font-size: 13px; }
.device-list { display: grid; gap: 8px; }
.device-row { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.device-row:first-child { border-top: 0; }
.device-row > span { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.menu-list { display: grid; gap: 8px; }
.menu-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); font-weight: 600; }

/* reports */
.report-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.report { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.report-draft { border-style: dashed; border-color: var(--note-line); background: #fffdf7; }
.report-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.report-head h3 { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.report-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.photo { margin: 0; display: grid; gap: 4px; }
.photo-open { display: block; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: zoom-in; background: var(--stone); aspect-ratio: 4 / 3; }
.photo-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo figcaption { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.report-editor { gap: 14px; }
.edit-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 4px; }
.edit-photos:empty { display: none; }
.edit-photo { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); position: relative; }
.edit-photo img { grid-column: 1 / -1; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--stone); }
.edit-photo .input { min-height: 40px; font-size: 14px; padding: 6px 10px; }
.edit-photo-state { position: absolute; left: 12px; top: 12px; padding: 3px 8px; border-radius: 999px; background: rgb(0 0 0 / 60%); color: #fff; font-size: 12.5px; }
.edit-photo.is-error { border-color: #e5b4aa; }
.preview-frame { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-card); background: var(--bg); border: 1px dashed var(--line-strong); }
.preview-label { font-size: 13px; font-weight: 700; color: var(--green); }
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0f1a17; color: #fff; display: none; }
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.lightbox::backdrop { background: #0f1a17; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 10px 8px 16px; }
.lightbox-count { font-size: 14px; opacity: .8; font-variant-numeric: tabular-nums; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgb(255 255 255 / 12%); }
.lightbox-stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 0 8px; min-height: 0; }
.lightbox-img { grid-column: 2; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; min-height: 0; }
.lightbox-caption { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); text-align: center; font-size: 14px; opacity: .9; min-height: 20px; }

/* decisions */
.decision-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.decision { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.decision-open { border-color: var(--lime-line); box-shadow: inset 4px 0 0 var(--lime); }
.decision-changes_requested { border-color: #e9d29b; box-shadow: inset 4px 0 0 #e2b84f; }
.decision-cancelled { opacity: .65; }
.decision.is-target { outline: 3px solid var(--focus); outline-offset: 2px; }
.decision-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.decision-head h3 { font-size: 16.5px; font-weight: 700; overflow-wrap: anywhere; }
.decision-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.decision-answer { padding: 10px 12px; border-radius: var(--r-field); background: var(--field); display: grid; gap: 6px; font-size: 14px; }
.decision-answer blockquote { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; }

/* conversation extras */
.msg-files { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-file { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 36px; padding: 4px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-strong); font-size: 13.5px; cursor: pointer; text-align: left; }
.msg-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.msg-file small { color: var(--muted); }
.msg-file-image { padding: 0; overflow: hidden; border-radius: 10px; }
.msg-file-image img { display: block; width: 120px; height: 90px; object-fit: cover; background: var(--stone); }
.msg-system { opacity: .9; }
.composer-attach span, .composer-mic span { font-size: 14px; }
.ws-chat { container-type: inline-size; }
/* A narrow conversation column (tablets, 1024 px): icon buttons, the status takes its own line. */
@container (max-width: 470px) {
  .composer-mic span, .composer-attach span, .target .icon { display: none; }
  .composer-mic, .composer-attach { width: 44px; padding: 0; }
  .composer-row { flex-wrap: wrap; }
  .composer-status { order: 5; flex-basis: 100%; }
  .target { padding: 0 6px; font-size: 13.5px; }
}
.clip-note { flex-basis: 100%; font-size: 12.5px; color: var(--muted); }

/* notices */
.notify-row.is-unread { border-color: var(--lime-line); box-shadow: inset 4px 0 0 var(--lime); }
.notify-main:hover .notify-event { color: var(--green-soft); }
.notify-status { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; }
.event-warn .event-icon { background: var(--warn-bg); color: var(--warn-ink); }
.login-loading { text-align: center; }

/* ---------- medium widths: rail sidebar ---------- */
@media (max-width: 1279px) {
  .ws-head { grid-template-columns: auto minmax(0, 1fr); }
  .step { grid-column: 1 / -1; }
}
@media (max-width: 1199px) {
  :root { --sidebar: 92px; --gutter: 22px; }
  .sidebar { padding: 18px 8px; align-items: stretch; gap: 20px; }
  .brand { flex-direction: column; align-items: center; padding: 0; gap: 0; }
  .brand-rest small { display: none; }
  .brand-rest { align-items: center; }
  .nav-item { flex-direction: column; justify-content: center; gap: 4px; min-height: 62px; padding: 6px 4px; font-size: 12px; text-align: center; position: relative; }
  .nav-badge { position: absolute; top: 4px; right: 12px; margin: 0; min-width: 20px; height: 20px; font-size: 12px; }
  .side-role { display: none; }
  .btn-on-dark { flex-direction: column; gap: 4px; padding: 8px 4px; font-size: 12px; white-space: normal; min-height: 62px; justify-content: center; }
  .journal-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
  .target .icon { display: none; }
}
@media (max-height: 820px) and (min-width: 768px) {
  .composer-text { min-height: 54px; }
  .chat-head { padding: 8px 20px; }
  .chat-head .muted { display: none; }
  .ws-head { padding-top: 10px; padding-bottom: 10px; }
}
@media (max-width: 979px) {
  /* Tablets and phones are touch devices even when an emulator reports a mouse: 44 px targets. */
  .ref-chip, .btn-small { min-height: 44px; }
  .icon-btn-small { width: 44px; height: 44px; }
  .ws-grid { grid-template-columns: minmax(0, 1fr); }
  .ws[data-pane="chat"] .ws-main, .ws:not([data-pane="chat"]) .ws-chat { display: none; }
  .ws-main { border-right: 0; }
  .journal-grid { grid-template-columns: minmax(0, 1fr); }
  .journal-side { position: static; grid-template-columns: 1fr 1fr; gap: 14px; }
  .object-row { grid-template-columns: minmax(0, 1fr) auto; }
  .object-step { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- phone ---------- */
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px 16px;
    background: var(--green); color: var(--green-ink);
  }
  .topbar .brand { flex-direction: row; align-items: flex-end; gap: 6px; }
  .topbar .brand-sv { font-size: 28px; }
  .topbar .brand-rest small { display: block; }
  .topbar-role { margin-left: auto; font-size: 13px; opacity: .8; }
  .topbar-training { color: var(--green-ink); padding: 0 10px; }
  .topbar-training:hover { background: rgb(255 255 255 / 10%) !important; }
  .topbar-training span { font-size: 14px; }
  .topbar :focus-visible { outline-color: var(--lime); }
  .training-strip { padding: 6px var(--gutter); font-size: 12.5px; }
  .strip-long { display: none; }
  .strip-short { display: inline; }

  .bottom-nav { display: block; grid-column: 1; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav ul { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .bottom-nav .nav-item { flex-direction: column; justify-content: center; gap: 3px; min-height: 60px; padding: 6px 2px; border-radius: 0; font-size: 12px; color: var(--muted); position: relative; }
  .bottom-nav .nav-item:hover { background: none; }
  .bottom-nav .nav-item[aria-current="page"] { background: none; color: var(--green); }
  .bottom-nav .nav-item[aria-current="page"] .icon { background: var(--lime); border-radius: 10px; box-sizing: content-box; padding: 2px 12px; }
  .bottom-nav .nav-badge { position: absolute; top: 4px; left: calc(50% + 10px); margin: 0; min-width: 20px; height: 20px; font-size: 11.5px; background: var(--green); color: #fff; }
  body[data-view="object"] .bottom-nav { display: none; }

  .page { padding: 20px var(--gutter) 28px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 26px; }
  .event, .event-lead { grid-template-columns: 36px minmax(0, 1fr); padding: 14px; gap: 12px; }
  .event-icon, .event-lead .event-icon { width: 36px; height: 36px; border-radius: 10px; }
  .event-action { grid-column: 1 / -1; width: 100%; }
  .event-lead .event-title { font-size: 18px; }
  .journal-side { grid-template-columns: minmax(0, 1fr); }
  .object-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .object-step { grid-row: auto; }
  .notify-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .notify-status { justify-items: start; display: flex; gap: 8px; align-items: center; }

  .ws-head { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 6px var(--gutter) 12px; }
  .ws-back { justify-self: start; margin-left: -10px; }
  .ws-title { padding-top: 0; gap: 4px; }
  .ws-title h1 { font-size: 21px; line-height: 1.18; }
  .ws-meta { font-size: 13px; gap: 2px 10px; }
  .ws-place { display: none; }
  .step { padding: 8px 6px 8px 12px; }
  .ws-tabs { padding: 0 6px; }
  .chat-head { display: none; }
  /* Phone: the object page scrolls as a whole — header scrolls away, tabs stay on top, the composer
     stays at the bottom. Works on short screens (320×568) where fixed panes would leave no room. */
  body[data-view="object"] .main { overflow: auto; display: block; }
  body[data-view="object"] .ws, body[data-view="object"] .ws-grid { display: block; }
  .ws[data-pane="chat"] .ws-chat { display: block; }
  .ws-tabs { position: sticky; top: 0; z-index: 6; }
  .thread-wrap { position: static; }
  .thread { height: auto; overflow: visible; min-height: 30vh; }
  .composer { position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -6px 16px rgb(23 62 54 / 6%); }
  .new-pill { position: fixed; bottom: calc(var(--composer-h, 170px) + 10px); z-index: 7; }
  .thread { padding: 12px var(--gutter) 16px; }
  .msg { max-width: 92%; }
  .ws-main { padding: 14px var(--gutter) 24px; overflow: visible; }
  .composer { padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom)); gap: 7px; }
  .composer-text { min-height: 54px; }
  .composer-hint { font-size: 12.5px; }
  .composer-status { font-size: 12px; }
  .composer-mic span { display: none; }
  .event { align-items: start; }
  .step-text { font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* Typing with the on-screen keyboard: keep the title, fold the rest of the header. */
  body.composing[data-view="object"] .training-strip,
  body.composing .ws-meta,
  body.composing .ws-head .step,
  body.composing .ws-back,
  body.composing .composer-hint { display: none; }
  body.composing .ws-head { padding-top: 8px; padding-bottom: 8px; }
  body.composing .ws-title h1 { font-size: 17px; -webkit-line-clamp: 1; }
  .composer-mic { width: 48px; padding: 0; }

  /* An open document covers the screen; the reply is one tap away and keeps the reference. */
  .ws[data-doc-open][data-pane="docs"] .ws-main { position: fixed; inset: 0; z-index: 60; padding: 0; background: var(--surface); padding-top: env(safe-area-inset-top); overflow: hidden; }
  .viewer-head { grid-template-columns: auto minmax(0, 1fr); padding: 6px 10px 6px 4px; gap: 4px 6px; }
  .viewer-close span { display: none; }
  .viewer-close { padding: 0 10px; }
  .viewer-reply { grid-column: 1 / -1; width: calc(100% - 6px); margin-left: 6px; }
  .viewer-tools { padding: 6px 10px; gap: 6px; }
  .viewer-version { flex: 1 1 100%; }
  .viewer-zoomer { margin-left: auto; }
  .viewer-canvas { padding: 8px; }
  .viewer-strip { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  body[data-view="object"] .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
  .training { width: 100%; max-width: none; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 90dvh; overflow: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@media (max-width: 419px) {
  .target .icon { display: none; }
  .target { padding: 0 6px; font-size: 13.5px; }
}
@media (max-width: 359px) {
  .topbar-role { display: none; }
  .viewer-page { min-width: 52px; }
  .composer-targets .icon { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- CRM and portal: responsive ---------- */
@media (min-width: 980px) {
  /* The conversation is always on the right: its tab is not needed. */
  .ws-tabs [data-pane="chat"] { display: none; }
}
@media (max-width: 1199px) {
  .lead-grid { grid-template-columns: minmax(0, 1fr) 300px; }
  .side-role-link { display: none; }
}
@media (max-width: 979px) {
  .lead-grid { grid-template-columns: minmax(0, 1fr); }
  .lead-side { position: static; }
  .lead-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .lead-row-side { display: flex; flex-wrap: wrap; gap: 2px 12px; }
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .object-row { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (max-width: 767px) {
  .lead-head { grid-template-columns: minmax(0, 1fr); }
  .contact-card { min-width: 0; }
  .lead-title h1 { font-size: 24px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > span:empty { display: none; }
  .toolbar .select { flex: 1 1 140px; min-width: 0; }
  .sheet { width: 100%; max-width: none; margin: auto 0 0; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .sheet-actions .btn { flex: 1 1 auto; }
  .copy-box { grid-template-columns: minmax(0, 1fr); }
  .event-item { grid-template-columns: minmax(0, 1fr) auto; }
  .event-item .event-when { grid-column: 1 / -1; }
  .person-row { grid-template-columns: minmax(0, 1fr); }
  .person-actions { justify-content: flex-start; }
  .page-head-row { align-items: flex-start; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 auto; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edit-photos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-report { grid-template-columns: 96px minmax(0, 1fr); }
  .ov-report img { width: 96px; height: 72px; }
  .rights-table { font-size: 13px; }
  .composer-attach { width: 48px; padding: 0; }
  .composer-attach span { display: none; }
  .ws-rail { max-width: none; }
  .object-flags { justify-content: flex-start; }
  .viewer-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
  .viewer-actions .btn { flex: 1 1 auto; }
  body.composing .ws-rail, body.composing .ws-tabs { display: none; }
}

/* Site chat in the lead card (as in Vista): the visitor on the left, the team on the right. */
.lead-chat { height: auto; min-height: 0; overflow: auto; max-height: min(420px, 55vh); padding: 4px 0 12px; }
.lead-chat-panel .panel-head .muted { margin-left: auto; }
.lead-chat-panel .note-box { border-top: 1px solid var(--line); padding-top: 12px; }
