/* Соня · помощь — интерфейс.
   Стиль «рамка и лист»: навигация на тонированной рамке, работа на белом листе.
   Цвет — только на данных (статусы, сроки, контрольная) и на ссылках; главная кнопка почти чёрная.
   Сетка листа: отступ 32px по краям, один промежуток 24px между блоками. */

@font-face { font-family: "VK Sans Text"; src: url("fonts/vk-sans-text-400.a8ac165e58bd.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "VK Sans Text"; src: url("fonts/vk-sans-text-500.46039553bdfb.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "VK Sans Text"; src: url("fonts/vk-sans-text-600.e21a0fdba0c9.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "VK Sans Display"; src: url("fonts/vk-sans-display-600.8a5897ed9cb7.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  color-scheme: light;
  --frame: #f2f4f7;
  --surface: #ffffff;
  --raised: #f5f7f9;
  --active: #e5e8ed;
  --border: #e3e6ea;
  --rule: #eceef1;
  --control: #cdd1d7;
  --text: #15181d;
  --muted: #5a606a;
  --accent: #2a5ea8;
  --accent-soft: #eaf1fb;
  --primary: #15181d;
  --on-primary: #ffffff;
  --positive: #1e7b4f;
  --negative: #c4242a;
  --sos: #c8261c;
  --sos-soft: #fdeceb;
  --pill-new-bg: #e6eefa;       --pill-new-ink: #1f4f8f;
  --pill-work-bg: #fdf3dc;      --pill-work-ink: #7a4a06;
  --pill-done-bg: #dcf5e5;      --pill-done-ink: #0f4a2b;
  --pill-closed-bg: #eceef1;    --pill-closed-ink: #464b53;
  --notice-bg: #fff8e6;         --notice-ink: #7a4a06;

  --radius-sheet: 16px;
  --radius-card: 12px;
  --radius-control: 8px;
  --sidebar: 232px;
  --gap: 24px;
  --pad: 32px;
  --control-h: 38px;
  --font: "VK Sans Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "VK Sans Display", var(--font);
  --mono: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --frame: #0e0f11;
  --surface: #17191c;
  --raised: #1e2125;
  --active: #2a2e34;
  --border: #282b30;
  --rule: #222529;
  --control: #40454d;
  --text: #f1f3f5;
  --muted: #a7adb6;
  --accent: #8fb6f0;
  --accent-soft: #1d2a3c;
  --primary: #f1f3f5;
  --on-primary: #111214;
  --positive: #6fcf97;
  --negative: #f08a8a;
  --sos: #ff8a80;
  --sos-soft: #3a1f1d;
  --pill-new-bg: #1d2a3c;    --pill-new-ink: #a9c8f5;
  --pill-work-bg: #3a2e17;   --pill-work-ink: #f1cd85;
  --pill-done-bg: #173023;   --pill-done-ink: #8fdcae;
  --pill-closed-bg: #2a2e34; --pill-closed-ink: #c2c7cf;
  --notice-bg: #2f2817;      --notice-ink: #f1cd85;
}

/* ---------- основа */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; min-width: 320px; min-height: 100vh;
  background: var(--frame); color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; color: var(--text); }
h1 { font: 600 24px/1.25 var(--font-display); letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 16px; line-height: 1.4; font-weight: 600; }
h3 { font-size: 14px; line-height: 1.4; font-weight: 600; }
p { margin: 0; }
small { font-size: 12px; }
svg { flex: none; }
img { max-width: 100%; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text { overflow-wrap: anywhere; }
.inline { display: inline; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; transform: translateY(-200%); padding: 10px 16px; background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius-control); }
.skip-link:focus { transform: none; }
code { font: .92em var(--mono); background: var(--raised); padding: 1px 5px; border-radius: 4px; }
pre { margin: 0; padding: 14px 16px; overflow-x: auto; background: var(--raised); border-radius: var(--radius-control); font: 13px/1.55 var(--mono); }
pre code { padding: 0; background: none; font-size: inherit; }
pre code.hljs { padding: 0; background: transparent; }
pre, code, textarea.mono, textarea[name=code] { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* ---------- каркас: рамка, боковая панель, лист */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 16px 12px 12px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 8px; color: var(--text); font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; padding-bottom: 3px;
  border-radius: 8px; background: var(--accent); color: var(--surface);
  font: 600 20px/1 var(--font-display); letter-spacing: -.06em;
}
.brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-link {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 0 10px; border-radius: var(--radius-control);
  color: var(--muted); font: 500 14px/1.2 var(--font);
  background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
}
.side-nav a:hover, .side-link:hover { color: var(--text); background: var(--active); text-decoration: none; }
.side-nav a[aria-current] { color: var(--text); background: var(--active); font-weight: 600; }
.side-nav a[aria-current] .icon { color: var(--accent); }
.side-nav .nav-sos { color: var(--sos); }
.side-nav .nav-sos:hover, .side-nav .nav-sos[aria-current] { color: var(--sos); background: var(--sos-soft); }
.side-nav .nav-sos[aria-current] .icon { color: var(--sos); }
.nav-count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--accent); color: var(--surface);
  font-size: 12px; font-weight: 600;
}
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.side-account { display: flex; align-items: center; gap: 4px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.account-profile { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-control); color: var(--text); }
.account-profile:hover, .account-profile[aria-current] { background: var(--active); text-decoration: none; }
.account-initial { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--pill-new-bg); color: var(--pill-new-ink); font-weight: 600; }
.account-name { min-width: 0; display: flex; flex-direction: column; font-weight: 600; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-name small { color: var(--muted); font-weight: 400; }
.side-account form { margin: 0; }
.icon-button {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: var(--radius-control); background: none; color: var(--muted); cursor: pointer;
}
.icon-button:hover { background: var(--active); color: var(--text); }
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: inline; }

