:root {
    --bg: #f3f7fc;
    --bg-2: #eaf4ff;
    --card: #ffffff;
    --text: #11213d;
    --muted: #64748b;
    --line: #dce7f4;
    --navy: #003d91;
    --navy-dark: #062458;
    --navy-deep: #03183d;
    --teal: #17d7c4;
    --teal-dark: #08a797;
    --blue: #0b5fd7;
    --red: #ef4444;
    --green: #10b981;
    --amber: #f59e0b;
    --grey: #64748b;
    --shadow: 0 18px 45px rgba(5, 33, 74, .11);
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    font-family: Inter, Segoe UI, Roboto, Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(23,215,196,.18), transparent 34rem),
        linear-gradient(180deg, #f7fbff 0%, var(--bg) 100%);
    color: var(--text);
    min-height: 100%;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--navy); }
.topbar {
    background: linear-gradient(135deg, var(--navy-deep), var(--navy) 64%, var(--teal-dark));
    color: #fff;
    padding: 16px 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 12px 30px rgba(3,24,61,.22);
}
.brand-wrap { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand-wrap:hover { color: #fff; }
.brand-logo { width: 46px; height: 46px; object-fit: contain; filter: drop-shadow(0 8px 14px rgba(0,0,0,.22)); }
.brand { font-size: 25px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.brand span { color: var(--teal); }
.school-name { font-size: 13px; color: rgba(255,255,255,.78); margin-top: 4px; }
.user-chip {
    background: rgba(255,255,255,.13);
    border: 1px solid rgba(255,255,255,.2);
    padding: 7px 12px 7px 7px;
    border-radius: 999px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(12px);
}
.user-initial {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--teal);
    color: var(--navy-deep);
    font-weight: 800;
}
.nav {
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid var(--line);
    padding: 0 26px;
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
}
.nav a {
    padding: 14px 15px;
    color: #334155;
    border-bottom: 3px solid transparent;
    font-weight: 700;
    font-size: 14px;
}
.nav a.active, .nav a:hover { border-bottom-color: var(--teal); color: var(--navy); }
.container { max-width: 1220px; margin: 24px auto; padding: 0 20px; }
.card {
    background: rgba(255,255,255,.97);
    border: 1px solid rgba(220,231,244,.9);
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.card h1, .card h2 { margin-top: 0; letter-spacing: -.03em; }
.card h2 { font-size: 22px; }
.card-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.page-hero {
    background: linear-gradient(135deg, rgba(0,61,145,.96), rgba(6,36,88,.96) 58%, rgba(23,215,196,.9));
    color: #fff;
    border-radius: 22px;
    padding: 28px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
}
.page-hero h1 { margin: 3px 0 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.045em; }
.page-hero .muted { color: rgba(255,255,255,.78); }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 900; color: var(--teal); }
.hero-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.summary-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }
.stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 17px;
    box-shadow: 0 10px 26px rgba(5, 33, 74, .06);
    position: relative;
    overflow: hidden;
}
.stat::after {
    content: '';
    position: absolute;
    right: -28px;
    top: -28px;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: rgba(0,61,145,.08);
}
.stat .num { font-size: 34px; font-weight: 850; letter-spacing: -.04em; }
.stat .label { color: var(--muted); margin-top: 4px; font-weight: 700; }
.stat-oncall::after { background: rgba(11,95,215,.12); }
.stat-firstaid::after { background: rgba(239,68,68,.12); }
.stat-enroute::after { background: rgba(16,185,129,.14); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #475569; font-size: 12px; background: #f8fbff; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfdff; }
.row-firstaid td:first-child { border-left: 4px solid var(--red); }
.row-oncall td:first-child { border-left: 4px solid var(--blue); }
.row-enroute td:first-child { border-left: 4px solid var(--green); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 800; }
.badge-blue { background: var(--blue); }
.badge-red { background: var(--red); }
.badge-green { background: var(--green); }
.badge-grey { background: var(--grey); }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 11px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(135deg, var(--navy), #0b5fd7);
    color: #fff;
    box-shadow: 0 8px 18px rgba(11,95,215,.22);
}
.btn:hover { color: #fff; transform: translateY(-1px); }
.btn.secondary { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3); box-shadow: none; }
.card .btn.secondary { background: #eef4fb; color: var(--navy); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.green { background: linear-gradient(135deg, var(--teal-dark), var(--green)); box-shadow: 0 8px 18px rgba(16,185,129,.2); }
.btn.small { padding: 7px 10px; font-size: 12px; border-radius: 9px; }
.btn.wide { width: 100%; }
.form-row { margin-bottom: 14px; }
label { display: block; font-weight: 800; margin-bottom: 6px; color: #253756; }
input, select {
    width: 100%;
    max-width: 440px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    font-size: 15px;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus { outline: 3px solid rgba(23,215,196,.24); border-color: var(--teal-dark); }
.form-actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    max-width: 760px;
}
.permission-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: #f8fbff;
    cursor: pointer;
    margin: 0;
}
.permission-card:hover { border-color: var(--teal-dark); background: #f2fffd; }
.permission-card input { width: auto; margin-top: 3px; }
.permission-card strong { display: block; color: var(--text); }
.permission-card small { display: block; color: var(--muted); font-weight: 600; margin-top: 3px; line-height: 1.35; }
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.login-shell { min-height: calc(100vh - 170px); display: grid; place-items: center; padding: 30px 0; }
.login-panel {
    width: min(440px, 100%);
    background: rgba(255,255,255,.97);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow);
    text-align: left;
}
.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 8px; }
.login-logo { width: 170px; max-width: 70%; height: auto; }
.login-panel h1 { text-align: center; margin: 8px 0 8px; font-size: 32px; letter-spacing: -.04em; }
.login-panel .muted { text-align: center; margin-bottom: 22px; }
.login-form input { max-width: none; }
.footer { color: var(--muted); text-align: center; padding: 20px; font-size: 12px; }
.chart-box { min-height: 0; overflow: hidden; }
.chart-canvas {
    position: relative;
    width: 100%;
    height: 285px;
    max-height: 285px;
}
.chart-canvas-wide {
    height: 310px;
    max-height: 310px;
}
.chart-canvas canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
}
.reports-grid { align-items: stretch; }
.report-filter-form { margin-top: 14px; }
.report-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    align-items: end;
}
.report-filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}
.report-filter-actions .btn { min-height: 42px; }
.muted { color: var(--muted); }
.inline-form { display: inline; }
.refresh-status { display: inline-flex; align-items: center; min-height: 36px; padding: 8px 11px; border-radius: 999px; font-size: 13px; font-weight: 800; background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.22); }
.refresh-status.ok::before { content: '●'; color: var(--teal); margin-right: 7px; }
.refresh-status.loading::before { content: '●'; color: var(--amber); margin-right: 7px; }
.refresh-status.error { background: rgba(239,68,68,.14); color: #fff; }
.refresh-status.error::before { content: '●'; color: #fecaca; margin-right: 7px; }

.sound-help {
    background: rgba(255,255,255,.92);
    border: 1px solid var(--line);
    border-left: 4px solid var(--teal);
    color: var(--muted);
    border-radius: 14px;
    padding: 11px 14px;
    margin: -4px 0 18px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(5, 33, 74, .05);
}
.btn.sound-on {
    background: linear-gradient(135deg, var(--teal-dark), var(--green));
    border-color: rgba(255,255,255,.34);
}
.refresh-status.new {
    background: rgba(23,215,196,.22);
    color: #fff;
    border-color: rgba(23,215,196,.42);
}
.refresh-status.new::before { content: '●'; color: #5ff4e6; margin-right: 7px; }
body.has-new-request .live-card {
    animation: newRequestPulse 1.8s ease-out 1;
}
@keyframes newRequestPulse {
    0% { box-shadow: 0 0 0 0 rgba(23,215,196,.45), var(--shadow); transform: translateY(0); }
    22% { box-shadow: 0 0 0 10px rgba(23,215,196,.18), var(--shadow); transform: translateY(-2px); }
    100% { box-shadow: 0 0 0 0 rgba(23,215,196,0), var(--shadow); transform: translateY(0); }
}
.empty-cell { color: var(--muted); text-align: center; padding: 26px; font-weight: 700; }
@media (max-width: 760px) {
    .topbar { align-items: flex-start; gap: 12px; flex-direction: column; padding: 14px 18px; }
    .nav { padding: 0 14px; }
    .container { padding: 0 14px; margin-top: 16px; }
    .page-hero { flex-direction: column; align-items: flex-start; padding: 22px; }
    .hero-actions { justify-content: flex-start; }
    table { font-size: 13px; }
    th, td { padding: 9px 7px; }
    .login-panel { padding: 24px; }
}

.small-text { font-size: 0.82rem; }
