/* ═══════════════════════════════════════════════
   OpenMRS Modern — Legacy-Layout-Matching Design
   Same information architecture, modern facelift
   ═══════════════════════════════════════════════ */

/* ── 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: #f0f0f0;
    --surface: #ffffff;
    --surface-2: #fafbfe;
    --border: #dbe4f0;
    --border-subtle: #eaeef6;
    --text: #1b1b1b;
    --text-secondary: #4a5578;
    --text-muted: #6b7a99;
    --accent: #4f6ef7;
    --accent-hover: #3b5ce5;
    --accent-subtle: rgba(79,110,247,0.08);
    --accent-dark: #3a52b5;
    --header-bg: #3a3f54;
    --teal: #00b4d8;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --widget-header-line: var(--accent);
}
* { 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-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: 10px 12px;
    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: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 160ms;
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary.full-width { width: 100% }
.btn-primary:hover { background: var(--accent-hover) }
.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: 6px 10px; font-size: 12px }
.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 — legacy-style header
   ═══════════════════════════════════════════════ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column }

.app-header {
    background: var(--header-bg);
    padding: 0 20px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-brand-text {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #ffffff;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}
.header-user, .header-location {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #ddd;
    font-size: 13px;
    cursor: default;
}
.header-icon {
    width: 16px;
    height: 16px;
    stroke: #ccc;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -2px;
}
.caret { font-size: 10px; color: #aaa }
.header-location {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
}
.header-logout {
    background: none;
    border: none;
    color: #ddd;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
}
.header-logout:hover { color: #fff }
.header-logout .header-icon { stroke: #ddd }

/* ── Breadcrumb bar (legacy match) ── */
.breadcrumb-bar {
    background: #eee;
    border-bottom: 1px solid #ccc;
    padding: 6px 20px;
    font-size: 14px;
    color: var(--text-secondary);
}
.breadcrumb-bar a { color: var(--accent); text-decoration: none; cursor: pointer }
.breadcrumb-bar a:hover { text-decoration: underline }
.breadcrumb-sep { color: #999; margin: 0 2px }

/* ═══════════════════════════════════════════════
   Main content area — dense EMR layout
   ═══════════════════════════════════════════════ */
.app-main { flex: 1; padding: 16px 20px; max-width: 1200px; margin: 0 auto; width: 100% }

.page-head { margin-bottom: 10px }
.page-head h1 { font-size: 18px; margin-bottom: 2px; color: var(--accent) }
.page-head .crumb { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px }
.page-head .crumb a { color: var(--accent); cursor: pointer; text-decoration: none }
.page-head .crumb a:hover { text-decoration: underline }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    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: 16px }
.search-bar input {
    flex: 1;
    padding: 8px 12px;
    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: 13px }
.tbl th { text-align: left; padding: 6px 8px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); background: #f8f8f8 }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--border-subtle) }
.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) }

/* ═══════════════════════════════════════════════
   Home page — legacy tile grid
   ═══════════════════════════════════════════════ */
.home-greeting {
    color: var(--accent);
    font-size: 16px;
    margin-bottom: 16px;
    font-weight: 400;
    /* Legacy uses <h4> for greeting text */
}
.tile-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.home-tile {
    /* Legacy tiles: 166x130px, #ddd background, centered icon + text */
    width: 166px;
    min-height: 130px;
    background: linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 100%);
    border: 1px solid #d0d0d0;
    border-radius: var(--radius-md);
    padding: 20px 14px 16px;
    cursor: pointer;
    transition: all 200ms;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: 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: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.home-tile .tile-icon svg {
    width: 42px;
    height: 42px;
    stroke: #444;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.home-tile .tile-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    /* Legacy uses dark text, not accent color on tiles */
}

/* ═══════════════════════════════════════════════
   Patient Header (legacy-style)
   ═══════════════════════════════════════════════ */
