/* Bonds AI — dark analytics terminal.
   Near-black surfaces, bright mint-green accent, high contrast.
   Class names kept stable so app.js keeps working. */
:root {
  /* surfaces (dark, slightly green-tinted graphite) */
  --bg: #080b0c;
  --bg-2: #0b0f10;
  --panel: #0f1517;
  --panel-2: #131b1d;
  --panel-3: #172023;
  --line: #26333a;
  --line-2: #38484f;

  /* text — brighter for contrast */
  --text: #f2f8f5;
  --muted: #a6bab1;
  --muted-2: #7d918a;

  /* accent — mint green like the reference */
  --acc: #1fe0a0;
  --acc-2: #14b982;
  --acc-dim: #0e8f65;
  --acc-glow: rgba(31,224,160,.22);

  /* semantic */
  --green: #2fe08a; --red: #ff5470; --amber: #f5b13c; --cyan: #35d6e6; --violet: #8b7bff;

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
  --shadow: 0 2px 6px rgba(0,0,0,.4), 0 12px 34px -18px rgba(0,0,0,.7);
  --shadow-lg: 0 8px 40px -12px rgba(0,0,0,.75);
  --ring: 0 0 0 3px rgba(31,224,160,.22);
  --font: "Inter", ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* light theme — same mint accent, light surfaces */
body.light {
  --bg: #eef1f2; --bg-2: #ffffff; --panel: #ffffff; --panel-2: #f6f8f8;
  --panel-3: #eef2f2; --line: #e3e9e9; --line-2: #d0dada;
  --text: #101a17; --muted: #5f7169; --muted-2: #7a8a83;
  --acc: #0fae7a; --acc-2: #0c9468; --acc-glow: rgba(15,174,122,.18);
  /* семантические цвета для БЕЛОЙ темы: dark-тема оставляет их яркими (для тёмного
     фона), на белом они тонут — переопределяем в читаемые тёмные тона (как в paper). */
  --green: #0a9d5f; --red: #d1233b; --amber: #a8760a; --cyan: #0e8fa6; --violet: #6f5fc7;
  --shadow: 0 1px 3px rgba(16,26,23,.08), 0 10px 30px -18px rgba(16,26,23,.25);
  --shadow-lg: 0 10px 40px -14px rgba(16,26,23,.22);
}
body.light {
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(15,174,122,.06), rgba(15,174,122,0) 55%),
    var(--bg);
}

/* ── "Paper" theme — warm editorial skin (IBM Plex, bronze accent), ported
      from the reference artifact. Same class names, only tokens + type change. */
