:root {
    --navy: #0c2e33;
    --navy-soft: #164850;
    --ink: #14343a;
    --muted: #5a7276;
    --brass: #0f8f86;
    --brass-bright: #5eead4;
    --cream: #eef5f6;
    --paper: #f7fbfb;
    --line: #d3e3e6;
    --clay: #c2410c;
    --clay-deep: #9a3412;
    --shadow: 0 18px 50px rgba(12, 46, 51, 0.08);
    --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
    --sans: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 100% 0%, rgba(94, 234, 212, 0.18), transparent 28%),
        var(--cream);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.02rem;
    line-height: 1.55;
}

img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.03em; line-height: 1.08; }
p { margin: 0; }
button, input { font: inherit; }
a { color: inherit; }

.skip-link {
    position: absolute;
    left: 16px;
    top: -48px;
    z-index: 80;
    background: var(--paper);
    color: var(--ink);
    padding: 8px 12px;
    border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 22px 16px 18px;
    background:
        linear-gradient(180deg, rgba(94, 234, 212, 0.08), transparent 18%),
        var(--navy);
    color: #f2fbfb;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    padding: 4px 8px 16px;
    color: #f2fbfb;
    text-decoration: none;
    border-bottom: 1px solid rgba(94, 234, 212, 0.28);
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--brass-bright);
    border: 1px solid rgba(94, 234, 212, 0.45);
    border-radius: 50%;
}

