/* TCA design tokens, reset and shared components */
:root {
  --bg: #060a15; --bg2: #0a1122; --panel: #0d1628; --panel2: #111c33; --panel3: #16233f;
  --line: rgba(112, 146, 255, .16); --line2: rgba(112, 146, 255, .28);
  --text: #eaf0ff; --muted: #93a1c2; --faint: #6b7a9c;
  --accent: #1f6bff; --accent2: #3fa4ff; --accent-ink: #fff; --accent-soft: rgba(31, 107, 255, .16);
  --good: #22c55e; --good-soft: rgba(34, 197, 94, .16); --warn: #f59e0b; --warn-soft: rgba(245, 158, 11, .16);
  --bad: #f0524f; --bad-soft: rgba(240, 82, 79, .16); --purple: #a78bfa; --orange: #fb923c; --gold: #f7a928;
  --card-bg: linear-gradient(180deg, rgba(19, 32, 62, .78), rgba(10, 19, 40, .88));
  --tile: rgba(255, 255, 255, .045); --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --r: 14px; --r-sm: 10px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Montserrat', 'Inter', system-ui, sans-serif;
  --nav-h: 66px; --tab-h: 64px; --maxw: 1320px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f2f5fb; --bg2: #e9eef9; --panel: #ffffff; --panel2: #f4f7fd; --panel3: #e8eefb;
  --line: rgba(31, 60, 140, .13); --line2: rgba(31, 60, 140, .25);
  --text: #0e1a36; --muted: #55648a; --faint: #8190b0;
  --accent: #1558e6; --accent2: #1f7bff; --accent-soft: rgba(21, 88, 230, .1);
  --good-soft: rgba(34, 197, 94, .14); --warn-soft: rgba(245, 158, 11, .16); --bad-soft: rgba(240, 82, 79, .12);
  --card-bg: #fff; --tile: rgba(20, 50, 120, .05); --shadow: 0 8px 30px rgba(20, 40, 100, .1);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; }
body.noscroll { overflow: hidden; }
a { color: var(--accent2); text-decoration: none; } a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0 0 .8em; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; vertical-align: -3px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .faint { color: var(--faint); }
.right { margin-left: auto; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; } .row.tight { gap: 6px; } .row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; } .stack.tight { gap: 8px; }
.grid { display: grid; gap: 16px; } .grid.g2 { grid-template-columns: repeat(2, 1fr); } .grid.g3 { grid-template-columns: repeat(3, 1fr); } .grid.g4 { grid-template-columns: repeat(4, 1fr); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }

