:root {
  color-scheme: light;
  --surface-page: #f5f2ec;
  --surface-panel: #fffefb;
  --surface-input: #fbfaf7;
  --surface-subtle: #f0ece5;
  --surface-hover: #eaf0f6;
  --surface-selected: #dfeaf6;
  --border-subtle: #e3ddd3;
  --border-strong: #cdc4b7;
  --text-primary: #252525;
  --text-secondary: #72757c;
  --text-heading-muted: #61748a;
  --control-muted: #9298a1;
  --accent: #315f8d;
  --accent-hover: #264b70;
  --accent-soft: #e4edf7;
  --focus-ring: rgba(49, 95, 141, 0.2);
  --danger: #c94f49;
  --danger-soft: #f8e9e7;
  --shadow-raised: 0 2px 8px rgba(61, 49, 31, 0.07);
  --shadow-floating: 0 12px 30px rgba(61, 49, 31, 0.16);
}

* { box-sizing: border-box; }
html { background: var(--surface-page); }
body {
  min-width: 280px;
  min-height: 100dvh;
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font: 0.875rem/1.55 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-header {
  min-height: 56px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-panel);
}

.app-header__inner {
  display: flex;
  align-items: center;
  width: min(100% - 32px, 920px);
  min-height: 56px;
  margin: 0 auto;
  gap: 10px;
}

.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  object-fit: contain;
}

.app-title { font-weight: 600; line-height: 1.25; }
.app-subtitle { color: var(--text-secondary); font-size: 0.75rem; line-height: 1.25; }

.collection-nav { margin-left: auto; }
.collection-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}
.collection-menu a {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 22px;
  text-decoration: none;
}
.collection-menu a:hover { background: var(--surface-hover); color: var(--text-primary); }
.collection-menu a[aria-current="page"] {
  background: var(--surface-selected);
  color: var(--accent-hover);
}
.collection-menu .refresh-reports {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 4px;
  border-left: 1px solid var(--border-subtle);
  border-radius: 0 8px 8px 0;
  color: var(--accent);
}
.collection-menu .refresh-reports:hover { color: var(--accent-hover); }
.menu-toggle {
  display: none;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  gap: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-panel);
  color: var(--text-primary);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.menu-toggle:hover,
.menu-toggle[aria-expanded="true"] { background: var(--surface-hover); }
.menu-toggle:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.menu-toggle__icon { display: grid; width: 18px; gap: 3px; }
.menu-toggle__icon span { height: 2px; border-radius: 999px; background: currentColor; }
.menu-toggle__label { font-size: 0.8125rem; }

.page-shell {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 24px 0 40px;
}

.report-toolbar,
.report-card,
.empty-state,
.message {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--surface-panel);
  box-shadow: var(--shadow-raised);
}

.report-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.toolbar-copy h1 {
  margin: 0 0 4px;
  color: var(--text-heading-muted);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
}

.toolbar-copy p { margin: 0; color: var(--text-secondary); font-size: 0.8125rem; }
.date-form { min-width: 300px; }
.date-form label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}
.date-control { display: flex; gap: 8px; }

select { min-height: 40px; border-radius: 10px; font: inherit; }
select {
  width: 100%;
  padding: 6px 36px 6px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-input);
  color: var(--text-primary);
}
select:focus-visible,
a:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
select:focus-visible { border-color: var(--accent); }

.report-card { overflow: hidden; }
.report-meta {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 20px;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.report-content { padding: 24px; }
.report-content > :first-child { margin-top: 0; }
.report-content > :last-child { margin-bottom: 0; }
.report-content h1 {
  margin: 0 0 16px;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.5rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.report-content h2 {
  margin: 28px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-heading-muted);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}
.report-content h3,
.report-content h4 {
  margin: 16px 0 4px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
}
.report-content p,
.report-content ul,
.report-content ol,
.report-content blockquote,
.report-content pre,
.report-content table { margin: 0 0 12px; }
.report-content p,
.report-content li { max-width: 78ch; }
.report-content a {
  border-radius: 3px;
  color: var(--accent);
  font-weight: 500;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.report-content a:hover { color: var(--accent-hover); background: var(--surface-hover); }
.report-content blockquote,
.report-content pre {
  padding: 12px 16px;
  border-left: 3px solid var(--border-strong);
  border-radius: 0 7px 7px 0;
  background: var(--surface-subtle);
}
.report-content code,
.empty-state code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-subtle);
  font-size: 0.8125rem;
}
.report-content pre { max-width: 100%; overflow-x: auto; }
.report-content pre code { padding: 0; }
.report-content table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.report-content th,
.report-content td {
  padding: 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}
.report-content th { background: var(--surface-subtle); color: var(--text-heading-muted); font-weight: 600; }

.empty-state,
.message { padding: 32px 24px; text-align: center; }
.empty-state__icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--control-muted);
}
.empty-state h2 { margin: 0 0 4px; font-size: 1rem; }
.empty-state p,
.message span { margin: 0; color: var(--text-secondary); }
.message--error { border-color: #e5c3bf; background: var(--danger-soft); color: var(--danger); }
.message strong,
.message span { display: block; }

@media (max-width: 640px) {
  .app-header__inner,
  .page-shell { width: min(100% - 24px, 920px); }
  .page-shell { padding-top: 12px; }
  .report-toolbar { display: block; padding: 16px; }
  .toolbar-copy { display: none; }
  .date-form { min-width: 0; margin-top: 0; }
  .date-control { align-items: stretch; flex-direction: column; }
  .report-content { padding: 20px 16px; }
  .report-meta { padding-inline: 16px; }

  .collection-nav { position: relative; }
  .menu-toggle { display: flex; }
  .collection-menu {
    position: absolute;
    z-index: 10;
    top: calc(100% + 6px);
    right: 0;
    display: none;
    width: min(260px, calc(100vw - 24px));
    max-height: min(70vh, 420px);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--surface-panel);
    box-shadow: var(--shadow-floating);
  }
  .collection-nav--open .collection-menu { display: grid; }
  .collection-menu a { width: 100%; min-height: 40px; padding: 9px 10px; }
  .collection-menu .refresh-reports {
    margin: 4px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    border-left: 0;
    border-radius: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