body.paper {
  --bg: #F1F0EC; --bg-2: #FFFFFF; --panel: #FFFFFF; --panel-2: #FAF9F5;
  --panel-3: #F1F0EC; --line: #DEDCD5; --line-2: #C6C3BA;
  --text: #191B1F; --muted: #74787F; --muted-2: #9A9E97;
  --acc: #8A6320; --acc-2: #6F4F19; --acc-dim: #B08A45; --acc-glow: rgba(138,99,32,.13);
  --green: #1D6A4B; --red: #A63A31; --amber: #B08A45; --cyan: #B08A45; --violet: #6f5fc7;
  --shadow: 0 1px 2px rgba(25,27,31,.05), 0 10px 28px -20px rgba(25,27,31,.30);
  --shadow-lg: 0 10px 40px -14px rgba(25,27,31,.28);
  --ring: 0 0 0 3px rgba(138,99,32,.18);
  --font: "IBM Plex Sans", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r-sm: 4px; --r: 5px; --r-lg: 6px; --r-xl: 8px;
}
body.paper {
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(138,99,32,.05), rgba(138,99,32,0) 55%),
    var(--bg);
}
body.paper h1, body.paper h2, body.paper h3, body.paper .brand {
  font-family: "IBM Plex Serif", Georgia, "Times New Roman", serif; letter-spacing: -.01em;
}
body.paper .kpi .value, body.paper .num, body.paper .value { font-family: var(--mono); }
/* recolor the hardcoded-mint accents to bronze so nothing stays green */
body.paper nav button[data-tab].active { background: rgba(138,99,32,.12); box-shadow: inset 0 0 0 1px rgba(138,99,32,.30); }
body.paper button#btn-refresh { background: rgba(138,99,32,.10); border-color: rgba(138,99,32,.35); }
body.paper button#btn-refresh:hover { background: rgba(138,99,32,.18); }
body.paper tbody tr:hover { background: rgba(138,99,32,.07); }
body.paper .badge.fix, body.paper .badge.moex { background: rgba(138,99,32,.12); border-color: rgba(138,99,32,.25); }
body.paper .alert.info { background: rgba(138,99,32,.07); border-color: rgba(138,99,32,.22); color: var(--text); }
body.paper .chip.on { background: var(--acc); color: #fff; border-color: var(--acc); }
body.paper .ac-item:hover, body.paper .ac-item.active { background: rgba(138,99,32,.10); }
body.paper .btn { color: #fff; }
body.paper ::selection { background: rgba(138,99,32,.22); color: #191B1F; }
/* light masthead like the reference (the dark header is dark-theme only) */
body.paper header { background: var(--panel); border-bottom: 1px solid var(--line-2); }
body.paper .brand { color: var(--text); }
body.paper nav button[data-tab] { color: var(--muted); }
body.paper nav button[data-tab]:hover { background: rgba(138,99,32,.07); color: var(--text); }
body.paper nav button[data-tab].active { color: var(--acc); }
body.paper .section-switch .sec-btn { background: var(--panel-2); color: var(--ink-2, var(--muted)); border: 1px solid var(--line); }
body.paper .section-switch .sec-btn:hover { background: rgba(138,99,32,.08); color: var(--text); }
body.paper .section-switch .sec-btn.active { background: var(--acc); color: #fff; border-color: var(--acc); box-shadow: none; }

/* белая тема: шапка светлая (не чёрный бар), как в бумаге — перекрашиваем весь текст навигации */
body.light header { background: var(--panel); border-bottom: 1px solid var(--line-2); }
body.light .brand { color: var(--text); }
body.light #updated, body.light #btn-refresh-full, body.light #visit-counter { color: var(--muted); }
body.light nav button[data-tab] { color: var(--muted); }
body.light nav button[data-tab]:hover { background: rgba(15,174,122,.08); color: var(--text); }
body.light nav button[data-tab].active { background: rgba(15,174,122,.12); color: var(--acc); box-shadow: inset 0 0 0 1px rgba(15,174,122,.3); }
body.light .section-switch .sec-btn { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
body.light .section-switch .sec-btn:hover { background: rgba(15,174,122,.08); color: var(--text); }
body.light .section-switch .sec-btn.active { background: linear-gradient(135deg, var(--acc), var(--acc-2)); color: #fff; border-color: var(--acc); box-shadow: none; }

/* ── "Indigo" theme — deep navy / violet night skin (4th style). */
body.indigo {
  --bg: #080b16; --bg-2: #0c1122; --panel: #10162e; --panel-2: #151d3d; --panel-3: #1a2450;
  --line: #202a4d; --line-2: #2d3968;
  --text: #e7ecff; --muted: #8d97c4; --muted-2: #5c6699;
  --acc: #7c8cff; --acc-2: #5f6fe6; --acc-dim: #4854b0; --acc-glow: rgba(124,140,255,.24);
  --green: #4fd6a0; --red: #ff6b8a; --amber: #f6b64a; --cyan: #4bc8ff; --violet: #a78bff;
  --shadow: 0 2px 6px rgba(0,0,0,.5), 0 14px 40px -18px rgba(0,0,0,.8);
  --ring: 0 0 0 3px rgba(124,140,255,.25);
}
body.indigo {
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(124,140,255,.10), rgba(124,140,255,0) 55%),
    radial-gradient(900px 500px at -6% -4%, rgba(75,200,255,.06), rgba(75,200,255,0) 50%),
    var(--bg);
}
/* recolor hardcoded-mint accents to indigo */
body.indigo nav button[data-tab].active { background: rgba(124,140,255,.16); color: var(--acc); box-shadow: inset 0 0 0 1px rgba(124,140,255,.35); }
body.indigo button#btn-refresh { background: rgba(124,140,255,.12); color: var(--acc); border-color: rgba(124,140,255,.4); }
body.indigo button#btn-refresh:hover { background: rgba(124,140,255,.2); }
body.indigo tbody tr:hover { background: rgba(124,140,255,.07); }
body.indigo .badge.fix, body.indigo .badge.moex { background: rgba(124,140,255,.14); color: var(--acc); border-color: rgba(124,140,255,.3); }
body.indigo .chip.on { background: rgba(124,140,255,.16); color: var(--acc); border-color: rgba(124,140,255,.55); }
body.indigo .alert.info { background: rgba(124,140,255,.08); border-color: rgba(124,140,255,.25); color: var(--text); }
body.indigo .ac-item:hover, body.indigo .ac-item.active { background: rgba(124,140,255,.12); }
body.indigo ::selection { background: rgba(124,140,255,.3); color: #fff; }

/* ── Settings popover (⚙): style picker + day/night toggle. */
.settings-pop {
  position: absolute; top: calc(100% + 8px); right: 0; width: 232px; z-index: 60;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 13px;
}
.sp-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 7px; font-weight: 700; }
.sp-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }
.sp-style { display: flex; align-items: center; gap: 7px; padding: 9px 10px; border: 1px solid var(--line-2);
  border-radius: 9px; background: var(--bg-2); color: var(--text); cursor: pointer; font: 600 12.5px/1 var(--font); }
.sp-style.on { border-color: var(--acc); color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.sp-style:hover { border-color: var(--acc); }
.sp-mode { width: 100%; padding: 9px; border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--bg-2); color: var(--text); cursor: pointer; font: 600 12.5px/1 var(--font); }
.sp-mode:hover { border-color: var(--acc); color: var(--acc); }

/* ── Client picker cards (portfolio landing) */
.cl-card { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  padding: 16px 18px; cursor: pointer; transition: border-color .15s, transform .1s, box-shadow .15s; }
.cl-card:hover { border-color: var(--acc); transform: translateY(-2px); box-shadow: var(--shadow); }
.cl-card { position: relative; }
.cl-del { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 7px;
  background: rgba(255,255,255,.05); color: var(--muted); border: none; cursor: pointer; font-size: 12px;
  display: none; align-items: center; justify-content: center; transition: background .12s, color .12s; }
.cl-card:hover .cl-del { display: flex; }
.cl-del:hover { background: rgba(255,90,90,.2); color: #ff6b6b; }
.top-tbl:not(.show-all) tr.tr-extra { display: none; }
.tr-toggle td { text-align: center !important; padding-top: 10px; }
.toggle-top { font-size: 12px; }
.cl-del-inline { display: inline-flex; align-items: center; justify-content: center; visibility: hidden;
  margin-left: 6px; width: 18px; height: 18px; border-radius: 5px;
  background: rgba(255,90,90,.14); color: #ff6b6b; border: none; cursor: pointer; font-size: 10px;
  vertical-align: middle; line-height: 1; }
.cl-row:hover .cl-del-inline { visibility: visible; }
.cl-del-inline:hover { background: rgba(255,90,90,.28); }
.cl-name { font-weight: 700; font-size: 16px; color: var(--text); }
.cl-open { margin-top: 12px; font-size: 12.5px; color: var(--acc); font-weight: 600; }

/* ── Pretty modal (replaces native prompt) */
.modal-ov { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.modal { width: min(420px, 92vw); background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 22px; }
.modal-title { font-weight: 700; font-size: 16px; color: var(--text); margin-bottom: 14px; }
.modal-input { width: 100%; }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── Portfolio picker inside a client (все / портфель 1 / 2 …) */
.pf-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pf-chip { display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 8px 14px; border-radius: 11px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); cursor: pointer; line-height: 1.25;
  transition: border-color .15s, background .15s, transform .1s; }
.pf-chip:hover { border-color: var(--acc); transform: translateY(-1px); }
.pf-chip.on { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 16%, var(--panel-2));
  box-shadow: inset 0 0 0 1px var(--acc); }
.pf-chip-n { font-weight: 700; font-size: 13.5px; }
.pf-chip-mv { font-size: 11px; color: var(--muted); }
.pf-chip { position: relative; }
.pf-chip.has-x { padding-right: 30px; }
.pf-acts { position: absolute; top: 5px; right: 6px; display: none; gap: 2px; }
.pf-chip.has-x:hover .pf-acts { display: flex; }
.pf-mini { background: rgba(255,255,255,.06); color: var(--muted); border: none; width: 19px; height: 19px;
  border-radius: 6px; cursor: pointer; font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s; }
.pf-mini:hover { background: rgba(255,255,255,.14); color: var(--text); }
.pf-mini[data-act="del"]:hover { background: rgba(255,90,90,.2); color: #ff6b6b; }
.pf-add { flex-direction: row; align-items: center; justify-content: center; color: var(--acc);
  border-style: dashed; font-weight: 700; font-size: 13px; }
.pf-add:hover { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 10%, var(--panel-2)); }
.btn.danger { background: rgba(255,90,90,.16); color: #ff6b6b; border: 1px solid rgba(255,90,90,.4); }
.btn.danger:hover { background: rgba(255,90,90,.26); }

/* ── «Важные даты» — раскрывающиеся ветки (купоны / оферты / погашения) */
.imp-grp { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; margin-bottom: 10px;
  background: var(--panel-2); }
.imp-grp > summary { display: flex; align-items: center; gap: 8px; cursor: pointer;
  list-style: none; padding: 10px 2px; font-weight: 600; font-size: 14px; color: var(--text); }
.imp-grp > summary::-webkit-details-marker { display: none; }
.imp-grp > summary::after { content: "⌄"; margin-left: 4px; color: var(--muted); transition: transform .15s; }
.imp-grp[open] > summary::after { transform: rotate(180deg); }
.imp-total { margin-left: auto; font-variant-numeric: tabular-nums; }
.imp-week { border: 1px solid var(--acc); border-radius: 12px; padding: 10px 14px 6px; margin-bottom: 14px;
  background: color-mix(in srgb, var(--acc) 7%, var(--panel-2)); }
.imp-week-h { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.evt-badge { display: inline-block; padding: 1px 8px; border: 1px solid; border-radius: 999px; font-size: 11px; font-weight: 600; }
.rate-badge { display: inline-block; padding: 1px 8px; border: 1px solid; border-radius: 6px; font-size: 11px; font-weight: 700; }
.htip { position: fixed; z-index: 300; display: none; min-width: 200px; max-width: 260px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px;
  box-shadow: var(--shadow-lg); pointer-events: none; font-size: 12.5px; }
.htip-h { font-weight: 700; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.htip-r { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.htip-r b { font-variant-numeric: tabular-nums; }

/* ── Симпатичные поля даты/числа под тёмную тему */
input[type=date], input[type=number], input[type=text], .modal-input {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 8px 11px; font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s; }
input[type=date]:focus, input[type=number]:focus, input[type=text]:focus, .modal-input:focus {
  outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 22%, transparent); }
input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(.5) sepia(1) saturate(3) hue-rotate(120deg); cursor: pointer; opacity: .8; }
input[type=date]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  background:
    radial-gradient(1100px 520px at 88% -8%, rgba(31,224,160,.08), rgba(31,224,160,0) 55%),
    radial-gradient(900px 500px at -6% -4%, rgba(53,214,230,.05), rgba(53,214,230,0) 50%),
    var(--bg);
  background-attachment: fixed;
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, .brand { letter-spacing: -.015em; }
td, th, .value, .kpi .value, .num { font-variant-numeric: tabular-nums; }
a { color: var(--acc); }

/* ------------------------------------------------------------------ header */
header {
  display: flex; flex-direction: column; gap: 9px; padding: 11px 24px;
  background: linear-gradient(180deg, rgba(15,21,23,.92), rgba(11,15,16,.82));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.hd-main { display: flex; align-items: center; gap: 22px; }
.brand {
  font-weight: 800; font-size: 16px; white-space: nowrap; color: #fff;
  display: flex; align-items: center; gap: 10px;
}
.brand b { color: var(--acc); font-weight: 800; }
.brand-by { color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none;
  white-space: nowrap; transition: color .15s; align-self: center; }
.brand-by:hover { color: var(--acc); }
.brand::before {
  content: ""; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, var(--acc), var(--cyan));
  box-shadow: 0 0 18px var(--acc-glow); flex: none;
}
nav { display: flex; }
#secnav { flex: 0 0 auto; }
#tabs { width: 100%; }
.section-switch { display: flex; gap: 6px; }
.section-switch .sec-btn {
  background: rgba(255,255,255,.04); color: #cdd8d4; border: none; padding: 8px 18px;
  border-radius: 10px; cursor: pointer; font: 800 13.5px/1 var(--font);
  transition: background .16s, color .16s; letter-spacing: .2px;
}
.section-switch .sec-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.section-switch .sec-btn.active {
  background: linear-gradient(135deg, var(--acc), var(--cyan)); color: #06231b;
  box-shadow: 0 0 16px var(--acc-glow);
}
.tab-row { display: flex; gap: 2px; flex-wrap: wrap; }
nav button[data-tab] {
  background: transparent; color: #9fb1ab; border: none; padding: 7px 13px;
  border-radius: 999px; cursor: pointer; font: 600 12.5px/1 var(--font);
  transition: background .16s, color .16s;
}
nav button[data-tab]:hover { background: rgba(255,255,255,.05); color: #fff; }
nav button[data-tab].active { background: rgba(31,224,160,.14); color: var(--acc); box-shadow: inset 0 0 0 1px rgba(31,224,160,.3); }
.actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
#updated { color: #7f938d; font-size: 12.5px; }
button#btn-refresh {
  background: rgba(31,224,160,.10); color: var(--acc);
  border: 1px solid rgba(31,224,160,.35); padding: 8px 15px; border-radius: 999px;
  cursor: pointer; font: 700 13px/1 var(--font); transition: background .16s, box-shadow .16s, transform .1s;
}
button#btn-refresh:hover { background: rgba(31,224,160,.18); box-shadow: 0 0 18px var(--acc-glow); }
button#btn-refresh:active { transform: translateY(1px); }
/* «Полное» — вторичная ghost-кнопка (тяжёлое обновление, только локально) */
button#btn-refresh-full {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: #7f938d;
  border: 1px solid rgba(127,147,141,.30); padding: 8px 13px; border-radius: 999px;
  cursor: pointer; font: 600 12.5px/1 var(--font);
  transition: color .16s, background .16s, border-color .16s, box-shadow .16s, transform .1s;
}
button#btn-refresh-full:hover { color: var(--acc); border-color: rgba(31,224,160,.45); background: rgba(31,224,160,.07); box-shadow: 0 0 14px var(--acc-glow); }
button#btn-refresh-full:active { transform: translateY(1px); }
button#btn-refresh-full:disabled { opacity: .45; cursor: default; box-shadow: none; }

main { padding: 28px 28px 10px; max-width: min(1760px, 96vw); margin: 0 auto; animation: viewIn .3s cubic-bezier(.2,.7,.3,1); }
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  width: 18px; height: 18px; border-radius: 5px; cursor: pointer; vertical-align: -4px;
  border: 1.5px solid var(--line-2); background: var(--panel-2); position: relative; flex: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
input[type="checkbox"]:hover { border-color: var(--acc); }
input[type="checkbox"]:checked { background: linear-gradient(135deg, var(--acc), var(--cyan)); border-color: var(--acc); }
input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 9px;
  border: solid #06231b; border-width: 0 2px 2px 0; transform: rotate(43deg);
}
/* светлые темы (бумага/белая): заливка чекбокса тёмно-бронзовая/зелёная — тёмная
   галочка на ней сливается, делаем белой */
body.paper input[type="checkbox"]:checked::after,
body.light input[type="checkbox"]:checked::after { border-color: #fff; }
input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 25%, transparent); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
footer { padding: 24px; font-size: 12px; color: var(--muted-2); text-align: center; }
.muted { color: var(--muted); }
.loading { padding: 70px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading::before { content: ""; width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--acc); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------------- kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
/* карточка выпуска: строго 4 тайла в ряд (даты — Погашение/Срок/Оферта — отдельным нижним рядом) */
.kpis-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .kpis-4 { grid-template-columns: repeat(2, 1fr); } }
.kpi { position: relative; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow); overflow: hidden; transition: transform .16s, border-color .16s; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--acc), var(--cyan)); opacity: 0; transition: opacity .16s; }
.kpi:hover { transform: translateY(-2px); border-color: var(--line-2); }
.kpi:hover::before { opacity: 1; }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.kpi .value { font-size: 25px; font-weight: 800; margin-top: 7px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; margin-top: 4px; color: var(--muted); font-weight: 500; }
/* KPI-тайл в виде кнопки («Другие выпуски эмитента» во втором ряду карточки) */
.kpi-btn { cursor: pointer; font: inherit; text-align: left; color: inherit; display: block; }
.kpi-btn:hover { border-color: var(--acc); }
.kpi-btn:hover::before { opacity: 1; }
.kpi-btn .value { color: var(--acc); }
.pos { color: var(--green); } .neg { color: var(--red); }

/* ------------------------------------------------------------------ layout */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 16px; font-size: 15px; color: var(--text); font-weight: 700; display: flex; align-items: center; gap: 9px; }
.panel h3::before { content: ""; width: 4px; height: 15px; border-radius: 2px; background: linear-gradient(180deg, var(--acc), var(--cyan)); }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 420px; }

