/* Court Mirror — дизайн-система «судебный классик». Правила: docs/DESIGN.md.
   Цвета — только через токены ниже; новые компоненты собираются из них. */

/* ───────── Токены: светлая тема ───────── */
:root {
  --font-serif: Georgia, "Noto Serif", "PT Serif", Cambria, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --bg: #f4f1e9;
  --surface: #fffdf8;
  --surface-2: #f6f1e5;
  --surface-sunken: #ece6d8;
  --border: #e0d8c6;
  --border-strong: #cbbfa5;
  --text: #1a2233;
  --text-muted: #5b6475;
  --text-faint: #8a8f99;

  --navy: #14243d;
  --navy-2: #1e3556;
  --on-navy: #f3ecdc;
  --on-navy-muted: #b7bfcd;

  --primary: #1e3a5f;
  --primary-hover: #152c49;
  --on-primary: #fffdf8;
  --gold: #a8812f;
  --gold-strong: #8c6a22;
  --gold-soft: #f3e8cc;
  --gold-line: #c9a45c;

  --success: #2e6a4c;
  --success-soft: #e1efe6;
  --warning: #8d6410;
  --warning-soft: #f7ebcf;
  --danger: #a23a31;
  --danger-soft: #f6e0dd;
  --info: #2c5687;
  --info-soft: #e1eaf5;

  --court-supreme: #0e5f63;
  --court-supreme-soft: #daf3f2;
  --court-federal: #593386;
  --court-federal-soft: #eee5f8;
  --court-rehab: #165538;
  --court-rehab-soft: #d8ece2;

  --paper: #fffdf6;
  --paper-text: #22201b;
  --paper-border: #e4dac3;

  --focus: 0 0 0 3px rgba(168, 129, 47, 0.35);
  --shadow-sm: 0 1px 2px rgba(26, 34, 51, 0.06);
  --shadow: 0 1px 2px rgba(26, 34, 51, 0.05), 0 6px 20px rgba(26, 34, 51, 0.06);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --container: 1180px;
}

