/* ================================================================
   University of Sri Jayewardenepura Medical Center Dashboard
   Design System: IBM Carbon / OpenMRS 3 (Function over Flash)
   Palette: Gray neutrals + Blue 60 (#0F62FE) as sole action color
   Grid: 8-point base, 4-point micro
   Radius: 0px containers, 2px micro, 4px interactive
================================================================ */

/* ── Design Tokens (Carbon-aligned) ── */
:root {
    /* Action — single blue family */
    --c-interactive:        #0F62FE;
    --c-interactive-hover:  #0043CE;
    --c-interactive-active: #002D9C;
    --c-focus:              #0F62FE;

    /* Backgrounds (layered grays for depth) */
    --c-bg-base:        #F4F4F4;   /* Gray 10 — page body */
    --c-bg-surface:     #FFFFFF;   /* White  — cards, panels */
    --c-bg-elevated:    #F4F4F4;   /* Gray 10 — input fields, elevated tiles */
    --c-bg-hover:       #E8E8E8;   /* Gray 20 hover */

    /* Sidebar (light shell) */
    --c-sidebar-bg:         #FFFFFF;   /* White */
    --c-sidebar-hover:      #F4F4F4;   /* Gray 10 */
    --c-sidebar-active-bg:  #EDF5FF;   /* Blue 10 (light blue tint) */
    --c-sidebar-text:       #525252;   /* Gray 70 */
    --c-sidebar-text-muted: #8D8D8D;   /* Gray 50 */
    --c-sidebar-active-indicator: #0F62FE; /* Blue 60 — 4px left border */
    --c-sidebar-w: 256px;

    /* Borders */
    --c-border:        #E0E0E0;   /* Gray 20 */
    --c-border-strong: #C6C6C6;   /* Gray 30 */

    /* Typography */
    --c-text-primary:   #161616;  /* Gray 100 */
    --c-text-secondary: #525252;  /* Gray 70 */
    --c-text-muted:     #8D8D8D;  /* Gray 50 */
    --c-text-on-dark:   #FFFFFF;
    --c-text-link:      #0F62FE;

    /* Semantic */
    --c-success:  #24A148;   /* Green 50 */
    --c-warning:  #F1C21B;   /* Yellow 30 */
    --c-error:    #DA1E28;   /* Red 60 */
    --c-info:     #0043CE;   /* Blue 70 */

    /* Radius (sharp/corporate) */
    --r-0: 0px;
    --r-xs: 2px;
    --r-sm: 4px;
    --r-md: 8px;   /* floating elements only */

    /* Topbar */
    --topbar-h: 56px;

    /* Elevation — no colored shadows, just neutral */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.08);
    --shadow-sm: 0 2px 6px rgba(0,0,0,0.10);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);

    /* Transition */
    --t: 0.15s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'IBM Plex Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--c-bg-base);
    color: var(--c-text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ================================================================
   SIDEBAR — Dark shell (Carbon pattern)
================================================================ */
.sidebar {
    width: var(--c-sidebar-w);
    min-height: 100vh;
    background: var(--c-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width var(--t);
    border-right: 1px solid var(--c-border);
}

.sidebar.collapsed { width: 48px; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--c-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--c-interactive);
    border-radius: var(--r-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-icon svg { width: 16px; height: 16px; color: white; }

.logo-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity var(--t), width var(--t);
}

.logo-name {
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--c-text-primary);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.logo-sub {
    font-size: 0.67rem;
    color: var(--c-text-muted);
    white-space: nowrap;
}

.sidebar-toggle {
    position: absolute;
    right: -12px;
    top: 28px;
    transform: translateY(-50%);
    background: #ffffff;
    border: 1px solid var(--c-border-strong);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xs);
    color: var(--c-text-secondary);
    cursor: pointer;
    z-index: 110;
    transition: transform var(--t), background var(--t);
    padding: 0;
}

.sidebar-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform var(--t);
}

.sidebar-toggle:hover {
    background: var(--c-bg-base);
    color: var(--c-text-primary);
    transform: translateY(-50%) scale(1.05);
}