/* Patient header — matches legacy's patient-header row layout */
.patient-header-legacy {
    background: #f9f9f9;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
}
.patient-header-legacy .patient-avatar {
    /* Hidden by default to match legacy which has no avatar circle */
    display: none;
}
.patient-name-block {
    flex: 1;
}
.patient-name-block h2 {
    /* Legacy uses <h1> at ~28px, bold */
    font-size: 26px;
    margin-bottom: 2px;
    color: var(--text);
    font-weight: 700;
}
.patient-name-labels {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 4px;
}
.patient-facts-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
    margin-top: 4px;
    flex-wrap: wrap;
    align-items: center;
}
.patient-facts-row .edit-link {
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    margin-left: 6px;
}
.patient-facts-row .edit-link:hover { text-decoration: underline }
.patient-id-col {
    margin-left: auto;
    text-align: right;
    font-size: 13px;
    color: var(--text-muted);
}
.patient-id-col .id-label { font-size: 11px; color: var(--text-muted); font-style: italic }
.patient-id-col .id-value { font-weight: 600; color: var(--text) }
/* Legacy labeled name: name text above, italic "Given" / "Family Name" below */
.labeled-name {
    display: inline-flex;
    flex-direction: column;
    vertical-align: bottom;
}
.labeled-name em {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
    margin-top: -2px;
}
.show-contact-btn {
    margin-top: 10px;
    font-size: 13px;
    padding: 5px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
}
.show-contact-btn:hover { border-color: var(--accent) }

/* ═══════════════════════════════════════════════
   Patient Dashboard — 3-column legacy layout
   ═══════════════════════════════════════════════ */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 250px;
    gap: 14px;
    align-items: start;
}

/* ── Widget sections (legacy info-section match) ── */
.widget-section {
    margin-bottom: 16px;
}
.widget-section-header {
    /* Legacy: icon + H3 text, with a colored top-border on the header */
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Sora', 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--accent-dark);
    padding: 6px 0 4px;
    border-top: 3px solid var(--widget-header-line);
    margin-bottom: 6px;
}
.widget-section-header svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.widget-section-header .widget-action {
    margin-left: auto;
    cursor: pointer;
    color: var(--accent);
    font-size: 16px;
    text-decoration: none;
}
.widget-section-header .widget-action:hover { color: var(--accent-hover) }
.widget-section-body {
    font-size: 13px;
    color: var(--text);
    padding: 2px 0;
}
.widget-section-body .empty-state {
    color: var(--text-muted);
    font-size: 13px;
    padding: 4px 0;
    text-align: left;
}

/* ── Right sidebar — General Actions (legacy action-section match) ── */
.actions-sidebar {
    background: var(--header-bg);
    border: 1px solid #2e3348;
    border-radius: var(--radius-sm);
    padding: 0;
}
.actions-sidebar-title {
    /* Legacy: white text on dark background, bold */
    font-family: 'Sora', 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    color: #ffffff;
}
.actions-sidebar-list {
    list-style: none;
    padding: 4px 0;
}
.actions-sidebar-list li {
    padding: 0;
}
.actions-sidebar-list li a,
.actions-sidebar-list li button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 14px;
    border: none;
    background: none;
    font-size: 13px;
    font-family: inherit;
    color: #e0e0e0;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    transition: background 120ms;
}
.actions-sidebar-list li a:hover,
.actions-sidebar-list li button:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}
.actions-sidebar-list li .action-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.actions-sidebar-list li .action-icon svg {
    width: 14px;
    height: 14px;
    stroke: #a0b0ff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── 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 }

/* ── Vitals display ── */
.vital-row { display: grid; grid-template-columns: 140px 50px 1fr; align-items: center; gap: 6px; padding: 4px 0 }
.vital-label { font-size: 13px; color: var(--text-secondary) }
.vital-value { font-size: 16px; font-weight: 700; text-align: right }
.sparkline-container { display: flex; align-items: center; gap: 12px; padding: 4px 0 }

/* ═══════════════════════════════════════════════
   Find Patient — legacy style
   ═══════════════════════════════════════════════ */
/* Find Patient — legacy layout match */
.find-patient-page h1 {
    color: var(--accent);
    font-size: 20px;
    margin-bottom: 14px;
    font-weight: 400;
    /* Legacy: green h1, normal weight */
}
.find-patient-search {
    margin-bottom: 16px;
}
.find-patient-search input {
    /* Legacy: ~75% width search bar with clear button */
    width: 75%;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    background: var(--surface);
}
.find-patient-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}
.find-patient-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}
/* Highlight most-recent patient row (legacy uses bright blue) */
.tbl tr.recent td {
    background: var(--accent-subtle);
}