/* ───────── Токены: тёмная тема (системная и выбранная вручную) ───────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c121d;
    --surface: #131b29;
    --surface-2: #182233;
    --surface-sunken: #0f1622;
    --border: #243045;
    --border-strong: #33425c;
    --text: #ebe5d7;
    --text-muted: #a3abba;
    --text-faint: #6f788a;
    --navy: #0f1a2c;
    --navy-2: #172640;
    --primary: #c9a45c;
    --primary-hover: #d8b46c;
    --on-primary: #141a24;
    --gold: #d2ad66;
    --gold-strong: #e0bf7d;
    --gold-soft: #2b2617;
    --gold-line: #b8934c;
    --success: #6fbf94;
    --success-soft: #16291f;
    --warning: #e2b85a;
    --warning-soft: #2c2412;
    --danger: #ec8a80;
    --danger-soft: #331a18;
    --info: #8ab4e6;
    --info-soft: #172739;
    --court-supreme: #5ed1d8;
    --court-supreme-soft: #122c2e;
    --court-federal: #c09df4;
    --court-federal-soft: #291a3c;
    --court-rehab: #46ba94;
    --court-rehab-soft: #102922;
    --paper: #141c2b;
    --paper-text: #ebe5d7;
    --paper-border: #2b3952;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --focus: 0 0 0 3px rgba(210, 173, 102, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0c121d;
  --surface: #131b29;
  --surface-2: #182233;
  --surface-sunken: #0f1622;
  --border: #243045;
  --border-strong: #33425c;
  --text: #ebe5d7;
  --text-muted: #a3abba;
  --text-faint: #6f788a;
  --navy: #0f1a2c;
  --navy-2: #172640;
  --primary: #c9a45c;
  --primary-hover: #d8b46c;
  --on-primary: #141a24;
  --gold: #d2ad66;
  --gold-strong: #e0bf7d;
  --gold-soft: #2b2617;
  --gold-line: #b8934c;
  --success: #6fbf94;
  --success-soft: #16291f;
  --warning: #e2b85a;
  --warning-soft: #2c2412;
  --danger: #ec8a80;
  --danger-soft: #331a18;
  --info: #8ab4e6;
  --info-soft: #172739;
  --court-supreme: #5ed1d8;
  --court-supreme-soft: #122c2e;
  --court-federal: #c09df4;
  --court-federal-soft: #291a3c;
  --court-rehab: #46ba94;
  --court-rehab-soft: #102922;
  --paper: #141c2b;
  --paper-text: #ebe5d7;
  --paper-border: #2b3952;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --focus: 0 0 0 3px rgba(210, 173, 102, 0.4);
}

/* ───────── База ───────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.2;
  margin: 0 0 var(--space-3);
  color: var(--text);
}

h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }

p { margin: 0 0 var(--space-3); }

a {
  color: var(--gold-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover { color: var(--gold); }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

::selection { background: var(--gold-soft); }

strong { font-weight: 650; }

/* ───────── Шапка ───────── */
.site-header {
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: var(--on-navy);
  border-bottom: 2px solid var(--gold-line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 10px var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--on-navy);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-link:hover { color: var(--on-navy); }

.brand-mark {
  width: 34px;
  height: 34px;
  padding: 6px;
  border-radius: 9px;
  color: var(--gold-line);
  background: rgba(201, 164, 92, 0.12);
  border: 1px solid rgba(201, 164, 92, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--on-navy-muted);
  letter-spacing: 0.03em;
}

/* На десктопе пункты переносятся на вторую строку, а не прячутся за край. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  margin: 0 auto;
  min-width: 0;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  color: var(--on-navy-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-link:hover {
  color: var(--on-navy);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: var(--on-navy);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  background: var(--gold-line);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  flex-shrink: 0;
}

.site-nav + .user-bar { margin-left: 0; }

.role-badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--gold-line);
  border: 1px solid rgba(201, 164, 92, 0.45);
  background: rgba(201, 164, 92, 0.1);
}

a.role-badge {
  text-decoration: none;
  transition: background-color 0.15s ease;
}

a.role-badge:hover,
a.role-badge[aria-current="page"] {
  color: var(--gold-line);
  background: rgba(201, 164, 92, 0.22);
}

.header-icon { width: 18px; height: 18px; }
.header-link[aria-current="page"] {
  color: var(--gold-line);
  border-color: rgba(201, 164, 92, 0.45);
}

.logout-form { margin: 0; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--on-navy-muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.icon-button:hover {
  color: var(--on-navy);
  background: rgba(255, 255, 255, 0.07);
}

.icon { width: 18px; height: 18px; display: none; }
.theme-toggle:not([data-mode]) .icon-system,
.theme-toggle[data-mode="system"] .icon-system,
.theme-toggle[data-mode="light"] .icon-light,
.theme-toggle[data-mode="dark"] .icon-dark { display: block; }

/* ───────── Каркас страницы ───────── */
.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
}

.site-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  padding: var(--space-5);
  border-top: 1px solid var(--border);
}

.page-header {
  margin-bottom: var(--space-5);
}

.page-header h1 { margin-bottom: var(--space-1); }

.header-with-action,
.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.header-subtitle,
.welcome-text {
  color: var(--text-muted);
  margin: 0;
}

.header-buttons {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.eyebrow {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-2);
}

.section { margin-top: var(--space-6); }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.section-title h2 { margin: 0; }

.section-title .count {
  color: var(--text-faint);
  font-size: 13px;
}

/* ───────── Карточки ───────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.card + .card { margin-top: var(--space-4); }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.pane-header h2 {
  margin: 0;
  font-size: 18px;
}

/* ───────── Кнопки ───────── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.05s ease;
}

.button:hover {
  color: var(--text);
  border-color: var(--gold-line);
}

.button:active { transform: translateY(1px); }

.button-primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

.button-primary:hover {
  background: var(--primary-hover);
  color: var(--on-primary);
  border-color: var(--primary-hover);
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.button-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.button-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: transparent;
}

.button-ghost.on-dark {
  color: var(--on-navy-muted);
}

.button-ghost.on-dark:hover {
  color: var(--on-navy);
  background: rgba(255, 255, 255, 0.07);
}

.button-sm {
  min-height: 30px;
  padding: 0 11px;
  font-size: 13px;
}

.button-lg {
  min-height: 46px;
  padding: 0 22px;
  font-size: 15px;
}

.button[disabled],
.button.htmx-request {
  opacity: 0.6;
  pointer-events: none;
}

/* ───────── Формы ───────── */
.form-group { margin-bottom: var(--space-4); }

