/**
 * theOne News — тёмная тема, shadcn-style sidebar, единая сетка отступов (--sp-*)
 */

:root {
  color-scheme: dark;

  /* --- Шкала отступов: только шаг 4px, без «случайных» значений --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;
  --sp-10: 64px;

  --page-pad-x: var(--sp-7);
  --page-pad-y: var(--sp-6);
  --section-gap: var(--sp-6);
  --panel-pad: var(--sp-6);
  --stack-gap: var(--sp-4);
  --stack-gap-tight: var(--sp-3);

  /* Sidebar (shadcn-style, sticky + опционально свёрнутый rail) */
  --sidebar-width: 16rem;
  --sidebar-width-collapsed: 4.25rem;
  --sidebar-pad-x: var(--sp-3);
  --sidebar-z-drawer: 200;
  --sidebar-z-backdrop: 199;
  --mobile-app-header-z: 210;
  --sidebar-bg: #0a0a0b;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-nav-radius: 8px;
  --sidebar-item-py: 10px;
  --sidebar-item-px: var(--sp-3);

  /* Фоны контента */
  --bg-root: #0c0c0e;
  --surface-0: #111114;
  --surface-1: #16161b;
  --surface-2: #1c1c22;
  --surface-raised: #232329;

  --border-subtle: rgba(255, 255, 255, 0.055);
  --border-default: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.13);

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;

  --accent: #94b8f0;
  --accent-strong: #c4d7f7;
  --accent-muted: rgba(148, 184, 240, 0.14);
  --accent-ring: rgba(148, 184, 240, 0.38);
  --sidebar-active-bg: rgba(255, 255, 255, 0.06);
  --sidebar-hover-bg: rgba(255, 255, 255, 0.04);

  --success: #6ee7b7;
  --success-muted: rgba(110, 231, 183, 0.13);
  --warning: #fbbf24;
  --warning-muted: rgba(251, 191, 36, 0.12);
  --error: #f9a8a8;
  --error-muted: rgba(249, 168, 168, 0.12);
  --info: #7dd3fc;
  --info-muted: rgba(125, 211, 252, 0.12);

  --shadow-card: 0 0 0 1px var(--border-subtle), 0 18px 48px rgba(0, 0, 0, 0.42);
  --shadow-md: 0 24px 64px rgba(0, 0, 0, 0.5);

  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  --font-display: "Outfit", "Inter", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: clamp(1.75rem, 2vw, 2.25rem);

  --leading-snug: 1.35;
  --leading-normal: 1.55;
  --leading-relaxed: 1.68;

  /* Легаси-имена → те же токены */
  --bg: var(--bg-root);
  --panel: var(--surface-1);
  --surface: var(--surface-1);
  --surface-muted: var(--surface-0);
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --border: var(--border-default);
  --shadow: var(--shadow-md);
  --radius: var(--radius-lg);
  --accent-soft: var(--accent-muted);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-root);
  background-image:
    radial-gradient(ellipse 100% 70% at 0% -25%, rgba(148, 184, 240, 0.06), transparent 52%),
    linear-gradient(180deg, var(--bg-root), #080809);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.12s ease;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

input,
select,
textarea,
button {
  font: inherit;
}

::selection {
  background: var(--accent-muted);
  color: var(--text-primary);
}

/* ========== Shell: sidebar | main ========== */

.shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-root);
  transition: margin-left 0.2s ease;
}

@media (min-width: 981px) {
  .mobile-app-header {
    display: none !important;
  }
}

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

body.sidebar-drawer-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .main-wrap,
  .mobile-app-header,
  .sidebar-mobile-toggle,
  .sidebar-backdrop {
    transition: none !important;
  }
}

/* ========== Sidebar (sticky, скролл только в .sidebar-nav-scroll) ========== */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--sidebar-z-backdrop);
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(2px);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Мобильный app bar: только ≤980px (см. .mobile-app-header) */
.mobile-app-header {
  display: none;
}

.sidebar-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-mobile-toggle:hover {
  background: var(--sidebar-hover-bg);
}

.sidebar-mobile-toggle .icon-close {
  display: none;
}

