/* marketwatcher.ai - one stylesheet for every page. Light and dark follow the device. No outside fonts or files. */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1b1f24; --muted: #66707a; --line: #dde1e6;
  --accent: #0f6b45; --up: #127a3e; --down: #b42318; --warn-bg: #fff4e5; --warn: #8a4b00;
  --sample-bg: #f3e8ff; --sample: #6b21a8; --on-accent: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #191d22; --text: #e6e9ec; --muted: #9aa4ae; --line: #2b3138;
    --accent: #4cc38a; --up: #4cc38a; --down: #ff7a6b; --warn-bg: #3a2a12; --warn: #ffc069;
    --sample-bg: #2e1f42; --sample: #d8b4fe; --on-accent: #0b1f14;
  }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; color: var(--muted); font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 2rem; }
footer { max-width: 1100px; margin: 0 auto; padding: 0 16px 2rem; color: var(--muted); font-size: .8rem; }
.muted { color: var(--muted); font-size: .85rem; }

/* top bar */
.bar { display: flex; align-items: center; gap: 1rem; padding: .6rem 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar .brand { font-weight: 700; color: var(--text); }
.bar nav { display: flex; gap: .9rem; flex: 1; flex-wrap: wrap; }
.bar nav a { color: var(--muted); }
.bar nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.bar .out { margin: 0; }
button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 6px; padding: .35rem .8rem; }
button:hover { border-color: var(--muted); }