.form-group label,
.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.required {
  color: var(--gold);
  margin-left: 2px;
}

.form-control {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control::placeholder { color: var(--text-faint); }

.form-control:hover { border-color: var(--gold-line); }

.form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus);
}

textarea.form-control {
  min-height: 110px;
  resize: vertical;
  line-height: 1.5;
}

select.form-control {
  appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.form-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-top: var(--space-4);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
}

/* ───────── Уведомления ───────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
  font-size: 14px;
}

.alert-error {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  color: var(--success);
}

.alert-warning {
  background: var(--warning-soft);
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
  color: var(--warning);
}

/* ───────── Бейджи статусов ───────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-status,
.badge-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: transparent;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: transparent;
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.badge-muted {
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge-court-supreme {
  background: var(--court-supreme-soft);
  color: var(--court-supreme);
  border-color: transparent;
}

.badge-court-federal {
  background: var(--court-federal-soft);
  color: var(--court-federal);
  border-color: transparent;
}

.badge-court-rehab {
  background: var(--court-rehab-soft);
  color: var(--court-rehab);
  border-color: transparent;
}

.claims-badge-overdue {
  font-weight: 700;
}

/* ───────── Таблицы ───────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card.table-card { padding: 0; overflow: hidden; }
.table-card .table-responsive { border: 0; border-radius: 0; }
.table-card > .pane-header {
  padding: var(--space-4) var(--space-5);
  margin-bottom: 0;
}
.table-card > .pane-header h2,
.table-card > .pane-header h3 {
  margin: 0;
  font-size: 18px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table tbody tr {
  transition: background-color 0.12s ease;
}

.data-table tbody tr:hover { background: var(--surface-2); }

.data-table tbody tr.claim-row-red td {
  background: var(--danger-soft);
  color: var(--text);
}

.data-table tbody tr.claim-row-red td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.data-table tbody tr.claim-row-yellow td {
  background: var(--warning-soft);
  color: var(--text);
}

.data-table tbody tr.claim-row-yellow td:first-child {
  box-shadow: inset 3px 0 0 var(--warning);
}

.table-actions {
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
}

.cell-claim {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}

.cell-muted { color: var(--text-muted); }

/* Реестр исков: расширение контейнера только для этой страницы. */
.site-main:has(> .page-wide) {
  max-width: calc(var(--container) + 4 * var(--space-7));
  min-width: 0;
}

.page-wide { min-width: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.claims-table {
  table-layout: fixed;
  min-width: 1120px;
}

.claims-table th,
.claims-table td {
  padding: var(--space-3);
  overflow-wrap: anywhere;
  white-space: normal;
}

.claims-number { width: 6%; }
.claims-court { width: 14%; }
.claims-topic { width: 18%; }
.claims-judge { width: 12%; }
.claims-status { width: 12%; }
.claims-deadlines { width: 14%; }
.claims-assignment { width: 24%; }

.claims-table .badge { white-space: normal; }
.claims-table .badge::before { flex-shrink: 0; }
.claims-table .cell-claim { white-space: nowrap; }

.claims-cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

/* Список судей — на всю ширину, кнопки «Назначить» и «Снять назначение» — одним рядом под ним.
   Формы не создают своих блоков (display: contents), отправка и htmx работают как обычно. */
.claims-assignment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.claims-assignment-actions > form { display: contents; }
.claims-assignment-actions > .alert { flex: 1 1 100%; }

.claims-assign-form select {
  flex: 1 1 100%;
  min-width: 0;
}

.claims-assignment-actions .button { flex-shrink: 0; }

/* ───────── Пустые состояния ───────── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 0;
}

.table-card .empty-state {
  border: 0;
  border-radius: 0;
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 17px;
  margin-bottom: var(--space-1);
}

/* ───────── Главная ───────── */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  background: linear-gradient(135deg, var(--navy-2), var(--navy));
  color: var(--on-navy);
  border: 1px solid rgba(201, 164, 92, 0.25);
}

