:root {
  --bg: #0d0b25; --bg2: #120f33; --surface: rgba(26, 22, 72, .62); --solid: #17143f;
  --text: #f1f2ff; --muted: #9a9ecf; --border: rgba(132, 120, 255, .22);
  --accent: #7c5cff; --accent2: #5230e0;
  --green: #35d6a0; --red: #ff6b83; --amber: #f6bd60; --blue: #4cc9f0; --grey: #8c92c4;
  --glow: 124, 92, 255; --radius: 16px;
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; color: var(--text); min-height: 100vh; font-size: 15px; line-height: 1.5;
  background:
    radial-gradient(1100px 520px at 75% -8%, rgba(91, 61, 240, .24), transparent 62%),
    radial-gradient(800px 480px at 0% 100%, rgba(53, 214, 160, .06), transparent 60%), var(--bg);
  background-attachment: fixed;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100; border-radius: 0 0 8px 0; }
.skip:focus { left: 0; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.025em; }
h1 { font-size: 2rem; font-weight: 650; }
h2 { font-size: 1.25rem; font-weight: 640; }
h3 { font-size: 1.05rem; font-weight: 620; }
p { margin: 0 0 .5rem; }
a { color: #b7a6ff; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.up { color: var(--green); } .down { color: var(--red); }

/* Layout */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 1.5rem 1rem; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1b1749 0%, #120f33 100%); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; font-weight: 650; letter-spacing: -.02em; }
.brand-mark { color: #b7a6ff; }
.brand-sub { color: var(--muted); font-size: .85rem; margin: .25rem 0 1.4rem; }
.nav { display: flex; flex-direction: column; gap: .3rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .62rem .8rem; border-radius: 10px;
  color: #c9ccf5; text-decoration: none; font-weight: 500; transition: background .15s ease;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(124, 92, 255, .14); }
.nav a[aria-current="page"] { background: linear-gradient(135deg, #7a4dff, #5230e0); color: #fff; box-shadow: 0 6px 20px rgba(110, 70, 255, .38); }
.side-bottom { margin-top: auto; }
.fine { color: var(--muted); font-size: .76rem; margin: .5rem 0 0; }
.user-card { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 12px; background: rgba(124, 92, 255, .1); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 650; background: linear-gradient(135deg, #7a4dff, #ff4fb8); }
.user-card b { display: block; font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.user-card button { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: .8rem; padding: .25rem; }
.user-card button:hover { color: var(--text); }
.main { padding: 2rem 2.2rem 3rem; max-width: 1360px; width: 100%; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.subtitle { color: var(--muted); margin: .2rem 0 0; }
.head-actions { display: flex; align-items: center; gap: .8rem; }
.updated { color: var(--muted); font-size: .82rem; }
.stack > * + * { margin-top: 1.1rem; }
.grid-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* Cards */
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1.1rem 1.2rem; min-width: 0; }
.card > h2, .card > .card-head { margin-bottom: .7rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.kpi {
  background: var(--solid); border: 1px solid rgba(var(--glow), .55); border-radius: 14px; padding: 1rem 1.1rem;
  box-shadow: 0 0 22px rgba(var(--glow), .16), inset 0 0 18px rgba(var(--glow), .06);
}
.kpi .label { color: var(--muted); font-size: .86rem; }
.kpi .value { font-size: 1.85rem; font-weight: 650; letter-spacing: -.02em; margin-top: .15rem; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: .88rem; font-weight: 550; margin-top: .1rem; font-variant-numeric: tabular-nums; min-height: 1.3em; }
.kpi.green { --glow: 53, 214, 160; } .kpi.red { --glow: 255, 107, 131; } .kpi.amber { --glow: 246, 189, 96; } .kpi.grey { --glow: 130, 140, 190; }
.kpi.grad { border-color: transparent; background: linear-gradient(var(--solid), var(--solid)) padding-box, linear-gradient(135deg, #7c5cff, #ff4fb8) border-box; }
.kpi.small .value { font-size: 1.5rem; }

/* Buttons, inputs */
.btn {
  border-radius: 10px; min-height: 2.4rem; padding: .45rem 1rem; font-weight: 550; cursor: pointer;
  background: rgba(124, 92, 255, .12); border: 1px solid var(--border); transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); background: rgba(124, 92, 255, .24); }
.btn.primary { background: linear-gradient(135deg, #7a4dff, #5230e0); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(110, 70, 255, .35); }
.btn.danger:hover { border-color: var(--red); background: rgba(255, 107, 131, .18); }
.btn.small { min-height: 2rem; padding: .25rem .7rem; font-size: .85rem; }
.btn[disabled] { opacity: .6; cursor: wait; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-size: .86rem; color: var(--muted); }
.field input, .field select, .search {
  background: #100e34; border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; min-height: 2.5rem; width: 100%;
}
.field input:focus, .field select:focus, .search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(124, 92, 255, .25); }
.field .hint { font-size: .78rem; color: var(--muted); }
.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-start; }
.row > * { flex: 1 1 200px; }
.seg { display: inline-flex; gap: .2rem; padding: .2rem; border: 1px solid var(--border); border-radius: 10px; background: rgba(16, 14, 52, .6); }
.seg button { border: 0; background: none; color: var(--muted); padding: .3rem .7rem; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: .86rem; }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: rgba(124, 92, 255, .35); color: #fff; }

/* Tabs */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: .8rem; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: .55rem .9rem; cursor: pointer; font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: #fff; border-bottom-color: var(--accent); }

/* Tables */
.table-wrap { overflow: auto; max-height: 470px; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .55rem .8rem; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #1a1646; color: var(--muted); font-weight: 550; font-size: .82rem; z-index: 1; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { border-top: 1px solid rgba(132, 120, 255, .12); }
tbody tr[data-secid] { cursor: pointer; }
tbody tr[data-secid]:hover, tbody tr[data-secid]:focus-visible { background: rgba(124, 92, 255, .16); }
tbody tr.sel { background: rgba(124, 92, 255, .28); }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); }

/* Badges */
.chip { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-weight: 600; font-size: .82rem; border: 1px solid; }
.chip.buy, .badge.buy { color: var(--green); border-color: rgba(53, 214, 160, .5); background: rgba(53, 214, 160, .12); }
.chip.sell, .badge.sell { color: var(--red); border-color: rgba(255, 107, 131, .5); background: rgba(255, 107, 131, .12); }
.chip.avoid, .badge.avoid { color: var(--amber); border-color: rgba(246, 189, 96, .5); background: rgba(246, 189, 96, .12); }
.chip.wait, .badge.wait { color: #b4b9e8; border-color: rgba(150, 158, 215, .45); background: rgba(150, 158, 215, .12); }
.badge { display: inline-block; padding: .3rem .95rem; border-radius: 999px; font-weight: 600; font-size: 1rem; border: 1px solid; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -110%); background: #1f1b57; border: 1px solid var(--border);
  border-radius: 8px; padding: .35rem .6rem; font-size: .8rem; white-space: nowrap; opacity: 0; transition: opacity .1s; z-index: 3;
}
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: .35rem; }
.donut-wrap { display: grid; place-items: center; gap: .7rem; }
.donut { position: relative; width: 170px; height: 170px; }
.donut .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut .center b { font-size: 1.6rem; font-weight: 650; }
.donut-legend { font-size: .85rem; color: var(--muted); display: grid; gap: .2rem; width: 100%; }
.donut-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .5rem; background: var(--c); }

/* Lists and misc */
.summary-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .35rem; }
.summary-list li { padding-left: 1rem; position: relative; }
.summary-list li::before { content: ""; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.notice { border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; background: rgba(124, 92, 255, .1); }
.notice.warn { border-color: rgba(246, 189, 96, .5); background: rgba(246, 189, 96, .1); }
.notice.error { border-color: rgba(255, 107, 131, .5); background: rgba(255, 107, 131, .1); }
.notice.ok { border-color: rgba(53, 214, 160, .5); background: rgba(53, 214, 160, .1); }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, rgba(124,92,255,.08), rgba(124,92,255,.2), rgba(124,92,255,.08)); background-size: 200% 100%; animation: sh 1.4s infinite; min-height: 1.2rem; }
@keyframes sh { to { background-position: -200% 0; } }
details.card summary { cursor: pointer; font-weight: 600; }
.news-item h3 { margin: .2rem 0 .4rem; font-size: 1.05rem; }
.news-meta { font-size: .8rem; color: var(--muted); }
.divider { height: 1px; background: var(--border); border: 0; margin: 1.6rem 0; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; background: #231e63; border: 1px solid var(--border); padding: .7rem 1rem; border-radius: 12px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; max-width: 340px; }
.toast.show { opacity: 1; transform: none; }
.auth { max-width: 460px; }

/* Mobile */
@media (max-width: 1100px) { .grid-kpi, .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: auto 0 0 0; top: auto; height: auto; z-index: 20; padding: .4rem .6rem calc(.4rem + env(safe-area-inset-bottom)); flex-direction: row; border-right: 0; border-top: 1px solid var(--border); }
  .brand, .brand-sub, .side-bottom { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: .15rem; font-size: .72rem; padding: .4rem .6rem; text-align: center; }
  .main { padding: 1.2rem 1rem 6rem; }
  h1 { font-size: 1.55rem; }
  .grid-3 { grid-template-columns: 1fr; }
  .head-actions .updated { display: none; }
}
@media (max-width: 480px) { .grid-kpi, .grid-4 { grid-template-columns: repeat(2, 1fr); gap: .7rem; } .kpi { padding: .8rem .85rem; } .kpi .value { font-size: 1.35rem; } .kpi.small .value { font-size: 1.2rem; } .kpi .label { font-size: .8rem; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
#view:focus{outline:none}

.kpi .delta:empty { display: none; }