.shell.sidebar-mobile-open .sidebar-mobile-toggle .icon-menu {
  display: none;
}

.shell.sidebar-mobile-open .sidebar-mobile-toggle .icon-close {
  display: block;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--text-primary);
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  transition: width 0.2s ease;
  z-index: 1;
}

.shell.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

.shell.sidebar-collapsed .sidebar-collapse-icon {
  transform: rotate(180deg);
}

.sidebar-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sidebar-pad-x) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-collapse-btn {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-top: var(--sp-1);
  padding: 0;
  border: none;
  border-radius: var(--sidebar-nav-radius);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-primary);
}

.sidebar-collapse-icon {
  display: block;
  transition: transform 0.2s ease;
}

@media (min-width: 981px) {
  .sidebar-collapse-btn {
    display: inline-flex;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 44px;
  min-width: 0;
}

.sidebar-brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--sidebar-nav-radius);
  object-fit: cover;
  background: var(--sidebar-active-bg);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

.sidebar-brand-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--leading-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.3;
}

/* Колонка под шапку, скроллящуюся середину и футер */
.sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: var(--sp-3) var(--sidebar-pad-x) 0;
}

/* Единственная зона вертикального скролла при переполнении навигации */
.sidebar-nav-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: var(--sp-3);
  margin-right: calc(-1 * var(--sp-1));
  padding-right: var(--sp-1);
}

.sidebar-nav-scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

.sidebar-group-label {
  margin: 0 0 var(--sp-2);
  padding: 0 var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.sidebar-content .sidebar-group-label:first-child {
  margin-top: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.sidebar-nav-icon {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: color 0.12s ease;
}

.sidebar-nav-item.is-active .sidebar-nav-icon {
  color: var(--accent-strong);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--sp-3);
  padding: var(--sidebar-item-py) var(--sidebar-item-px);
  border-radius: var(--sidebar-nav-radius);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-nav-item .sidebar-nav-count {
  margin-left: auto;
}

.sidebar-nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav-item.is-active {
  background: var(--sidebar-active-bg);
  color: var(--text-primary);
}

.sidebar-nav-text {
  flex: 1;
  min-width: 0;
}

.sidebar-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.sidebar-nav-item.is-active .sidebar-nav-count {
  background: var(--accent-muted);
  color: var(--accent-strong);
  border-color: rgba(148, 184, 240, 0.2);
}

.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: var(--sp-4) var(--sidebar-pad-x) var(--sp-5);
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
}

.sidebar-footer .sidebar-group-label,
.sidebar-footer-label {
  margin-bottom: var(--sp-3);
}

.sidebar-metrics {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}

.sidebar-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--sidebar-nav-radius);
  background: var(--sidebar-hover-bg);
  border: 1px solid transparent;
}

.sidebar-metric-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 500;
}

.sidebar-metric-value {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.sidebar-logout {
  margin: 0;
}

.sidebar-logout .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}

.sidebar-logout-icon {
  display: none;
  flex-shrink: 0;
}

