/* ─────────────────────────────────────────────────────────────────────
   LDF Makoanyane Military Hospital — Global Stylesheet
   Palette: Maroon #6B0F1A | Gold #D4AF37 | Navy #1A1A2E | Light #F5F0F0
   ───────────────────────────────────────────────────────────────────── */

:root {
    --maroon: #6b0f1a;
    --maroon-dark: #4e0912;
    --maroon-hover: #8b1a2a;
    --maroon-light: #f9edef;
    --gold: #d4af37;
    --gold-light: #f7f0d0;
    --navy: #1a1a2e;
    --text-primary: #1a1a2e;
    --text-secondary: #6b6b80;
    --text-muted: #9999aa;
    --bg: #f5f0f0;
    --bg-card: #ffffff;
    --border: #e8e0e0;
    --sidebar-w: 260px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm:
        0 1px 3px rgba(107, 15, 26, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:
        0 4px 16px rgba(107, 15, 26, 0.1), 0 2px 6px rgba(0, 0, 0, 0.06);
    --transition: 0.2s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    padding-left: var(--sidebar-w);
    line-height: 1.6;
}

/* ──────────────────────────────── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--maroon);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.crest {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-family: "Playfair Display", serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #fff;
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section-label {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.35);
    padding: 16px 8px 6px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition:
        background var(--transition),
        color var(--transition);
}

.nav-item svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-item.active {
    background: var(--gold);
    color: var(--maroon-dark);
    font-weight: 600;
}

.nav-item.active svg {
    stroke: var(--maroon-dark);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--maroon-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.825rem;
    font-weight: 600;
    color: #fff;
    display: block;
}

.user-role {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    display: block;
}

/* ──────────────────────────────── MAIN ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.main-content > .app-footer {
    margin-top: auto;
}

/* ──────────────────────────────── TOPBAR ── */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 68px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--maroon);
    border-radius: 2px;
}

.topbar-title {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-eyebrow {
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    color: var(--maroon);
    font-weight: 700;
    line-height: 1;
}

.page-heading {
    font-family: "Playfair Display", serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.2;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 20px;
}

.date-badge svg {
    width: 14px;
    height: 14px;
    stroke: var(--maroon);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: background var(--transition);
}

.btn-icon:hover {
    background: var(--bg);
}

.btn-icon svg {
    width: 17px;
    height: 17px;
    stroke: var(--text-secondary);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--maroon);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ──────────────────────────────── HERO BAND ── */
.hero-band {
    background: linear-gradient(
        135deg,
        var(--maroon-dark) 0%,
        var(--maroon) 60%,
        var(--maroon-hover) 100%
    );
    color: #fff;
    padding: 32px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

.hero-band::before {
    content: "";
    position: absolute;
    top: -40px;
    right: -40px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.08);
    pointer-events: none;
}

.hero-band::after {
    content: "LDF";
    position: absolute;
    right: 280px;
    top: 50%;
    transform: translateY(-50%);
    font-family: "Playfair Display", serif;
    font-size: 7rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.04);
    letter-spacing: 0.2em;
    pointer-events: none;
}

.hero-eyebrow {
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    color: var(--gold);
    font-weight: 700;
    margin-bottom: 6px;
}

.hero-title {
    font-family: "Playfair Display", serif;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 8px;
}

.hero-sub {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.65);
    max-width: 400px;
}

.hero-stats {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-shrink: 0;
}

.hero-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.hs-value {
    font-family: "Playfair Display", serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
}

.hs-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-divider {
    width: 1px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
}

/* ──────────────────────────────── CONTENT PADDING ── */
.main-content > *:not(.topbar):not(.hero-band) {
    padding-left: 28px;
    padding-right: 28px;
}

.main-content > .section-grid,
.main-content > .dual-panel,
.main-content > .panel {
    padding-left: 28px;
    padding-right: 28px;
}