.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 1px solid rgba(201, 164, 92, 0.25);
  box-shadow: 0 0 0 28px rgba(201, 164, 92, 0.05), 0 0 0 56px rgba(201, 164, 92, 0.03);
}

.hero h1 { color: var(--on-navy); margin-bottom: var(--space-2); }
.hero .eyebrow { color: var(--gold-line); }
.hero p { color: var(--on-navy-muted); max-width: 560px; }

.hero .quick-actions { margin-top: var(--space-4); }

.hero .button-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--on-navy);
  border-color: rgba(255, 255, 255, 0.18);
}

.hero .button-primary {
  background: var(--gold-line);
  color: #141a24;
  border-color: var(--gold-line);
}

.hero .button-primary:hover {
  background: #d6b46e;
  color: #141a24;
  border-color: #d6b46e;
}

.quick-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.debts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}

.debt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Блок «Судьи на сайте» */
.judges-online-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-3);
}

.judge-online-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.judge-online-avatar-wrap {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
}

.judge-online-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.judge-online-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.judge-online-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.judge-online-role {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.judge-online-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--text-muted);
}

.judge-online-status.is-online {
  color: var(--success);
  font-weight: 500;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.status-dot-online {
  background: var(--success);
}

.status-dot-offline {
  background: var(--text-faint);
}

.hearing-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-3);
}

.hearing-card {
  display: flex;
  gap: var(--space-4);
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.hearing-card:hover {
  border-color: var(--gold-line);
  transform: translateY(-1px);
}

.hearing-date {
  flex-shrink: 0;
  width: 62px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: var(--gold-strong);
  text-align: center;
  padding: 8px 4px;
  border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent);
}

.hearing-day {
  display: block;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.hearing-month {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.hearing-body { min-width: 0; flex: 1; }

.hearing-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 4px;
}

.hearing-claim {
  white-space: nowrap;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 17px;
}

.hearing-meta {
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.5;
}

/* ───────── Вход ───────── */
.auth-card {
  max-width: 460px;
  margin: var(--space-7) auto;
  text-align: center;
  padding: var(--space-6);
  border-top: 3px solid var(--gold-line);
}

.auth-card .brand-mark {
  width: 56px;
  height: 56px;
  padding: 10px;
  margin: 0 auto var(--space-4);
  color: var(--gold);
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 30%, transparent);
  display: block;
}

.auth-card p { color: var(--text-muted); }
.auth-card .button { margin-top: var(--space-3); }

/* ───────── Конструктор ───────── */
.template-picker-card {
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.template-picker-card .form-group {
  flex: 1;
  margin: 0;
}

.constructor-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: var(--space-4);
  align-items: start;
}

.constructor-preview-pane {
  position: sticky;
  top: 84px;
}

.constructor-preview-pane .pane-header h2 { white-space: nowrap; }

