/* ═══════════════════════════════════════════════
   OpenMRS Modern — Design System
   ═══════════════════════════════════════════════ */

/* ── Skip-to-content link (accessibility) ── */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    z-index: 1000;
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
    transition: top 200ms;
}
.skip-link:focus {
    top: 0;
}

:root {
    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #fafbfe;
    --border: #dbe4f0;
    --border-subtle: #eaeef6;
    --text: #0d1b3e;
    --text-secondary: #4a5578;
    --text-muted: #6b7a99;
    --accent: #4f6ef7;
    --accent-hover: #3b5ce5;
    --accent-subtle: rgba(79,110,247,0.08);
    --teal: #00b4d8;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 2px 8px rgba(13,27,62,0.04);
    --shadow-md: 0 8px 24px rgba(13,27,62,0.08);
}
* { margin:0; padding:0; box-sizing:border-box }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
h1,h2,h3,h4 { font-family: 'Sora', 'Inter', sans-serif; letter-spacing: -0.01em }

/* ── Login view ── */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-image:
        radial-gradient(ellipse at 30% 10%, rgba(79,110,247,0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 70% 90%, rgba(0,180,216,0.04) 0%, transparent 50%);
}
.login-card {
    max-width: 420px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow-md);
}
.brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.brand-dot {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--teal));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: 16px;
}
.brand-text { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px }
.login-card h2 { font-size: 22px; margin-top: 20px; margin-bottom: 6px }
.login-card .subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px }
.field { margin-bottom: 16px }
.field label { display:block; font-size:12px; font-weight:600; margin-bottom:6px; color:var(--text-secondary); text-transform:uppercase; letter-spacing:0.04em }
.field input, .field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface-2);
    outline: none;
    transition: border-color 180ms;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle) }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 160ms;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--teal));
    color: white;
    box-shadow: 0 4px 14px rgba(79,110,247,0.25);
}
.btn-primary.full-width { width: 100% }
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px) }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border) }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--accent) }
.btn-danger { background: var(--red); color: white; border-color: var(--red) }
.btn-danger:hover { filter: brightness(1.1) }
.btn-sm { padding: 7px 12px; font-size: 12.5px }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none }
.hint { font-size:11.5px; color:var(--text-muted); margin-top:14px; text-align:center; padding:10px 12px; background:var(--accent-subtle); border-radius:var(--radius-sm) }
.hint strong { color: var(--accent); font-family: 'JetBrains Mono', monospace }
.error-msg { color: var(--red); font-size: 13px; margin-top: 12px; text-align: center }

/* ── App shell ── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column }
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}
.app-header .brand-mark { margin: 0; cursor: pointer }
.app-nav { display: flex; gap: 2px; flex: 1 }
.app-nav a {
    padding: 6px 12px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 160ms;
    cursor: pointer;
}
.app-nav a:hover { background: var(--accent-subtle); color: var(--accent) }
.app-nav a.active { background: var(--accent-subtle); color: var(--accent); font-weight: 600 }
.app-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-secondary) }
.app-user strong { color: var(--text) }

.app-main { flex: 1; padding: 18px; max-width: 1400px; margin: 0 auto; width: 100% }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; gap: 10px }
.page-head h1 { font-size: 20px; margin-bottom: 2px }
.page-head .crumb { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}
.card h3 { font-size: 14px; margin-bottom: 8px }
.card-compact { padding: 16px 20px }

/* ── Search bar ── */
.search-bar { display: flex; gap: 10px; margin-bottom: 20px }
.search-bar input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    outline: none;
}
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle) }

