:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1d2638;
  --line: #2a3550;
  --text: #e8ecf5;
  --muted: #94a0ba;
  --accent: #4f8cff;
  --green: #34d399;
  --red: #f87171;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.fineprint { color: var(--muted); font-size: 12px; }
.error { color: var(--red); min-height: 18px; }
h2 { font-size: 16px; margin: 22px 4px 10px; }
h3 { font-size: 14px; margin: 20px 4px 8px; color: var(--muted); }

.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

/* LOGIN */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 340px; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
#pin { font-size: 28px; text-align: center; letter-spacing: 12px; padding: 12px; }

/* TOPBAR + TABS */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(15,20,32,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-actions { display: flex; gap: 8px; }
.tabs { position: sticky; top: 49px; z-index: 4; display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.tabs button { white-space: nowrap; background: var(--panel); color: var(--muted); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; }
.tabs button.active { color: #fff; background: var(--accent); border-color: var(--accent); }
main { padding: 8px 12px 60px; max-width: 760px; margin: 0 auto; }

/* BUTTONS + INPUTS */
button { cursor: pointer; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 10px 14px; font-size: 14px; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); border-color: var(--line); padding: 7px 11px; }
input, select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px; font-size: 15px; }
input:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* STATS */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .v.big { font-size: 24px; }

/* TABLES */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
thead th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:last-child td { border-bottom: none; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.tag { font-size: 11px; color: var(--muted); }

/* FORMS */
.card-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.card-form .hint { color: var(--muted); font-size: 12px; margin: 0; }
.msg { min-height: 18px; font-size: 13px; margin: 0; }
.msg.ok { color: var(--green); }
.msg.bad { color: var(--red); }

/* SUGGESTIONS */
.suggestions { display: flex; flex-direction: column; gap: 0; max-height: 240px; overflow-y: auto; }
.suggestions .item { padding: 10px 12px; border: 1px solid var(--line); border-top: none; cursor: pointer; background: var(--panel-2); }
.suggestions .item:first-child { border-top: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.suggestions .item:last-child { border-radius: 0 0 10px 10px; }
.suggestions .item:hover { background: var(--line); }
.suggestions .item .sym { font-weight: 700; }
.suggestions .item .meta { color: var(--muted); font-size: 12px; }

/* EDIT MODE */
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-head h3 { margin: 20px 0 8px; }
button.mini { padding: 5px 9px; font-size: 12px; border-radius: 8px; margin-left: 6px; }
button.mini:first-child { margin-left: 0; }
button.mini.del { background: transparent; color: var(--red); border-color: var(--red); }
td.rowact { white-space: nowrap; }

/* CHARTS */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.chart-card h3 { margin: 0 0 10px; color: var(--text); font-size: 14px; text-align: center; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; align-items: stretch; }
.chart-grid .chart-card { margin-top: 0; display: flex; flex-direction: column; }
.chart-box { position: relative; height: 240px; flex: 1 1 auto; min-height: 220px; }
.chart-box.nav { height: 300px; }
.chart-box.tall { height: 320px; }
#risk-stats { margin-top: 6px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.riskcol .v { font-size: 20px; }
.riskcol .k2 { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-top: 10px; }
.riskcol .v2 { font-size: 16px; font-weight: 700; margin-top: 2px; }

/* TOAST */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 999px; z-index: 20; box-shadow: 0 8px 30px rgba(0,0,0,.4); }

@media (max-width: 480px) {
  .stat .v { font-size: 20px; }
}