.draft-indicator {
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.draft-indicator::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.preview-container {
  transition: opacity 0.2s ease;
}

.preview-container.htmx-request {
  opacity: 0.55;
}

.preview-container.htmx-settling .preview-wrapper,
.preview-wrapper {
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.preview-placeholder {
  text-align: center;
  color: var(--text-muted);
  padding: var(--space-7) var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.preview-placeholder p { margin: 0; }

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.preview-meta strong {
  font-family: var(--font-serif);
  font-size: 16px;
}

.preview-template-name {
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 4px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.preview-tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.tab-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.preview-tab-pane { display: none; }
.preview-tab-pane.active { display: block; }

/* Лист документа — следует теме сайта. */
.document-sheet {
  background: var(--paper);
  color: var(--paper-text);
  border: 1px solid var(--paper-border);
  border-radius: 4px;
  padding: 40px 44px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.6;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04), 0 12px 32px -12px rgba(0, 0, 0, 0.25);
  max-height: 72vh;
  overflow: auto;
  overflow-wrap: anywhere;
}

.document-sheet a { color: var(--gold); }
.document-sheet blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid var(--gold-line);
}

.bb-center { text-align: center; }
.bb-left { text-align: left; }
.bb-right { text-align: right; }
.bb-justify { text-align: justify; }
.bb-font-serif { font-family: var(--font-serif); }
.bb-size-1 { font-size: 9px; }
.bb-size-2 { font-size: 10px; }
.bb-size-3 { font-size: 12px; }
.bb-size-4 { font-size: 15px; }
.bb-size-5 { font-size: 18px; }
.bb-size-6 { font-size: 22px; }
.bb-size-7 { font-size: 26px; }
.bb-table {
  border-collapse: collapse;
  table-layout: fixed;
  max-width: 100%;
  font: inherit;
  color: inherit;
}
.bb-table td {
  padding: 0;
  border: 0;
  vertical-align: top;
}
.document-sheet img {
  max-width: 100%;
  height: auto;
}

.bbcode-area {
  width: 100%;
  min-height: 420px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-sunken);
  color: var(--text);
  font: 13px/1.55 var(--font-mono);
  resize: vertical;
}

.preview-error-box {
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

.preview-error-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.preview-error-message { font-size: 14px; }

/* ───────── История и фильтры ───────── */
.filter-card { margin-bottom: var(--space-4); }

.filter-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: var(--space-3);
  align-items: end;
}

.filter-form-claims {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-form-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
}

.filter-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.filter-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ───────── Календарь недели (Заседания) ───────── */
.data-table tbody tr.week-day-today td {
  background: var(--gold-soft);
}

.data-table tbody tr.week-day-today td:first-child {
  box-shadow: inset 3px 0 0 var(--gold-line);
}

.week-day-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  white-space: nowrap;
}

.week-day-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 15px;
}

.week-hearings-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.week-hearing-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Отмена заседания прямо из календаря: крестик справа, подтверждение — data-confirm в app.js. */
.week-hearing-cancel {
  margin: 0 0 0 auto;
}

.hearing-cancel-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.hearing-cancel-button svg {
  width: 16px;
  height: 16px;
}

.hearing-cancel-button:hover,
.hearing-cancel-button:focus-visible {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger);
}

/* ───────── Штрафы, выплаты, премии и статистика ───────── */
.subnav {
  margin-bottom: var(--space-5);
}

.author-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 12px 16px;
  margin-bottom: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-line);
  border-radius: var(--radius);
  font-size: 14px;
}

details.card.ledger-details,
details.card.past-hearings-card {
  padding: 0;
  overflow: hidden;
}

details.card.ledger-details > summary,
details.card.past-hearings-card > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  transition: background-color 0.15s ease;
}

details.card.ledger-details > summary:hover,
details.card.past-hearings-card > summary:hover {
  background: var(--surface-2);
}

details.card.ledger-details > summary::-webkit-details-marker,
details.card.past-hearings-card > summary::-webkit-details-marker {
  display: none;
}

details.card.ledger-details > summary::after,
details.card.past-hearings-card > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-right: 4px;
}

details.card.ledger-details[open] > summary,
details.card.past-hearings-card[open] > summary {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

details.card.ledger-details[open] > summary::after,
details.card.past-hearings-card[open] > summary::after {
  transform: rotate(-135deg);
}

details.card.ledger-details > form {
  padding: var(--space-5);
}

details.card.ledger-details fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

details.card.ledger-details legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--space-4);
}

.form-grid .form-group-full {
  grid-column: 1 / -1;
}

.ledger-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
  align-items: start;
}

.ledger-actions-grid > * {
  min-width: 0;
}

.ledger-actions-grid .card + .card {
  margin-top: 0;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13.5px;
}

.report-pre {
  margin: 0;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text);
  font: 13.5px/1.65 var(--font-mono);
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.stats-grid > *,
.grid-profile > *,
.constructor-layout > * {
  min-width: 0;
}

.stats-grid .card + .card {
  margin-top: 0;
}

