/* ============================================================================
   Cockpit · Nano Banana — Amplitude-inspired dark design system
   Sidebar shell · electric-blue accent · calm data-dense surfaces
   ========================================================================== */

:root {
  /* surfaces (deep navy → elevated) */
  --bg:          #0a0d14;
  --sidebar:     #0d111b;
  --surface:     #121826;
  --surface-2:   #18203015;  /* unused alpha guard */
  --card:        #131a28;
  --card-2:      #19212f;
  --card-3:      #202938;
  --border:      #222b3b;
  --border-soft: #1a2230;

  /* text */
  --text:        #e8ecf3;
  --text-dim:    #8b95a7;
  --text-faint:  #5b657a;

  /* brand — Amplitude electric blue */
  --accent:        #2e6ff2;
  --accent-hover:  #4c8dff;
  --accent-ink:    #ffffff;
  --accent-soft:   rgba(46, 111, 242, 0.14);
  --accent-line:   rgba(46, 111, 242, 0.45);

  /* semantic */
  --green:  #34d399;
  --red:    #f87171;
  --amber:  #fbbf24;
  --orange: #fb923c;
  --purple: #a78bfa;
  --teal:   #2dd4bf;

  /* geometry */
  --radius:    12px;
  --radius-sm: 9px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 10px 30px -16px rgba(0,0,0,.65);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);

  --sidebar-w: 252px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

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

/* slim scrollbars to match the dark shell */
* { scrollbar-width: thin; scrollbar-color: #2b3547 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #2b3547; border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #3a465b; background-clip: padding-box; }

/* ============================================================================
   App shell — fixed sidebar + scrolling main column
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  z-index: 40;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 18px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-head .logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-size: 17px;
  background: linear-gradient(135deg, var(--accent) 0%, #1b4fd1 100%);
  box-shadow: 0 4px 12px -4px rgba(46,111,242,.6);
}
.sidebar-head .brand { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.sidebar-head .brand small { display: block; font-weight: 500; font-size: 0.68rem; color: var(--text-faint); letter-spacing: .04em; text-transform: uppercase; }

.deploy-switch { padding: 10px 14px 0; }
.deploy-select {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}
.deploy-select:hover { border-color: var(--accent-line); }
.deploy-select:focus { outline: none; border-color: var(--accent); }
.topbar .deploy-select { width: auto; max-width: 42vw; }

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 10px 16px;
}
.nav-section {
  padding: 14px 12px 6px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}
/* Base icon size. Without this, an inline .ico SVG that has no width/height
   attributes and is NOT inside .nav-item (e.g. the logout link) renders at the
   replaced-element default and balloons. Keep all .ico at a sane 18px. */
.ico { width: 18px; height: 18px; flex: 0 0 auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav-item.active {
  background: var(--accent-soft);
  color: #cfe0ff;
  font-weight: 600;
}
.nav-item.active .ico { opacity: 1; color: var(--accent-hover); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-hover);
}

.sidebar-foot {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--border-soft);
}
.sidebar-foot .logout {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
}
.sidebar-foot .logout:hover { background: var(--card-2); color: var(--text); text-decoration: none; }

.main-col { min-width: 0; display: flex; flex-direction: column; }

/* mobile top bar (hidden on desktop) */
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 14px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand { font-weight: 700; }
.topbar .logout { margin-left: auto; color: var(--text-dim); }
.nav-toggle {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  cursor: pointer;
}
.scrim { display: none; }

/* ============================================================================
   Content
   ========================================================================== */
.content { padding: 28px 32px 64px; max-width: 1180px; margin: 0 auto; width: 100%; }

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 1.04rem; font-weight: 650; letter-spacing: -0.01em; margin: 30px 0 14px; }
h3 { font-size: 0.92rem; font-weight: 600; margin: 22px 0 10px; color: var(--text-dim); }
p  { margin: 0 0 12px; }

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

/* ---- freshness plaque ---- */
.freshness {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-dim);
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  margin: 4px 0 22px;
}
.fresh-plaque { color: var(--text-dim); font-size: 0.84rem; margin: 4px 0 14px; }

.badge-progress {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 600;
  color: var(--accent-hover);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
}
.badge-progress::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(46,111,242,.18); }

