/* Doctor Check API: clinical, calm, readable. Light + dark via prefers-color-scheme. */
:root {
    --bg: #f6f8f8;
    --surface: #ffffff;
    --surface-2: #f1f5f5;
    --border: #dfe6e6;
    --text: #122022;
    --muted: #5d6f71;
    --accent: #0f766e;
    --accent-2: #115e59;
    --accent-soft: #ccfbf1;
    --critical: #9f1239;
    --error: #dc2626;
    --warning: #b45309;
    --info: #2563eb;
    --critical-soft: #ffe4e6;
    --error-soft: #fee2e2;
    --warning-soft: #fef3c7;
    --info-soft: #dbeafe;
    --grade-A: #15803d; --grade-B: #0f766e; --grade-C: #ca8a04; --grade-D: #ea580c; --grade-F: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 32, 34, .06), 0 4px 16px rgba(16, 32, 34, .05);
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c1415;
        --surface: #121d1f;
        --surface-2: #182628;
        --border: #25383a;
        --text: #e4eeee;
        --muted: #93a7a9;
        --accent: #2dd4bf;
        --accent-2: #5eead4;
        --accent-soft: #134e4a;
        --critical: #fb7185;
        --error: #f87171;
        --warning: #fbbf24;
        --info: #60a5fa;
        --critical-soft: #4c0519;
        --error-soft: #450a0a;
        --warning-soft: #451a03;
        --info-soft: #172554;
        --grade-A: #4ade80; --grade-B: #2dd4bf; --grade-C: #facc15; --grade-D: #fb923c; --grade-F: #f87171;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.muted { color: var(--muted); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: 4px; }
nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
nav a:hover { background: var(--surface-2); text-decoration: none; }
nav a.active { color: var(--accent); background: var(--accent-soft); }
.footer { color: var(--muted); font-size: 13px; padding: 40px 16px 32px; }

/* ---------- hero */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin: 32px 0 24px; flex-wrap: wrap; }
.hero h1 { font-size: 30px; letter-spacing: -.02em; }
.hero.compact h1 { font-size: 26px; }
.lede { color: var(--muted); max-width: 720px; margin: 8px 0 0; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #042f2e; } }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn .spinner { display: none; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.busy .spinner { display: inline-block; }
.btn.busy { opacity: .85; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- panels / form */
.panels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .panels { grid-template-columns: 1fr; } }
.panel, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.panel-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.panel-head h2 { font-size: 16px; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.panel-head .switch { margin-left: auto; }
.step { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input:not([type]), input[type=url], input[type=password], input[type=number], input[type=search], select, textarea {
    display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font: inherit; font-weight: 400;
}
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 160px; }
.row > .grow-0 { flex: 0 1 180px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .45; }

.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 10px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 6px; border-radius: 7px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pane { display: none; }
.pane.active { display: block; }

.drop { position: relative; border: 1.5px dashed var(--border); border-radius: 10px; padding: 26px 14px; text-align: center; cursor: pointer; background: var(--surface-2); font-weight: 500; }
.drop:hover, .drop.over { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-text { color: var(--muted); font-size: 13px; }
.drop.has-file .drop-text { color: var(--accent); font-weight: 600; }

.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 22px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }

.options { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px; }
.options summary { cursor: pointer; font-weight: 600; }
.options .row { margin-top: 12px; }
.submit-row { display: flex; align-items: center; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.alert { background: var(--error-soft); color: var(--error); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-weight: 500; }
.validation-summary-valid { display: none; }

.recent { margin-top: 36px; }
.recent h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.recent ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.recent a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); }
.recent a:hover { border-color: var(--accent); text-decoration: none; }
.recent-title { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grade { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.grade-A { background: var(--grade-A); } .grade-B { background: var(--grade-B); } .grade-C { background: var(--grade-C); } .grade-D { background: var(--grade-D); } .grade-F { background: var(--grade-F); }

/* ---------- report */
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 28px 0 20px; flex-wrap: wrap; }
.report-head h1 { font-size: 28px; letter-spacing: -.02em; margin-top: 6px; overflow-wrap: anywhere; }
.report-head p { margin: 4px 0 0; font-size: 13px; }
.ver { font-size: 15px; color: var(--muted); font-weight: 500; }
.back { font-size: 13px; }
.actions { display: flex; gap: 8px; }

.vitals { display: grid; grid-template-columns: minmax(280px, 1.1fr) minmax(260px, 1fr) minmax(260px, 1fr); gap: 16px; align-items: stretch; }
.vitals .score-card { grid-row: span 1; }
.vitals .sev-tiles, .vitals .cats { grid-column: span 2; }
@media (max-width: 1000px) { .vitals { grid-template-columns: 1fr; } .vitals .sev-tiles, .vitals .cats { grid-column: auto; } }

.score-card { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); --g: var(--grade-F); }
.grade-bg-A { --g: var(--grade-A); } .grade-bg-B { --g: var(--grade-B); } .grade-bg-C { --g: var(--grade-C); } .grade-bg-D { --g: var(--grade-D); } .grade-bg-F { --g: var(--grade-F); }
.ring { width: 118px; height: 118px; flex: none; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 11; }
.ring-value { fill: none; stroke: var(--g); stroke-width: 11; stroke-linecap: round; }
.ring-score { font-size: 32px; font-weight: 800; text-anchor: middle; fill: var(--text); }
.ring-sub { font-size: 12px; text-anchor: middle; fill: var(--muted); }
.grade-big { font-size: 22px; font-weight: 800; color: var(--g); }
.verdict { margin: 4px 0 0; color: var(--muted); }

.sev-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 560px) { .sev-tiles { grid-template-columns: repeat(2, 1fr); } }
.sev-tile { display: flex; flex-direction: column; justify-content: center; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 16px; text-align: left; cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow); border-top: 4px solid var(--c); transition: opacity .15s; }
.sev-tile.off { opacity: .35; }
.sev-count { display: block; font-size: 30px; font-weight: 800; color: var(--c); line-height: 1.1; }
.sev-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.sev-tile.sev-critical { --c: var(--critical); } .sev-tile.sev-error { --c: var(--error); } .sev-tile.sev-warning { --c: var(--warning); } .sev-tile.sev-info { --c: var(--info); }