.sheet {
  min-width: 0; margin: 8px 8px 8px 0;
  min-height: calc(100vh - 16px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet);
  display: flex; flex-direction: column;
}
/* На широких экранах (2K и больше) колонка встаёт по центру листа, а не прилипает к левому краю. */
.content { flex: 1; width: 100%; max-width: 1440px; margin-inline: auto; padding: 28px var(--pad) 56px; }
.content.narrow-page { max-width: 880px; }
.phone-bar, .tab-bar { display: none; }

/* ---------- заголовок страницы */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 24px; }
.page-head > div:first-child { min-width: 0; }
.page-sub { margin-top: 4px; color: var(--muted); font-size: 14px; max-width: 70ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); min-height: 28px; }
.crumbs a:hover { color: var(--text); text-decoration: none; }
.crumbs .icon { width: 16px; height: 16px; }

/* ---------- кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 16px; border-radius: var(--radius-control);
  border: 1px solid var(--control); background: var(--surface); color: var(--text);
  font: 500 14px/1.2 var(--font); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--muted); background: var(--raised); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary); border-color: var(--primary); opacity: .88; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: transparent; background: var(--active); color: var(--text); }
.btn-sos { background: var(--sos); border-color: var(--sos); color: #fff; font-weight: 600; }
.btn-sos:hover { background: var(--sos); border-color: var(--sos); opacity: .9; }
[data-theme="dark"] .btn-sos { color: #1d0f0e; }
.btn-sos-outline { color: var(--sos); border-color: color-mix(in srgb, var(--sos) 45%, transparent); }
.btn-sos-outline:hover { color: var(--sos); background: var(--sos-soft); border-color: var(--sos); }
.btn-small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.chosen { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; min-height: 36px; }
.linklike:hover { color: var(--text); }
.text-action { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--accent); font: 500 14px/1.3 var(--font); cursor: pointer; }
.text-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-action .icon { width: 16px; height: 16px; }

/* ---------- поля */
input[type=text], input[type=password], input[type=search], input[type=number], input[type=email],
input[type=datetime-local], input[type=time], input[type=date], select, textarea {
  width: 100%; min-width: 0; min-height: var(--control-h); padding: 8px 12px;
  border: 1px solid var(--control); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text); font: 400 14px/1.4 var(--font);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 0; line-height: 1.5; }
