:root {
    --primary: #2563eb;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --surface: #ffffff;
    --soft: #f3f6fb;
    --line: #dbe3ef;
    --text: #172033;
    --muted: #64748b;
    --sidebar: #ffffff;
    --topbar: #ffffff;
    --input: #ffffff;
    --table-head: #f8fafc;
    --shadow: rgba(15, 23, 42, .08);
}

html[data-theme="dark"] {
    --primary: #60a5fa;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #fb7185;
    --surface: #111827;
    --soft: #0b1220;
    --line: #253247;
    --text: #e5edf7;
    --muted: #9fb0c6;
    --sidebar: #0f172a;
    --topbar: #111827;
    --input: #172033;
    --table-head: #182235;
    --shadow: rgba(0, 0, 0, .35);
}

body {
    background: var(--soft);
    color: var(--text);
    transition: background-color .2s ease, color .2s ease;
}

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

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    flex: 0 0 260px;
    padding: 18px 14px;
}

.brand {
    align-items: center;
    display: flex;
    font-size: 19px;
    font-weight: 700;
    gap: 10px;
    margin-bottom: 22px;
}

.brand span:last-child {
    color: var(--text);
}

.brand-mark,
.login-icon {
    align-items: center;
    background: var(--primary);
    border-radius: 8px;
    color: white;
    display: inline-flex;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.sidebar .nav-link {
    align-items: center;
    border-radius: 7px;
    color: var(--muted);
    display: flex;
    gap: 10px;
    margin: 2px 0;
    padding: 10px 12px;
}

.sidebar .nav-link:hover {
    background: rgba(37, 99, 235, .1);
    color: var(--primary);
}

.sidebar .nav-link.disabled {
    color: #94a3b8;
}

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    align-items: center;
    background: var(--topbar);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 70px;
    padding: 12px 22px;
}

.search {
    align-items: center;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 10px;
    max-width: 520px;
    padding: 9px 12px;
    width: 100%;
}

.search input {
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--text);
    width: 100%;
}

.search input::placeholder {
    color: var(--muted);
}

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

.icon-btn {
    align-items: center;
    background: var(--input);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: inline-flex;
    height: 38px;
    justify-content: center;
    width: 38px;
}

.icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.notification-btn {
    position: relative;
}

.notification-badge {
    align-items: center;
    background: var(--danger);
    border: 2px solid var(--topbar);
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    height: 20px;
    justify-content: center;
    min-width: 20px;
    padding: 0 5px;
    position: absolute;
    right: -7px;
    top: -7px;
}

.notification-menu {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px var(--shadow);
    color: var(--text);
    min-width: 340px;
    overflow: hidden;
    padding: 0;
}

.notification-head,
.notification-footer {
    align-items: center;
    display: flex;
    justify-content: space-between;
    padding: 12px 14px;
}

.notification-head {
    background: var(--table-head);
    border-bottom: 1px solid var(--line);
}

.notification-head span {
    background: rgba(220, 38, 38, .12);
    border-radius: 999px;
    color: var(--danger);
    font-size: 12px;
    font-weight: 800;
    padding: 3px 9px;
}

.notification-item {
    align-items: center;
    color: var(--text);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 12px 14px;
    text-decoration: none;
}

.notification-item:hover {
    background: rgba(96, 165, 250, .08);
    color: var(--text);
}

.notification-item small {
    color: var(--muted);
    display: block;
    margin-top: 2px;
}

.notification-item b {
    color: var(--danger);
    white-space: nowrap;
}

.notification-empty {
    color: var(--muted);
    padding: 18px 14px;
    text-align: center;
}

.notification-footer {
    border-top: 1px solid var(--line);
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.user-chip {
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
}

.user-chip small {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 500;
}

.content {
    padding: 22px;
}

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

.page-heading h1 {
    font-size: 26px;
    margin: 0;
}

.page-heading p {
    color: var(--muted);
    margin: 3px 0 0;
}

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

.stat-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.stat-link {
    color: inherit;
    text-decoration: none;
}

.stat-link:hover {
    box-shadow: 0 10px 28px var(--shadow);
    transform: translateY(-1px);
}

.stat-card {
    align-items: center;
    border-left-width: 4px;
    display: flex;
    justify-content: space-between;
}

.stat-card span {
    color: var(--muted);
    display: block;
    font-size: 14px;
}

.stat-card strong {
    display: block;
    font-size: 25px;
}

.stat-card i {
    font-size: 25px;
}

.revenue-breakdown {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) 24px minmax(0, 1fr) 24px minmax(0, 1fr) 24px minmax(0, 1.2fr);
    margin: 16px 0;
    padding: 16px;
}

