:root {
    --navy: #1f3a5f;
    --navy-dark: #162b47;
    --accent: #c0392b;
    --accent-dark: #a63125;
    --grey: #595959;
    --light: #eef2f7;
    --border: #d8dfe8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #1a1a1a;
    background: #fafbfc;
}

.page { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- Header ---- */
.topbar {
    background: linear-gradient(to bottom, var(--navy), var(--navy-dark));
    color: #fff;
    padding: 0.65rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.8rem;
    box-shadow: 0 2px 6px rgba(22, 43, 71, 0.25);
    flex-wrap: wrap;
}

.topbar .brand {
    color: #fff; font-weight: 700; font-size: 1.15rem;
    text-decoration: none; letter-spacing: 0.2px;
}
.brand-accent { color: #e8946a; }

.topbar nav { display: flex; align-items: center; gap: 1.1rem; }
.topbar nav a {
    color: #cfdbe2; text-decoration: none; font-size: 0.95rem;
    padding: 0.2rem 0; border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.nav-toggle, .nav-burger { display: none; }
.topbar nav a:hover { color: #fff; border-bottom-color: #e8946a; }

.user-area { margin-left: auto; display: flex; align-items: center; gap: 1rem; }

.user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.user-name { font-size: 0.9rem; font-weight: 600; color: #fff; }
.user-school { font-size: 0.78rem; color: #a9bccb; }

.signin-link { color: #cfdbe2; text-decoration: none; font-size: 0.95rem; }
.signin-link:hover { color: #fff; }

.inline-form { display: inline; }
.link-button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #cfdbe2; cursor: pointer;
    font-size: 0.85rem; padding: 0.3rem 0.8rem; border-radius: 4px;
    font-family: inherit; transition: background 0.15s, color 0.15s;
}
.link-button:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* ---- Main ---- */
main { flex: 1; max-width: 760px; width: 100%; margin: 0 auto; padding: 2rem 1.5rem 3rem; }

/* Data-heavy pages (tables) get a wider column than prose pages. */
main:has(.wide) { max-width: 1100px; }

/* Horizontal scroll fallback for tables on narrow screens. */
.table-scroll { overflow-x: auto; }
.table-scroll table.sections { min-width: 680px; }

h1 { color: var(--navy); letter-spacing: -0.3px; }
h2 { color: var(--navy); margin-top: 0; }
h3 { color: var(--navy); }

/* ---- Forms & questions ---- */
.q { margin: 1.2rem 0; }
.q label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.q .help, .help { color: var(--grey); font-size: 0.9rem; margin: 0.2rem 0 0.5rem; }
.q input, .q select {
    padding: 0.5rem 0.7rem; font-size: 1rem; width: 100%; max-width: 420px;
    border: 1px solid var(--border); border-radius: 5px; background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.q input:focus, .q select:focus {
    outline: none; border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.15);
}

.answer-buttons { display: flex; gap: 0.5rem; }
.answer {
    padding: 0.45rem 1.3rem;
    border: 1px solid var(--navy);
    background: #fff; color: var(--navy);
    border-radius: 5px; cursor: pointer; font-size: 1rem;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.answer:hover { box-shadow: 0 1px 4px rgba(31, 58, 95, 0.25); }
.answer.selected { background: var(--navy); color: #fff; }

.btn-primary {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.6rem 1.6rem;
    background: var(--accent); color: #fff;
    border: none; border-radius: 5px;
    font-size: 1rem; cursor: pointer; text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--accent-dark); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ---- Tables ---- */
table.sections {
    border-collapse: collapse; width: 100%; margin: 1rem 0;
    background: #fff; border-radius: 6px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(31, 58, 95, 0.12);
}
table.sections th {
    background: var(--navy); color: #fff; text-align: left;
    padding: 0.55rem 0.9rem; font-size: 0.9rem; font-weight: 600;
    white-space: nowrap;
}
table.sections td {
    border-bottom: 1px solid var(--border); padding: 0.55rem 0.9rem;
    white-space: nowrap;
}
table.sections tr:last-child td { border-bottom: none; }
tr.rag-green td { background: #e7f4e8; }
tr.rag-amber td { background: #fdf3dc; }
tr.rag-red td { background: #fbe3e0; }

/* ---- Detail page layout (procedure register etc.) ---- */
.detail-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1.2rem; align-items: start; margin-top: 1rem;
}
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }

.panel {
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 1rem 1.2rem; box-shadow: 0 1px 3px rgba(31, 58, 95, 0.08);
}
.panel h3:first-child { margin-top: 0; }
.panel-span { grid-column: 1 / -1; }

.btn-secondary {
    display: inline-block; padding: 0.45rem 1.1rem;
    background: #fff; color: var(--navy); border: 1px solid var(--navy);
    border-radius: 5px; text-decoration: none; cursor: pointer; font-size: 0.95rem;
}
.btn-secondary:hover { background: var(--light); }

.guidance-toggle {
    background: none; border: none; padding: 0; margin-top: 0.25rem;
    color: var(--navy); font-size: 0.85rem; cursor: pointer;
    text-decoration: underline; font-family: inherit;
}
.guidance-panel {
    background: var(--light); border-left: 3px solid var(--navy);
    padding: 0.6rem 0.9rem; margin: 0.4rem 0; border-radius: 0 5px 5px 0;
    font-size: 0.9rem;
}
.guidance-panel p { margin: 0 0 0.4rem; }
.guidance-panel a { color: var(--navy); font-weight: 600; }

.note-input {
    width: 100%; max-width: 480px; margin-top: 0.3rem;
    padding: 0.3rem 0.5rem; font-size: 0.85rem;
    border: 1px solid var(--border); border-radius: 4px;
    background: #fdfdfd; color: var(--grey);
}
.note-input:focus { outline: none; border-color: var(--navy); color: #1a1a1a; }

/* ---- Callouts ---- */
.warning {
    background: #fbe3e0; border-left: 4px solid var(--accent);
    padding: 0.7rem 1rem; border-radius: 0 5px 5px 0;
}
.cta {
    background: var(--light); border-left: 4px solid var(--navy);
    padding: 0.7rem 1rem; border-radius: 0 5px 5px 0;
}

/* ---- Landing ---- */
.hero { text-align: center; padding: 2rem 0 1rem; }
.hero .lede { max-width: 560px; margin: 0.5rem auto 1rem; }
.lede { font-size: 1.1rem; color: #333; }

.feature-row { display: flex; gap: 1.2rem; margin: 2rem 0; flex-wrap: wrap; }
.feature {
    flex: 1 1 200px; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; padding: 1rem 1.2rem;
    box-shadow: 0 1px 3px rgba(31, 58, 95, 0.08);
}
.feature h3 { color: var(--navy); margin-top: 0; }

.strip { text-align: center; color: var(--grey); font-size: 0.9rem; margin-top: 1.5rem; }

/* ---- Footer ---- */
.footer {
    background: var(--light);
    border-top: 1px solid var(--border);
    color: var(--grey);
    font-size: 0.85rem;
    padding: 0.8rem 1.5rem;
}
.footer a { color: var(--navy); }

@media (max-width: 700px) {
    .topbar { gap: 0.8rem; flex-wrap: wrap; }

    .nav-burger {
        display: block; margin-left: auto;
        color: #cfdbe2; font-size: 1.5rem; line-height: 1;
        cursor: pointer; padding: 0.2rem 0.4rem; user-select: none;
    }
    .nav-burger:hover { color: #fff; }

    /* Collapsed by default; the checked checkbox opens the menu. */
    .topbar nav, .topbar .user-area { display: none; }

    .nav-toggle:checked ~ nav {
        display: flex; flex-direction: column; align-items: flex-start;
        width: 100%; gap: 0; padding: 0.4rem 0 0.2rem;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }
    .nav-toggle:checked ~ nav a {
        padding: 0.55rem 0; width: 100%;
        border-bottom: none; font-size: 1rem;
    }

    .nav-toggle:checked ~ .user-area {
        display: flex; width: 100%; margin-left: 0;
        justify-content: space-between; align-items: center;
        padding: 0.4rem 0 0.7rem;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }
    .nav-toggle:checked ~ .user-area .user-chip {
        display: flex; align-items: flex-start;
    }
    .user-chip { align-items: flex-start; }
    .user-name, .user-school { text-align: left; }
}
