/* fx-monitor: единый стиль. Светлая/тёмная тема через переменные; шрифты системные; без inline-стилей. */
:root {
  --bg: #fbfbfa; --surface: #ffffff; --surface-2: #f3f2ef; --border: #e3e1dc; --text: #0e1116; --muted: #5a6170;
  --accent: #4f5bc8; --accent-ink: #ffffff; --accent-soft: #eceefc;
  --pos: #0b7a47; --neg: #c0312b; --warn: #94600a; --info: #2a5db0;
  --pos-1: #e3f4ea; --pos-2: #c6e9d4; --pos-3: #9fd8b8; --pos-4: #6cc394;
  --neg-1: #fbe7e5; --neg-2: #f6cbc8; --neg-3: #efa7a2; --neg-4: #e5817a;
  --shadow: 0 1px 2px rgba(14, 17, 22, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171b; --surface: #1e1f24; --surface-2: #26272d; --border: #33353d; --text: #ededef; --muted: #9a9ca8;
    --accent: #7c84ff; --accent-ink: #101226; --accent-soft: #272a4a;
    --pos: #3ddc97; --neg: #ff7b72; --warn: #f0b429; --info: #7db0ff;
    --pos-1: #17342a; --pos-2: #1c4a38; --pos-3: #226046; --pos-4: #236b4b;
    --neg-1: #3a1f20; --neg-2: #55292b; --neg-3: #73343a; --neg-4: #94434a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171b; --surface: #1e1f24; --surface-2: #26272d; --border: #33353d; --text: #ededef; --muted: #9a9ca8;
  --accent: #7c84ff; --accent-ink: #101226; --accent-soft: #272a4a;
  --pos: #3ddc97; --neg: #ff7b72; --warn: #f0b429; --info: #7db0ff;
  --pos-1: #17342a; --pos-2: #1c4a38; --pos-3: #226046; --pos-4: #236b4b;
  --neg-1: #3a1f20; --neg-2: #55292b; --neg-3: #73343a; --neg-4: #94434a;
  --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; font-weight: 650; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem .75rem; z-index: 100; }
.skip:focus { left: 0; }
[hidden] { display: none !important; }
.inline { display: inline; margin: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 1rem; }
.foot { color: var(--muted); font-size: .75rem; padding-top: 0; padding-bottom: 2rem; }

/* шапка */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); display: inline-block; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a, .subnav a { color: var(--muted); text-decoration: none; padding: .35rem .65rem; border-radius: 8px; font-weight: 500; }
.mainnav a:hover, .subnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a[aria-current], .subnav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.topbar-tools { display: flex; gap: .25rem; align-items: center; }

