:root {
  color-scheme: light;
  --bg: #f3f4f1;
  --surface: #fcfcfb;
  --line: #e4e3de;
  --grid: #ecebe6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --inside: #2a78d6;
  --outside: #eb6834;
  --accent: #1f6fd1;
  --danger: #c43d3c;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --line: #2d2d2b;
    --grid: #262624;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --inside: #3987e5;
    --outside: #d95926;
    --accent: #3987e5;
    --danger: #e66767;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
[hidden] { display: none !important; }
h2 { font-size: 17px; margin: 0 0 4px; }
.muted { color: var(--text-2); margin: 0 0 12px; }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0 10px; font-size: 14px; }

.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.bolt { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 15px; }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:hover { filter: brightness(1.05); }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link.danger { color: var(--danger); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 12px; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; margin: 0; }
select { width: auto; display: inline-block; margin: 0; padding: 6px 10px; font-size: 14px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .brand { margin-bottom: 12px; }
.auth-card .btn { width: 100%; }

/* layout */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.tabs button.active { background: var(--bg); color: var(--text); }
.who { font-size: 14px; color: var(--text-2); white-space: nowrap; }
main { max-width: 1100px; margin: 0 auto; padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 480px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head .muted { margin: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 16px; align-items: start; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 label { margin-bottom: 4px; }
#add-now { margin-bottom: 16px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-inline { display: flex; gap: 8px; align-items: center; }
.chips { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.chips button { border: 0; background: none; padding: 6px 11px; border-radius: 7px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.chips button.active { background: var(--accent); color: #fff; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; gap: 6px; }
.tile .big { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .big small { font-size: 14px; font-weight: 600; color: var(--text-2); }
.tile .sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* legend + swatches */
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.inside { background: var(--inside); }
.sw.outside { background: var(--outside); }
.sw.est { background: var(--muted); opacity: .4; }

/* charts */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--line); stroke-width: 1; }
.chart .b-inside { fill: var(--inside); }
.chart .b-outside { fill: var(--outside); }
.chart .est { opacity: .42; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit.on { fill: var(--text); fill-opacity: .05; }
.chart .peak { fill: var(--text-2); font-weight: 700; font-size: 11px; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.14); border-radius: 10px; padding: 10px 12px; font-size: 13px; min-width: 170px; }
.tip b { display: block; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip .r span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip .foot { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 5px; }
.table-view summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; margin-top: 8px; }
.table-view .table-wrap, .table-view table { margin-top: 10px; }

.meter-field .hint { display: block; font-weight: 500; color: var(--muted); margin-top: 4px; font-size: 12px; }
.meter-field.inside input { border-left: 4px solid var(--inside); }
.meter-field.outside input { border-left: 4px solid var(--outside); }

.empty { text-align: center; padding: 40px 20px; }
.empty p { max-width: 460px; margin: 8px auto 16px; color: var(--text-2); }
.note { max-width: 760px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 30; }

@media (max-width: 760px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  main { padding: 14px; }
  .card { padding: 16px; }
  .tile .big { font-size: 22px; }
}

/* ---- easy-read bar lists ---- */
.chips button .sw { margin-right: 5px; vertical-align: -1px; }
.chips button.active .sw { outline: 2px solid #fff; outline-offset: -1px; }
.toolbar .btn { margin-left: auto; }
.hlist { display: flex; flex-direction: column; }
.hrow { display: grid; grid-template-columns: 150px 1fr 72px; gap: 14px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.hrow:last-child { border-bottom: 0; }
.hlabel b { display: block; font-size: 15px; }
.hlabel span { display: block; font-size: 12px; color: var(--muted); }
.hbars { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hbar { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.hbar .fill { display: block; height: 20px; border-radius: 0 6px 6px 0; flex: none; max-width: calc(100% - 120px); }
.hbar .fill.inside { background: var(--inside); }
.hbar .fill.outside { background: var(--outside); }
.hbar .fill.est { opacity: .4; }
.hbar .val { font-size: 15px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hbar .val em { font-style: normal; font-weight: 500; font-size: 12px; color: var(--text-2); }
.hbar .val.none { font-weight: 500; color: var(--muted); font-size: 13px; }
.htag { text-align: right; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--text); color: var(--surface); }
@media (max-width: 760px) {
  .hrow { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .hlabel { grid-column: 1; }
  .htag { grid-column: 2; grid-row: 1; }
  .hbars { grid-column: 1 / -1; }
  .toolbar .btn { margin-left: 0; width: 100%; }
}
