/* SVOD — дизайн-система.
   Тёмная боковая панель и светлое рабочее поле: тёмный текст на светлом фоне
   читается заметно легче, чем светлый на тёмном. Палитра рабочего поля взята
   из AQUATIC, боковая панель оставлена морской. */

:root {
  /* Боковая панель */
  --side-bg-top: #072433;
  --side-bg-bottom: #04161f;
  --side-text: #c2dbe7;
  --side-text-dim: #7e a0b0;
  --side-active: rgba(49, 216, 240, 0.16);
  --cyan: #31d8f0;

  /* Рабочее поле */
  --bg: #f6f8fb;
  --card: #ffffff;
  --card-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #1e293b;
  --ink-dim: #475569;
  --ink-faint: #64748b;
  --brand: #1f7ae0;
  --brand-soft: #eef6ff;
  --brand-line: #bfdbfe;

  --good: #059669;
  --good-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --idle: #64748b;
  --idle-soft: #f1f5f9;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 10px 30px rgba(16, 24, 40, 0.12);
  --sidebar: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Волны остались только на входе: на светлом рабочем поле они не нужны. */
.surface { display: none; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: #1663bd; text-decoration: none; }

h1, h2, h3 { margin: 0 0 10px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; margin-top: 16px; }
p { margin: 0 0 12px; }

.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); font-size: 13px; }
.icon { flex: 0 0 auto; }

/* ── Каркас ─────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  padding: 16px 12px 24px;
  background: linear-gradient(180deg, var(--side-bg-top), var(--side-bg-bottom));
  color: var(--side-text);
  display: flex; flex-direction: column;
}
.sidebar a { color: var(--side-text); }
.sidebar a:hover { color: #ffffff; }

.brand { display: flex; align-items: center; gap: 9px; padding: 4px 6px 20px; }
.brand .mark { height: 34px; width: auto; display: block; flex: 0 0 auto; }
.brand .words { min-width: 0; }
.brand .word { display: block; height: 15px; width: auto; }
.brand .logo { font-size: 19px; font-weight: 700; letter-spacing: 0.18em; color: #fff; display: block; }
.brand .tag {
  display: block; font-size: 8.5px; letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.45); text-transform: uppercase; margin-top: 4px;
}
.brand:hover { opacity: 0.92; }

.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.4); padding: 0 10px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item .label { flex: 1; min-width: 0; }
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: var(--side-active); color: #fff; }
.nav-item.active .icon { color: var(--cyan); }
.nav-item .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.nav-item .dot.partial { background: #f0b93f; }
.nav-item .dot.planned { background: rgba(255, 255, 255, 0.3); }

.sidebar-foot {
  margin-top: auto; padding: 12px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-foot .faint { color: rgba(255, 255, 255, 0.5); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 14px; color: var(--ink-dim); }

.segmented {
  display: inline-flex; gap: 3px; padding: 3px; border-radius: var(--radius-sm);
  background: var(--card-muted); border: 1px solid var(--border);
}
.segmented a, .segmented button {
  padding: 6px 14px; border-radius: 7px; font-size: 14px; color: var(--ink-dim);
  border: 1px solid transparent; background: transparent; cursor: pointer; font-family: inherit;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.8); }
.segmented .on { background: var(--card); border-color: var(--border); color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }

.content { padding: 22px 24px 64px; max-width: 1440px; width: 100%; }
.page-head { margin-bottom: 18px; }
.page-head .sub { color: var(--ink-dim); max-width: 82ch; margin: 0; }

/* ── Карточки ───────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.card-head .icon { color: var(--brand); }

.grid { display: grid; gap: 16px; align-items: stretch; }
.grid > .card { margin-top: 0; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }

/* ── Показатель ─────────────────────────────────────────── */

