:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --border: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --danger: #d92d20;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05), 0 1px 3px rgb(16 24 40 / 0.04);
  --radius: 12px;
  --row: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0e13;
    --surface: #14171e;
    --surface-2: #1b1f28;
    --border: #262b36;
    --text: #e7e9ee;
    --muted: #8b93a7;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --danger: #f97066;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

/* Category accents */
.accent-0 { --cat: #6366f1; }
.accent-1 { --cat: #0d9488; }
.accent-2 { --cat: #d97706; }
.accent-3 { --cat: #e11d48; }
.accent-4 { --cat: #0284c7; }
.accent-5 { --cat: #9333ea; }
@media (prefers-color-scheme: dark) {
  .accent-0 { --cat: #818cf8; }
  .accent-1 { --cat: #2dd4bf; }
  .accent-2 { --cat: #fbbf24; }
  .accent-3 { --cat: #fb7185; }
  .accent-4 { --cat: #38bdf8; }
  .accent-5 { --cat: #c084fc; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar form { margin: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; }
.container { max-width: 880px; margin: 0 auto; padding: 28px 16px 64px; }

/* Buttons */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: #fff; padding: 10px 14px; }
.btn-primary:hover { background: var(--accent-hover); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0c0e13; } }

/* Page header + toolbar */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 26px; font-weight: 700; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.segmented button {
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.range { display: flex; align-items: center; gap: 8px; }
.range label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.range-sep { color: var(--muted); }
input[type="date"], .field input {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
input[type="date"]:focus, .field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Categories */
.category {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.category summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.category summary::-webkit-details-marker { display: none; }
.category summary:hover { background: var(--surface-2); }
.chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex: none;
}
.category[open] .chevron { transform: rotate(45deg); }
.cat-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex: none;
  font-weight: 700;
  font-size: 14px;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 14%, transparent);
}
.cat-name { font-weight: 650; font-size: 16px; }
.cat-meta { margin-left: auto; font-size: 13px; color: var(--muted); }

/* Report rows: at most 10 visible, then the list scrolls */
.reports {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
  max-height: calc(var(--row) * 10);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.reports li + li { border-top: 1px solid var(--border); }
.reports a {
  display: flex;
  align-items: center;
  gap: 14px;
  height: calc(var(--row) - 1px);
  padding: 0 18px;
  transition: background 0.12s;
}
.reports a:hover { background: var(--surface-2); }
.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  line-height: 1;
}
.day b { font-size: 15px; font-weight: 700; }
.day small { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-top: 3px; }
.info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.title { font-weight: 550; font-size: 14.5px; }
.sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  flex: none;
}
.pill-soft { color: var(--muted); background: var(--surface-2); }
.arrow { color: var(--muted); flex: none; transition: transform 0.15s, color 0.15s; }
.reports a:hover .arrow { color: var(--text); transform: translateX(2px); }
.empty { margin: 0; padding: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state h2 { font-size: 18px; margin-bottom: 6px; }

/* Login */
.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 200px); }
.login-card {
  width: 100%;
  max-width: 380px;
  display: grid;
  gap: 16px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; }
.login-card .muted { margin-top: -10px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 550; }
.field input { padding: 10px 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.alert {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

@media (max-width: 600px) {
  .container { padding-top: 20px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .segmented { justify-content: space-between; }
  .segmented button { flex: 1; }
  .range label { flex: 1; }
  .range input { flex: 1; min-width: 0; }
  .range label span { display: none; }
  .cat-meta { display: none; }
  .reports a { padding: 0 14px; gap: 12px; }
}
