/* Капитал — дизайн-токены и каркас. Уровень: банковское приложение.
   Inter, индиго с фиолетовым градиентом, светлая и тёмная тема.

   Правила:
   - цвета ТОЛЬКО через токены :root — hex в страницах не писать;
   - «краски» = цветные аватарки сущностей и semantic-пилюли, не радуга фонов;
   - у денег tabular-nums, у главной цифры экрана вес 800;
   - движение тонкое (.15s), prefers-reduced-motion уважаем. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --text: #16192c;
  --text-dim: #676b7e;
  --line: #e7e8f0;
  --accent: #4f46e5;        /* индиго */
  --accent-2: #7c3aed;      /* фиолетовый — пара для градиента */
  --accent-soft: #eef0fe;
  --good: #0f9d58;
  --good-soft: #e6f6ed;
  --warn: #b7791f;
  --warn-soft: #fdf3e0;
  --bad: #d23f31;
  --bad-soft: #fdeae7;
  --radius: 14px;
  --radius-sm: 10px;
  /* тень двухслойная: контактная + рассеянная, как у банковских карточек */
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .05);
  --shadow-lift: 0 2px 4px rgba(16, 24, 40, .05), 0 12px 32px rgba(16, 24, 40, .10);
  --hero-grad: linear-gradient(135deg, #4f46e5 0%, #6d5ae8 55%, #7c3aed 100%);
  --hero-shadow: 0 10px 30px rgba(79, 70, 229, .30);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1019;
    --surface: #171826;
    --surface-2: #1f2031;
    --text: #ececf4;
    --text-dim: #9a9ab0;
    --line: #292a3c;
    --accent: #7c74f2;
    --accent-2: #9a6ef5;
    --accent-soft: #24224a;
    --good: #34b46e; --good-soft: #15301f;
    --warn: #d99b3c; --warn-soft: #33270f;
    --bad: #e0604f;  --bad-soft: #391712;
    --shadow: none;
    --shadow-lift: none;
    --hero-grad: linear-gradient(135deg, #4338ca 0%, #5b4bd5 55%, #6d28d9 100%);
    --hero-shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1019; --surface: #171826; --surface-2: #1f2031;
  --text: #ececf4; --text-dim: #9a9ab0; --line: #292a3c;
  --accent: #7c74f2; --accent-2: #9a6ef5; --accent-soft: #24224a;
  --good: #34b46e; --good-soft: #15301f;
  --warn: #d99b3c; --warn-soft: #33270f;
  --bad: #e0604f; --bad-soft: #391712;
  --shadow: none; --shadow-lift: none;
  --hero-grad: linear-gradient(135deg, #4338ca 0%, #5b4bd5 55%, #6d28d9 100%);
  --hero-shadow: none;
}
:root[data-theme="light"] {
  --bg: #f4f5fa; --surface: #ffffff; --surface-2: #f1f2f7;
  --text: #16192c; --text-dim: #676b7e; --line: #e7e8f0;
  --accent: #4f46e5; --accent-2: #7c3aed; --accent-soft: #eef0fe;
  --good: #0f9d58; --good-soft: #e6f6ed;
  --warn: #b7791f; --warn-soft: #fdf3e0;
  --bad: #d23f31; --bad-soft: #fdeae7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .05);
  --shadow-lift: 0 2px 4px rgba(16, 24, 40, .05), 0 12px 32px rgba(16, 24, 40, .10);
  --hero-grad: linear-gradient(135deg, #4f46e5 0%, #6d5ae8 55%, #7c3aed 100%);
  --hero-shadow: 0 10px 30px rgba(79, 70, 229, .30);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-soft); }

/* Тонкий скроллбар — как в приложениях, а не в браузере 2005 года */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

/* Каркас: сайдбар на десктопе, таб-бар снизу на мобиле */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 228px; flex-shrink: 0; padding: 20px 12px;
  border-right: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 18px; padding: 4px 10px 20px;
  letter-spacing: -0.02em;
}
.sidebar .brand .brand-name span { color: var(--accent); }
/* Знак бренда: градиентный суперэллипс с буквой — «лицо» приложения */
.brand-mark {
  width: 30px; height: 30px; border-radius: 10px; flex: 0 0 30px;
  background: var(--hero-grad); color: #fff !important;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 800; letter-spacing: 0;
  box-shadow: var(--hero-shadow);
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); text-decoration: none; font-weight: 600;
  font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav-link .ico { font-size: 17px; line-height: 1; width: 22px; text-align: center; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.main { flex: 1; padding: 26px 28px; max-width: 1240px; min-width: 0; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; z-index: 50;
    width: auto; height: auto; flex-direction: row; padding: 6px 8px;
    border-right: none; border-top: 1px solid var(--line);
    justify-content: space-around;
    /* лёгкая дымка, как у нижних панелей в банках */
    box-shadow: 0 -4px 16px rgba(16, 24, 40, .06);
  }
  .sidebar .brand, .sidebar .nav-spacer, .sidebar form { display: none; }
  /* Разделов семь — на узком телефоне подписи жмём, но не режем */
  .nav-link {
    flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px;
    text-align: center; line-height: 1.15; min-width: 0; font-weight: 600;
  }
  .nav-link .ico { width: auto; font-size: 19px; }
  .main { padding: 16px 12px 92px; }
}

/* Компоненты */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}

