:root {
  color-scheme: light dark;
  --bg: #eef3f4;
  --surface: #ffffff;
  --surface-2: #f6f8f8;
  --surface-3: #e9f0f0;
  --ink: #172b36;
  --muted: #627680;
  --line: #d4dfe1;
  --brand: #123947;
  --brand-2: #1c5263;
  --teal: #007f76;
  --teal-bright: #00a69a;
  --green: #7ac943;
  --focus: #008ee0;
  --critical: #ba3333;
  --critical-bg: #feeae8;
  --warning: #8a5b00;
  --warning-bg: #fff1c9;
  --ok: #257542;
  --ok-bg: #e3f4e7;
  --shadow: 0 20px 55px rgba(18, 57, 71, .1);
  --shadow-soft: 0 8px 26px rgba(18, 57, 71, .07);
  --radius: 18px;
  font-family: Inter, Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1c24;
    --surface: #112a35;
    --surface-2: #163440;
    --surface-3: #1b3d49;
    --ink: #e7f0f2;
    --muted: #a5bac1;
    --line: #31505b;
    --brand: #09222c;
    --brand-2: #173f4e;
    --teal: #58d3c6;
    --teal-bright: #80e1d7;
    --critical: #ff8582;
    --critical-bg: #4a2528;
    --warning: #ffd06f;
    --warning-bg: #483915;
    --ok: #8bd39d;
    --ok-bg: #183d2a;
    --shadow: 0 20px 55px rgba(0, 0, 0, .28);
    --shadow-soft: 0 8px 26px rgba(0, 0, 0, .2);
  }
}