/* ──────────────────────────────── KPI CARDS ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding-top: 24px;
    padding-bottom: 8px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kpi-maroon {
    background: var(--maroon-light);
}
.kpi-maroon svg {
    stroke: var(--maroon);
    fill: none;
}
.kpi-gold {
    background: var(--gold-light);
}
.kpi-gold svg {
    stroke: var(--gold);
    fill: none;
}
.kpi-green {
    background: #edfaf4;
}
.kpi-green svg {
    stroke: #1b7b4e;
    fill: none;
}
.kpi-red {
    background: #fef0f0;
}
.kpi-red svg {
    stroke: #c0392b;
    fill: #c0392b;
}
.kpi-blue {
    background: #eff4fe;
}
.kpi-blue svg {
    stroke: #2563eb;
    fill: none;
}
.kpi-purple {
    background: #f4effd;
}
.kpi-purple svg {
    stroke: #7c3aed;
    fill: none;
}
.kpi-teal {
    background: #e6f7f7;
}
.kpi-teal svg {
    stroke: #0d9488;
    fill: none;
}
.kpi-emerald {
    background: #ecfdf5;
}
.kpi-emerald svg {
    stroke: #059669;
    fill: none;
}

.kpi-data {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-family: "Playfair Display", serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
}

.kpi-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.kpi-delta {
    font-size: 0.71rem;
    font-weight: 600;
    margin-top: 4px;
}

.kpi-delta.up {
    color: #1b7b4e;
}
.kpi-delta.down {
    color: #c0392b;
}
.kpi-delta.neutral {
    color: var(--text-muted);
}

/* ──────────────────────────────── DUAL PANEL ── */
.dual-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding-top: 24px;
}

/* ──────────────────────────────── PANEL ── */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-family: "Playfair Display", serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--navy);
}

.panel-link {
    font-size: 0.78rem;
    color: var(--maroon);
    text-decoration: none;
    font-weight: 600;
    transition: color var(--transition);
}

.panel-link:hover {
    color: var(--maroon-hover);
}

.mt-6 {
    margin-top: 20px;
}

/* ──────────────────────────────── DATA TABLE ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.845rem;
}

.data-table thead {
    background: var(--bg);
}

.data-table th {
    padding: 10px 20px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table tbody tr:hover {
    background: #faf6f6;
}

.patient-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.p-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--maroon-light);
    color: var(--maroon);
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.p-id {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ──────────────────────────────── BADGES ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.69rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.badge-stable {
    background: #edfaf4;
    color: #1b7b4e;
}
.badge-critical {
    background: #fef0f0;
    color: #c0392b;
}
.badge-post-op {
    background: var(--maroon-light);
    color: var(--maroon);
}
.badge-observation {
    background: var(--gold-light);
    color: #7a6000;
}
.badge-done {
    background: #eff4fe;
    color: #2563eb;
}
.badge-in-progress {
    background: var(--maroon-light);
    color: var(--maroon);
}
.badge-upcoming {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* ──────────────────────────────── APPOINTMENTS ── */
.appt-list {
    padding: 8px 0;
}

.appt-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.appt-item:last-child {
    border-bottom: none;
}
.appt-item:hover {
    background: #faf6f6;
}

.appt-current {
    background: var(--maroon-light);
    border-left: 3px solid var(--maroon);
}

.appt-time {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--maroon);
    min-width: 44px;
    font-variant-numeric: tabular-nums;
}

.appt-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.appt-info strong {
    font-size: 0.845rem;
    color: var(--navy);
}

.appt-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ──────────────────────────────── WARD OCCUPANCY ── */
.ward-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.ward-card {
    padding: 16px 20px;
    border-right: 1px solid var(--border);
}

.ward-card:nth-child(3n) {
    border-right: none;
}
.ward-card:nth-child(n + 4) {
    border-top: 1px solid var(--border);
}