/* кнопки и формы */
.btn { font: inherit; font-weight: 500; font-size: .875rem; display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: .35rem .85rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
input[type=text], input[type=password], select { font: inherit; min-height: 38px; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; }
label { display: block; font-size: .8125rem; color: var(--muted); font-weight: 500; }
label input, label select { margin-top: .25rem; }
.stack { display: grid; gap: .75rem; max-width: 360px; }

/* карточки и сетки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin-right: auto; }
.card-tools { display: flex; gap: .5rem; }
.card > h2 { margin-bottom: .75rem; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.crumb { margin: 0 0 .25rem; font-size: .8125rem; color: var(--muted); }
.crumb a { color: var(--muted); }
.h1sub { font-size: .9rem; font-weight: 400; }
.subnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem; }
.grid-main > .card { margin-bottom: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 > .card, .grid-2 > .card { margin-bottom: 0; }
.grid-main + .card, .grid-2 { margin-top: 1rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.fresh { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* чипы периодов, сегменты */
.chips { display: flex; gap: .25rem; flex-wrap: wrap; }
.chip { padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .8125rem; background: var(--surface); }
.chip:hover { color: var(--text); }
.chip[aria-current] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-b { font: inherit; font-size: .8125rem; border: 0; background: var(--surface); color: var(--muted); padding: .3rem .65rem; cursor: pointer; min-height: 32px; }
.seg-b + .seg-b { border-left: 1px solid var(--border); }
.seg-b[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius); padding: .75rem .9rem; min-width: 0; }
.kpi.pos { border-left-color: var(--pos); } .kpi.neg { border-left-color: var(--neg); } .kpi.warn { border-left-color: var(--warn); }
.kpi-t { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi-v { font-size: 1.25rem; font-weight: 650; margin: .15rem 0; overflow-wrap: anywhere; }
.kpi-s { line-height: 1.3; }

/* статусы */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-online { color: var(--pos); background: var(--pos-1); }
.st-offline { color: var(--neg); background: var(--neg-1); }
.st-stale { color: var(--warn); background: var(--surface-2); outline: 1px solid var(--warn); }
.st-never { color: var(--muted); }
.badge.near { color: var(--warn); background: var(--surface-2); }
.side { font-family: var(--mono); font-size: .75rem; font-weight: 700; padding: .1rem .4rem; border-radius: 4px; background: var(--surface-2); }
.side.buy { color: var(--pos); } .side.sell { color: var(--neg); }

/* таблицы */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; padding: 0 .25rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.tbl th, .tbl td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl thead th { font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tfoot td { font-weight: 600; border-top: 2px solid var(--border); border-bottom: 0; }
.cmt { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.sortlink { color: inherit; text-decoration: none; }
.sortlink:hover { color: var(--accent); }
.share { display: inline-block; width: 48px; height: 6px; background: var(--surface-2); border-radius: 3px; vertical-align: middle; overflow: hidden; }
.bar { display: block; height: 100%; background: var(--accent); }
.bar.neg { background: var(--neg); }
.heat td, .heat th { text-align: center; }
.heat th:first-child { text-align: left; }
.pos-1 { background: var(--pos-1); } .pos-2 { background: var(--pos-2); } .pos-3 { background: var(--pos-3); } .pos-4 { background: var(--pos-4); }
.neg-1 { background: var(--neg-1); } .neg-2 { background: var(--neg-2); } .neg-3 { background: var(--neg-3); } .neg-4 { background: var(--neg-4); }
.heat td[class*="pos-"], .heat td[class*="neg-"], .cal td[class*="pos-"], .cal td[class*="neg-"] { color: var(--text); }

/* метрики */
.metrics { margin: 0; }
.mrow { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px dashed var(--border); font-size: .8125rem; }
.mrow:last-child { border-bottom: 0; }
.mrow dt { color: var(--muted); }
.mrow dd { margin: 0; text-align: right; }
.metrics.narrow { max-width: 360px; margin-top: 1rem; }

/* вкладки */
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); margin: -.25rem -.25rem .75rem; padding: 0 .25rem; }
.tabs button { font: inherit; font-size: .875rem; font-weight: 500; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: .6rem .8rem; cursor: pointer; white-space: nowrap; min-height: 44px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.count { font-family: var(--mono); font-size: .7rem; background: var(--surface-2); border-radius: 999px; padding: 0 .4rem; margin-left: .2rem; color: var(--muted); }

/* графики */
.chart-box { position: relative; height: 220px; }
.chart-box.tall { height: 400px; }

/* пустые состояния и уведомления */
.empty { padding: 1.25rem .5rem; text-align: center; }
.empty p { margin: .15rem 0; }
.notice { border: 1px solid var(--border); border-left-width: 4px; border-radius: 8px; padding: .7rem .9rem; margin: 0 0 1rem; background: var(--surface-2); }
.notice p { margin: .25rem 0; }
.notice.err { border-left-color: var(--neg); } .notice.warn { border-left-color: var(--warn); }
.notice.info { border-left-color: var(--info); } .notice.ok { border-left-color: var(--pos); }

/* обзор */
.totals { display: flex; gap: 2rem; flex-wrap: wrap; align-items: flex-end; }
.totals > div { display: grid; }
.totals b { font-size: 1.25rem; }
.totals-note { margin: 0; width: 100%; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.acc-tile { display: block; color: inherit; text-decoration: none; margin: 0; transition: border-color .15s; }
.acc-tile:hover { border-color: var(--accent); }
.acc-top { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; margin-bottom: .75rem; }
.acc-name { font-weight: 650; }
.acc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem .75rem; margin: 0; }
.acc-grid dt { font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.acc-grid dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* фильтры */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.pick { position: relative; }
.pick summary { cursor: pointer; min-height: 38px; display: flex; align-items: center; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: .875rem; }
.pick-list { position: absolute; z-index: 10; margin-top: .25rem; max-height: 260px; overflow: auto; min-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .4rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
.check { display: flex; gap: .5rem; align-items: center; padding: .3rem .4rem; color: var(--text); font-size: .875rem; }
.check input { width: auto; margin: 0; min-height: 0; }
.filter-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.sumrow { display: flex; flex-wrap: wrap; gap: .75rem 2rem; }
.sumrow > div { display: grid; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }

/* календарь */
.cal { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; min-width: 560px; }
.cal th { font-size: .75rem; color: var(--muted); font-weight: 600; padding: .25rem; }
.cal td.day { height: 76px; vertical-align: top; padding: .35rem .45rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.cal td.day.pos-1 { background: var(--pos-1); } .cal td.day.neg-1 { background: var(--neg-1); }
.cal td.day.pos-2 { background: var(--pos-2); } .cal td.day.neg-2 { background: var(--neg-2); }
.cal td.day.pos-3 { background: var(--pos-3); } .cal td.day.neg-3 { background: var(--neg-3); }
.cal td.day.pos-4 { background: var(--pos-4); } .cal td.day.neg-4 { background: var(--neg-4); }
.cal td.blank { border-color: transparent; background: transparent; }
.cal td.today { outline: 2px solid var(--accent); }
.cal .dnum { display: block; font-size: .75rem; color: var(--muted); }
.cal .dnet { display: block; font-size: .875rem; font-weight: 650; }
.cal .dtr { display: block; }
.cal td[class*="pos-"] .dnet, .cal td[class*="neg-"] .dnet, .cal td[class*="pos-"] .dnum, .cal td[class*="neg-"] .dnum, .cal td[class*="pos-"] .dtr, .cal td[class*="neg-"] .dtr { color: var(--text); }

/* события */
.evlist { list-style: none; margin: 0; padding: 0; }
.evlist li { display: flex; flex-wrap: wrap; gap: .1rem .6rem; padding: .4rem 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.ev { font-weight: 600; font-size: .8125rem; }
.ev.pos { color: var(--pos); } .ev.neg { color: var(--neg); } .ev.warn { color: var(--warn); }

/* вход, ошибки, шаги */
.login { max-width: 380px; margin: 12vh auto 0; }
.login .brand { margin: 0 0 1rem; }
.login h1 { margin-bottom: 1rem; }
.errpage { max-width: 520px; margin: 8vh auto 0; }
.steps { padding-left: 1.2rem; margin: 0 0 1rem; }
.steps li { margin: .3rem 0; }
.code { font-size: 1.75rem; letter-spacing: .12em; font-weight: 700; margin: .25rem 0; user-select: all; }

/* адаптив */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .grid-main, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-main > .card + .card { margin-top: 1rem; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .wrap { padding: .75rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .kpi-v { font-size: 1.05rem; }
  .chart-box.tall { height: 240px; }
  .topbar-in { gap: .5rem; }
  .pick-list { position: static; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* подсказка «?» (details без JS) */
.hint { display: inline-block; position: relative; vertical-align: middle; margin-left: .25rem; }
.hint > summary { list-style: none; cursor: help; width: 1.25rem; height: 1.25rem; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 700; line-height: 1.15rem; text-align: center; text-transform: none; letter-spacing: 0; }
.hint > summary::-webkit-details-marker { display: none; }
.hint > summary:hover, .hint[open] > summary { color: var(--accent); border-color: var(--accent); }
.hint-body { position: absolute; z-index: 30; left: 0; top: calc(100% + .3rem); width: min(20rem, calc(100vw - 6rem)); padding: .55rem .7rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(14, 17, 22, .18); font-size: .8125rem; font-weight: 400; line-height: 1.4; text-transform: none; letter-spacing: 0; white-space: normal; }
