:root {
  color-scheme: light;
  --page: #f9f9f9;
  --surface: #ffffff;
  --text: #191919;
  --text-muted: #666666;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #257de0;
  --up: #006c10;
  --down: #b3261e;
  --notice-bg: #fff6dd;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0b0b0b;
    --surface: #191919;
    --text: #efefef;
    --text-muted: #9c9c9c;
    --grid: #303030;
    --axis: #474747;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #338ced;
    --up: #53c556;
    --down: #f08a84;
    --notice-bg: #33290c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 16px;
  background: var(--page);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.top, main { max-width: 960px; margin: 0 auto; }
.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin-bottom: 16px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 4px; }
p { margin: 0; }
.muted { color: var(--text-muted); font-size: 14px; }
.footnote { margin-top: 12px; }
.label { color: var(--text-muted); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.hero-value { font-size: 52px; font-weight: 600; line-height: 1.1; margin: 4px 0; }
.up { color: var(--up); }
.down { color: var(--down); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.tile-value { font-size: 24px; font-weight: 600; }

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 auto 16px;
  max-width: 960px;
  font-size: 14px;
}

.table-wrap { overflow-x: auto; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th { color: var(--text-muted); font-weight: 500; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.num { font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 600; }

.chart { position: relative; margin-top: 12px; }
.chart svg { display: block; outline-offset: 2px; touch-action: pan-y; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.series-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.series-fill { fill: var(--series-1); }
.tick { fill: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tick-y { text-anchor: end; dominant-baseline: middle; }
.tick-x { text-anchor: middle; }
.end-label { fill: var(--text); font-size: 13px; font-weight: 600; dominant-baseline: middle; }
.cap-label { fill: var(--text); font-size: 12px; text-anchor: middle; }
.hit { fill: transparent; outline-offset: -2px; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
  z-index: 2;
}
.chart-tip-title { font-weight: 600; margin-bottom: 2px; }

.filters { display: grid; gap: 8px; margin-bottom: 16px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-row span { color: var(--text-muted); font-size: 14px; min-width: 44px; }
.filters button[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
tr.sub td:first-child { padding-left: 16px; }
tr.sub2 td:first-child { padding-left: 32px; }
tr.empty td { color: var(--text-muted); }

/* Toolbar, buttons and the entry dialog */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar .inline { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); }
button, select, input, textarea { font: inherit; color: var(--text); }
button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button.primary { background: var(--series-1); border-color: var(--series-1); color: #ffffff; font-weight: 600; }
button.quiet { border-color: transparent; background: transparent; color: var(--text-muted); padding: 6px 8px; }
button.danger { color: var(--down); }
.filters button { border-radius: 999px; padding: 6px 14px; font-size: 14px; }
td button { padding: 4px 10px; font-size: 13px; }
select, input, textarea {
  background: var(--surface);
  border: 1px solid var(--axis);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}
.toolbar select { width: auto; }
input[type="radio"] { width: auto; }

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
#entry-form { display: grid; gap: 14px; }
#entry-form label { display: grid; gap: 4px; font-size: 14px; color: var(--text-muted); }
#entry-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; }
#entry-form legend { font-size: 14px; color: var(--text-muted); padding: 0 4px; }
#entry-form fieldset.choice { display: flex; gap: 16px; border: 0; padding: 0; }
#entry-form fieldset.choice legend { float: left; min-width: 44px; padding: 0; }
#entry-form fieldset.choice label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 15px; }
#tournament-fields, #cash-fields { display: grid; gap: 14px; }
#tournament-fields[hidden], #cash-fields[hidden] { display: none; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.line-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(130px, 1.4fr) auto; gap: 8px; }
.summary { font-weight: 600; min-height: 1.45em; }
.problems { margin: 0; padding-left: 18px; color: var(--down); font-size: 14px; }
.problems:empty { display: none; }
/* Save stays in reach on a phone however long the form gets. */
.actions {
  display: flex; gap: 8px; align-items: center;
  position: sticky; bottom: -20px; margin: 0 -20px -20px; padding: 12px 20px 20px;
  background: var(--surface); border-top: 1px solid var(--border);
}
.spacer { flex: 1; }

.drive { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.drive button { padding: 5px 12px; font-size: 14px; }