.ward-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ward-bar-wrap {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.ward-bar {
    height: 100%;
    background: var(--maroon);
    border-radius: 3px;
    transition: width 0.6s ease;
}

.ward-bar-critical {
    background: #c0392b;
}
.ward-bar-green {
    background: #1b7b4e;
}

.ward-numbers {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.ward-pct {
    font-weight: 700;
    color: var(--maroon);
}
.ward-pct-critical {
    color: #c0392b;
}

/* ──────────────────────────────── ALERTS ── */
.alerts-list {
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.845rem;
    line-height: 1.5;
}

.alert-item svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-critical {
    background: #fef0f0;
}
.alert-critical svg {
    stroke: #c0392b;
}
.alert-critical strong {
    color: #c0392b;
}

.alert-warning {
    background: var(--gold-light);
}
.alert-warning svg {
    stroke: #7a6000;
}
.alert-warning strong {
    color: #7a6000;
}

.alert-info {
    background: #eff4fe;
}
.alert-info svg {
    stroke: #2563eb;
}
.alert-info strong {
    color: #2563eb;
}

/* ──────────────────────────────── FORM ELEMENTS ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.form-control {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-size: 0.875rem;
    font-family: "Inter", sans-serif;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
    width: 100%;
}

.form-control:focus {
    border-color: var(--maroon);
    box-shadow: 0 0 0 3px rgba(107, 15, 26, 0.1);
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* ──────────────────────────────── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.845rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition:
        background var(--transition),
        box-shadow var(--transition);
    font-family: "Inter", sans-serif;
    text-decoration: none;
    white-space: nowrap;
}

.btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.btn-primary:hover {
    background: var(--maroon-hover);
    box-shadow: 0 3px 10px rgba(107, 15, 26, 0.25);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-gold {
    background: var(--gold);
    color: var(--maroon-dark);
}

.btn-gold:hover {
    background: #c9a62e;
}

.btn-danger {
    background: #c0392b;
    color: #fff;
}

.btn-danger:hover {
    background: #a93226;
}

.btn-sm {
    padding: 6px 13px;
    font-size: 0.775rem;
}

/* ──────────────────────────────── PAGE TOOLBAR ── */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 0;
    gap: 16px;
}

.toolbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    min-width: 280px;
}

.toolbar-search svg {
    width: 15px;
    height: 15px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    flex-shrink: 0;
}

.toolbar-search input {
    border: none;
    outline: none;
    font-size: 0.845rem;
    font-family: "Inter", sans-serif;
    color: var(--text-primary);
    background: transparent;
    width: 100%;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ──────────────────────────────── FILTER TABS ── */
.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.filter-tab {
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition:
        background var(--transition),
        color var(--transition);
    font-family: "Inter", sans-serif;
}

.filter-tab.active,
.filter-tab:hover {
    background: var(--bg-card);
    color: var(--maroon);
    font-weight: 600;
}

.filter-tab.active {
    box-shadow: var(--shadow-sm);
}

/* ──────────────────────────────── MODAL ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: translateY(8px);
    transition: transform var(--transition);
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-family: "Playfair Display", serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--navy);
}

.modal-close {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ──────────────────────────────── PAGINATION ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.page-buttons {
    display: flex;
    gap: 4px;
}

.page-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: "Inter", sans-serif;
    transition: background var(--transition);
}

.page-btn:hover {
    background: var(--bg);
}

.page-btn.active {
    background: var(--maroon);
    color: #fff;
    border-color: var(--maroon);
}

/* ──────────────────────────────── SECTION PADDING ── */
.section-pad {
    padding-top: 24px;
    padding-bottom: 24px;
}

/* ──────────────────────────────── INFO GRID (detail view) ── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.info-cell {
    padding: 14px 20px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.info-cell:nth-child(3n) {
    border-right: none;
}

.info-cell-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.info-cell-value {
    font-size: 0.895rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ──────────────────────────────── STAT STRIP ── */
.stat-strip {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 20px 0 0;
}

.stat-strip-item {
    flex: 1;
    padding: 16px 20px;
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-strip-item:last-child {
    border-right: none;
}

.strip-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--maroon-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.strip-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--maroon);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.strip-data-val {
    font-family: "Playfair Display", serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
    display: block;
}

.strip-data-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 2px;
}

/* ──────────────────────────────── APP FOOTER ── */
.app-footer {
    margin-top: 28px;
    padding: 0 28px;
}