/* ---- period selector ---- */
.period-bar {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
}
.period-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 15px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transition: background .12s ease, color .12s ease;
}
.period-btn:hover { color: var(--text); background: var(--card-2); }
.period-btn.active { background: var(--accent); color: var(--accent-ink); }
/* standalone action button (e.g. «Пересчитать») */
.freshness .period-btn { border: 1px solid var(--border); background: var(--card-2); color: var(--text-dim); padding: 5px 12px; }
.freshness .period-btn:hover { color: var(--text); border-color: var(--accent-line); }

.period-meta { font-size: 0.84rem; }

/* ============================================================================
   KPI cards
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: border-color .14s ease, transform .14s ease;
}
.kpi-card:hover { border-color: var(--border); transform: translateY(-1px); }
.kpi-card::after {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(var(--accent), #1b4fd1);
  opacity: 0; transition: opacity .14s ease;
}
.kpi-card:hover::after { opacity: .9; }
.kpi-label {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: .01em;
}
.kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value.green  { color: var(--green); }
.kpi-value.red    { color: var(--red); }
.kpi-value.yellow { color: var(--amber); }
.kpi-value.grey   { color: var(--text-faint); }

/* ----------------------------------------------------------------------------
   Обзор: заголовок + балансы провайдеров как «приборные» тайлы (top-right)
   -------------------------------------------------------------------------- */
.overview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.overview-head h1 { margin: 0; }

.bal-tiles { display: flex; gap: 10px; flex-wrap: wrap; }

/* Per-status accent driven by one custom property so the dot, value, gauge and
   glow stay in sync. Defaults to the neutral "no data" grey. */
.bal-tile {
  --bal: var(--text-faint);
  --bal-soft: rgba(91,101,122,0.16);
  position: relative;
  min-width: 152px;
  padding: 11px 14px 12px;
  background:
    radial-gradient(120% 80% at 100% 0%, var(--bal-soft), transparent 60%),
    linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
/* status-coloured hairline along the top edge */
.bal-tile::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--bal), transparent 85%);
  opacity: .9;
}
.bal-tile:hover {
  transform: translateY(-1px);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.bal-green  { --bal: var(--green);  --bal-soft: rgba(52,211,153,.15); }
.bal-yellow { --bal: var(--amber);  --bal-soft: rgba(251,191,36,.15); }
.bal-red    { --bal: var(--red);    --bal-soft: rgba(248,113,113,.16); }
.bal-grey   { --bal: var(--text-faint); --bal-soft: rgba(91,101,122,.14); }
.bal-tile.bal-empty::before { opacity: .35; }

.bal-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 7px;
}
.bal-provider {
  font-size: 0.62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--text-dim);
}
.bal-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--bal);
  box-shadow: 0 0 0 3px var(--bal-soft);
  flex: none;
}

.bal-value {
  font-family: var(--mono);
  font-size: 1.32rem; font-weight: 600;
  line-height: 1.05; letter-spacing: -0.02em;
  color: var(--bal);
  font-feature-settings: "tnum" 1;
}
/* configured-but-down / not-set states read as quiet text, never alarming colour */
.bal-value.bal-muted {
  font-family: var(--font);
  font-size: 0.92rem; font-weight: 600;
  color: var(--text-dim);
}
.bal-unit {
  font-size: 0.72em; font-weight: 500;
  color: var(--text-dim); margin-left: 3px;
}
.bal-unit-pre { margin-left: 0; margin-right: 2px; }

.bal-sub {
  margin-top: 5px; font-size: 0.66rem; color: var(--text-faint);
}

/* fuel-gauge runway: thin track + status-coloured fill */
.bal-runway { margin-top: 9px; }
.bal-gauge {
  height: 3px; border-radius: 999px;
  background: var(--card-3);
  overflow: hidden;
}
.bal-gauge > span {
  display: block; height: 100%;
  background: var(--bal);  /* fallback when color-mix unsupported */
  background: linear-gradient(90deg, var(--bal), color-mix(in srgb, var(--bal) 55%, transparent));
  border-radius: 999px;
  transition: width .5s cubic-bezier(.2,.7,.2,1);
}
.bal-runway-label {
  display: block; margin-top: 5px;
  font-size: 0.66rem; color: var(--text-dim);
  letter-spacing: .005em;
}

/* ============================================================================
   Tables
   ========================================================================== */