/* ------------------------------------------------------------------ tables */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); }
.tbl-wrap.panel { padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 13px; text-align: center; white-space: nowrap; }
/* широкие таблицы (скринер, карта, идеи) — компактнее, чтобы влезало без промотки */
.tbl-wrap th, .tbl-wrap td { padding: 7px 7px; font-size: 12.5px; }
.tbl-wrap th { letter-spacing: .2px; }
th { color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel-3); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line-2); transition: color .15s; }
th:hover { color: var(--acc); }
td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
th:first-child, td:first-child { text-align: left; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(31,224,160,.05); }
.link { color: var(--acc); cursor: pointer; font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ------------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.4; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.fix, .badge.moex { background: rgba(31,224,160,.12); color: var(--acc); border-color: rgba(31,224,160,.25); }
.badge.float { background: rgba(53,214,230,.12); color: var(--cyan); border-color: rgba(53,214,230,.25); }
.badge.excel { background: rgba(139,123,255,.12); color: var(--violet); }
.badge.none, .badge.unknown { background: rgba(255,255,255,.05); color: var(--muted); }
.badge.green { background: rgba(47,224,138,.12); color: var(--green); }

/* rating pill, color by grade */
.rt { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; border: 1px solid; }
.rt-AAA, .rt-AA { color: #2fe08a; border-color: rgba(47,224,138,.4); background: rgba(47,224,138,.08); }
.rt-A { color: #7ddc5b; border-color: rgba(125,220,91,.4); background: rgba(125,220,91,.08); }
.rt-BBB { color: #e7d84a; border-color: rgba(231,216,74,.4); background: rgba(231,216,74,.08); }
.rt-BB { color: #f5b13c; border-color: rgba(245,177,60,.4); background: rgba(245,177,60,.08); }
.rt-B { color: #ff8a4c; border-color: rgba(255,138,76,.4); background: rgba(255,138,76,.08); }
.rt-CCC, .rt-CC, .rt-C, .rt-D { color: #ff5470; border-color: rgba(255,84,112,.4); background: rgba(255,84,112,.08); }
.rt-NR { color: var(--muted); border-color: var(--line-2); }
/* светлые темы (белая + кремовая paper): яркие цвета бейджей рейтинга тонут — тёмные тона */
body.light .rt-AAA, body.light .rt-AA, body.paper .rt-AAA, body.paper .rt-AA { color: #0a7d4c; }
body.light .rt-A, body.paper .rt-A { color: #4a8a1a; }
body.light .rt-BBB, body.paper .rt-BBB { color: #8a7400; }
body.light .rt-BB, body.paper .rt-BB { color: #9a5c00; }
body.light .rt-B, body.paper .rt-B { color: #b0480d; }
body.light .rt-CCC, body.light .rt-CC, body.light .rt-C, body.light .rt-D,
body.paper .rt-CCC, body.paper .rt-CC, body.paper .rt-C, body.paper .rt-D { color: #c01f37; }

/* ------------------------------------------------------------------ alerts */
.alert { padding: 12px 15px; border-radius: var(--r); margin-bottom: 12px; border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.alert::before { font-size: 14px; }
.alert.info { background: rgba(31,224,160,.06); border-color: rgba(31,224,160,.22); color: #bfe9db; }
.alert.info::before { content: "ⓘ"; color: var(--acc); }
.alert.warn { background: rgba(245,177,60,.07); border-color: rgba(245,177,60,.28); color: #f2d29a; }
.alert.warn::before { content: "⚠"; color: var(--amber); }
.alert.error { background: rgba(255,84,112,.07); border-color: rgba(255,84,112,.3); color: #f5b6c1; }
.alert.error::before { content: "✕"; color: var(--red); }
/* светлые темы: бледный текст алертов невидим на белом/кремовом — тёмные тона */
body.light .alert.info, body.paper .alert.info { color: #0a6b4c; }
body.light .alert.warn, body.paper .alert.warn { color: #8a5a00; }
body.light .alert.error, body.paper .alert.error { color: #b3223b; }

/* ---------------------------------------------------------------- controls */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=number], textarea, select {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 9px 12px; font: 14px/1.4 var(--font);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--acc); box-shadow: var(--ring); }
textarea { resize: vertical; }
.btn { background: linear-gradient(180deg, var(--acc), var(--acc-2)); color: #04120c; border: none; padding: 10px 18px; border-radius: var(--r-sm); cursor: pointer; font: 800 13.5px/1 var(--font); transition: filter .15s, transform .1s, box-shadow .15s; }
.btn:hover { filter: brightness(1.08); box-shadow: 0 0 20px var(--acc-glow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; box-shadow: none; }
.btn.ghost { background: transparent; border: 1px solid var(--line-2); color: var(--text); }
.btn.ghost:hover { border-color: var(--acc); color: var(--acc); filter: none; box-shadow: none; }
/* светлые темы: прозрачная ghost-кнопка бледная — даём фон панели и явный тёмный текст */
body.light .btn.ghost, body.paper .btn.ghost { background: var(--panel-2); color: var(--text); border-color: var(--line-2); }
body.light .btn.ghost:hover, body.paper .btn.ghost:hover { color: var(--acc); border-color: var(--acc); }
.drop { border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); padding: 40px; text-align: center; color: var(--muted); background: var(--bg-2); transition: border-color .18s, background .18s, color .18s; }
.drop.over { border-color: var(--acc); color: var(--acc); background: rgba(31,224,160,.05); }

/* filter chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid var(--line-2); color: var(--muted); background: var(--bg-2); transition: all .14s; user-select: none; }
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.on { background: rgba(31,224,160,.14); color: var(--acc); border-color: rgba(31,224,160,.5); }
/* счётчик внутри ВЫБРАННОГО чипа — наследует цвет чипа (иначе тёмный --muted тонет на заливке) */
.chip.on .muted { color: inherit; opacity: .8; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px 20px; align-items: start; }
.field.full { grid-column: 1 / -1; }
.panel.fullscreen { position: fixed; inset: 10px; z-index: 1000; margin: 0; overflow: auto; box-shadow: 0 0 0 100vmax rgba(0,0,0,.6); }
.panel.fullscreen .chart.tall { height: calc(100vh - 130px) !important; }
.range { display: flex; align-items: center; gap: 8px; }
.range input { width: 84px; }

/* autocomplete dropdown */
.ac-wrap { position: relative; }
.ac-menu { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px); background: var(--panel-3); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; }
.ac-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 13px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: rgba(31,224,160,.10); }
.ac-item .nm { font-weight: 600; color: var(--text); }
.ac-item .meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.ac-item .isin { color: var(--muted-2); font-size: 11px; font-family: var(--mono); }

.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 2px 0 4px; }
.stat-row .s .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-row .s .v { font-size: 18px; font-weight: 800; margin-top: 2px; }

/* ============================ телефон / планшет ============================ */
@media (max-width: 760px) {
  header { padding: 9px 13px; gap: 8px; }
  .hd-main { gap: 10px; flex-wrap: wrap; }
  .brand { font-size: 15px; }
  .actions { gap: 8px; }
  #updated { font-size: 11px; line-height: 1.15; max-width: 128px; text-align: right; }
  button#btn-refresh { padding: 8px 12px; font-size: 12px; }
  #btn-settings { padding: 6px 9px !important; }
/* Шапка всегда тёмная (в обеих темах), поэтому кнопка настроек не должна брать
   var(--text) — на светлой теме он тёмный и шестерёнка сливается с фоном. */
#btn-settings { color: #9fb1ab !important; border-color: rgba(255,255,255,.16) !important; }
#btn-settings:hover { color: #fff !important; border-color: rgba(255,255,255,.4) !important; }
/* светлые темы: шапка светлая → шестерёнка должна быть тёмной */
body.light #btn-settings, body.paper #btn-settings { color: var(--muted) !important; border-color: var(--line-2) !important; }
body.light #btn-settings:hover, body.paper #btn-settings:hover { color: var(--text) !important; border-color: var(--acc) !important; }
  /* вкладки — горизонтальный скролл вместо переноса в столбик */
  #tabs { width: 100%; }
  .tab-row { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px; }
  .tab-row::-webkit-scrollbar { display: none; }
  nav button[data-tab] { white-space: nowrap; flex: 0 0 auto; padding: 8px 12px; font-size: 13px; }
  main { padding: 14px 12px 46px; max-width: 100%; }
  .panel { padding: 14px 13px; border-radius: 13px; }
  h2 { font-size: 17px; } h3 { font-size: 15px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .kpi { padding: 12px 13px; }
  .kpi .value, .kpi .value { font-size: 20px; }
  .grid2, .grid3 { grid-template-columns: 1fr; gap: 12px; }
  .chart { min-height: 240px; }
  .chart.tall { min-height: 300px; }
  /* таблицы уже скроллятся внутри .tbl-wrap — просто компактнее */
  table { font-size: 12.5px; }
  th, td { padding: 7px 9px; }
  .toolbar { gap: 8px; }
  .toolbar input[type=text] { width: 100% !important; }
  .filters { gap: 12px; }
  .modal { width: 96vw !important; padding: 16px 14px; }
  .modal .chart { min-height: 260px; }
  footer { padding: 14px 12px 26px; font-size: 11px; }
}
/* тач-устройства: убрать «залипающий» hover-сдвиг */
@media (hover: none) {
  .kpi:hover, .cl-card:hover, .pf-chip:hover, .sp-style:hover, .btn:hover,
  nav button:hover, .chip:hover { transform: none; box-shadow: var(--shadow); }
  .kpi:hover::before { opacity: 0; }
}

/* ---- заставка запуска (~3.4с), динамичная ---- */
#splash { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 38%, #12241d, #0a1210 68%);
  transition: opacity .6s ease, visibility .6s; }
#splash.gone { opacity: 0; visibility: hidden; pointer-events: none; }
/* заставка под выбранную тему: фон и заголовок не должны оставаться тёмно-зелёными на светлых темах */
body.light #splash { background: radial-gradient(circle at 50% 38%, #ffffff, #eef1f2 68%); }
body.paper #splash { background: radial-gradient(circle at 50% 38%, #f6f1e8, #ece5d7 68%); }
body.light .splash-title, body.paper .splash-title { background: linear-gradient(100deg, var(--text) 30%, var(--acc) 50%, var(--text) 70%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; }
body.light .splash-bar, body.paper .splash-bar { background: rgba(16,26,23,.10); }
/* движущееся фоновое свечение */
.splash-bg { position: absolute; width: 150vmax; height: 150vmax; left: 50%; top: 50%;
  transform: translate(-50%, -50%); pointer-events: none; opacity: .5;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(31,224,160,.18) 60deg, transparent 130deg, rgba(53,214,230,.15) 220deg, transparent 300deg);
  animation: splSpin 8s linear infinite; filter: blur(30px); }
.splash-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 15px; padding: 20px; }
.splash-logo { position: relative; width: 88px; height: 88px; border-radius: 24px;
  background: linear-gradient(135deg, var(--acc), var(--cyan, #35d6e6)); background-size: 200% 200%;
  box-shadow: 0 0 60px var(--acc-glow, rgba(31,224,160,.5));
  animation: splPop .7s cubic-bezier(.2,.9,.3,1) both, splPulse 1.8s ease-in-out .8s infinite, splShift 3s ease-in-out infinite; }
/* вращающееся кольцо вокруг логотипа */
.splash-ring { position: absolute; inset: -9px; border-radius: 30px; padding: 2px;
  background: conic-gradient(from 0deg, transparent 0 55%, var(--acc) 78%, var(--cyan, #35d6e6) 92%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: splSpin 1.6s linear infinite; }
.splash-title { font-size: 38px; font-weight: 800; letter-spacing: -.02em; animation: splUp .7s .15s both;
  background: linear-gradient(100deg, #fff 30%, var(--acc) 50%, #fff 70%); background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  animation: splUp .7s .15s both, splShimmer 2.4s linear .9s infinite; }
.splash-title b { -webkit-text-fill-color: var(--acc); }
.splash-sub { color: var(--muted); font-size: 13.5px; letter-spacing: .2px; animation: splUp .7s .3s both; }
/* рисующаяся кривая доходности */
.splash-spark { width: 240px; height: 46px; margin-top: 2px; overflow: visible; animation: splUp .7s .4s both; }
.splash-spark polyline { fill: none; stroke: var(--acc); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px var(--acc-glow, rgba(31,224,160,.6)));
  stroke-dasharray: 640; stroke-dashoffset: 640; animation: splDraw 2.6s ease-in-out .5s forwards; }
.splash-bar { width: 200px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 4px; }
.splash-bar::after { content: ""; display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--acc), var(--cyan, #35d6e6)); animation: splLoad 3.2s cubic-bezier(.4,0,.2,1) forwards; }
@keyframes splSpin { to { transform: rotate(360deg); } }
.splash-bg { animation: splSpinBg 8s linear infinite; }
@keyframes splSpinBg { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes splPop { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes splPulse { 0%, 100% { box-shadow: 0 0 38px var(--acc-glow, rgba(31,224,160,.4)); } 50% { box-shadow: 0 0 90px var(--acc-glow, rgba(31,224,160,.7)); } }
@keyframes splShift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes splUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes splShimmer { to { background-position: -220% 0; } }
@keyframes splDraw { to { stroke-dashoffset: 0; } }
@keyframes splLoad { 0% { width: 0; } 55% { width: 66%; } 100% { width: 100%; } }
@media (prefers-reduced-motion: reduce) { #splash *, .splash-bg { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* счётчик посещений — в ряд с кнопками справа, компактно */
#visit-counter { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
#visit-counter:empty { display: none; }

/* иконка «развернуть» в углу графика — без ободка, лёгкая */
.xc-btn { position: absolute; top: -2px; right: 0; z-index: 4; display: grid; place-items: center;
  width: 22px; height: 22px; padding: 0; border: none; background: transparent; cursor: pointer;
  color: var(--muted); opacity: .55; transition: color .15s, opacity .15s, transform .12s; }
.xc-btn:hover { color: var(--acc); opacity: 1; transform: scale(1.12); }
.xc-btn svg { display: block; width: 14px; height: 14px; }

::selection { background: rgba(31,224,160,.28); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #33444a; }
::-webkit-scrollbar-track { background: transparent; }

/* ссылка на гайд в настройках — выглядит как кнопка режима */
.sp-link { display: block; text-decoration: none; text-align: center; box-sizing: border-box; width: 100%; }
