:root {
    --primary: #0068b7;
    --primary-dark: #00518e;
    --accent: #008f68;
    --accent-dark: #007252;
    --surface: #ffffff;
    --background: #f4f7fb;
    --muted: #eef3f8;
    --border: #d8e2ed;
    --text: #10233e;
    --text-muted: #60748d;
    --danger: #c81e3a;
    --warning: #985c00;
    --shadow: 0 12px 32px rgba(23, 52, 86, .08);
    --radius: 16px;
    --focus: 0 0 0 4px rgba(0, 104, 183, .16);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--text); font: 15px/1.55 "Segoe UI", Arial, sans-serif; }
button, input, select { font: inherit; }
button, select, [role="button"] { cursor: pointer; }
a { color: var(--primary); }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }

.skip-link { position: fixed; z-index: 2000; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); border-radius: 8px; background: var(--text); color: white; }
.skip-link:focus { transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.topbar { border-bottom: 1px solid var(--border); background: rgba(255,255,255,.97); }
.topbar__inner { display: flex; width: min(100% - 40px, 1500px); min-height: 82px; margin: auto; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 13px; color: var(--text); text-decoration: none; }
.brand__mark { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 13px; background: linear-gradient(145deg, var(--primary), #1b8fd0); color: white; box-shadow: 0 8px 20px rgba(0,104,183,.2); }
.brand__mark svg { width: 26px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; line-height: 1.25; }
.brand small { margin-top: 2px; color: var(--text-muted); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.secure-badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid #bfe7d8; border-radius: 999px; background: #ecfbf5; color: #006e50; font-size: 13px; font-weight: 700; }
.secure-badge svg { width: 18px; }

.page-shell { width: min(100% - 40px, 1500px); min-height: calc(100vh - 158px); margin: auto; padding: 28px 0 48px; }
.page-heading { display: flex; margin-bottom: 24px; align-items: center; justify-content: space-between; }
.page-heading h1 { margin: 0; font-size: clamp(24px, 2.2vw, 32px); letter-spacing: -.025em; }
.page-heading p { margin: 5px 0 0; color: var(--text-muted); }
.footer { padding: 20px; border-top: 1px solid var(--border); background: white; color: var(--text-muted); text-align: center; font-size: 13px; }

.selection-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 24px; align-items: start; }
.selection-card, .help-card, .form-card, .context-bar, .success-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.selection-card { padding: clamp(24px, 4vw, 48px); }
.stepper { display: flex; margin-bottom: 42px; align-items: center; }
.stepper__item { display: flex; min-width: max-content; align-items: center; gap: 8px; color: #8090a3; font-size: 13px; font-weight: 700; }
.stepper__item b { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: white; }
.stepper__item.is-active { color: var(--primary); }
.stepper__item.is-active b { border-color: var(--primary); background: var(--primary); color: white; }
.stepper__line { width: 100%; height: 1px; margin: 0 12px; background: var(--border); }
.selection-form { display: grid; gap: 22px; max-width: 720px; }
.selection-form .button { justify-self: start; }
.help-card { padding: 30px; }
.help-card__icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 14px; background: #e7f3fc; color: var(--primary); }
.help-card__icon svg { width: 27px; }
.help-card h2 { margin: 20px 0 12px; font-size: 19px; }
.help-card ol { margin: 0; padding-left: 22px; color: #3f536d; }
.help-card li + li { margin-top: 10px; }
.help-card p { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }

.field { min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; color: #314761; font-size: 13px; font-weight: 700; }
.field label span { color: var(--danger); }
.field input, .field select, .selection-form select, .school-dialog select, .search-box input { width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid #c8d5e3; border-radius: 10px; outline: 0; background: white; color: var(--text); transition: border-color .2s, box-shadow .2s, background .2s; }
.field input:focus, .field select:focus, .selection-form select:focus, .school-dialog select:focus, .search-box input:focus { border-color: var(--primary); box-shadow: var(--focus); }
.field input[readonly] { border-color: #dbe4ed; background: #f1f5f9; color: #41556c; cursor: default; }
.field small, .selection-form small { display: block; margin-top: 7px; color: var(--text-muted); font-size: 12px; }
select:disabled, button:disabled { cursor: not-allowed; opacity: .55; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 700; text-decoration: none; transition: background .2s, border-color .2s, color .2s, box-shadow .2s; }
.button svg { width: 20px; }
.button--large { min-height: 50px; padding-inline: 23px; }
.button--primary { background: var(--accent); color: white; box-shadow: 0 7px 17px rgba(0,143,104,.18); }
.button--primary:hover:not(:disabled) { background: var(--accent-dark); }
.button--secondary { border-color: #cbd7e3; background: white; color: #344a64; }
.button--secondary:hover { background: #f4f7fa; border-color: #aebdcd; }
.button:focus-visible, .icon-button:focus-visible { outline: 0; box-shadow: var(--focus); }

.context-bar { display: flex; margin-bottom: 20px; padding: 15px 18px; align-items: center; gap: 14px; }
.context-bar div span, .context-bar div strong { display: block; }
.context-bar div span { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.context-bar div strong { font-size: 14px; }
.context-bar > svg { width: 17px; color: #91a0b1; }
.context-bar a { margin-left: auto; font-weight: 700; }
.report-form { display: grid; gap: 20px; }
.form-card { padding: 22px; }
.form-card__heading { display: flex; margin-bottom: 20px; align-items: center; justify-content: space-between; gap: 18px; }
.form-card__heading > div { position: relative; padding-left: 46px; }
.form-card__heading h2 { margin: 0; font-size: 18px; }
.form-card__heading p { margin: 3px 0 0; color: var(--text-muted); font-size: 13px; }
.section-number { position: absolute; top: -3px; left: 0; display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: #e3f1fb; color: var(--primary); font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }

.selected-schools { overflow: hidden; border: 1px solid var(--border); border-radius: 12px; }
.empty-state { display: grid; min-height: 170px; place-items: center; align-content: center; gap: 6px; color: var(--text-muted); text-align: center; }
.empty-state svg { width: 38px; margin-bottom: 4px; color: #93a6ba; }
.empty-state strong { color: #42566d; }
.selected-table { width: 100%; border-collapse: collapse; }
.selected-table th { padding: 11px 14px; background: var(--muted); color: #4b6077; font-size: 11px; text-align: left; text-transform: uppercase; }
.selected-table td { padding: 12px 14px; border-top: 1px solid #e6edf4; vertical-align: middle; }
.selected-table strong, .selected-table small { display: block; }
.selected-table small { color: var(--text-muted); }
.selected-table input { width: 86px; min-height: 38px; padding: 7px 9px; border: 1px solid #c8d5e3; border-radius: 8px; }
.remove-school { min-height: 38px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--danger); font-weight: 700; }
.remove-school:hover { background: #fff0f3; }

.service-grid { display: grid; margin: 0; padding: 0; border: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.service-option { display: flex; min-height: 82px; align-items: flex-start; gap: 12px; padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: white; cursor: pointer; transition: border-color .2s, background .2s, box-shadow .2s; }
.service-option:hover { border-color: #9bc8e4; background: #f7fbfe; }
.service-option:has(input:checked) { border-color: var(--primary); background: #edf7fd; box-shadow: 0 0 0 2px rgba(0,104,183,.08); }
.service-option input { position: absolute; opacity: 0; pointer-events: none; }
.service-option__check { display: grid; width: 23px; height: 23px; flex: 0 0 23px; place-items: center; border: 1px solid #b7c5d4; border-radius: 6px; color: transparent; }
.service-option input:checked + .service-option__check { border-color: var(--primary); background: var(--primary); color: white; }
.service-option input:focus-visible + .service-option__check { box-shadow: var(--focus); }
.service-option__check svg { width: 16px; stroke-width: 2.5; }
.service-option strong, .service-option small { display: block; }
.service-option strong { color: #28415d; }
.service-option small { margin-top: 3px; color: var(--text-muted); font-size: 12px; }

.alert { margin-bottom: 20px; padding: 14px 17px; border: 1px solid; border-radius: 11px; }
.alert ul { margin: 7px 0 0; padding-left: 20px; }
.alert--error { border-color: #f5bdc8; background: #fff1f3; color: #8e1730; }
.alert--warning { border-color: #f0d092; background: #fff9e9; color: #754700; }

.school-dialog { width: min(1100px, calc(100% - 32px)); max-height: min(780px, calc(100vh - 32px)); padding: 0; border: 0; border-radius: 17px; background: white; box-shadow: 0 30px 80px rgba(12,29,49,.3); }
.school-dialog::backdrop { background: rgba(15, 29, 46, .62); backdrop-filter: blur(3px); }
.school-dialog__header, .school-dialog__filters, .school-dialog__footer { display: flex; align-items: center; gap: 14px; padding: 18px 22px; }
.school-dialog__header { justify-content: space-between; border-bottom: 1px solid var(--border); }
.school-dialog__header h2 { margin: 0; font-size: 20px; }
.school-dialog__header p { margin: 3px 0 0; color: var(--text-muted); font-size: 13px; }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 10px; background: transparent; color: #52677e; }
.icon-button:hover { background: var(--muted); }
.icon-button svg { width: 22px; }
.school-dialog__filters { border-bottom: 1px solid var(--border); background: #f8fafc; }
.school-dialog__filters select { width: 240px; }
.search-box { position: relative; width: 100%; }
.search-box svg { position: absolute; top: 50%; left: 13px; width: 20px; transform: translateY(-50%); color: #76899e; pointer-events: none; }
.search-box input { padding-left: 42px; }
.school-dialog__body { min-height: 280px; max-height: 480px; overflow-y: auto; padding: 10px; }
.school-row { display: grid; min-height: 64px; padding: 10px 12px; border-radius: 10px; grid-template-columns: 44px minmax(220px, 2fr) minmax(120px, 1fr) repeat(3, 100px); align-items: center; gap: 10px; }
.school-row:hover { background: #f2f7fb; }
.school-row input { width: 19px; height: 19px; accent-color: var(--primary); }
.school-row strong, .school-row small { display: block; }
.school-row small, .school-row span { color: var(--text-muted); font-size: 12px; }
.school-row__metric { text-align: center; }
.school-dialog__footer { justify-content: space-between; border-top: 1px solid var(--border); }
.school-dialog__footer > div { display: flex; gap: 10px; }
.loading-state { padding: 80px 20px; color: var(--text-muted); text-align: center; }

.success-card { max-width: 680px; margin: 30px auto; padding: 54px 32px; text-align: center; }
.success-card__icon { display: grid; width: 74px; height: 74px; margin: 0 auto; place-items: center; border-radius: 50%; background: #def7ec; color: var(--accent); }
.success-card__icon svg { width: 38px; stroke-width: 2.5; }
.success-card h2 { margin: 22px 0 8px; font-size: 26px; }
.success-card p { margin: 0; color: var(--text-muted); }
.reference-code { display: inline-block; margin: 14px 0; padding: 10px 16px; border: 1px dashed #94abc0; border-radius: 9px; background: #f5f8fb; font: 700 20px/1.2 Consolas, monospace; letter-spacing: .06em; }
.success-card__note { margin-bottom: 28px !important; }

@media (max-width: 1023px) {
    .selection-layout { grid-template-columns: 1fr; }
    .help-card { display: none; }
    .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid--three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .school-row { grid-template-columns: 44px minmax(200px, 1fr) 130px repeat(3, 76px); }
}

@media (max-width: 767px) {
    .topbar__inner, .page-shell { width: min(100% - 24px, 1500px); }
    .topbar__inner { min-height: 70px; }
    .brand strong { max-width: 210px; font-size: 14px; }
    .secure-badge { display: none; }
    .page-shell { padding-top: 20px; }
    .page-heading { margin-bottom: 18px; }
    .page-heading h1 { font-size: 24px; }
    .selection-card, .form-card { padding: 17px; border-radius: 13px; }
    .stepper { margin-bottom: 28px; }
    .stepper__item { font-size: 0; }
    .stepper__item b { font-size: 13px; }
    .context-bar { flex-wrap: wrap; }
    .context-bar a { width: 100%; margin-left: 0; }
    .form-card__heading { align-items: stretch; flex-direction: column; }
    .form-card__heading .button { width: 100%; }
    .form-grid, .form-grid--three, .service-grid { grid-template-columns: 1fr; }
    .form-actions { align-items: stretch; flex-direction: column-reverse; }
    .form-actions .button { width: 100%; }
    .selected-schools { overflow-x: auto; }
    .selected-table { min-width: 740px; }
    .school-dialog { width: 100%; max-height: 100dvh; margin: auto 0 0; border-radius: 17px 17px 0 0; }
    .school-dialog__header, .school-dialog__filters, .school-dialog__footer { padding: 15px; }
    .school-dialog__filters { align-items: stretch; flex-direction: column; }
    .school-dialog__filters select { width: 100%; }
    .school-dialog__body { max-height: calc(100dvh - 280px); }
    .school-row { grid-template-columns: 38px 1fr; }
    .school-row__level, .school-row__metric { grid-column: 2; text-align: left; }
    .school-row__metric { display: inline-block; }
    .school-dialog__footer { align-items: stretch; flex-direction: column; }
    .school-dialog__footer > div { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