/* Свёрнутый desktop-rail */
.shell.sidebar-collapsed .sidebar-brand-text,
.shell.sidebar-collapsed .sidebar-brand-sub,
.shell.sidebar-collapsed .sidebar-content .sidebar-group-label,
.shell.sidebar-collapsed .sidebar-footer-label,
.shell.sidebar-collapsed .sidebar-metrics,
.shell.sidebar-collapsed .sidebar-nav-text,
.shell.sidebar-collapsed .sidebar-nav-count {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell.sidebar-collapsed .sidebar-header {
  flex-direction: column;
  align-items: center;
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

.shell.sidebar-collapsed .sidebar-brand {
  justify-content: center;
}

.shell.sidebar-collapsed .sidebar-collapse-btn {
  margin-top: var(--sp-2);
  align-self: center;
}

.shell.sidebar-collapsed .sidebar-nav-item {
  justify-content: center;
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

.shell.sidebar-collapsed .sidebar-nav-icon {
  color: var(--text-secondary);
}

.shell.sidebar-collapsed .sidebar-nav-item.is-active .sidebar-nav-icon {
  color: var(--accent-strong);
}

.shell.sidebar-collapsed .sidebar-content {
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

.shell.sidebar-collapsed .sidebar-footer {
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

.shell.sidebar-collapsed .sidebar-logout-text {
  display: none;
}

.shell.sidebar-collapsed .sidebar-logout-icon {
  display: block;
}

.shell.sidebar-collapsed .sidebar-logout .button {
  min-height: 44px;
  padding: var(--sp-2);
}

/* ========== Main ========== */

.main {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: var(--page-pad-y) var(--page-pad-x);
}

.main-inner {
  width: 100%;
  max-width: none;
  margin: 0;
}

/* Вертикальный ритм: равные отступы между секциями/блоками контента */
.main-inner > section + section {
  margin-top: var(--section-gap);
}

.main-inner > section + .panel,
.main-inner > .panel + section,
.main-inner > .panel + .panel {
  margin-top: var(--section-gap);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--section-gap);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}

.eyebrow {
  margin: 0 0 var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--leading-snug);
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

.lead {
  margin: var(--sp-3) 0 0;
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  font-weight: 400;
  max-width: min(52ch, 100%);
}

.muted,
.field span,
.field-hint,
.stat-helper {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* ========== Панели / карточки: единый padding и скругление ========== */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--panel-pad);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.panel-head h2 {
  margin-bottom: var(--sp-2);
}

/* Сетка метрик: одинаковая высота карточек */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-6);
  margin-bottom: var(--section-gap);
  align-items: stretch;
}

.stats-grid > .stat-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 140px;
}

.stats-grid > .stat-card .stat-helper {
  margin-top: auto;
}

.stat-card {
  padding: var(--panel-pad);
  gap: var(--sp-3);
}

.stat-card strong {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: var(--leading-snug);
}

.stat-label {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.stat-helper {
  margin: 0;
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--text-tertiary);
}

.grid {
  display: grid;
  gap: var(--section-gap);
}

.layout-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
  align-items: stretch;
  gap: var(--section-gap);
}

.layout-grid > .panel {
  height: 100%;
  min-height: 0;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--stack-gap);
}

.split-view {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: var(--section-gap);
}

.split-view > .panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.detail-view {
  align-items: stretch;
}

.stack {
  display: grid;
  gap: var(--stack-gap);
}

.stack-tight {
  display: grid;
  gap: var(--stack-gap-tight);
}

/* ========== Forms ========== */

.field {
  display: grid;
  gap: var(--sp-2);
}

.field span {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  color: var(--text-tertiary);
}

input,
select,
textarea {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  color: var(--text-primary);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}

.checkbox-row input {
  width: auto;
  margin-top: var(--sp-1);
}

.checkbox-row span {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.form-options {
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  border: 1px solid var(--border-subtle);
  gap: var(--sp-3);
  display: grid;
}

/* ========== Buttons ========== */

.button,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition:
    transform 0.1s ease,
    filter 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

.button {
  background: linear-gradient(180deg, #9ebdf5 0%, #7fa3e8 50%, #6b94e0 100%);
  color: #0c1420;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 6px 20px rgba(0, 0, 0, 0.35);
}

.button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  text-decoration: none;
}

.button.is-loading {
  opacity: 0.85;
  cursor: progress;
}

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

.button-secondary:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  text-decoration: none;
}

.button-full {
  width: 100%;
}

.button-row,
.actions,
.inline-meta,
.filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
}

.actions {
  justify-content: flex-end;
}

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

.filters-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.filter-actions {
  align-self: end;
}

/* ========== Badges ========== */