/* ---------- cards */
.card { background: var(--card-bg); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.card.pad, .pad { padding: 20px; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; }
.card-h h2, .card-h h3 { margin: 0; font-size: 19px; font-weight: 700; }
.card-h .ico { color: var(--gold); display: grid; place-items: center; }
.card-h .more { margin-left: auto; font-size: 13px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.card-b { padding: 14px 20px 20px; }
.error-box { display: flex; gap: 14px; padding: 18px; color: var(--bad); }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; background: var(--panel3); color: var(--text); padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; line-height: 1.2; transition: transform .12s, box-shadow .2s, background .2s, border-color .2s; text-decoration: none !important; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); } .btn:active { transform: none; }
.btn.primary { background: linear-gradient(180deg, #2f7dff, #1558e6); color: #fff; box-shadow: 0 6px 20px rgba(31, 107, 255, .4); }
.btn.primary:hover { box-shadow: 0 8px 26px rgba(31, 107, 255, .6); }
.btn.ghost { background: transparent; border-color: var(--line2); } .btn.ghost:hover { background: var(--tile); }
.btn.light { background: #f4f7ff; color: #0b1634; } .btn.danger { background: var(--bad); color: #fff; }
.btn.good { background: var(--good); color: #05210f; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; } .btn.lg { padding: 13px 24px; font-size: 15px; }
.btn.block { width: 100%; } .btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { background: transparent; border: 0; padding: 8px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--tile); color: var(--text); }

/* ---------- forms */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field .lbl { font-weight: 600; font-size: 13px; color: var(--muted); }
.field .hint { color: var(--faint); font-size: 12px; } .field .err { color: var(--bad); font-size: 13px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; padding: 0; accent-color: var(--accent); flex: none; }
textarea { resize: vertical; min-height: 90px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; } .form-grid .full { grid-column: 1 / -1; }
.form-msg { padding: 10px 12px; border-radius: 10px; font-size: 14px; } .form-msg.err { background: var(--bad-soft); color: var(--bad); } .form-msg.ok { background: var(--good-soft); color: var(--good); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { position: relative; } .chip-check input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip-check span { display: inline-block; padding: 7px 14px; border: 1px solid var(--line2); border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--panel2); }
.chip-check input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* ---------- badges, avatars */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--tile); color: var(--muted); }
.badge.green { background: #1f9d4f; color: #fff; } .badge.blue { background: var(--accent); color: #fff; } .badge.amber { background: var(--warn); color: #231600; }
.badge.red { background: var(--bad); color: #fff; } .badge.purple { background: #7c5cf0; color: #fff; } .badge.gray { background: var(--panel3); color: var(--muted); }
.badge.demo { background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 6px, #d98a06 6px, #d98a06 12px); color: #231600; letter-spacing: .06em; font-size: 10px; }
:root[data-theme="light"] .badge.gray { color: #44527a; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #2d6cff, #6c3df5); color: #fff; font-weight: 700; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.plink { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; } .plink:hover { color: var(--accent2); text-decoration: none; }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; } .flag .cc { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.pill-tca { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--accent-soft); color: var(--accent2); padding: 2px 8px; border-radius: 6px; font-weight: 600; }

/* ---------- tables */
.tbl-wrap { overflow-x: auto; border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line2); white-space: nowrap; background: var(--tile); position: sticky; top: 0; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: var(--tile); } .tbl tr.click { cursor: pointer; }
.tbl .num { font-variant-numeric: tabular-nums; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.tbl .strong { font-weight: 700; }
.mk { font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: 1px; }
.mk.pb { background: var(--good-soft); color: var(--good); } .mk.cr { background: rgba(247, 169, 40, .2); color: var(--gold); }
.pos1 { color: var(--gold); font-weight: 800; } .pos2 { color: #cbd5e1; font-weight: 800; } .pos3 { color: #d6965b; font-weight: 800; }

/* ---------- tabs, pager, misc */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; margin-bottom: 18px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; padding: 11px 16px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--text); } .tab.on { color: var(--accent2); border-color: var(--accent2); }
.tab .count { background: var(--tile); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 18px 0 4px; flex-wrap: wrap; }
.pg { min-width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line2); background: transparent; } .pg.cur { background: var(--accent); border-color: var(--accent); color: #fff; } .pg[disabled] { opacity: .35; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 70px 20px; color: var(--muted); }
.spin { width: 30px; height: 30px; border: 3px solid var(--line2); border-top-color: var(--accent2); border-radius: 50%; animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 36px 16px; color: var(--muted); } .empty .icon { opacity: .6; margin-bottom: 8px; }
.prose p { margin: 0 0 1em; line-height: 1.65; max-width: 75ch; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; } .kv dt { color: var(--muted); font-size: 13px; } .kv dd { margin: 0; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.stat { background: var(--tile); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; } .stat span { color: var(--muted); font-size: 12.5px; }

/* ---------- modal & toast */
.modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(2, 6, 18, .7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .18s; }
.modal.wide { width: min(860px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); } .modal-h h3 { margin: 0; font-size: 18px; }
.modal-b { padding: 20px; overflow: auto; } .modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
#toasts { position: fixed; right: 16px; bottom: calc(var(--tab-h) + 16px); z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--panel3); border: 1px solid var(--line2); box-shadow: var(--shadow); animation: pop .2s; font-size: 14px; }
.toast.ok .icon { color: var(--good); } .toast.err .icon { color: var(--bad); } .toast.out { opacity: 0; transform: translateX(20px); transition: .3s; }
@media (min-width: 900px) { #toasts { bottom: 20px; } }
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