/* Воронка по шагам: столбцы слева направо, высота ∝ числу пользователей */
.funnel-flow {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 18px 16px 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.funnel-step {
  flex: 1 1 0;
  min-width: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.funnel-count {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.funnel-track { width: 100%; height: 140px; display: flex; align-items: flex-end; }
.funnel-bar {
  width: 100%;
  min-height: 3px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(180deg, var(--accent-hover), #1b4fd1);
}
.funnel-label {
  margin-top: 9px;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.25;
}
.funnel-conv {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--card);
}
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--card-2);
  position: sticky; top: 0;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s ease; }
tr:hover td { background: var(--card-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-total td { font-weight: 700; background: var(--card-3); color: var(--text); }
.row-total:hover td { background: var(--card-3); }

/* ============================================================================
   Form controls
   ========================================================================== */
select, input {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 0.86rem;
  font-family: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.controls {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 18px;
}
.controls label { display: inline-flex; align-items: center; gap: 7px; color: var(--text-dim); font-size: 0.85rem; }

/* ============================================================================
   Charts
   ========================================================================== */
.chart-wrap {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
}
canvas { max-width: 100%; }

/* ============================================================================
   Drill-down modal
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5, 8, 14, 0.7);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 14px; z-index: 60; overflow-y: auto;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 920px; padding: 22px;
  box-shadow: var(--shadow);
}
.modal-close {
  float: right;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 1.2rem; line-height: 1;
  border-radius: var(--radius-sm); cursor: pointer;
}
.modal-close:hover { color: var(--text); border-color: var(--accent-line); }
.clickable { cursor: pointer; color: var(--accent-hover); }
.clickable:hover { text-decoration: underline; }
.prompt-cell { max-width: 360px; white-space: normal; word-break: break-word; }

/* ============================================================================
   Status colours
   ========================================================================== */
.status-completed { color: var(--green); }
.status-failed    { color: var(--red); }
.status-pending, .status-processing { color: var(--amber); }

/* ============================================================================
   Health — traffic light, dots, widgets
   ========================================================================== */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot.green  { background: var(--green);  box-shadow: 0 0 0 3px rgba(52,211,153,.16); }
.dot.yellow { background: var(--amber);  box-shadow: 0 0 0 3px rgba(251,191,36,.16); }
.dot.red    { background: var(--red);    box-shadow: 0 0 0 3px rgba(248,113,113,.16); }
.dot.grey   { background: var(--text-faint); }
/* Stage 6: тревожные серые. grey-stall = зависла (есть задачи, 0 завершено) —
   приглушённый янтарь с кольцом, заметнее обычного серого, но не полный жёлтый.
   grey-no-norm = норма latency не задана — серый с кольцом-намёком «посмотри». */
.dot.grey-stall   { background: var(--amber); opacity: .6; box-shadow: 0 0 0 3px rgba(251,191,36,.12); }
.dot.grey-no-norm { background: var(--text-faint); box-shadow: 0 0 0 3px rgba(139,149,167,.20); }

.health-color.green  { color: var(--green); }
.health-color.yellow { color: var(--amber); }
.health-color.red    { color: var(--red); }
.health-color.grey   { color: var(--text-faint); }
.health-color.grey-stall   { color: var(--amber); opacity: .85; font-size: 0.78rem; margin-left: 8px; }
.health-color.grey-no-norm { color: var(--text-dim); font-size: 0.82rem; }
.model-note { font-size: 0.76rem; margin-left: 8px; }

.balance-chart { width: 100%; height: 80px; margin-top: 10px; }

.traffic-light {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 22px;
  transition: border-color .14s ease;
}
.traffic-light:hover { border-color: var(--border); text-decoration: none; }
.traffic-light a, a.traffic-light { color: inherit; text-decoration: none; }
.traffic-light .tl-head { display: inline-flex; align-items: center; gap: 10px; margin-right: 6px; }
.traffic-light .tl-head strong { font-size: 0.96rem; }
.tl-domains { display: flex; flex-wrap: wrap; gap: 8px; }
.tl-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill); padding: 6px 13px; font-size: 0.82rem;
}
.health-section { margin-top: 28px; }

/* ============================================================================
   Login
   ========================================================================== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, rgba(46,111,242,.16), transparent 60%),
    var(--bg);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 30px;
  width: 100%; max-width: 372px;
  box-shadow: var(--shadow);
}
.login-card h1 { text-align: center; margin-bottom: 22px; font-size: 1.4rem; }
.login-card label { display: block; margin: 14px 0 5px; color: var(--text-dim); font-size: 0.82rem; font-weight: 500; }
.login-card input { width: 100%; padding: 10px 12px; }
.login-card button {
  width: 100%; margin-top: 22px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: var(--radius-sm);
  padding: 11px; font-weight: 700; font-size: 0.92rem; font-family: inherit;
  cursor: pointer; transition: background .12s ease;
}
.login-card button:hover { background: var(--accent-hover); }
.login-error { color: var(--red); margin-top: 14px; text-align: center; font-size: 0.86rem; }

.error-page { text-align: center; padding: 72px 16px; }

/* ============================================================================
   Лента «Генерации» — карточка задачи с парой «исходник → результат».
   Карточки, а не таблица: строка с двумя картинками в таблицу не ложится, и
   дозагрузка хвоста ленты вставляется в поток без вложенных таблиц.
   ========================================================================== */
.gen-row {
  display: flex; gap: 18px; align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.gen-media { display: flex; gap: 10px; align-items: center; flex: 0 0 auto; }
.gen-arrow { color: var(--text-faint); font-size: 1.1rem; }
.gen-meta { min-width: 0; flex: 1 1 auto; }
.gen-head {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline;
  font-size: 0.82rem; margin-bottom: 8px;
}
.gen-error { color: var(--red); font-size: 0.8rem; margin-top: 8px; word-break: break-word; }
.gen-row .prompt-cell { max-width: none; font-size: 0.9rem; }

.thumb { position: relative; margin: 0; width: 132px; }
.thumb img {
  width: 132px; height: 132px; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card-2);
  display: block;
}
.thumb figcaption {
  margin-top: 5px; text-align: center;
  font-size: 0.72rem; color: var(--text-faint);
}
.thumb-plate {
  width: 132px; height: 132px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  color: var(--text-faint); font-size: 0.74rem;
  text-decoration: none;
}
a.thumb-plate:hover { color: var(--text); border-color: var(--accent-line); }
/* Плашка про битую ссылку ждёт своего часа: возраст задачи — только прогноз,
   и реально протухшую ссылку мы узнаём по ошибке загрузки картинки. */
.thumb-fallback { display: none; }
.thumb-failed .thumb-fallback { display: flex; }
.thumb-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(5, 8, 14, .78);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 1px 8px; font-size: 0.72rem; color: var(--text-dim);
}
.feed-more { margin: 6px 0 24px; }
.feed-more .period-btn {
  border: 1px solid var(--border); background: var(--card-2); color: var(--text-dim);
}
.feed-more .period-btn:hover { color: var(--text); border-color: var(--accent-line); }

/* ============================================================================
   Responsive — collapse sidebar into an off-canvas drawer
   ========================================================================== */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.open {
    display: block;
    position: fixed; inset: 0;
    background: rgba(5,8,14,.55);
    z-index: 35;
  }
  .content { padding: 22px 18px 56px; }
}

