:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e2ef;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --accent: #2563eb;
    --danger: #b42318;
    --warning: #b45309;
    --success: #047857;
    --soft: #eef6f6;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #e9f7f4 0%, #edf3ff 100%); }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: 0 20px 60px rgba(21, 35, 66, .12); }
.login-card h1 { margin: 0 0 8px; font-size: 28px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { background: #102a43; color: #edf5ff; padding: 22px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: grid; gap: 4px; margin-bottom: 22px; }
.brand strong { font-size: 22px; letter-spacing: 0; }
.brand span { color: #b9c9d8; font-size: 13px; }
.nav { display: grid; gap: 6px; }
.nav a { padding: 10px 12px; border-radius: 6px; color: #dbe9f6; }
.nav a.active, .nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.main { min-width: 0; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .user { color: var(--muted); font-size: 14px; }
.content { padding: 28px; max-width: 1400px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-header h1 { margin: 0 0 6px; font-size: 26px; }
.page-header p { margin: 0; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.metric span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.metric strong { font-size: 26px; }

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.money { font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 650; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #cfd8e3; border-radius: 6px; padding: 10px 11px; background: #fff; color: var(--ink); }
.field textarea { min-height: 110px; resize: vertical; }
.check-list { display: flex; gap: 10px; flex-wrap: wrap; }
.check-list label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 6px; min-height: 40px; padding: 9px 14px; cursor: pointer; background: var(--brand); color: #fff; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: #f8fafc; }
.btn.danger { background: var(--danger); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.inline-form { display: inline; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 700; text-transform: capitalize; background: #eef2ff; color: #3730a3; }
.badge.paid, .badge.completed, .badge.signed, .badge.active { background: #ecfdf3; color: var(--success); }
.badge.partial, .badge.checked_in, .badge.open { background: #fff7ed; color: var(--warning); }
.badge.unpaid, .badge.cancelled, .badge.inactive { background: #fef3f2; color: var(--danger); }
.badge.stable, .badge.low, .badge.administered { background: #ecfdf3; color: var(--success); }
.badge.watch, .badge.medium, .badge.held, .badge.scheduled { background: #fff7ed; color: var(--warning); }
.badge.critical, .badge.escalated, .badge.high, .badge.missed { background: #fef2f2; color: var(--danger); }
.alert { margin-bottom: 16px; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.alert.success { border-color: #bbf7d0; background: #f0fdf4; color: var(--success); }
.alert.error { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.detail-list { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.pagination { margin-top: 16px; }
.pagination nav > div:first-child { display: none; }

@media (max-width: 1000px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metrics, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.three, .grid.two, .form-grid { grid-template-columns: 1fr; }
    .content { padding: 20px; }
}

@media (max-width: 640px) {
    .topbar, .page-header { align-items: flex-start; flex-direction: column; }
    .metrics { grid-template-columns: 1fr; }
    .nav { grid-template-columns: 1fr; }
    .detail-list { grid-template-columns: 1fr; }
}

/* Command-center dashboard refresh */
body {
    background:
        linear-gradient(180deg, #eef7fb 0%, #f7fbff 42%, #f8fafc 100%);
}

.content { max-width: 1560px; width: 100%; }
.panel h2 { margin: 0; font-size: 18px; }
th { letter-spacing: 0; }

.sidebar {
    isolation: isolate;
    position: sticky;
    background: linear-gradient(180deg, #083344 0%, #164e63 46%, #0f766e 100%);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, .08), 18px 0 44px rgba(8, 47, 73, .12);
}
.sidebar::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, #22d3ee, #22c55e, #facc15, #38bdf8);
    animation: sidebarRail 6s linear infinite;
    z-index: -1;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.brand-copy { display: grid; gap: 4px; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, #fef2f2, #cffafe);
    color: #dc2626;
    box-shadow: 0 12px 28px rgba(34, 211, 238, .2);
    animation: markPulse 2.8s ease-in-out infinite;
}
.brand-mark svg, .nav-icon, .card-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav { gap: 7px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 11px;
    border: 1px solid transparent;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, background .18s ease, border-color .18s ease, color .18s ease;
}
.nav a::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: #67e8f9;
    transform: scaleY(0);
    transform-origin: center;
    transition: transform .2s ease;
}
.nav a:hover, .nav a.active {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .16);
    transform: translateX(4px);
}
.nav a:hover::after, .nav a.active::after { transform: scaleY(1); }
.nav a.active .nav-icon { color: #fde68a; }
.nav-icon { flex: 0 0 auto; width: 19px; height: 19px; transition: transform .2s ease, color .2s ease; }
.nav a:hover .nav-icon { transform: translateY(-1px) scale(1.08); }
.nav-text { min-width: 0; overflow-wrap: anywhere; }

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
    gap: 24px;
    align-items: center;
    border-radius: 8px;
    padding: 28px;
    margin-bottom: 22px;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, .98), rgba(37, 99, 235, .92) 48%, rgba(126, 34, 206, .88)),
        linear-gradient(90deg, rgba(255, 255, 255, .12) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255, 255, 255, .12) 1px, transparent 1px);
    background-size: auto, 34px 34px, 34px 34px;
    color: #fff;
    box-shadow: 0 26px 70px rgba(15, 23, 42, .18);
}
.hero-copy h1 {
    max-width: 760px;
    margin: 10px 0 12px;
    font-size: 42px;
    line-height: 1.05;
}
.hero-copy p { max-width: 680px; margin: 0; color: rgba(255, 255, 255, .86); font-size: 16px; }
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    color: #082f49;
    background: #cffafe;
    font-size: 13px;
    font-weight: 800;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-actions .btn.secondary { background: rgba(255, 255, 255, .96); }
.hero-signals { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero-signals span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    color: rgba(255, 255, 255, .92);
    font-weight: 700;
}
.signal-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    display: inline-block;
    box-shadow: 0 0 0 5px rgba(255, 255, 255, .12);
    animation: dotPulse 1.8s ease-in-out infinite;
}
.signal-dot.green { background: #4ade80; }
.signal-dot.amber { background: #facc15; }
.signal-dot.blue { background: #67e8f9; }
.hero-visual { min-width: 0; }
.hero-visual img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    filter: drop-shadow(0 22px 34px rgba(8, 47, 73, .26));
    animation: visualFloat 6s ease-in-out infinite;
}

.command-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.command-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    align-items: center;
    min-height: 150px;
    padding: 16px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 16px 38px rgba(15, 23, 42, .08);
    animation: cardRise .55s ease both;
    animation-delay: var(--delay);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.command-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 22px 48px rgba(15, 23, 42, .13);
}
.card-icon {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #0f172a;
    background: #e2e8f0;
}
.card-label { color: var(--muted); font-weight: 750; }
.command-card strong { grid-column: 1 / -1; font-size: 30px; line-height: 1; overflow-wrap: anywhere; }
.card-hint { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }

.tone-teal .card-icon, .tone-teal.pipeline-card { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.tone-blue .card-icon, .tone-blue.pipeline-card { background: #dbeafe; color: #2563eb; border-color: #bfdbfe; }
.tone-purple .card-icon, .tone-purple.pipeline-card { background: #ede9fe; color: #7c3aed; border-color: #ddd6fe; }
.tone-green .card-icon, .tone-green.pipeline-card { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.tone-cyan .card-icon { background: #cffafe; color: #0891b2; }
.tone-indigo .card-icon { background: #e0e7ff; color: #4f46e5; }
.tone-amber .card-icon, .tone-amber.pipeline-card { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.tone-orange .card-icon { background: #ffedd5; color: #c2410c; }
.tone-red .card-icon { background: #fee2e2; color: #b91c1c; }
.tone-violet .card-icon { background: #f3e8ff; color: #8b5cf6; }
.tone-emerald .card-icon { background: #d1fae5; color: #059669; }
.tone-rose .card-icon { background: #ffe4e6; color: #be123c; }

.insight-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.28fr) minmax(280px, .86fr) minmax(280px, .86fr);
    gap: 18px;
    margin-bottom: 18px;
}
.chart-panel { min-height: 326px; }
.finance-chart {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    height: 206px;
    align-items: end;
    padding: 18px 8px 4px;
    border-radius: 8px;
    background: linear-gradient(180deg, #f8fafc, #eef6ff);
    border: 1px solid #e2e8f0;
}
.finance-month { display: grid; gap: 8px; align-items: end; text-align: center; color: var(--muted); font-weight: 750; font-size: 12px; height: 100%; }
.finance-bars { display: flex; align-items: end; justify-content: center; gap: 5px; height: 160px; }
.bar {
    display: block;
    width: 13px;
    min-height: 8px;
    border-radius: 7px 7px 3px 3px;
    transition: height .3s ease;
    animation: barGrow .8s ease both;
}
.bar.invoice, .legend.invoice { background: #2563eb; }
.bar.paid, .legend.paid { background: #10b981; }
.bar.expense, .legend.expense { background: #f97316; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; color: var(--muted); font-size: 13px; font-weight: 750; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }

.status-bars, .occupancy-list { display: grid; gap: 14px; }
.status-row { display: grid; gap: 7px; }
.status-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); font-weight: 750; }
.status-label strong { color: var(--ink); }
.progress-track {
    height: 11px;
    border-radius: 999px;
    background: #eef2f7;
    overflow: hidden;
}
.progress-track span {
    display: block;
    height: 100%;
    min-width: 4%;
    border-radius: inherit;
    background: #64748b;
    animation: widthIn .75s ease both;
}
.status-row.tone-blue .progress-track span { background: #2563eb; }
.status-row.tone-green .progress-track span { background: #16a34a; }
.status-row.tone-teal .progress-track span { background: #0d9488; }
.status-row.tone-red .progress-track span { background: #dc2626; }
.status-row.tone-amber .progress-track span { background: #f59e0b; }

.occupancy-row {
    display: grid;
    grid-template-columns: minmax(120px, .85fr) minmax(160px, 1fr) auto;
    align-items: center;
    gap: 12px;
}
.occupancy-meta { display: grid; gap: 2px; }
.occupancy-meta span { color: var(--muted); font-size: 12px; }
.occupancy-rail {
    height: 16px;
    background: #edf2f7;
    border-radius: 999px;
    overflow: hidden;
}
.occupancy-rail > span {
    display: block;
    height: 100%;
    min-width: 28%;
    background: #dbeafe;
    border-radius: inherit;
}
.occupancy-rail i {
    display: block;
    height: 100%;
    min-width: 4%;
    background: linear-gradient(90deg, #22c55e, #2563eb);
    border-radius: inherit;
    animation: widthIn .75s ease both;
}
.occupancy-row b { font-size: 13px; color: var(--brand-dark); }

.pipeline-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.pipeline-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 74px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    font-weight: 800;
    transition: transform .18s ease, box-shadow .18s ease;
}
.pipeline-card strong { font-size: 28px; }
.pipeline-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(15, 23, 42, .1); }

.dashboard-tables {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.dashboard-tables .panel:last-child:nth-child(odd) { grid-column: 1 / -1; }
.dashboard-tables table { min-width: 660px; }
.badge.scheduled, .badge.ordered { background: #dbeafe; color: #1d4ed8; }
.badge.sample_collected, .badge.processing, .badge.in_progress { background: #fef3c7; color: #92400e; }
.badge.no_show { background: #fef3c7; color: #b45309; }

@keyframes sidebarRail {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}
@keyframes markPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
@keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: .95; }
    50% { transform: scale(1.25); opacity: .72; }
}
@keyframes visualFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
@keyframes cardRise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes barGrow {
    from { transform: scaleY(.18); transform-origin: bottom; }
    to { transform: scaleY(1); transform-origin: bottom; }
}
@keyframes widthIn {
    from { transform: scaleX(.1); transform-origin: left; }
    to { transform: scaleX(1); transform-origin: left; }
}

@media (max-width: 1200px) {
    .dashboard-hero, .insight-grid { grid-template-columns: 1fr; }
    .hero-copy h1 { font-size: 34px; }
    .pipeline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
    .sidebar { position: static; height: auto; }
    .sidebar::before { width: 100%; height: 4px; inset: 0 0 auto 0; }
    .nav a:hover, .nav a.active { transform: translateY(-1px); }
}

@media (max-width: 760px) {
    .dashboard-hero { padding: 20px; }
    .hero-copy h1 { font-size: 29px; }
    .hero-signals span { width: 100%; }
    .command-metrics, .pipeline-grid, .dashboard-tables { grid-template-columns: 1fr; }
    .finance-chart { gap: 7px; }
    .finance-bars { gap: 3px; }
    .bar { width: 10px; }
    .occupancy-row { grid-template-columns: 1fr; align-items: start; }
    .dashboard-tables .panel:last-child:nth-child(odd) { grid-column: auto; }
}

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

/* Global page polish and workflow controls */
.page-header {
    padding: 22px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #f8fbff 58%, #ecfeff);
    box-shadow: 0 18px 44px rgba(15, 23, 42, .07);
}
.page-header h1 { font-size: 30px; line-height: 1.1; }
.panel {
    box-shadow: 0 14px 34px rgba(15, 23, 42, .06);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.panel:hover { border-color: #bfdbfe; box-shadow: 0 18px 42px rgba(15, 23, 42, .08); }
.spaced-panel { margin-top: 18px; }
.toolbar {
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background: rgba(255, 255, 255, .82);
    box-shadow: 0 12px 28px rgba(15, 23, 42, .05);
}
.search-form input,
.search-form select,
.quick-form input,
.quick-form textarea,
.quick-pay input {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    min-height: 38px;
    padding: 9px 10px;
    background: #fff;
    color: var(--ink);
}
.search-form input:focus,
.search-form select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.quick-form input:focus,
.quick-form textarea:focus,
.quick-pay input:focus {
    outline: 3px solid rgba(37, 99, 235, .16);
    border-color: #2563eb;
}
.table-wrap {
    box-shadow: 0 12px 32px rgba(15, 23, 42, .05);
}
tbody tr {
    transition: background .16s ease;
}
tbody tr:hover { background: #f8fbff; }
td a:not(.btn) { color: #075985; font-weight: 750; }
td a:not(.btn):hover { color: #0f766e; }
.btn {
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(15, 118, 110, .16);
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(15, 118, 110, .2); }
.btn.secondary { box-shadow: 0 8px 18px rgba(15, 23, 42, .06); }
.btn.warning { background: #f59e0b; color: #111827; }
.btn.warning:hover { background: #d97706; color: #111827; }
.btn.danger:hover { background: #991b1b; }
.btn:disabled,
button:disabled {
    cursor: not-allowed;
    opacity: .55;
    transform: none;
    box-shadow: none;
}
.row-actions,
.status-actions,
.compact-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}
.row-actions form,
.status-actions form,
.compact-actions form { margin: 0; }
.quick-pay {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.quick-pay input { width: 98px; min-height: 32px; padding: 6px 8px; }
.workflow-panel {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(280px, 1.2fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 18px;
    border-color: #bfdbfe;
    background: linear-gradient(135deg, #ffffff, #eff6ff);
}
.workflow-panel h2 { margin: 0 0 4px; }
.quick-form {
    display: grid;
    grid-template-columns: minmax(160px, 220px) auto;
    gap: 10px;
    align-items: start;
}
.quick-form.wide { grid-template-columns: minmax(190px, 250px) minmax(260px, 1fr) auto; }
.quick-form textarea { min-height: 74px; resize: vertical; }
.status-actions .btn { min-height: 36px; }
.total-panel {
    background: linear-gradient(135deg, #ffffff, #f0fdf4);
    border-color: #bbf7d0;
}
.badge.reserved { background: #fef3c7; color: #92400e; }
.badge.maintenance, .badge.void { background: #f1f5f9; color: #475569; }
.badge.occupied { background: #fee2e2; color: #b91c1c; }
.badge.available { background: #dcfce7; color: #15803d; }
.badge.discharged, .badge.approved { background: #d1fae5; color: #047857; }
.badge.transferred { background: #e0e7ff; color: #4338ca; }
.badge.cancelled, .badge.cancelled button { background: #fee2e2; color: #b91c1c; }
.badge.in_consultation, .badge.processing, .badge.scheduled { background: #dbeafe; color: #1d4ed8; }
.badge.sample_collected, .badge.in_progress { background: #fef3c7; color: #b45309; }
.form-grid {
    padding: 20px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .05);
}
.field label { color: #334155; }
.field input,
.field select,
.field textarea {
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field input:hover,
.field select:hover,
.field textarea:hover { border-color: #94a3b8; }
.detail-list {
    padding-top: 6px;
}
.detail-list dt { font-weight: 750; }
.detail-list dd { min-width: 0; overflow-wrap: anywhere; }
.alert { box-shadow: 0 10px 24px rgba(15, 23, 42, .05); }
.pagination nav { display: flex; justify-content: center; }
.login-card { border-color: rgba(14, 165, 233, .22); }
.login-card::before {
    content: "";
    display: block;
    height: 4px;
    margin: -28px -28px 22px;
    background: linear-gradient(90deg, #0f766e, #2563eb, #f59e0b, #dc2626);
}

@media (max-width: 900px) {
    .workflow-panel,
    .quick-form,
    .quick-form.wide { grid-template-columns: 1fr; }
    .quick-form input,
    .quick-form textarea { width: 100%; }
}

@media (max-width: 640px) {
    .page-header { padding: 18px; }
    .page-header h1 { font-size: 25px; }
    .row-actions,
    .status-actions,
    .compact-actions,
    .quick-pay { align-items: stretch; flex-direction: column; }
    .row-actions .btn,
    .status-actions .btn,
    .compact-actions .btn,
    .quick-pay input { width: 100%; }
}

/* Full-width responsive shell fix */
html,
body {
    min-width: 320px;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}
body {
    background:
        linear-gradient(90deg, rgba(37, 99, 235, .04) 1px, transparent 1px),
        linear-gradient(180deg, rgba(20, 184, 166, .045) 1px, transparent 1px),
        linear-gradient(180deg, #eef7fb 0%, #f8fbff 44%, #f8fafc 100%);
    background-size: 34px 34px, 34px 34px, auto;
}
.app-shell {
    width: 100%;
    max-width: none;
    grid-template-columns: minmax(250px, 282px) minmax(0, 1fr);
}
.main {
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .74), rgba(236, 253, 245, .42)),
        linear-gradient(180deg, rgba(219, 234, 254, .45), rgba(248, 250, 252, .92));
}
.topbar,
.content {
    width: 100%;
    max-width: none !important;
}
.content {
    margin: 0;
    padding: clamp(16px, 2vw, 32px);
}
.content > * {
    min-width: 0;
}
.grid,
.metrics,
.command-metrics,
.insight-grid,
.pipeline-grid,
.dashboard-tables,
.form-grid {
    width: 100%;
}
.grid > *,
.metrics > *,
.command-metrics > *,
.insight-grid > *,
.pipeline-grid > *,
.dashboard-tables > *,
.form-grid > *,
.panel,
.page-header,
.toolbar {
    min-width: 0;
}
.panel,
.page-header,
.toolbar,
.table-wrap {
    backdrop-filter: saturate(120%) blur(6px);
}
.table-wrap {
    width: 100%;
    max-width: 100%;
    overscroll-behavior-inline: contain;
}
table {
    max-width: 100%;
}
.actions,
.search-form,
.row-actions,
.status-actions,
.compact-actions,
.hero-actions,
.hero-signals {
    min-width: 0;
}
.actions > *,
.search-form > *,
.row-actions > *,
.status-actions > *,
.compact-actions > * {
    max-width: 100%;
}
.search-form input[type="search"] {
    min-width: min(320px, 100%);
    flex: 1 1 260px;
}
.search-form select,
.search-form .btn {
    flex: 0 1 auto;
}
.btn,
.badge,
.nav a,
.pipeline-card,
.command-card {
    overflow-wrap: anywhere;
}

@media (min-width: 1500px) {
    .command-metrics {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
    .dashboard-tables {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .dashboard-tables .panel:last-child:nth-child(odd) {
        grid-column: auto;
    }
    .grid.four {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1800px) {
    .insight-grid {
        grid-template-columns: minmax(0, 1.35fr) minmax(320px, .82fr) minmax(320px, .82fr);
    }
    .dashboard-hero {
        grid-template-columns: minmax(0, 1.2fr) minmax(420px, .8fr);
    }
}

@media (max-width: 1280px) {
    .app-shell {
        grid-template-columns: 244px minmax(0, 1fr);
    }
    .sidebar {
        padding-inline: 14px;
    }
    .nav a {
        padding-inline: 10px;
    }
    .command-metrics {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }
}

@media (max-width: 1100px) {
    .topbar {
        min-height: 68px;
        height: auto;
        padding-block: 12px;
    }
    .dashboard-hero {
        grid-template-columns: 1fr;
    }
    .hero-visual img {
        max-height: 300px;
    }
}

@media (max-width: 1000px) {
    .app-shell {
        display: block;
    }
    .main {
        min-height: auto;
    }
    .sidebar {
        position: relative;
        top: auto;
        height: auto;
        max-height: none;
        border-bottom: 1px solid rgba(255, 255, 255, .16);
    }
    .brand {
        margin-bottom: 14px;
    }
    .nav {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    .content {
        padding: clamp(14px, 3vw, 24px);
    }
}

@media (max-width: 760px) {
    .topbar {
        padding: 14px 16px;
    }
    .topbar form,
    .topbar .btn {
        width: 100%;
    }
    .sidebar {
        padding: 16px;
    }
    .nav {
        grid-template-columns: 1fr;
        max-height: 48vh;
        overflow-y: auto;
        padding-right: 2px;
    }
    .dashboard-hero {
        gap: 18px;
        padding: 18px;
    }
    .hero-copy h1 {
        font-size: 27px;
        line-height: 1.12;
    }
    .hero-copy p {
        font-size: 15px;
    }
    .command-card {
        min-height: 126px;
    }
    .panel,
    .page-header,
    .toolbar,
    .form-grid {
        padding: 16px;
    }
    table {
        min-width: 620px;
    }
}

@media (max-width: 520px) {
    .content {
        padding: 12px;
    }
    .brand {
        align-items: flex-start;
    }
    .brand-mark {
        width: 38px;
        height: 38px;
    }
    .hero-actions .btn,
    .search-form .btn,
    .search-form input,
    .search-form select,
    .actions .btn,
    .actions form,
    .actions button,
    .status-actions form,
    .status-actions button,
    .row-actions form,
    .row-actions button,
    .row-actions .btn {
        width: 100%;
    }
    .detail-list {
        gap: 6px;
    }
    .finance-chart {
        height: 178px;
        padding-inline: 4px;
    }
    .finance-bars {
        height: 132px;
    }
    table {
        min-width: 560px;
    }
}

/* Sidebar visibility and accounting module polish */
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}
.brand {
    flex: 0 0 auto;
}
.nav {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    padding-bottom: 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .38) rgba(255, 255, 255, .08);
}
.nav::-webkit-scrollbar {
    width: 8px;
}
.nav::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
}
.nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .36);
    border-radius: 999px;
}
.nav a {
    flex-shrink: 0;
}
.accounting-filter {
    margin-bottom: 18px;
}
.accounting-metrics .metric:nth-child(1) { border-color: #bbf7d0; background: linear-gradient(135deg, #ffffff, #f0fdf4); }
.accounting-metrics .metric:nth-child(2) { border-color: #fed7aa; background: linear-gradient(135deg, #ffffff, #fff7ed); }
.accounting-metrics .metric:nth-child(3) { border-color: #bfdbfe; background: linear-gradient(135deg, #ffffff, #eff6ff); }
.accounting-metrics .metric:nth-child(4) { border-color: #bae6fd; background: linear-gradient(135deg, #ffffff, #f0f9ff); }
.accounting-metrics .metric:nth-child(5) { border-color: #ddd6fe; background: linear-gradient(135deg, #ffffff, #f5f3ff); }
.accounting-metrics .metric:nth-child(6) { border-color: #fecaca; background: linear-gradient(135deg, #ffffff, #fff1f2); }
.statement-panel table {
    min-width: 620px;
}
.statement-total td {
    background: #f8fafc;
    font-weight: 850;
    border-top: 2px solid #cbd5e1;
}
.vat-panel {
    background: linear-gradient(135deg, #ffffff, #fff7ed);
    border-color: #fed7aa;
}
.accounting-grid {
    align-items: start;
}
.money-input {
    text-align: right;
}

@media (min-width: 1500px) {
    .accounting-grid.grid.two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1000px) {
    .sidebar {
        height: auto;
        min-height: 0;
        overflow: visible;
    }
    .nav {
        max-height: none;
        overflow: visible;
        padding-right: 0;
        padding-bottom: 0;
    }
}

@media (max-width: 760px) {
    .nav {
        max-height: none;
        overflow: visible;
    }
    .accounting-filter .search-form,
    .accounting-filter .field,
    .accounting-filter input,
    .accounting-filter .btn {
        width: 100%;
    }
}

/* Advanced accounting panels */
.final-statement-panel {
    background: linear-gradient(135deg, #ffffff, #eef2ff);
    border-color: #c7d2fe;
}
.cashbook-panel {
    background: linear-gradient(135deg, #ffffff, #ecfeff);
    border-color: #a5f3fc;
}
.aging-panel {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
}
.aging-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 14px;
}
.aging-strip span {
    display: grid;
    gap: 5px;
    min-height: 76px;
    padding: 12px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
}
.aging-strip b {
    color: #1d4ed8;
    font-size: 13px;
}
.aging-strip strong {
    font-size: 20px;
}
.payable-strip span {
    border-color: #fed7aa;
    background: #fff7ed;
}
.payable-strip b {
    color: #c2410c;
}
.finance-final-list dd {
    font-weight: 750;
}
.ledger-metrics {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
@media (max-width: 760px) {
    .aging-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 520px) {
    .aging-strip {
        grid-template-columns: 1fr;
    }
}
/* Final sidebar redesign: full, polished, unclipped */
.app-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    min-height: 100vh;
    width: 100%;
    align-items: stretch;
}
.sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    height: 100vh;
    min-height: 100vh;
    padding: 18px 14px 16px;
    overflow: hidden;
    color: #eef8ff;
    background:
        linear-gradient(180deg, rgba(8, 47, 73, .98), rgba(14, 116, 144, .98) 48%, rgba(13, 148, 136, .98)),
        radial-gradient(circle at 20% 8%, rgba(125, 211, 252, .26), transparent 32%);
    border-right: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 18px 0 42px rgba(15, 23, 42, .13);
}
.sidebar::before {
    inset: 0 auto 0 0;
    width: 5px;
    height: auto;
    z-index: 0;
    border-radius: 0 999px 999px 0;
}
.sidebar > * {
    position: relative;
    z-index: 1;
}
.brand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    margin: 0 0 14px;
    padding: 10px 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .14);
}
.brand-copy {
    min-width: 0;
}
.brand-copy strong,
.brand-copy span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 100%;
    min-height: 0;
    padding: 4px 6px 14px 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.nav a {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 11px;
    border-radius: 8px;
    line-height: 1.2;
    white-space: normal;
    color: #e6f6ff;
    background: rgba(255, 255, 255, .045);
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: none;
}
.nav a:hover,
.nav a.active {
    transform: translateX(3px);
    background: rgba(255, 255, 255, .15);
    border-color: rgba(255, 255, 255, .22);
}
.nav-text {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-icon {
    width: 20px;
    height: 20px;
    align-self: center;
}
.sidebar-footer {
    flex: 0 0 auto;
    display: grid;
    gap: 7px;
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
}
.sidebar-footer strong {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #d9fbff;
    font-size: 12px;
    font-weight: 800;
}
.sidebar-status i {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, .16);
}
.main {
    min-width: 0;
}
@media (max-width: 1280px) {
    .app-shell {
        grid-template-columns: 282px minmax(0, 1fr);
    }
    .sidebar {
        padding-inline: 12px;
    }
}
@media (max-width: 1060px) {
    .app-shell {
        grid-template-columns: 268px minmax(0, 1fr);
    }
    .nav a {
        grid-template-columns: 20px minmax(0, 1fr);
        column-gap: 9px;
        padding-inline: 10px;
    }
}
@media (max-width: 900px) {
    .app-shell {
        display: block;
    }
    .sidebar {
        position: relative;
        top: auto;
        height: auto;
        min-height: 0;
        padding: 16px;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, .16);
    }
    .sidebar::before {
        inset: 0 0 auto 0;
        width: 100%;
        height: 5px;
        border-radius: 0 0 999px 999px;
    }
    .brand {
        margin-bottom: 12px;
    }
    .nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
        max-height: none;
        overflow: visible;
        padding: 0;
    }
    .nav a:hover,
    .nav a.active {
        transform: translateY(-1px);
    }
    .sidebar-footer {
        margin-top: 12px;
    }
}
@media (max-width: 560px) {
    .brand-copy strong,
    .brand-copy span,
    .sidebar-footer strong,
    .nav-text {
        white-space: normal;
        text-overflow: clip;
    }
    .nav {
        grid-template-columns: 1fr;
    }
}
/* Final all-page design pass */
:root {
    --surface: rgba(255, 255, 255, .92);
    --surface-strong: #ffffff;
    --ink-soft: #334155;
    --ring: rgba(37, 99, 235, .18);
    --shadow-sm: 0 10px 24px rgba(15, 23, 42, .06);
    --shadow-md: 0 18px 42px rgba(15, 23, 42, .09);
    --shadow-lg: 0 26px 70px rgba(15, 23, 42, .12);
}
body {
    color: #172033;
    background:
        linear-gradient(90deg, rgba(37, 99, 235, .035) 1px, transparent 1px),
        linear-gradient(180deg, rgba(20, 184, 166, .04) 1px, transparent 1px),
        linear-gradient(180deg, #eef7fb 0%, #f8fbff 46%, #f8fafc 100%);
    background-size: 36px 36px, 36px 36px, auto;
}
.main {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .66), rgba(248, 250, 252, .96)),
        linear-gradient(135deg, rgba(219, 234, 254, .48), rgba(236, 253, 245, .4));
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    min-height: 74px;
    padding: 12px clamp(18px, 2vw, 30px);
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid rgba(148, 163, 184, .32);
    box-shadow: 0 14px 34px rgba(15, 23, 42, .06);
}
.topbar-title {
    display: grid;
    gap: 4px;
    min-width: 0;
}
.topbar-title strong {
    color: #0f172a;
    font-size: 18px;
    line-height: 1.2;
}
.topbar .user {
    color: #64748b;
    font-weight: 650;
}
.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.topbar-actions form {
    margin: 0;
}
.topbar-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 850;
}
.topbar-chip i {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 5px rgba(34, 197, 94, .14);
}
.content {
    display: grid;
    align-content: start;
    gap: 20px;
    padding: clamp(18px, 2.2vw, 34px);
}
.content > .page-header,
.content > .panel,
.content > .table-wrap,
.content > .metrics,
.content > .grid {
    margin-top: 0;
    margin-bottom: 0;
}
.page-header {
    position: relative;
    overflow: hidden;
    align-items: center;
    padding: clamp(20px, 2vw, 28px);
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(240, 249, 255, .94) 48%, rgba(236, 253, 245, .92));
    box-shadow: var(--shadow-md);
}
.page-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, #0f766e, #2563eb, #f59e0b, #dc2626);
}
.page-header h1 {
    color: #0f172a;
    font-size: clamp(25px, 2vw, 32px);
    line-height: 1.12;
}
.page-header p {
    max-width: 780px;
    color: #64748b;
    font-weight: 550;
}
.page-header .actions {
    margin-top: 0;
    justify-content: flex-end;
}
.panel,
.form-grid,
.table-wrap,
.toolbar,
.metric,
.command-card,
.pipeline-card {
    border-radius: 8px;
}
.panel {
    padding: clamp(18px, 1.6vw, 24px);
    background: var(--surface);
    border: 1px solid rgba(148, 163, 184, .28);
    box-shadow: var(--shadow-sm);
    backdrop-filter: saturate(120%) blur(8px);
}
.panel:hover {
    transform: none;
    border-color: rgba(37, 99, 235, .28);
    box-shadow: var(--shadow-md);
}
.panel h2,
.toolbar h2 {
    color: #0f172a;
    font-size: 18px;
    line-height: 1.25;
}
.toolbar {
    min-height: 54px;
    padding: 12px 14px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(248, 250, 252, .96), rgba(255, 255, 255, .94));
    border: 1px solid rgba(148, 163, 184, .26);
    box-shadow: none;
}
.metrics,
.command-metrics {
    gap: 16px;
}
.metric,
.command-card {
    background: linear-gradient(135deg, #ffffff, #f8fbff);
    border: 1px solid rgba(148, 163, 184, .28);
    box-shadow: var(--shadow-sm);
}
.metric {
    min-height: 112px;
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 18px;
}
.metric span,
.card-label,
.card-hint {
    color: #64748b;
}
.metric strong {
    color: #0f172a;
    font-size: clamp(24px, 2vw, 30px);
    line-height: 1;
}
.table-wrap {
    overflow: auto;
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, .3);
    box-shadow: var(--shadow-sm);
}
table {
    border-collapse: separate;
    border-spacing: 0;
}
th,
td {
    padding: 13px 15px;
    border-bottom: 1px solid #e2e8f0;
}
th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: #475569;
    background: linear-gradient(180deg, #f8fafc, #eef6ff);
    font-weight: 850;
}
tbody tr:nth-child(even) {
    background: #fbfdff;
}
tbody tr:hover {
    background: #f0f9ff;
}
td {
    color: #243047;
}
.form-grid {
    gap: 18px;
    padding: clamp(18px, 1.7vw, 24px);
    background: linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(248, 250, 252, .96));
    border: 1px solid rgba(148, 163, 184, .28);
    box-shadow: var(--shadow-sm);
}
.field label {
    color: #243047;
    font-size: 13px;
    font-weight: 850;
}
.field input,
.field select,
.field textarea,
.search-form input,
.search-form select,
.quick-form input,
.quick-form textarea,
.quick-pay input {
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, .03);
}
.field textarea,
.quick-form textarea {
    line-height: 1.45;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.search-form input:focus,
.search-form select:focus,
.quick-form input:focus,
.quick-form textarea:focus,
.quick-pay input:focus {
    outline: 4px solid var(--ring);
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, .18);
}
.check-list label {
    min-height: 40px;
    border-radius: 8px;
    background: #f8fafc;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.check-list label:hover {
    transform: translateY(-1px);
    border-color: #93c5fd;
    background: #eff6ff;
}
.btn {
    min-height: 40px;
    border-radius: 8px;
    font-weight: 850;
    letter-spacing: 0;
    box-shadow: 0 12px 24px rgba(15, 118, 110, .18);
}
.btn.secondary {
    background: #ffffff;
    color: #0f172a;
    border-color: #cbd5e1;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .06);
}
.btn.secondary:hover {
    background: #f8fafc;
    border-color: #93c5fd;
}
.btn.danger {
    background: #dc2626;
}
.btn.small {
    min-height: 34px;
    padding: 7px 11px;
}
.actions,
.row-actions,
.status-actions,
.compact-actions,
.search-form {
    gap: 9px;
}
.badge {
    min-height: 24px;
    border-radius: 999px;
    padding: 4px 10px;
    border: 1px solid currentColor;
    border-color: color-mix(in srgb, currentColor 22%, transparent);
    font-weight: 850;
}
.detail-list {
    gap: 12px 18px;
    padding: 4px 0 0;
}
.detail-list dt {
    color: #64748b;
    font-weight: 850;
}
.detail-list dd {
    color: #172033;
}
.alert {
    border-radius: 8px;
    padding: 13px 15px;
    box-shadow: var(--shadow-sm);
}
.alert.success {
    border-color: #86efac;
    background: #f0fdf4;
}
.alert.error {
    border-color: #fca5a5;
    background: #fef2f2;
}
.pagination {
    display: flex;
    justify-content: center;
}
.login-shell {
    background:
        linear-gradient(90deg, rgba(37, 99, 235, .05) 1px, transparent 1px),
        linear-gradient(180deg, rgba(20, 184, 166, .06) 1px, transparent 1px),
        linear-gradient(135deg, #e9f7f4 0%, #edf3ff 100%);
    background-size: 36px 36px, 36px 36px, auto;
}
.login-card {
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}
@media (max-width: 900px) {
    .topbar {
        position: relative;
        align-items: stretch;
    }
    .topbar,
    .topbar-actions,
    .page-header {
        flex-direction: column;
    }
    .topbar-actions,
    .topbar-actions form,
    .topbar-actions .btn,
    .topbar-chip,
    .page-header .actions,
    .page-header .actions .btn,
    .page-header .actions form,
    .page-header .actions button {
        width: 100%;
    }
    .topbar-actions {
        align-items: stretch;
    }
    .page-header .actions {
        justify-content: stretch;
    }
}
@media (max-width: 640px) {
    .content {
        gap: 16px;
        padding: 14px;
    }
    .page-header,
    .panel,
    .form-grid,
    .toolbar {
        padding: 16px;
    }
    th,
    td {
        padding: 11px 12px;
    }
    .metric {
        min-height: 96px;
    }
}
@media print {
    .sidebar,
    .topbar,
    .actions,
    .row-actions,
    .status-actions,
    .compact-actions,
    .btn {
        display: none !important;
    }
    .app-shell,
    .main,
    .content {
        display: block !important;
        padding: 0 !important;
        background: #ffffff !important;
    }
    .panel,
    .page-header,
    .table-wrap,
    .form-grid {
        box-shadow: none !important;
        border-color: #d1d5db !important;
    }
}
/* Definitive fixed sidebar override: never becomes a half-page top block */
html,
body {
    min-height: 100%;
}
.app-shell {
    display: block !important;
    min-height: 100vh;
    width: 100%;
}
.sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 100;
    width: 300px !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 18px 14px 16px !important;
    overflow: hidden !important;
    border-right: 1px solid rgba(255, 255, 255, .14);
    border-bottom: 0 !important;
}
.sidebar::before {
    inset: 0 auto 0 0 !important;
    width: 5px !important;
    height: auto !important;
    border-radius: 0 999px 999px 0 !important;
}
.main {
    min-height: 100vh;
    margin-left: 300px !important;
    width: calc(100% - 300px) !important;
}
.nav {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 4px 6px 14px 0 !important;
}
.nav a {
    display: grid !important;
    grid-template-columns: 22px minmax(0, 1fr) !important;
    width: 100% !important;
}
.sidebar-footer {
    flex: 0 0 auto;
}
@media (max-width: 1180px) {
    .sidebar {
        width: 276px !important;
    }
    .main {
        margin-left: 276px !important;
        width: calc(100% - 276px) !important;
    }
}
@media (max-width: 820px) {
    .sidebar {
        width: 82px !important;
        padding: 14px 10px !important;
    }
    .main {
        margin-left: 82px !important;
        width: calc(100% - 82px) !important;
    }
    .brand {
        justify-content: center;
        padding: 8px 0 14px !important;
    }
    .brand-copy,
    .sidebar-footer {
        display: none !important;
    }
    .brand-mark {
        width: 42px;
        height: 42px;
    }
    .nav {
        padding: 4px 0 10px !important;
        gap: 8px !important;
    }
    .nav a {
        grid-template-columns: 1fr !important;
        justify-items: center;
        min-height: 46px;
        padding: 10px 8px !important;
    }
    .nav-text {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }
    .nav a:hover,
    .nav a.active {
        transform: translateX(0) !important;
    }
    .topbar,
    .topbar-actions,
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .topbar-actions,
    .topbar-actions form,
    .topbar-actions .btn,
    .topbar-chip,
    .page-header .actions,
    .page-header .actions .btn,
    .page-header .actions form,
    .page-header .actions button {
        width: 100%;
    }
}
@media (max-width: 460px) {
    .sidebar {
        width: 70px !important;
        padding-inline: 8px !important;
    }
    .main {
        margin-left: 70px !important;
        width: calc(100% - 70px) !important;
    }
    .content {
        padding: 12px !important;
    }
    .topbar {
        padding: 12px !important;
    }
}
@media print {
    .sidebar {
        display: none !important;
    }
    .main {
        width: 100% !important;
        margin-left: 0 !important;
    }
}
/* Final sidebar scroll stability pass */
.sidebar {
    overflow: hidden !important;
}
.nav {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.nav:focus-visible {
    outline: 2px solid rgba(125, 211, 252, .85);
    outline-offset: 3px;
}
@supports (height: 100svh) {
    .sidebar {
        height: 100svh !important;
        min-height: 100svh !important;
    }
}
@media (max-width: 820px) {
    .nav {
        flex-basis: 0 !important;
    }
}
/* Settings and document branding */
.brand-mark img,
.login-brand .brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 5px;
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.login-brand h1 { margin: 0; }
.login-brand p { margin: 4px 0 0; }
.settings-preview {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr);
    gap: 18px;
    margin-bottom: 18px;
}
.brand-preview-card,
.settings-document-preview {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #eef8fb);
    box-shadow: var(--shadow-sm);
}
.brand-preview-card {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    padding: 22px;
}
.brand-preview-mark {
    width: 92px;
    height: 92px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(135deg, var(--preview-primary), var(--preview-accent));
    color: #fff;
    font-size: 28px;
    font-weight: 900;
}
.brand-preview-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    background: #fff;
}
.brand-preview-card h2,
.settings-document-preview strong {
    margin: 5px 0;
    font-size: 24px;
}
.brand-preview-card p,
.settings-document-preview p {
    margin: 3px 0;
    color: var(--muted);
}
.settings-document-preview {
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 22px;
}
.settings-document-preview span,
.settings-document-preview small {
    color: var(--muted);
    font-weight: 800;
}
.settings-form {
    display: grid;
    gap: 18px;
}
.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}
.settings-savebar {
    position: sticky;
    bottom: 14px;
    z-index: 15;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .9);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(14px);
}
.report-letterhead {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 18px;
    padding: 24px;
    border-radius: 8px;
    color: #fff;
    background: linear-gradient(135deg, var(--report-primary), var(--report-accent));
    box-shadow: var(--shadow-md);
}
.report-brand {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    min-width: 0;
}
.report-brand-mark {
    width: 82px;
    height: 82px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: rgba(255, 255, 255, .94);
    color: var(--report-primary);
    font-size: 26px;
    font-weight: 900;
}
.report-brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 7px;
}
.report-brand h1 {
    margin: 6px 0;
    font-size: 30px;
}
.report-brand p,
.report-window p {
    margin: 4px 0;
    color: rgba(255, 255, 255, .86);
}
.report-window {
    min-width: 260px;
    display: grid;
    align-content: center;
    gap: 8px;
    padding: 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .2);
}
.report-window span {
    color: rgba(255, 255, 255, .76);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 900;
}
.report-window strong { font-size: 18px; }
@media (max-width: 900px) {
    .settings-preview { grid-template-columns: 1fr; }
    .report-letterhead { flex-direction: column; }
    .settings-savebar { justify-content: stretch; flex-direction: column; }
    .settings-savebar .btn { width: 100%; }
}
@media (max-width: 560px) {
    .brand-preview-card,
    .report-brand { grid-template-columns: 1fr; }
    .brand-preview-mark,
    .report-brand-mark { width: 68px; height: 68px; }
}
@media print {
    .report-letterhead {
        color: #fff !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
/* AI assistant module */
.ai-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .7fr);
    gap: 20px;
    align-items: stretch;
    padding: clamp(22px, 2.4vw, 32px);
    border-radius: 8px;
    color: #ffffff;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, .96), rgba(37, 99, 235, .9) 46%, rgba(190, 24, 93, .78)),
        linear-gradient(90deg, rgba(255, 255, 255, .14) 1px, transparent 1px);
    background-size: auto, 32px 32px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.ai-hero h1 {
    margin: 10px 0 10px;
    font-size: clamp(32px, 3vw, 46px);
    line-height: 1.05;
}
.ai-hero p {
    max-width: 820px;
    margin: 0;
    color: rgba(255, 255, 255, .88);
    font-weight: 600;
}
.ai-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 22px;
}
.ai-hero-actions .btn.secondary {
    background: rgba(255, 255, 255, .94);
}
.ai-status-board {
    display: grid;
    gap: 10px;
    align-content: center;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 8px;
    background: rgba(255, 255, 255, .14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
}
.ai-status-board span,
.ai-settings-strip span {
    display: grid;
    gap: 4px;
    min-width: 0;
}
.ai-status-board b,
.ai-settings-strip b {
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 900;
}
.ai-workspace {
    align-items: start;
}
.ai-compose textarea {
    min-height: 210px;
}
.ai-task-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.ai-task-card {
    display: grid;
    gap: 8px;
    min-height: 126px;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #dbeafe;
    background: linear-gradient(135deg, #ffffff, #eff6ff);
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.ai-task-card:hover,
.ai-task-card.active {
    transform: translateY(-3px);
    border-color: #38bdf8;
    box-shadow: var(--shadow-md);
}
.ai-task-card strong {
    color: #0f172a;
    font-size: 15px;
}
.ai-task-card span {
    color: #64748b;
    font-size: 13px;
    line-height: 1.4;
}
.ai-result-panel {
    padding: clamp(18px, 2vw, 24px);
    border-radius: 8px;
    border: 1px solid #bfdbfe;
    background: linear-gradient(135deg, #ffffff, #f0f9ff);
    box-shadow: var(--shadow-md);
    animation: cardRise .35s ease both;
}
.ai-result-panel.live {
    border-color: #86efac;
    background: linear-gradient(135deg, #ffffff, #ecfdf3);
}
.ai-result-panel.fallback {
    border-color: #fde68a;
    background: linear-gradient(135deg, #ffffff, #fffbeb);
}
.ai-result-panel pre {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.55;
    font-family: inherit;
    color: #172033;
}
.ai-history-panel table {
    min-width: 860px;
}
.ai-settings-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.ai-settings-strip span {
    padding: 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: linear-gradient(135deg, #0f766e, #2563eb);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    overflow-wrap: anywhere;
}
.ai-settings-panel .form-grid {
    background: linear-gradient(135deg, #ffffff, #f0fdfa 48%, #eff6ff);
}
.ai-connection-card {
    margin: 0 0 16px;
    padding: 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #eff6ff);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .08);
}
.ai-connection-card.connected {
    border-color: #86efac;
    background: linear-gradient(135deg, #ffffff, #ecfdf3 55%, #f0f9ff);
}
.ai-connection-card.failed {
    border-color: #fecaca;
    background: linear-gradient(135deg, #ffffff, #fff7ed 56%, #fef2f2);
}
.ai-connection-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.ai-connection-head h3 {
    margin: 8px 0 4px;
    font-size: 18px;
}
.ai-connection-head p {
    margin: 0;
    color: var(--muted);
}
.ai-connection-grid,
.ai-header-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.ai-header-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.ai-connection-grid span,
.ai-header-list span {
    min-width: 0;
    padding: 11px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background: rgba(255, 255, 255, .74);
    overflow-wrap: anywhere;
    color: var(--ink);
}
.ai-connection-grid b,
.ai-header-list b {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}
@media (max-width: 1100px) {
    .ai-hero,
    .ai-workspace {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 720px) {
    .ai-task-grid,
    .ai-settings-strip {
        grid-template-columns: 1fr;
    }
    .ai-hero-actions,
    .ai-hero-actions .btn {
        width: 100%;
    }
}
/* Embedded AI workflow drafts */
.ai-inline-panel {
    padding: clamp(16px, 1.6vw, 22px);
    border-radius: 8px;
    border: 1px solid #bfdbfe;
    background: linear-gradient(135deg, #ffffff, #eff6ff 48%, #f0fdfa);
    box-shadow: var(--shadow-md);
    animation: cardRise .3s ease both;
}
.ai-inline-panel.live {
    border-color: #86efac;
    background: linear-gradient(135deg, #ffffff, #ecfdf3);
}
.ai-inline-panel.fallback {
    border-color: #fde68a;
    background: linear-gradient(135deg, #ffffff, #fffbeb);
}
.ai-inline-panel pre {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.55;
    font-family: inherit;
    color: #172033;
}
.ai-inline-panel + .panel,
.ai-inline-panel + .grid {
    margin-top: 0;
}
/* Overall interface refinement pass */
:root {
    --hf-page: #f6f8fc;
    --hf-page-2: #eef7f7;
    --hf-card: rgba(255, 255, 255, .96);
    --hf-card-strong: #ffffff;
    --hf-border: rgba(148, 163, 184, .32);
    --hf-border-strong: rgba(100, 116, 139, .38);
    --hf-text: #111827;
    --hf-subtext: #5b6678;
    --hf-blue: #2563eb;
    --hf-teal: #0f766e;
    --hf-emerald: #059669;
    --hf-amber: #d97706;
    --hf-rose: #e11d48;
    --hf-violet: #7c3aed;
    --hf-shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --hf-shadow-sm: 0 10px 24px rgba(15, 23, 42, .07);
    --hf-shadow-md: 0 18px 44px rgba(15, 23, 42, .1);
    --hf-shadow-lg: 0 30px 80px rgba(15, 23, 42, .14);
    --hf-focus: 0 0 0 4px rgba(37, 99, 235, .16);
}
html {
    color-scheme: light;
    scroll-behavior: smooth;
}
body {
    color: var(--hf-text);
    background:
        radial-gradient(circle at 18% 4%, rgba(20, 184, 166, .11), transparent 32%),
        radial-gradient(circle at 86% 12%, rgba(37, 99, 235, .1), transparent 28%),
        linear-gradient(180deg, var(--hf-page) 0%, var(--hf-page-2) 44%, #f8fafc 100%) !important;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}
body::selection {
    background: rgba(37, 99, 235, .18);
}
a {
    transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.main {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(248, 250, 252, .9)),
        linear-gradient(135deg, rgba(236, 253, 245, .34), rgba(239, 246, 255, .5)) !important;
}
.content {
    gap: clamp(18px, 1.8vw, 26px) !important;
    padding: clamp(18px, 2.2vw, 34px) !important;
}
.topbar {
    min-height: 76px !important;
    background: rgba(255, 255, 255, .86) !important;
    backdrop-filter: blur(18px) saturate(150%);
    border-bottom: 1px solid rgba(148, 163, 184, .26) !important;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .06) !important;
}
.topbar-title strong {
    letter-spacing: 0;
}
.topbar .user {
    color: var(--hf-subtext) !important;
}
.topbar-chip {
    background: linear-gradient(135deg, #eff6ff, #ecfdf5) !important;
    border-color: #bfdbfe !important;
    box-shadow: var(--hf-shadow-xs);
}
.sidebar {
    background:
        linear-gradient(180deg, rgba(8, 47, 73, .98) 0%, rgba(15, 76, 92, .98) 45%, rgba(15, 118, 110, .98) 100%),
        linear-gradient(135deg, rgba(255, 255, 255, .08), transparent) !important;
    box-shadow: 20px 0 60px rgba(8, 47, 73, .16), inset -1px 0 0 rgba(255, 255, 255, .12) !important;
}
.sidebar::before {
    background: linear-gradient(180deg, #38bdf8, #2dd4bf 38%, #f59e0b 72%, #fb7185) !important;
}
.brand {
    border-radius: 8px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
}
.brand-copy strong {
    color: #ffffff;
    line-height: 1.1;
}
.brand-copy span {
    color: rgba(226, 232, 240, .82) !important;
}
.brand-mark {
    background: linear-gradient(135deg, #ffffff, #cffafe 58%, #fef3c7) !important;
    color: var(--hf-teal) !important;
    box-shadow: 0 14px 30px rgba(34, 211, 238, .18), inset 0 1px 0 rgba(255, 255, 255, .75) !important;
}
.nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(203, 213, 225, .48) transparent;
}
.nav::-webkit-scrollbar {
    width: 8px;
}
.nav::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(203, 213, 225, .42);
}
.nav a {
    min-height: 44px !important;
    border-radius: 8px !important;
    color: rgba(241, 245, 249, .88) !important;
    background: transparent;
}
.nav a:hover {
    background: rgba(255, 255, 255, .1) !important;
    border-color: rgba(255, 255, 255, .14) !important;
}
.nav a.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .09)) !important;
    border-color: rgba(255, 255, 255, .24) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 10px 22px rgba(8, 47, 73, .22);
}
.nav a.active::after {
    background: linear-gradient(180deg, #fde68a, #38bdf8) !important;
}
.nav-icon {
    color: inherit;
    opacity: .95;
}
.sidebar-footer {
    border-radius: 8px !important;
    border-color: rgba(255, 255, 255, .16) !important;
    background: rgba(255, 255, 255, .08) !important;
}
.page-header {
    min-height: 118px;
    border: 1px solid rgba(148, 163, 184, .28) !important;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(240, 249, 255, .96) 50%, rgba(236, 253, 245, .95)) !important;
    box-shadow: var(--hf-shadow-md) !important;
}
.page-header::before {
    height: 5px !important;
    background: linear-gradient(90deg, var(--hf-teal), var(--hf-blue), var(--hf-violet), var(--hf-amber), var(--hf-rose)) !important;
}
.page-header h1 {
    letter-spacing: 0;
    color: #0f172a !important;
}
.page-header p {
    color: var(--hf-subtext) !important;
    line-height: 1.5;
}
.panel,
.metric,
.command-card,
.pipeline-card,
.table-wrap,
.form-grid,
.login-card,
.brand-preview-card,
.settings-document-preview {
    border: 1px solid var(--hf-border) !important;
    background: var(--hf-card) !important;
    box-shadow: var(--hf-shadow-sm) !important;
}
.panel {
    position: relative;
    overflow: hidden;
}
.panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(15, 118, 110, .75), rgba(37, 99, 235, .65), rgba(217, 119, 6, .55));
    opacity: .55;
}
.panel > * {
    position: relative;
    z-index: 1;
}
.panel:hover,
.metric:hover,
.command-card:hover,
.pipeline-card:hover {
    border-color: rgba(37, 99, 235, .32) !important;
    box-shadow: var(--hf-shadow-md) !important;
}
.toolbar {
    min-height: 58px !important;
    border-color: rgba(148, 163, 184, .24) !important;
    background: linear-gradient(135deg, rgba(248, 250, 252, .96), rgba(255, 255, 255, .98)) !important;
}
.toolbar h2,
.panel h2 {
    letter-spacing: 0;
    color: #0f172a !important;
}
.metrics {
    gap: clamp(12px, 1.2vw, 18px) !important;
}
.metric {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.metric::after {
    content: "";
    position: absolute;
    inset: auto -20px -36px auto;
    width: 96px;
    height: 96px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(20, 184, 166, .12), rgba(37, 99, 235, .13));
    z-index: -1;
}
.metric span {
    color: var(--hf-subtext) !important;
    font-weight: 800;
}
.metric strong {
    color: #0f172a !important;
}
.table-wrap {
    overflow: auto !important;
    border-radius: 8px !important;
}
table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}
th {
    color: #475569 !important;
    background: linear-gradient(180deg, #f8fafc, #eef6ff) !important;
    border-bottom: 1px solid #dbe4ef !important;
    font-size: 12px !important;
    letter-spacing: .02em !important;
}
td {
    color: #1f2937 !important;
}
tbody tr {
    transition: background .14s ease;
}
tbody tr:nth-child(even) {
    background: rgba(248, 250, 252, .76) !important;
}
tbody tr:hover {
    background: #eef9ff !important;
}
table a {
    color: #1d4ed8;
    font-weight: 750;
}
.form-grid {
    background: linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(248, 250, 252, .98)) !important;
}
.field label {
    color: #1f2937 !important;
}
.field input,
.field select,
.field textarea,
.search-form input,
.search-form select,
.quick-form input,
.quick-form textarea,
.quick-pay input {
    border-color: #cbd5e1 !important;
    background: #ffffff !important;
    color: #111827 !important;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field input:hover,
.field select:hover,
.field textarea:hover,
.search-form input:hover,
.search-form select:hover,
.quick-form input:hover,
.quick-form textarea:hover,
.quick-pay input:hover {
    border-color: #94a3b8 !important;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.search-form input:focus,
.search-form select:focus,
.quick-form input:focus,
.quick-form textarea:focus,
.quick-pay input:focus {
    outline: 0 !important;
    border-color: var(--hf-blue) !important;
    box-shadow: var(--hf-focus) !important;
}
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand);
}
input[type="color"] {
    min-height: 46px;
    padding: 4px !important;
}
.btn {
    border-radius: 8px !important;
    box-shadow: 0 12px 26px rgba(15, 118, 110, .18) !important;
    transform: translateY(0);
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(15, 118, 110, .22) !important;
}
.btn:active {
    transform: translateY(0);
}
.btn.secondary {
    background: linear-gradient(135deg, #ffffff, #f8fafc) !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}
.btn.secondary:hover {
    border-color: #93c5fd !important;
    color: #1d4ed8 !important;
}
.btn.warning {
    background: var(--hf-amber) !important;
    color: #ffffff !important;
    box-shadow: 0 12px 26px rgba(217, 119, 6, .22) !important;
}
.btn.danger {
    background: var(--hf-rose) !important;
    color: #ffffff !important;
    box-shadow: 0 12px 26px rgba(225, 29, 72, .22) !important;
}
.badge {
    border: 1px solid rgba(15, 23, 42, .08) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}
.badge.pending,
.badge.ordered,
.badge.scheduled,
.badge.waiting {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
}
.badge.approved,
.badge.completed,
.badge.paid,
.badge.active,
.badge.dispensed {
    background: #ecfdf5 !important;
    color: #047857 !important;
}
.badge.partial,
.badge.processing,
.badge.called,
.badge.in_service,
.badge.open {
    background: #fffbeb !important;
    color: #b45309 !important;
}
.badge.void,
.badge.cancelled,
.badge.skipped,
.badge.inactive,
.badge.unpaid {
    background: #fff1f2 !important;
    color: #be123c !important;
}
.alert {
    border-radius: 8px !important;
    box-shadow: var(--hf-shadow-xs) !important;
}
.detail-list {
    align-items: start;
}
.detail-list dt {
    color: var(--hf-subtext) !important;
}
.detail-list dd {
    min-width: 0;
    overflow-wrap: anywhere;
}
.workflow-panel {
    align-items: center;
    background: linear-gradient(135deg, #ffffff, #f0fdfa) !important;
}
.status-actions,
.compact-actions,
.actions,
.row-actions {
    align-items: center;
}
.ai-hero,
.dashboard-hero,
.report-letterhead {
    box-shadow: var(--hf-shadow-lg) !important;
}
.ai-result-panel,
.ai-inline-panel {
    box-shadow: var(--hf-shadow-md) !important;
}
.settings-savebar {
    border-color: rgba(148, 163, 184, .28) !important;
    background: rgba(255, 255, 255, .88) !important;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .12) !important;
}
.pagination a,
.pagination span {
    border-radius: 8px !important;
}
@media (max-width: 1180px) {
    .content {
        padding: 22px !important;
    }
    .page-header {
        min-height: auto;
    }
}
@media (max-width: 820px) {
    .sidebar {
        box-shadow: 12px 0 34px rgba(8, 47, 73, .14) !important;
    }
    .brand {
        background: transparent;
        border-color: transparent;
        box-shadow: none !important;
    }
    .nav a {
        border-radius: 8px !important;
    }
    .content {
        padding: 16px !important;
    }
    .page-header,
    .panel,
    .form-grid,
    .toolbar {
        padding: 16px !important;
    }
    .actions,
    .topbar-actions,
    .status-actions,
    .compact-actions {
        align-items: stretch !important;
    }
}
@media (max-width: 560px) {
    .content {
        padding: 12px !important;
        gap: 14px !important;
    }
    .topbar {
        padding: 12px !important;
    }
    .page-header h1 {
        font-size: 24px !important;
    }
    .metric strong {
        font-size: 24px !important;
    }
    .btn,
    .actions .btn,
    .actions form,
    .actions button,
    .search-form .btn,
    .search-form a,
    .quick-form .btn {
        width: 100%;
    }
    .detail-list {
        gap: 8px;
    }
}
@media print {
    body {
        background: #ffffff !important;
    }
    .panel::before,
    .page-header::before {
        display: none !important;
    }
}
/* Communication, schedule, dark mode, and RTL support */
.ui-preferences {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 8px;
    background: rgba(255, 255, 255, .78);
}
.ui-preferences select {
    min-height: 34px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 5px 8px;
    background: #fff;
    color: #0f172a;
}
.message-unread td {
    background: #eff6ff !important;
}
.message-body p {
    margin: 8px 0 0;
    white-space: pre-wrap;
    line-height: 1.65;
}
.schedule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 18px;
}
.schedule-card {
    display: grid;
    gap: 14px;
}
.schedule-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.schedule-card-head h2 {
    margin: 0 0 4px;
}
.schedule-counts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.schedule-counts span {
    min-height: 64px;
    padding: 10px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #eff6ff);
    color: #475569;
    font-size: 13px;
    font-weight: 800;
}
.schedule-counts b {
    display: block;
    color: #0f172a;
    font-size: 22px;
}
.appointment-stack {
    display: grid;
    gap: 9px;
}
.appointment-stack.compact {
    max-width: 720px;
}
.appointment-chip {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #f8fbff);
}
.appointment-chip strong {
    color: #1d4ed8;
}
.appointment-chip span {
    min-width: 0;
    overflow-wrap: anywhere;
}
.appointment-chip em {
    font-style: normal;
}
.public-request-card {
    width: min(720px, 100%);
}
.public-request-card textarea {
    min-height: 150px;
}
body.theme-dark {
    --bg: #0b1120;
    --panel: #111827;
    --ink: #e5edf7;
    --muted: #9aa8bc;
    --line: rgba(148, 163, 184, .24);
    --hf-page: #0b1120;
    --hf-page-2: #111827;
    --hf-card: rgba(15, 23, 42, .96);
    --hf-text: #e5edf7;
    --hf-subtext: #9aa8bc;
    color: #e5edf7 !important;
    background: linear-gradient(180deg, #0b1120, #111827) !important;
}
body.theme-dark .main,
body.theme-dark .topbar,
body.theme-dark .page-header,
body.theme-dark .panel,
body.theme-dark .metric,
body.theme-dark .command-card,
body.theme-dark .pipeline-card,
body.theme-dark .table-wrap,
body.theme-dark .toolbar,
body.theme-dark .form-grid,
body.theme-dark .login-card,
body.theme-dark .settings-savebar,
body.theme-dark .ui-preferences {
    background: rgba(15, 23, 42, .94) !important;
    border-color: rgba(148, 163, 184, .25) !important;
    color: #e5edf7 !important;
}
body.theme-dark .page-header h1,
body.theme-dark .panel h2,
body.theme-dark .toolbar h2,
body.theme-dark .metric strong,
body.theme-dark .schedule-counts b,
body.theme-dark td,
body.theme-dark .field label {
    color: #f8fafc !important;
}
body.theme-dark .muted,
body.theme-dark .small,
body.theme-dark .page-header p,
body.theme-dark .topbar .user,
body.theme-dark .metric span {
    color: #a8b3c7 !important;
}
body.theme-dark th {
    background: #172033 !important;
    color: #cbd5e1 !important;
    border-color: rgba(148, 163, 184, .22) !important;
}
body.theme-dark tbody tr,
body.theme-dark tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, .84) !important;
}
body.theme-dark tbody tr:hover,
body.theme-dark .message-unread td {
    background: rgba(30, 64, 175, .24) !important;
}
body.theme-dark .field input,
body.theme-dark .field select,
body.theme-dark .field textarea,
body.theme-dark .search-form input,
body.theme-dark .search-form select,
body.theme-dark .ui-preferences select,
body.theme-dark .quick-form input,
body.theme-dark .quick-form textarea,
body.theme-dark .quick-pay input {
    background: #0f172a !important;
    border-color: rgba(148, 163, 184, .34) !important;
    color: #f8fafc !important;
}
body.theme-dark .btn.secondary,
body.theme-dark .appointment-chip,
body.theme-dark .schedule-counts span {
    background: linear-gradient(135deg, #111827, #172033) !important;
    border-color: rgba(148, 163, 184, .28) !important;
    color: #e5edf7 !important;
}
html[dir="rtl"] body {
    direction: rtl;
}
html[dir="rtl"] th,
html[dir="rtl"] td {
    text-align: right;
}
html[dir="rtl"] .sidebar::before {
    inset: 0 0 0 auto;
}
html[dir="rtl"] .nav a:hover,
html[dir="rtl"] .nav a.active {
    transform: translateX(-4px);
}
html[dir="rtl"] .nav a::after {
    inset: 0 0 0 auto;
}
html[dir="rtl"] .detail-list {
    grid-template-columns: 1fr 180px;
}
html[dir="rtl"] .topbar-actions,
html[dir="rtl"] .actions,
html[dir="rtl"] .search-form,
html[dir="rtl"] .schedule-card-head {
    flex-direction: row-reverse;
}
@media (max-width: 820px) {
    .topbar-actions,
    .ui-preferences {
        width: 100%;
        flex-wrap: wrap;
        justify-content: stretch;
    }
    .ui-preferences select,
    .ui-preferences .btn {
        flex: 1 1 100px;
    }
    .appointment-chip {
        grid-template-columns: 1fr;
        align-items: start;
    }
    .schedule-counts {
        grid-template-columns: 1fr;
    }
    html[dir="rtl"] .detail-list {
        grid-template-columns: 1fr;
    }
}
/* Workflow hardening additions */
.payment-grid,
.transfer-grid {
    grid-template-columns: minmax(130px, .5fr) minmax(150px, .55fr) minmax(170px, .75fr) minmax(185px, .7fr) minmax(220px, 1fr) auto;
}
.transfer-grid {
    grid-template-columns: minmax(280px, .9fr) minmax(260px, 1fr) auto;
}
.quick-form select,
.payment-grid select,
.transfer-grid select {
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 9px 11px;
    background: #ffffff;
    color: #111827;
}
.payment-grid textarea,
.transfer-grid textarea {
    min-height: 42px;
}
.invoice-payment-panel,
.transfer-panel {
    align-items: start;
}
body.theme-dark .quick-form select,
body.theme-dark .payment-grid select,
body.theme-dark .transfer-grid select {
    background: #0f172a !important;
    border-color: rgba(148, 163, 184, .34) !important;
    color: #f8fafc !important;
}
@media (max-width: 1180px) {
    .payment-grid,
    .transfer-grid {
        grid-template-columns: 1fr 1fr;
    }
    .payment-grid .btn,
    .transfer-grid .btn {
        width: 100%;
    }
}
@media (max-width: 700px) {
    .payment-grid,
    .transfer-grid {
        grid-template-columns: 1fr;
    }
}
/* Patient timeline and statement workflow */
.patient-timeline {
    position: relative;
    display: grid;
    gap: 14px;
    padding-left: 18px;
}
.patient-timeline::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 7px;
    width: 2px;
    background: linear-gradient(180deg, #0f766e, #2563eb, #d97706, #e11d48);
    border-radius: 999px;
}
.timeline-entry {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}
.timeline-marker {
    width: 16px;
    height: 16px;
    margin-top: 18px;
    border: 3px solid #ffffff;
    border-radius: 999px;
    background: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
    z-index: 1;
}
.timeline-card {
    padding: 16px;
    border: 1px solid var(--hf-border, #d9e2ef);
    border-radius: 8px;
    background: var(--hf-card, #ffffff);
    box-shadow: var(--hf-shadow-sm, 0 10px 24px rgba(15, 23, 42, .07));
}
.timeline-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.timeline-head h2 {
    margin: 4px 0 0;
    font-size: 18px;
}
.timeline-card p {
    margin: 10px 0 0;
    color: var(--hf-subtext, #5b6678);
    line-height: 1.55;
}
.timeline-entry.tone-green .timeline-marker { background: #059669; box-shadow: 0 0 0 4px rgba(5, 150, 105, .12); }
.timeline-entry.tone-purple .timeline-marker { background: #7c3aed; box-shadow: 0 0 0 4px rgba(124, 58, 237, .12); }
.timeline-entry.tone-amber .timeline-marker { background: #d97706; box-shadow: 0 0 0 4px rgba(217, 119, 6, .12); }
.timeline-entry.tone-cyan .timeline-marker { background: #0891b2; box-shadow: 0 0 0 4px rgba(8, 145, 178, .12); }
.timeline-entry.tone-emerald .timeline-marker { background: #047857; box-shadow: 0 0 0 4px rgba(4, 120, 87, .12); }
.timeline-entry.tone-rose .timeline-marker { background: #e11d48; box-shadow: 0 0 0 4px rgba(225, 29, 72, .12); }
.timeline-entry.tone-violet .timeline-marker { background: #8b5cf6; box-shadow: 0 0 0 4px rgba(139, 92, 246, .12); }
.timeline-entry.tone-slate .timeline-marker { background: #64748b; box-shadow: 0 0 0 4px rgba(100, 116, 139, .12); }
body.theme-dark .timeline-card {
    background: rgba(15, 23, 42, .94) !important;
    border-color: rgba(148, 163, 184, .25) !important;
}
body.theme-dark .timeline-card p {
    color: #a8b3c7 !important;
}
html[dir="rtl"] .patient-timeline {
    padding-left: 0;
    padding-right: 18px;
}
html[dir="rtl"] .patient-timeline::before {
    left: auto;
    right: 7px;
}
html[dir="rtl"] .timeline-head {
    flex-direction: row-reverse;
}
@media (max-width: 640px) {
    .patient-timeline {
        padding-left: 10px;
    }
    .timeline-entry {
        grid-template-columns: 12px minmax(0, 1fr);
        gap: 9px;
    }
    .timeline-head {
        display: grid;
    }
}
/* Appointment calendar and patient vitals trend */
.calendar-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}
.calendar-column {
    display: grid;
    gap: 14px;
    align-content: start;
}
.calendar-column-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.calendar-column-head h2 {
    margin: 0 0 4px;
}
.calendar-slots {
    display: grid;
    gap: 10px;
}
.calendar-appointment {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #eff6ff);
}
.calendar-time {
    color: #1d4ed8;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}
.calendar-detail {
    display: grid;
    gap: 5px;
    min-width: 0;
}
.calendar-detail a {
    color: #0f172a;
    font-weight: 850;
}
.calendar-detail span:not(.badge) {
    color: #64748b;
    font-size: 13px;
}
.calendar-empty {
    padding: 18px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: #64748b;
    background: #f8fafc;
}
.vitals-latest {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.vitals-latest h2 {
    margin: 3px 0;
}
.vitals-latest p {
    margin: 0;
    color: var(--hf-subtext, #5b6678);
}
.vitals-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.vitals-pills span {
    display: grid;
    gap: 4px;
    min-width: 92px;
    padding: 10px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: linear-gradient(135deg, #eff6ff, #ffffff);
    color: #475569;
    font-size: 12px;
    font-weight: 850;
}
.vitals-pills strong {
    color: #0f172a;
    font-size: 19px;
}
.vitals-trend {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}
.vitals-row {
    display: grid;
    grid-template-columns: 110px minmax(260px, 1fr) minmax(220px, .8fr);
    gap: 14px;
    align-items: center;
    padding: 13px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: linear-gradient(135deg, #ffffff, #f8fbff);
}
.vitals-date {
    display: grid;
    gap: 4px;
}
.vitals-date span,
.vitals-note span {
    color: #64748b;
    font-size: 12px;
    font-weight: 750;
}
.vitals-bars {
    display: grid;
    gap: 7px;
}
.vitals-bars div {
    position: relative;
    min-height: 22px;
    overflow: hidden;
    border-radius: 999px;
    background: #eef2f7;
}
.vitals-bars span {
    position: relative;
    z-index: 1;
    display: block;
    padding: 3px 10px;
    color: #0f172a;
    font-size: 12px;
    font-weight: 850;
}
.vitals-bars i {
    position: absolute;
    inset: 0 auto 0 0;
    min-width: 0;
    border-radius: inherit;
}
.vitals-bars .bp { background: rgba(37, 99, 235, .26); }
.vitals-bars .temp { background: rgba(217, 119, 6, .25); }
.vitals-bars .pulse { background: rgba(225, 29, 72, .22); }
.vitals-bars .spo2 { background: rgba(5, 150, 105, .25); }
.vitals-note {
    display: grid;
    gap: 4px;
}
.vitals-note p {
    margin: 0;
    color: #475569;
}
body.theme-dark .calendar-appointment,
body.theme-dark .calendar-empty,
body.theme-dark .vitals-row,
body.theme-dark .vitals-pills span {
    background: linear-gradient(135deg, #111827, #172033) !important;
    border-color: rgba(148, 163, 184, .28) !important;
}
body.theme-dark .calendar-detail a,
body.theme-dark .vitals-pills strong,
body.theme-dark .vitals-bars span {
    color: #f8fafc !important;
}
body.theme-dark .vitals-bars div {
    background: #0f172a !important;
}
body.theme-dark .calendar-detail span:not(.badge),
body.theme-dark .calendar-empty,
body.theme-dark .vitals-date span,
body.theme-dark .vitals-note span,
body.theme-dark .vitals-note p,
body.theme-dark .vitals-latest p {
    color: #a8b3c7 !important;
}
html[dir="rtl"] .vitals-bars i {
    inset: 0 0 0 auto;
}
@media (max-width: 920px) {
    .vitals-latest,
    .calendar-column-head {
        align-items: stretch;
        flex-direction: column;
    }
    .vitals-row {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 560px) {
    .calendar-appointment {
        grid-template-columns: 1fr;
    }
    .vitals-pills span {
        flex: 1 1 100%;
    }
}
/* Pharmacy stock alert center */
.stock-alert-header {
    background: linear-gradient(135deg, rgba(14, 165, 233, .13), rgba(16, 185, 129, .14)), var(--panel);
}
.stock-alert-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stock-alert-card {
    position: relative;
    overflow: hidden;
    min-height: 132px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 16px 36px rgba(15, 23, 42, .08);
}
.stock-alert-card::after {
    content: "";
    position: absolute;
    inset: auto -28px -36px auto;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    opacity: .18;
    background: currentColor;
}
.stock-alert-card span,
.stock-alert-card small {
    display: block;
    color: var(--muted);
    font-weight: 800;
}
.stock-alert-card strong {
    display: block;
    margin: 10px 0 6px;
    color: #0f172a;
    font-size: 34px;
    line-height: 1;
}
.stock-alert-card.critical { color: #dc2626; border-color: rgba(220, 38, 38, .24); }
.stock-alert-card.warning { color: #d97706; border-color: rgba(217, 119, 6, .28); }
.stock-alert-card.low { color: #2563eb; border-color: rgba(37, 99, 235, .24); }
.stock-alert-card.held { color: #7c3aed; border-color: rgba(124, 58, 237, .22); }
.stock-alert-grid .table-wrap table {
    min-width: 620px;
}
.row-actions {
    white-space: nowrap;
}
.row-actions .inline-form {
    justify-content: flex-end;
}
.badge.warning {
    background: #fff7ed;
    color: #c2410c;
}
.badge.danger,
.badge.expired {
    background: #fee2e2;
    color: #b91c1c;
}
.badge.blocked {
    background: #ede9fe;
    color: #6d28d9;
}
.badge.depleted {
    background: #e5e7eb;
    color: #374151;
}
body.theme-dark .stock-alert-card {
    background: linear-gradient(135deg, #111827, #172033) !important;
    border-color: rgba(148, 163, 184, .28) !important;
}
body.theme-dark .stock-alert-card strong {
    color: #f8fafc;
}
body.theme-dark .badge.warning {
    background: rgba(217, 119, 6, .18);
    color: #fed7aa;
}
body.theme-dark .badge.danger,
body.theme-dark .badge.expired {
    background: rgba(220, 38, 38, .18);
    color: #fecaca;
}
body.theme-dark .badge.blocked {
    background: rgba(124, 58, 237, .2);
    color: #ddd6fe;
}
body.theme-dark .badge.depleted {
    background: rgba(148, 163, 184, .22);
    color: #e2e8f0;
}
@media (max-width: 1180px) {
    .stock-alert-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 620px) {
    .stock-alert-metrics {
        grid-template-columns: 1fr;
    }
}
/* Admission billing panel */
.admission-billing-panel {
    background: linear-gradient(135deg, rgba(15, 118, 110, .08), rgba(37, 99, 235, .08)), var(--panel);
}
.admission-billing-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0;
}
.admission-billing-summary div {
    padding: 14px;
    border: 1px solid rgba(37, 99, 235, .18);
    border-radius: 8px;
    background: rgba(255, 255, 255, .72);
}
.admission-billing-summary span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}
.admission-billing-summary strong {
    display: block;
    margin-top: 6px;
    color: #0f172a;
    font-size: 22px;
}
.admission-billing-actions {
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.admission-billing-actions p {
    margin: 4px 0 0;
}
body.theme-dark .admission-billing-summary div {
    background: rgba(15, 23, 42, .64);
    border-color: rgba(148, 163, 184, .26);
}
body.theme-dark .admission-billing-summary strong {
    color: #f8fafc;
}
@media (max-width: 920px) {
    .admission-billing-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 560px) {
    .admission-billing-summary {
        grid-template-columns: 1fr;
    }
}
/* Insurance claim settlement workflow */
.insurance-actions-panel {
    background: linear-gradient(135deg, rgba(37, 99, 235, .08), rgba(16, 185, 129, .08)), var(--panel);
}
.insurance-status-actions {
    align-items: stretch;
}
.insurance-status-actions .quick-pay {
    min-width: 230px;
}
.insurance-metrics.metrics {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.insurance-settlement-panel .table-wrap table {
    min-width: 720px;
}
@media (max-width: 760px) {
    .insurance-status-actions,
    .insurance-status-actions form,
    .insurance-status-actions .quick-pay {
        width: 100%;
    }
    .insurance-status-actions .quick-pay {
        grid-template-columns: 1fr;
    }
}

.badge.sentinel { background: #fef2f2; color: var(--danger); }
.badge.moderate, .badge.reported, .badge.triaged, .badge.action_required { background: #fff7ed; color: var(--warning); }
.badge.resolved, .badge.closed { background: #ecfdf3; color: var(--success); }

.badge.operational { background: #dcfce7; color: #15803d; }
.badge.service_due, .badge.waiting_parts { background: #fef3c7; color: #b45309; }
.badge.under_maintenance, .badge.assigned { background: #dbeafe; color: #1d4ed8; }
.badge.out_of_service, .badge.retired { background: #fee2e2; color: #b91c1c; }
.badge.preventive, .badge.calibration, .badge.safety_check { background: #e0e7ff; color: #4338ca; }
body.theme-dark .badge.operational { background: rgba(22, 163, 74, .18); color: #86efac; }
body.theme-dark .badge.service_due, body.theme-dark .badge.waiting_parts { background: rgba(245, 158, 11, .18); color: #fcd34d; }
body.theme-dark .badge.under_maintenance, body.theme-dark .badge.assigned { background: rgba(37, 99, 235, .2); color: #93c5fd; }
body.theme-dark .badge.out_of_service, body.theme-dark .badge.retired { background: rgba(220, 38, 38, .2); color: #fca5a5; }
body.theme-dark .badge.preventive, body.theme-dark .badge.calibration, body.theme-dark .badge.safety_check { background: rgba(79, 70, 229, .24); color: #c7d2fe; }
/* Staff HR and payroll surfaces */
.staff-ops-panel {
    background: linear-gradient(135deg, rgba(16, 185, 129, .09), rgba(37, 99, 235, .08)), var(--panel);
}
.staff-watch-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.staff-watch-grid h3 {
    margin: 0 0 10px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 900;
}
.staff-watch-grid .table-wrap table {
    min-width: 620px;
}
.badge.present,
.badge.leave,
.badge.annual,
.badge.sick,
.badge.maternity,
.badge.training {
    background: #dcfce7;
    color: #15803d;
}
.badge.late,
.badge.half_day,
.badge.draft,
.badge.unpaid,
.badge.emergency {
    background: #fef3c7;
    color: #b45309;
}
.badge.absent,
.badge.rejected {
    background: #fee2e2;
    color: #b91c1c;
}
.badge.on_call,
.badge.night,
.badge.evening,
.badge.day,
.badge.morning {
    background: #e0e7ff;
    color: #4338ca;
}
body.theme-dark .staff-ops-panel {
    background: linear-gradient(135deg, rgba(16, 185, 129, .14), rgba(37, 99, 235, .12)), #111827 !important;
}
body.theme-dark .staff-watch-grid h3 {
    color: #f8fafc;
}
body.theme-dark .badge.present,
body.theme-dark .badge.leave,
body.theme-dark .badge.annual,
body.theme-dark .badge.sick,
body.theme-dark .badge.maternity,
body.theme-dark .badge.training {
    background: rgba(22, 163, 74, .2);
    color: #86efac;
}
body.theme-dark .badge.late,
body.theme-dark .badge.half_day,
body.theme-dark .badge.draft,
body.theme-dark .badge.unpaid,
body.theme-dark .badge.emergency {
    background: rgba(245, 158, 11, .2);
    color: #fcd34d;
}
body.theme-dark .badge.absent,
body.theme-dark .badge.rejected {
    background: rgba(220, 38, 38, .2);
    color: #fca5a5;
}
body.theme-dark .badge.on_call,
body.theme-dark .badge.night,
body.theme-dark .badge.evening,
body.theme-dark .badge.day,
body.theme-dark .badge.morning {
    background: rgba(79, 70, 229, .24);
    color: #c7d2fe;
}
@media (max-width: 1100px) {
    .staff-watch-grid {
        grid-template-columns: 1fr;
    }
}
/* Bed turnover and housekeeping surfaces */
.bed-turnover-panel,
.turnover-actions-panel {
    background: linear-gradient(135deg, rgba(245, 158, 11, .10), rgba(14, 165, 233, .08)), var(--panel);
}
.turnover-action-grid {
    display: grid;
    grid-template-columns: minmax(150px, max-content) minmax(150px, max-content) 1fr;
    gap: 14px;
    align-items: start;
}
.ready-form {
    display: grid;
    gap: 10px;
    min-width: 0;
}
.ready-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #334155;
    font-weight: 800;
}
.badge.ready,
.badge.deep_clean,
.badge.routine {
    background: #dcfce7;
    color: #15803d;
}
.badge.isolation,
.badge.discharge,
.badge.transfer {
    background: #fef3c7;
    color: #b45309;
}
body.theme-dark .bed-turnover-panel,
body.theme-dark .turnover-actions-panel {
    background: linear-gradient(135deg, rgba(245, 158, 11, .16), rgba(14, 165, 233, .12)), #111827 !important;
}
body.theme-dark .ready-form label {
    color: #e2e8f0;
}
body.theme-dark .badge.ready,
body.theme-dark .badge.deep_clean,
body.theme-dark .badge.routine {
    background: rgba(22, 163, 74, .2);
    color: #86efac;
}
body.theme-dark .badge.isolation,
body.theme-dark .badge.discharge,
body.theme-dark .badge.transfer {
    background: rgba(245, 158, 11, .2);
    color: #fcd34d;
}
@media (max-width: 900px) {
    .turnover-action-grid {
        grid-template-columns: 1fr;
    }
}
/* Dietary meal order surfaces */
.dietary-panel tbody tr td:first-child a,
.dietary-summary h2 { color: var(--brand-dark); }
.dietary-action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: stretch; }
.dietary-action-grid form { display: grid; gap: 8px; align-content: start; }
.dietary-action-grid textarea { min-height: 76px; }
.check-card { min-height: 48px; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); font-weight: 700; }
.badge.ordered, .badge.approved, .badge.preparing, .badge.held, .badge.delivered, .badge.nil_by_mouth, .badge.diabetic, .badge.cardiac, .badge.renal, .badge.pediatric, .badge.high_protein { color: #064e3b; background: #d1fae5; }
.badge.preparing, .badge.held { color: #92400e; background: #fef3c7; }
.badge.cancelled { color: #991b1b; background: #fee2e2; }
.theme-dark .check-card { background: rgba(255,255,255,.04); }
/* Clinical handover surfaces */
.handover-summary,
.handover-panel {
    background: linear-gradient(135deg, rgba(6, 182, 212, .12), rgba(99, 102, 241, .1));
}

.handover-action-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.handover-action-grid form {
    display: grid;
    gap: 10px;
}

.handover-action-grid textarea {
    min-height: 92px;
}

.handover-sbar-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.handover-sbar-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 14px;
}

.handover-sbar-grid article span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.handover-sbar-grid article p {
    margin: 0;
    line-height: 1.55;
}
/* Patient feedback surfaces */
.feedback-summary,
.feedback-panel,
.feedback-workflow-panel {
    background: linear-gradient(135deg, rgba(14, 165, 233, .12), rgba(34, 197, 94, .1));
}

.feedback-form textarea {
    min-height: 110px;
}

.badge.compliment {
    background: rgba(34, 197, 94, .16);
    color: #15803d;
}

.badge.suggestion {
    background: rgba(14, 165, 233, .16);
    color: #0369a1;
}

.badge.complaint {
    background: rgba(244, 63, 94, .15);
    color: #be123c;
}
/* Shell geometry lock: keeps the sidebar full-height, responsive, and RTL-safe. */
:root {
    --hf-sidebar-width: 300px;
}

.app-shell {
    display: block !important;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 100;
    width: var(--hf-sidebar-width) !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.main {
    min-height: 100vh;
    width: calc(100% - var(--hf-sidebar-width)) !important;
    margin-left: var(--hf-sidebar-width) !important;
}

.nav {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

html[dir="rtl"] .sidebar {
    inset: 0 0 0 auto !important;
    border-right: 0 !important;
    border-left: 1px solid rgba(255, 255, 255, .14);
    box-shadow: -20px 0 60px rgba(8, 47, 73, .16), inset 1px 0 0 rgba(255, 255, 255, .12) !important;
}

html[dir="rtl"] .main {
    margin-left: 0 !important;
    margin-right: var(--hf-sidebar-width) !important;
}

html[dir="rtl"] .sidebar::before {
    inset: 0 0 0 auto !important;
}

@media (max-width: 1180px) {
    :root {
        --hf-sidebar-width: 276px;
    }
}

@media (max-width: 820px) {
    :root {
        --hf-sidebar-width: 82px;
    }

    .sidebar {
        padding: 14px 10px !important;
    }

    .brand-copy,
    .sidebar-footer,
    .nav-text {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }
}

@media (max-width: 460px) {
    :root {
        --hf-sidebar-width: 70px;
    }
}

@media print {
    :root {
        --hf-sidebar-width: 0px;
    }

    .sidebar {
        display: none !important;
    }

    .main {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}
/* Discharge follow-up surfaces */
.discharge-followup-panel,
.discharge-followup-summary,
.discharge-followup-workflow-panel {
    background: linear-gradient(135deg, rgba(245, 158, 11, .12), rgba(14, 165, 233, .09));
}

.discharge-followup-form textarea {
    min-height: 108px;
}

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

.followup-action-grid .full {
    grid-column: 1 / -1;
}

.followup-note-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.followup-note-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 14px;
}

.followup-note-grid article span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.followup-note-grid article p {
    margin: 0;
    line-height: 1.55;
}

.badge.critical,
.badge.urgent {
    background: rgba(225, 29, 72, .16);
    color: #be123c;
}

@media (max-width: 760px) {
    .followup-action-grid {
        grid-template-columns: 1fr;
    }
}
/* Infection control and IPC surveillance surfaces */
.infection-panel,
.infection-summary,
.infection-workflow-panel {
    background: linear-gradient(135deg, rgba(225, 29, 72, .10), rgba(14, 165, 233, .08)), var(--panel);
}

.infection-form textarea,
.infection-action-grid textarea {
    min-height: 108px;
}

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

.infection-action-grid .full {
    grid-column: 1 / -1;
}

.infection-note-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.infection-note-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft, #f8fafc);
    padding: 14px;
}

.infection-note-grid article span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.infection-note-grid article p {
    margin: 0;
    line-height: 1.55;
}

.badge.isolated,
.badge.contact,
.badge.droplet,
.badge.contact_droplet {
    background: rgba(225, 29, 72, .16);
    color: #be123c;
}

.badge.airborne,
.badge.protective,
.badge.confirmed {
    background: rgba(124, 58, 237, .16);
    color: #6d28d9;
}

.badge.standard,
.badge.suspected,
.badge.under_review {
    background: rgba(14, 165, 233, .16);
    color: #0369a1;
}

.badge.ruled_out,
.badge.none {
    background: rgba(100, 116, 139, .16);
    color: #475569;
}

.tone-red.pipeline-card {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}

body.theme-dark .infection-panel,
body.theme-dark .infection-summary,
body.theme-dark .infection-workflow-panel {
    background: linear-gradient(135deg, rgba(225, 29, 72, .16), rgba(14, 165, 233, .12)), #111827 !important;
}

body.theme-dark .infection-note-grid article {
    background: rgba(255, 255, 255, .04);
    border-color: rgba(148, 163, 184, .28);
}

@media (max-width: 760px) {
    .infection-action-grid {
        grid-template-columns: 1fr;
    }
}
/* Critical result closed-loop alerting */
.critical-alert-panel,
.critical-alert-summary,
.critical-alert-workflow-panel {
    background: linear-gradient(135deg, rgba(220, 38, 38, .11), rgba(245, 158, 11, .09)), var(--panel);
}

.critical-alert-form textarea,
.critical-alert-action-grid textarea {
    min-height: 108px;
}

.critical-alert-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.critical-alert-action-grid .full {
    grid-column: 1 / -1;
}

.critical-alert-note-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.critical-alert-note-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft, #f8fafc);
    padding: 14px;
}

.critical-alert-note-grid article span {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .04em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.critical-alert-note-grid article p {
    margin: 0;
    line-height: 1.55;
}

.badge.life_threatening,
.badge.escalated {
    background: rgba(127, 29, 29, .18);
    color: #991b1b;
}

.badge.watch,
.badge.notified,
.badge.acknowledged {
    background: rgba(245, 158, 11, .18);
    color: #92400e;
}

.badge.open {
    background: rgba(220, 38, 38, .14);
    color: #b91c1c;
}

.badge.dismissed {
    background: rgba(100, 116, 139, .16);
    color: #475569;
}

body.theme-dark .critical-alert-panel,
body.theme-dark .critical-alert-summary,
body.theme-dark .critical-alert-workflow-panel {
    background: linear-gradient(135deg, rgba(220, 38, 38, .18), rgba(245, 158, 11, .13)), #111827 !important;
}

body.theme-dark .critical-alert-note-grid article {
    background: rgba(255, 255, 255, .04);
    border-color: rgba(148, 163, 184, .28);
}

@media (max-width: 760px) {
    .critical-alert-action-grid {
        grid-template-columns: 1fr;
    }
}