:root {
  --bg: #0b0e14; --panel: #11161f; --panel2: #151b26; --line: #1f2735; --line2: #2a3446;
  --text: #d7dde7; --muted: #7d8799; --faint: #566074; --accent: #4c8dff; --accent2: #2f6fe0;
  --up: #16c784; --down: #ea3943; --warn: #f5a524; --violet: #8b7cf6;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.num, td.num, .mono { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 14px; margin: 0; font-weight: 600; color: #e6ebf3; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* shell */
.shell { display: grid; align-items: start; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #0d1118; border-right: 1px solid var(--line); padding: 16px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand.big { font-size: 24px; padding: 0 0 6px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--violet)); display: inline-block; box-shadow: 0 0 0 3px rgba(76,141,255,.12); }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
nav a.active { background: var(--panel2); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.ico { width: 18px; text-align: center; opacity: .8; }
.sidebar-foot { margin-top: auto; padding: 10px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: rgba(11,14,20,.92); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px); }
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; background: var(--panel); }
.chip.ok { color: var(--up); border-color: rgba(22,199,132,.35); }
.chip.bad { color: var(--down); border-color: rgba(234,57,67,.45); background: rgba(234,57,67,.08); }
.chip.warn { color: var(--warn); border-color: rgba(245,165,36,.4); }
.chip.live { color: #fff; background: var(--down); border-color: var(--down); font-weight: 700; }
.view { padding: 22px; max-width: 1500px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* panels & grids */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.tile .sym { font-weight: 600; font-size: 13px; } .tile .nm { color: var(--muted); font-size: 11px; }
.tile .px { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.empty { color: var(--muted); padding: 22px; text-align: center; border: 1px dashed var(--line2); border-radius: 8px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
td.wrap { white-space: normal; }

/* badges & bars */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 5px; letter-spacing: .03em; }
.badge.buy { background: rgba(22,199,132,.14); color: var(--up); } .badge.sell { background: rgba(234,57,67,.14); color: var(--down); }
.badge.hold { background: rgba(125,135,153,.18); color: var(--text); } .badge.info { background: rgba(76,141,255,.14); color: var(--accent); }
.badge.warn { background: rgba(245,165,36,.14); color: var(--warn); } .badge.paper { background: rgba(139,124,246,.16); color: var(--violet); }
.badge.live { background: var(--down); color: #fff; }
.scorebar { display: inline-flex; align-items: center; gap: 8px; }
.scorebar .track { display: block; width: 64px; height: 6px; background: var(--line2); border-radius: 3px; overflow: hidden; }
.scorebar .fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.comp { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; margin: 6px 0; font-size: 12.5px; }
.comp .track { display: block; height: 7px; background: var(--line2); border-radius: 4px; overflow: hidden; }
.comp .fill { display: block; height: 100%; border-radius: 4px; }
.gauge { height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--down), #6b7588 50%, var(--up)); position: relative; margin: 14px 0 6px; }
.gauge .needle { position: absolute; top: -5px; width: 4px; height: 20px; background: #fff; border-radius: 2px; transform: translateX(-2px); box-shadow: 0 0 0 3px rgba(0,0,0,.4); }

/* lists */
.list { display: flex; flex-direction: column; }
.item { padding: 9px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
ul.plain { margin: 0; padding-left: 18px; } ul.plain li { margin: 3px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.levels { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.levels .tile .px { font-size: 15px; }
.explain { line-height: 1.6; color: #c8cfdb; }
.callout { border: 1px solid var(--line2); background: var(--panel2); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; }
.callout.warn { border-color: rgba(245,165,36,.4); background: rgba(245,165,36,.06); }
.callout.bad { border-color: rgba(234,57,67,.45); background: rgba(234,57,67,.07); }
.timeline .item { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 11.5px; margin-top: 4px; flex-wrap: wrap; }
.spark { width: 90px; height: 26px; }

/* forms */
input, select, textarea { background: #0d121a; color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; font: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(76,141,255,.15); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 14px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 550; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { background: rgba(234,57,67,.14); border-color: rgba(234,57,67,.5); color: #ff8088; }
.btn.danger.solid { background: var(--down); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 8px 12px; font: inherit; font-weight: 550; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: #fff; border-color: var(--accent); }
.error { color: var(--down); min-height: 18px; font-size: 13px; }

/* chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 12px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 12px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--accent2); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg ul { margin: 4px 0; padding-left: 18px; }
.chat form { display: flex; gap: 10px; } .chat form input { flex: 1; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

/* login, modal, toast */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 0%, rgba(76,141,255,.12), transparent), var(--bg); }
.login-card { width: min(380px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 20px; max-height: 90vh; overflow: auto; }
.modal-card h2 { margin-bottom: 10px; font-size: 16px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel2); border: 1px solid var(--line2); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; max-width: 360px; box-shadow: 0 8px 24px rgba(0,0,0,.4); font-size: 13px; }
.toast.bad { border-left-color: var(--down); } .toast.good { border-left-color: var(--up); }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 4px; z-index: 20; border-right: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .sidebar-foot { display: none; }
  nav { display: flex; width: 100%; overflow-x: auto; }
  nav a { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 8px; min-width: 64px; }
  .view { padding: 14px 12px 90px; }
  .g2, .g3, .g-main { grid-template-columns: 1fr; }
  .g4, .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head .stat { text-align: left !important; }
  .topbar { padding: 8px 12px; flex-wrap: wrap; }
  .search { max-width: none; order: 3; flex-basis: 100%; }
  .chat { height: calc(100vh - 230px); }
  .timeline .item { grid-template-columns: 1fr; gap: 2px; }
}
