/* TibaMoja theme - deep navy chrome, clinical teal actions, warm coral/amber alerts. */
:root {
    --mf-navy-900: #0b2239;
    --mf-navy-800: #12304d;
    --mf-navy-700: #1b4066;
    --mf-teal: #0d9488;
    --mf-teal-dark: #0f766e;
    --mf-teal-light: #e6f6f4;
    --mf-coral: #e2574c;
    --mf-amber: #f59e0b;
    --mf-green: #16a34a;
    --mf-blue: #2563eb;
    --mf-bg: #f2f5f8;
    --mf-surface: #ffffff;
    --mf-border: #e3e8ef;
    --mf-text: #1e293b;
    --mf-muted: #64748b;
    --sidebar-w: 256px;

    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--mf-text);
    --bs-body-bg: var(--mf-bg);
    --bs-primary: var(--mf-teal);
    --bs-primary-rgb: 13, 148, 136;
    --bs-link-color: var(--mf-teal-dark);
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: var(--mf-navy-700);
    --bs-border-color: var(--mf-border);
}

body { background: var(--mf-bg); font-size: 0.9rem; }

.btn-primary {
    --bs-btn-bg: var(--mf-teal); --bs-btn-border-color: var(--mf-teal);
    --bs-btn-hover-bg: var(--mf-teal-dark); --bs-btn-hover-border-color: var(--mf-teal-dark);
    --bs-btn-active-bg: var(--mf-teal-dark); --bs-btn-active-border-color: var(--mf-teal-dark);
    --bs-btn-disabled-bg: var(--mf-teal); --bs-btn-disabled-border-color: var(--mf-teal);
}
.btn-outline-primary {
    --bs-btn-color: var(--mf-teal-dark); --bs-btn-border-color: var(--mf-teal);
    --bs-btn-hover-bg: var(--mf-teal); --bs-btn-hover-border-color: var(--mf-teal);
    --bs-btn-active-bg: var(--mf-teal-dark);
}
.btn-navy { --bs-btn-color:#fff; --bs-btn-bg: var(--mf-navy-800); --bs-btn-border-color: var(--mf-navy-800);
    --bs-btn-hover-color:#fff; --bs-btn-hover-bg: var(--mf-navy-700); --bs-btn-hover-border-color: var(--mf-navy-700); }
.text-teal { color: var(--mf-teal-dark) !important; }
.bg-teal-light { background: var(--mf-teal-light) !important; }
.form-control:focus, .form-select:focus {
    border-color: var(--mf-teal); box-shadow: 0 0 0 .2rem rgba(13, 148, 136, .18);
}
.form-check-input:checked { background-color: var(--mf-teal); border-color: var(--mf-teal); }

/* ---------- layout ---------- */
.page-wrapper { display: flex; min-height: 100vh; }

.left-sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: var(--mf-navy-900); color: #fff;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
    scrollbar-width: thin; scrollbar-color: var(--mf-navy-700) transparent;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.35rem; text-decoration: none; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
    width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--mf-teal), #22c3b4); font-size: 1.25rem;
}
.sidebar-brand .name { font-weight: 700; font-size: 1.08rem; letter-spacing: -0.02em; line-height: 1.1; }
.sidebar-brand .sub { font-size: .7rem; color: #8fb3cf; font-weight: 500; }
.left-sidebar nav { padding: .5rem 0 2rem; }
.left-sidebar ul { list-style: none; margin: 0; padding: 0; }
.nav-small-cap {
    padding: 1rem 1.35rem .35rem; font-size: .68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .08em; color: #6f93b3;
}
.sidebar-link {
    display: flex; align-items: center; gap: .65rem; padding: .48rem 1.35rem; margin: 1px .6rem;
    border-radius: 8px; color: #d3e1ee; text-decoration: none; font-size: .87rem;
}
.sidebar-link i { font-size: 1.1rem; color: #7fa5c6; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: var(--mf-teal); color: #fff; font-weight: 600; }
.sidebar-link.active i { color: #fff; }
.sidebar-link .badge-q {
    margin-left: auto; background: var(--mf-coral); color: #fff; border-radius: 999px;
    font-size: .7rem; font-weight: 700; padding: .1rem .48rem; min-width: 1.4rem; text-align: center;
}
.sidebar-link.active .badge-q { background: #fff; color: var(--mf-teal-dark); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 60px; background: var(--mf-surface); border-bottom: 1px solid var(--mf-border);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 1030;
}
.topbar .search { max-width: 380px; flex: 1; position: relative; }
.topbar .search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--mf-muted); }
.topbar .search input { padding-left: 2.2rem; background: var(--mf-bg); border-color: transparent; border-radius: 999px; }
.branch-chip {
    background: var(--mf-teal-light); color: var(--mf-teal-dark); border-radius: 999px; padding: .25rem .75rem;
    font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--mf-navy-800); color: #fff;
    display: grid; place-items: center; font-weight: 600; font-size: .8rem;
}
.content { padding: 1.5rem; flex: 1; }
.sidebar-toggle { display: none; }