@media (max-width: 560px) {
  .gen-row { flex-direction: column; }
  .thumb, .thumb img, .thumb-plate { width: 104px; }
  .thumb img, .thumb-plate { height: 104px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.55rem; }
  .content { padding: 18px 14px 48px; }
  h1 { font-size: 1.3rem; }
}
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   Герой выручки за сегодня (верх «Обзора») + мобильные доработки
   ========================================================================== */
.revenue-hero {
  background: linear-gradient(180deg, #10231b, var(--card));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  margin: 0 0 20px;
  text-align: center;
}
.revenue-hero .rh-label {
  font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint);
}
.revenue-hero .rh-total {
  font-size: 2.7rem; font-weight: 800; color: var(--green); line-height: 1.04; margin: 6px 0 8px;
}
.revenue-hero .rh-rows {
  display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  font-size: 1.05rem; color: var(--text-dim);
}
.revenue-hero .rh-rows b { color: var(--text); font-weight: 700; }
.revenue-hero .rh-when { font-size: .72rem; color: var(--text-faint); margin-top: 10px; }

@media (max-width: 700px) {
  /* Широкие таблицы не ломают страницу — прокручиваются по горизонтали внутри себя. */
  .content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .content canvas { max-width: 100% !important; }
}
@media (max-width: 560px) {
  .revenue-hero { padding: 16px; }
  .revenue-hero .rh-total { font-size: 2.15rem; }
}