/* ── Table ── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px }
.tbl th { text-align: left; padding: 6px 10px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border) }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border-subtle) }
.tbl { line-height: 1.3 }
.tbl tr { transition: background 120ms }
.tbl tr.clickable:hover td { background: var(--accent-subtle); cursor: pointer }
.tbl .muted { color: var(--text-muted); font-size: 12px }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 600 }
.badge-green { background: rgba(34,197,94,0.1); color: var(--green) }
.badge-orange { background: rgba(245,158,11,0.1); color: var(--orange) }
.badge-red { background: rgba(239,68,68,0.1); color: var(--red) }
.badge-blue { background: var(--accent-subtle); color: var(--accent) }
.badge-neutral { background: #eef0f8; color: var(--text-muted) }

/* ── Patient detail ── */
.patient-hero {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-subtle), rgba(0,180,216,0.04));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.patient-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--teal));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Sora', sans-serif;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}
.patient-meta { flex: 1; min-width: 200px }
.patient-meta h2 { font-size: 20px; margin-bottom: 4px }
.patient-meta .facts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); margin-top: 4px }
.patient-meta .facts span { display: inline-flex; align-items: center; gap: 6px }

/* ── Active visit pulse ── */
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.5 } }
.badge-active-visit { background: rgba(34,197,94,0.15); color: var(--green); animation: pulse 2s infinite }

.tabs-row { display: flex; gap: 2px; margin-bottom: 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap }
.tabs-row button {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 160ms;
}
.tabs-row button:hover { color: var(--text) }
.tabs-row button.active { color: var(--accent); border-bottom-color: var(--accent) }

.tab-content { display: none }
.tab-content.active { display: block }

.empty-state { padding: 20px 14px; text-align: center; color: var(--text-muted); font-size: 13px }

/* ── Modal ── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13,27,62,0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-backdrop.open { display: flex }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 60px rgba(13,27,62,0.3);
}
.modal h3 { font-size: 20px; margin-bottom: 20px }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px }

/* ── Two-column grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
/* grid-2 collapses to 1-col at mobile, handled in 768px block below */

/* ── Three-column tile grid ── */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px }
@media (max-width: 1024px) { .grid-3 { grid-template-columns: repeat(2, 1fr); gap: 14px } }
@media (max-width: 768px) { .grid-3 { grid-template-columns: repeat(2, 1fr); gap: 10px } }

/* ── Small JSON code block ── */
.code {
    background: #0d1b3e;
    color: #dbe8ff;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow-y: auto;
}

/* ── Stat chips ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat .lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px }
.stat .val { font-size: 24px; font-weight: 700; font-family: 'Sora', sans-serif; color: var(--text) }
.stat .val.green { color: var(--green) }
.stat .val.orange { color: var(--orange) }

.loading { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px }

/* ── Home tiles ── */
.home-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 200ms;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}
.home-tile:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.home-tile .tile-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--accent-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
}
.home-tile .tile-icon svg { width: 24px; height: 24px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round }
.home-tile .tile-title { font-size: 14px; font-weight: 600; color: var(--text) }
.home-tile .tile-sub { font-size: 12px; color: var(--text-muted) }

/* ── Action toolbar ── */
.action-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px }
.action-toolbar .btn { font-size: 12.5px; padding: 6px 12px }

/* ── Widget card overrides ── */
.widget-card { min-height: 180px }
.widget-card h3 { display: flex; align-items: center; gap: 8px }
.widget-card h3 svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 2 }

/* ── Sparkline / Vitals grid ── */
.vital-row { display: grid; grid-template-columns: 180px 60px 1fr; align-items: center; gap: 8px; padding: 6px 0 }
.vital-label { font-size: 13px; color: var(--text-secondary) }
.vital-value { font-size: 18px; font-weight: 700; text-align: right }
.vital-spark { }
.sparkline-container { display: flex; align-items: center; gap: 12px; padding: 6px 0 }
.sparkline-label { font-size: 12px; color: var(--text-secondary); min-width: 80px }
.sparkline-value { font-size: 14px; font-weight: 600; min-width: 60px; text-align: right }

/* ── Toast notification ── */
.toast-container { position: fixed; top: 58px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px }
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toastIn 300ms ease-out;
    max-width: 380px;
}
.toast-success { background: var(--green); color: white }
.toast-error { background: var(--red); color: white }
.toast-info { background: var(--accent); color: white }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: translateX(0) } }

/* ── Footer ── */
.footer {
    padding: 18px 28px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}
