[hidden] { display: none !important; }
:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1d1d1f; --muted: #6b6b70; --line: #e4e2dc;
  --accent: #2f6fbe; --up: #b3361f; --down: #237a3b; --gold: #a07a12; --silver: #6d7480; --copper: #9a5a2e;
  --chip: #eeece6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416; --card: #1d1d20; --ink: #ececee; --muted: #9a9aa2; --line: #2e2e33;
    --accent: #6aa5ec; --up: #f0816c; --down: #6fcf8a; --gold: #e2bd52; --silver: #b7bec9; --copper: #d99662;
    --chip: #2a2a2f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px;
  border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 650; font-size: 16px; }
nav { display: flex; align-items: center; gap: 6px; }
main { padding: 18px 20px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 6px; } h2 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--up); min-height: 1.2em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.narrow { max-width: 360px; margin: 60px auto; }
label { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }
label input { display: block; width: 100%; margin-top: 4px; }
button { font: inherit; cursor: pointer; border-radius: 7px; border: 1px solid var(--line); background: var(--chip); color: var(--ink); padding: 6px 12px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; }
.tab { border: 0; background: none; color: var(--muted); }
.tab.on { color: var(--ink); background: var(--chip); }
.bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.bar input[type=search] { flex: 1; min-width: 200px; max-width: 420px; }
.seg { display: inline-flex; background: var(--chip); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.split { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.split.open { grid-template-columns: minmax(0, 1fr) 420px; }
@media (max-width: 1000px) { .split.open { grid-template-columns: 1fr; } }
.tablecard { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--card); }
th.sorted::after { content: " \25BE"; } th.sorted.asc::after { content: " \25B4"; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
#tbl tbody tr { cursor: pointer; } #tbl tbody tr:hover, #tbl tbody tr.sel { background: var(--chip); }
td.name { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.id { color: var(--muted); font-size: 11px; margin-left: 4px; }
.g { color: var(--gold); } .s { color: var(--silver); } .c { color: var(--copper); }
.rise { color: var(--down); } .fall { color: var(--up); }
.tag { font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--chip); color: var(--muted); margin-left: 4px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 8px 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
dt { color: var(--muted); } dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; } .row input { flex: 1; min-width: 110px; }
.chart { width: 100%; height: 180px; margin-top: 10px; }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.cmp { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--chip); font-size: 13px; }
.ok { color: var(--down); } .bad { color: var(--up); }
#logTbl td { font-size: 12px; white-space: normal; }
#logTbl td:nth-child(-n+2) { width: 1%; white-space: nowrap; }
.bar label { display: inline-flex; align-items: center; gap: 5px; margin: 0; white-space: nowrap; }
.bar label input { display: inline; width: auto; margin: 0; }

th.nosort { cursor: default; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi-l { font-size: 12px; color: var(--muted); }
.kpi-v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi-s { font-size: 11px; color: var(--muted); }
.movers { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 12px; }
.mv ol { list-style: none; margin: 0; padding: 0; }
.mv li { display: grid; grid-template-columns: 1fr auto 56px; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.mv li:last-child { border-bottom: 0; }
.mv li:hover .mv-name { color: var(--accent); }
.mv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv .num { text-align: right; font-variant-numeric: tabular-nums; }
.filters select, .filters input { padding: 5px 8px; }
.filters label input { margin-left: 4px; width: 58px; }
#fProfit { width: 76px; }
.cols dd { white-space: nowrap; }
.tag.warn { background: color-mix(in srgb, var(--up) 18%, transparent); color: var(--up); }
.detail { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; }
.detail .head { justify-content: space-between; margin: 0; align-items: baseline; }
.detail h3 { font-size: 13px; margin: 10px 0 6px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols dl { font-size: 13px; }
.chart-ctl { justify-content: space-between; margin-top: 14px; }
.seg.small button { padding: 3px 9px; font-size: 12px; }
.cuts { display: inline-flex; gap: 10px; }
.intro { margin-bottom: 12px; } .intro p { margin: 4px 0 0; }
.legend-notes { margin-top: 10px; }
.bad-input { border-color: var(--up) !important; }
#flipTbl tbody tr { cursor: pointer; } #flipTbl tbody tr:hover { background: var(--chip); }
.filters label input[type=checkbox] { width: auto; margin: 0; }

#craftTbl tbody tr { cursor: pointer; } #craftTbl tbody tr:hover, #craftTbl tbody tr.sel { background: var(--chip); }
#craftTbl td.name .id { display: block; margin-left: 0; }
table.mini th, table.mini td { padding: 5px 6px; font-size: 13px; }
table.mini tr.total td { border-bottom: 0; }
code { background: var(--chip); padding: 1px 5px; border-radius: 4px; }
#craftTbl td:last-child, #flipTbl td:last-child { white-space: normal; min-width: 90px; }

.chartwrap { position: relative; margin-top: 6px; }
.chart-top { justify-content: space-between; margin: 0; min-height: 22px; align-items: center; }
.chart .hit { cursor: crosshair; touch-action: pan-y; }
.charttip { position: absolute; z-index: 3; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.15); min-width: 150px; }
.charttip-h { color: var(--muted); margin-bottom: 3px; }
.charttip-r { display: grid; grid-template-columns: 10px auto; column-gap: 6px; align-items: center; margin-top: 2px; }
.charttip-r i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; grid-row: span 3; align-self: start; margin-top: 4px; }
.charttip-r span { grid-column: 2; font-variant-numeric: tabular-nums; }
.legend-item { border: 0; background: none; padding: 2px 4px; color: var(--muted); font-size: 12px; }
.legend-item.off { opacity: .45; text-decoration: line-through; }
.chart { user-select: none; -webkit-user-select: none; }

.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.row.two label { margin: 10px 0 0; }
.row.two select { width: 100%; margin-top: 4px; display: block; }
#authSwitch { margin: 8px 0 0; }
#authSwitch a, .link { color: var(--accent); }
code.big { font-size: 18px; letter-spacing: 1px; padding: 2px 8px; }
input.copy { width: 100%; margin-top: 4px; font-size: 12px; }
#invTbl, #userTbl { margin-top: 10px; }
.row.two + button, #mkForm button { margin-top: 14px; }
.ok-tag { background: color-mix(in srgb, var(--down) 18%, transparent); color: var(--down); }
#funnelCard { margin-bottom: 14px; } #funnelCard .head { justify-content: space-between; align-items: center; margin: 0; }
ol.steps { padding-left: 20px; margin: 8px 0 12px; } ol.steps li { margin: 3px 0; }
.big-link { word-break: break-all; font-weight: 600; }
