/* WestStar Media Creator — CSS 1/2: токены темы, раскладка (топбар + боковое меню), карточки, плитки.
   Палитра — панель руководителя AQS (frontend/dashboard): тёплые нейтральные поверхности, синий акцент.
   Тёмная тема включается классом .dark на <html> (static/js/hub.js, localStorage 'hub-theme'). */

:root {
  color-scheme: light;
  --page: #f0f0ec;
  --surface-1: #fcfcfb;
  --surface-2: #f4f4f1;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --border: rgba(11, 11, 11, 0.1);
  --border-strong: rgba(11, 11, 11, 0.2);
  --track: #e8e7e1;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(42, 120, 214, 0.12);
  --good: #0ca30c;
  --good-text: #006300;
  --good-soft: rgba(12, 163, 12, 0.14);
  --warning: #fab219;
  --warning-text: #7a5200;
  --warning-soft: rgba(250, 178, 25, 0.18);
  --critical: #d03b3b;
  --critical-text: #a12525;
  --critical-soft: rgba(208, 59, 59, 0.14);
  --info-soft: rgba(42, 120, 214, 0.12);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 1px 1px rgba(11, 11, 11, 0.03);
  --shadow-pop: 0 10px 30px rgba(11, 11, 11, 0.14);
  --radius: 10px;
  --card-inset: 22px;
  --topbar-h: 56px;
}

html.dark {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.22);
  --track: #2c2c2a;
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.2);
  --good: #0ca30c;
  --good-text: #4ade80;
  --good-soft: rgba(12, 163, 12, 0.22);
  --warning: #fab219;
  --warning-text: #fde68a;
  --warning-soft: rgba(250, 178, 25, 0.2);
  --critical: #e66767;
  --critical-text: #fca5a5;
  --critical-soft: rgba(230, 103, 103, 0.2);
  --info-soft: rgba(57, 135, 229, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
.icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* --- Layout --------------------------------------------------------------- */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }
.app-body { display: flex; flex: 1; min-width: 0; }
.content-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-content { flex: 1; padding: 24px; max-width: 1320px; width: 100%; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 6px; }
.topbar-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; padding-right: 14px; margin-right: 6px; border-right: 1px solid var(--border); }
.topbar-brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.topbar-title { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; color: var(--ink); }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.user-chip .avatar { width: 30px; height: 30px; border-radius: 999px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.user-chip .name { font-weight: 500; line-height: 1.1; font-size: 13px; }

.sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  position: sticky; top: var(--topbar-h);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0 8px; }
.nav-group { margin-bottom: 6px; }
.nav-group-title { padding: 12px 20px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 20px; font-size: 14px; color: var(--ink); transition: background-color .15s ease; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 26px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-item .icon { color: var(--muted); }
.nav-item.active .icon { color: var(--accent); }
.nav-count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: 999px; }
.sidebar-foot { padding: 12px 20px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

/* --- Page header ----------------------------------------------------------- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* --- Cards ----------------------------------------------------------------- */
.card {
  background: var(--surface-1);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px var(--card-inset) var(--card-inset);
  margin-bottom: 16px;
}
.card > h2, .card-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.card.flush { padding: 0; }
.section-band { display: flex; align-items: center; gap: 12px; margin: 28px 0 14px; flex-wrap: wrap; }
.section-band.band-first { margin-top: 4px; }
.section-band > h2 { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 0; white-space: nowrap; }
.section-band > .rule { flex: 1 1 40px; height: 1px; background: var(--border); }
.section-band > .band-actions { display: flex; gap: 8px; align-items: center; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.stat-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px var(--card-inset); display: flex; flex-direction: column; min-height: 104px; color: var(--ink); }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: auto; padding-top: 8px; text-align: right; font-variant-numeric: tabular-nums; }
.stat-card.is-warn .value { color: var(--warning-text); }
.stat-card.is-bad .value { color: var(--critical-text); }
.stat-card.is-good .value { color: var(--good-text); }
.stat-link { transition: border-color .15s ease, box-shadow .15s ease; }
.stat-link:hover { border-color: var(--border-strong); box-shadow: 0 4px 14px rgba(0, 0, 0, .08); text-decoration: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }

.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* --- Login ----------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--page); }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo { text-align: center; margin-bottom: 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-logo .brand-mark { width: 44px; height: 44px; font-size: 18px; border-radius: 12px; }
.auth-logo h1 { font-size: 20px; font-weight: 700; }
.auth-logo p { color: var(--muted); font-size: 13px; }

/* --- Mobile ---------------------------------------------------------------- */
@media (max-width: 860px) {
  :root { --card-inset: 14px; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar { position: fixed; top: var(--topbar-h); left: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0, 0, 0, .45); z-index: 40; }
  .grid-2 { grid-template-columns: 1fr; }
  .main-content { padding: 14px; }
  .topbar { padding: 0 10px; }
  .topbar-brand { padding-right: 8px; }
  .topbar-brand span.brand-text { display: none; }
  .page-title { font-size: 19px; }
  .stat-card .value { font-size: 24px; }
}
@media (max-width: 520px) {
  .topbar-title, .user-chip .name, .dropdown-toggle .muted { display: none; }
  .topbar { gap: 4px; }
  .topbar-left, .topbar-right { gap: 2px; }
  .topbar-brand { margin-right: 0; }
  .user-chip { padding: 4px; }
}