/* Hero — главная карточка экрана: градиент, белые цифры.
   Одна на страницу, иначе перестаёт быть главной. */
.card.hero {
  background: var(--hero-grad); border: none; color: #fff;
  box-shadow: var(--hero-shadow);
}
.card.hero .dim { color: rgba(255, 255, 255, .74); }
.card.hero a { color: #fff; }
.card.hero .cap-split { border-top-color: rgba(255, 255, 255, .28); }
.card.hero strong { color: #fff; }

.grid { display: grid; gap: 14px; }
/* min-width:0 у ячеек: длинная сумма не должна распирать колонку и выталкивать
   сетку за край экрана (ловилось на телефоне: «$1 035 039» рвал страницу) */
.grid > * { min-width: 0; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
canvas, img { max-width: 100%; }
@media (max-width: 800px) {
  /* Карточки с главными суммами — в один столбец: цифра 25px в половину
     экрана не влезает, а мельчить деньги хуже, чем листать */
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .big { font-size: 25px; }
}
h1 { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 16px; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 10px; }
.num { font-variant-numeric: tabular-nums; }
.big { font-size: 30px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; }
.dim { color: var(--text-dim); }
.small { font-size: 13px; }

.pill {
  display: inline-block; padding: 2.5px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad  { background: var(--bad-soft);  color: var(--bad); }
.pill.dim  { background: var(--surface-2); color: var(--text-dim); }

/* Аватарка сущности (счёт, площадка, монета): цвет держится за именем.
   Фон выводим из цвета через color-mix — работает в обеих темах сам. */
.ava {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px;
  display: inline-grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: 0;
  color: var(--ava); background: color-mix(in srgb, var(--ava) 14%, var(--surface));
}
.ava.sm { width: 28px; height: 28px; border-radius: 9px; flex-basis: 28px; font-size: 11.5px; }
/* монета/счёт в таблице: аватарка + имя одной строкой */
.coin-id { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.hue0 { --ava: #6366f1; }   /* индиго */
.hue1 { --ava: #0ea5e9; }   /* небо */
.hue2 { --ava: #10b981; }   /* изумруд */
.hue3 { --ava: #f59e0b; }   /* янтарь */
.hue4 { --ava: #ef4444; }   /* коралл */
.hue5 { --ava: #ec4899; }   /* розовый */
.hue6 { --ava: #8b5cf6; }   /* фиолет */
.hue7 { --ava: #14b8a6; }   /* бирюза */

table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-dim); font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

button, .btn {
  font: inherit; font-weight: 700; cursor: pointer;
  background: var(--accent); color: #fff; border: none;
  padding: 9px 16px; border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(79, 70, 229, .30);
  transition: filter .15s, transform .15s, background .15s, box-shadow .15s;
}
button:hover, .btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
button.ghost, .btn.ghost {
  background: transparent; color: var(--accent);
  border: 1px solid var(--line); box-shadow: none;
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--accent-soft); filter: none;
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px;
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label { font-size: 13px; font-weight: 600; color: var(--text-dim); display: block; margin-bottom: 4px; }

/* Полоска лимита оси (балансировка) */
.axis-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; position: relative; }
.axis-bar .fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.axis-bar .fill.over { background: var(--bad); }

/* Спрятанное — всегда спрятано: свои display-стили не должны перебивать hidden */
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ===== Сворачиваемый раздел (details.sec) =====
   Длинные страницы (настройки, сделки) режем на разделы: в заголовке главная
   цифра или пояснение, внутри — подробности. Свёрнутый раздел всё равно
   отвечает на вопрос «что там», разворачивают его ради «почему».
   Работает без единой строчки JS. */
details.sec {
  background: var(--surface); border-radius: var(--radius); margin-bottom: 12px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
details.sec > summary {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 15px 18px; cursor: pointer; list-style: none; user-select: none;
  border-radius: var(--radius); transition: background .15s;
}
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after {
  content: "⌄"; margin-left: auto; font-size: 20px; line-height: 1;
  opacity: .45; transition: transform .15s;
}
details.sec[open] > summary::after { transform: rotate(180deg); }
details.sec > summary:hover { background: var(--surface-2); }
details.sec .sec-title { font-size: 15.5px; font-weight: 700; }
details.sec .sec-fact { font-variant-numeric: tabular-nums; }
details.sec .sec-body { padding: 0 18px 18px; }
details.sec[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 14px; }

@media (max-width: 720px) {
  details.sec > summary { padding: 13px 14px; }
  details.sec .sec-body { padding: 0 14px 14px; }
}


/* Выпадающий список разметки монеты — компактный, прямо в таблице */
select.coin-axis {
  padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: inherit; font: inherit; font-size: 13px;
  max-width: 150px;
}


/* ===== Подсказка аналитика под блоком =====
   Живёт прямо под цифрами: вопрос «и что мне с этим делать» возникает там,
   где человек смотрит на цифру, а не на отдельной странице. */
.hint-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.hint-btn { font-size: 13.5px; padding: 6px 13px; }
.hint-body { margin-top: 10px; font-size: 14.5px; line-height: 1.6; max-width: 760px; }
.hint-body p { margin: 0 0 9px; }
.hint-body p:last-child { margin-bottom: 0; }
.hint-foot { margin-top: 8px; font-size: 12px; }