/* By default, it's expanded, so chevron points left */
.sidebar:not(.collapsed) #sidebarToggle svg {
    transform: rotate(180deg);
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--c-sidebar-text-muted);
    padding: 16px 16px 8px;
    white-space: nowrap;
    transition: opacity var(--t);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--c-sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: all var(--t);
    position: relative;
    white-space: nowrap;
    border-left: 4px solid transparent;
}

.nav-item:hover {
    background: var(--c-sidebar-hover);
    color: var(--c-text-primary);
}

.nav-item.active {
    background: var(--c-sidebar-active-bg);
    color: var(--c-interactive);
    font-weight: 600;
    border-left-color: var(--c-sidebar-active-indicator);
}

.nav-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-icon svg { width: 16px; height: 16px; }
.nav-label { flex: 1; transition: opacity var(--t); }

.nav-badge {
    background: rgba(15,98,254,0.1);
    color: var(--c-interactive);
    font-size: 0.66rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--r-xs);
    transition: opacity var(--t);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 8px 0;
    border-top: 1px solid var(--c-border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    overflow: hidden;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--c-interactive);
    border-radius: var(--r-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name  { font-size: 0.8rem; font-weight: 600; color: var(--c-text-primary); white-space: nowrap; }
.user-role  { font-size: 0.67rem; color: var(--c-sidebar-text-muted); white-space: nowrap; }

/* Collapsed state */
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-info { display: none !important; }

.sidebar.collapsed .sidebar-header {
    padding: 0;
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    gap: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
}

.sidebar.collapsed .user-avatar {
    display: none;
}

.sidebar.collapsed .sidebar-user {
    padding: 8px 0;
    justify-content: center;
}

.sidebar.collapsed .user-logout {
    margin-left: 0 !important;
}

.sidebar.collapsed .user-logout button {
    width: 32px;
    height: 32px;
    border-radius: var(--r-xs);
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-secondary);
    transition: all var(--t);
}

.sidebar.collapsed .user-logout button:hover {
    border-color: var(--c-error);
    color: var(--c-error);
    background: rgba(218,30,40,0.06);
}

/* ================================================================
   MAIN CONTENT
================================================================ */
.main-content {
    margin-left: var(--c-sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--t);
}

.main-content.expanded { margin-left: 48px; }

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h);
    background: var(--c-bg-surface);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--c-text-primary);
}

.breadcrumb {
    font-size: 0.72rem;
    color: var(--c-text-muted);
    margin-top: 1px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-time {
    font-size: 0.78rem;
    color: var(--c-text-secondary);
    font-variant-numeric: tabular-nums;
    font-weight: 400;
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xs);
    padding: 4px 10px;
}

.topbar-badge {
    width: 32px;
    height: 32px;
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-secondary);
    cursor: pointer;
    transition: all var(--t);
}

.topbar-badge:hover {
    border-color: var(--c-interactive);
    color: var(--c-interactive);
    background: rgba(15,98,254,0.06);
}

/* ── Page Content ── */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ================================================================
   STATS ROW
================================================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin-bottom: 24px;
    background: var(--c-border);
    border: 1px solid var(--c-border);
}

@media (max-width: 900px) { .stats-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px) { .stats-row { grid-template-columns: 1fr; } }

.stat-card {
    background: var(--c-bg-surface);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: background var(--t);
}

.stat-card:hover { background: var(--c-bg-elevated); }

.stat-icon {
    width: 40px;
    height: 40px;
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 18px; height: 18px; color: var(--c-interactive); }

/* Semantic variants — use border-left for color identity */
.stat-icon--blue   { border-left: 3px solid var(--c-interactive); }
.stat-icon--green  { border-left: 3px solid var(--c-success); }
.stat-icon--orange { border-left: 3px solid #FF832B; }
.stat-icon--teal   { border-left: 3px solid #009D9A; }

.stat-body { display: flex; flex-direction: column; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 300;
    color: var(--c-text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--c-text-secondary);
    margin-top: 4px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ================================================================
   CARD / PANEL
================================================================ */
.glass-card {
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-0);
}

.panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text-primary);
    width: 100%;
}

.panel-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--c-interactive);
}

.panel-icon svg { width: 16px; height: 16px; }
.panel-icon--violet  { color: var(--c-interactive); }
.panel-icon--emerald { color: var(--c-success); }

.panel-body { padding: 24px; }

