  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

  :root {
    /* ── Core Palette ── */
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface2: #f7f8fa;
    --surface3: #eef0f4;
    --border: #e1e4e9;
    --border-strong: #c8cdd6;

    /* ── Brand / Accent ── */
    --accent: #9a6f0a;
    --accent2: #b8860b;
    --accent3: #d4a017;
    --accent-light: #fdf6e3;
    --accent-mid: #f5e6c0;

    /* ── Semantic Colors ── */
    --success: #0f7b3c;
    --success-light: #e6f4ec;
    --success-border: #a3d4b8;
    --danger: #b91c1c;
    --danger-light: #fef2f2;
    --danger-border: #fca5a5;
    --warn: #b45309;
    --warn-light: #fffbeb;
    --warn-border: #fcd34d;
    --info: #1d4ed8;
    --info-light: #eff6ff;
    --info-border: #93c5fd;

    /* ── Compliance Status ── */
    --status-compliant: #0f7b3c;
    --status-compliant-bg: #e6f4ec;
    --status-pending: #b45309;
    --status-pending-bg: #fffbeb;
    --status-attention: #b91c1c;
    --status-attention-bg: #fef2f2;
    --status-expiring: #c2410c;
    --status-expiring-bg: #fff7ed;
    --status-overdue: #991b1b;
    --status-overdue-bg: #fef2f2;
    --status-critical: #7f1d1d;
    --status-critical-bg: #fef2f2;

    /* ── Typography ── */
    --text: #0f1520;
    --text2: #374151;
    --text3: #6b7280;
    --text4: #9ca3af;

    /* ── Elevation ── */
    --shadow-xs: 0 1px 2px rgba(15,21,32,0.05);
    --shadow: 0 1px 3px rgba(15,21,32,0.08), 0 2px 8px rgba(15,21,32,0.04);
    --shadow-md: 0 4px 12px rgba(15,21,32,0.08), 0 2px 4px rgba(15,21,32,0.04);
    --shadow-lg: 0 8px 24px rgba(15,21,32,0.10), 0 2px 8px rgba(15,21,32,0.06);
    --shadow-xl: 0 16px 48px rgba(15,21,32,0.12), 0 4px 16px rgba(15,21,32,0.08);

    /* ── Shape ── */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* ── Layout ── */
    --sidebar: 248px;

    /* ── Transitions ── */
    --transition: 150ms cubic-bezier(0.4,0,0.2,1);
    --transition-slow: 250ms cubic-bezier(0.4,0,0.2,1);
  }

  /* ── DARK MODE ── */
  [data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface2: #1c2128;
    --surface3: #21262d;
    --border: #30363d;
    --border-strong: #484f58;
    --text: #e6edf3;
    --text2: #adbac7;
    --text3: #768390;
    --text4: #545d68;
    --accent: #d4a017;
    --accent2: #e8b923;
    --accent-light: #2d2106;
    --accent-mid: #3d2e0a;
    --success-light: #0d2818;
    --success-border: #1a4731;
    --danger-light: #2d0f0f;
    --danger-border: #6b1f1f;
    --warn-light: #2d1f06;
    --warn-border: #6b3f0a;
    --info-light: #0d1a3d;
    --info-border: #1e3a8a;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.25);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: 'Inter', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* ── SCROLLBAR ── */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text4); }

  /* ── AUTH ── */
  #auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d1117 0%, #1a1f2e 40%, #0f1a0a 70%, #1a140a 100%);
    position: relative;
    overflow: hidden;
  }
  #auth-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
      radial-gradient(ellipse 60% 50% at 20% 80%, rgba(184,134,11,0.12) 0%, transparent 60%),
      radial-gradient(ellipse 50% 40% at 80% 20%, rgba(15,123,60,0.08) 0%, transparent 60%);
    pointer-events: none;
  }
  .auth-box {
    background: rgba(255,255,255,0.98);
    border-radius: var(--radius-xl);
    padding: 48px 44px;
    width: 400px;
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.1);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255,255,255,0.2);
  }
  .auth-logo { text-align: center; margin-bottom: 32px; }
  .auth-logo .org {
    font-family: 'Inter', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
    letter-spacing: -0.02em;
  }
  .auth-logo .sub {
    font-size: 11px;
    color: var(--text3);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 4px;
    font-weight: 500;
  }
  .auth-box h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text);
    letter-spacing: -0.01em;
  }

  /* ── FIELDS & FORMS ── */
  .field { margin-bottom: 16px; }
  .field label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .field input,
  .field select,
  .field textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    line-height: 1.5;
  }
  .field input:hover,
  .field select:hover,
  .field textarea:hover {
    border-color: var(--border-strong);
  }
  .field input:focus,
  .field select:focus,
  .field textarea:focus {
    outline: none;
    border-color: var(--accent2);
    box-shadow: 0 0 0 3px rgba(184,134,11,0.12);
    background: var(--surface);
  }
  .field textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
  .field select { cursor: pointer; }

  /* ── BUTTONS ── */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    transition: all var(--transition);
    letter-spacing: -0.01em;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
  }
  .btn:active { transform: translateY(1px); }
  .btn-primary {
    background: linear-gradient(135deg, var(--accent2) 0%, var(--accent3) 100%);
    color: #fff;
    box-shadow: 0 1px 3px rgba(184,134,11,0.3), 0 1px 2px rgba(0,0,0,0.08);
  }
  .btn-primary:hover {
    background: linear-gradient(135deg, var(--accent3) 0%, #e8c040 100%);
    box-shadow: 0 4px 12px rgba(184,134,11,0.35), 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-1px);
  }
  .btn-secondary {
    background: var(--surface);
    color: var(--text2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
  }
  .btn-secondary:hover {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border-strong);
  }
  .btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger-border);
  }
  .btn-danger:hover {
    background: #fee2e2;
    border-color: var(--danger);
  }
  .btn-sm { padding: 5px 11px; font-size: 12.5px; }
  .btn-full { width: 100%; justify-content: center; }
  .auth-error {
    color: var(--danger);
    font-size: 12.5px;
    margin-top: 12px;
    display: none;
    background: var(--danger-light);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-weight: 500;
  }

  /* ── LAYOUT ── */
  #app { display: none; min-height: 100vh; }
  .layout { display: flex; min-height: 100vh; }

  /* ── SIDEBAR ── */
  .sidebar {
    width: var(--sidebar);
    background: #0d1117;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    border-right: 1px solid #21262d;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }
  .sidebar-brand {
    padding: 20px 16px 12px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e1e4e9;
  }
  .sidebar-brand .org { display: none; }
  .sidebar-brand .sub { display: none; }
  .sidebar-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    display: block;
  }
  .sidebar-portal-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #374151;
    margin-top: 6px;
    text-align: center;
    background: linear-gradient(90deg, var(--accent2), var(--accent3));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
  }
  .nav-section-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #484f58;
    padding: 10px 10px 4px;
    margin-top: 4px;
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #8b949e;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    position: relative;
  }
  .nav-item:hover {
    background: rgba(255,255,255,0.07);
    color: #e6edf3;
  }
  .nav-item.active {
    background: linear-gradient(90deg, rgba(184,134,11,0.2), rgba(184,134,11,0.08));
    color: #d4a017;
    font-weight: 600;
    border-left: 2px solid #d4a017;
    padding-left: 8px;
  }
  .nav-item.active svg { color: #d4a017; }
  .nav-item svg { flex-shrink: 0; opacity: 0.8; }
  .nav-item.active svg { opacity: 1; }
  .sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid #21262d;
    background: #0d1117;
  }
  .staff-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    border: 1px solid #21262d;
  }
  .staff-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent2), var(--accent3));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(184,134,11,0.3);
  }
  .staff-info .name { font-size: 12.5px; font-weight: 600; color: #e6edf3; }
  .staff-info .role { font-size: 10.5px; color: #545d68; margin-top: 1px; }
  .btn-logout {
    margin-top: 8px;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    color: #545d68;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition);
    font-weight: 500;
  }
  .btn-logout:hover { background: rgba(185,28,28,0.12); color: #fca5a5; }

  /* ── MAIN ── */
  .main { margin-left: var(--sidebar); flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
  .topbar {
    background: rgba(255,255,255,0.95);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 1px 0 var(--border), var(--shadow-xs);
  }
  .topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a2332;
    letter-spacing: -0.01em;
  }
  .topbar-right { display: flex; align-items: center; gap: 10px; }
  .content { padding: 24px 28px; flex: 1; min-width: 0; }

  /* ── CARDS ── */
  .card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition-slow);
  }
  .card:hover { box-shadow: var(--shadow-md); }
  .card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface2);
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .card-header h3 {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .card-body { padding: 20px; }

  /* ── STATS ── */
  .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    transition: all var(--transition-slow);
    position: relative;
    overflow: hidden;
  }
  .stat-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(184,134,11,0.2), transparent);
    opacity: 0;
    transition: opacity var(--transition);
  }
  .stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
  .stat-card:hover::after { opacity: 1; }
  .stat-card .label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
  }
  .stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin: 6px 0 3px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.1;
  }
  .stat-card .sub { font-size: 11.5px; color: var(--text3); font-weight: 400; }
  .stat-icon {
    float: right;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xs);
  }
  .stat-icon.green { background: var(--success-light); color: var(--success); }
  .stat-icon.blue { background: var(--info-light); color: var(--info); }
  .stat-icon.warn { background: var(--warn-light); color: var(--warn); }
  .stat-icon.red { background: var(--danger-light); color: var(--danger); }

  /* ── TABLE ── */
  .search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
  .search-input {
    flex: 1;
    padding: 8px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
  }
  .search-input:hover { border-color: var(--border-strong); }
  .search-input:focus {
    outline: none;
    border-color: var(--accent2);
    box-shadow: 0 0 0 3px rgba(184,134,11,0.1);
  }
  table { width: 100%; border-collapse: collapse; }
  th {
    padding: 9px 14px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1.5px solid var(--border);
    background: var(--surface2);
    position: sticky;
    top: 58px;
    z-index: 2;
    white-space: nowrap;
  }
  td {
    padding: 11px 14px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
    color: var(--text2);
    transition: background var(--transition);
    vertical-align: middle;
  }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--surface2); }
  .resident-name {
    font-weight: 600;
    color: var(--accent2);
    cursor: pointer;
    transition: color var(--transition);
  }
  .resident-name:hover { color: var(--accent3); text-decoration: underline; text-underline-offset: 2px; }
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
  }
  .badge-green {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success-border);
  }
  .badge-warn {
    background: var(--warn-light);
    color: var(--warn);
    border-color: var(--warn-border);
  }
  .badge-red {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger-border);
  }

  /* ── MODAL ── */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,14,20,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.18s cubic-bezier(0.34,1.56,0.64,1);
    border: 1px solid var(--border);
  }
  .modal-lg { max-width: 800px; }
  @keyframes slideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
  .modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--surface2);
    z-index: 1;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .modal-body { padding: 24px; }
  .modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: var(--surface2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
  .btn-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text3);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: all var(--transition);
  }
  .btn-close:hover { background: var(--danger-light); color: var(--danger); }

  /* ── PROFILE ── */
  .profile-header {
    background: linear-gradient(135deg, #1a1a1a, #b8860b);
    color: #fff; border-radius: var(--radius); padding: 28px; margin-bottom: 20px;
    display: flex; align-items: center; gap: 20px;
  }
  .profile-avatar {
    width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    font-family: 'DM Serif Display', serif; font-size: 26px; color: #fff; flex-shrink: 0;
  }
  .profile-name { font-family: 'DM Serif Display', serif; font-size: 24px; }
  .profile-meta { display: flex; gap: 20px; margin-top: 8px; font-size: 13px; opacity: 0.8; }
  .back-btn {
    background: none; border: none; cursor: pointer; color: var(--accent);
    font-family: inherit; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px;
    margin-bottom: 16px; padding: 0;
  }
  .back-btn:hover { text-decoration: underline; }

  /* ── NOTES ── */
  .notes-list { display: flex; flex-direction: column; gap: 12px; }
  .note-card {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
    transition: border-color 0.15s; cursor: pointer;
  }
  .note-card:hover { border-color: var(--accent); }
  .note-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .note-date { font-size: 13px; font-weight: 700; color: var(--accent); }
  .note-staff { font-size: 12px; color: var(--text3); margin-top: 2px; }
  .note-preview { font-size: 13px; color: var(--text2); margin-top: 8px; line-height: 1.5; }
  .note-actions { display: flex; gap: 6px; flex-shrink: 0; }

  /* ── NOTE DETAIL ── */
  .note-section { margin-bottom: 20px; }
  .note-section-title {
    font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase;
    letter-spacing: 0.07em; margin-bottom: 10px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .note-field { margin-bottom: 10px; }
  .note-field .field-label { font-size: 11px; font-weight: 600; color: var(--text3); margin-bottom: 3px; }
  .note-field .field-value { font-size: 14px; color: var(--text); line-height: 1.6; }
  .note-field .field-value.empty { color: var(--text3); font-style: italic; }
  .note-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

  /* ── TIMELINE ── */
  .timeline { position: relative; }
  .timeline::before {
    content: ''; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px;
    background: var(--border);
  }
  .timeline-item { display: flex; gap: 16px; margin-bottom: 20px; position: relative; }
  .timeline-dot {
    width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    color: #fff; font-size: 12px; z-index: 1;
  }
  .timeline-content { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
  .timeline-date { font-size: 12px; font-weight: 700; color: var(--accent); }
  .timeline-staff { font-size: 11px; color: var(--text3); }
  .timeline-text { font-size: 13px; color: var(--text2); margin-top: 6px; line-height: 1.5; }

  /* ── FORM ── */
  .form-section-title {
    font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase;
    letter-spacing: 0.06em; margin: 20px 0 12px; padding-bottom: 6px;
    border-bottom: 2px solid var(--accent-light);
  }
  .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .span2 { grid-column: span 2; }

  /* ── PRINT ── */
  @media print {
    .sidebar, .topbar, .nav-item, .btn, .modal-footer, .back-btn, #auth-screen { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    body { background: #fff; }
  }

  /* ── EMPTY STATE ── */
  .empty-state { text-align: center; padding: 60px 24px; }
  .empty-state svg { color: var(--text3); margin-bottom: 16px; }
  .empty-state h4 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
  .empty-state p { font-size: 14px; color: var(--text3); }

  /* ── VOICE TO NOTE ── */
  .voice-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px; border: 1.5px solid var(--border);
    background: var(--surface); color: var(--text2);
    font-family: inherit; font-size: 12.5px; font-weight: 700;
    cursor: pointer; transition: all 0.18s; user-select: none;
    position: relative; overflow: hidden;
  }
  .voice-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
  .voice-btn.recording {
    background: #fdf0ef; border-color: #c0392b; color: #c0392b;
    animation: voicePulse 1.2s ease-in-out infinite;
  }
  .voice-btn.recording .voice-mic-icon { animation: micBounce 0.6s ease-in-out infinite alternate; }
  .voice-btn.unsupported { opacity: 0.5; cursor: not-allowed; border-style: dashed; }
  @keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0.25); }
    50% { box-shadow: 0 0 0 6px rgba(192,57,43,0); }
  }
  @keyframes micBounce {
    from { transform: scale(1); }
    to { transform: scale(1.25); }
  }
  .voice-wave {
    display: none; align-items: center; gap: 2px; height: 14px;
  }
  .voice-btn.recording .voice-wave { display: flex; }
  .voice-btn.recording .voice-label { display: none; }
  .voice-wave span {
    display: block; width: 3px; background: #c0392b; border-radius: 2px;
    animation: waveBar 0.8s ease-in-out infinite alternate;
  }
  .voice-wave span:nth-child(1) { height: 4px; animation-delay: 0s; }
  .voice-wave span:nth-child(2) { height: 10px; animation-delay: 0.15s; }
  .voice-wave span:nth-child(3) { height: 14px; animation-delay: 0.3s; }
  .voice-wave span:nth-child(4) { height: 8px; animation-delay: 0.45s; }
  .voice-wave span:nth-child(5) { height: 5px; animation-delay: 0.6s; }
  @keyframes waveBar {
    from { transform: scaleY(0.4); opacity: 0.7; }
    to { transform: scaleY(1); opacity: 1; }
  }
  .voice-interim {
    font-size: 12px; color: var(--text3); font-style: italic;
    margin-top: 5px; min-height: 18px; line-height: 1.5;
    padding: 0 2px; display: none;
  }
  .voice-interim.visible { display: block; }

  /* ── TOAST ── */
  #toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    background: #0d1117;
    color: #e6edf3;
    padding: 11px 18px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    display: none;
    animation: fadeIn 0.18s cubic-bezier(0.34,1.56,0.64,1);
    border: 1px solid #30363d;
    max-width: 360px;
    line-height: 1.4;
  }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* Responsive */
  @media (max-width: 900px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .span2 { grid-column: span 1; }
    .note-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 640px) {
    :root { --sidebar: 0px; }
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); width: 240px; }
    .stats-grid { grid-template-columns: 1fr; }
  }

  /* Page views */
  .page { display: none; }
  .page.active { display: block; }

  /* ── RESIDENT STATUS BADGES ── */
  .status-active { background:#e6f4ea; color:#1e7e34; border:1px solid #a8d5b0; }
  .status-hospitalized { background:#fff3cd; color:#856404; border:1px solid #ffe08a; }
  .status-onleave { background:#e8f0fe; color:#1a73e8; border:1px solid #b0c8f8; }
  .status-discharged { background:#f8d7da; color:#721c24; border:1px solid #f5b8be; }

  /* ── PROFILE REFINEMENTS ── */
  .profile-tab { padding:9px 16px; font-size:13px; }
  .note-card { padding:14px 16px; }
  .med-card { padding:12px 14px; }
  td { padding:10px 14px; }
  .card-header h3 { font-size:14px; }
  .profile-header { padding:22px; }
  .profile-name { font-size:22px; }

  /* ── PHOTO UPLOAD ── */
  .resident-photo-wrap {
    position:relative; width:64px; height:64px; flex-shrink:0;
  }
  .resident-photo {
    width:64px; height:64px; border-radius:50%; object-fit:cover;
    border:3px solid rgba(255,255,255,0.3);
  }
  .photo-upload-btn {
    position:absolute; bottom:0; right:0;
    width:22px; height:22px; border-radius:50%;
    background:var(--accent); border:2px solid #fff;
    display:flex; align-items:center; justify-content:center;
    cursor:pointer; font-size:11px; color:#fff;
  }
  #photo-upload-input { display:none; }

  /* ── VITALS ── */
  .vitals-table { width:100%; border-collapse:collapse; font-size:13px; }
  .vitals-table th {
    background:var(--accent); color:#fff; padding:8px 10px;
    font-size:11px; font-weight:700; text-transform:uppercase;
    letter-spacing:0.05em; border:1px solid #c9a227;
  }
  .vitals-table td {
    padding:8px 10px; border:1px solid var(--border);
    font-size:13px; vertical-align:middle;
  }
  .vitals-table tr:nth-child(even) td { background:#fdfaf3; }
  .vitals-table tr:hover td { background:var(--accent-light); }

  /* ── MEDICATION ── */
  .med-card {
    border:1px solid var(--border); border-radius:var(--radius);
    padding:14px 16px; display:flex; align-items:flex-start;
    gap:14px; transition:border-color 0.15s;
  }
  .med-card:hover { border-color:var(--accent); }
  .med-icon {
    width:38px; height:38px; border-radius:10px;
    background:var(--accent-light); color:var(--accent);
    display:flex; align-items:center; justify-content:center;
    flex-shrink:0; font-size:18px;
  }
  .med-name { font-weight:700; font-size:14px; color:var(--text); }
  .med-detail { font-size:12px; color:var(--text2); margin-top:2px; line-height:1.6; }
  .med-flag { font-size:11px; font-weight:700; color:var(--danger); margin-top:4px; }

  /* ── BODY MAP ── */
  .body-map-container {
    display:flex; gap:24px; justify-content:center;
    flex-wrap:wrap; margin:12px 0;
  }
  .body-map-side { text-align:center; }
  .body-map-side h4 {
    font-size:11px; font-weight:700; color:var(--text3);
    text-transform:uppercase; letter-spacing:0.07em; margin-bottom:8px;
  }
  .body-map-svg { position:relative; display:inline-block; }
  .body-region {
    cursor:pointer; fill:transparent; stroke:transparent;
    transition:fill 0.15s;
  }
  .body-region:hover { fill:rgba(184,134,11,0.25); stroke:#b8860b; stroke-width:1; }
  .body-region.selected { fill:rgba(192,57,43,0.3); stroke:#c0392b; stroke-width:1.5; }
  .body-map-legend {
    margin-top:12px; font-size:12px; color:var(--text2);
    display:flex; flex-wrap:wrap; gap:8px; justify-content:center;
  }
  .body-map-legend span {
    background:rgba(192,57,43,0.15); color:var(--danger);
    border:1px solid rgba(192,57,43,0.3);
    padding:3px 8px; border-radius:20px; font-size:11px; font-weight:600;
  }

  /* ── CALENDAR ── */
  .cal-grid {
    display:grid; grid-template-columns:repeat(7,1fr); gap:4px;
  }
  .cal-header-cell {
    text-align:center; font-size:11px; font-weight:700;
    color:var(--text3); text-transform:uppercase;
    padding:6px 0; letter-spacing:0.05em;
  }
  .cal-day {
    min-height:72px; border:1px solid var(--border);
    border-radius:8px; padding:6px; cursor:pointer;
    transition:border-color 0.15s, background 0.15s;
    position:relative;
  }
  .cal-day:hover { border-color:var(--accent); background:var(--accent-light); }
  .cal-day.today { border-color:var(--accent); border-width:2px; }
  .cal-day.other-month { opacity:0.35; }
  .cal-day-num {
    font-size:12px; font-weight:700; color:var(--text);
    margin-bottom:4px;
  }
  .cal-day.today .cal-day-num { color:var(--accent); }
  .cal-dot {
    display:inline-block; width:7px; height:7px;
    border-radius:50%; margin:1px;
  }
  .cal-dot-note { background:#b8860b; }
  .cal-dot-incident { background:#c0392b; }
  .cal-day-popup {
    position:fixed; z-index:500; background:#fff;
    border:1px solid var(--border); border-radius:12px;
    box-shadow:var(--shadow-lg); padding:16px; width:280px;
    font-size:13px;
  }
  .cal-popup-title {
    font-weight:700; font-size:14px; color:var(--accent);
    margin-bottom:10px; padding-bottom:8px;
    border-bottom:1px solid var(--border);
  }
  .cal-popup-item {
    padding:6px 0; border-bottom:1px solid var(--border);
    font-size:12px; color:var(--text2); line-height:1.5;
  }
  .cal-popup-item:last-child { border-bottom:none; }
  .cal-popup-item strong { color:var(--text); }

  /* ── PROFILE TABS ── */
  .profile-tab {
    padding:10px 18px; border:none; background:none;
    font-family:inherit; font-size:13.5px; font-weight:600;
    color:var(--text3); cursor:pointer; border-bottom:3px solid transparent;
    transition:all 0.15s; margin-bottom:-2px; white-space:nowrap; flex-shrink:0;
  }
  .profile-tab:hover { color:var(--text); }
  .profile-tab.active { color:var(--accent); border-bottom-color:var(--accent); }


  /* Incident Report Form */
  .ir-section-title {
    font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase;
    letter-spacing: 0.06em; margin: 20px 0 12px; padding-bottom: 6px;
    border-bottom: 2px solid var(--accent-light);
  }
  .checkbox-group { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 4px; }
  .checkbox-item { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text); cursor: pointer; }
  .checkbox-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
  .ir-witness-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
  .ir-yn { display: flex; gap: 16px; align-items: center; margin-top: 4px; }
  .ir-yn label { display: flex; align-items: center; gap: 5px; font-size: 13.5px; cursor: pointer; }
  .ir-yn input[type="radio"] { accent-color: var(--accent); }
  @media (max-width: 768px) {
  #auth-screen, #app {
    display: none !important;
  }

  #mobile-block {
    display: flex !important;
  }
}
