/* Веб-версия мониторинга курса иены (templates/web.html). Без сборки и внешних запросов. */

@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url(../fonts/golos-text-cyrillic-wght-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 900; font-display: swap;
  src: url(../fonts/golos-text-latin-wght-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 {
  --page: #f3f0e8; --surface: #faf8f3; --sunk: #ece8dd;
  --ink: #1b1a17; --ink-2: #4b473f; --muted: #6e695e; --rule: #d9d3c5; --grid: #e6e1d5; --axis: #c9c2b2;
  --series: #2a78d6; --series-wash: rgb(42 120 214 / .10); --band: rgb(27 26 23 / .09); --median: #7d776b;
  --good: #006300; --good-bg: #e3efdd; --bad: #b4322f; --bad-bg: #f6e1dc; --warn: #8a5a00; --warn-bg: #f5e8c8;
  --accent: #bb3a22;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #141311; --surface: #1c1b18; --sunk: #25231f;
    --ink: #ece8de; --ink-2: #c5c0b3; --muted: #958f82; --rule: #35322c; --grid: #2a2823; --axis: #3d3a33;
    --series: #3987e5; --series-wash: rgb(57 135 229 / .14); --band: rgb(236 232 222 / .09); --median: #9a9486;
    --good: #5cc15c; --good-bg: #1c2b1a; --bad: #ee7b72; --bad-bg: #33201d; --warn: #e5b450; --warn-bg: #30281a;
    --accent: #e4694e;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, p, ul, ol, dl, dd, figure, table { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration-color: var(--rule); text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; border-radius: 6px; }
svg { display: block; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 3.4vw, 40px) 40px; }

/* ───── шапка ───── */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 18px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.coin { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: var(--ink); color: var(--page); font: 600 20px/1 var(--sans); }
.brand b { display: block; font: 600 18px/1.2 var(--sans); letter-spacing: -.01em; }
.brand small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 16px; flex: none; }
.fresh { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.fresh i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.fresh.live i { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.fresh.stale i { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--page);
  font: 600 15px/1 var(--sans); text-decoration: none; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.btn:hover { background: var(--series); border-color: var(--series); color: #fff; }
.btn.line { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.line:hover { background: var(--ink); border-color: var(--ink); color: var(--page); }
.btn svg { width: 18px; height: 18px; flex: none; }

/* ───── переключатель «покупаю / продаю»: над всем, что он меняет ───── */
.filters { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 16px; margin: 0 calc(-1 * clamp(16px, 3.4vw, 40px)) 16px; padding: 10px clamp(16px, 3.4vw, 40px);
  background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--sunk); }
.seg button { min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  font: 500 15px/1 var(--sans); cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / .12), 0 0 0 1px var(--rule); }
.seg.range { margin-top: 14px; }      /* периоды — сразу под графиком, к которому относятся */
.seg.range button { min-width: 56px; padding: 0 14px; font-size: 14px; }

/* ───── сетка ───── */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.col { display: grid; gap: 16px; min-width: 0; }
.side { position: sticky; top: 76px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: clamp(18px, 2vw, 26px); min-width: 0; }
.card > h2 { font: 600 17px/1.3 var(--sans); letter-spacing: -.005em; }
.card > h2 + .hint { margin-top: 4px; }
.hint { font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.loading .card { opacity: .55; }
.card { transition: opacity .2s; }

/* ───── главный показатель и график ───── */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.hero-label { font-size: 14.5px; color: var(--ink-2); }
.hero-label b { font-weight: 600; color: var(--ink); }
.hero-val { margin-top: 2px; font: 600 clamp(52px, 7vw, 76px)/1 var(--sans); letter-spacing: -.035em; white-space: nowrap; }
.hero-val small { font: 500 .42em/1 var(--sans); letter-spacing: 0; color: var(--muted); margin-left: .12em; }
.delta { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; padding: 6px 12px 6px 9px; border-radius: 999px;
  background: var(--sunk); color: var(--ink-2); font: 500 14.5px/1.2 var(--sans); }
.delta svg { width: 14px; height: 14px; flex: none; }
.delta b { font-weight: 600; }
.delta.good { background: var(--good-bg); color: var(--good); }
.delta.bad { background: var(--bad-bg); color: var(--bad); }
.delta span { color: var(--ink-2); font-weight: 400; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.key { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--series); border-radius: 2px; flex: none; }
.key.med { border-top: 2px dashed var(--median); border-radius: 0; }
.key.band { height: 10px; border: 0; background: var(--band); border-radius: 2px; }

.chart { position: relative; margin-top: 18px; outline-offset: 4px; touch-action: pan-y; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart text { font: 400 12px var(--sans); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .band { fill: var(--band); }
.chart .med { fill: none; stroke: var(--median); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .sbi { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .dot.med-dot { fill: var(--median); }
.chart .end-label { font-weight: 600; fill: var(--ink); }
.chart .end-label.sub { font-weight: 400; fill: var(--ink-2); }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart-empty { display: grid; place-items: center; min-height: 240px; color: var(--muted); font-size: 14.5px; text-align: center; }
.tip { position: absolute; top: 0; left: 0; z-index: 2; min-width: 190px; padding: 10px 12px 11px; border-radius: 10px; pointer-events: none;
  background: var(--surface); border: 1px solid var(--rule); box-shadow: 0 10px 28px -10px rgb(0 0 0 / .35);
  font-size: 13.5px; line-height: 1.35; opacity: 0; transition: opacity .1s; }
.tip.on { opacity: 1; }
.tip time { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12.5px; }
.tip div { display: flex; align-items: center; gap: 8px; }
.tip div + div { margin-top: 4px; }
.tip b { font-weight: 600; color: var(--ink); min-width: 46px; font-variant-numeric: tabular-nums; }
.tip span { color: var(--ink-2); }

details.tbl { margin-top: 14px; border-top: 1px solid var(--rule); padding-top: 12px; }
details.tbl summary { cursor: pointer; font-size: 13.5px; color: var(--ink-2); width: fit-content; }
details.tbl summary:hover { color: var(--ink); }
.scroll { max-height: 280px; overflow: auto; margin-top: 10px; border: 1px solid var(--rule); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
.scroll th, .scroll td { padding: 7px 12px; font-size: 13.5px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
.scroll th { position: sticky; top: 0; background: var(--surface); font-weight: 500; color: var(--muted); }
.scroll th:first-child, .scroll td:first-child { text-align: left; }
.scroll tr:last-child td { border-bottom: 0; }

/* ───── три плитки ───── */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tile .label { font-size: 13.5px; color: var(--muted); }
.tile .value { margin-top: 6px; font: 600 28px/1.1 var(--sans); letter-spacing: -.02em; white-space: nowrap; }
.tile .value small { font: 500 15px/1 var(--sans); color: var(--muted); letter-spacing: 0; }
.tile .note { margin-top: 8px; font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }
.tile .note small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.verdict { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.verdict svg { width: 14px; height: 14px; flex: none; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }

/* ───── рейтинг ───── */
.rank-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.rank-head h2 { font: 600 17px/1.3 var(--sans); }
.rank table { margin-top: 14px; }
.rank th { padding: 0 10px 8px; font: 500 12.5px/1.2 var(--sans); color: var(--muted); text-align: right; white-space: nowrap; border-bottom: 1px solid var(--rule); }
.rank th:nth-child(2) { text-align: left; }
.rank td { padding: 11px 10px; border-bottom: 1px solid var(--grid); text-align: right; vertical-align: middle; }
.rank tr:last-child td { border-bottom: 0; }
.rank td.pos { width: 34px; padding-right: 2px; text-align: left; color: var(--muted); font-size: 14px; }
.rank td.bank { text-align: left; }
.rank td.bank b { display: block; font-weight: 500; overflow-wrap: anywhere; }
.rank td.bank small { display: block; margin-top: 1px; font-size: 12.5px; color: var(--muted); }
.rank td.spark { width: 84px; }
.rank td.spark svg { margin-left: auto; }
.rank td.rate { width: 86px; font-weight: 600; font-size: 16.5px; }
.rank td.diff { width: 86px; color: var(--ink-2); font-size: 14.5px; }
.rank tr.is-sbi td { background: var(--series-wash); }
.rank tr.is-sbi td:first-child { border-radius: 10px 0 0 10px; }
.rank tr.is-sbi td:last-child { border-radius: 0 10px 10px 0; }
.rank tr.is-sbi td.bank b { font-weight: 600; }
.spark-line { fill: none; stroke: var(--median); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.is-sbi .spark-line { stroke: var(--series); }
.rank .disclaimer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--rule); }

/* ───── калькулятор ───── */
.field { display: block; margin-top: 14px; }
.field .lbl { display: block; margin-bottom: 6px; font-size: 13.5px; color: var(--muted); }
.inp { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 16px; border-radius: 12px; background: var(--page); border: 1px solid var(--rule); transition: border-color .15s; }
.inp:focus-within { border-color: var(--series); box-shadow: 0 0 0 3px var(--series-wash); }
.inp input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font: 600 22px/1 var(--sans); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.inp em { font-style: normal; font-weight: 500; font-size: 18px; color: var(--muted); }
.swap-note { margin: 10px 0 0; display: flex; justify-content: center; color: var(--muted); }
.swap-note svg { width: 18px; height: 18px; }
select { width: 100%; height: 48px; padding: 0 40px 0 14px; border-radius: 12px; border: 1px solid var(--rule); background: var(--page); cursor: pointer;
  appearance: none; -webkit-appearance: none; font-size: 15px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%237a7468' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center; background-size: 12px 8px; }
.calc-out { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); display: grid; gap: 9px; }
.calc-out div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14.5px; color: var(--ink-2); }
.calc-out div b { font-weight: 600; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc-out div small { display: block; font-size: 12.5px; color: var(--muted); }

/* ───── Telegram и пояснения ───── */
.tg h2 { font: 600 17px/1.3 var(--sans); }
.tg p { margin-top: 6px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.tg .btn { width: 100%; margin-top: 16px; }
.notes { display: grid; gap: 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.notes b { font-weight: 600; color: var(--ink); }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--muted); }
.banner { display: none; margin-bottom: 16px; padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: 14.5px; }
.banner.on { display: block; }

/* ───── узкие экраны ───── */
@media (max-width: 1040px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .col { display: contents; }      /* одна колонка: калькулятор поднимается выше длинного рейтинга */
  .main { order: 1; } .tiles { order: 2; } .calc { order: 3; } .rank { order: 4; } .tg { order: 5; } .notes { order: 6; }
}
@media (max-width: 720px) {
  .top { padding: 14px 0 10px; }
  .top-right .btn { display: none; }
  .fresh { font-size: 12.5px; text-align: right; }
  .filters { position: static; gap: 8px; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 8px; }
  .tiles { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tiles .card { border-radius: 0; border-bottom-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center; }
  .tiles .card:first-child { border-radius: var(--radius) var(--radius) 0 0; }
  .tiles .card:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom-width: 1px; }
  .tile .value { margin: 0; grid-column: 2; grid-row: 1 / span 2; font-size: 24px; text-align: right; }
  .tile .note { margin-top: 2px; }
  .tile .note small { display: inline; margin-left: 6px; }
  .rank td.diff, .rank th.diff { display: none; }
  .rank td.spark { width: 64px; }
  .rank td, .rank th { padding-left: 6px; padding-right: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