.kpi { display: flex; gap: 14px; align-items: flex-start; }
.kpi .badge {
  width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); border: 1px solid var(--brand-line); color: var(--brand);
}
.kpi .badge.warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.kpi .badge.bad { background: var(--bad-soft); border-color: #fecaca; color: var(--bad); }
.kpi .body { min-width: 0; flex: 1; }
.kpi .label { font-size: 13.5px; color: var(--ink-faint); margin-bottom: 4px; }
.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; color: var(--ink); }
.kpi .value.blank { color: var(--ink-faint); font-weight: 500; }
.kpi .delta { font-size: 13.5px; margin-top: 5px; display: flex; align-items: center; gap: 5px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.none { color: var(--ink-faint); }

/* ── Значки состояния ──────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border); color: var(--ink-dim);
  background: var(--idle-soft); white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--idle); }
.pill.ok { color: var(--good); border-color: #a7f3d0; background: var(--good-soft); }
.pill.ok::before { background: var(--good); }
.pill.warn { color: var(--warn); border-color: #fde68a; background: var(--warn-soft); }
.pill.warn::before { background: var(--warn); }
.pill.bad { color: var(--bad); border-color: #fecaca; background: var(--bad-soft); }
.pill.bad::before { background: var(--bad); }
.pill.idle { color: var(--idle); }
.pill.plain::before { display: none; }

/* ── Строки событий ────────────────────────────────────── */

.event {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--card-muted);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
}
.event.critical { border-left-color: var(--bad); background: var(--bad-soft); }
.event.important { border-left-color: #f59e0b; background: var(--warn-soft); }
.event .badge {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; background: var(--card); border: 1px solid var(--border); color: var(--ink-dim);
}
.event .body { flex: 1; min-width: 0; }
.event .title { font-size: 14.5px; color: var(--ink); }
.event .meta { font-size: 13px; color: var(--ink-faint); }

/* ── Формы ─────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; color: var(--ink-dim); margin-bottom: 6px; font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%; padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--ink); font-family: inherit; font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.15);
}
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--brand); background: var(--brand);
  color: #fff; font-size: 14.5px; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: #1663bd; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: var(--card); border-color: var(--border-strong); color: var(--ink-dim); }
.btn.ghost:hover { background: var(--card-muted); color: var(--ink); }
.btn.small { padding: 6px 12px; font-size: 13.5px; }

.alert {
  padding: 12px 15px; border-radius: var(--radius-sm);
  border: 1px solid #fecaca; background: var(--bad-soft);
  color: #991b1b; margin-bottom: 16px; font-size: 14.5px;
}

/* ── Таблицы ───────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th, table.data td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--border); vertical-align: top;
}
table.data th {
  color: var(--ink-faint); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.06em;
  white-space: nowrap; cursor: pointer; user-select: none;
  background: var(--card-muted);
}
table.data thead th:first-child { border-top-left-radius: 8px; }
table.data thead th:last-child { border-top-right-radius: 8px; }
table.data th[data-sort]::after { content: " ↕"; font-size: 9px; opacity: 0.5; }
table.data th[data-sort][data-dir="asc"]::after { content: " ↑"; color: var(--brand); opacity: 1; }
table.data th[data-sort][data-dir="desc"]::after { content: " ↓"; color: var(--brand); opacity: 1; }
table.data td { color: var(--ink-dim); }
table.data tbody tr:hover { background: var(--card-muted); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody th { background: transparent; text-transform: none; letter-spacing: 0;
  font-size: 13.5px; color: var(--ink-faint); font-weight: 500; cursor: default; }

/* ── Пустое состояние ──────────────────────────────────── */

.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 26px;
  background: var(--card);
}
.empty h2 { margin-bottom: 8px; }
.empty .what { color: var(--ink-dim); max-width: 78ch; margin-bottom: 14px; }
.empty .needs {
  border-left: 3px solid var(--brand); padding: 10px 0 10px 15px;
  color: var(--ink); max-width: 78ch; background: var(--brand-soft);
  border-radius: 0 8px 8px 0; padding-right: 12px;
}

/* ── Прогресс ──────────────────────────────────────────── */

.progress { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--brand), #4aa8ff);
  transition: width 0.4s ease;
}

/* ── Вход ──────────────────────────────────────────────── */

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; z-index: 1;
  background: linear-gradient(180deg, #0a2e42 0%, #072433 45%, #051d29 100%);
}
.login-shell .surface { display: block; position: fixed; inset: 0 0 auto 0; height: 300px; z-index: 0; pointer-events: none; }
.login-shell .surface img { width: 100%; height: 100%; object-fit: cover; opacity: 0.7; }
/* Карточка входа тёмная: логотип светлый, на белом фоне он бы пропал. */
.login-card {
  width: 100%; max-width: 400px; position: relative; z-index: 1;
  background: rgba(7, 36, 51, 0.82);
  border: 1px solid rgba(126, 200, 227, 0.22);
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  color: #eaf6fb;
}
.login-card .brand { justify-content: center; padding: 0 0 20px; flex-direction: column; gap: 6px; }
.login-card .brand .lockup { width: 210px; height: auto; display: block; }
.login-card .brand .tag { text-align: center; color: rgba(255, 255, 255, 0.5); }
.login-card h1 { color: #fff; }
.login-card .field label { color: #b9d6e4; }
.login-card .faint { color: rgba(255, 255, 255, 0.5); }
.login-card input[type="email"], .login-card input[type="password"], .login-card input[type="text"] {
  background: rgba(3, 18, 27, 0.55);
  border-color: rgba(126, 200, 227, 0.28);
  color: #eaf6fb;
}
.login-card input::placeholder { color: rgba(255, 255, 255, 0.35); }
.login-card input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(49, 216, 240, 0.18); }
.login-card .alert { background: rgba(220, 38, 38, 0.16); border-color: rgba(255, 120, 120, 0.4); color: #ffd9d9; }
.login-card .btn { background: var(--cyan); border-color: var(--cyan); color: #04202b; font-weight: 600; }
.login-card .btn:hover { background: #5ce4f7; color: #04202b; }

/* ── Подвал ────────────────────────────────────────────── */

.footnote {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--ink-faint); font-size: 13px; margin-top: 18px;
}

/* ── Списки ────────────────────────────────────────────── */

.stage-list { margin: 0 0 12px; padding-left: 20px; }
.stage-list li { margin-bottom: 6px; color: var(--ink-dim); }
.stage-list.done li { color: var(--ink); }

/* ── Появление ─────────────────────────────────────────── */

.card, .empty { animation: rise 0.24s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

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

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

.menu-toggle { display: none; }

@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: 250px;
    transform: translateX(-100%); transition: transform 0.2s ease; overflow-y: auto;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 10; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px 14px 48px; }
  .topbar { padding: 12px 14px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}