.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.sources ul { list-style: none; padding: 0; margin: 0; }
.sources li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 14px; flex-wrap: wrap; }
.sources .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; transform: translateY(-1px); }
.sources .ran .dot { background: var(--accent); }
.sources .skipped strong { color: var(--muted); }
.notes { margin-top: 10px !important; padding-top: 10px !important; border-top: 1px solid var(--border); }
.notes li { font-size: 13px; color: var(--muted); display: block !important; }

.cats .cat-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 5px 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.cat-name { font-size: 13px; font-weight: 600; }
.cat-bar { height: 8px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.cat-bar span { display: block; height: 100%; background: var(--accent); border-radius: 8px; }
.cat-count { font-size: 13px; color: var(--muted); text-align: right; }
.cat-row.on .cat-name { color: var(--accent); }

.findings { margin-top: 24px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; position: sticky; top: 58px; background: var(--bg); padding: 10px 0; z-index: 5; }
.toolbar input[type=search] { flex: 1 1 260px; margin: 0; }
.toolbar select { width: auto; margin: 0; }
.seg { display: flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.seg a { padding: 5px 11px; border-radius: 7px; color: var(--muted); font-size: 13px; font-weight: 600; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg a:hover { text-decoration: none; color: var(--text); }

.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); }
.group > summary { padding: 12px 18px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 700; list-style: none; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.group[open] > summary::before { transform: rotate(90deg); }
.group-title { overflow-wrap: anywhere; }
.pill { background: var(--surface-2); color: var(--muted); font-size: 12px; padding: 1px 9px; border-radius: 20px; }
.finding-list { list-style: none; margin: 0; padding: 0 18px 8px; }
.finding { padding: 14px 0 14px 14px; border-top: 1px solid var(--border); border-left: 3px solid var(--c); margin-left: -2px; }
.finding[hidden] { display: none; }
.sev-border-critical { --c: var(--critical); } .sev-border-error { --c: var(--error); } .sev-border-warning { --c: var(--warning); } .sev-border-info { --c: var(--info); }
.finding-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.finding-title { font-size: 14.5px; }
.rule-id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.sev-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 20px; }
.sev-pill.sev-critical { background: var(--critical-soft); color: var(--critical); }
.sev-pill.sev-error { background: var(--error-soft); color: var(--error); }
.sev-pill.sev-warning { background: var(--warning-soft); color: var(--warning); }
.sev-pill.sev-info { background: var(--info-soft); color: var(--info); }
.tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; }
.msg { margin: 6px 0 4px; overflow-wrap: anywhere; }
.loc { display: inline-block; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.rx { margin: 8px 0 0; padding: 8px 12px; background: var(--accent-soft); border-radius: 8px; font-size: 13.5px; display: flex; gap: 8px; overflow-wrap: anywhere; }
.rx-mark { font-weight: 800; color: var(--accent); font-size: 15px; line-height: 1.3; }
.clean { text-align: center; padding: 40px; margin-top: 24px; }
.clean h2 { margin-bottom: 8px; }

/* ---------- rules */
.rules { margin-bottom: 16px; overflow-x: auto; }
.rules h2 { font-size: 18px; margin-bottom: 10px; }
.rules table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rules th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); }
.rules td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.rules td .muted { font-size: 13px; }
.rules tr:target { background: var(--accent-soft); }

@media print {
    .topbar, .toolbar, .actions, .back, .footer { display: none !important; }
    .group { break-inside: auto; box-shadow: none; }
    body { background: #fff; }
}
