:root {
    color-scheme: light;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    color: #102a35;
    background: #f3f8fa;
    --navy: #073b4c;
    --blue: #087f8c;
    --blue-dark: #05636d;
    --aqua: #d8f2f4;
    --border: #c7dbe0;
    --muted: #526a73;
    --danger: #9c2f27;
    --surface: #ffffff;
    --shadow: 0 8px 26px rgb(7 59 76 / 10%);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.skip-link {
    position: fixed;
    left: 1rem;
    top: -5rem;
    z-index: 10;
    padding: .75rem 1rem;
    color: white;
    background: var(--navy);
}
.skip-link:focus { top: 1rem; }

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 72px;
    padding: .75rem max(1rem, env(safe-area-inset-left));
    color: white;
    background: var(--navy);
}
.brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-weight: 800;
    background: var(--blue);
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: .1rem; color: #cce6eb; }

main { width: min(100% - 2rem, 980px); margin: 0 auto; padding: 1.5rem 0 2.5rem; }
footer { padding: 1rem; color: var(--muted); text-align: center; font-size: .875rem; }
.hidden { display: none !important; }
.stack { display: grid; gap: 1rem; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.muted { color: var(--muted); }
.eyebrow { margin: 0; color: var(--blue-dark); font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: .25rem 0 .5rem; font-size: clamp(1.8rem, 7vw, 2.6rem); line-height: 1.1; }
h2 { margin: 0; font-size: 1.25rem; }
h3 { margin: 0; font-size: 1.05rem; }
p { line-height: 1.55; }

.auth-shell { width: min(100%, 430px); margin: 4vh auto 0; }
.card {
    padding: 1.2rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.form-field { display: grid; gap: .4rem; }
label { font-weight: 700; }
input {
    width: 100%;
    min-height: 48px;
    padding: .75rem;
    border: 1px solid #78939b;
    border-radius: 10px;
    color: #102a35;
    background: white;
}
input:focus, button:focus-visible, a:focus-visible { outline: 3px solid #f1bd43; outline-offset: 2px; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: .7rem 1rem;
    border: 2px solid transparent;
    border-radius: 10px;
    font-weight: 750;
    cursor: pointer;
}
.button-primary { width: 100%; color: white; background: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { color: white; border-color: #9dc9d0; background: transparent; }
.button-link { padding-inline: 0; color: var(--blue-dark); background: transparent; text-decoration: underline; }
.button:disabled { cursor: wait; opacity: .65; }
.notice { padding: .9rem 1rem; border-radius: 10px; background: var(--aqua); line-height: 1.45; }
.notice-error { color: #6f1e18; border: 1px solid #e2ada8; background: #fff1ef; }

.portal-header { margin-bottom: 1.2rem; }
.dashboard { display: grid; gap: 1rem; }
.section-grid { display: grid; gap: 1rem; }
.detail-list { display: grid; gap: .65rem; margin: .8rem 0 0; }
.detail-row { display: grid; gap: .15rem; padding-top: .65rem; border-top: 1px solid #e4eef0; }
.detail-label { color: var(--muted); font-size: .85rem; font-weight: 700; }
.chemistry { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .65rem; margin-top: .8rem; }
.reading { padding: .7rem; border-radius: 10px; background: #eef7f8; }
.reading strong, .reading span { display: block; }
.empty { padding: 1rem; border: 1px dashed #8da9b0; border-radius: 12px; color: var(--muted); }
.loading { display: grid; place-items: center; min-height: 40vh; text-align: center; }
.spinner { width: 38px; height: 38px; border: 4px solid #c5e1e5; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-color: var(--blue); } }

@media (min-width: 700px) {
    .site-header { padding-inline: max(2rem, calc((100vw - 980px) / 2)); }
    main { padding-top: 2.5rem; }
    .section-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section-grid > h2, .section-grid > .empty { grid-column: 1 / -1; }
    .card { padding: 1.5rem; }
}
