:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --border: #d5d9e1;
    --accent: #1f6f43;
    --accent-dark: #17563a;
    --danger: #b42318;
    --radius: 8px;
    color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* author display rules (buttons, flex rows) must not defeat the hidden attribute */

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 28px 0 8px; }
a { color: var(--accent-dark); }
.muted { color: var(--muted); }
.wrap { overflow-wrap: anywhere; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px; background: var(--accent-dark); color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 20px; align-items: center; }
form.inline { display: inline; margin: 0; }
button.link {
    background: none; border: 0; padding: 0; color: #fff; font: inherit; cursor: pointer; text-decoration: underline;
}

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; margin-bottom: 20px;
}
.card.narrow { max-width: 420px; margin: 48px auto; }

label { display: block; margin-bottom: 14px; font-weight: 600; }
label.check { font-weight: 400; align-self: end; }
input[type=text], input[type=password], input[type=number], input:not([type]), select {
    display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff;
}
input[type=file] { display: block; margin-top: 6px; font-weight: 400; }

.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > label { flex: 1 1 220px; }
.row > .full { flex: 1 1 100%; margin: 0; }
.encrypt-option { margin: 4px 0 16px; }
.encrypt-option #encrypt-fields { margin-top: 10px; }
.download-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 0 0 12px; }
.download-form label { flex: 1 1 260px; max-width: 360px; }
.download-form .error { flex: 1 1 100%; margin: 0; }