/* ── Dual Panel ── */
.dual-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.dual-panel > * {
    min-width: 0;
}

@media (max-width: 1100px) { .dual-panel { grid-template-columns: 1fr; } }

/* ================================================================
   SEARCH
================================================================ */
.search-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--c-text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 40px;
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border-strong);
    border-bottom: 2px solid var(--c-border-strong);
    border-radius: var(--r-0);
    color: var(--c-text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all var(--t);
    outline: none;
}

.search-input::placeholder { color: var(--c-text-muted); }

.search-input:focus {
    border-bottom-color: var(--c-interactive);
    background: var(--c-bg-surface);
    outline: 2px solid var(--c-focus);
    outline-offset: -2px;
}

.search-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
}

.search-spinner.active { display: flex; }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-interactive);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Search Results Dropdown */
.search-results {
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border-strong);
    border-top: none;
    border-radius: var(--r-0);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    max-height: 300px;
    overflow-y: auto;
    position: relative;
    z-index: 20;
}

.search-results.hidden { display: none; }

.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--t);
    border-bottom: 1px solid var(--c-border);
}

.result-item:last-child { border-bottom: none; }

.result-item:hover {
    background: rgba(15,98,254,0.06);
}

.result-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--r-xs);
    background: var(--c-interactive);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.result-info { flex: 1; min-width: 0; }

.result-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--c-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    font-size: 0.72rem;
    color: var(--c-text-muted);
    margin-top: 1px;
}

.result-hin {
    font-size: 0.69rem;
    font-weight: 600;
    color: var(--c-interactive);
    white-space: nowrap;
    background: rgba(15,98,254,0.08);
    padding: 2px 8px;
    border-radius: var(--r-xs);
}

.no-results {
    padding: 20px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 0.84rem;
}

/* ================================================================
   STUDENT PROFILE CARD
================================================================ */
.student-profile {
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-interactive);
    overflow: hidden;
    animation: slideIn 0.15s ease;
}

.student-profile.hidden { display: none; }

@keyframes slideIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.profile-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: rgba(15,98,254,0.04);
    border-bottom: 1px solid var(--c-border);
    position: relative;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--r-xs);
    background: var(--c-interactive);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.profile-meta { flex: 1; min-width: 0; }

.profile-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--c-text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-hin {
    font-size: 0.72rem;
    color: var(--c-interactive);
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.profile-badges { display: flex; gap: 4px; flex-wrap: wrap; }

.badge {
    font-size: 0.66rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--r-xs);
    background: rgba(15,98,254,0.1);
    color: var(--c-interactive);
    border: 1px solid rgba(15,98,254,0.2);
}

.badge--green {
    background: rgba(36,161,72,0.08);
    color: var(--c-success);
    border-color: rgba(36,161,72,0.2);
}

.btn-close-profile {
    background: transparent;
    border: 1px solid var(--c-border);
    color: var(--c-text-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all var(--t);
    flex-shrink: 0;
    border-radius: var(--r-xs);
}

.btn-close-profile svg { width: 12px; height: 12px; }

.btn-close-profile:hover {
    background: rgba(218,30,40,0.08);
    border-color: var(--c-error);
    color: var(--c-error);
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.profile-field {
    padding: 12px 16px;
    border-bottom: 1px solid var(--c-border);
    border-right: 1px solid var(--c-border);
}

.profile-field:nth-child(even) { border-right: none; }
.profile-field--full { grid-column: 1 / -1; border-right: none; }
.profile-field:last-child, .profile-field:nth-last-child(-n+2):not(.profile-field--full) { border-bottom: none; }

.field-label {
    display: block;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-muted);
    margin-bottom: 2px;
}

.field-value {
    display: block;
    font-size: 0.84rem;
    color: var(--c-text-primary);
    font-weight: 400;
    word-break: break-all;
}

/* Search Empty State */
.search-empty {
    text-align: center;
    padding: 32px 20px;
    color: var(--c-text-muted);
}

.empty-icon {
    width: 48px;
    height: 48px;
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.empty-icon svg { width: 22px; height: 22px; }
.search-empty p { font-size: 0.84rem; line-height: 1.5; }

/* ================================================================
   FORMS
================================================================ */
.form-section-title {
    font-size: 0.69rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-secondary);
    margin: 16px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--c-border);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-group {
    flex: 1;
    margin-bottom: 16px;
}

.form-group--sm { flex: 0 0 96px; }
.form-group--lg { flex: 2; }
.form-group--full { flex: 1 1 100%; }

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--c-text-secondary);
    margin-bottom: 6px;
}

