:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-synthesis: none;
  --ink: #1d1d1f;
  --muted: #626269;
  --line: #dedee3;
  --surface: #fff;
  --bg: #f5f5f7;
  --subtle: #f8f8fa;
  --accent: #0066cc;
  --primary: #0066cc;
  --track: #007aff;
  --green: #248a3d;
  --purple: #af52de;
  --amber: #ad6800;
  --red: #c9342b;
  --slate: #8e8e93;
  --blue: #007aff;
  --pale: #eaf3ff;
  --glass: rgba(255,255,255,.84);
  --shadow: 0 2px 8px rgba(0,0,0,.025), 0 12px 32px rgba(0,0,0,.025);
  --icon-filter: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.45; }
button, input, select { font: inherit; }
button, a, input, select, summary, [tabindex] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid transparent; border-radius: 999px; padding: 9px 18px; font-weight: 600; white-space: nowrap; }
button:disabled { opacity: .4; cursor: default; }
button:hover:not(:disabled) { filter: brightness(.95); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--track); outline-offset: 4px; }
a { color: var(--accent); }
button.primary { background: var(--primary); color: #fff; }
button.secondary { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: 0 1px 3px #00000006; }
button.quiet { background: transparent; color: var(--accent); }
.icon { display: inline-block; width: 18px; height: 18px; flex: 0 0 auto; vertical-align: middle; filter: var(--icon-filter); }
.primary .icon, .brand-mark .icon { filter: brightness(0) invert(1); }
.muted { color: var(--muted); font-size: .867rem; }
.app-header { position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); background: var(--glass); -webkit-backdrop-filter: saturate(160%) blur(24px); backdrop-filter: saturate(160%) blur(24px); }
.header-inner { max-width: 1280px; margin: auto; min-height: 76px; padding: 12px 36px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 1rem; letter-spacing: -.2px; }
.brand-copy { display: flex; flex-direction: column; gap: 1px; }
.brand-copy small { font-size: .733rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 12px; background: var(--primary); flex-shrink: 0; }
.brand-mark .icon { width: 21px; height: 21px; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.private-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; color: var(--muted); }
.private-badge .icon { width: 14px; height: 14px; }
.dashboard { max-width: 1280px; margin: auto; padding: 42px 36px 32px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
h1 { font-size: 2.4rem; font-weight: 700; letter-spacing: -.045em; line-height: 1.15; margin: 0 0 10px; }
h2 { font-size: 1.133rem; font-weight: 600; letter-spacing: -.02em; margin: 0; }
p { line-height: 1.55; }
.title-row p { margin: 0; }
#freshness { white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.field select, .field input { height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 0 14px; min-width: 170px; }
.select-control { position: relative; display: flex; min-width: 0; }
.field select { -webkit-appearance: none; appearance: none; width: 100%; padding-right: 42px; }
.select-chevron { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 14px; height: 18px; background: var(--muted); -webkit-mask: url("icons/chevron-expand.svg") center / contain no-repeat; mask: url("icons/chevron-expand.svg") center / contain no-repeat; pointer-events: none; }
.user-field select { max-width: 280px; min-width: 220px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }
.kpis { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px 24px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.kpi-title { display: flex; align-items: center; gap: 8px; font-size: .867rem; color: var(--muted); font-weight: 500; }
.kpi-title .icon { width: 16px; height: 16px; }
.kpi strong { font-size: 2.8rem; line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.kpi small { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; padding: 24px 26px 18px; gap: 16px; }
.panel-heading p { margin: 5px 0 0; font-size: .8rem; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--track); }
.swatch.episodes { background: var(--purple); }
.swatch.complete { background: var(--green); }
.swatch.partial { background: var(--amber); }
.swatch.failed { background: var(--red); }
.swatch.interrupted { background: var(--slate); }
.swatch.in_progress { background: var(--blue); }
.trend-chart { padding: 8px 24px 18px; min-height: 285px; display: flex; align-items: center; justify-content: center; }
.trend-chart svg { width: 100%; height: auto; display: block; max-height: 320px; overflow: visible; }
.axis-text { fill: var(--muted); font-size: 12px; }
.grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 5; }
.bar.tracks { fill: var(--track); }
.bar.episodes { fill: var(--purple); }
.bar.complete { fill: var(--green); }
.bar.partial { fill: var(--amber); }
.bar.failed { fill: var(--red); }
.bar.interrupted { fill: var(--slate); }
.bar.in_progress { fill: var(--blue); }
.bar.format { fill: var(--track); }
.bar-background { fill: var(--subtle); }
.trend-group:hover .bar, .trend-group:focus .bar { filter: brightness(1.12); }
.split-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 24px; }
.split-grid > .panel { min-height: 250px; }
.count-label { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.outcome-legend { padding: 0 26px 20px; gap: 12px; }
.collection-chart, .format-chart { padding: 0 26px 24px; display: flex; flex-direction: column; gap: 18px; }
.bar-row { display: grid; grid-template-columns: 110px minmax(50px,1fr) 40px; gap: 12px; align-items: center; font-size: .867rem; }
.bar-row svg { width: 100%; height: 12px; display: block; }
.bar-row .number { text-align: right; font-variant-numeric: tabular-nums; }
.format-chart { padding-top: 10px; }
.format-chart .bar-row { grid-template-columns: 65px minmax(50px,1fr) 60px; }
.table-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; font-size: .867rem; text-align: left; }
th { font-size: .8rem; font-weight: 500; color: var(--muted); background: var(--subtle); padding: 14px 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 16px 26px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--subtle); }
.user-button { color: var(--accent); background: transparent; min-height: 32px; padding: 0; border-radius: 4px; font-size: .867rem; font-weight: 500; text-align: left; justify-content: flex-start; }
.user-id { color: var(--muted); font-size: .733rem; margin-top: 2px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; font-size: .733rem; font-weight: 600; padding: 5px 10px; background: var(--subtle); color: var(--ink); }
.badge.complete { background: #e8f5ec; color: #1b7130; }
.badge.partial { background: #fff3dc; color: #805000; }
.badge.failed { background: #ffebe9; color: #a5211c; }
.badge.interrupted { background: #eeeef1; color: #5b5b63; }
.badge.in_progress { background: #eaf3ff; color: #0055ad; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 26px; border-top: 1px solid var(--line); gap: 12px; }
.pagination > div { display: flex; gap: 8px; }
.pagination button { font-size: .8rem; }
.dashboard-footer { display: flex; justify-content: space-between; gap: 30px; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.dashboard-footer details { max-width: 750px; }
.dashboard-footer summary { cursor: pointer; font-weight: 500; min-height: 44px; padding-top: 10px; }
.dashboard-footer > span { text-align: right; padding-top: 10px; }
.empty-banner { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 18px 22px; margin-bottom: 24px; display: flex; gap: 5px; flex-direction: column; }
.empty-banner strong { font-size: .933rem; font-weight: 600; }
.empty-banner span { color: var(--muted); font-size: .867rem; }
.error-banner { border: 1px solid var(--red); background: var(--surface); color: var(--red); padding: 16px 20px; border-radius: 16px; margin: 0 0 24px; }
.panel-empty { color: var(--muted); font-size: .867rem; padding: 32px 0; text-align: center; width: 100%; }
.table-scroll > .panel-empty { padding: 32px 20px; }
.chart-tooltip { position: fixed; z-index: 10; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); pointer-events: none; font-size: .8rem; line-height: 1.7; white-space: pre-line; }
.login-page { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 32px 20px; }
.login-card { max-width: 420px; width: 100%; background: var(--surface); padding: 40px; border-radius: 28px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-card > .brand-mark { width: 56px; height: 56px; border-radius: 17px; margin-bottom: 28px; }
.login-card > .brand-mark .icon { width: 30px; height: 30px; }
.login-card h1 { font-size: 2rem; }
.login-card > p { margin: 0 0 28px; font-size: .933rem; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input[type=password] { height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--subtle); color: var(--ink); padding: 0 14px; font-size: 16px; }
.login-card button { margin-top: 12px; width: 100%; min-height: 48px; }
.login-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 24px 0 0 !important; color: var(--muted); font-size: .8rem !important; }
.login-note .icon { width: 14px; height: 14px; }
.form-error { font-size: .867rem; color: var(--red); margin: 0; }
[hidden] { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root { --ink: #f5f5f7; --muted: #a5a5ad; --line: #3b3b41; --surface: #1c1c1e; --bg: #101012; --subtle: #252528; --accent: #64a8ff; --track: #409cff; --green: #30d158; --purple: #bf5af2; --amber: #ffb340; --red: #ff6961; --slate: #98989d; --blue: #64a8ff; --pale: #162e49; --glass: rgba(28,28,30,.87); --shadow: 0 8px 24px #00000016; --icon-filter: invert(1); }
  .badge.complete { background: #183322; color: #75df91; }
  .badge.partial { background: #352817; color: #ffd085; }
  .badge.failed { background: #3b2020; color: #ffaaa4; }
  .badge.interrupted { background: #303036; color: #ccc; }
  .badge.in_progress { background: #16304a; color: #8fcaff; }
}
@media (max-width: 1050px) {
  .dashboard { padding: 32px 24px; }
  .header-inner { padding: 12px 24px; }
  .filter-actions { margin-left: 0; }
  .field select { min-width: 150px; }
  .user-field select { min-width: 180px; }
  .kpi { padding: 20px; }
  .bar-row { grid-template-columns: 90px minmax(50px,1fr) 35px; gap: 8px; }
  th, td { padding-left: 20px; padding-right: 20px; }
  .split-grid { gap: 20px; }
}
@media (max-width: 720px) {
  .dashboard { padding: 28px 16px; }
  .header-inner { padding: 10px 16px; min-height: 68px; }
  .header-actions { gap: 4px; }
  .header-actions .quiet { padding: 9px 12px; }
  .private-badge { display: none; }
  .title-row { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 24px; }
  h1 { font-size: 2rem; }
  .filters { gap: 12px; }
  .field { flex: 1; min-width: 0; }
  .field select, .field input, .user-field select { width: 100%; min-width: 0; max-width: none; font-size: 16px; }
  .custom-date { flex-basis: 40%; }
  .user-field { flex-basis: 100%; }
  .filter-actions { width: 100%; justify-content: flex-end; gap: 6px; }
  button { min-height: 44px; padding: 9px 14px; }
  .kpis { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
  .kpi { padding: 18px; gap: 12px; border-radius: 18px; }
  .kpi-title { font-size: .8rem; gap: 6px; min-height: 36px; align-items: flex-start; }
  .kpi-title .icon { margin-top: 2px; }
  .kpi strong { font-size: 2.4rem; }
  .kpi small { font-size: .733rem; }
  .panel { margin-bottom: 20px; border-radius: 18px; }
  .panel-heading { padding: 20px 18px 16px; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .panel-heading .legend { gap: 12px; }
  .trend-chart { padding: 0 12px 16px; min-height: 210px; }
  .split-grid { grid-template-columns: 1fr; gap: 0; }
  .split-grid > .panel { min-height: 0; }
  .outcome-legend { padding-left: 18px; padding-right: 18px; }
  .collection-chart, .format-chart { padding: 0 18px 22px; }
  .format-chart { padding-top: 10px; }
  .dashboard-footer { flex-direction: column; gap: 8px; }
  .dashboard-footer > span { text-align: left; }
  .login-card { padding: 32px; }
  .pagination { padding: 16px 18px; flex-wrap: wrap; }
  .user-button { min-height: 44px; }
}
@media (prefers-reduced-transparency: reduce) { .app-header { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-contrast: more) { :root { --muted: var(--ink); --line: var(--ink); --shadow: none; } .app-header { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (forced-colors: active) { .field select { -webkit-appearance: auto; appearance: auto; padding-right: 14px; } .select-chevron { display: none; } }
@media (prefers-reduced-motion: no-preference) { button { transition: background .15s, filter .15s; } }
