:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #64748b;
    --line: #dde5ee;
    --line-soft: #edf1f5;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #e6f7f4;
    --danger: #b42318;
    --danger-soft: #fef2f2;
    --warning: #b7791f;
    --warning-soft: #fffbeb;
    --success: #0f766e;
    --success-soft: #ecfdf5;
    --info: #334155;
    --info-soft: #f8fafc;
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
    --shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.04);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(180deg, #f8fafc 0, var(--bg) 260px);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--accent-dark);
    font-weight: 600;
    text-underline-offset: 2px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: #17202e;
    color: #fff;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.16);
}

.brand {
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.nav a,
.nav-more summary {
    color: #e5e7eb;
    border-radius: 6px;
    padding: 7px 9px;
    text-decoration: none;
}

.nav a:hover,
.nav-more summary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-more {
    position: relative;
}

.nav-more summary {
    cursor: pointer;
    list-style: none;
}

.nav-more summary::-webkit-details-marker {
    display: none;
}

.nav-more-menu {
    background: #111827;
    border: 1px solid #374151;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
    display: grid;
    gap: 8px;
    min-width: 190px;
    padding: 10px;
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 20;
}

.nav-more:not([open]) .nav-more-menu {
    display: none;
}

.nav-more-menu a {
    white-space: nowrap;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.auth-container {
    width: min(430px, calc(100% - 32px));
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

h1, h2, h3 {
    color: #17202e;
    line-height: 1.2;
    margin: 0 0 14px;
}

h1 {
    font-size: 30px;
}

h2 {
    font-size: 20px;
}

h3 {
    font-size: 15px;
    margin-top: 16px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.panel, .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    padding: 18px;
}

.panel {
    margin-bottom: 22px;
}

.card {
    min-height: 104px;
}

.metric {
    color: #17202e;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.05;
    margin-bottom: 6px;
}

.muted {
    color: var(--muted);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: top;
}

th {
    background: #f8fafc;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    letter-spacing: 0;
}

tr:nth-child(even) td {
    background: #fcfdff;
}

tr:hover td {
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: 0;
}

form {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    padding: 20px;
}

.compact-form {
    max-width: 320px;
    margin-bottom: 16px;
}

.unstyled-form {
    padding: 0;
    border: 0;
    background: transparent;
}

label {
    display: block;
    font-weight: 700;
    margin: 12px 0 6px;
}

input, select, textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 11px;
    font: inherit;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

textarea {
    min-height: 110px;
}

.large-textarea {
    min-height: 260px;
}

.summary-copy-box {
    min-height: 360px;
    background: #fcfdff;
    border-color: var(--line);
    line-height: 1.55;
    white-space: pre;
}

.summary-copy-box.short {
    min-height: 180px;
}

.summary-list {
    margin: 0;
    padding-left: 18px;
}

.summary-list li {
    margin-bottom: 8px;
}

.priority-list {
    display: grid;
    gap: 12px;
}

.priority-item {
    align-items: flex-start;
    background: #fcfdff;
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 10px;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(110px, 140px) 1fr;
    padding: 13px 14px;
}

.priority-label {
    justify-self: start;
}

.student-health-summary {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.student-health-count {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
}

.student-health-count strong,
.student-health-count span {
    display: block;
}

.student-health-count strong {
    font-size: 28px;
    line-height: 1;
    margin-bottom: 6px;
}

.student-health-count span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.student-health-count.ok {
    background: var(--success-soft);
    border-color: #99f6e4;
}

.student-health-count.warning {
    background: var(--warning-soft);
    border-color: #fcd34d;
}

.student-health-count.critical {
    background: var(--danger-soft);
    border-color: #fecaca;
}

.student-status-cards {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 14px;
}

.student-status-card {
    background: var(--info-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.student-status-card span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-bottom: 4px;
}

.student-status-card strong {
    color: #1f2933;
    font-size: 17px;
}

.student-action-list {
    counter-reset: action;
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.student-action-list li {
    background: #fcfdff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    font-weight: 700;
    padding: 10px 12px;
}

.review-flags {
    display: grid;
    gap: 8px;
}

.review-flag {
    border: 1px solid var(--line);
    border-left: 5px solid #64748b;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
}

.review-flag span {
    display: block;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.review-flag.critical {
    background: var(--danger-soft);
    border-left-color: var(--danger);
}

.review-flag.warning {
    background: var(--warning-soft);
    border-left-color: var(--warning);
}

.review-flag.info {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.assistant-summary {
    margin: 18px 0;
}

.assistant-readable {
    background: var(--info-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 12px 0 16px;
    padding: 14px;
}

.assistant-readable h3 {
    color: #334155;
    font-size: 12px;
    margin: 12px 0 4px;
    text-transform: uppercase;
}

.assistant-readable h3:first-child {
    margin-top: 0;
}

.assistant-readable p {
    margin: 0 0 4px;
}

.intake-review-summary {
    background: #fcfdff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 16px;
}

.intake-review-summary h2,
.intake-review-summary h3 {
    color: #334155;
    font-size: 12px;
    margin: 14px 0 4px;
    text-transform: uppercase;
}

.intake-review-summary h2:first-child {
    margin-top: 0;
}

.intake-review-summary p {
    margin: 0 0 4px;
}

.intake-review-grid {
    display: grid;
    gap: 10px 16px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    margin-top: 12px;
}

.intake-dashboard-list {
    display: grid;
    gap: 4px 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.raw-json-details {
    margin-top: 14px;
}

.raw-json-details summary {
    color: var(--accent-dark);
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 8px;
}

.intake-match-panel {
    background: var(--info-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 16px;
    padding: 16px;
}

.intake-match-panel h2 {
    margin-bottom: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 16px;
}

.button, button {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(15, 118, 110, 0.16);
}

.button:hover, button:hover {
    background: var(--accent-dark);
    box-shadow: 0 5px 14px rgba(15, 118, 110, 0.2);
}

.button.secondary {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: none;
    color: #334155;
}

.button.secondary:hover {
    background: #eef2f6;
    box-shadow: none;
}

.button.danger, button.danger {
    background: var(--danger);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-actions form {
    padding: 0;
    border: 0;
    background: transparent;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.filter-tabs a {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: #334155;
    padding: 7px 10px;
    text-decoration: none;
    background: #fff;
}

.filter-tabs a.active {
    border-color: var(--accent);
    background: #ccfbf1;
    color: var(--accent-dark);
    font-weight: 700;
}

.flash, .errors {
    background: var(--success-soft);
    border: 1px solid #99f6e4;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.errors {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: var(--danger);
}

.status {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 9px;
    background: #e2e8f0;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status:empty {
    display: none;
}

.health-badge {
    border-radius: 999px;
    display: inline-block;
    font-size: 13px;
    padding: 4px 10px;
    vertical-align: middle;
}

.health-badge.ok,
.student-attention-summary.ok {
    background: var(--success-soft);
    border-color: #99f6e4;
    color: #115e59;
}

.health-badge.warning,
.student-attention-summary.warning {
    background: var(--warning-soft);
    border-color: #fcd34d;
    color: #92400e;
}

.health-badge.critical,
.student-attention-summary.critical {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: var(--danger);
}

.student-attention-summary {
    border-left: 5px solid currentColor;
}

.student-attention-summary p,
.workflow-summary {
    margin: 4px 0 0;
}

.workflow-summary {
    color: #334155;
    font-weight: 700;
}

.page-title + .panel,
.page-title + .grid {
    margin-top: 4px;
}

details.panel {
    padding: 0;
}

details.panel > summary {
    align-items: center;
    border-radius: 10px;
    color: #17202e;
    cursor: pointer;
    display: flex;
    font-size: 16px;
    font-weight: 700;
    justify-content: space-between;
    padding: 16px 18px;
}

details.panel > summary::after {
    color: var(--muted);
    content: "Open";
    font-size: 12px;
    font-weight: 700;
}

details.panel[open] > summary {
    border-bottom: 1px solid var(--line-soft);
}

details.panel[open] > summary::after {
    content: "Close";
}

details.panel > :not(summary) {
    margin-left: 18px;
    margin-right: 18px;
}

details.panel > :last-child {
    margin-bottom: 18px;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 18px;
    }

    .container {
        width: min(100% - 24px, 1180px);
        margin-top: 18px;
    }

    .page-title {
        align-items: flex-start;
        flex-direction: column;
    }

    h1 {
        font-size: 25px;
    }

    h2 {
        font-size: 18px;
    }

    .panel, .card, form {
        padding: 14px;
    }

    .nav-more-menu {
        box-shadow: none;
        position: static;
    }

    .metric {
        font-size: 26px;
    }

    th, td {
        padding: 10px;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    .priority-item {
        grid-template-columns: 1fr;
    }
}
