/* Админка You&Me. Цвета — из Palette.swift приложения; цвета серий прогнаны валидатором
   (CVD, контраст, полоса светлоты) отдельно для светлой и тёмной темы. */

@font-face { font-family: 'Onest'; font-weight: 400 800; font-display: swap; src: url(/fonts/onest-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-weight: 400 800; font-display: swap; src: url(/fonts/onest-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Onest'; font-weight: 400 800; font-display: swap; src: url(/fonts/onest-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(/fonts/plex-mono-400-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url(/fonts/plex-mono-400-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url(/fonts/plex-mono-500-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url(/fonts/plex-mono-500-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --bg: #F5F4F1;
  --surface: #FFFFFF;
  --raised: #F0EEEA;
  --text: #16181D;
  --body: #565B64;
  --muted: #767B85;
  --faint: #9297A1;
  --border: rgba(21, 22, 26, 0.12);
  --sep: rgba(21, 22, 26, 0.09);
  --grid: rgba(21, 22, 26, 0.07);
  --axis: rgba(21, 22, 26, 0.22);
  --solid: #16181D;
  --on-solid: #F7F6F3;
  --you: #4C9DEB;
  --me: #E2726B;
  /* Серии: iOS, Android, Telegram, другое (порядок прошёл проверку соседних пар). */
  --s1: #2F86D6;
  --s2: #D85F57;
  --s3: #00909A;
  --s4: #C9971F;
  --good: #38853E;
  --good-text: #1E6626;
  --warn: #DDB049;
  --warn-text: #AA7E00;
  --bad: #D35D31;
  --bad-text: #A63C0C;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0E0F13;
    --surface: #17191F;
    --raised: #222630;
    --text: #F2F0EC;
    --body: #B6BBC6;
    --muted: #8B8F9A;
    --faint: #5F6470;
    --border: #262A33;
    --sep: #22252D;
    --grid: #1F222A;
    --axis: #3A3F4B;
    --solid: #F2F0EC;
    --on-solid: #0E0F13;
    --s1: #3A8BDB;
    --s2: #D8625A;
    --s3: #00979F;
    --s4: #B98A1C;
    --good-text: #4FA556;
    --warn-text: #DDB049;
    --bad-text: #E07A50;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Onest, system-ui, -apple-system, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; padding: 48px 0; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top {
  display: flex; align-items: center; gap: 12px;
  max-width: 1120px; margin: 0 auto; padding: 16px 16px 8px;
}
.mark { width: 40px; height: 40px; flex: none; }
.mark-you { fill: var(--you); }
.mark-me { fill: var(--me); }
.top-title { flex: 1; min-width: 0; }
.top-actions { display: flex; gap: 8px; }

main { max-width: 1120px; margin: 0 auto; padding: 8px 16px 48px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px 16px;
  margin-top: 12px;
  min-width: 0;
}
.card > .muted { margin-top: 2px; }

button.ghost {
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: 14px;
}
button.ghost:hover { background: var(--raised); }
button.ghost:disabled { opacity: 0.5; cursor: default; }
button.solid, a.solid {
  background: var(--solid); color: var(--on-solid); border: 0; border-radius: 14px;
  padding: 14px; font-weight: 600; font-size: 16px; width: 100%;
}
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }

/* Вход */
.login { max-width: 380px; margin: 48px auto 0; padding: 24px 20px; text-align: center; }
.login h2 { font-size: 24px; }
.login form { display: grid; gap: 12px; margin-top: 20px; }
.login input#code {
  font: 500 30px/1 var(--mono); letter-spacing: 0.35em; text-align: center;
  padding: 14px 0 14px 0.35em; border-radius: 14px; border: 1px solid var(--border);
  background: var(--raised); color: var(--text); width: 100%;
}
.login input#code::placeholder { color: var(--faint); }
.error { color: var(--bad-text); font-size: 14px; min-height: 20px; margin-top: 10px; }

/* Тревога о балансе */
.alert {
  margin-top: 12px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface);
  display: flex; gap: 10px; align-items: flex-start; font-size: 14px;
}
.alert .dot { margin-top: 5px; }

