/* SwingGPT — mobile-first, light/dark via prefers-color-scheme. */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #eef0f4; --line: #dfe3ea;
  --text: #15181e; --muted: #667085; --accent: #2f6fed;
  --pos: #0f8a4f; --neg: #c8342f; --warn: #b7791f;
  --radius: 12px; --gap: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --panel-2: #1f232c; --line: #2a303b;
    --text: #e8ebf1; --muted: #8b93a3; --accent: #6b9bff;
    --pos: #3ecf8e; --neg: #ff6b63; --warn: #f0b44c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); } .neg { color: var(--neg); }

/* chrome */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-size: 18px; letter-spacing: -.02em; } .brand b { color: var(--accent); }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a, .bottomnav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.topnav a.on, .bottomnav a.on { color: var(--text); background: var(--panel-2); }
.topbar form { margin-left: auto; }
.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 10px; font-size: 13px; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.bottomnav a { font-size: 13px; padding: 8px 10px; }
main { max-width: 1100px; margin: 0 auto; padding: 12px 12px 90px; }
@media (min-width: 820px) {
  .topnav { display: flex; } .bottomnav { display: none; } main { padding: 20px 20px 40px; }
}

/* headings & sections */
h1 { font-size: 22px; margin: 4px 0 2px; letter-spacing: -.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px;
  display: flex; align-items: center; gap: 8px; }
h2 .count { background: var(--panel-2); color: var(--text); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: var(--gap); }
.section > h3 { margin: 0 0 10px; font-size: 14px; }
.sub { font-size: 13px; color: var(--muted); }

/* chips / pills */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.chip b { color: var(--text); margin-left: 4px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); } .chip.on b { color: var(--bg); }
.pill { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.st-DISCOVERED { background: #2f6fed22; color: var(--accent); }
.st-ACTIVE { background: #1aa6a622; color: #16a3a3; }
.st-CONTINUE { background: #0f8a4f22; color: var(--pos); }
.st-PROTECT { background: #b7791f26; color: var(--warn); }
.st-EXIT_SIGNAL { background: #c8342f24; color: var(--neg); }
.st-INVALIDATED { background: #c8342f18; color: var(--neg); }
.st-CLOSED, .st-WATCH { background: var(--panel-2); color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }

/* cards */
.cards { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1040px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card:active { transform: scale(.995); }
.card-top { display: flex; align-items: center; gap: 8px; }
.sym { font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.card-top .days { margin-left: auto; font-size: 12px; color: var(--muted); }
.company { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 10px 0 8px; }
.metric { text-align: left; } .metric .k { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.metric .v { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.card .line { font-size: 13px; color: var(--muted); margin-top: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .line b { color: var(--text); font-weight: 600; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* detail page */
.back { font-size: 13px; color: var(--muted); }
.hero { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 4px; }
.hero .sym { font-size: 26px; }
.grid-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 700px) { .grid-stats { grid-template-columns: repeat(6, 1fr); } }
.stat { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.lock .k::after { content: " 🔒"; font-size: 9px; }
.kv { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.prose { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.two { display: grid; gap: var(--gap); } @media (min-width: 820px) { .two { grid-template-columns: 1fr 1fr; } }
.bull { border-left: 3px solid var(--pos); padding-left: 10px; } .bear { border-left: 3px solid var(--neg); padding-left: 10px; }
details { border-top: 1px solid var(--line); } details:first-of-type { border-top: 0; }
summary { cursor: pointer; list-style: none; padding: 10px 2px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 14px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "▸"; color: var(--muted); width: 10px; } details[open] > summary::before { content: "▾"; }
details > .body { padding: 2px 2px 14px 18px; }
.tl-event { font-size: 13px; color: var(--muted); padding: 8px 2px 8px 18px; border-top: 1px solid var(--line); }
.tl-event b { color: var(--text); }
.ev { padding: 10px 0; border-top: 1px solid var(--line); } .ev:first-child { border-top: 0; }
.ev .fact, .ev .interp { font-size: 14px; margin-top: 6px; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; }
.ev .fact { background: var(--panel-2); } .ev .interp { border: 1px dashed var(--line); }
.ev .lbl { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 2px; }
.payload dl { margin: 0; } .payload .kv { font-size: 13px; }
.payload .nested { border-left: 2px solid var(--line); padding-left: 10px; }

/* tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
td { font-family: var(--mono); font-variant-numeric: tabular-nums; } td:first-child { font-family: inherit; }

/* forms */
.toolbar { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
input[type=search], select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font: inherit; }
input[type=search] { flex: 1; min-width: 160px; }
.seg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; } .row .right { text-align: right; font-family: var(--mono); font-size: 13px; }
pre.report { white-space: pre-wrap; word-break: break-word; font: 14px/1.55 var(--mono); margin: 0; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 22px; }
.login-card .brand { font-size: 24px; } .login-card p { margin: 4px 0 18px; }
.login-card input { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; }
.login-card button { width: 100%; margin-top: 10px; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; }
.err { color: var(--neg); font-size: 14px; margin: 0 0 10px; }
.pad-s { padding: 4px 0; }

/* current swings overview table */
.section.flush { padding: 0; overflow: hidden; }
table.swings th.sortable { cursor: pointer; user-select: none; }
table.swings th.sorted { color: var(--text); }
table.swings tr.click { cursor: pointer; }
table.swings tr.click:hover td { background: var(--panel-2); }
table.swings td, table.swings th { padding: 10px 10px; }
table.swings .sticky { position: sticky; left: 0; background: var(--panel); z-index: 1; }
table.swings th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 2; }
table.swings tr.click:hover .sticky { background: var(--panel-2); }
.sym-link { font-weight: 700; color: var(--accent); }

/* charts */
.lw-chart { position: relative; width: 100%; min-width: 0; }
.lw-chart.trade { height: 220px; } .lw-chart.score { height: 140px; }
@media (min-width: 820px) { .lw-chart.trade { height: 320px; } .lw-chart.score { height: 170px; } }
.chart-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 8px;
  font: 12px var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.chart-meta b { color: var(--text); font-weight: 600; } .chart-meta .dim { color: var(--muted); }
.chart-meta .sw { display: inline-block; width: 10px; height: 2px; margin-right: 5px; vertical-align: middle; }
.chart-meta .sw-cont { background: var(--accent); } .chart-meta .sw-cur { background: var(--warn); }
.chart-meta .sw-init { border-top: 1px dashed var(--muted); height: 0; }
.chart-meta .credit { margin-left: auto; font-size: 10px; color: var(--muted); opacity: .7; }

/* never let long content push the page wider than the screen */
main, .section, .two > *, .cards > * { min-width: 0; }
.grid-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 700px) { .grid-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.two { grid-template-columns: minmax(0, 1fr); } @media (min-width: 820px) { .two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.kv { grid-template-columns: minmax(96px, 30%) minmax(0, 1fr); }
.kv dd, .prose, .card .line, p { overflow-wrap: anywhere; }
html, body { overflow-x: hidden; }