.req { color: var(--c-error); }

.form-control {
    width: 100%;
    padding: 10px 12px;
    background: var(--c-bg-elevated);
    border: none;
    border-bottom: 1px solid var(--c-border-strong);
    border-radius: var(--r-0);
    color: var(--c-text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    transition: all var(--t);
    outline: none;
    appearance: none;
}

.form-control::placeholder { color: var(--c-text-muted); }

.form-control:focus {
    border-bottom-color: var(--c-interactive);
    outline: 2px solid var(--c-interactive);
    outline-offset: -2px;
    background: var(--c-bg-surface);
}

.form-control:hover:not(:focus) { border-bottom-color: var(--c-border-strong); }

.form-control.is-invalid {
    border-bottom-color: var(--c-error);
    outline: 2px solid var(--c-error);
    outline-offset: -2px;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238D8D8D' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    padding-right: 32px;
    cursor: pointer;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-error {
    display: block;
    font-size: 0.69rem;
    color: var(--c-error);
    margin-top: 4px;
    min-height: 14px;
    font-weight: 400;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--c-border);
    margin-top: 8px;
}

/* ================================================================
   BUTTONS
================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--t);
    border: none;
    outline: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus {
    outline: 2px solid var(--c-focus);
    outline-offset: 2px;
}

/* Carbon Primary = Blue 60 */
.btn--primary {
    background: var(--c-interactive);
    color: white;
}
 
.btn--primary:hover { background: var(--c-interactive-hover); }
.btn--primary:active { background: var(--c-interactive-active); }
 
.btn--primary:disabled {
    background: var(--c-bg-elevated);
    color: var(--c-text-muted);
    cursor: not-allowed;
    border: 1px solid var(--c-border);
}

/* Success Button = Green 50 */
.btn--success {
    background: var(--c-success);
    color: white;
}
.btn--success:hover {
    background: #1e873c;
}
.btn--success:active {
    background: #197032;
}

/* Ghost button */
.btn--ghost {
    background: transparent;
    border: 1px solid var(--c-border-strong);
    color: var(--c-text-secondary);
}

.btn--ghost:hover {
    background: var(--c-bg-elevated);
    border-color: var(--c-text-secondary);
    color: var(--c-text-primary);
}

/* ================================================================
   ALERTS
================================================================ */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    margin: 0 24px 0;
    font-size: 0.875rem;
    animation: slideDown 0.2s ease;
    border-left: 4px solid transparent;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: #DEFBE6;
    border-left-color: var(--c-success);
    color: #0E6027;
}

.alert-error {
    background: #FFF1F1;
    border-left-color: var(--c-error);
    color: #A2191F;
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.6;
    padding: 0;
    transition: opacity var(--t);
}

.alert-close:hover { opacity: 1; }

/* ================================================================
   TOAST
================================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-success);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-md);
    z-index: 999;
    transform: translateY(12px);
    opacity: 0;
    transition: all 0.22s ease;
    pointer-events: none;
    min-width: 240px;
}

.toast.show { transform: translateY(0); opacity: 1; }

.toast-icon {
    width: 24px;
    height: 24px;
    background: var(--c-success);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.toast.toast--error {
    border-left: 4px solid var(--c-error);
}
.toast.toast--error .toast-icon {
    background: var(--c-error);
}

.toast-message {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--c-text-primary);
}

/* ── Btn Icon ── */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t);
    border-radius: var(--r-xs);
    padding: 4px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-strong); }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-muted); }

/* ================================================================
   OPD — Selected Patient Card
================================================================ */
.selected-patient {
    background: var(--c-bg-surface);
    border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-interactive);
    overflow: hidden;
    animation: slideIn 0.15s ease;
}

.selected-patient.hidden { display: none; }

.selected-patient-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--c-border);
}

