:root {
    --seda-blue: #087abb;
    --seda-blue-dark: #075f96;
    --seda-green: #078151;
    --ink: #173d33;
    --muted: #667871;
    --line: #d4e8e1;
    --surface: #ffffff;
    --background: #f2f8f6;
    --shadow: 0 18px 45px rgba(8, 71, 56, 0.12);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--background);
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    background-color: var(--background);
    background-image:
        linear-gradient(rgba(7, 122, 187, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(7, 122, 187, 0.035) 1px, transparent 1px);
    background-size: 36px 36px;
}

a { color: inherit; }

.topbar {
    min-height: 74px;
    padding: 12px clamp(20px, 4vw, 54px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: white;
    background: linear-gradient(105deg, var(--seda-blue-dark), #138dcc);
    box-shadow: 0 5px 18px rgba(6, 84, 128, 0.2);
}

.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand-logo { display: block; width: 108px; height: 54px; object-fit: contain; }
.brand-mark {
    width: 42px; height: 42px; display: grid; place-items: center;
    border: 2px solid white; border-radius: 7px; font: 800 29px/1 Georgia, serif;
    box-shadow: inset 0 0 0 3px rgba(255,255,255,.15);
}
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 15px; letter-spacing: .02em; text-transform: uppercase; }
.brand-copy small { opacity: .88; font-weight: 600; }
.environment-pill { padding: 9px 14px; border: 1px solid rgba(255,255,255,.38); border-radius: 999px; font-size: 13px; font-weight: 700; }

main { min-height: calc(100vh - 144px); }
.login-shell { width: min(1120px, calc(100% - 36px)); margin: 0 auto; padding: clamp(48px, 8vw, 100px) 0; display: grid; grid-template-columns: 1.05fr .85fr; gap: clamp(36px, 7vw, 92px); align-items: center; }
.login-intro h1 { max-width: 650px; margin: 8px 0 18px; font-size: clamp(38px, 5vw, 64px); line-height: 1.02; letter-spacing: -.045em; }
.login-intro > p:not(.eyebrow) { max-width: 610px; color: var(--muted); font-size: 18px; line-height: 1.7; }
.eyebrow { margin: 0; color: var(--seda-blue-dark); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.trust-list { display: flex; flex-wrap: wrap; gap: 10px; padding: 0; margin: 28px 0 0; list-style: none; }
.trust-list li { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.64); color: #41665c; font-size: 13px; font-weight: 650; }

.login-card, .table-card, .filters-card { background: rgba(255,255,255,.96); border: 1px solid var(--line); box-shadow: var(--shadow); }
.login-card { padding: clamp(28px, 4vw, 44px); border-radius: 18px; }
.card-heading h2 { margin: 8px 0 8px; font-size: 31px; }
.card-heading > p:last-child { margin: 0 0 26px; color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 10px; }
.login-form label, .filters-card label { font-size: 13px; font-weight: 750; }
input, select { width: 100%; min-height: 46px; margin-top: 7px; padding: 10px 12px; border: 1px solid #bfd8cf; border-radius: 8px; background: white; color: var(--ink); font: inherit; }
input:focus, select:focus { outline: 3px solid rgba(8,122,187,.14); border-color: var(--seda-blue); }
button, .secondary-button { min-height: 46px; border: 0; border-radius: 8px; padding: 11px 18px; background: var(--seda-blue); color: white; font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; }
.download-button { display: inline-flex; min-height: 46px; align-items: center; padding: 11px 18px; border-radius: 8px; background: var(--seda-blue); color: white; font-weight: 800; text-decoration: none; }
.login-form button { margin-top: 12px; box-shadow: 0 8px 18px rgba(8,122,187,.22); }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .58; }
.help-text { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; }
.notice { margin: 0 0 20px; padding: 12px 14px; border-radius: 8px; font-size: 14px; line-height: 1.45; }
.notice--info { color: #075783; background: #eaf6fc; border: 1px solid #b8def1; }
.notice--error { color: #8c2e2e; background: #fff0f0; border: 1px solid #f1c6c6; }
.notice--success { color: #116342; background: #e9f8f1; border: 1px solid #b9e5d1; }

.setup-shell { width: min(620px, calc(100% - 28px)); margin: 0 auto; padding: 64px 0 90px; }
.setup-card { padding: clamp(26px, 5vw, 44px); background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.setup-card h1 { margin: 8px 0 10px; font-size: clamp(30px, 5vw, 42px); letter-spacing: -.035em; }
.setup-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.stack-form { display: grid; gap: 10px; margin-top: 24px; }
.stack-form label { font-size: 13px; font-weight: 750; }
.stack-form button { margin-top: 12px; }
.setup-card code { padding: 2px 5px; border-radius: 4px; background: rgba(0,0,0,.06); }

.admin-shell { width: min(1280px, calc(100% - 36px)); margin: 0 auto; padding: 48px 0 90px; }
.admin-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.admin-header h1 { margin: 6px 0; font-size: clamp(34px, 4vw, 50px); letter-spacing: -.04em; }
.admin-header p:last-child { margin: 0; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.metric-card { position: relative; min-height: 154px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.96); box-shadow: 0 8px 25px rgba(8,71,56,.07); }
.metric-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.metric-card strong { display: block; margin-bottom: 7px; font-size: 22px; }
.metric-card small { color: var(--muted); }
.status-dot { position: absolute; top: 20px; right: 20px; width: 11px; height: 11px; border-radius: 50%; }
.status-dot--ok { background: #15a168; box-shadow: 0 0 0 5px #e1f5ec; }
.status-dot--error { background: #d84c4c; box-shadow: 0 0 0 5px #fae9e9; }
.admin-card { margin-top: 22px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.97); box-shadow: 0 10px 30px rgba(8,71,56,.08); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin: 5px 0 0; font-size: 25px; }
.search-form { display: flex; align-items: end; gap: 8px; min-width: min(100%, 440px); }
.search-form input { margin: 0; }
.table-scroll { width: 100%; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { padding: 12px 10px; color: white; background: var(--seda-blue); text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.admin-table td { padding: 12px 10px; border-bottom: 1px solid #dce9e4; vertical-align: middle; }
.admin-table tbody tr:hover { background: #f4faf8; }
.create-account-form { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(150px, 1fr) auto; gap: 7px; align-items: center; min-width: 470px; }
.create-account-form input { min-height: 38px; margin: 0; padding: 7px 9px; }
.create-account-form button { min-height: 38px; padding: 8px 12px; font-size: 12px; }
.account-badge { display: inline-block; padding: 6px 9px; border-radius: 999px; color: #116342; background: #e8f7f0; font-size: 12px; font-weight: 750; }
.compact-empty { min-height: 160px; padding: 28px 20px; }
.muted-copy { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.results-shell { width: min(1220px, calc(100% - 36px)); margin: 0 auto; padding: 54px 0 80px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin: 7px 0; font-size: clamp(34px, 4vw, 48px); letter-spacing: -.03em; }
.page-heading p:last-child { margin: 0; max-width: 780px; color: var(--muted); }
.secondary-button { min-height: auto; white-space: nowrap; background: white; color: var(--seda-blue-dark); border: 1px solid #b9d9e9; }
.filters-card { display: grid; grid-template-columns: 1.4fr repeat(2, 1fr) auto; gap: 14px; align-items: end; padding: 20px; border-radius: 14px; box-shadow: 0 8px 24px rgba(8,71,56,.08); }
.table-card { margin-top: 22px; border-radius: 14px; overflow: hidden; }
.status-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.status-tab { flex: 1; padding: 14px 18px; font-size: 13px; font-weight: 750; text-align: center; border-right: 1px solid var(--line); }
.status-tab:last-child { border-right: 0; }
.status-tab--complete { color: var(--seda-blue); }
.status-tab--partial { color: #c87314; }
.status-tab--empty { color: #788c85; }
.empty-state { min-height: 290px; padding: 50px 24px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: #e8f6f1; color: var(--seda-green); font-size: 25px; font-weight: 900; }
.empty-state h2 { margin: 16px 0 7px; }
.empty-state p { max-width: 580px; margin: 0; color: var(--muted); line-height: 1.6; }
.results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table th { padding: 13px 12px; color: white; background: var(--seda-blue); text-align: left; font-size: 11px; letter-spacing: .055em; text-transform: uppercase; }
.results-table td { padding: 13px 12px; border-bottom: 1px solid #dce9e4; vertical-align: middle; }
.results-table tbody tr:hover { background: #f4faf8; }
.results-table td strong, .results-table td small { display: block; }
.results-table td small { margin-top: 3px; color: var(--muted); }
.result-badge { display: inline-flex; padding: 6px 9px; border-radius: 999px; color: #08734a; background: #e4f7ef; font-size: 11px; font-weight: 800; white-space: nowrap; }
.result-badge--partial { color: #9b5308; background: #fff0dc; }
.view-result { display: inline-flex; padding: 8px 12px; border-radius: 7px; color: white; background: var(--seda-blue); font-weight: 800; text-decoration: none; }
.detail-actions { display: flex; gap: 9px; }
.report-sheet { padding: clamp(20px, 4vw, 42px); border: 1px solid var(--line); border-radius: 15px; background: #f9fdfb; box-shadow: var(--shadow); }
.report-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 2px solid var(--seda-blue); }
.report-header h2 { margin: 5px 0 0; font-size: 28px; }
.report-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 22px 0; padding: 1px; background: var(--line); }
.report-meta div { padding: 12px; background: white; }
.report-meta dt, .study-meta dt { margin-bottom: 5px; color: #4f766b; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.report-meta dd, .study-meta dd { margin: 0; }
.study-list { display: grid; gap: 22px; }
.study-card { overflow: hidden; border: 1px solid #c8e1d8; border-radius: 10px; background: white; break-inside: avoid; }
.study-meta { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.study-meta div { padding: 11px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.study-meta div:last-child { border-right: 0; }
.study-values { display: grid; grid-template-columns: 1.45fr 1fr; min-height: 140px; }
.study-values > div { padding: 0 14px 14px; }
.study-values > div + div { background: #f2faf6; border-left: 1px solid var(--line); }
.study-values h3 { margin: 0 -14px 13px; padding: 9px 14px; color: white; background: var(--seda-blue); font-size: 11px; letter-spacing: .055em; text-transform: uppercase; }
.study-values > div + div h3 { background: var(--seda-green); }
.study-values pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #2c3834; font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }

.footer { min-height: 70px; padding: 18px clamp(20px, 4vw, 54px); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #aac5bc; background: #082c21; font-size: 12px; }

@media (max-width: 820px) {
    .login-shell { grid-template-columns: 1fr; padding-top: 48px; }
    .login-intro h1 { font-size: clamp(36px, 10vw, 54px); }
    .filters-card { grid-template-columns: 1fr 1fr; }
    .filters-card label:first-child { grid-column: 1 / -1; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .metric-grid { grid-template-columns: 1fr; }
    .admin-header, .section-heading { align-items: flex-start; flex-direction: column; }
    .search-form { width: 100%; }
    .report-meta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
    .environment-pill { display: none; }
    .brand-copy strong { font-size: 13px; }
    .login-shell, .results-shell { width: min(100% - 24px, 1120px); }
    .login-card { padding: 24px 20px; }
    .filters-card { grid-template-columns: 1fr; }
    .filters-card label:first-child { grid-column: auto; }
    .status-tabs { display: grid; grid-template-columns: 1fr; }
    .status-tab { border-right: 0; border-bottom: 1px solid var(--line); }
    .study-meta, .study-values, .report-meta { grid-template-columns: 1fr; }
    .study-values > div + div { border-left: 0; border-top: 1px solid var(--line); }
    .footer { align-items: flex-start; flex-direction: column; }
}

@media print {
    .topbar, .footer, .no-print { display: none !important; }
    body, :root { background: white; }
    main { min-height: 0; }
    .results-shell { width: 100%; padding: 0; }
    .report-sheet { padding: 0; border: 0; box-shadow: none; }
}
