:root {
    --ink: #14213d;
    --muted: #667085;
    --line: #d8dee8;
    --surface: #ffffff;
    --canvas: #f4f6f8;
    --green: #147d64;
    --green-dark: #0c5e4b;
    --yellow: #f2c14e;
    --red: #c63c3c;
    --shadow: 0 12px 32px rgba(20, 33, 61, .09);
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); letter-spacing: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }

.topbar {
    min-height: 76px;
    padding: 12px clamp(20px, 5vw, 72px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand-mark { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 6px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.topbar-login { color: var(--green-dark); font-weight: 700; text-decoration: none; }

.home-main { max-width: 1240px; margin: 0 auto; padding: clamp(46px, 8vh, 90px) clamp(20px, 4vw, 52px) 34px; }
.home-intro { max-width: 780px; }
.eyebrow { margin: 0 0 12px; color: var(--green); text-transform: uppercase; font-size: 13px; font-weight: 800; }
.home-intro h1 { margin: 0; max-width: 760px; font-size: clamp(36px, 5.5vw, 68px); line-height: 1.04; font-weight: 800; }
.home-copy { max-width: 670px; margin: 22px 0 0; color: var(--muted); font-size: 18px; line-height: 1.65; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: clamp(38px, 7vh, 72px); }
.action-card { min-height: 238px; padding: 22px; position: relative; display: grid; grid-template-rows: auto 1fr auto auto; gap: 12px; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 3px 12px rgba(20, 33, 61, .04); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.action-card:hover { transform: translateY(-3px); border-color: #aeb9c9; box-shadow: var(--shadow); }
.action-primary { background: var(--green); color: #fff; border-color: var(--green); }
.action-number { font-size: 12px; font-weight: 800; opacity: .66; }
.action-icon { position: absolute; right: 20px; top: 18px; font-size: 28px; line-height: 1; }
.action-card strong { align-self: end; font-size: 24px; }
.action-card > span:not(.action-number):not(.action-icon) { min-height: 48px; color: var(--muted); line-height: 1.5; }
.action-primary > span:not(.action-number):not(.action-icon) { color: rgba(255,255,255,.8); }
.action-card b { font-size: 22px; justify-self: end; }
.home-footer { max-width: 1240px; margin: 12px auto 0; padding: 22px clamp(20px, 4vw, 52px) 34px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 13px; }

.page-shell { min-height: 100vh; }
.page-main { max-width: 1120px; margin: 0 auto; padding: 34px 20px 64px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin: 4px 0 0; font-size: 32px; }
.page-heading p { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.back-link { color: var(--green-dark); font-weight: 700; text-decoration: none; white-space: nowrap; }
.form-panel, .login-panel, .lookup-panel, .dashboard-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.form-panel { padding: clamp(22px, 4vw, 38px); }
.form-section { padding: 0 0 28px; margin: 0 0 28px; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; margin-bottom: 0; }
.form-section h2 { margin: 0 0 18px; font-size: 19px; }
.registration-gate { margin-bottom: 26px; padding: 0 0 4px; border-bottom: 2px solid #d6e8e1; }
.registration-actions { justify-content: flex-start; }
.address-subsection { margin: 0 0 18px; padding: 16px 18px 18px; background: #f8fafb; border: 1px solid var(--line); border-radius: 6px; }
.address-subsection h3 { margin: 0 0 14px; color: var(--green-dark); font-size: 15px; }
.address-subsection:last-child { margin-bottom: 0; }
.address-note { padding-bottom: 0; background: transparent; border: 0; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.field { grid-column: span 6; min-width: 0; }
.field.third { grid-column: span 4; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.required { color: var(--red); }
.control { width: 100%; min-height: 44px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #b9c2cf; border-radius: 6px; outline: none; }
.control:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20, 125, 100, .13); }
textarea.control { min-height: 92px; resize: vertical; }
.field-note { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 8px; }
.button { min-height: 44px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 6px; font-weight: 750; text-decoration: none; cursor: pointer; }
.button-primary { color: #fff; background: var(--green); border-color: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--ink); background: #fff; border-color: #aeb9c9; }
.message { display: block; margin: 0 0 20px; padding: 12px 14px; border-radius: 6px; line-height: 1.5; }
.message-error { color: #8b1e1e; background: #fff0f0; border: 1px solid #f0b8b8; }
.message-success { color: #0c5e4b; background: #eaf7f2; border: 1px solid #a8d7c8; }
.hidden { display: none !important; }
.narrow-main { max-width: 540px; padding-top: clamp(46px, 9vh, 90px); }
.login-panel, .lookup-panel { padding: 30px; }
.login-panel h1, .lookup-panel h1 { margin: 0 0 8px; font-size: 28px; }
.panel-copy { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.stack { display: grid; gap: 17px; }
.stack .button { width: 100%; }
.panel-footer { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.dashboard-panel { padding: 26px; }
.dashboard-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.role-badge { display: inline-flex; padding: 5px 9px; color: var(--green-dark); background: #eaf7f2; border: 1px solid #b9dfd2; border-radius: 999px; font-size: 12px; font-weight: 800; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-top: 22px; }
.dashboard-item { min-height: 142px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfd; }
.dashboard-item h2 { margin: 0 0 9px; font-size: 17px; }
.dashboard-item p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
.profile-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.profile-table th, .profile-table td { padding: 12px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.profile-table th { width: 34%; color: var(--muted); font-size: 13px; }
.student-summary { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; padding-top: 24px; align-items: start; }
.student-photo { width: 180px; aspect-ratio: 3 / 4; object-fit: contain; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: #f4f6f8; }
.student-photo-edit { display: block; width: 150px; aspect-ratio: 3 / 4; margin: 0 0 12px; object-fit: contain; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: #f4f6f8; }
.photo-file { padding: 7px 9px; }
.photo-file::file-selector-button { min-height: 34px; margin-right: 12px; padding: 6px 12px; color: var(--ink); background: #f8fafb; border: 1px solid #aeb9c9; border-radius: 5px; font-weight: 700; cursor: pointer; }
.student-details h2 { margin: 0; font-size: 21px; }
.config-editor { margin-bottom: 24px; padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.config-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.config-editor-heading h2 { margin: 0; font-size: 22px; }
.config-editing { color: var(--green-dark); font-size: 13px; font-weight: 750; }
.config-editor-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.config-checks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 14px 26px; padding-top: 2px; }
.config-checks label { margin-left: 6px; font-weight: 650; }
.config-checks input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; accent-color: var(--green); }
.config-editor-actions { padding-top: 20px; }
.class-scope-list { min-height: 168px; padding: 6px; }
.class-scope-list option { padding: 7px 8px; }
.config-panel { overflow-x: auto; }
.config-table { width: 100%; min-width: 1120px; border-collapse: collapse; }
.config-table th, .config-table td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.config-table th { color: var(--muted); background: #f8fafb; font-size: 12px; text-transform: uppercase; }
.config-table input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); }
.inline-action { display: inline-block; margin-right: 12px; color: var(--green-dark); font-weight: 700; text-decoration: none; }
.inline-danger { color: var(--red); }
.inline-action[disabled] { color: var(--muted); cursor: not-allowed; text-decoration: none; }
.config-actions { padding: 20px 0 0; }
.inline-link { display: inline-block; margin-top: 12px; color: var(--green-dark); font-size: 13px; font-weight: 750; text-decoration: none; }
.dynamic-group-title { grid-column: 1 / -1; margin: 8px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 16px; }
.dynamic-group-title:first-child { padding-top: 0; border-top: 0; }
.dynamic-accordion { grid-column: 1 / -1; margin-top: 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; overflow: hidden; }
.dynamic-accordion + .dynamic-accordion { margin-top: 12px; }
.dynamic-accordion details { width: 100%; }
.dynamic-accordion summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; color: var(--green-dark); background: #f8fafb; font-size: 15px; font-weight: 800; cursor: pointer; list-style: none; }
.dynamic-accordion summary::-webkit-details-marker { display: none; }
.dynamic-accordion summary::after { content: '+'; flex: 0 0 auto; color: var(--green); font-size: 22px; line-height: 1; }
.dynamic-accordion details[open] summary { border-bottom: 1px solid var(--line); }
.dynamic-accordion details[open] summary::after { content: '−'; }
.dynamic-accordion-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; padding: 16px; }
.extended-profile { margin-top: 20px; }
.extended-profile h2 { margin: 0; font-size: 21px; }
.admin-main { max-width: 1320px; }
.management-editor { margin-bottom: 24px; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.management-editor .config-editor-heading { margin-bottom: 22px; }
.management-checks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 14px 28px; padding-top: 4px; }
.management-checks label { margin-left: 6px; font-weight: 650; }
.management-checks input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; accent-color: var(--green); }
.management-panel { overflow: hidden; padding: 0; }
.management-toolbar { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(180px, 1fr) auto; gap: 16px; align-items: end; padding: 22px 24px; border-bottom: 1px solid var(--line); background: #f8fafb; }
.management-toolbar .field { grid-column: auto; }
.management-table-wrap { width: 100%; overflow-x: auto; }
.management-table { width: 100%; min-width: 1040px; border-collapse: collapse; }
.management-table th, .management-table td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.management-table th { color: var(--muted); background: #fff; font-size: 12px; text-transform: uppercase; white-space: nowrap; }
.management-table tr:last-child td { border-bottom: 0; }
.management-table td:last-child { min-width: 180px; }
.student-browser { display: grid; gap: 18px; }
.state-select { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.student-overview-wrap { width: 100%; overflow-x: auto; }
.student-overview { min-width: 860px; margin-top: 0; }
.student-overview td:nth-child(4), .student-overview th:nth-child(4) { text-align: center; width: 76px; }
.student-overview td:nth-child(5) { min-width: 280px; white-space: normal; }
.management-table .inline-action { margin-top: 3px; margin-bottom: 3px; }
.class-toolbar { grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto; }
.assignment-toolbar { grid-template-columns: minmax(260px, 1fr) auto; }

@media (max-width: 800px) {
    .action-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .action-card { min-height: 184px; }
    .field, .field.third { grid-column: 1 / -1; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .home-footer { flex-direction: column; }
    .student-summary { grid-template-columns: 1fr; }
    .student-photo { width: min(180px, 100%); }
    .config-editor-heading { flex-direction: column; }
    .management-toolbar, .class-toolbar, .assignment-toolbar { grid-template-columns: 1fr; align-items: stretch; }
    .management-toolbar .button { width: 100%; }
}
@media (max-width: 520px) {
    .topbar { padding: 10px 16px; }
    .brand strong { font-size: 14px; }
    .brand small, .topbar-login { font-size: 12px; }
    .home-intro h1 { font-size: 38px; }
    .home-copy { font-size: 16px; }
    .page-main { padding-left: 14px; padding-right: 14px; }
    .form-panel, .login-panel, .lookup-panel { padding: 20px 16px; }
    .form-actions { align-items: stretch; flex-direction: column-reverse; }
    .form-actions .button { width: 100%; }
    .dashboard-header { align-items: flex-start; flex-direction: column; }
}