.footer a { color: var(--accent); text-decoration: none }
.footer a:hover { text-decoration: underline }

/* ── Utility ── */
.mt-12 { margin-top: 12px }
.mb-12 { margin-bottom: 12px }
.hidden { display: none !important }
.flex { display: flex }
.gap-8 { gap: 8px }
.gap-10 { gap: 10px }
.flex-between { display: flex; justify-content: space-between; align-items: center }

/* ═══════════════════════════════════════════════
   Responsive — tablet (max-width: 1024px)
   ═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .app-main { padding: 20px }

    /* Nav: horizontal scroll instead of wrapping */
    .app-nav { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch }
    .app-nav a { white-space: nowrap; font-size: 12.5px; padding: 7px 11px }

    /* Grid: already 2-col via grid-3 rule above */
    .grid-2 { gap: 14px }

    /* Action toolbar: wrap into rows, slightly smaller */
    .action-toolbar .btn { font-size: 11.5px; padding: 6px 10px }

    /* Patient hero: tighter */
    .patient-hero { padding: 22px; gap: 18px }
    .patient-meta h2 { font-size: 20px }

    /* Tabs: scroll horizontally */
    .tabs-row { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch }
    .tabs-row button { white-space: nowrap; flex-shrink: 0 }
}

/* ═══════════════════════════════════════════════
   Responsive — mobile (max-width: 768px)
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .app-main { padding: 10px }

    /* Header: compact — reduced height for density */
    .app-header { padding: 0 10px; height: 44px; gap: 8px }
    .brand-text { font-size: 13px }
    .brand-dot { width: 26px; height: 26px; font-size: 12px; border-radius: 6px }
    .brand-mark img { height: 22px !important }

    /* Nav: horizontal scroll with smaller text */
    .app-nav { overflow-x: auto; flex-wrap: nowrap; gap: 0; -webkit-overflow-scrolling: touch }
    .app-nav a { white-space: nowrap; font-size: 11px; padding: 5px 8px }

    /* User section: compact */
    .app-user { font-size: 10.5px; gap: 4px; flex-shrink: 0 }
    .app-user span { display: none }
    .app-user .btn { font-size: 10.5px; padding: 4px 7px }

    /* Page head */
    .page-head { flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 10px }
    .page-head h1 { font-size: 18px; margin-bottom: 2px }
    .page-head .crumb { font-size: 11px; margin-bottom: 2px }

    /* Home tiles: 2 columns, COMPACT — all tiles visible without scrolling */
    .home-tile { padding: 12px; gap: 4px; border-radius: 10px }
    .home-tile .tile-icon { width: 28px; height: 28px; border-radius: 6px }
    .home-tile .tile-icon svg { width: 15px; height: 15px }
    .home-tile .tile-title { font-size: 13px }
    .home-tile .tile-sub { display: none }

    /* Patient hero: horizontal row, very compact */
    .patient-hero { flex-direction: row; text-align: left; padding: 10px 12px; gap: 10px; align-items: center; margin-bottom: 10px }
    .patient-avatar { width: 36px; height: 36px; font-size: 14px; flex-shrink: 0 }
    .patient-meta h2 { font-size: 15px; margin-bottom: 2px; line-height: 1.2 }
    .patient-meta .facts { font-size: 10.5px; gap: 6px; margin-top: 2px; flex-wrap: wrap }
    .patient-meta { min-width: auto; flex: 1 }
    .patient-hero > .btn { display: none }

    /* Action toolbar: icon-density row */
    .action-toolbar { gap: 4px; margin-bottom: 10px }
    .action-toolbar .btn { font-size: 10.5px; padding: 4px 7px }

    /* Widget grid: 1 column, compact */
    .grid-2 { grid-template-columns: 1fr; gap: 8px }
    .card { padding: 10px; margin-bottom: 8px; border-radius: 10px }
    .widget-card { min-height: auto }
    .widget-card h3 { font-size: 13px; margin-bottom: 5px }
    .widget-card .widget-body { font-size: 12px }

    /* Tables: horizontal scroll, DENSE text */
    .tbl { font-size: 11.5px }
    .widget-card .tbl,
    .card .tbl { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch }
    .tbl th { padding: 6px 6px; font-size: 9.5px }
    .tbl td { padding: 6px 6px }

    /* Vitals widget: compact */
    .vital-row { grid-template-columns: 1fr 50px 1fr; gap: 4px; padding: 3px 0 }
    .vital-label { font-size: 11.5px }
    .vital-value { font-size: 15px }

    /* Tabs: horizontal scroll */
    .tabs-row { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; margin-bottom: 10px }
    .tabs-row button { white-space: nowrap; flex-shrink: 0; font-size: 11.5px; padding: 6px 10px }

    /* Forms: full-width, reduced vertical spacing */
    .field { margin-bottom: 8px }
    .field label { margin-bottom: 3px; font-size: 11px }
    .field input, .field select { padding: 8px 10px; font-size: 13px }

    /* Modal: full-width-ish */
    .modal { padding: 16px; max-width: 95vw }
    .modal h3 { font-size: 16px; margin-bottom: 12px }
    .modal-actions { flex-wrap: wrap; gap: 6px }

    /* Search bar */
    .search-bar { flex-direction: column; margin-bottom: 10px }
    .search-bar input { font-size: 13px; padding: 8px 10px }

    /* Stats row */
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 10px }
    .stat { padding: 10px 12px }
    .stat .val { font-size: 18px }
    .stat .lbl { font-size: 10px }

    /* Login: tighter */
    .login-card { padding: 28px 22px }
    .login-card h2 { font-size: 19px }

    /* Footer */
    .footer { padding: 10px; font-size: 10.5px }

    /* Toast: full width */
    .toast-container { right: 10px; left: 10px; top: 50px }
    .toast { max-width: 100%; font-size: 12px; padding: 10px 14px }

    /* Empty state: less padding */
    .empty-state { padding: 20px 10px; font-size: 12px }
    .loading { padding: 12px; font-size: 12px }

    /* Badges: slightly smaller */
    .badge { padding: 2px 7px; font-size: 10px }
}

