/* CyberCFO Mini App — светлая тема (ТЗ §5). Токены темы + состояний. */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --ink: #1b1b18;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e9e8e2;
  --brand: #0ba678;
  --brand-ink: #087a59;

  /* Состояния (ТЗ §5): Всплеск 🟣 Рост 🟢 Стагнация ⚪ Падение 🟠 Обвал 🔴 Recovery 🔵 */
  --st-surge: #7c3aed;
  --st-growth: #0ba678;
  --st-stagnation: #898781;
  --st-decline: #e8842b;
  --st-collapse: #d03b3b;
  --st-recovery: #2a78d6;
  --st-norm: #b8b7b1;

  /* Каналы (категориальная, валидирована) */
  --ch-1: #2a78d6;
  --ch-2: #1baf7a;
  --ch-3: #eda100;
  --ch-4: #4a3aa7;
  --ch-5: #eb6834;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 27, 24, 0.05), 0 4px 16px rgba(27, 27, 24, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 76px;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.topbar h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .role { margin-left: auto; font-size: 12px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); padding: 3px 9px; border-radius: 20px; }

main { padding: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 560px; margin: 0 auto; }
.tab-view { display: none; flex-direction: column; gap: 14px; }
.tab-view.active { display: flex; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.03em; }
.card .sub { font-size: 12px; color: var(--muted); }

/* KPI-плитки */
.kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.kpi .value.tabular { font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Спарклайн-карточки статистик */
.stat-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: start; }
.stat-card .head { display: flex; align-items: center; gap: 8px; }
.stat-card .name { font-size: 15px; font-weight: 600; }
.state-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; color: #fff; white-space: nowrap; }
.stat-card .metrics { grid-column: 1; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.stat-card .metrics b { color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-card .spark { grid-column: 1 / -1; margin-top: 8px; }
.stat-card .actions { grid-column: 1 / -1; margin-top: 10px; }

.btn { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--brand-ink);
  padding: 7px 13px; border-radius: 10px; }
.btn:hover { border-color: var(--brand); }
.btn.brand { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Легенда */
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }

/* FP-раскладка */
.fp-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0;
  border-bottom: 1px solid var(--line); font-size: 14px; }
.fp-row:last-child { border-bottom: none; }
.fp-row .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.fp-row.rest .amt { color: var(--brand-ink); }
.payment-note { font-size: 12px; color: var(--muted); }

/* Прогресс-бар резерва */
.bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }

/* Нижняя навигация */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tabbar button { flex: 1; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
  background: none; border: none; color: var(--muted); padding: 10px 4px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tabbar button .ico { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--brand-ink); }

/* Модал плейбука */
.modal-back { position: fixed; inset: 0; background: rgba(27, 27, 24, 0.4); z-index: 20;
  display: none; align-items: flex-end; justify-content: center; }
.modal-back.open { display: flex; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 20px; }
.modal .pb-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.modal h3 { margin: 0; font-size: 19px; }
.modal .pb-block { margin-top: 16px; }
.modal .pb-block h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--muted); }
.modal .trigger { font-size: 14px; color: var(--ink-2); background: var(--bg);
  border-radius: 10px; padding: 10px 12px; }
.forbidden li { color: #a23; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand); }
.check.done span { color: var(--muted); text-decoration: line-through; }
.modal .close { position: sticky; top: 0; float: right; }

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