/* Плитки */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.kpi { margin-top: 0; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.kpi-note { color: var(--muted); font-size: 12px; }
.kpi-rows { margin-top: 6px; display: grid; gap: 1px; font-size: 12.5px; color: var(--body); }
.kpi-rows div { display: flex; justify-content: space-between; gap: 8px; }
.kpi-rows span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.kpi svg { margin-top: 8px; width: 100%; height: 28px; }

/* Переключатель периода */
.range { display: flex; align-items: center; gap: 6px; margin-top: 20px; }
.range button {
  border: 1px solid var(--border); background: transparent; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--body);
}
.range button[aria-checked="true"] { background: var(--solid); color: var(--on-solid); border-color: var(--solid); }

/* Графики */
.chart { position: relative; margin-top: 12px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font: 11px var(--mono); font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.s1 { fill: var(--s1); } .s2 { fill: var(--s2); } .s3 { fill: var(--s3); } .s4 { fill: var(--s4); }
.ln1 { stroke: var(--s1); } .ln2 { stroke: var(--s2); }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-linejoin: round; }
.spark-end { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.marker { stroke: var(--surface); stroke-width: 2; }
.band { fill: transparent; }
.band:hover, .band.on { fill: var(--grid); }
.empty-note { color: var(--muted); font-size: 13px; padding: 20px 0 8px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; color: var(--body); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key.dash { width: 14px; height: 2px; border-radius: 1px; }
.key.k1 { background: var(--s1); } .key.k2 { background: var(--s2); } .key.k3 { background: var(--s3); } .key.k4 { background: var(--s4); }

.tip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 12px; min-width: 130px;
}
.tip-day { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row b { font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 10px; }
.tip-row .key { flex: none; }

details { margin-top: 10px; }
summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.scroll { overflow-x: auto; }

/* Таблицы и строки */
table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 4px; }
td { padding: 7px 4px; border-top: 1px solid var(--sep); }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.n + td.n, th.n + th.n { padding-left: 16px; }
tr.dim td { color: var(--muted); }
td svg { width: 64px; height: 18px; display: block; margin-left: auto; }

.rows { display: grid; margin-top: 6px; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--sep); font-size: 14px; }
.row:first-child { border-top: 0; }
.row span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.row .sub { color: var(--muted); }

.hbars { display: grid; gap: 10px; margin-top: 12px; }
.hbar-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--body); }
.hbar-head span:last-child { font-family: var(--mono); color: var(--text); }
.hbar-track { height: 8px; margin-top: 4px; }
.hbar-fill { height: 8px; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-fill.k1 { background: var(--s1); } .hbar-fill.k2 { background: var(--s2); } .hbar-fill.k3 { background: var(--s3); } .hbar-fill.k4 { background: var(--s4); }
.subhead { margin-top: 18px; font-size: 13px; color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 6px; font-family: Onest, system-ui, sans-serif !important; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.good-text { color: var(--good-text); } .warn-text { color: var(--warn-text); } .bad-text { color: var(--bad-text); }
.meter { height: 8px; border-radius: 4px; background: var(--raised); margin-top: 8px; overflow: hidden; }
.meter div { height: 100%; border-radius: 4px; }
.meter .good { background: var(--good); } .meter .warn { background: var(--warn); } .meter .bad { background: var(--bad); }

.grid { display: grid; gap: 0 12px; }

@media (min-width: 720px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 20px; }
}

#dash.stale { opacity: 0.6; transition: opacity 0.2s; }

/* Подключение кода по одноразовой ссылке */
a.solid { display: block; text-decoration: none; text-align: center; margin-top: 20px; }
.enroll-hint { margin-top: 18px; text-align: left; }
.enroll-key { display: block; margin: 10px 0; padding: 12px; border-radius: 12px; background: var(--raised); font: 500 15px/1.5 var(--mono); word-break: normal; user-select: all; -webkit-user-select: all; }
a.link { color: var(--s1); text-decoration: none; display: inline-block; margin-top: 16px; }
