/* ==========================================================================
   Poker Stats — визуальная система «четырёхцветная колода».
   Цвета мастей несут смысл: ♣ зелёный — плюс, ♥ красный — минус,
   ♦ синий — турниры, ♠ чёрный — кэш и основные действия.
   Светлая тема — лицевая сторона карты, тёмная — сукно стола.
   ========================================================================== */

/* ---------- шрифты (свои копии: внешние CDN в части сетей тормозят) ---------- */
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(vendor/fonts/golos-text-cyrillic-400-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(vendor/fonts/golos-text-latin-400-normal.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: "Golos Text"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(vendor/fonts/golos-text-cyrillic-500-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(vendor/fonts/golos-text-latin-500-normal.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: "Golos Text"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(vendor/fonts/golos-text-cyrillic-600-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(vendor/fonts/golos-text-latin-600-normal.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: "Unbounded"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(vendor/fonts/unbounded-cyrillic-500-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(vendor/fonts/unbounded-latin-500-normal.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: "Unbounded"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(vendor/fonts/unbounded-cyrillic-600-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(vendor/fonts/unbounded-latin-600-normal.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 {
  --bg: #FFFFFF;          /* лицевая сторона карты */
  --surface: #F0F3F1;     /* поля, сегменты — едва заметный оттенок сукна */
  --line: #DFE5E1;        /* тонкие разделители */
  --ink: #000000;         /* ♠ — текст, кэш, основные кнопки */
  --muted: #5F6A64;       /* второстепенный текст */
  --on-ink: #FFFFFF;
  --heart: #CF1124;       /* ♥ — минус, ошибки */
  --club: #0A8239;        /* ♣ — плюс */
  --diamond: #1B5BCB;     /* ♦ — турниры, ссылки */

  --display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --text: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: 16px;
}
:root[data-theme="dark"] {
  --bg: #0E231B;          /* сукно */
  --surface: #163229;
  --line: #234338;
  --ink: #F2F5F1;
  --muted: #92A99C;
  --on-ink: #0E231B;
  --heart: #FF6873;
  --club: #48D483;
  --diamond: #7DA9FF;
}

/* ---------- база ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; padding: 12px var(--gutter) 40px;
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 var(--text);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--diamond); outline-offset: 2px; }
.plus { color: var(--club); }
.minus { color: var(--heart); }
.num { font-variant-numeric: tabular-nums; }

h3 {
  margin: 32px 0 6px;
  font: 500 15px/1.3 var(--display); letter-spacing: -0.01em;
}

/* ---------- навигация: текстовые вкладки + фишка «добавить» ---------- */
.tabs {
  display: flex; align-items: center; gap: 2px;
  margin: 0 calc(-1 * var(--gutter)) 12px; padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}
.tabs button {
  position: relative; padding: 10px 10px 12px; border: 0; background: none;
  color: var(--muted); font-weight: 500; font-size: 15px; white-space: nowrap;
}
.tabs button:first-child { padding-left: 0; }
.tabs button.active { color: var(--ink); }
.tabs button.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--ink);
}
.tabs button:first-child.active::after { left: 0; }
/* «Добавить» — фишка: круг цвета ♠ с пунктирной кромкой, как у настоящей фишки */
.tabs .tab-add {
  margin-left: auto; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  background: var(--ink); color: var(--on-ink);
  font: 500 22px/1 var(--display);
  outline: 2px dashed var(--bg); outline-offset: -6px;
}
.tabs .tab-add.active { background: var(--diamond); }
.tabs .tab-add.active::after { display: none; }
.tabs .tab-add:focus-visible { outline: 2px solid var(--diamond); outline-offset: 2px; }

.tab { display: none; }
.tab.active { display: block; }

/* ---------- фильтры ---------- */
.filters { display: flex; gap: 6px; margin-bottom: 18px; }
.filters select {
  flex: 1 1 auto; width: auto; min-width: 0; margin: 0; padding: 8px 22px 8px 9px;
  font-size: 13px; border-radius: 8px;
  background-position: right 12px center, right 7px center;
  text-overflow: ellipsis;
}

/* ---------- статистика: профит + график как главное ---------- */
.hero { margin-bottom: 4px; }
.hero-profit {
  font: 600 44px/1.05 var(--display); letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.hero-sub { margin-top: 6px; color: var(--muted); font-size: 14px; }
.chart {
  position: relative; height: 210px;
  margin: 14px calc(-1 * var(--gutter)) 0;
}
.chart-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 0 32px; text-align: center; color: var(--muted); font-size: 14px;
}

.kpis {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 14px 0 0; border-top: 1px solid var(--line);
}
.kpi { padding: 10px 0 10px 12px; border-bottom: 1px solid var(--line); }
.kpi:nth-child(3n + 1) { padding-left: 0; }
.kpi:not(:nth-child(3n + 1)) { border-left: 1px solid var(--line); }
.kpi dt { color: var(--muted); font-size: 12px; }
.kpi dd { margin: 2px 0 0; font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- таблицы: по видам / по румам ---------- */
.table .row-item {
  display: grid; grid-template-columns: minmax(0, 2.1fr) 0.9fr 0.8fr 0.8fr; gap: 8px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.table .row-item > span:not(:first-child) { text-align: right; }
.table .row-item.head { padding: 6px 0; color: var(--muted); font-size: 12px; }
.table .name { min-width: 0; }
.table .name b { font-weight: 500; white-space: nowrap; }
.table .name small { display: block; color: var(--muted); font-size: 12px; }
.table .row-item .val { font-weight: 500; }

.suit { display: inline-block; width: 1.15em; font-style: normal; }
.suit-cash { color: var(--ink); }
.suit-mtt { color: var(--diamond); }

.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* ---------- список сессий ---------- */

.session {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.session .suit { font-size: 18px; align-self: flex-start; margin-top: 1px; }
.session .main { flex: 1; min-width: 0; }
.session .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .right { text-align: right; }
.session .profit { font-weight: 600; font-variant-numeric: tabular-nums; }
.session .date { color: var(--muted); font-size: 12px; }
.session .del {
  width: 32px; height: 32px; margin-right: -6px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); font-size: 18px; line-height: 1;
}
.session .del:active { background: var(--surface); color: var(--heart); }

/* ---------- формы ---------- */
form label, .report label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; }
.row label { flex: 1; min-width: 0; }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 11px 12px;
  font: 400 16px/1.3 var(--text); color: var(--ink);   /* 16px: iOS не зумит при фокусе */
  background: var(--surface); border: 1px solid transparent; border-radius: 10px; outline: none;
  -webkit-appearance: none; appearance: none;
}
select {
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%);
  background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat;
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }   /* фокус уже виден по рамке */
input[type="date"] { min-height: 44px; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.seg { display: flex; gap: 4px; padding: 4px; margin-bottom: 12px; background: var(--surface); border-radius: 12px; }
.seg button { flex: 1; padding: 9px; border: 1px solid transparent; border-radius: 9px; background: none; color: var(--muted); font-weight: 500; }
.seg button.active { background: var(--bg); border-color: var(--line); color: var(--ink); }

.preview-label { margin-top: 6px; text-align: center; color: var(--muted); font-size: 13px; }
.profit-preview {
  margin: 0 0 14px; text-align: center;
  font: 600 26px/1.2 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}

button.primary, button.secondary, button.danger {
  display: block; width: 100%; padding: 14px; border: 0; border-radius: 12px; font-size: 16px; font-weight: 600;
}
button.primary { background: var(--ink); color: var(--on-ink); }
button.primary:disabled { opacity: .45; }
button.secondary { background: var(--surface); color: var(--ink); font-weight: 500; }
button.danger { margin-top: 8px; background: none; color: var(--heart); font-weight: 500; }

/* ---------- автодополнение рума и лимита ---------- */
.ac { position: relative; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10;
  max-height: 240px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .14);
}
.ac-item { padding: 11px 12px; color: var(--ink); font-size: 15px; }
.ac-item + .ac-item { border-top: 1px solid var(--line); }
.ac-item:hover, .ac-item.active { background: var(--surface); }
.ac-item b { font-weight: 600; }

/* ---------- отчёты ---------- */
.report { padding-bottom: 22px; }
.report + .report { padding-top: 4px; border-top: 1px solid var(--line); }
.report h3 { margin-top: 18px; margin-bottom: 12px; }
.report-card { margin-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips button {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--ink); font-size: 14px;
}
.chips button.active { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.hint-text { color: var(--muted); font-size: 13px; }
.report .hint-text { margin: 10px 0 0; }
.report-preview {
  white-space: pre-wrap; margin-top: 14px; padding: 12px;
  font: 13px/1.5 var(--text); background: var(--surface); border-radius: 10px;
}

/* ---------- подписка ---------- */
.sub-banner {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin-bottom: 10px; padding: 9px 12px; border-radius: 10px;
  background: var(--surface); font-size: 13px; color: var(--muted); cursor: pointer;
}
.sub-banner b { color: var(--ink); font-weight: 600; }
.sub-banner .go { color: var(--diamond); font-weight: 500; white-space: nowrap; }
.paywall { padding: 28px 4px; }
.paywall-icon { font: 600 64px/1 var(--display); }
.paywall h2 { margin: 18px 0 8px; font: 600 24px/1.2 var(--display); letter-spacing: -0.02em; }
.paywall p { color: var(--muted); max-width: 34em; }
.paywall ul { margin: 18px 0 24px; padding-left: 18px; }
.paywall li { margin: 7px 0; }
.paywall li::marker { content: "♠  "; color: var(--muted); }
.paywall .hint { font-size: 13px; margin: 12px 0 22px; }

/* ---------- служебное ---------- */
.boot { padding: 48px 0; color: var(--muted); }
.boot.error { color: var(--heart); white-space: pre-wrap; font-size: 14px; }
.toast {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: max(16px, env(safe-area-inset-bottom));
  padding: 13px 14px; border-radius: 12px; z-index: 20;
  background: var(--ink); color: var(--on-ink); font-size: 14px; text-align: center;
}

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