fieldset.layout-choice { border: 0; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset.layout-choice legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
@media (max-width: 640px) { fieldset.layout-choice { grid-template-columns: 1fr; } }
label.choice { margin: 0; cursor: pointer; font-weight: 400; display: block; }
label.choice input { position: absolute; opacity: 0; }
.choice-body {
    display: flex; flex-direction: column; gap: 4px; height: 100%;
    border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: #fff;
}
.choice-body em { font-weight: 400; color: var(--muted); font-style: normal; }
.legend-hint { font-weight: 400; color: var(--muted); }

/* Miniature spreadsheets that show how each layout looks in Excel. */
.mini-sheet {
    display: block; margin-top: 8px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
    font: 12.5px/1.3 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: #fff;
}
.ms-row { display: grid; grid-template-columns: 24px 1.1fr 1.5fr .7fr 1fr; border-top: 1px solid #e6e9ef; }
.ms-row:first-child { border-top: 0; }
.ms-row > span { padding: 4px 8px; border-left: 1px solid #eef0f4; min-height: 25px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-row > span:first-child { border-left: 0; }
.ms-head > span { background: #e8f1ec; color: var(--accent-dark); font-weight: 700; }
.ms-n { background: #f3f4f7; color: var(--muted); text-align: center; padding: 4px 0 !important; font-size: 11px; }
.ms-head > .ms-n { background: #e8f1ec; }
.ms-num { text-align: right; }
.ms-row.g1 { background: #eef4ff; }
.ms-row.g2 { background: #fff7e6; }
.ms-row.first { border-top: 2px solid #98a2b3; }
.ms-head + .ms-row.first { border-top: 1px solid #e6e9ef; }
.ms-row > .ms-n { background: #f3f4f7; }
.ms-repeat { color: #9aa3b2; font-style: italic; }
.ms-empty {
    background: repeating-linear-gradient(135deg, transparent 0 4px, rgba(152, 162, 179, .28) 4px 5px);
}
.ms-caption { display: flex; gap: 8px; align-items: baseline; margin-top: 6px; font-size: .85rem; color: var(--muted); }
.ms-key { flex: none; padding: 0 8px; border: 1px solid var(--border); border-radius: 4px; font-size: .75rem; font-style: normal; }
.ms-key.ms-empty { color: var(--muted); }

label.choice input:checked + .choice-body { border-color: var(--accent); background: #eef7f1; }
label.choice input:focus-visible + .choice-body { outline: 3px solid #9ad1b2; }

button, a.button {
    display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 6px;
    padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button:hover, a.button:hover { background: var(--accent-dark); }
button:disabled { opacity: .55; cursor: default; }
button.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: #eef0f4; }
button.danger { color: var(--danger); }
.actions { display: flex; gap: 10px; margin-top: 8px; }

.upload-status { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
progress { width: 240px; height: 14px; accent-color: var(--accent); }
.error { color: var(--danger); }
.success { color: #067647; font-weight: 600; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #eef0f4; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.num { text-align: right; white-space: nowrap; }
.card table { border: 0; }

.badge {
    display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
    background: #e4e7ec; color: #344054;
}
.badge.running { background: #dbeafe; color: #1e40af; }
.badge.queued { background: #fef3c7; color: #92400e; }
.badge.succeeded { background: #d1fadf; color: #05603a; }
.badge.failed { background: #fee4e2; color: var(--danger); }

.status-line { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 16px 0 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------------------------------------------------------------- navigation, intro text */
.topbar nav a.active { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
.lead { color: var(--muted); max-width: 70ch; margin: -4px 0 18px; }
main.wide { max-width: 1480px; }
.badge.cancelled, .badge.expired { background: #e4e7ec; color: #475467; }

/* ---------------------------------------------------------------- file choosers */
.two-files { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two-files { grid-template-columns: 1fr; } }
.file-field { margin-bottom: 8px; }
label.dropzone {
    position: relative; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center;
    min-height: 118px; padding: 16px; text-align: center; cursor: pointer; font-weight: 400;
    border: 2px dashed var(--border); border-radius: var(--radius); background: #fafbfc;
    transition: border-color .12s, background .12s;
}
label.dropzone:hover, label.dropzone.dragging { border-color: var(--accent); background: #eef7f1; }
label.dropzone.has-file { border-style: solid; border-color: var(--accent); background: #f4faf6; }
label.dropzone:focus-within { outline: 3px solid #9ad1b2; }
.dz-label { font-weight: 700; }
.dz-hint { color: var(--muted); font-size: .88rem; }
.dz-chosen { margin-top: 6px; font-size: .9rem; overflow-wrap: anywhere; }
label.dropzone.has-file .dz-chosen { color: var(--accent-dark); font-weight: 600; }
label.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; margin: 0; }

/* ---------------------------------------------------------------- results explorer */
.explorer { margin-top: 8px; }
.explorer button, .explorer select, .explorer input { font: inherit; }
dl.facts.compact { margin-top: 8px; }

.ex-banner { background: #f2f4f7; border: 1px solid var(--border); border-left: 4px solid #98a2b3; border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; }
.ex-banner.warn { background: #fffaeb; border-color: #fedf89; border-left-color: #f79009; }
.ex-allgood { grid-column: 1 / -1; background: #ecfdf3; border: 1px solid #abefc6; border-radius: var(--radius); padding: 18px 20px; color: #05603a; font-size: 1.05rem; }

.ex-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
    display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px;
}
button.tile.clickable { cursor: pointer; font-weight: 400; }
button.tile.clickable:hover { background: #f8fafc; border-color: #98a2b3; }
button.tile.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #f4faf6; }
.tile-value { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.tile-label { color: var(--muted); font-size: .88rem; }
.tile-bad .tile-value { color: var(--danger); }
.tile-warn .tile-value { color: #b54708; }
.tile-good .tile-value { color: #067647; }

.ex-facets { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; margin-bottom: 4px; align-items: start; }
.facet-panel { margin: 0 0 8px; padding: 14px 16px; }
.facet-panel h3, .section-table h3 { margin: 0 0 8px; font-size: .95rem; }
ul.facet-list { list-style: none; margin: 0; padding: 0; }
button.facet {
    display: grid; grid-template-columns: 1fr auto; gap: 0 10px; width: 100%; text-align: left; padding: 5px 8px; margin: 1px 0;
    background: none; color: var(--text); border: 1px solid transparent; border-radius: 6px; font-weight: 400; cursor: pointer;
}
button.facet:hover { background: #f2f4f7; }
button.facet.active { background: #eef7f1; border-color: var(--accent); }
.facet-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.facet-bar { grid-column: 1 / -1; height: 4px; background: #eef0f4; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.facet-bar > span { display: block; height: 100%; background: #7bb592; border-radius: 2px; }
button.link-button { background: none; border: 0; padding: 2px 4px; color: var(--accent-dark); font-weight: 400; text-decoration: underline; cursor: pointer; }
button.link-button:hover { background: none; color: var(--accent); }

.section-table { grid-column: 1 / -1; padding: 14px 16px; margin-bottom: 8px; }
.section-table table { font-size: .92rem; }
.section-table td, .section-table th { padding: 5px 10px; }
.section-table tr.active { background: #eef7f1; }
button.facet-link { background: none; border: 0; padding: 0; color: var(--accent-dark); font-weight: 600; cursor: pointer; text-align: left; }
button.facet-link:hover { background: none; text-decoration: underline; }
td.good { color: #067647; }

.ex-toolbar { padding: 14px 16px; margin-bottom: 8px; }
.ex-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.ex-row + .ex-row { margin-top: 12px; }
.ex-field { display: flex; flex-direction: column; gap: 3px; margin: 0; font-size: .82rem; color: var(--muted); font-weight: 600; flex: 0 1 190px; min-width: 150px; }
.ex-field.ex-search { flex: 1 1 280px; }
.ex-field input, .ex-field select { margin: 0; padding: 7px 9px; color: var(--text); font-weight: 400; }
.ex-row-groups { align-items: center; padding-top: 12px; border-top: 1px solid var(--border); }
.ex-grouplabel { font-weight: 700; font-size: .9rem; }
.ex-spacer { flex: 1 1 auto; }
.segments { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
button.segment { background: #fff; color: var(--text); border: 0; border-right: 1px solid var(--border); border-radius: 0; padding: 7px 12px; font-weight: 500; font-size: .92rem; }
button.segment:last-child { border-right: 0; }
button.segment:hover { background: #f2f4f7; }
button.segment.active { background: var(--accent); color: #fff; }
.ex-hint { margin: 10px 0 0; min-height: 1.3em; font-size: .88rem; }

.ex-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
button.chip { background: #eef7f1; color: var(--accent-dark); border: 1px solid #b7dcc5; border-radius: 999px; padding: 2px 10px; font-weight: 400; font-size: .86rem; }
button.chip:hover { background: #e0f0e6; }
.chip-label { font-weight: 700; }

.ex-results { transition: opacity .12s; }
.ex-results.loading { opacity: .5; pointer-events: none; }
.ex-resultsbar { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.ex-count { font-weight: 600; }
.ex-pagesize { margin: 0; font-weight: 400; color: var(--muted); font-size: .88rem; }
.ex-pagesize select { display: inline-block; width: auto; margin: 0; padding: 3px 6px; }
.ex-empty { text-align: center; color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap table { border: 0; border-radius: 0; }
table.ex-table { font-size: .9rem; }
table.ex-table th, table.ex-table td { padding: 6px 10px; }
table.ex-table th { position: sticky; top: 0; white-space: nowrap; }
table.ex-table td.msg { min-width: 360px; overflow-wrap: anywhere; }
table.ex-table td.val { max-width: 320px; overflow-wrap: anywhere; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; }
td.val-a { background: #fef3f2; }
td.val-b { background: #ecfdf3; }
table.ex-table code { font-size: .88em; background: #f2f4f7; padding: 0 4px; border-radius: 3px; overflow-wrap: anywhere; }
table.ex-table tr.row-warning td:first-child { box-shadow: inset 3px 0 0 #f79009; }
.muted { color: var(--muted); }
mark { background: #fff1b8; color: inherit; padding: 0 1px; border-radius: 2px; }
button.sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
button.sort:hover { background: none; text-decoration: underline; }
button.sort.on { color: var(--accent-dark); }

.pill { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #e4e7ec; color: #344054; white-space: nowrap; }
.pill.sev-error { background: #fee4e2; color: var(--danger); }
.pill.sev-warning { background: #fef0c7; color: #93370d; }
.pill.chg-mod { background: #fef0c7; color: #93370d; }
.pill.chg-a { background: #fee4e2; color: var(--danger); }
.pill.chg-b { background: #d1fadf; color: #05603a; }
td.chg-mod { color: #93370d; }
td.chg-a { color: var(--danger); }
td.chg-b { color: #067647; }
.pills { display: inline-flex; flex-wrap: wrap; gap: 4px; }

tr.group-row { cursor: default; }
tr.group-row.open { background: #f8fafc; }
td.twisty-cell { width: 34px; padding-right: 0; }
button.twisty { background: none; border: 0; color: var(--muted); padding: 2px 6px; font-size: .8rem; font-weight: 400; }
button.twisty:hover { background: #eef0f4; color: var(--text); }
td.count-cell { width: 90px; }
.count-bar { display: block; height: 4px; background: #eef0f4; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.count-bar > span { display: block; height: 100%; background: #98a2b3; }
td.group-title { overflow-wrap: anywhere; }
code.rule-tag { background: #e8f1ec; color: var(--accent-dark); }
.group-example { color: var(--muted); font-size: .84rem; margin-top: 2px; max-width: 110ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.sub-row > td { background: #f8fafc; padding: 0; }
.sub-body { padding: 10px 14px 12px 44px; }
.sub-body table { font-size: .86rem; }
.sub-actions { display: flex; gap: 8px; margin-top: 10px; }
.sub-actions button { padding: 5px 12px; font-size: .88rem; }

.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.pager button { padding: 6px 12px; }
.pager-info { color: var(--muted); padding: 0 8px; }

/* ---------------------------------------------------------------- language switch */
.topbar-end { display: flex; align-items: center; gap: 24px; }
.lang-switch { display: inline-flex; margin: 0; border: 1px solid rgba(255, 255, 255, .55); border-radius: 6px; overflow: hidden; }
.lang-switch button {
    background: transparent; color: #fff; border: 0; border-radius: 0; padding: 3px 9px;
    font: inherit; font-size: .82rem; font-weight: 600; letter-spacing: .03em; cursor: pointer;
}
.lang-switch button + button { border-left: 1px solid rgba(255, 255, 255, .55); }
.lang-switch button:hover { background: rgba(255, 255, 255, .16); }
.lang-switch button.on { background: #fff; color: var(--accent-dark); }
@media (max-width: 720px) { .topbar { flex-wrap: wrap; gap: 8px; } .topbar-end { flex-wrap: wrap; gap: 12px; } }

/* ---------------------------------------------------------------- what happens to the user's data */
.data-note {
    display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 24px; padding: 10px 14px; font-size: .9rem;
    color: #344054; background: #ecf6f0; border: 1px solid #c4e1d1; border-radius: var(--radius);
}
.data-note strong { color: var(--accent-dark); }
.once-note { margin: -4px 0 12px; }
