:root {
  --bg: #0a0d13; --panel: #10141c; --panel2: #151a24; --border: #1f2633; --border2: #2a3242;
  --text: #d9dee8; --muted: #7c8597; --up: #22c38e; --down: #f0485c; --warn: #f5a524; --accent: #f5a524;
  --btc: #f7931a; --eth: #4c8dff; --oth: #3a4252;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--border2); border-radius: 6px; padding: 6px 8px; }
.muted { color: var(--muted); } .small { font-size: 11px; }
.up { color: var(--up); } .dn { color: var(--down); } .warn { color: var(--warn); }
.sp { flex: 1; }
[hidden] { display: none !important; }

/* header */
.hdr { display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.back-link { color: var(--muted); font-size: 12px; white-space: nowrap; }
.back-link:hover { color: var(--text); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .06em; font-size: 14px; }
.brand b { font-weight: 800; color: var(--accent); }
.logo { width: 18px; height: 18px; border-radius: 5px; background: conic-gradient(from 200deg, var(--accent), #f0485c, var(--accent)); }
.nav { flex: 1; display: flex; justify-content: center; gap: 36px; }
.nav a { color: var(--muted); font-weight: 600; letter-spacing: .08em; font-size: 13px; padding: 16px 0; border-bottom: 2px solid transparent; }
.nav a.on { color: var(--text); border-color: var(--accent); }
.hdr-right { display: flex; align-items: center; gap: 12px; }
.icon { background: none; border: 0; color: var(--muted); padding: 4px; border-radius: 6px; display: inline-flex; align-items: center; gap: 3px; }
.icon:hover { color: var(--text); background: var(--panel2); }
.icon.on { color: var(--accent); }
#log-count { font-size: 10px; color: var(--accent); font-family: var(--mono); }
.logwrap { position: relative; }
.live { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live.on { color: var(--up); } .live.on::before { background: var(--up); box-shadow: 0 0 6px var(--up); }

.banner { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: rgba(240,72,92,.12); border-bottom: 1px solid rgba(240,72,92,.4); color: #ffc9cf; }
.btn { background: var(--accent); color: #111; border: 0; border-radius: 6px; padding: 6px 12px; font-weight: 600; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--border2); font-weight: 500; }

main { padding: 12px 12px 4px; min-height: calc(100vh - 100px); }
.foot { color: var(--muted); font-size: 11px; padding: 8px 16px 16px; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.segs { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg { background: none; border: 0; color: var(--muted); padding: 5px 10px; border-radius: 6px; font-size: 12px; }
.seg:hover { color: var(--text); }
.seg.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border2); }
.search { width: 160px; background: var(--panel); border-color: var(--border); }
.dd { position: relative; }
.dd-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; }
.dd-btn small { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.dd-btn b { font-weight: 600; }
.caret { color: var(--muted); font-size: 10px; }
.dd-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 260px; background: var(--panel); border: 1px solid var(--border2); border-radius: 10px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.dd-item { display: flex; gap: 8px; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 7px 8px; }
.dd-item:hover { background: var(--panel2); }
.dd-item b { display: block; font-weight: 600; }
.dd-item small { display: block; color: var(--muted); font-size: 11px; }
.dd-item .chk { width: 14px; color: var(--accent); flex: none; }
.statusline { display: flex; align-items: center; gap: 12px; color: var(--text); font-size: 12px; margin: 2px 2px 10px; }
.statusline .bar { width: 160px; height: 4px; background: var(--panel2); border-radius: 2px; overflow: hidden; }
.statusline .bar i { display: block; height: 100%; background: var(--accent); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(390px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.grid.empty { background: none; border: 0; }
.empty-msg { padding: 60px; text-align: center; color: var(--muted); }
.card { background: var(--bg); display: flex; flex-direction: column; height: 316px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 2px; font-size: 12px; white-space: nowrap; }
.card-head .sym { font-weight: 700; letter-spacing: .02em; }
.card-head .sym:hover { color: var(--accent); }
.lbl { font-weight: 600; font-size: 11px; letter-spacing: .03em; overflow: hidden; text-overflow: ellipsis; }
.lbl.up2 { color: #3ee0a8; } .lbl.up { color: var(--up); } .lbl.neu { color: var(--muted); } .lbl.dn { color: var(--down); } .lbl.dn2 { color: #ff6b7d; } .lbl.warn { color: var(--warn); }
.chg { font-family: var(--mono); font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.up { background: var(--up); } .dot.dn { background: var(--down); }
.card-chart { flex: 1; min-height: 0; position: relative; }
.card-chart[data-error]::after, .modal-chart[data-error]::after { content: attr(data-error); position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* popover */
.popover { position: absolute; z-index: 40; width: 280px; background: var(--panel); border: 1px solid var(--border2); border-radius: 10px; padding: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.55); }
.popover.log { right: 0; top: 34px; width: 340px; max-height: 420px; overflow: auto; }
.pop-title { font-weight: 700; margin-bottom: 8px; }
.pop-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.pop-input { flex: 1; min-width: 0; }
.pop-list { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.pop-item { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 12px; }
.pop-note { color: var(--muted); font-size: 11px; margin-top: 8px; }
.log-row { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.modal-box { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--border2); border-radius: 12px; padding: 14px; max-height: 92vh; overflow: auto; }
.modal-box.wide { width: min(1200px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.modal-title a { font-weight: 800; font-size: 15px; }
.modal-chart { height: min(70vh, 640px); position: relative; }
#settings form label { display: block; margin: 12px 0; font-weight: 600; }
#settings form label small { display: block; font-weight: 400; color: var(--muted); margin: 2px 0 6px; }
#settings form input[type=number], #settings form input[type=text], #settings form select { width: 100%; }
#settings .row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
#settings .row.end { justify-content: flex-end; }
details summary { cursor: pointer; color: var(--muted); margin: 10px 0; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--panel2); border: 1px solid var(--border2); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; max-width: 360px; box-shadow: 0 10px 24px rgba(0,0,0,.5); transition: opacity .4s, transform .4s; }
.toast.up { border-left-color: var(--up); } .toast.dn { border-left-color: var(--down); } .toast.warn { border-left-color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* densities */
.view-title { display: flex; align-items: baseline; gap: 10px; }
.view-title b { letter-spacing: .08em; }
.counts { font-size: 12px; font-family: var(--mono); }
.filters { gap: 14px; }
.fgroup { display: inline-flex; align-items: center; gap: 6px; }
.fgroup small { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.table-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
.dtable { width: 100%; border-collapse: collapse; font-size: 12px; }
.dtable th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .06em; text-align: left; padding: 9px 12px; cursor: pointer; white-space: nowrap; border-bottom: 1px solid var(--border); }
.dtable th.sorted { color: var(--text); }
.dtable td { padding: 7px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dtable tr:hover td { background: var(--panel); }
.dtable .num { text-align: right; font-family: var(--mono); }
.dtable th.num { text-align: right; }
.chip { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.chip.up { background: rgba(34,195,142,.12); } .chip.dn { background: rgba(240,72,92,.12); }
.size { display: flex; justify-content: flex-end; gap: 4px; align-items: baseline; }
.sizebar { height: 3px; background: var(--panel2); border-radius: 2px; margin-top: 3px; display: flex; justify-content: flex-start; }
.sizebar i { display: block; height: 100%; border-radius: 2px; }
.sizebar.up i { background: var(--up); } .sizebar.dn i { background: var(--down); }
.link { background: none; border: 0; color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.link:hover { color: var(--accent); }
.empty-row { text-align: center; color: var(--muted); padding: 40px !important; }

/* market */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.tile { background: var(--bg); padding: 12px 14px; min-width: 0; }
.tile small, .panel-head small { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.big { font-size: 20px; font-weight: 700; font-family: var(--mono); display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.delta { font-size: 12px; }
.split { display: flex; justify-content: space-between; font-family: var(--mono); font-weight: 600; margin: 6px 0; }
.breadth { display: flex; height: 6px; border-radius: 3px; overflow: hidden; gap: 2px; }
.breadth i { display: block; height: 100%; }
.breadth i.up { background: var(--up); } .breadth i.dn { background: var(--down); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.panel { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head b { font-size: 12px; letter-spacing: .06em; }
.fg-val { display: flex; align-items: baseline; gap: 10px; font-weight: 700; margin-bottom: 10px; }
.fg-val .num { font-size: 28px; font-family: var(--mono); }
.fg-scale { position: relative; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--down), #6b2a33 40%, #2a3242 50%, #1d5e49 60%, var(--up)); }
.needle { position: absolute; top: -4px; width: 3px; height: 14px; background: #fff; border-radius: 2px; transform: translateX(-50%); }
.fg-ends { display: flex; justify-content: space-between; margin: 4px 0 10px; }
.fg-ends small { color: var(--muted); font-size: 10px; }
.comp { display: grid; grid-template-columns: 110px 1fr auto 52px; align-items: center; gap: 10px; padding: 4px 0; font-size: 12px; }
.comp b { text-align: right; font-family: var(--mono); }
.comp-bar { height: 4px; background: var(--panel2); border-radius: 2px; overflow: hidden; }
.comp-bar i { display: block; height: 100%; }
.comp-bar i.up { background: var(--up); } .comp-bar i.dn { background: var(--down); }
.comp-bar i.btc, .stack i.btc, .sw.btc { background: var(--btc); } .comp-bar i.eth, .stack i.eth, .sw.eth { background: var(--eth); } .comp-bar i.oth, .sw.oth { background: var(--oth); }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--oth); margin-bottom: 10px; gap: 2px; }
.stack i { display: block; height: 100%; }
.mrow { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; border-top: 1px solid var(--border); padding: 7px 2px; text-align: left; }
.mrow:hover { background: var(--panel); }
.mrow > .muted:first-child { width: 18px; font-family: var(--mono); }
.mval { width: 130px; text-align: right; font-family: var(--mono); font-weight: 600; }
.mbar { height: 3px; background: var(--panel2); border-radius: 2px; margin-top: 3px; display: flex; justify-content: flex-end; }
.mbar i { display: block; height: 100%; border-radius: 2px; background: currentColor; opacity: .8; }

/* swing */
.regime { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border2); cursor: help; }
.regime.up { color: var(--up); border-color: rgba(34,195,142,.4); } .regime.dn { color: var(--down); border-color: rgba(240,72,92,.4); } .regime.warn { color: var(--warn); border-color: rgba(245,165,36,.4); }
.num-in { width: 80px; padding: 5px 6px; }
.dtable.swing td { vertical-align: top; }
.dtable.swing td:nth-child(3) { min-width: 300px; white-space: normal; }
.dtable.swing .why { white-space: normal; max-width: 380px; margin-top: 2px; line-height: 1.3; }
.chip.warnc { background: rgba(245,165,36,.14); color: var(--warn); } .chip.neu { background: var(--panel2); color: var(--muted); }
.tdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 3px; }
.tdot.up { background: var(--up); } .tdot.dn { background: #3a4252; }
.score { display: inline-block; min-width: 30px; text-align: center; padding: 1px 6px; border-radius: 4px; font-weight: 700; background: var(--panel2); }
.score.s4 { background: rgba(34,195,142,.2); color: #3ee0a8; } .score.s3 { background: rgba(34,195,142,.12); color: var(--up); } .score.s2 { color: var(--warn); }
.panel.calc, .panel.howto { margin-top: 10px; }
.calc-out { margin: 8px 0; display: grid; gap: 4px; }
.howto ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.howto b { color: var(--text); }

@media (max-width: 900px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .two, .three { grid-template-columns: 1fr; }
  .nav { gap: 16px; }
  .hdr-right #hdr-weight { display: none; }
  .grid { grid-template-columns: 1fr; }
}