@media (max-width: 991.98px) {
    .left-sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); transition: left .2s; }
    .left-sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.35); }
    .sidebar-toggle { display: inline-flex; }
    .content { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}

/* ---------- components ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.page-header .subtitle { color: var(--mf-muted); font-size: .85rem; margin-top: .15rem; }

.card { border: 1px solid var(--mf-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); }
.card-header { background: transparent; border-bottom: 1px solid var(--mf-border); font-weight: 600; padding: .85rem 1.1rem; }
.card-header .mdi { color: var(--mf-teal); }

.table { --bs-table-hover-bg: #f6fafb; margin-bottom: 0; }
.table > thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mf-muted);
    font-weight: 600; background: #f8fafc; border-bottom-width: 1px; white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-card .table > :not(caption) > * > * { padding: .65rem 1rem; }

.card.stat-card { padding: 1.1rem 1.2rem; flex-direction: row; align-items: center; gap: 1rem; }
.stat-card .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.45rem; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-card .label { color: var(--mf-muted); font-size: .8rem; }
.tone-teal { background: var(--mf-teal-light); color: var(--mf-teal-dark); }
.tone-navy { background: #e7eef6; color: var(--mf-navy-700); }
.tone-coral { background: #fdecea; color: #c0392b; }
.tone-amber { background: #fef3c7; color: #b45309; }
.tone-green { background: #dcfce7; color: #15803d; }
.tone-blue { background: #dbeafe; color: #1d4ed8; }

.status-pill { display: inline-block; border-radius: 999px; padding: .18rem .6rem; font-size: .72rem; font-weight: 600; white-space: nowrap; }

.patient-banner {
    background: linear-gradient(120deg, var(--mf-navy-800), var(--mf-navy-700)); color: #fff;
    border-radius: 12px; padding: 1rem 1.25rem; display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap;
}
.patient-banner .pb-avatar { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 1.6rem; }
.patient-banner .pb-name { font-size: 1.15rem; font-weight: 700; }
.patient-banner .pb-meta { color: #b7cde2; font-size: .82rem; }
.patient-banner .pb-tag { background: rgba(255,255,255,.12); border-radius: 999px; padding: .2rem .65rem; font-size: .75rem; }
.patient-banner .pb-allergy { background: var(--mf-coral); border-radius: 999px; padding: .2rem .65rem; font-size: .75rem; font-weight: 600; }

.vitals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
.vital { background: var(--mf-bg); border-radius: 10px; padding: .55rem .75rem; }
.vital .v-label { font-size: .7rem; color: var(--mf-muted); text-transform: uppercase; letter-spacing: .04em; }
.vital .v-value { font-size: 1.05rem; font-weight: 700; }

.nav-tabs .nav-link { color: var(--mf-muted); font-weight: 500; }
.nav-tabs .nav-link.active { color: var(--mf-teal-dark); font-weight: 600; border-bottom-color: #fff; }

.bed-tile { border-radius: 10px; padding: .7rem; text-align: center; border: 1px solid var(--mf-border); background: #fff; display:block; text-decoration:none; color: inherit; }
.bed-tile.free { border-color: #86efac; background: #f0fdf4; }
.bed-tile.occupied { border-color: #fca5a5; background: #fef2f2; }
.bed-tile .bed-no { font-weight: 700; font-size: 1rem; }
.bed-tile .bed-pt { font-size: .74rem; color: var(--mf-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-state { text-align: center; color: var(--mf-muted); padding: 2.5rem 1rem; }
.empty-state i { font-size: 2.4rem; color: #cbd5e1; display: block; margin-bottom: .4rem; }

.form-label { font-weight: 500; font-size: .82rem; color: #334155; margin-bottom: .25rem; }
.errorlist { list-style: none; padding: 0; margin: .2rem 0 0; color: var(--mf-coral); font-size: .78rem; }
.section-title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--mf-teal-dark); margin: 1rem 0 .6rem; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-hero {
    background: radial-gradient(circle at 20% 20%, rgba(34,195,180,.35), transparent 45%),
                linear-gradient(150deg, var(--mf-navy-900), var(--mf-navy-700));
    color: #fff; padding: 3.5rem; display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero h2 { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.03em; max-width: 26rem; }
.login-hero .feature { display: flex; gap: .75rem; align-items: center; margin-bottom: .8rem; color: #cfe0ef; }
.login-hero .feature i { font-size: 1.3rem; color: #5eead4; }
.login-form-wrap { display: grid; place-items: center; padding: 2rem; }
.login-form-wrap form { width: 100%; max-width: 380px; }
@media (max-width: 767.98px) { .login-page { grid-template-columns: 1fr; } .login-hero { display: none; } }

/* ---------- print ---------- */
.print-doc { max-width: 800px; margin: 0 auto; background: #fff; padding: 2rem; border-radius: 12px; }
.print-doc .doc-head { display: flex; justify-content: space-between; border-bottom: 3px solid var(--mf-teal); padding-bottom: .75rem; margin-bottom: 1rem; }
@media print {
    .left-sidebar, .topbar, .no-print, .messages { display: none !important; }
    body, .content { background: #fff !important; padding: 0 !important; }
    .print-doc { box-shadow: none; padding: 0; }
    .card { border: none; box-shadow: none; }
}

.form-control, .form-select { font-size: .9rem; }
.form-control-lg, .form-select-lg { font-size: 1rem; }
.card-header .nav-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.card-header .nav-tabs .nav-link { padding: .5rem .75rem; white-space: nowrap; }

.moh-grid td, .moh-grid th { padding: .25rem .35rem !important; text-align: center; }
.moh-grid td:first-child, .moh-grid th:first-child { text-align: left; white-space: nowrap; position: sticky; left: 0; background: #fff; }
.moh-grid .zero { color: #cbd5e1; }
.dropdown-item.active, .dropdown-item:active { background: var(--mf-teal); color: #fff; }
button.branch-chip { cursor: pointer; }

/* Captcha - same "Human verification" block as Bimalink, in TibaMoja colours */
.captcha-block { background: #f8fafc; border: 1.5px solid var(--mf-border); border-radius: 10px; padding: .85rem 1rem; }
.captcha-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--mf-muted); margin-bottom: .6rem; }
.captcha-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.captcha-row img.captcha { display: block; border-radius: 6px; border: 1px solid var(--mf-border); }
.captcha-input { width: 100px; height: 44px; border: 1.5px solid #d1d5db; border-radius: 8px; font-size: 1.1rem; font-weight: 700;
    text-align: center; background: #fff; color: var(--mf-text); padding: 0 .5rem; transition: border-color .15s, box-shadow .15s; }
.captcha-input:focus { outline: none; border-color: var(--mf-teal); box-shadow: 0 0 0 3px rgba(13, 148, 136, .18); }
.captcha-refresh { color: var(--mf-teal-dark); text-decoration: none; font-weight: 500; }

/* Themed confirmation dialog (replaces the browser's confirm/prompt) */
.btn-danger {
    --bs-btn-bg: var(--mf-coral); --bs-btn-border-color: var(--mf-coral);
    --bs-btn-hover-bg: #c94237; --bs-btn-hover-border-color: #c94237;
    --bs-btn-active-bg: #b83a30; --bs-btn-active-border-color: #b83a30;
}
.btn-warning {
    --bs-btn-color: #fff; --bs-btn-bg: var(--mf-amber); --bs-btn-border-color: var(--mf-amber);
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706;
    --bs-btn-active-color: #fff; --bs-btn-active-bg: #b45309;
}
.mf-confirm .modal-content { border: 0; border-radius: 16px; box-shadow: 0 24px 60px rgba(11, 34, 57, .25); }
.mf-confirm .modal-dialog { max-width: 440px; }
.mf-confirm-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.75rem; }
.mf-confirm[data-tone="primary"] .mf-confirm-icon { background: var(--mf-teal-light); color: var(--mf-teal-dark); }
.mf-confirm[data-tone="warning"] .mf-confirm-icon { background: #fef3c7; color: #b45309; }
.mf-confirm[data-tone="danger"] .mf-confirm-icon { background: #fdecea; color: #c0392b; }
.modal-backdrop.show { opacity: .45; background: var(--mf-navy-900); }

/* Help & FAQ */
.guide-toc { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.guide-toc .list-group-item { border: 0; padding: .3rem 1rem; }
.guide-toc .guide-sub { font-size: .78rem; }
.guide-search-icon { position: absolute; left: .55rem; top: 50%; transform: translateY(-50%); color: var(--mf-muted); }
.guide-body { max-width: 900px; line-height: 1.6; padding: 1.5rem 2rem; }
.guide-body h1 { font-size: 1.6rem; font-weight: 700; }
.guide-body h2 { font-size: 1.3rem; font-weight: 700; margin-top: 2.2rem; padding-top: .8rem; border-top: 2px solid var(--mf-teal-light); color: var(--mf-navy-800); scroll-margin-top: 80px; }
.guide-body h3 { font-size: 1.05rem; font-weight: 700; margin-top: 1.5rem; scroll-margin-top: 80px; }
.guide-body img { max-width: 100%; border: 1px solid var(--mf-border); border-radius: 10px; box-shadow: 0 6px 18px rgba(15, 23, 42, .08); margin: .5rem 0 1rem; }
.guide-body blockquote { background: var(--mf-teal-light); border-left: 4px solid var(--mf-teal); border-radius: 0 8px 8px 0; padding: .7rem 1rem; margin: 1rem 0; }
.guide-body blockquote p { margin: 0; }
.guide-body code { background: var(--mf-bg); color: var(--mf-navy-700); padding: .05rem .35rem; border-radius: 4px; }
.guide-body table { font-size: .85rem; }
.guide-body mark { background: #fde68a; padding: 0 .1rem; }
@media (max-width: 991.98px) { .guide-toc { position: static; max-height: none; } .guide-body { padding: 1rem; } }

/* Copyright footer (Innova Africa Ltd) */
.app-footer { padding: .9rem 1.5rem 1.2rem; text-align: center; font-size: .78rem; color: var(--mf-muted); border-top: 1px solid var(--mf-border); }
.app-footer a, .login-copyright a { color: var(--mf-teal-dark); font-weight: 600; text-decoration: none; }
.app-footer a:hover, .login-copyright a:hover { text-decoration: underline; }
.login-copyright { position: absolute; bottom: 1rem; left: 0; right: 0; text-align: center; font-size: .78rem; color: var(--mf-muted); margin: 0; }
.login-home-link { margin: 1.25rem 0 0; text-align: center; font-size: .88rem; }
.login-home-link a { color: var(--mf-teal-dark); font-weight: 600; text-decoration: none; }
.login-home-link a:hover { text-decoration: underline; }
.login-form-wrap { position: relative; align-content: center; }

/* Collapsible sidebar sections */
.nav-section-toggle { display: flex; align-items: center; gap: .4rem; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.nav-section-toggle:hover, .nav-section-toggle:focus-visible { color: #d3e1ee; outline: none; }
.nav-section-toggle:focus-visible { box-shadow: inset 0 0 0 2px rgba(94, 234, 212, .5); border-radius: 6px; }
.nav-section-toggle .mdi-chevron-down { margin-left: auto; font-size: 1rem; transition: transform .15s ease; }
.nav-section-toggle.collapsed .mdi-chevron-down { transform: rotate(-90deg); }
.nav-section-toggle .section-badge { margin-left: .35rem; font-size: .65rem; letter-spacing: 0; }
.nav-section-toggle .section-badge { background: var(--mf-coral); color: #fff; border-radius: 999px; font-weight: 700; padding: .05rem .42rem; min-width: 1.2rem; text-align: center; }

/* Error pages (CSRF / page expired) */
.error-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem; padding: 2rem 1rem;
    background: radial-gradient(circle at 15% 10%, rgba(34,195,180,.22), transparent 40%),
                linear-gradient(160deg, var(--mf-navy-900), var(--mf-navy-700)); }
.error-card { width: 100%; max-width: 560px; background: var(--mf-surface); border-radius: 18px; padding: 2.25rem 2rem; box-shadow: 0 30px 70px rgba(4,18,31,.35); }
.error-brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; color: var(--mf-navy-900); text-decoration: none; margin-bottom: 1.75rem; }
.error-icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 2rem; margin-bottom: 1rem; }  /* colour from .tone-* */
.error-code { font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mf-teal-dark); margin-bottom: .35rem; }
.error-card h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; color: var(--mf-navy-900); margin-bottom: .75rem; }
.error-lede { color: #475569; margin-bottom: 1.25rem; }
.error-why { background: var(--mf-bg); border-radius: 12px; padding: 1rem 1.1rem; margin-bottom: 1.25rem; }
.error-why-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin-bottom: .5rem; }
.error-why ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; color: #334155; font-size: .93rem; }
.error-why li { display: flex; gap: .6rem; align-items: flex-start; }
.error-why i { color: var(--mf-teal); font-size: 1.1rem; line-height: 1.3; }
.error-next { color: #334155; margin-bottom: 1.5rem; }
.error-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.error-actions .btn { flex: 1 1 auto; }
.error-help { font-size: .82rem; color: #64748b; margin: 1.5rem 0 0; }
.error-debug { font-family: ui-monospace, monospace; font-size: .78rem; color: var(--mf-coral); background: #fef2f2; border-radius: 8px; padding: .5rem .7rem; margin: 1rem 0 0; }
.error-debug span { color: #94a3b8; }
.error-copyright { font-size: .78rem; color: #9fbad0; margin: 0; }
.error-copyright a { color: #5eead4; font-weight: 600; text-decoration: none; }
@media (max-width: 480px) { .error-card { padding: 1.75rem 1.25rem; } .error-card h1 { font-size: 1.45rem; } }

/* Messages (partials/messages.html) */
.mf-message { display: flex; align-items: flex-start; gap: .6rem; padding: .7rem 2.75rem .7rem .9rem; border: 0; border-left: 4px solid currentColor; box-shadow: 0 4px 14px rgba(15,23,42,.06); }
.mf-message > .mdi { font-size: 1.2rem; line-height: 1.2; flex: none; }
.mf-message > span { flex: 1; }
.mf-message .btn-close { padding: .95rem .9rem; }
.mf-message.alert-success { background: #ecfdf5; color: #166534; }
.mf-message.alert-info { background: #eff6ff; color: #1e40af; }
.mf-message.alert-warning { background: #fffbeb; color: #92400e; }
.mf-message.alert-danger { background: #fef2f2; color: #991b1b; }
.mf-message.fade:not(.show) { transition: opacity .4s ease; }