.ui-badge,
.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.ui-badge-muted,
.pill {
  background: var(--surface-2);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.ui-badge-success {
  background: var(--success-muted);
  border-color: rgba(110, 231, 183, 0.22);
  color: var(--success);
}

.ui-badge-warning,
.badge {
  background: var(--warning-muted);
  border-color: rgba(251, 191, 36, 0.2);
  color: var(--warning);
}

.ui-badge-error {
  background: var(--error-muted);
  border-color: rgba(249, 168, 168, 0.2);
  color: var(--error);
}

.ui-badge-info {
  background: var(--info-muted);
  border-color: rgba(125, 211, 252, 0.2);
  color: var(--info);
}

/* ========== Tables ========== */

.table-wrap {
  overflow-x: auto;
  margin: calc(-1 * var(--sp-2));
  padding: var(--sp-2);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  text-align: left;
}

.table th {
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ========== Lists & карточки контента ========== */

.news-list,
.rule-list,
.account-list {
  display: grid;
  gap: var(--sp-4);
}

.news-card,
.rule-card,
.rule-chip,
.account-card {
  display: grid;
  gap: var(--sp-4);
  padding: var(--panel-pad);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--surface-0);
}

.news-card {
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.news-card:hover {
  border-color: rgba(148, 184, 240, 0.22);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  text-decoration: none;
}

.news-card h3 {
  color: var(--text-primary);
  font-size: var(--text-base);
}

.news-card-top,
.news-card-meta,
.account-card-head,
.section-title-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  align-items: flex-start;
}

.account-card.is-focused {
  border-color: rgba(148, 184, 240, 0.35);
  box-shadow: 0 0 0 1px var(--accent-muted);
}

.auth-inline-form {
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-subtle);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4) var(--sp-6);
  margin: var(--sp-6) 0;
}

.meta-grid dt {
  margin: 0;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meta-grid dd {
  margin: var(--sp-2) 0 0;
  color: var(--text-primary);
}

.compact-meta {
  margin: var(--sp-2) 0;
}

.summary-box {
  margin-top: var(--sp-6);
  padding: var(--sp-4) var(--sp-6);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  border: 1px solid var(--border-subtle);
}

.summary-box strong {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.moderation-box {
  background: rgba(251, 191, 36, 0.06);
  border-color: rgba(251, 191, 36, 0.14);
  margin-top: var(--sp-6);
  margin-bottom: var(--sp-6);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

.compact-tags {
  margin-top: var(--sp-3);
}

.rule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.prose {
  white-space: pre-wrap;
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.empty-state {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-6);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-default);
  background: var(--surface-0);
  text-align: center;
}

.empty-state-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.empty-state-head h3 {
  text-align: left;
}

.empty-state h3 {
  color: var(--text-primary);
}

/* ========== Flash ========== */

.flash {
  margin-bottom: var(--section-gap);
  padding: var(--sp-4) var(--sp-6);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--text-sm);
  font-weight: 500;
}

.flash-error {
  background: var(--error-muted);
  border-color: rgba(249, 168, 168, 0.22);
  color: var(--error);
}

.flash-success {
  background: var(--success-muted);
  border-color: rgba(110, 231, 183, 0.22);
  color: var(--success);
}

.flash-info {
  background: var(--info-muted);
  border-color: rgba(125, 211, 252, 0.2);
  color: var(--info);
}

.compact-flash {
  margin-bottom: 0;
}

.mono {
  font-family: "JetBrains Mono", "IBM Plex Mono", "Consolas", monospace;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

pre {
  overflow-x: auto;
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: #050508;
  border: 1px solid var(--border-subtle);
  color: #d4d4d8;
  font-size: var(--text-xs);
  line-height: 1.5;
}

summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--accent);
}

/* ========== Auth ========== */

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background-color: var(--bg-root);
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -30%, rgba(148, 184, 240, 0.1), transparent 55%),
    linear-gradient(180deg, var(--bg-root), #080809);
}

.auth-card {
  width: min(420px, 100%);
  padding: var(--sp-9) var(--sp-7);
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  margin-top: var(--sp-3);
  font-size: var(--text-2xl);
}

/* ========== Tabs & modals ========== */

.tabs {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  margin-bottom: var(--section-gap);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-0);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  text-decoration: none;
}

.tab-btn.is-active {
  background: var(--accent-muted);
  border-color: rgba(148, 184, 240, 0.28);
  color: var(--accent-strong);
  font-weight: 600;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  padding: var(--sp-6);
  z-index: 1000;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  width: min(980px, 100%);
  max-height: calc(100vh - var(--sp-10));
  overflow: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.modal--narrow {
  width: min(480px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--panel-pad) var(--panel-pad) 0;
}

.modal-title {
  display: grid;
  gap: var(--sp-2);
}

.modal-body {
  padding: var(--sp-4) var(--panel-pad) var(--panel-pad);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-0);
  color: var(--text-primary);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.12s ease;
}