/* ═══════════════════════════════════════════════
   Responsive — small mobile (max-width: 480px)
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
    .app-main { padding: 6px }
    .app-header { padding: 0 6px; height: 40px }

    /* Hide brand text on very small screens, keep logo */
    .app-header .brand-text { display: none }
    .brand-dot { width: 24px; height: 24px; font-size: 11px }

    /* Nav: even more compact */
    .app-nav a { font-size: 10.5px; padding: 4px 6px }

    /* Home tiles: keep 2 columns, ultra-compact */
    .home-tile { padding: 10px 8px; gap: 3px; border-radius: 8px }
    .home-tile .tile-icon { width: 24px; height: 24px; border-radius: 5px }
    .home-tile .tile-icon svg { width: 13px; height: 13px }
    .home-tile .tile-title { font-size: 12px }
    .home-tile .tile-sub { display: none }

    /* Patient hero: ultra-compact horizontal */
    .patient-hero { padding: 8px 10px; gap: 8px }
    .patient-avatar { width: 32px; height: 32px; font-size: 12px }
    .patient-meta h2 { font-size: 14px; margin-bottom: 1px }
    .patient-meta .facts { font-size: 10px; gap: 4px }

    /* Buttons: very compact */
    .action-toolbar { gap: 3px }
    .action-toolbar .btn { font-size: 10px; padding: 3px 6px }
    .btn { font-size: 11.5px; padding: 7px 10px }
    .btn-sm { font-size: 10.5px; padding: 4px 7px }

    /* Cards */
    .card { padding: 8px; border-radius: 8px; margin-bottom: 6px }
    .widget-card h3 { font-size: 12px; margin-bottom: 4px }

    /* Tables */
    .tbl { font-size: 10.5px }
    .tbl th { font-size: 9px; padding: 4px 5px }
    .tbl td { padding: 4px 5px }

    /* Stats */
    .stats-row { grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px }
    .stat { padding: 8px }
    .stat .val { font-size: 16px }
    .stat .lbl { font-size: 9px }

    /* Page head */
    .page-head { gap: 4px; margin-bottom: 6px }
    .page-head h1 { font-size: 16px }
    .page-head .crumb { font-size: 10px }

    /* Modal */
    .modal { padding: 14px; border-radius: 10px }
    .modal h3 { font-size: 15px; margin-bottom: 10px }

    /* Login */
    .login-shell { padding: 10px }
    .login-card { padding: 20px 14px }

    /* Vitals: ultra-compact */
    .vital-row { grid-template-columns: 1fr 40px 1fr; gap: 2px; padding: 2px 0 }
    .vital-label { font-size: 10.5px }
    .vital-value { font-size: 14px }

    /* Grid gap */
    .grid-2 { gap: 6px }

    /* Badges */
    .badge { padding: 1px 5px; font-size: 9.5px }

    /* Admin actions section */
    .admin-actions-section { margin-bottom: 8px }
}

