:root {
  --color-background: #020617;
  --color-surface: #0b1220;
  --color-surface-raised: #111b2e;
  --color-surface-soft: #172033;
  --color-border: #2a3a52;
  --color-border-strong: #3c526f;
  --color-foreground: #f8fafc;
  --color-muted: #a9b7ca;
  --color-muted-strong: #cbd5e1;
  --color-accent: #38d886;
  --color-accent-strong: #1fbf70;
  --color-accent-soft: rgba(56, 216, 134, 0.12);
  --color-warning: #f5c451;
  --color-error: #fb7185;
  --shadow-toolbar: 0 16px 40px rgba(0, 0, 0, 0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --motion-fast: 160ms ease-out;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-width: 320px; min-height: 100%; background: var(--color-background); color: var(--color-foreground); }

body { min-height: 100vh; min-height: 100dvh; overflow: hidden; }

button, select, a { font: inherit; }

button, .button, .history-link { min-height: 44px; touch-action: manipulation; }

button, .button, .history-link { cursor: pointer; }

button:disabled, .button[aria-disabled="true"] { cursor: not-allowed; opacity: 0.42; }

a { color: inherit; }

.skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; transform: translateY(-150%); padding: 10px 14px; border-radius: var(--radius-sm); background: var(--color-accent); color: #04120b; font-weight: 700; }
.skip-link:focus { transform: translateY(0); }

:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }

.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 28px; border-bottom: 1px solid var(--color-border); background: linear-gradient(135deg, #0d1728 0%, #07101e 60%, #071b17 100%); }

.brand-block h1 { margin: 2px 0 5px; font-size: clamp(22px, 2.2vw, 32px); line-height: 1.15; letter-spacing: -0.02em; }
.brand-note, .eyebrow, .section-kicker { margin: 0; }
.brand-note { color: var(--color-muted); font-size: 13px; }
.eyebrow, .section-kicker { color: var(--color-accent); font-size: 11px; font-weight: 750; letter-spacing: 0.14em; }

.topbar-summary { display: flex; align-items: stretch; gap: 10px; }
.summary-item { min-width: 118px; padding: 10px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: rgba(15, 23, 42, 0.76); }
.summary-item span { display: block; margin-bottom: 4px; color: var(--color-muted); font-size: 12px; }
.summary-item strong { font-size: 16px; font-variant-numeric: tabular-nums; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; padding: 9px 14px; border: 1px solid transparent; border-radius: var(--radius-sm); text-decoration: none; font-weight: 650; white-space: nowrap; transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), opacity var(--motion-fast); }
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { border-color: var(--color-accent); background: var(--color-accent); color: #03120a; }
.button-primary:hover:not(:disabled) { border-color: #69eda7; background: #69eda7; }
.button-secondary { border-color: var(--color-border-strong); background: var(--color-surface-raised); color: var(--color-foreground); }
.button-secondary:hover:not(:disabled), .button-quiet:hover:not(:disabled) { border-color: #647f9e; background: #1a2940; }
.button-quiet { border-color: var(--color-border); background: transparent; color: var(--color-muted-strong); }

.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); height: calc(100vh - 104px); height: calc(100dvh - 104px); min-height: 0; }

.history-panel { display: flex; flex-direction: column; min-height: 0; padding: 20px 16px 16px; border-right: 1px solid var(--color-border); background: var(--color-surface); }
.history-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 0 4px 14px; }
.history-heading-row h2 { margin: 3px 0 0; font-size: 20px; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--color-muted-strong); font-size: 11px; white-space: nowrap; }
.live-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 4px var(--color-accent-soft); }