.modal-close:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.modal .panel {
  box-shadow: none;
  border: 1px solid var(--border-subtle);
}

/* Dropdown / details blocks (настройки) */
.dropdown {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
  padding: 0;
  overflow: hidden;
}

.dropdown > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  border-bottom: 1px solid transparent;
}

.dropdown > summary::-webkit-details-marker {
  display: none;
}

.dropdown > summary::after {
  content: "▾";
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  transition: transform 0.12s ease;
}

.dropdown[open] > summary {
  border-bottom-color: var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.dropdown[open] > summary::after {
  transform: rotate(180deg);
}

.dropdown > .grid,
.dropdown > .stack,
.dropdown > div {
  padding: var(--sp-5);
}

/* ========== Rich text editor ========== */

.rewrite-editor-form {
  display: grid;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.editor-label {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-3);
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.button-ghost {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--surface-1);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 600;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}

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

.toolbar-btn {
  min-height: 36px;
}

.rich-editor {
  flex: 1;
  min-height: 260px;
  max-height: min(70vh, 720px);
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-6);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: #0e0e12;
  color: var(--text-primary);
  outline: none;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.split-view > .panel .rich-editor {
  flex: 1;
}

.rich-editor:focus {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}

.attachments-block {
  margin-top: var(--sp-6);
}

@media (min-width: 981px) {
  .attachments-sticky {
    position: sticky;
    top: calc(var(--sp-6) + 8px);
  }
}

.attachment-list {
  margin: var(--sp-3) 0 0;
  padding-left: var(--sp-6);
}

.attachment-grid {
  list-style: none;
  margin: var(--sp-3) 0 0;
  padding-left: 0;
  display: grid;
  gap: var(--sp-3);
}

.attachment-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.01);
}

.attachment-item-info {
  min-width: 0;
}

.attachment-item-type .attachment-type-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.attachment-item-meta {
  margin-top: var(--sp-1);
  word-break: break-word;
}

.attachment-item-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  align-items: flex-end;
}

.attachment-summary {
  margin-top: var(--sp-2);
  font-size: var(--text-sm);
}

/* Media preview (compact thumbnails) */
.icon-button-mini {
  min-height: 32px;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-md);
}

.attachment-preview-wrap {
  margin-top: var(--sp-3);
}

.attachment-preview-thumb-wrap {
  position: relative;
  width: 160px;
  height: 110px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.attachment-preview-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attachment-preview-thumb-actions {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-2);
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.attachment-preview-thumb-wrap:hover .attachment-preview-thumb-actions {
  opacity: 1;
  pointer-events: auto;
}

.attachment-preview-modal-img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-md);
}

.original-body {
  white-space: pre-wrap;
}

.rewrite-tags {
  margin-top: var(--sp-6);
}

.debug-panel {
  margin-top: var(--sp-7);
}

.rewrite-head .lead {
  margin-top: var(--sp-3);
}

.review-panel {
  padding-bottom: var(--sp-6);
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}

/* Rewrite header actions + regenerate UI */
.rewrite-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.rewrite-head-text {
  min-width: 0;
}

.rewrite-head-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  min-height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-0);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.icon-button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.icon-button-text {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.htmx-indicator {
  display: none;
}

.htmx-indicator.htmx-request {
  display: block;
}

.rewrite-progress {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
}

.progress-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-bar-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, rgba(148, 184, 240, 0.25), rgba(148, 184, 240, 0.7), rgba(148, 184, 240, 0.25));
  animation: progress 1.2s ease-in-out infinite;
}

@keyframes progress {
  0% { transform: translateX(-60%); }
  50% { transform: translateX(60%); }
  100% { transform: translateX(180%); }
}

.skeleton-block {
  margin-top: var(--sp-4);
  display: grid;
  gap: var(--sp-3);
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255,255,255,0.06), rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-90 { width: 90%; }
.skeleton-line.w-100 { width: 100%; }

