/* Цвета — из темы Telegram (светлая/тёмная сама), запасные — на случай открытия в браузере */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --text: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #7a7a80);
  --accent: var(--tg-theme-button-color, #2a78d6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--muted) 25%, transparent);
  --good: #1baf7a;
  --warn: #c98500;
  --bad: #e34948;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0 16px 32px; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.muted { color: var(--muted); }
.center { text-align: center; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 4px; }
.title { font-weight: 700; font-size: 18px; }
.title .muted { font-weight: 400; font-size: 14px; }
button { font: inherit; color: inherit; }
.icon { background: none; border: 0; font-size: 20px; padding: 6px; cursor: pointer; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--card);
  color: var(--text); cursor: pointer; white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }

.month { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.month h2 { margin: 0; font-size: 17px; }
.month button { background: var(--card); border: 0; border-radius: 10px; width: 40px; height: 34px; cursor: pointer; }
.month button:disabled { opacity: .3; cursor: default; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--card); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 20px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile.wide { grid-column: 1 / -1; }

.bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.card { background: var(--card); border-radius: 14px; padding: 12px; margin-top: 12px; }
.card h3 { margin: 0 0 2px; font-size: 15px; }
.card .note { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.chart { position: relative; height: 220px; }
.chart.tall { height: 300px; }

/* свои графики (charts.js) */
.mc { display: block; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.mc-grid { stroke: var(--line); stroke-width: 1; }
.mc-zero { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.mc-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.mc-tick { fill: var(--muted); font-size: 11px; }
.mc-seg { stroke: var(--card); stroke-width: 1.5; }
.mc-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; font-size: 12px;
  color: var(--muted); align-items: center; padding-top: 4px; line-height: 1.3; }
.mc-legend i, .mc-tip i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.mc-tip { position: absolute; display: none; pointer-events: none; z-index: 2; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; font-size: 12px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15); }
.mc-tip-title { font-weight: 600; margin-bottom: 2px; }

.row { padding: 8px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .line { display: flex; justify-content: space-between; gap: 8px; }
.row .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .sub { color: var(--muted); font-size: 12px; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary .name::before { content: "▸ "; color: var(--muted); }
details[open] > summary .name::before { content: "▾ "; }
details .arts { padding: 4px 0 0 14px; }
details .arts .line { font-size: 13px; padding: 3px 0; }

.soon { text-align: center; padding: 48px 12px; color: var(--muted); }
.soon b { display: block; font-size: 32px; margin-bottom: 8px; }
.error { text-align: center; padding: 40px 12px; }

/* шаг 2: долги и прогноз */
.value.bad, .sub.bad, .risk.bad { color: var(--bad); }
.sub.warn, .risk.warn { color: var(--warn); }
.risk { font-size: 14px; font-weight: 600; }
.seg { display: flex; gap: 6px; margin: 2px 0 10px; }
.seg button { flex: 1; border: 0; border-radius: 10px; padding: 7px 0; background: var(--card); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.slider { width: 100%; margin: 6px 0 4px; accent-color: var(--accent); }
.calc { font-size: 14px; }
.week { color: var(--muted); font-size: 12px; font-weight: 600; margin: 10px 0 2px; }

/* шаг 3: ИИС */
.chart.short { height: 170px; }
.note.right { text-align: right; margin: -4px 0 8px; }
.card > .line { padding: 4px 0; font-size: 13px; }
.card > .sub { font-size: 13px; margin-top: 4px; }

/* шаг 4: поездки */
.trip { display: block; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line);
  padding: 8px 0; cursor: pointer; }
.trip .line { display: flex; justify-content: space-between; gap: 8px; }
.trip .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip .num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.trip .sub { color: var(--muted); font-size: 12px; }
.back { background: var(--card); border: 0; border-radius: 10px; padding: 7px 12px; margin-bottom: 8px; cursor: pointer; }
