:root {
    --green: #4F7F3A;
    --green-dark: #2F5D2E;
    --orange: #F5A623;
    --red: #D93025;
    --cream: #FFF8EE;
    --green-soft: #EEF6EA;
    --text: #243024;
    --muted: #687566;
    --border: #C9DEC1;
    --white: #FFFFFF;
    --shadow: 0 18px 50px rgba(47, 93, 46, .12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: linear-gradient(180deg, var(--cream) 0%, #fffdf8 52%, var(--green-soft) 100%);
    font-family: "Nunito", Arial, sans-serif;
    font-size: 16px;
}

a {
    color: var(--green-dark);
    text-decoration: none;
    font-weight: 800;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px clamp(18px, 4vw, 46px);
    background: rgba(255, 248, 238, .92);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
}

.brand,
.brand-large {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: inline-grid;
    width: 48px;
    height: 48px;
    place-items: center;
    color: #fff;
    background: var(--green);
    border: 3px solid #fff;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(79, 127, 58, .22);
    font-weight: 900;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.1;
}

.brand small {
    color: var(--muted);
    font-weight: 700;
}

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

.nav a {
    padding: 10px 12px;
    border-radius: 999px;
}

.nav a:hover {
    background: var(--green-soft);
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 80px;
}

.login-layout {
    display: grid;
    min-height: calc(100vh - 140px);
    place-items: center;
}

.login-card,
.panel,
.form-card,
.stat-card,
.action-card {
    background: rgba(255, 255, 255, .94);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.login-card {
    width: min(520px, 100%);
    padding: clamp(24px, 5vw, 42px);
}

.brand-large {
    align-items: flex-start;
    margin-bottom: 26px;
}

.brand-large .brand-mark {
    width: 62px;
    height: 62px;
    border-radius: 20px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 780px;
    margin-bottom: 8px;
    color: var(--green-dark);
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.04;
}

h2 {
    color: var(--green-dark);
    font-size: 1.35rem;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--orange);
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.hero-band,
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: clamp(22px, 4vw, 36px);
    background: linear-gradient(135deg, #ffffff 0%, #f5fbf0 100%);
    border: 1px solid var(--border);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.hero-band p,
.page-heading p {
    max-width: 650px;
    color: var(--muted);
    font-size: 1.08rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.admin-stats {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.stat-card {
    padding: 20px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 800;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    color: var(--green-dark);
    font-size: 2.2rem;
    line-height: 1;
}

.stat-card.warning strong {
    color: var(--red);
}

.action-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.action-card {
    padding: 20px;
    transition: transform .18s ease, box-shadow .18s ease;
}

.action-card:hover {
    transform: translateY(-2px);
}

.action-card strong,
.action-card span {
    display: block;
}

.action-card span {
    margin-top: 4px;
    color: var(--muted);
    font-weight: 700;
}

.panel,
.form-card {
    margin-bottom: 20px;
    padding: clamp(18px, 3vw, 28px);
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
}

.form-stack,
.child-form {
    display: grid;
    gap: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

label span,
label small {
    display: block;
    margin-bottom: 7px;
    color: var(--green-dark);
    font-weight: 900;
}

label small,
.helper,
.notice,
.muted {
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    font: inherit;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 4px rgba(79, 127, 58, .14);
}

textarea {
    min-height: 125px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    white-space: nowrap;
}

.btn-primary {
    color: #fff;
    background: var(--green);
}

.btn-secondary {
    color: var(--green-dark);
    background: var(--green-soft);
    border: 1px solid var(--border);
}

.btn-danger {
    color: #fff;
    background: var(--red);
}

.btn-small {
    min-height: 34px;
    padding: 7px 12px;
    font-size: .9rem;
}

.filters {
    display: grid;
    grid-template-columns: 1.5fr repeat(4, 1fr) auto;
    gap: 10px;
    margin-bottom: 18px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid #e5efdf;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--green-dark);
    font-size: .86rem;
    text-transform: uppercase;
}

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

.badge,
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green-dark);
    font-size: .86rem;
    font-weight: 900;
}

.badge-epipen,
.tag-red {
    background: #fdecea;
    color: var(--red);
}

.badge-allergy,
.badge-complex-case,
.badge-needs-clarification {
    background: #fff1d6;
    color: #8a5900;
}

.badge-inactive {
    background: #eeeeee;
    color: #6b6b6b;
}

.allergy-list {
    display: grid;
    gap: 8px;
}

.allergy-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 92px 92px;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fbfff8;
    border: 1px solid #e3efd9;
    border-radius: 14px;
}

.allergy-head {
    background: var(--green-dark);
    color: #fff;
    font-weight: 900;
}

.check-cell {
    display: grid;
    place-items: center;
}

.check-cell input,
.checkbox-grid input,
.radio-row input,
.option-stack input,
.confirmation-card input {
    width: 20px;
    height: 20px;
    min-height: 20px;
    accent-color: var(--green);
}

.epipen-cell input {
    accent-color: var(--red);
}

.other-allergy {
    display: none;
    margin-top: 16px;
}

.other-allergy.is-visible {
    display: block;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.checkbox-grid label,
.radio-row label,
.option-stack label,
.confirmation-card label {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
}

.radio-row,
.option-stack {
    display: grid;
    gap: 12px;
}

.sticky-submit {
    position: sticky;
    bottom: 14px;
    z-index: 10;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px;
    background: rgba(255, 248, 238, .9);
    border: 1px solid var(--border);
    border-radius: 999px;
    backdrop-filter: blur(10px);
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    font-weight: 800;
}

.flash-success {
    background: var(--green-soft);
    color: var(--green-dark);
    border: 1px solid var(--border);
}

.flash-error {
    background: #fdecea;
    color: var(--red);
    border: 1px solid #f5bbb5;
}

.demo-note {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: .92rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.details {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px;
}

.details dt {
    color: var(--muted);
    font-weight: 900;
}

.details dd {
    margin: 0;
}

.note-box {
    padding: 14px;
    background: var(--green-soft);
    border-radius: 14px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

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

.activity-item {
    padding: 14px;
    background: #fbfff8;
    border: 1px solid #e3efd9;
    border-radius: 16px;
}

.activity-item p {
    margin: 4px 0;
}

.activity-item span {
    color: var(--muted);
    font-size: .9rem;
    font-weight: 800;
}

@media (max-width: 980px) {
    .stats-grid,
    .admin-stats,
    .action-row,
    .detail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 680px) {
    .topbar,
    .hero-band,
    .page-heading,
    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        width: 100%;
    }

    .stats-grid,
    .admin-stats,
    .action-row,
    .form-grid,
    .checkbox-grid,
    .detail-grid,
    .filters {
        grid-template-columns: 1fr;
    }

    .allergy-row {
        grid-template-columns: minmax(120px, 1fr) 70px 70px;
        padding: 9px;
    }

    .sticky-submit {
        border-radius: 20px;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .details {
        grid-template-columns: 1fr;
    }
}