.footer-inner {
    border-top: 1px solid var(--border);
    padding: 18px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-dev {
    font-size: 0.74rem;
}

.footer-dev a {
    color: var(--maroon);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.footer-dev a:hover {
    color: var(--maroon-hover);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* ──────────────────────────────── RESPONSIVE ── */
@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .hero-stats {
        display: none;
    }
    .dual-panel {
        grid-template-columns: 1fr;
    }
    .ward-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .form-row-3 {
        grid-template-columns: 1fr 1fr;
    }
    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .info-cell:nth-child(3n) {
        border-right: 1px solid var(--border);
    }
    .info-cell:nth-child(2n) {
        border-right: none;
    }
}

@media (max-width: 768px) {
    body {
        padding-left: 0;
    }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .hamburger {
        display: flex;
    }
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .hero-band {
        flex-direction: column;
        align-items: flex-start;
    }
    .stat-strip {
        flex-direction: column;
    }
    .stat-strip-item {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .stat-strip-item:last-child {
        border-bottom: none;
    }
    .topbar {
        padding: 0 16px;
    }
    .main-content > .section-grid,
    .main-content > .dual-panel,
    .main-content > .panel {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ──────────────────────────────── MOBILE BACKDROP ── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.55);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar-backdrop.show {
    opacity: 1;
}

/* ═══════════════════════
   MOBILE / SMALL SCREEN LAYER
   ═══════════════════════ */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }

    /* Sidebar: slide-over with backdrop */
    .sidebar {
        width: 280px;
        max-width: 84vw;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
    }

    .sidebar-backdrop.visible {
        display: block;
    }

    /* Topbar */
    .topbar {
        height: 60px;
        padding: 0 12px;
        gap: 10px;
    }

    .page-heading {
        font-size: 1.05rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 42vw;
    }

    .date-badge {
        display: none;
    }

    .user-dropdown-name,
    .user-dropdown-chevron {
        display: none;
    }

    .user-dropdown {
        padding: 4px;
        border-radius: 50%;
        border: none;
    }

    .user-dropdown-avatar {
        width: 34px;
        height: 34px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    /* Content padding */
    .main-content > *:not(.topbar):not(.hero-band) {
        padding-left: 14px;
        padding-right: 14px;
    }

    .main-content > .section-grid,
    .main-content > .dual-panel,
    .main-content > .panel {
        padding-left: 14px;
        padding-right: 14px;
    }

    .alert-item.alert-info,
    .alert-item.alert-critical {
        margin-left: 14px !important;
        margin-right: 14px !important;
    }

    /* Hero band */
    .hero-band {
        padding: 22px 16px;
        gap: 16px;
    }

    .hero-title {
        font-size: 1.25rem;
    }

    .hero-sub {
        font-size: 0.8rem;
    }

    .hero-stats {
        display: flex;
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .hero-stat {
        flex: 1;
    }

    .hero-divider {
        height: 36px;
    }

    .hs-value {
        font-size: 1.5rem;
    }

    .hero-band::after {
        font-size: 4rem;
        right: -20px;
    }

    /* KPI cards */
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding-top: 16px;
    }

    .kpi-grid[style*="grid-template-columns"],
    div[class].kpi-grid {
        grid-template-columns: 1fr !important;
    }

    .kpi-card {
        padding: 14px;
        gap: 12px;
        min-width: 0;
        max-width: 100%;
    }

    .kpi-card > div {
        min-width: 0;
    }

    .kpi-icon {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }

    .kpi-value {
        font-size: 1.35rem;
        word-break: break-word;
    }

    .kpi-label {
        font-size: 0.72rem;
        overflow-wrap: anywhere;
    }

    /* Tables → wrap cells within panel width */
    .panel {
        display: flex;
        flex-direction: column;
        max-width: 100%;
    }

    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        width: auto;
    }

    .data-table thead,
    .data-table tbody {
        display: table;
        width: 100%;
        max-width: 100%;
        table-layout: fixed;
    }

    .data-table tr {
        display: table-row;
    }

    .data-table th,
    .data-table td {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .data-table td,
    .data-table th {
        padding: 10px 14px;
        white-space: normal;
    }

    /* Panels */
    .panel-header {
        padding: 14px 14px 10px;
        gap: 10px;
    }

    .panel-title {
        font-size: 0.92rem;
    }

    .dual-panel {
        gap: 12px;
        padding-top: 16px;
    }

    .mt-6 {
        margin-top: 14px;
    }

    /* Ward grid */
    .ward-grid {
        grid-template-columns: 1fr;
    }

    .ward-card {
        padding: 12px 14px;
    }

    .ward-card:nth-child(3n) {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .ward-card:last-child {
        border-bottom: none;
    }

    /* Info grid */
    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-cell {
        border-right: none;
        padding: 10px 14px;
    }

    .info-cell:nth-child(3n) {
        border-right: none;
    }

    .info-cell:nth-child(2n) {
        border-right: none;
    }

    /* Stat strip */
    .stat-strip-item {
        padding: 12px 14px;
    }

    /* Page toolbar */
    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .toolbar-search {
        min-width: 0;
        width: 100%;
        order: -1;
    }

    .toolbar-right {
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar-right .btn {
        flex: 1;
        justify-content: center;
        min-width: 120px;
    }

    /* Filter tabs scrollable */
    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .filter-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Modals full-bleed-ish */
    .modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .modal {
        max-height: 92vh;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-header {
        padding: 16px 16px 12px;
    }

    .modal-footer {
        padding: 12px 16px;
    }

    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }

    /* Forms */
    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .btn {
        padding: 10px 18px;
    }

    .btn-sm {
        padding: 8px 14px;
    }

    /* Pagination */
    .pagination {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    /* Footer */
    .app-footer {
        padding: 0 14px;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .user-menu {
        position: fixed;
        top: 60px;
        right: 10px;
        left: auto;
    }
}

/* Very small phones */
@media (max-width: 380px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .hero-stats {
        flex-wrap: wrap;
    }

    .toolbar-right .btn {
        min-width: 100%;
    }
}

/* ═══════════════════════
   SHARED MOBILE FIXES FOR ALL ADMIN PAGES
   (forms, panels, selects, buttons rows, page headers)
   ═══════════════════════ */
@media (max-width: 768px) {
    /* Form panels created inline with wrappers */
    .panel[style*="max-width"],
    .panel[style*="width:100%"] {
        max-width: 100% !important;
        width: 100% !important;
    }

    .panel > div[style*="padding: 24px"],
    .panel > div[style*="padding:24px"] {
        padding: 14px !important;
    }

    /* Action button rows at bottom of forms */
    div[style*="justify-content:flex-end"],
    div[style*="justify-content: flex-end"] {
        flex-direction: column-reverse;
    }

    div[style*="justify-content:flex-end"] .btn,
    div[style*="justify-content: flex-end"] .btn {
        width: 100%;
        justify-content: center;
    }

    /* Toolbar filter selects */
    .page-toolbar select.form-control {
        width: 100% !important;
    }

    .toolbar-right {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .toolbar-right select.form-control,
    .toolbar-right .btn {
        width: 100%;
    }

    /* Detail pages with fixed-width label cells */
    .data-table td[style*="width:180px"] {
        width: auto;
        white-space: normal;
    }

    /* Panels centered via parent flex wrappers */
    div[style*="justify-content:center"] {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    /* Header rows with padding:0 28px */
    div[style*="padding:0 28px"],
    div[style*="padding: 0 28px"],
    div[style*="padding:16px 28px"] {
        padding-left: 14px !important;
        padding-right: 14px !important;
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Wide inline grid rows collapse */
    div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Table action buttons wrap */
    .data-table td {
        vertical-align: middle;
    }

    .data-table td .btn-sm {
        margin: 2px 0;
    }

    /* Beds grid in ward detail */
    .beds-grid {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)) !important;
    }

    /* Staff card */
    div[style*="max-width:520px"],
    div[style*="max-width:520px;"] {
        max-width: 100% !important;
    }

    /* Inline min-width search boxes & wide inline grids (lab, pharmacy, queue) */
    .toolbar-search[style*="min-width"] {
        min-width: 0 !important;
    }

    td[style*="min-width"],
    div[style*="min-width:320px"],
    div[style*="min-width:280px"],
    div[style*="min-width:260px"],
    div[style*="min-width:240px"] {
        min-width: 0 !important;
        max-width: 100%;
    }

    div[style*="repeat(2,minmax(100px,1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Generic inline flex rows wrap instead of overflowing */
    .panel td > div[style*="display:flex"] {
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}