/* ═══════════════════════════════════════════════
   Legacy grid helpers
   ═══════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px }

/* ── 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 }

/* ── 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: 14px 20px;
    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 }

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

/* ── 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 (used by admin views) ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    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) }

/* ── Action toolbar (used by non-dashboard views) ── */
.action-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px }
.action-toolbar .btn { font-size: 12px; padding: 6px 12px }

/* ── Widget card (used by non-dashboard views as fallback) ── */
.widget-card { min-height: 80px }
.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 }

/* ── Tabs (used by various admin/sub-views) ── */
.tabs-row { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap }
.tabs-row button {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    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 }

/* ── Patient hero (used by non-dashboard views that reference it) ── */
.patient-hero {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    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 }

/* ── Home tile legacy ── */
.home-tile .tile-sub { font-size: 12px; color: var(--text-muted); display: none }

/* ── Admin actions (collapsible, used in patient-dashboard) ── */
.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;
}

/* ═══════════════════════════════════════════════
   Responsive — tablet (max-width: 1024px)
   ═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
    .dashboard-grid .actions-sidebar {
        grid-column: 1 / -1;
    }
    .home-tile { width: 140px; min-height: 110px }
}

/* ═══════════════════════════════════════════════
   Responsive — mobile (max-width: 768px)
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    .app-main { padding: 10px }
    .app-header { padding: 0 10px; height: 42px }
    .header-brand-text { font-size: 13px }
    .header-right { gap: 10px }
    .header-user, .header-location { font-size: 11px }
    .breadcrumb-bar { padding: 4px 10px; font-size: 12px }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .home-tile { width: 140px; min-height: 110px }

    .patient-header-legacy { flex-direction: column; gap: 10px; padding: 12px }
    .patient-name-block h2 { font-size: 18px }
    .patient-id-col { margin-left: 0; text-align: left }

    .home-tile { padding: 16px 10px }
    .home-tile .tile-icon svg { width: 32px; height: 32px }
    .home-tile .tile-title { font-size: 13px }

    .grid-2 { grid-template-columns: 1fr }
    .grid-3 { grid-template-columns: 1fr }

    .find-patient-search input { width: 100% }

    .card { padding: 10px; margin-bottom: 8px }
    .tbl { font-size: 12px }
    .tbl th { font-size: 10px; padding: 5px 6px }
    .tbl td { padding: 5px 6px }

    .modal { padding: 16px; max-width: 95vw }
}

/* ═══════════════════════════════════════════════
   Responsive — small mobile (max-width: 480px)
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {
    .app-main { padding: 6px }
    .app-header { padding: 0 6px; height: 40px }
    .header-brand-text { display: none }
    .header-right { gap: 6px }
    .header-user .caret, .header-location .caret { display: none }
    .header-user span:not(.caret), .header-location span:not(.caret) { font-size: 10px }

    .home-tile { width: 120px; min-height: 100px; padding: 12px 8px; gap: 6px }
    .home-tile .tile-icon svg { width: 28px; height: 28px }
    .home-tile .tile-title { font-size: 12px }

    .btn { font-size: 11.5px; padding: 7px 10px }
    .btn-sm { font-size: 10.5px; padding: 4px 7px }

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

    .footer { padding: 10px; font-size: 10.5px }
    .toast-container { right: 10px; left: 10px; top: 50px }
    .toast { max-width: 100%; font-size: 12px; padding: 10px 14px }
}

/* ═══════════════════════════════════════════════
   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;
        --header-bg: #1a1b2e;
        --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);
    }
    .breadcrumb-bar { background: #1e1f32; border-bottom-color: #2d2e45 }
    .home-tile { background: linear-gradient(180deg, #222339, #1a1b2e); border-color: #2d2e45 }
    .actions-sidebar { background: #1a1b2e; border-color: #2d2e45 }
    .actions-sidebar-title { border-bottom-color: rgba(255,255,255,0.1) }
    .code { background: #0a0c14 }
    .badge-neutral { background: #2d2e45; color: var(--text-muted) }
    .hint { background: rgba(79,110,247,0.12) }
    .tbl th { background: #1e1f32 }
}