/* ── Textarea styling ── */
textarea:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-subtle) !important; outline: none }

/* ═══════════════════════════════════════════════
   Focus indicators (accessibility)
   ═══════════════════════════════════════════════ */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════
   Language switcher
   ═══════════════════════════════════════════════ */
.lang-switcher {
    appearance: none;
    -webkit-appearance: none;
    background: var(--accent-subtle);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 22px 4px 8px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234f6ef7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}
.lang-switcher:hover { border-color: var(--accent) }
.lang-switcher:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.login-lang-row { display: flex; justify-content: flex-end; margin-bottom: 8px }

/* ═══════════════════════════════════════════════
   RTL (Right-to-Left) layout support — Arabic
   ═══════════════════════════════════════════════ */
[dir="rtl"] { direction: rtl; text-align: right }
[dir="rtl"] .app-header { flex-direction: row-reverse }
[dir="rtl"] .app-nav { flex-direction: row-reverse }
[dir="rtl"] .app-user { flex-direction: row-reverse }
[dir="rtl"] .patient-hero { flex-direction: row-reverse }
[dir="rtl"] .patient-meta { text-align: right }
[dir="rtl"] .facts { direction: rtl }
[dir="rtl"] .tbl th, [dir="rtl"] .tbl td { text-align: right }
[dir="rtl"] .widget-header { flex-direction: row-reverse }
[dir="rtl"] .action-toolbar { flex-direction: row-reverse }
[dir="rtl"] .page-head { text-align: right }
[dir="rtl"] .crumb { direction: rtl }
[dir="rtl"] .grid-3, [dir="rtl"] .grid-2 { direction: rtl }
[dir="rtl"] .home-tile { text-align: right }
[dir="rtl"] .card { text-align: right }
[dir="rtl"] .search-bar input { text-align: right; direction: rtl }
[dir="rtl"] .login-card { text-align: right }
[dir="rtl"] .login-lang-row { justify-content: flex-start }
[dir="rtl"] .brand-mark { flex-direction: row-reverse }
[dir="rtl"] .admin-actions-section div[style*="display:flex"] { flex-direction: row-reverse }
[dir="rtl"] .lang-switcher {
    background-position: left 6px center;
    padding: 4px 8px 4px 22px;
}
[dir="rtl"] .modal { text-align: right }
[dir="rtl"] .footer { direction: rtl; text-align: center }

/* ═══════════════════════════════════════════════
   Dark mode (prefers-color-scheme)
   ═══════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1117;
        --surface: #1a1b2e;
        --surface-2: #222339;
        --border: #2d2e45;
        --border-subtle: #252640;
        --text: #e4e4f0;
        --text-secondary: #a0a0b8;
        --text-muted: #6b6b85;
        --accent-subtle: rgba(79,110,247,0.15);
        --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
        --shadow-md: 0 8px 24px rgba(0,0,0,0.3);
    }
    .code { background: #0a0c14; }
    .badge-neutral { background: #2d2e45; color: var(--text-muted); }
    .hint { background: rgba(79,110,247,0.12); }
}