.stats-chart-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: var(--space-3);
}

.stats-chart {
  display: block;
  width: 100%;
  min-width: 480px;
  height: auto;
}

.chart-track {
  fill: var(--surface-sunken);
}

.chart-bar {
  fill: var(--primary);
  opacity: 0.88;
  transition: opacity 0.15s ease;
}

.stats-chart g:hover .chart-bar {
  fill: var(--gold);
  opacity: 1;
}

.chart-label {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
}

.chart-value {
  fill: var(--gold-strong);
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
}

/* ───────── Просмотр документа ───────── */
.document-view-card .document-sheet { max-height: none; }

/* ───────── Профиль ───────── */
.grid-profile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: var(--space-4);
  align-items: start;
}

.grid-profile .card + .card { margin-top: 0; }

.profile-details {
  margin: 0;
  display: grid;
  gap: var(--space-3);
}

.profile-details dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.profile-details dd {
  margin: 2px 0 0;
  font-size: 15px;
}

.signature-preview-box {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--surface-2);
}

.signature-preview-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.signature-image-container {
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  display: flex;
  justify-content: center;
  border: 1px solid var(--paper-border);
}

.signature-img {
  max-width: 100%;
  max-height: 90px;
}

.signature-url-text {
  margin: var(--space-2) 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.signature-text-box {
  background: var(--paper);
  color: var(--paper-text);
  border-radius: var(--radius-sm);
  border: 1px solid var(--paper-border);
  padding: var(--space-4);
  text-align: center;
}

.signature-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 22px;
}

.signature-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ───────── Статистика v2 ───────── */
.stats-subnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.stats-judge-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.stats-filter-card {
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
}

.stats-date-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.stats-date-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stats-date-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stats-metrics-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-value {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--text);
  line-height: 1.2;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-faint);
}

.metric-danger {
  color: var(--danger);
}

.metric-warning {
  color: var(--warning);
}

.stats-overdue-card {
  margin-top: var(--space-4);
}

.stats-overdue-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.overdue-metric-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.overdue-count {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
}

.stats-hearing-summary {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.stats-sub-heading {
  margin-top: var(--space-4);
}

/* ───────── Адаптив ───────── */
@media (max-width: 1360px) {
  .brand-sub { display: none; }
}

@media (max-width: 980px) {
  .constructor-layout,
  .grid-profile,
  .stats-grid,
  .ledger-actions-grid {
    grid-template-columns: 1fr;
  }

  .constructor-preview-pane { position: static; }

  .filter-form,
  .filter-form-claims,
  .filter-form-2 {
    grid-template-columns: 1fr 1fr;
  }

  .filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .debts-grid,
  .judges-online-grid { grid-template-columns: 1fr; }

  .site-header-inner {
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    padding: 10px var(--space-4);
  }

  .brand-sub { display: none; }

  .site-nav + .user-bar,
  .user-bar { margin-left: auto; }

  .brand-mark { width: 30px; height: 30px; padding: 5px; }

  .brand-name { font-size: 17px; }

  .role-badge { padding: 4px 8px; }

  .site-nav {
    order: 3;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: 100%;
    margin: 0 -8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-link.active::after { bottom: -2px; }

  .site-main { padding: var(--space-5) var(--space-4) var(--space-6); }

  h1 { font-size: 25px; }

  .hero { padding: var(--space-5); }

  .card { padding: var(--space-4); }

  .table-card > .pane-header,
  details.card.ledger-details > summary,
  details.card.ledger-details > form {
    padding: var(--space-4);
  }

  .form-grid { grid-template-columns: 1fr; }

  .document-sheet { padding: 24px 20px; font-size: 14px; }

  .filter-form,
  .filter-form-claims,
  .filter-form-2 {
    grid-template-columns: 1fr;
  }

  .data-table th,
  .data-table td { padding: 10px 12px; }

  .stats-judge-form {
    margin-left: 0;
    width: 100%;
  }

  .stats-date-form {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 420px) {
  /* На телефоне остаётся только знак: кнопки шапки помещаются в одну строку с ним. */
  .brand-text { display: none; }
}

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