/* Liquidity Radar Pro — mobile-first, light default, dark via [data-theme=dark] */
:root {
  --bg: #f5f7fb; --card: #ffffff; --card2: #f0f3f8; --line: #e3e8f0;
  --text: #0f172a; --muted: #64748b; --accent: #2563eb; --accent-ink: #fff;
  --up: #059669; --up-bg: #e7f7f0; --down: #dc2626; --down-bg: #fdecec;
  --warn: #b45309; --warn-bg: #fff4e0; --wait: #475569; --wait-bg: #eef2f7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 16px; --tabh: 64px;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #0b1020; --card: #121a2e; --card2: #18223a; --line: #24304a;
  --text: #e8edf7; --muted: #8b98b3; --accent: #4f8cff;
  --up: #22c55e; --up-bg: #0f2a1d; --down: #f05252; --down-bg: #2e1517;
  --warn: #f5b041; --warn-bg: #2d230f; --wait: #9aa7c0; --wait-bg: #1a2338;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 12px);
}
button { font: inherit; color: inherit; }
b, .price-big, .lv b, .metrics b, .sizing b, .kv-grid b, .tbl td { font-variant-numeric: tabular-nums; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.logo { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 200deg, var(--accent), #22c55e, var(--accent)); }
.pills { display: flex; gap: 6px; margin-left: auto; }
.pill { font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 99px; background: var(--wait-bg); color: var(--wait); white-space: nowrap; }
.pill.live { background: var(--up-bg); color: var(--up); }
.pill.stale, .pill.reconnecting, .pill.connecting { background: var(--warn-bg); color: var(--warn); }
.pill.off, .pill.offline, .pill.error { background: var(--down-bg); color: var(--down); }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; width: 36px; height: 36px; font-size: 18px; }

main { max-width: 640px; margin: 0 auto; padding: 10px 10px 0; }
.view { display: none; }
.view.active { display: block; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sub { font-size: 12px; font-weight: 700; margin: 8px 0 4px; color: var(--muted); }
.sub.good { color: var(--up); } .sub.bad { color: var(--down); }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.matlab { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.warn-line { margin-top: 8px; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); }
.disclaimer { font-size: 11px; color: var(--muted); padding: 4px 6px 12px; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--card2); }
.tag.up { background: var(--up-bg); color: var(--up); } .tag.down { background: var(--down-bg); color: var(--down); }
.up { color: var(--up); } .down { color: var(--down); } .warn { color: var(--warn); }

/* price */
.price-big { font-size: 40px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0; }
.kv-row { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; }
.kv-row b { color: var(--text); font-weight: 700; }

/* decision */
.decision { border-width: 2px; }
.decision[data-dir="long"] { border-color: var(--up); }
.decision[data-dir="short"] { border-color: var(--down); }
.dir-word { font-size: 44px; font-weight: 900; letter-spacing: .02em; line-height: 1; margin-top: 8px; color: var(--wait); }
.decision[data-dir="long"] .dir-word { color: var(--up); }
.decision[data-dir="short"] .dir-word { color: var(--down); }
.dir-sub { font-size: 14px; color: var(--muted); margin: 4px 0 10px; }
.lock-chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.lock-chip.on { background: var(--accent); color: var(--accent-ink); }
.strength { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--card2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.decision[data-dir="long"] .bar i { background: var(--up); }
.decision[data-dir="short"] .bar i { background: var(--down); }

.levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 12px; }
.lv { border: 1px solid var(--line); background: var(--card2); border-radius: 12px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lv i { font-style: normal; font-size: 11px; font-weight: 700; color: var(--muted); }
.lv b { font-size: 13px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.lv s { text-decoration: none; font-size: 10px; color: var(--muted); }
.lv.sl b { color: var(--down); } .lv.tp b { color: var(--up); }
.metrics, .sizing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.sizing { grid-template-columns: repeat(4, 1fr); }
.metrics div, .sizing div, .kv-grid div, .stats-grid div { background: var(--card2); border-radius: 12px; padding: 8px; min-width: 0; }
.metrics i, .sizing i, .kv-grid i, .stats-grid i { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.metrics b, .sizing b { font-size: 14px; font-weight: 800; }
@media (max-width: 380px) {
  .levels { grid-template-columns: repeat(3, 1fr); }
  .sizing { grid-template-columns: repeat(2, 1fr); }
  .price-big { font-size: 34px; }
}

.btn-primary { width: 100%; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: 14px; margin-top: 12px; font-size: 17px; }
.btn-primary.long { background: var(--up); } .btn-primary.short { background: var(--down); }
.btn-primary:disabled { background: var(--card2); color: var(--muted); }
.btn-small { border: 1px solid var(--line); background: var(--card2); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 700; }
.btn-small.danger { color: var(--down); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reasons { margin: 0; padding-left: 16px; font-size: 13px; }
.reasons li { margin-bottom: 4px; }

/* chart */
.tf-row, .chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card2); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 700; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chart-box { position: relative; height: 58vh; min-height: 300px; margin: 10px 0 6px; border-radius: 12px; overflow: hidden; background: var(--card2); }
.chart-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; color: var(--muted); font-size: 14px; z-index: 2; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; color: var(--muted); }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.sw.entry { background: var(--accent); } .sw.sl { background: var(--down); } .sw.tp { background: var(--up); }

/* paper */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.stats-grid b { font-size: 16px; font-weight: 800; }
.table-wrap { overflow-x: auto; margin-top: 6px; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.tbl th { text-align: left; color: var(--muted); font-weight: 700; padding: 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid var(--line); }
.pnl-big { font-size: 34px; font-weight: 900; }

/* radar */
.imb { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.imb-bar { flex: 1; height: 12px; border-radius: 99px; background: var(--down-bg); overflow: hidden; }
.imb-bar i { display: block; height: 100%; width: 50%; background: var(--up); margin-left: auto; transition: width .3s; }
.walls .wall { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.kv-grid b { font-size: 16px; font-weight: 800; display: block; }
.kv-grid s { text-decoration: none; font-size: 11px; color: var(--muted); }
.spark { width: 100%; height: 70px; display: block; margin: 8px 0; }
.mini-list .it { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.mini-list .it:last-child { border-bottom: 0; }

/* admin */
.field { padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field label { display: block; font-weight: 700; font-size: 14px; }
.field .matlab { margin: 2px 0 6px; }
.field input[type=number], .field input[type=url], .field input[type=text], .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); color: var(--text); font: inherit; font-size: 16px;
}
.field .inline { display: flex; gap: 6px; }
.field .err { color: var(--down); font-size: 12px; margin-top: 4px; }
.field .ok { color: var(--up); font-size: 12px; margin-top: 4px; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 99px; border: 0; background: var(--line); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 23px; }

/* tabbar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 700; color: var(--muted); }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 12px); transform: translateX(-50%) translateY(20px);
  max-width: 92vw; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 30;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--up); color: #fff; } .toast.bad { background: var(--down); color: #fff; } .toast.warn { background: var(--warn); color: #fff; }
.info-chips { margin-top: 8px; }
.ichip { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; background: var(--card2); color: var(--muted); white-space: nowrap; }
.ichip.up { background: var(--up-bg); color: var(--up); } .ichip.down { background: var(--down-bg); color: var(--down); } .ichip.warn { background: var(--warn-bg); color: var(--warn); }
.warn-line.bad { background: var(--down-bg); color: var(--down); font-weight: 700; }
#view-paper > .warn-line { margin: 0 0 10px; }
#btEquity { width: 100%; margin-top: 8px; }

/* v0.3 journal / presets / alerts */
.field textarea { min-height: 70px; resize: vertical; }
.tbl td.note { white-space: normal; color: var(--muted); font-size: 11px; max-width: 240px; }
.btn-edit { border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 8px; padding: 2px 8px; font: inherit; font-size: 12px; }
.diff-list { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
.diff-list li { margin: 2px 0; }

/* 6 tabs: keep the bar usable on small phones */
.tab { min-width: 0; padding: 0 1px; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 380px) { .tab { font-size: 10px; } .tab svg { width: 21px; height: 21px; } }
@media (max-width: 330px) { .tab { font-size: 9px; } .tab svg { width: 19px; height: 19px; } }

/* Token Unlock */
.ul-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ul-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; text-align: left; width: 100%; border: 1px solid var(--line); background: var(--card2); border-radius: 12px; padding: 8px 10px; color: var(--text); font: inherit; }
.ul-row.short { border-left: 4px solid var(--down); } .ul-row.wait { border-left: 4px solid var(--warn); } .ul-row.avoid { opacity: .75; }
.ul-row .ul-top { font-weight: 800; font-size: 15px; } .ul-row .ul-cd { font-weight: 700; font-size: 13px; text-align: right; }
.ul-row .ul-sub { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.ul-act { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 99px; margin-left: 6px; }
.ul-act.SHORT { background: var(--down-bg); color: var(--down); } .ul-act.WAIT { background: var(--warn-bg); color: var(--warn); } .ul-act.AVOID { background: var(--wait-bg); color: var(--wait); }
.ul-trade { background: var(--card2); border-radius: 12px; padding: 8px 10px; margin-top: 6px; font-size: 13px; }