.revenue-breakdown > div {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.revenue-breakdown span {
    color: var(--muted);
    display: block;
    font-size: 13px;
}

.revenue-breakdown strong {
    display: block;
    font-size: 24px;
    margin-top: 4px;
}

.revenue-breakdown > i {
    color: var(--muted);
    justify-self: center;
}

.revenue-breakdown .revenue-total {
    background: rgba(22, 163, 74, .1);
    border-color: rgba(22, 163, 74, .45);
}

.panel h2 {
    font-size: 17px;
    margin-bottom: 16px;
}

.table-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.table {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--line);
    --bs-table-hover-bg: rgba(96, 165, 250, .08);
    --bs-table-hover-color: var(--text);
}

.table-light {
    --bs-table-bg: var(--table-head);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--line);
}

.form-control,
.form-select {
    background-color: var(--input);
    border-color: var(--line);
    color: var(--text);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--input);
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(96, 165, 250, .18);
    color: var(--text);
}

.form-control::placeholder {
    color: var(--muted);
}

.form-text {
    color: var(--muted) !important;
}

.prescription-builder {
    display: grid;
    gap: 12px;
}

.prescription-row {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.prescription-row + .prescription-row {
    margin-top: 12px;
}

.prescription-row-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.prescription-row-head strong {
    font-size: 14px;
}

.medicine-row-search {
    margin-bottom: 8px;
}

.nav-tabs {
    border-color: var(--line);
}

.nav-tabs .nav-link {
    color: var(--muted);
}

.nav-tabs .nav-link.active {
    background: var(--surface);
    border-color: var(--line) var(--line) var(--surface);
    color: var(--primary);
}

.sms-import-box {
    background: rgba(37, 99, 235, .06);
    border: 1px dashed var(--primary);
    border-radius: 8px;
    padding: 16px;
}

.sms-file-help {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
    margin-top: 10px;
}

.lab-summary-strip {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}

.lab-summary-tab {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    padding: 14px 16px;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.lab-summary-tab:hover,
.lab-summary-tab.active {
    border-color: var(--primary);
    box-shadow: 0 12px 30px var(--shadow);
    transform: translateY(-1px);
}

.lab-summary-strip span {
    color: var(--muted);
    display: block;
    font-size: 13px;
}

.lab-summary-strip strong {
    display: block;
    font-size: 28px;
    line-height: 1.1;
    margin-top: 4px;
}

.lab-section {
    margin-bottom: 22px;
}

.lab-section-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.lab-section-head h2 {
    align-items: center;
    display: flex;
    font-size: 18px;
    gap: 9px;
    margin: 0;
}

.lab-section-pending .lab-section-head h2 i {
    color: var(--warning);
}

.lab-section-completed .lab-section-head h2 i {
    color: var(--success);
}

.lab-section-head p {
    color: var(--muted);
    margin: 4px 0 0;
}

.lab-section-head > span {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: inline-flex;
    font-weight: 800;
    height: 34px;
    justify-content: center;
    min-width: 42px;
    padding: 0 12px;
}

.lab-orders {
    display: grid;
    gap: 16px;
}

.lab-order-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.lab-order-card.is-pending {
    border-left: 4px solid var(--warning);
}

.lab-order-card.is-completed {
    border-left: 4px solid var(--success);
}

.lab-order-card.is-completed .lab-order-header {
    background: rgba(22, 163, 74, .06);
}

.lab-order-header {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding: 18px 20px;
}

.lab-order-title {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 18px;
    font-weight: 800;
}

.lab-order-meta {
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 8px;
}

.lab-order-meta i {
    color: var(--primary);
    margin-right: 4px;
}

.lab-order-actions {
    align-items: flex-end;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 170px;
}

.lab-test-count {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.lab-order-table {
    border-top: 1px solid var(--line);
}

.lab-test-name {
    font-weight: 700;
    min-width: 190px;
}

.lab-result-form {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(180px, 2fr) minmax(130px, 1.2fr) minmax(80px, .8fr) minmax(140px, 1fr) 42px;
}

.lab-result-form .btn {
    min-height: 32px;
}

.lab-empty {
    align-items: center;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 22px;
}

.login-page {
    align-items: center;
    background:
        linear-gradient(90deg, rgba(239, 246, 255, .95), rgba(239, 246, 255, .62) 45%, rgba(15, 23, 42, .3)),
        url("/assets/images/hospital-login-bg.png") center / cover no-repeat;
    display: flex;
    min-height: 100vh;
    justify-content: center;
    padding: 20px;
}

html[data-theme="dark"] body.login-page {
    background:
        linear-gradient(90deg, rgba(7, 17, 31, .96), rgba(7, 17, 31, .76) 45%, rgba(7, 17, 31, .42)),
        url("/assets/images/hospital-login-bg.png") center / cover no-repeat;
}

.login-card {
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(18px);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 55px var(--shadow);
    max-width: 410px;
    padding: 28px;
    width: 100%;
    position: relative;
}

html[data-theme="dark"] .login-card {
    background: rgba(17, 24, 39, .82);
}

.login-theme-toggle {
    position: absolute;
    right: 18px;
    top: 18px;
}

.login-card h1 {
    font-size: 25px;
    margin-top: 14px;
}

.login-card p,
.demo-login {
    color: var(--muted);
}

.demo-login {
    font-size: 13px;
    margin-top: 16px;
    text-align: center;
}

.required::after {
    color: var(--danger);
    content: " *";
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        border-bottom: 1px solid var(--line);
        border-right: 0;
        width: 100%;
    }

    .sidebar .nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        flex-wrap: wrap;
    }

    .revenue-breakdown {
        grid-template-columns: 1fr;
    }

    .revenue-breakdown > i {
        display: none;
    }

    .lab-summary-strip {
        grid-template-columns: 1fr;
    }

    .lab-section-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .lab-order-header {
        align-items: stretch;
        flex-direction: column;
    }

    .lab-order-actions {
        align-items: stretch;
        min-width: 0;
    }

    .lab-result-form {
        grid-template-columns: 1fr;
    }

    .lab-result-form .btn {
        width: 100%;
    }
}

.queue-display-page {
    background: #07111f;
    color: #f8fafc;
    min-height: 100vh;
}

.queue-display {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
    padding: 34px;
}

.queue-display-header {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.queue-display-header span,
.queue-section-title,
.queue-display-footer {
    color: #93c5fd;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.queue-display-header h1 {
    font-size: clamp(36px, 5vw, 76px);
    font-weight: 800;
    margin: 0;
}

.queue-clock {
    align-items: center;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(147, 197, 253, .25);
    border-radius: 8px;
    display: flex;
    font-size: 28px;
    gap: 12px;
    padding: 16px 20px;
}

.queue-hero {
    display: grid;
    gap: 24px;
    grid-template-columns: 1.3fr 1fr;
}

.queue-focus,
.queue-number-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, .96), rgba(30, 41, 59, .92));
    border: 1px solid rgba(147, 197, 253, .22);
    border-radius: 8px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .3);
}