.history-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 4px 16px; scrollbar-color: var(--color-border-strong) transparent; }
.history-link { width: 100%; display: block; margin-bottom: 8px; padding: 12px 13px; border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--color-muted-strong); text-align: left; transition: background-color var(--motion-fast), border-color var(--motion-fast); }
.history-link:hover:not(:disabled) { border-color: var(--color-border); background: var(--color-surface-soft); }
.history-link[aria-current="date"] { border-color: rgba(56, 216, 134, 0.52); background: var(--color-accent-soft); color: var(--color-foreground); }
.history-link strong, .history-link span { display: block; }
.history-link strong { margin-bottom: 4px; font-size: 15px; }
.history-link span { color: var(--color-muted); font-size: 12px; }
.source-note { padding: 14px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-raised); }
.source-note span, .source-note strong, .source-note small { display: block; }
.source-note span { margin-bottom: 3px; color: var(--color-muted); font-size: 11px; }
.source-note strong { font-size: 13px; }
.source-note small { margin-top: 4px; color: var(--color-accent); font-size: 11px; }

.report-area { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #050a13; }
.report-toolbar { position: relative; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--color-border); background: rgba(11, 18, 32, 0.96); box-shadow: var(--shadow-toolbar); }
.date-navigation, .report-actions { display: flex; align-items: center; gap: 8px; }
.mobile-date-control { display: none; }
.mobile-date-control label { display: block; margin-bottom: 4px; color: var(--color-muted); font-size: 12px; }
.mobile-date-control select { width: 100%; min-height: 44px; padding: 8px 36px 8px 12px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: var(--color-surface-raised); color: var(--color-foreground); }

.report-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); }
.selected-date { display: block; font-size: 15px; font-weight: 700; }
.file-meta { display: block; margin-top: 3px; color: var(--color-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.status-message { margin: 0; color: var(--color-muted-strong); font-size: 12px; text-align: right; }
.status-message[data-tone="success"] { color: var(--color-accent); }
.status-message[data-tone="warning"] { color: var(--color-warning); }
.status-message[data-tone="error"] { color: var(--color-error); }

.report-stage { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; background: #030710; }
.report-frame { display: block; width: 100%; height: 100%; min-height: calc(100vh - 190px); border: 0; background: #050a13; }
.state-panel { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 32px; text-align: center; background: radial-gradient(circle at 50% 20%, #101e33, #050a13 54%); }
.state-panel[hidden] { display: none; }
.state-panel svg { width: 48px; height: 48px; fill: none; stroke: var(--color-accent); stroke-width: 1.4; }
.state-panel h2 { margin: 18px 0 6px; font-size: 21px; }
.state-panel p { max-width: 540px; margin: 0 0 20px; color: var(--color-muted); line-height: 1.6; }
.loading-panel { align-content: center; }
.loading-line { width: min(320px, 64vw); height: 10px; margin-bottom: 10px; border-radius: 10px; background: linear-gradient(90deg, #162237 20%, #2b3b56 50%, #162237 80%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.loading-line-wide { width: min(460px, 76vw); height: 18px; }

@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 980px) {
  .summary-item { display: none; }
  .report-actions { display: none; }
}

@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { min-height: auto; align-items: flex-start; padding: 14px 16px; }
  .brand-note, .eyebrow { display: none; }
  .brand-block h1 { margin: 8px 0 0; font-size: 20px; }
  .topbar-summary { flex-shrink: 0; }
  .button { padding-inline: 12px; }
  #refresh-button span { display: none; }
  .app-shell { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - 73px); min-height: calc(100dvh - 73px); }
  .history-panel { display: none; }
  .report-area { min-height: calc(100vh - 73px); min-height: calc(100dvh - 73px); }
  .report-toolbar { position: sticky; top: 0; flex-wrap: wrap; padding: 10px 12px; }
  .date-navigation { display: grid; grid-template-columns: auto minmax(135px, 1fr) auto; width: 100%; }
  .mobile-date-control { display: block; }
  #latest-button { grid-column: 1 / -1; }
  .report-meta { align-items: flex-start; padding: 10px 14px; }
  .file-meta { max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .status-message { max-width: 34%; }
  .report-stage { min-height: calc(100vh - 230px); min-height: calc(100dvh - 230px); }
  .report-frame { height: calc(100vh - 230px); height: calc(100dvh - 230px); min-height: 620px; }
}

@media (max-width: 430px) {
  .report-meta { display: block; }
  .status-message { max-width: none; margin-top: 6px; text-align: left; }
  .file-meta { max-width: 92vw; }
}

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