.sel-avatar {
    width: 40px;
    height: 40px;
    background: var(--c-interactive);
    border-radius: var(--r-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.93rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.sel-info { flex: 1; min-width: 0; }

.sel-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--c-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sel-meta {
    display: block;
    font-size: 0.72rem;
    color: var(--c-interactive);
    font-weight: 400;
    margin-top: 2px;
}

.sel-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.sel-detail {
    padding: 10px 16px;
    border-right: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sel-detail:nth-child(even) { border-right: none; }
.sel-detail:nth-last-child(-n+2) { border-bottom: none; }

.sd-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-muted);
}

.sd-val {
    font-size: 0.84rem;
    font-weight: 400;
    color: var(--c-text-primary);
}

/* ================================================================
   OPD — Table
================================================================ */
.opd-table-wrap {
    overflow-x: auto;
    margin-top: 16px;
    border: 1px solid var(--c-border);
}

.opd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 700px;
}

.opd-table thead tr {
    background: var(--c-bg-elevated);
    border-bottom: 1px solid var(--c-border-strong);
}

.opd-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.69rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--c-text-secondary);
    white-space: nowrap;
}

.opd-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
    color: var(--c-text-primary);
}

.opd-table tbody tr:last-child td { border-bottom: none; }
.opd-table tbody tr:hover { background: rgba(15,98,254,0.04); }
.queue-item.active-queue-item { background: rgba(15,98,254,0.08) !important; }

.opd-id {
    font-size: 0.72rem;
    color: var(--c-text-muted);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

.tbl-patient { display: flex; align-items: center; gap: 10px; }

.tbl-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--r-xs);
    background: var(--c-interactive);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.69rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.tbl-name { font-size: 0.875rem; font-weight: 400; color: var(--c-text-primary); }
.tbl-hin  { font-size: 0.69rem; color: var(--c-interactive); font-weight: 400; margin-top: 1px; }

.opd-complaint { font-weight: 400; color: var(--c-text-primary); max-width: 200px; }
.opd-remarks   { color: var(--c-text-secondary); max-width: 160px; }
.opd-doctor    { color: var(--c-text-secondary); font-weight: 400; white-space: nowrap; }
.opd-date      { color: var(--c-text-muted); white-space: nowrap; font-size: 0.78rem; }

/* New row highlight */
.opd-table tbody tr.new-row {
    background: #DEFBE6;
    animation: rowPop 1s ease forwards;
}

@keyframes rowPop {
    0%   { background: #A7F0BA; }
    100% { background: transparent; }
}

/* ================================================================
   OPD — Tabs (Carbon content switcher style)
================================================================ */
.opd-tabs {
    display: flex;
    background: var(--c-bg-elevated);
    border-bottom: 1px solid var(--c-border);
}

.opd-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--c-text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--t);
    white-space: nowrap;
}

.opd-tab:hover {
    color: var(--c-text-primary);
    background: var(--c-bg-hover);
}

.opd-tab.active {
    color: var(--c-interactive);
    border-bottom-color: var(--c-interactive);
    background: var(--c-bg-surface);
    font-weight: 600;
}

.opd-tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.opd-pane { padding: 24px; }
.opd-pane.hidden { display: none; }

/* OPD Form Grid */
.opd-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
    margin-bottom: 8px;
}

@media (max-width: 700px) {
    .opd-form-grid { grid-template-columns: 1fr; }
    .opd-form-grid > * { grid-column: 1 !important; }
}

/* ================================================================
   STATUS & PRIORITY TAGS (Carbon tag style — sharp, no pill)
================================================================ */
.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--r-xs);
    font-size: 0.69rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.status-pending   { background: #FCF4D6; color: #8E6A00; }
.status-dispensed { background: #DEFBE6; color: #044317; }
.status-cancelled { background: #FFF1F1; color: #A2191F; }
.status-draft     { background: var(--c-bg-elevated); color: var(--c-text-muted); }

.priority-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--r-xs);
    font-size: 0.69rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.priority-routine { background: #EDF5FF; color: #0043CE; }
.priority-urgent  { background: #FFF8E1; color: #8E6A00; }
.priority-stat    { background: #FFF1F1; color: #A2191F; }

/* ================================================================
   UTILITY
================================================================ */
.hidden { display: none !important; }