textarea.mono, textarea[name=code] { font: 13px/1.5 var(--mono); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23808690' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
input[type=file] { font: inherit; font-size: 13px; color: var(--muted); max-width: 100%; }
input, select, textarea { scroll-margin-top: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .label, .field > span:first-child, .label { font-size: 14px; font-weight: 500; color: var(--text); }
.field small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.field-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.field-caption .text-action { font-size: 13px; }
.req { color: var(--negative); font-style: normal; }
.error, .field small.error { color: var(--negative); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--negative); }
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; color: var(--text); cursor: pointer; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > select { flex: 1; min-width: 150px; width: auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
.password-wrap { position: relative; display: flex; }
.password-wrap input { padding-right: 92px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--accent); font: 500 13px var(--font); cursor: pointer; }
.password-toggle:hover { background: var(--accent-soft); }

/* Выбор из вариантов — плитки */
.choice-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.choice-field legend { padding: 0; margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice-grid label {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--control); border-radius: var(--radius-control); background: var(--surface);
  font-size: 14px; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.choice-grid label:hover { border-color: var(--muted); }
.choice-grid label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.choice-grid label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.urgency-choices { grid-template-columns: 1fr; }
.urgency-choices label:has(input[value=sos]:checked) { border-color: var(--sos); background: var(--sos-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* Файлы */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 16px; cursor: pointer;
  border: 1px dashed var(--control); border-radius: var(--radius-control); background: var(--surface);
  transition: border-color .15s, background-color .15s;
}
.dropzone > span { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 500; }
.dropzone small { color: var(--muted); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-size: 13px; }
.file-list:empty, .file-status:empty, .draft-note:empty { display: none; }
.file-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; border-bottom: 1px solid var(--rule); }
.file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-size { color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-list .bad { color: var(--negative); }
.file-remove { min-height: 32px; padding: 0 10px; }
.attach-file { position: relative; cursor: pointer; }
.attach-file input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.attach-file:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.draft-note { color: var(--muted); font-size: 12px; }

/* Раскрывашки */
details > summary { cursor: pointer; }
.disclosure > summary, .workflow-extra > summary, .versions > summary, .library-stats > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; list-style: none;
  color: var(--accent); font-weight: 500;
}
.disclosure > summary::-webkit-details-marker, .workflow-extra > summary::-webkit-details-marker,
.versions > summary::-webkit-details-marker, .library-stats > summary::-webkit-details-marker, .code-preview > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after, .workflow-extra > summary::after, .versions > summary::after, .library-stats > summary::after {
  content: ""; width: 7px; height: 7px; margin: -3px 0 0 4px; border: solid currentColor; border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); transition: transform .15s;
}
details[open] > summary::after { transform: rotate(-135deg); margin-top: 3px; }
details:not([open]) > summary .when-open, details[open] > summary .when-closed { display: none; }

/* ---------- статусы и сообщения */
.badge {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--pill-closed-bg); color: var(--pill-closed-ink);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.st-new { background: var(--pill-new-bg); color: var(--pill-new-ink); }
.st-in_progress { background: var(--pill-work-bg); color: var(--pill-work-ink); }
.st-draft_ready { background: var(--pill-work-bg); color: var(--pill-work-ink); box-shadow: inset 0 0 0 1px currentColor; }
.st-done { background: var(--pill-done-bg); color: var(--pill-done-ink); }
.st-closed { background: var(--pill-closed-bg); color: var(--pill-closed-ink); }

.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.msg { padding: 10px 14px; border-radius: var(--radius-control); background: var(--accent-soft); color: var(--text); }
.msg-success { background: var(--pill-done-bg); color: var(--pill-done-ink); }
.msg-error { background: var(--sos-soft); color: var(--negative); }
.msg-warning { background: var(--notice-bg); color: var(--notice-ink); }
.returned-note { margin-bottom: 20px; padding: 12px 16px; border-radius: var(--radius-control); background: var(--notice-bg); color: var(--notice-ink); }
.returned-note a { font-weight: 500; }

/* ---------- список заявок */
.queue-views {
  display: flex; gap: 24px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.queue-views::-webkit-scrollbar { display: none; }
.queue-views a {
  position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 42px; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.queue-views a:hover { color: var(--text); text-decoration: none; }
.queue-views a[aria-current] { color: var(--text); font-weight: 600; }
.queue-views a[aria-current]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.queue-views a span { color: var(--muted); font-weight: 400; }

.queue-filter-toggle { display: none; }
.queue-filters {
  display: grid; grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
  align-items: end; gap: 12px; margin: 20px 0 8px;
}
.queue-archive-filters { grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) auto; }
.queue-filters label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.queue-results { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0 0; color: var(--muted); font-size: 13px; }

.queue-table { width: 100%; margin-top: 12px; border-collapse: collapse; table-layout: fixed; text-align: left; }
.queue-table th, .queue-table td { padding: 14px 12px; border-bottom: 1px solid var(--rule); vertical-align: middle; text-align: left; overflow-wrap: anywhere; font-weight: 400; }
.queue-table thead th { padding-block: 10px; color: var(--muted); font-size: 12px; font-weight: 500; border-bottom-color: var(--border); }
.queue-table th:first-child { padding-left: 12px; }
.queue-table .queue-task { width: 46%; }
.queue-table .queue-subject { width: 20%; color: var(--muted); }
.queue-table .queue-status { width: 16%; }
.queue-table .queue-due { width: 18%; text-align: right; }
.queue-table thead .queue-due { text-align: right; }
.queue-table tbody tr { position: relative; transition: background-color .12s; }
.queue-table tbody tr:hover, .queue-table tbody tr:focus-within { background: var(--raised); }
.queue-table tbody tr.is-sos { background: var(--sos-soft); }
.queue-title { color: var(--text); font-weight: 600; font-size: 15px; line-height: 1.4; }
.queue-title::after { content: ""; position: absolute; inset: 0; }
.queue-title:hover, .queue-table tr:hover .queue-title { color: var(--accent); text-decoration: none; }
.queue-title:focus-visible { outline: none; }
.queue-table tr:has(.queue-title:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.queue-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; color: var(--muted); font-size: 13px; }
.queue-meta strong { color: var(--negative); font-weight: 500; }
.queue-meta .tag-sos { color: var(--sos); font-weight: 600; }
.queue-mobile-label { display: none; }
.queue-due time { display: block; color: var(--text); }
.queue-due small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.queue-due .queue-overdue, .queue-due small.queue-overdue { color: var(--negative); font-weight: 500; }
.queue-due .due-soon { color: var(--pill-work-ink); font-weight: 500; }
.queue-no-date { color: var(--muted); }

.empty-state, .queue-empty, .support-empty {
  margin-top: 16px; padding: 40px 24px; text-align: center;
  border: 1px dashed var(--control); border-radius: var(--radius-card);
}
.empty-state h2, .queue-empty h2, .support-empty h2 { margin-bottom: 4px; }
.empty-state p, .queue-empty p, .support-empty p { color: var(--muted); }
.empty-state .btn, .queue-empty .btn, .support-empty .btn { margin-top: 16px; }

/* ---------- карточка заявки */
.detail-head { margin-bottom: 20px; }
.detail-head h1 { margin-top: 2px; }
.detail-byline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.detail-byline .discussion-jump { display: none; }

/* Путь заявки: Новая → В работе → Готово → Закрыта */
.status-track { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.status-track li { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 12px; }
.status-track li::before { content: ""; height: 4px; border-radius: 2px; background: var(--active); }
.status-track li.done { color: var(--text); }
.status-track li.done::before { background: var(--accent); opacity: .45; }
.status-track li.now { color: var(--text); font-weight: 600; }
.status-track li.now::before { background: var(--accent); }

.request-operations { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.request-operations:has(> *) { margin-bottom: 24px; }
.request-operations form { margin: 0; }
.request-operations > .row > select { min-width: 150px; }
.request-operations .text-action { margin-left: auto; }

.sos-box { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; padding: 14px 16px; border-radius: var(--radius-card); background: var(--sos-soft); color: var(--text); }
.sos-box b { color: var(--sos); }

.detail-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: var(--gap); align-items: start; }
.detail-content { min-width: 0; display: flex; flex-direction: column; gap: 28px; }

.detail-answer { display: flex; flex-direction: column; gap: 12px; }
.answer-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.answer-head h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.answer-head .row { gap: 8px 16px; }
.answer-note { padding: 12px 14px; border-radius: var(--radius-control); background: var(--accent-soft); }
.guide-frame { display: block; width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius-card); background: #fff; }
.rating { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border-radius: var(--radius-control); background: var(--raised); }
.rating > span { margin-right: 4px; font-weight: 500; }
.rating form { margin: 0; }
.versions ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.versions li { padding: 3px 0; }
.versions .current { color: var(--text); font-weight: 600; }

.request-materials { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.request-materials h2 { font-size: 18px; }
.task-description { font-size: 15px; line-height: 1.6; max-width: 72ch; }
.request-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin: 0; border-radius: var(--radius-card); overflow: hidden; background: var(--border); border: 1px solid var(--border); }
.request-facts > div { padding: 12px 14px; background: var(--surface); }
.request-facts dt { color: var(--muted); font-size: 12px; }
.request-facts dd { margin: 2px 0 0; font-weight: 500; }
.request-facts dd.overdue, .urg-label.urg-high { color: var(--negative); }
.urg-label.urg-sos { color: var(--sos); }
.material-block { display: flex; flex-direction: column; gap: 8px; }
.rules-note { padding: 12px 14px; border-radius: var(--radius-control); background: var(--notice-bg); color: var(--notice-ink); }

.atts { display: flex; flex-direction: column; gap: 10px; }
.att { min-width: 0; }
.att img { display: block; max-height: 340px; margin-bottom: 6px; border-radius: var(--radius-control); border: 1px solid var(--border); }
.att-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; overflow-wrap: anywhere; }
.att-line .muted { font-size: 12px; }
.attachment-download { font-size: 13px; }
.code-preview summary { list-style: none; color: var(--accent); font-size: 13px; margin: 4px 0; }

/* Переписка */
.discussion { min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: var(--radius-card); background: var(--raised); position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.discussion h2 { display: flex; align-items: baseline; gap: 8px; }
.discussion h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.discussion-empty { color: var(--muted); }
.message-entry { display: flex; flex-direction: column; gap: 4px; max-width: 92%; padding: 10px 12px; border-radius: 12px 12px 12px 4px; background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; }
.message-entry.mine { align-self: flex-end; border-radius: 12px 12px 4px 12px; background: var(--accent-soft); border-color: transparent; }
.message-entry header { display: flex; justify-content: space-between; gap: 4px 12px; font-size: 12px; }
.message-entry header b { font-weight: 600; }
.message-entry time { color: var(--muted); }
.message-entry:target { outline: 2px solid var(--accent); outline-offset: 2px; }
.reply-editor { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.reply-editor > .label { font-size: 13px; }
.reply-editor textarea { min-height: 88px; }
.reply-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Обработка (для Кости) */
.processing { margin-top: 32px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-card); }
.processing > h2 { margin-bottom: 16px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.admin-grid > * { min-width: 0; }
.table-wrap { overflow-x: auto; }
.jobs { width: 100%; border-collapse: collapse; font-size: 13px; }
.jobs th, .jobs td { padding: 8px 8px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.jobs th { color: var(--muted); font-weight: 500; font-size: 12px; border-bottom-color: var(--border); }
.jobs .num { text-align: right; }

/* ---------- формы заявки */
.workflow-editor { display: flex; flex-direction: column; gap: var(--gap); }
.editor-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: var(--gap); align-items: start; }
.editor-fields { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.editor-aside { padding: 20px; border-radius: var(--radius-card); background: var(--raised); }
.editor-fields > h2 { font-size: 16px; }
.workflow-extra { border-top: 1px solid var(--rule); padding-top: 8px; }
.workflow-extra > .stack { padding-top: 12px; }
.workflow-submit { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 20px; border-top: 1px solid var(--border); }
.workflow-submit > .row { margin-left: auto; }
.workflow-submit .draft-note { max-width: 44ch; }
.sos-intro { margin-bottom: 20px; }

/* ---------- база знаний */
.library-filter { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(160px, 1fr) auto; align-items: end; gap: 12px; }
.library-filter .field > span:first-child { color: var(--muted); font-size: 12px; font-weight: 500; }
.library-result { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.library-group { margin-top: 32px; }
.library-group h2 { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.library-group h2 small { color: var(--muted); font-size: 13px; font-weight: 400; }
.library-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.library-entry { display: grid; grid-template-columns: minmax(0, 1fr) 190px 120px; align-items: baseline; gap: 16px; padding: 14px 12px; border-bottom: 1px solid var(--rule); color: var(--text); transition: background-color .12s; }
.library-entry:hover { background: var(--raised); text-decoration: none; }
.library-entry:hover .library-title { color: var(--accent); }
.library-title { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.kb-snippet { margin-top: 2px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.kb-snippet mark { background: var(--notice-bg); color: var(--notice-ink); padding: 0 2px; border-radius: 3px; }
.library-type { color: var(--muted); font-size: 13px; }
.library-type span { display: block; }
.rate-clear { color: var(--positive); }
.rate-unclear { color: var(--pill-work-ink); }
.library-entry time { color: var(--muted); font-size: 13px; text-align: right; }
.library-stats { margin-top: 28px; padding: 14px 16px; border-radius: var(--radius-card); background: var(--raised); }
.library-stats ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

/* ---------- предметы */
.subjects-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: var(--gap); align-items: start; }
.subject-add-jump { display: none; }
.subjects-index { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.subject-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: start; padding: 16px 4px; border-bottom: 1px solid var(--rule); }
.subject-entry h2 { overflow-wrap: anywhere; }
.subject-rules { margin: 4px 0 6px; color: var(--muted); max-width: 70ch; overflow-wrap: anywhere; }
.subject-count { font-size: 12px; color: var(--muted); }
.subject-entry > a { font-weight: 500; }
.subject-entry > form { width: 280px; padding: 14px; border-radius: var(--radius-card); background: var(--raised); }
.subject-entry .row { margin-top: 6px; }
.wish-layout > .wish-form { order: 2; position: sticky; top: 24px; }
.wish-layout > .empty-state { margin-top: 0; }
.support-panel { display: flex; flex-direction: column; gap: 16px; padding: 20px; border-radius: var(--radius-card); background: var(--raised); min-width: 0; }
.subject-editor textarea { min-height: 6.5rem; }
.settings-form { max-width: 560px; }
.support-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ---------- профиль */
.settings-list { max-width: 920px; border-top: 1px solid var(--border); }
.settings-row { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--gap); padding: 24px 0; border-bottom: 1px solid var(--border); }
.settings-row > div:first-child p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.settings-content { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; min-width: 0; }
.settings-content > p { color: var(--muted); max-width: 56ch; }
.settings-content > p strong { color: var(--text); }
.account-facts { display: grid; gap: 6px; margin: 0; }
.account-facts div { display: grid; grid-template-columns: 80px 1fr; gap: 12px; }
.account-facts dt { color: var(--muted); }
.account-facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.quiet-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: min(100%, 360px); }
.tg-widget { display: flex; min-height: 40px; margin-top: 8px; }

/* ---------- вход */
/* Гостевые страницы (вход, блокировка, вход по ссылке): карточка по центру экрана при любой ширине. */
body.guest main.content {
  max-width: none; min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px);
  display: grid; place-items: center; padding: 32px 16px 16px;
}
.auth-sheet { width: min(100%, 400px); display: flex; flex-direction: column; gap: 20px; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sheet); }
.auth-brand { padding: 0; min-height: 0; }
.auth-sheet h1 { font-size: 22px; }
.auth-sheet > p { color: var(--muted); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn-primary { min-height: 42px; }
.auth-telegram { display: flex; flex-direction: column; gap: 10px; padding-top: 20px; border-top: 1px solid var(--border); }
.auth-telegram h2 { font-size: 14px; }
.auth-telegram p { color: var(--muted); font-size: 13px; }
.guest-tools { text-align: center; padding: 0 16px 20px; font-size: 13px; }

/* ---------- контрольная: баннер для Кости и живые подсказки */
.sos-banner { background: var(--sos); color: #fff; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; }
.sos-banner-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px var(--pad); }
.sos-banner a { color: #fff; font-weight: 600; text-decoration: underline; }
.sos-banner .btn { background: transparent; border-color: rgba(255, 255, 255, .6); color: #fff; }
.sos-banner .btn:hover { background: rgba(255, 255, 255, .12); }
.sos-banner-item + .sos-banner-item { margin-top: 4px; }
[data-theme="dark"] .sos-banner { color: #1d0f0e; }
[data-theme="dark"] .sos-banner a { color: #1d0f0e; }
[data-theme="dark"] .sos-banner .btn { color: #1d0f0e; border-color: rgba(0, 0, 0, .4); }
.live-note {
  position: fixed; right: 16px; bottom: 16px; z-index: 30; max-width: calc(100vw - 32px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 10px 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
}

.dialog { width: min(520px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-sheet); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .24); }
.dialog::backdrop { background: rgba(10, 12, 16, .45); }
.dialog p { color: var(--muted); }

/* ---------- обучение */
.tour-shade { position: fixed; inset: 0; z-index: 90; }
.tour-shade-dark { background: rgba(10, 12, 16, .5); }
.tour-spot {
  position: fixed; z-index: 91; pointer-events: none; border-radius: 10px;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(10, 12, 16, .5);
  transition: left .2s, top .2s, width .2s, height .2s;
}
.tour-card {
  position: fixed; z-index: 92; width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 10px; padding: 18px 18px 14px;
  background: var(--surface); color: var(--text); border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .28);
}
.tour-card-center { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); }
.tour-card-docked { left: 12px; right: 12px; width: auto; }
.tour-from { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.tour-from .account-initial { width: 26px; height: 26px; font-size: 13px; }
.tour-count { margin-left: auto; font-weight: 400; }
.tour-card h2 { font-size: 17px; }
.tour-card p { line-height: 1.55; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.tour-nav { display: flex; gap: 8px; margin-left: auto; }
.tour-skip { margin-left: -12px; }
.tour-demo { pointer-events: none; }
.tour-demo .queue-title::after { content: none; }
.tour-demo-tag { padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }

/* ---------- планшет и телефон: рамка исчезает, лист становится экраном */
@media (max-width: 1100px) {
  .wish-layout > .wish-form { order: 0; position: static; }
  .detail-columns, .editor-columns, .subjects-layout { grid-template-columns: minmax(0, 1fr); }
  .discussion { position: static; max-height: none; overflow: visible; }
  .detail-byline .discussion-jump { display: inline-flex; }
}

@media (max-width: 1023px) {
  :root { --pad: 20px; --control-h: 44px; }
  body { background: var(--surface); }
  .shell { display: block; }
  .sidebar { display: none; }
  .phone-bar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    height: 52px; padding: 0 8px 0 12px; background: var(--frame);
  }
  .phone-bar .brand { padding: 0; font-size: 15px; min-width: 0; }
  .phone-bar-actions { display: flex; align-items: center; gap: 4px; }
  .page-actions .btn-sos-outline { display: none; }
  .phone-bar .icon-button { width: 44px; height: 44px; }
  .sheet { margin: 0; min-height: 0; border: 0; border-radius: 0; }
  .sos-banner { border-radius: 0; }
  .content { padding: 20px var(--pad) calc(88px + env(safe-area-inset-bottom)); }
  .tab-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tab-bar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; border-radius: 10px; color: var(--muted); font-size: 11px; font-weight: 500;
  }
  .tab-bar a:hover { text-decoration: none; }
  .tab-bar a .icon { width: 22px; height: 22px; }
  .tab-bar a[aria-current] { color: var(--accent); }
  .tab-bar a[aria-current] .icon { stroke-width: 2; }
  .tab-bar .nav-count { position: absolute; top: 3px; left: calc(50% + 6px); height: 18px; min-width: 18px; padding: 0 5px; font-size: 11px; margin: 0; }
  .live-note { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .btn { min-height: var(--control-h); }
  .btn-small { min-height: 36px; }
  input[type=text], input[type=password], input[type=search], input[type=number], input[type=email],
  input[type=datetime-local], input[type=time], input[type=date], select, textarea { font-size: 16px; }
  .choice-grid label { min-height: 44px; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  h1 { font-size: 22px; }
  .page-head { margin-bottom: 16px; }
  .page-actions .btn-primary { flex: 1; }
  .page-head .page-actions { width: 100%; }

  /* Фильтры заявок: поиск на всю ширину, остальное — по кнопке */
  .queue-views { gap: 20px; margin-inline: calc(var(--pad) * -1); padding-inline: var(--pad); }
  .queue-filter-toggle {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 8px;
    padding: 0; border: 0; background: none; color: var(--accent); font: 500 14px var(--font); cursor: pointer;
  }
  .queue-filter-toggle:not([hidden])[aria-expanded="false"] + .queue-filters { display: none; }
  .queue-filters, .queue-archive-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
  .queue-filters .queue-search, .queue-filters .btn, .queue-archive-filters label { grid-column: 1 / -1; }

  /* Таблица заявок → список карточек в две строки */
  .queue-table { margin-top: 8px; border-top: 1px solid var(--border); }
  .queue-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .queue-table tbody { display: block; }
  .queue-table tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "task task" "subject status" "due due";
    gap: 6px 12px; padding: 14px 4px; border-bottom: 1px solid var(--rule);
  }
  .queue-table tbody tr.is-sos { margin-inline: calc(var(--pad) * -1); padding-inline: var(--pad); }
  .queue-table tbody th, .queue-table tbody td, .queue-table tbody th:first-child { width: auto !important; padding: 0; border: 0; text-align: left; }
  .queue-table .queue-task { grid-area: task; }
  .queue-table .queue-subject { grid-area: subject; align-self: center; font-size: 14px; }
  .queue-table .queue-status { grid-area: status; justify-self: end; }
  .queue-table .queue-due { grid-area: due; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; text-align: left; font-size: 14px; }
  .queue-due time, .queue-due small { display: inline; margin: 0; font-size: 14px; }
  .queue-mobile-label { display: inline; color: var(--muted); }

  .status-track li { font-size: 11px; }
  .request-operations > * { flex: 1 1 auto; }
  .request-operations .btn { width: 100%; }
  .request-operations .row { width: 100%; }
  .request-operations .text-action { margin-left: 0; flex: none; }
  .request-facts { grid-template-columns: 1fr 1fr; }
  .request-facts > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .guide-frame { height: 72vh; min-height: 360px; }
  .discussion { margin-inline: calc(var(--pad) * -1); padding: 20px var(--pad); border-radius: 0; }
  .message-entry { max-width: 100%; }
  .processing { margin-inline: calc(var(--pad) * -1); padding: 20px var(--pad); border-radius: 0; border-inline: 0; }

  .editor-aside { margin-inline: calc(var(--pad) * -1); padding: 20px var(--pad); border-radius: 0; }
  .workflow-submit { flex-direction: column-reverse; align-items: stretch; }
  .workflow-submit > .row { margin-left: 0; display: grid; grid-template-columns: 1fr 2fr; }
  .urgency-choices { grid-template-columns: 1fr 1fr; }

  .library-filter { grid-template-columns: minmax(0, 1fr) auto; }
  .library-filter .field:first-child { grid-column: 1 / -1; }
  .library-entry { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 4px; }
  .library-entry > div:first-child { grid-column: 1 / -1; }
  .library-entry time { font-size: 12px; }

  .subject-add-jump { display: inline-flex; }
  .subject-entry:has(> form) { grid-template-columns: minmax(0, 1fr); }
  .subject-entry > form { width: auto; }
  .wish-layout > .wish-form { order: 0; position: static; }
  .support-panel { margin-inline: calc(var(--pad) * -1); padding: 20px var(--pad); border-radius: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-sheet { padding: 24px 20px; }
}

@media (max-width: 380px) {
  .choice-grid, .urgency-choices { grid-template-columns: minmax(0, 1fr); }
  .phone-bar .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