/* tables */
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; }
.list th, .list td { padding: .45rem .7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.list th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.list tr:last-child td { border-bottom: 0; }
.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.list .sym a { font-weight: 600; }
.list .name { color: var(--muted); white-space: normal; }
/* Sortable column titles and the filter bar (Symbols page, assets/symbols.js). */
.list th button.sort { all: unset; cursor: pointer; text-transform: inherit; letter-spacing: inherit; font: inherit;
  color: inherit; display: inline-flex; align-items: center; gap: .25rem; }
.list th button.sort:hover, .list th[aria-sort="ascending"] button.sort, .list th[aria-sort="descending"] button.sort { color: var(--text); }
.list th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.list th[aria-sort="ascending"] .arrow::after { content: "\25B2"; font-size: .65rem; }
.list th[aria-sort="descending"] .arrow::after { content: "\25BC"; font-size: .65rem; }
.list th.num button.sort { flex-direction: row-reverse; }
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0 0 1rem; }
.filterbar input, .filterbar select { font: inherit; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--text); }
.filterbar input { flex: 1 1 14rem; max-width: 22rem; }
.filterbar .count { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
h2 .count { font-weight: 400; font-size: .85em; margin-left: .3rem; }
.group p.about { margin: -.25rem 0 .5rem; font-size: .85rem; }
/* The public placeholder demo (demo/index.php). */
main.demo { max-width: 52rem; }
.demo-banner { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem .9rem; font-weight: 600; margin: 0 0 1rem; }
.demo-summary { color: var(--muted); max-width: 40rem; }
.demo-figure { margin: 1rem 0; }
.demo-figure img, .demo-figure video { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.demo-figure figcaption { font-size: .85rem; color: var(--muted); margin-top: .4rem; }
@media (max-width: 640px) { .list .wide { display: none; } }
.up { color: var(--up); }
.down { color: var(--down); }
.tablewrap { overflow-x: auto; }
.list .sub { display: none; font-size: .75rem; color: var(--muted); font-weight: 400; }
@media (max-width: 640px) {
  .list .name, .list .when, .list .state { display: none; }
  .list .sub { display: block; }
  .list th, .list td { padding: .4rem .5rem; }
  .bar { gap: .4rem 1rem; }
  .bar .brand { flex: 1; }
  .bar nav { order: 3; flex-basis: 100%; }
}

/* badges */
.badge { display: inline-block; font-size: .7rem; font-weight: 600; padding: .05rem .4rem; border-radius: 4px;
  vertical-align: middle; background: var(--line); color: var(--muted); }
.badge.sample { background: var(--sample-bg); color: var(--sample); }
.badge.fill, .badge.partial { background: var(--warn-bg); color: var(--warn); }
.badge.off, .badge.failed { background: var(--down); color: #fff; }
.badge.ok { background: var(--up); color: #fff; }

/* sign-in */
.signin { max-width: 340px; margin: 12vh auto 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 1.5rem; }
.signin h1 { text-align: center; }
.signin form { display: flex; flex-direction: column; gap: .4rem; }
.signin input { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text); }
.signin button { margin-top: .8rem; background: var(--accent); color: var(--on-accent); border-color: var(--accent); padding: .55rem; }
.error { color: var(--down); margin: .4rem 0 0; font-size: .9rem; }
.empty { color: var(--muted); }

/* data health */
.cards { display: flex; gap: .8rem; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; min-width: 180px; }
.card.bad { border-color: var(--down); }
.card .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.card .v { font-size: 1.05rem; margin-top: .15rem; }
.card .note { color: var(--down); font-size: .85rem; margin-top: .3rem; }
.list td.gaps, .list td.msg { white-space: normal; font-size: .85rem; }
.list td.msg { color: var(--muted); max-width: 360px; }

/* charts */
:root { --shade: rgba(120, 120, 140, .09); --s1: #2563eb; --s2: #d97706; --s3: #16a34a; --s4: #9333ea; }
@media (prefers-color-scheme: dark) { :root { --shade: rgba(160, 170, 190, .08); --s1: #60a5fa; --s2: #fbbf24; --s3: #4ade80; --s4: #c084fc; } }
.chart-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.chart-head h1 { margin: 0 0 .25rem; }
.chart-head h1 .muted { font-size: 1rem; font-weight: 400; }
.quote { display: flex; gap: .4rem .8rem; align-items: baseline; flex-wrap: wrap; }
.quote .price { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ranges { display: flex; gap: .25rem; }
.ranges button { padding: .3rem .6rem; font-size: .85rem; }
.ranges button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chart-info { min-height: 1.4rem; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-info b { color: var(--text); font-weight: 600; }
.chart-info .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: .5rem; }
.key.k0 { background: var(--s1); } .key.k1 { background: var(--s2); } .key.k2 { background: var(--s3); } .key.k3 { background: var(--s4); }
.chart { position: relative; height: 460px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart.loading { opacity: .55; }
.chart-canvas { display: block; cursor: crosshair; }
@media (max-width: 640px) { .chart { height: 340px; } .quote .price { font-size: 1.25rem; } }

/* reports */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .9rem; }
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.reports { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 1rem; align-items: start; }
.report-list ul { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; }
.report-list li a { display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem; padding: .5rem .7rem;
  border-bottom: 1px solid var(--line); color: var(--text); }
.report-list li:last-child a { border-bottom: 0; }
.report-list li a:hover { text-decoration: none; background: var(--bg); }
.report-list li.on a { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.report-list .day { color: var(--muted); font-size: .85rem; }
.report-list .title { grid-column: 1 / -1; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { margin-top: .5rem; }
.report { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.2rem; min-width: 0; }
.report h2 { color: var(--text); font-size: 1.1rem; margin: .4rem 0 .2rem; }
.report pre { white-space: pre-wrap; word-wrap: break-word; font: .9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 1rem 0 0; }
.badge.k-daily { background: var(--line); color: var(--text); }
.badge.k-weekly { background: var(--s1); color: #fff; }
.badge.k-alert { background: var(--warn-bg); color: var(--warn); }
.badge.k-health { background: var(--down); color: #fff; }
@media (max-width: 760px) {
  .reports { grid-template-columns: 1fr; }
  .report { order: -1; }
}

/* sectors */
.group h2 .muted { font-weight: 400; font-size: .85rem; margin-left: .4rem; }
.list.sector { table-layout: fixed; }
.list.sector th:nth-child(1) { width: 2.6rem; }
.list.sector th:nth-child(2) { width: 13rem; }
.list.sector th:nth-child(4) { width: 7rem; }
.list.sector th:nth-child(5), .list.sector th:nth-child(6), .list.sector th:nth-child(7) { width: 5.5rem; }
.list.sector td.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list.sector tr.untracked td { color: var(--muted); }
.list.sector .sym .sub { display: none; }
@media (max-width: 640px) {
  .list.sector .sym .sub { display: block; }
  .list.sector th:nth-child(1), .list.sector td:nth-child(1),
  .list.sector th:nth-child(6), .list.sector td:nth-child(6) { display: none; }
  .list.sector th:nth-child(2) { width: auto; }
  .list.sector th:nth-child(4) { width: 4.8rem; }
  .list.sector th:nth-child(5), .list.sector th:nth-child(7) { width: 4.9rem; }
  .list.sector td { font-size: .85rem; }
  .group h2 .muted { display: block; margin: .2rem 0 0; }
}

/* patterns + rules (batch 9) */
.lead { font-size: 1.05rem; margin: 0 0 .4rem; }
.list.patterns td.pat { white-space: normal; }
.list.patterns tr.survives td { background: color-mix(in srgb, var(--up) 7%, transparent); }
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: .8rem; }
@media (max-width: 640px) { .rules { grid-template-columns: 1fr; } }
.rule.card { min-width: 0; }
.rule.card.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rule .k a { color: var(--text); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: .95rem; }
.rule .how { font-size: .8rem; margin: .2rem 0 .5rem; min-height: 2.4em; }
table.mini { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
table.mini th, table.mini td { padding: .2rem .3rem; border-top: 1px solid var(--line); text-align: left; }
table.mini thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: .75rem; }
table.mini .num { text-align: right; }
@media (max-width: 640px) {
  .list.patterns .kind, .list.patterns th:nth-child(5), .list.patterns td:nth-child(5),
  .list.patterns th:nth-child(10), .list.patterns td:nth-child(10) { display: none; }
  .list.rulesyms th:nth-child(5), .list.rulesyms td:nth-child(5), .list.rulesyms th:nth-child(6), .list.rulesyms td:nth-child(6),
  .list.rulesyms th:nth-child(n+5), .list.rulesyms td:nth-child(n+5) { display: none; }
}

/* query screen (batch 10e) */
.qbox { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; }
.qbox .tabs button { padding: .3rem .9rem; border-radius: 999px; }
.qbox .tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.qform { display: flex; flex-direction: column; gap: .5rem; }
.qform label { font-size: .85rem; color: var(--muted); }
.qform textarea, .qform input, .qform select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: .45rem .55rem; }
.qform textarea { width: 100%; resize: vertical; }
.qrow { display: flex; gap: .5rem; align-items: stretch; }
.qrow textarea { flex: 1; }
.mic { white-space: nowrap; }
.mic.on { background: var(--down); border-color: var(--down); color: #fff; }
.qform .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem .8rem; }
.qform .grid label { display: flex; flex-direction: column; gap: .2rem; }
.qform .grid label.check { flex-direction: row; align-items: center; gap: .4rem; align-self: end; padding-bottom: .5rem; }
.qform .go { align-self: flex-start; background: var(--accent); border-color: var(--accent); color: var(--on-accent); padding: .45rem 1.2rem; }
.qform .go[disabled] { opacity: .5; cursor: not-allowed; }
.samples { margin: .8rem 0 0; }
.result { margin-top: 1.2rem; }
.qtitle { color: var(--text); font-size: 1.15rem; margin: 0 0 .5rem; }
.qanswer { white-space: pre-wrap; font-size: 1rem; }
.qsummary { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; margin: .5rem 0 1rem; }
.qsummary > div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; }
.qsummary dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.qsummary dd { margin: .15rem 0 0; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.qchart .chart { height: 360px; }
.qtable .more { margin-top: .5rem; }
.qnotes { padding-left: 1.1rem; }
.qerror { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: .7rem .9rem; }
@media (max-width: 640px) { .qchart .chart { height: 280px; } .qrow { flex-direction: column; }
  .qsummary { grid-template-columns: 1fr 1fr; } .qsummary dd { font-size: .95rem; } }