:root[data-theme="dark"] {
  --bg: #0b1c24;
  --surface: #112a35;
  --surface-2: #163440;
  --surface-3: #1b3d49;
  --ink: #e7f0f2;
  --muted: #a5bac1;
  --line: #31505b;
  --brand: #09222c;
  --brand-2: #173f4e;
  --teal: #58d3c6;
  --teal-bright: #80e1d7;
  --critical: #ff8582;
  --critical-bg: #4a2528;
  --warning: #ffd06f;
  --warning-bg: #483915;
  --ok: #8bd39d;
  --ok-bg: #183d2a;
  --shadow: 0 20px 55px rgba(0, 0, 0, .28);
  --shadow-soft: 0 8px 26px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; min-width: 300px; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button, select, label[for="fileInput"] { cursor: pointer; }
button, input, select, summary, label[for="fileInput"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible,
label[for="fileInput"]:focus-within, .drop-zone:focus-within, .partner-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; transform: translateY(-150%); padding: 10px 14px; border-radius: 8px; background: var(--surface); color: var(--ink); }
.skip-link:focus { transform: none; }

.site-header { position: relative; z-index: 10; min-height: 70px; display: flex; align-items: center; gap: 20px; padding: 12px clamp(18px, 4vw, 58px); background: var(--brand); color: white; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand { display: flex; align-items: center; gap: 11px; color: white; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: linear-gradient(145deg, var(--green), #b2df62); color: #123a25; font-weight: 950; font-size: 22px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }
.brand strong { display: block; font-size: 16px; letter-spacing: .08em; }
.brand small { display: block; margin-top: 1px; color: rgba(255,255,255,.68); font-size: 10px; text-transform: uppercase; letter-spacing: .13em; }
.header-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }
.language-switch { display: flex; padding: 3px; border: 1px solid rgba(255,255,255,.22); border-radius: 10px; background: rgba(255,255,255,.06); }
.language-switch button { min-width: 41px; border: 0; border-radius: 7px; padding: 7px 8px; color: rgba(255,255,255,.7); background: transparent; font-size: 12px; font-weight: 800; }
.language-switch button[aria-pressed="true"] { color: var(--brand); background: white; }
.icon-button { width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.22); border-radius: 10px; color: white; background: rgba(255,255,255,.06); }

.hero { position: relative; isolation: isolate; padding: clamp(42px, 7vw, 92px) clamp(18px, 5vw, 72px); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, .75fr); gap: clamp(34px, 6vw, 86px); align-items: center; overflow: hidden; background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 72%, #176b6a 130%); color: white; }
.hero::before { content: ""; position: absolute; z-index: -1; width: 620px; height: 620px; right: -280px; top: -340px; border-radius: 50%; border: 110px solid rgba(122,201,67,.08); }
.hero-copy { max-width: 760px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 11px; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
.hero .eyebrow { color: #85ded1; }
h1 { margin: 0; max-width: 750px; font-size: clamp(36px, 5vw, 68px); line-height: 1.01; letter-spacing: -.045em; text-wrap: balance; }
.lede { margin: 20px 0 0; max-width: 700px; color: rgba(255,255,255,.74); font-size: clamp(16px, 1.7vw, 20px); line-height: 1.55; }
.trust-list { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 26px 0 0; padding: 0; list-style: none; color: rgba(255,255,255,.88); font-size: 12px; font-weight: 700; }
.trust-list li::before { content: "✓"; margin-right: 7px; color: #a8e274; font-weight: 950; }

.file-card { width: 100%; max-width: 570px; justify-self: end; padding: clamp(20px, 3vw, 30px); border: 1px solid rgba(255,255,255,.2); border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: 0 32px 80px rgba(0,0,0,.28); }
.file-card-heading { display: flex; align-items: center; gap: 13px; }
.file-card h2 { margin: 0; font-size: 19px; }
.file-card-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.step-number { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: var(--teal); font-weight: 900; }
.drop-zone { margin-top: 19px; min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 25px; border: 2px dashed var(--line); border-radius: 16px; background: var(--surface-2); text-align: center; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.drop-zone.dragging { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 9%, var(--surface)); transform: translateY(-2px); }
.drop-zone > span { color: var(--muted); font-size: 12px; }
.drop-zone small { max-width: 100%; margin-top: 6px; color: var(--muted); overflow-wrap: anywhere; }
.file-glyph { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 3px; border-radius: 14px; background: color-mix(in srgb, var(--teal) 13%, var(--surface)); color: var(--teal); font-size: 25px; font-weight: 900; }
.primary-button, .secondary-button, .text-button { border-radius: 10px; font-weight: 760; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 15px; border: 0; color: white; background: var(--teal); box-shadow: 0 7px 17px color-mix(in srgb, var(--teal) 24%, transparent); }
.secondary-button { min-height: 39px; padding: 8px 13px; border: 1px solid var(--line); color: var(--ink); background: var(--surface-2); }
.text-button { padding: 7px 2px; border: 0; color: var(--teal); background: transparent; }
.progress-panel { margin-top: 18px; }
.progress-line { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.progress-line strong { color: var(--ink); }
progress { width: 100%; height: 10px; margin: 10px 0 5px; accent-color: var(--teal); }
.error-panel { margin-top: 16px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--critical) 40%, var(--line)); border-radius: 11px; color: var(--critical); background: var(--critical-bg); line-height: 1.45; font-size: 13px; }

.analysis { max-width: 1540px; margin: 0 auto; padding: clamp(32px, 5vw, 64px) clamp(14px, 4vw, 58px) 60px; }
.analysis-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.analysis-heading h2, .section-heading h2 { margin: 0; font-size: clamp(25px, 3vw, 37px); line-height: 1.1; letter-spacing: -.025em; }
.clock-warning { margin-top: 20px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 13px; padding: 14px 17px; border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--line)); border-radius: 13px; background: var(--warning-bg); color: var(--warning); }
.clock-warning > span { font-size: 23px; }
.clock-warning strong { font-size: 13px; }
.clock-warning p { margin: 3px 0 0; line-height: 1.45; font-size: 12px; }
.stats-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 11px; }
.stat-card { min-height: 112px; padding: 16px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow-soft); }
.stat-card span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.stat-card strong { margin-top: auto; font-size: clamp(24px, 2.6vw, 34px); font-variant-numeric: tabular-nums; }
.stat-card small { margin-top: 3px; color: var(--muted); line-height: 1.4; }
.period-card { grid-column: span 2; }
.period-card strong { font-size: clamp(16px, 1.8vw, 23px); }
.critical-stat strong { color: var(--critical); }
.warning-stat strong { color: var(--warning); }
.quality-panel { margin-top: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.quality-panel summary { display: flex; align-items: center; gap: 8px; padding: 12px 15px; cursor: pointer; font-size: 13px; font-weight: 760; }
.quality-panel ul { margin: 0; padding: 4px 20px 17px 38px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.quality-panel li + li { margin-top: 7px; }
.count-badge { min-width: 24px; padding: 3px 7px; border-radius: 999px; color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, var(--surface)); text-align: center; font-size: 11px; }

.panel { margin-top: 22px; padding: clamp(18px, 3vw, 30px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-heading > span { color: var(--muted); font-size: 12px; }
.chart-toolbar { margin-top: 20px; display: grid; grid-template-columns: minmax(200px, 300px) minmax(170px, 230px) minmax(260px, 1fr); gap: 12px; align-items: start; }
.chart-toolbar label > span, .custom-range label > span, .filter-grid label > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
input, select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface-2); }
.custom-range { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(190px, 1fr)) auto; gap: 9px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.custom-range[hidden] { display: none; }
.custom-range .secondary-button { min-height: 42px; }
.range-error { grid-column: 1 / -1; margin: 0; color: var(--critical); font-size: 11px; line-height: 1.4; }
.metric-picker { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.metric-picker summary { height: 40px; display: flex; align-items: center; padding: 0 12px; cursor: pointer; color: var(--ink); font-size: 12px; font-weight: 750; }
.metric-list { max-height: 230px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 10px; overflow: auto; padding: 4px 12px 13px; border-top: 1px solid var(--line); }
.metric-list label { display: flex; align-items: center; gap: 7px; padding: 5px 0; color: var(--muted); font-size: 11px; cursor: pointer; }
.metric-list input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--teal); }
.chart-help, .section-intro { color: var(--muted); font-size: 11px; line-height: 1.5; }
.marker-key { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.marker-swatch { width: 18px; border-top: 2px dashed var(--critical); }
.chart-wrap { min-height: 430px; margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
#chart { width: 100%; min-height: 430px; }
.chart-empty { padding: 45px 20px; text-align: center; color: var(--muted); }
.uplot { font-family: inherit !important; }
.uplot, .uplot .u-wrap { background: var(--surface); }
.uplot .u-legend { color: var(--ink); font-size: 11px; }
.uplot .u-label { color: var(--ink); }
.uplot .u-value { color: var(--muted); }
.uplot .u-cursor-x, .uplot .u-cursor-y { border-color: var(--muted) !important; }

.filter-grid { margin-top: 20px; display: grid; grid-template-columns: 1fr 1.25fr 1.25fr 1fr 1fr auto; gap: 9px; align-items: end; }
.subsection { margin-top: 28px; }
.subsection h3 { margin: 0 0 11px; font-size: 16px; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: var(--surface-2); font-size: 9px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.code-cell { color: var(--teal); font-weight: 900; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; padding: 4px 8px; border-radius: 999px; font-size: 9px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.badge.critical { color: var(--critical); background: var(--critical-bg); }
.badge.warning { color: var(--warning); background: var(--warning-bg); }
.badge.active { color: var(--critical); background: var(--critical-bg); }
.badge.cleared { color: var(--ok); background: var(--ok-bg); }
.badge.outside, .badge.unknown { color: var(--muted); background: var(--surface-3); }
.occurrence-list { display: grid; gap: 10px; }
.occurrence-card { border: 1px solid var(--line); border-radius: 13px; overflow: clip; background: var(--surface); }
.occurrence-card > summary { list-style: none; display: grid; grid-template-columns: 68px minmax(180px, 1.6fr) minmax(160px, .8fr) auto auto; gap: 12px; align-items: center; padding: 13px 15px; cursor: pointer; }
.occurrence-card > summary::-webkit-details-marker { display: none; }
.occurrence-title { min-width: 0; font-weight: 720; line-height: 1.35; }
.occurrence-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.inspect-button { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; color: var(--teal); background: var(--surface-2); font-size: 10px; font-weight: 800; }
.chevron { color: var(--muted); transition: transform .18s ease; }
.occurrence-card[open] .chevron { transform: rotate(180deg); }
.occurrence-detail { padding: 19px; border-top: 1px solid var(--line); background: var(--surface-2); }
.bilingual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.language-card { padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.language-card h4 { margin: 0 0 8px; color: var(--teal); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.language-card strong { display: block; line-height: 1.4; }
.language-card p { margin: 7px 0 0; color: var(--muted); line-height: 1.55; font-size: 12px; }
.detail-metadata { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; color: var(--muted); font-size: 11px; }
.captured { margin-top: 15px; }
.captured h4, .guidance h4 { margin: 0 0 8px; font-size: 12px; }
.parameter-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 0; }
.parameter-list div { display: flex; gap: 5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-family: "Cascadia Mono", Consolas, monospace; font-size: 10px; }
.parameter-list dt { color: var(--muted); }
.parameter-list dd { margin: 0; }
.guidance { margin-top: 18px; }
.cause-list { display: grid; gap: 8px; }
.cause-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.cause-card summary { padding: 11px 13px; cursor: pointer; font-size: 12px; font-weight: 740; }
.cause-body { padding: 0 13px 13px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.cause-translation { margin-bottom: 8px; }
.cause-body ol { margin: 7px 0 0; padding-left: 21px; }
.cause-body li + li { margin-top: 6px; }
.safety-notice { margin-top: 17px; padding: 12px 14px; border-left: 3px solid var(--warning); border-radius: 0 9px 9px 0; color: var(--warning); background: var(--warning-bg); font-size: 11px; line-height: 1.5; }
.empty-state { padding: 30px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.event-table-wrap { max-height: 390px; }
#showMoreEvents { margin-top: 12px; }

footer { max-width: 1540px; margin: 0 auto; padding: clamp(32px, 4vw, 48px) clamp(18px, 4vw, 58px) 40px; color: var(--muted); font-size: 11px; line-height: 1.6; }
footer p { max-width: 1120px; margin: 6px 0; }
.partner-strip { margin: 0 0 18px; padding: 0 0 22px; border-bottom: 1px solid var(--line); }
.partner-strip h2 { margin: 0 0 10px; color: var(--muted); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.partner-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.partner-card { min-width: 0; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: color-mix(in srgb, var(--surface) 82%, transparent); text-decoration: none; transition: border-color .18s ease, background .18s ease; }
.partner-card:hover { border-color: color-mix(in srgb, var(--teal) 55%, var(--line)); background: color-mix(in srgb, var(--teal) 4%, var(--surface)); }
.partner-card-copy { min-width: 0; display: grid; gap: 3px; }
.partner-card-copy strong { color: var(--teal); font-size: 13px; }
.partner-card-copy > span { color: var(--muted); font-size: 11px; line-height: 1.45; }
.partner-card-arrow { flex: none; color: var(--teal); font-size: 18px; line-height: 1; }

@media (max-width: 1180px) {
  .hero { grid-template-columns: 1fr 460px; }
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chart-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-toolbar .metric-picker { grid-column: span 2; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .hero-copy { max-width: 780px; }
  .file-card { max-width: none; justify-self: stretch; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .period-card { grid-column: span 2; }
  .chart-toolbar { grid-template-columns: 1fr; }
  .chart-toolbar .metric-picker { grid-column: auto; }
  .occurrence-card > summary { grid-template-columns: 55px minmax(0, 1fr) auto; }
  .occurrence-time { grid-column: 2; }
  .inspect-button { grid-column: 2; width: max-content; }
  .occurrence-card .chevron { grid-column: 3; grid-row: 1; }
}

@media (max-width: 620px) {
  .site-header { min-height: 62px; padding: 10px 13px; }
  .brand-mark { width: 37px; height: 37px; }
  .brand small { display: none; }
  .language-switch button { min-width: 35px; padding-inline: 5px; }
  .hero { padding: 35px 14px 42px; }
  h1 { font-size: clamp(34px, 12vw, 49px); }
  .trust-list { display: grid; gap: 8px; }
  .file-card { padding: 16px; border-radius: 17px; }
  .drop-zone { min-height: 215px; padding: 18px; }
  .analysis { padding: 32px 10px 45px; }
  .analysis-heading, .section-heading { align-items: flex-start; }
  .analysis-heading { flex-direction: column; }
  .stats-grid { gap: 8px; }
  .stat-card { min-height: 102px; padding: 13px; }
  .panel { padding: 16px 12px; border-radius: 14px; }
  .section-heading h2 { font-size: 25px; }
  .chart-wrap, #chart { min-height: 350px; }
  .custom-range { grid-template-columns: 1fr; }
  .custom-range .secondary-button { width: 100%; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid button { width: 100%; }
  .metric-list { grid-template-columns: 1fr; }
  .bilingual-grid { grid-template-columns: 1fr; }
  .occurrence-card > summary { padding: 12px 10px; gap: 8px; }
  .occurrence-detail { padding: 12px 10px; }
  .table-scroll { margin-inline: -3px; }
  th, td { padding: 10px; }
  .partner-grid { grid-template-columns: 1fr; }
  footer { padding-top: 28px; }
  .partner-card { min-height: 66px; padding: 12px 14px; }
}

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

@media print {
  .site-header, .hero, .chart-actions, .filter-grid, .inspect-button, #showMoreEvents, footer { display: none !important; }
  :root { --bg: white; --surface: white; --surface-2: #f8f8f8; --ink: black; --muted: #555; --line: #ccc; }
  .analysis { padding: 0; }
  .panel, .stat-card { box-shadow: none; break-inside: avoid; }
}