.icon { width: 22px; height: 22px; display: block; }
.icon-mark { width: 30px; height: 30px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong {
    font-family: var(--serif);
    font-size: 1.35rem;
    font-weight: 560;
    letter-spacing: 0.12em;
}
.brand-text small {
    color: rgba(242, 251, 251, 0.72);
    font-size: 0.74rem;
    letter-spacing: 0.01em;
}

.side-nav {
    display: grid;
    align-content: start;
    gap: 4px;
    overflow: auto;
}

.side-section {
    margin: 16px 12px 6px;
    color: var(--brass-bright);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    color: rgba(242, 251, 251, 0.86);
    text-decoration: none;
    border-radius: 12px;
}
.side-link:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.side-link[aria-current="page"] {
    color: #06262b;
    background: var(--brass-bright);
}

.sidebar-foot {
    margin-top: auto;
    padding: 16px 12px 4px;
    border-top: 1px solid rgba(94, 234, 212, 0.22);
}
.sidebar-kicker {
    color: var(--brass-bright);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.sidebar-path {
    margin-top: 6px;
    color: rgba(242, 251, 251, 0.78);
    font-size: 0.92rem;
}

.app-main { min-width: 0; }
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 68px;
    padding: 0 28px;
    background: rgba(247, 251, 251, 0.9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.topbar-title {
    font-family: var(--serif);
    font-size: 1.25rem;
}
.topbar-meta {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.88rem;
    letter-spacing: 0.04em;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    cursor: pointer;
}
.menu-toggle .bar {
    display: block;
    width: 16px;
    height: 1.5px;
    margin: 4px auto;
    background: var(--navy);
}

.app-content {
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: 36px 0 72px;
}

.page-heading { max-width: 46rem; margin-bottom: 28px; }
.page-heading h1 { margin: 0 0 10px; font-size: clamp(2.6rem, 4vw, 3.8rem); }
.lede { color: var(--muted); font-size: 1.06rem; }

.eyebrow {
    margin: 0 0 10px;
    color: var(--brass);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
.eyebrow-light { color: var(--brass-bright); }

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.panel-head h2 { margin: 0; font-size: clamp(1.6rem, 2vw, 2.1rem); }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}
.stat-card { color: #fff; border-color: transparent; min-height: 180px; }
.stat-card .eyebrow,
.stat-card p,
.stat-card .stat-value { color: #fff; }
.stat-value {
    margin: 8px 0 10px;
    font-family: var(--serif);
    font-size: clamp(3rem, 4vw, 3.6rem);
    line-height: 0.9;
    letter-spacing: -0.04em;
}
.stat-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.24);
}
.stat-split dt {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.stat-split dd {
    margin: 4px 0 0;
    font-family: var(--serif);
    font-size: 1.7rem;
    line-height: 1;
}
.stat-card--forest { background: #0f6e6a; }
.stat-card--indigo { background: #1d4ed8; }
.stat-card--maroon { background: #c2410c; }
.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.stat-card-top .eyebrow { flex: 1; margin-bottom: 0; }
.stat-card .eyebrow.is-name {
    letter-spacing: 0.06em;
    line-height: 1.35;
}
.stat-corner { margin: 0; text-align: right; }
.stat-corner-value {
    display: block;
    font-family: var(--serif);
    font-size: 2rem;
    line-height: 0.9;
    letter-spacing: -0.04em;
}
.stat-corner-label {
    display: block;
    margin-top: 5px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.section-head { margin: 36px 0 16px; }
.section-head h2 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.5rem); }

.level-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.level-card {
    display: flex;
    flex-direction: column;
    min-height: 230px;
    padding: 18px 18px 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    text-decoration: none;
}
.level-card.is-live { color: inherit; }
.level-card.is-live:hover { border-color: var(--brass); transform: translateY(-2px); }
.level-index {
    color: var(--brass);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.14em;
}
.feature-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin: 14px 0 12px;
    color: var(--brass);
    border: 1px solid var(--line);
    border-radius: 50%;
}
.level-card h3 { margin: 0 0 8px; font-size: 1.7rem; }
.level-card p { color: var(--muted); }
.level-open,
.level-wait {
    margin-top: auto;
    padding-top: 16px;
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.level-open { color: var(--navy); }
.level-wait { color: #6a8488; }

.dash-split {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 18px;
    margin-top: 22px;
}
.city-panel {
    background:
        radial-gradient(circle at 0% 0%, rgba(94, 234, 212, 0.16), transparent 42%),
        linear-gradient(165deg, #145058, #0c2e33 60%);
    border-color: rgba(94, 234, 212, 0.28);
    color: #f3fbfb;
}
.city-panel h2,
.city-panel .eyebrow { color: #f7fffd; }
.city-panel .eyebrow { color: var(--brass-bright); }
.empty-copy { color: rgba(243, 251, 251, 0.75); }

.chart-bars { display: grid; gap: 14px; }
.chart-bar-row {
    display: grid;
    grid-template-columns: minmax(90px, 0.7fr) minmax(0, 1.4fr) 28px;
    gap: 12px;
    align-items: center;
}
.chart-bar-row span { font-size: 0.92rem; letter-spacing: 0.04em; }
.chart-bar-track {
    height: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
}
.chart-bar {
    display: block;
    height: 100%;
    min-width: 8px;
    background: linear-gradient(90deg, #0f8f86, #99f6e4);
    border-radius: inherit;
}
.chart-bar-row strong { font-variant-numeric: tabular-nums; text-align: right; }

.registry { display: grid; gap: 18px; }
.entry-grid {
    display: grid;
    grid-template-columns: 180px minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 16px 18px;
    align-items: start;
}
.field-wide { grid-column: span 2; }
.field-full { grid-column: 1 / -1; }
.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5c7276;
}
.field input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #c9dbdf;
    border-radius: 12px;
    background: white;
    color: var(--ink);
}
.field input::placeholder { color: #8aa0a4; }
.field input.is-upper { text-transform: uppercase; letter-spacing: 0.04em; }
.field input.is-lower { text-transform: lowercase; }
.field input[type="file"] {
    height: auto;
    min-height: 48px;
    padding: 11px 14px;
}
.logo-preview,
.logo-thumb {
    display: block;
    width: 64px;
    height: 64px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}
.logo-preview { margin-top: 12px; }
.field input[readonly] {
    background: #e7f2f3;
    color: #5c7276;
    letter-spacing: 0.04em;
}
.field select {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #c9dbdf;
    border-radius: 12px;
    background: white;
    color: var(--ink);
}
.field select:disabled {
    background: #e7f2f3;
    color: #5c7276;
}
.field input:focus-visible,
.field select:focus-visible,
.btn:focus-visible,
.side-link:focus-visible,
.brand:focus-visible,
.text-link:focus-visible,
.table-link:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}
.hint { margin-top: 6px; color: var(--muted); font-size: 0.84rem; }
.field-error { margin-top: 6px; color: var(--clay); font-size: 0.88rem; }
.edit-state {
    margin: 0;
    color: #0f6e78;
    font-size: 0.92rem;
}
.form-alert {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fde8e4;
    color: var(--clay-deep);
}
.form-actions { display: flex; gap: 8px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 12px 18px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 550;
    transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.btn-brass { background: var(--brass-bright); color: #06262b; }
.btn-brass:hover { background: #99f6e4; }
.btn-primary { background: var(--navy); color: #f3fbfb; }
.btn-primary:hover { background: var(--navy-soft); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #e7f3f4; }
.btn-danger { background: var(--clay); color: #fff8f5; }
.btn-danger:hover { background: var(--clay-deep); }
.btn-small { padding: 7px 12px; border-radius: 9px; font-size: 0.92rem; }
.btn-text-danger { background: transparent; color: var(--clay); }
.btn-text-danger:hover { background: rgba(194, 65, 12, 0.08); }

.count-pill {
    margin: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e7f2f3;
    color: #5c7276;
    font-size: 0.85rem;
    white-space: nowrap;
}

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 920px; }
.data-table-compact { min-width: 420px; }
.data-table th {
    padding: 0 14px 12px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5c7276;
    border-bottom: 1px solid var(--line);
}
.data-table td {
    padding: 14px;
    border-bottom: 1px solid #e4eef0;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #f2f8f8; }
.data-table tr.is-editing { background: #e3f3f2; }
.data-table tr.is-fresh { animation: fresh 1.6s ease; }
.cell-id { width: 90px; color: #5c7276; font-variant-numeric: tabular-nums; }
.cell-logo { width: 84px; }
.cell-logo .logo-thumb { width: 48px; height: 48px; }
.cell-name { font-weight: 600; letter-spacing: 0.03em; }
.cell-address { max-width: 240px; }
.cell-email { color: #3d5c64; letter-spacing: 0.01em; }
.cell-actions { width: 160px; white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: 4px; }
.empty-row td { color: var(--muted); }
.empty-row strong { display: block; color: var(--ink); font-weight: 600; }
.empty-row span { display: block; margin-top: 4px; }
.sub { display: block; margin-top: 2px; color: var(--muted); font-size: 0.86rem; font-weight: 400; letter-spacing: 0; }
.school-cell { display: flex; align-items: center; gap: 12px; }
.table-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.table-link:hover { color: #0f6e78; }
.text-link { color: var(--brass); font-weight: 600; text-decoration: none; white-space: nowrap; }
.text-link:hover { text-decoration: underline; }
.empty-block { display: grid; justify-items: start; gap: 14px; color: var(--muted); }

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(7, 31, 36, 0.52);
}
.modal-card {
    width: min(460px, 100%);
    padding: 24px;
    background: var(--paper);
    border-radius: 20px;
    box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 8px; font-size: 1.8rem; }
.modal-card p { color: var(--muted); }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 60;
    max-width: min(360px, calc(100% - 32px));
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--navy);
    color: #f3fbfb;
    box-shadow: var(--shadow);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(6, 30, 36, 0.46);
}

@keyframes fresh {
    from { background: #d4f3ec; }
    to { background: transparent; }
}

.page-login { background: var(--cream); }
.login-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(340px, 480px);
}
.login-visual {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100vh;
    padding: 56px 64px 64px;
    color: #f4fbfb;
    background:
        radial-gradient(circle at 12% 18%, rgba(194, 65, 12, 0.28), transparent 32%),
        radial-gradient(circle at 88% 8%, rgba(94, 234, 212, 0.2), transparent 28%),
        linear-gradient(165deg, #071c20 0%, #0c2e33 46%, #123f3a 100%);
}
.login-visual .eyebrow { color: var(--brass-bright); }
.crest-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin: 36px 0 40px;
    padding: 0;
    list-style: none;
}
.crest-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%;
    padding: 18px 14px 16px;
    background: #fffdf8;
    border-radius: 22px;
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}
.crest-card img {
    width: 100%;
    height: 168px;
    object-fit: contain;
}
.crest-card span {
    display: block;
    margin-top: 12px;
    color: #5c4038;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.35;
    text-align: center;
    text-transform: uppercase;
}
.login-visual h1 {
    margin: 0 0 14px;
    max-width: 12ch;
    color: #f7fbfb;
    font-size: clamp(3rem, 5vw, 4.6rem);
}
.login-visual-copy p {
    max-width: 36rem;
    color: rgba(244, 251, 251, 0.82);
    font-size: 1.08rem;
}
.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    background:
        radial-gradient(circle at 100% 0%, rgba(94, 234, 212, 0.16), transparent 32%),
        var(--cream);
}
.login-card { width: min(400px, 100%); }
.brand-login {
    display: inline-flex;
    margin-bottom: 28px;
    color: var(--navy);
    text-decoration: none;
    border-bottom: 0;
}
.brand-login .brand-mark {
    color: var(--brass);
    border-color: rgba(15, 143, 134, 0.4);
}
.brand-login .brand-text strong { color: var(--navy); }
.brand-login .brand-text small { color: var(--muted); }
.login-card h2 { margin: 0 0 8px; font-size: 2.7rem; }
.login-copy { color: var(--muted); }
.login-form { display: grid; gap: 16px; margin-top: 22px; }
.login-card .form-alert { margin: 18px 0 0; }
.login-submit { width: 100%; margin-top: 4px; }
.side-logout { margin-top: 14px; }
.side-logout-btn {
    width: 100%;
    padding: 8px 12px;
    color: rgba(242, 251, 251, 0.86);
    background: transparent;
    border: 1px solid rgba(94, 234, 212, 0.28);
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
}
.side-logout-btn:hover { color: white; background: rgba(255, 255, 255, 0.06); }

@media (max-width: 1100px) {
    .level-grid,
    .stat-grid,
    .dash-split { grid-template-columns: 1fr 1fr; }
    .level-grid { grid-template-columns: 1fr 1fr; }
    .entry-grid { grid-template-columns: 1fr 1fr; }
    .field-wide { grid-column: span 2; }
}

@media (max-width: 860px) {
    .app-shell { display: block; }
    .sidebar {
        position: fixed;
        z-index: 40;
        width: min(300px, 88vw);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }
    .sidebar.is-open { transform: none; }
    .menu-toggle { display: inline-block; }
    .topbar-meta { display: none; }
    .app-content { width: min(100% - 32px, 1180px); padding-top: 24px; }
    .stat-grid,
    .level-grid,
    .dash-split,
    .entry-grid { grid-template-columns: 1fr; }
    .field-wide,
    .field-full { grid-column: auto; }
    .chart-bar-row { grid-template-columns: 1fr; gap: 6px; }
    .login-screen { grid-template-columns: 1fr; }
    .login-visual { min-height: 0; padding: 28px 20px 32px; }
    .login-visual h1 { max-width: none; font-size: clamp(2.2rem, 8vw, 3rem); }
    .crest-card img { height: 96px; }
    .login-panel { padding: 28px 20px 40px; }
}