.queue-focus {
    min-height: 290px;
    padding: 32px;
}

.queue-focus span {
    color: #bfdbfe;
    display: block;
    font-size: clamp(24px, 3vw, 42px);
    font-weight: 800;
}

.queue-focus strong {
    color: #ffffff;
    display: block;
    font-size: clamp(76px, 12vw, 170px);
    font-weight: 900;
    line-height: 1;
    margin: 18px 0;
}

.queue-focus small {
    color: #cbd5e1;
    display: block;
    font-size: clamp(22px, 2vw, 34px);
}

.queue-now {
    border-color: rgba(52, 211, 153, .7);
}

.queue-next {
    border-color: rgba(251, 191, 36, .7);
}

.queue-number-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    margin-top: 12px;
}

.queue-number-card {
    padding: 22px;
}

.queue-number-card strong {
    display: block;
    font-size: clamp(34px, 4vw, 58px);
}

.queue-number-card span,
.queue-number-card small {
    color: #cbd5e1;
    display: block;
    font-size: 18px;
}

.queue-number-card .urgent-text {
    color: #fca5a5;
    font-weight: 800;
}

.queue-empty {
    opacity: .72;
}

.queue-display-footer {
    margin-top: auto;
    text-align: center;
}

@media (max-width: 900px) {
    .queue-display {
        padding: 20px;
    }

    .queue-display-header,
    .queue-hero {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }
}