@keyframes shimmer {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* ========== Адаптив ========== */

@media (max-width: 1200px) {
  .layout-grid,
  .split-view,
  .stats-grid,
  .filters-grid,
  .form-grid,
  .two-up,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .layout-grid > .panel,
  .split-view > .panel {
    height: auto;
  }
}

@media (max-width: 980px) {
  .mobile-app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: var(--mobile-app-header-z);
    min-height: 52px;
    padding: var(--sp-2) var(--sp-4);
    padding-top: calc(var(--sp-2) + env(safe-area-inset-top, 0px));
    background: var(--bg-root);
    background: color-mix(in srgb, var(--bg-root) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
  }

  .mobile-header-side {
    flex: 0 0 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-header-side--spacer {
    pointer-events: none;
    visibility: hidden;
  }

  .mobile-header-brand {
    flex: 1;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    min-width: 0;
  }

  .mobile-header-brand-text {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-align: center;
    line-height: var(--leading-snug);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-header-logo {
    display: block;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--sidebar-active-bg);
  }

  .sidebar-backdrop:not([hidden]) {
    display: block;
  }

  .sidebar-mobile-toggle {
    display: inline-flex;
  }

  .shell {
    flex-direction: row;
    align-items: stretch;
    min-height: 100vh;
  }

  /* Off-canvas drawer: не занимает место в потоке, полная высота экрана */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(17.5rem, 88vw);
    height: 100vh;
    max-height: 100vh;
    z-index: var(--sidebar-z-drawer);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    border-right: 1px solid var(--sidebar-border);
    border-bottom: none;
    box-shadow: none;
  }

  .shell.sidebar-mobile-open .sidebar {
    transform: translateX(0);
    box-shadow: 24px 0 48px rgba(0, 0, 0, 0.45);
  }

  /* На телефоне drawer всегда полной ширины панели, не «узкий rail» */
  .shell.sidebar-collapsed .sidebar {
    width: min(17.5rem, 88vw);
  }

  .shell.sidebar-collapsed .sidebar-brand-text,
  .shell.sidebar-collapsed .sidebar-brand-sub,
  .shell.sidebar-collapsed .sidebar-content .sidebar-group-label,
  .shell.sidebar-collapsed .sidebar-footer-label,
  .shell.sidebar-collapsed .sidebar-metrics,
  .shell.sidebar-collapsed .sidebar-nav-text,
  .shell.sidebar-collapsed .sidebar-nav-count {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  .shell.sidebar-collapsed .sidebar-brand-text {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
  }

  .shell.sidebar-collapsed .sidebar-header {
    flex-direction: row;
    align-items: flex-start;
    padding-left: var(--sidebar-pad-x);
    padding-right: var(--sidebar-pad-x);
  }

  .shell.sidebar-collapsed .sidebar-brand {
    justify-content: flex-start;
  }

  .shell.sidebar-collapsed .sidebar-nav-item {
    justify-content: flex-start;
    padding-left: var(--sidebar-item-px);
    padding-right: var(--sidebar-item-px);
  }

  .shell.sidebar-collapsed .sidebar-content {
    padding-left: var(--sidebar-pad-x);
    padding-right: var(--sidebar-pad-x);
  }

  .shell.sidebar-collapsed .sidebar-footer {
    padding-left: var(--sidebar-pad-x);
    padding-right: var(--sidebar-pad-x);
  }

  .shell.sidebar-collapsed .sidebar-logout-text {
    display: inline;
  }

  .shell.sidebar-collapsed .sidebar-logout-icon {
    display: none;
  }

  .shell.sidebar-collapsed .sidebar-logout .button {
    min-height: 40px;
    padding: var(--sp-2) var(--sp-4);
  }

  .sidebar-collapse-btn {
    display: none !important;
  }

  .main-wrap {
    width: 100%;
    flex: 1;
    min-height: 100vh;
    min-width: 0;
  }

  .main {
    padding: var(--page-pad-y) var(--sp-4);
  }

  .page-header,
  .panel-head,
  .news-card-top,
  .news-card-meta,
  .account-card-head,
  .section-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  :root {
    --page-pad-x: var(--sp-4);
    --page-pad-y: var(--sp-5);
  }
}
