  :root {
    --primary: #1a3a5c;
    --primary-light: #2a5a8c;
    --accent: #e8a020;
    --accent-light: #f5c060;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface2: #f0f3f7;
    --border: #dde2ea;
    --text: #1a1f2e;
    --text2: #5a6478;
    --text3: #8a96a8;
    --danger: #c0392b;
    --success: #1e7e4e;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 16px rgba(26,58,92,0.10);
    --shadow-sm: 0 1px 4px rgba(26,58,92,0.08);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
  }

  /* ── Screens ── */
  .screen { display: none; min-height: 100vh; }
  .screen.active { display: flex; flex-direction: column; }

  /* ── Auth Screen ── */
  #screen-auth {
    background: linear-gradient(160deg, #1a3a5c 0%, #0d2240 55%, #1a3a5c 100%);
    align-items: center;
    justify-content: center;
    padding: 24px;
  }

  .auth-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 36px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  }

  .auth-logo {
    text-align: center;
    margin-bottom: 28px;
  }

  .auth-logo-icon {
    width: 72px; height: 72px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
  }

  .auth-logo-icon img { width: 100%; height: 100%; object-fit: contain; }

  .auth-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.3px;
  }

  .auth-logo p {
    font-size: 13px;
    color: var(--text3);
    margin-top: 2px;
  }

  /* Tabs */
  .auth-tabs {
    display: flex;
    background: var(--surface2);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 24px;
  }

  .auth-tab {
    flex: 1;
    padding: 9px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text2);
    transition: all 0.2s;
    border: none;
    background: none;
  }

  .auth-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
  }

  /* Forms */
  .form-group { margin-bottom: 16px; }

  /* Same light-blue chip look as .stmt-label (Statement/JIR/DOL) — .form-label is the
     equivalent field-label class used by Login/Register, Claim Registration, ILA, Raise
     Bill and Policy Particulars, so this is what makes the chip a true app-wide theme
     instead of only covering the Statement/JIR family. 2026-07-23. */
  .form-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
    background: #dceaf9; border: 1px solid #a9c9e8;
    border-radius: var(--radius-sm); padding: 5px 11px; line-height: 1.35;
  }

  .form-input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    transition: border 0.2s;
    outline: none;
    -webkit-appearance: none;
  }

  .form-input:focus { border-color: var(--primary); }

  .form-input::placeholder { color: var(--text3); }

  select.form-input { cursor: pointer; }

  .btn {
    width: 100%;
    padding: 13px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    letter-spacing: 0.2px;
  }

  .btn-primary {
    background: var(--primary);
    color: #fff;
  }

  .btn-primary:active { background: #0d2240; transform: scale(0.99); }

  .btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text2);
    margin-top: 10px;
  }

  .btn-accent {
    background: var(--accent);
    color: #fff;
  }

  .btn-accent:active { background: #c88010; }

  .btn-danger {
    background: var(--danger);
    color: #fff;
    margin-top: 10px;
  }

  .form-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    min-height: 18px;
  }

  .form-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 20px 0 14px;
  }

  /* Role selector */
  .role-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }

  .role-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
  }

  .role-card.selected {
    border-color: var(--primary);
    background: #eef3fa;
  }

  .role-card-icon {
    font-size: 26px;
    margin-bottom: 6px;
    display: block;
  }

  .role-card-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: block;
  }

  .role-card-desc {
    font-size: 11px;
    color: var(--text3);
    margin-top: 2px;
    display: block;
  }

  /* ── Profile Setup ── */
  #screen-profile {
    background: var(--bg);
    padding: 0;
  }

  .profile-header {
    background: var(--primary);
    color: #fff;
    padding: 20px 20px 24px;
  }

  .profile-header h2 { font-size: 18px; font-weight: 600; }
  .profile-header p { font-size: 13px; opacity: 0.7; margin-top: 4px; }

  .profile-body {
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
  }

  .logo-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: border 0.2s;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
  }

  .logo-upload-area:hover { border-color: var(--primary-light); }

  .logo-upload-area input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
  }

  .logo-preview {
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
    display: none;
    margin: 0 auto 8px;
  }

  .logo-upload-hint { font-size: 13px; color: var(--text3); }
  .logo-upload-hint strong { color: var(--primary); display: block; font-size: 14px; margin-bottom: 4px; }

  /* ── Main App ── */
  #screen-app { background: var(--bg); }

  /* Top nav */
  .top-nav {
    background: var(--primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .top-nav-logo {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
    flex: 1;
  }

  .top-nav-logo span { color: var(--accent-light); }

  .hamburger-btn {
    background: none; border: none; color: #fff;
    width: 32px; height: 32px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0;
  }
  .hamburger-btn svg { width: 22px; height: 22px; }

  /* ── Side menu drawer ── */
  .side-menu-overlay {
    position: fixed; inset: 0; z-index: 600;
    background: rgba(0,0,0,0.45);
    display: none;
  }
  .side-menu {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 250px; max-width: 78vw;
    background: var(--surface);
    z-index: 601;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
    padding: 18px 0;
    overflow-y: auto;
  }
  .side-menu.open { transform: translateX(0); }
  .side-menu-header {
    padding: 6px 18px 18px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border); margin-bottom: 8px;
  }
  .side-menu-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; flex-shrink: 0;
  }
  .side-menu-name { font-size: 14px; font-weight: 700; color: var(--text); }
  .side-menu-role { font-size: 11.5px; color: var(--text3); margin-top: 1px; }
  .side-menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 18px; font-size: 14px; color: var(--text);
    cursor: pointer;
  }
  .side-menu-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--text2); }
  .side-menu-item:active { background: var(--surface2); }
  .side-menu-item.danger { color: var(--danger); }
  .side-menu-item.danger svg { color: var(--danger); }
  .side-menu-divider { height: 1px; background: var(--border); margin: 8px 0; }

  .nav-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.3);
    position: relative;
  }

  /* Dropdown */
  .nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 200px;
    display: none;
    z-index: 200;
    overflow: hidden;
  }

  .nav-dropdown.open { display: block; }

  .nav-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
  }

  .nav-dropdown-name { font-size: 14px; font-weight: 600; color: var(--text); }
  .nav-dropdown-role { font-size: 12px; color: var(--text3); margin-top: 2px; }

  .nav-dropdown-item {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
  }

  .nav-dropdown-item:hover { background: var(--surface2); }
  .nav-dropdown-item.danger { color: var(--danger); }

  /* Dashboard */
  .dashboard {
    padding: 20px 16px;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
  }

  .welcome-banner {
    background: linear-gradient(120deg, var(--primary), var(--primary-light));
    border-radius: var(--radius);
    padding: 20px;
    color: #fff;
    margin-bottom: 24px;
  }

  .welcome-banner h2 { font-size: 18px; font-weight: 600; }
  .welcome-banner p { font-size: 13px; opacity: 0.8; margin-top: 4px; }

  .welcome-banner .role-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 10px;
    letter-spacing: 0.3px;
  }

  /* Month-over-month stats */
  .month-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }

  .month-stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 14px 12px;
    position: relative;
    overflow: hidden;
  }

  .month-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-color, var(--primary));
  }

  .month-stat-title {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text2);
    margin-bottom: 10px;
  }

  .month-stat-cols { display: flex; align-items: center; }
  .month-stat-col { flex: 1; text-align: center; }
  .month-stat-divider { width: 1px; height: 30px; background: var(--border); }
  .month-stat-num { font-size: 22px; font-weight: 700; color: var(--primary); }
  .month-stat-num.dim { font-size: 17px; color: var(--text3); }
  .month-stat-lbl { font-size: 10px; color: var(--text3); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.02em; }

  /* Claim picker modal */
  .claim-picker-row {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
  }
  .claim-picker-row:active { background: var(--surface2); }
  .claim-picker-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
  .claim-picker-row-top strong { font-size: 14px; color: var(--text); }
  .claim-picker-row-top span { font-size: 11.5px; color: var(--text3); flex-shrink: 0; }
  .claim-picker-row-bottom { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; }
  .claim-picker-row-bottom span { font-size: 12px; color: var(--text2); }
  .claim-picker-row-bottom span:last-child { color: var(--text3); text-align: right; }

  /* Section */
  .section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
  }

  /* Module grid */
  .module-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 24px;
  }

  .module-card {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    border-bottom: 4px solid var(--card-color, var(--primary));
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
    padding: 10px 4px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .module-card:active {
    transform: translateY(2px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  }

  .module-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--card-color, var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-bottom: 5px;
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.35), inset 0 -1px 2px rgba(0,0,0,0.15);
  }

  .module-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    display: block;
    line-height: 1.15;
  }

  .module-sub {
    display: none;
  }

  .module-card.locked { opacity: 0.5; pointer-events: none; }

  .coming-soon {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--surface2);
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text3);
    padding: 2px 7px;
    letter-spacing: 0.3px;
  }

  /* Built and working, just not launched to everyone yet (staged rollout —
     see BETA_MODULES in admin-team.js) — distinct from .coming-soon (not
     built at all), so it gets its own colour rather than reading as "same
     as Soon". Card stays clickable; the click itself explains why. */
  .beta-badge {
    position: absolute;
    top: 8px; right: 8px;
    background: #ede9fe;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    color: #7c3aed;
    padding: 2px 7px;
    letter-spacing: 0.3px;
  }

  /* Info row */
  .info-row {
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
  }

  .info-row-label { color: var(--text3); font-size: 12px; }
  .info-row-value { font-weight: 500; color: var(--text); font-size: 14px; }

  /* Bottom nav */
  .bottom-nav {
    position: fixed;
    left: 14px; right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-radius: 24px;
    box-shadow: 0 6px 22px rgba(26,58,92,0.25);
    display: flex;
    padding: 5px 6px;
    z-index: 100;
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 2px 0;
    cursor: pointer;
    color: var(--text3);
    font-size: 10px;
    font-weight: 500;
    transition: color 0.2s;
  }

  .bottom-nav-item.active { color: var(--primary); font-weight: 700; }

  .bottom-nav-icon {
    width: 25px; height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1px;
    transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  }

  .bottom-nav-icon svg { width: 15px; height: 15px; }

  .bottom-nav-item.active .bottom-nav-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    color: #fff;
    transform: translateY(-8px);
    box-shadow: 0 4px 10px rgba(232,160,32,0.45);
  }

  .bottom-nav-item.active .bottom-nav-icon svg { width: 17px; height: 17px; }

  /* Admin panel */
  .user-list-item {
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .user-initials {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
  }

  .user-info { flex: 1; }
  .user-name { font-size: 14px; font-weight: 600; }
  .user-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }

  .role-pill {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
  }

  .role-pill.surveyor { background: #deeeff; color: #1a4a8a; }
  .role-pill.insured { background: #e8f5e9; color: #1a6a30; }
  .role-pill.admin { background: #fff3e0; color: #8a4a00; }
  .role-pill.firm_admin { background: #fde8ff; color: #6a008a; }
  .role-pill.principal_surveyor { background: #e8f0ff; color: #1a2a8a; }
  .role-pill.firm_surveyor { background: #deeeff; color: #1a4a8a; }
  .role-pill.independent_surveyor { background: #e8f5e9; color: #1a6a30; }

  /* ── Manage Users: grouped rows + click-to-open detail modal ──
     2026-08-23 — replaced a per-row "Actions" button column (which grew to
     8 buttons and started overflowing off-screen) with: rows grouped by
     role under a collapsible header (less up/down scrolling through a flat
     list), and clicking any row opens all of that user's controls in one
     modal instead of hunting through inline buttons. */
  .user-group-header:hover td { background: var(--border) !important; }
  .user-row { cursor: pointer; transition: background 0.1s; }
  .user-row:hover { background: var(--surface2); }

  .user-detail-modal-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,35,0.5);
    display: flex; align-items: flex-end; justify-content: center;
  }
  .user-detail-modal {
    background: var(--surface);
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.25);
  }
  .udm-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface); z-index: 1;
  }
  .udm-body { padding: 6px 18px 22px; }
  .udm-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
  .udm-section:last-child { border-bottom: none; }
  .udm-section-title {
    font-size: 11px; font-weight: 700; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px;
  }
  .udm-info-row {
    display: flex; justify-content: space-between; font-size: 13px;
    padding: 5px 0; color: var(--text2);
  }
  .udm-info-row strong { color: var(--text); font-weight: 600; }
  .udm-btn {
    display: block; text-align: left;
    font-size: 13px; padding: 10px 12px; margin-top: 8px;
    border: 1px solid var(--border); background: transparent; color: var(--text);
    border-radius: 8px; cursor: pointer; transition: background 0.1s;
  }
  .udm-btn:first-of-type { margin-top: 0; }
  .udm-btn:hover { background: var(--surface2); }
  .udm-btn-good { border-color: #43a047; color: #2e7d32; }
  .udm-btn-danger { border-color: #e53935; color: #c62828; }

  /* Desktop: centered dialog instead of a bottom sheet — and per the
     "Super Admin mostly works on laptop" note, size the whole Manage Users
     panel generously rather than treating it as a stretched mobile view. */
  @media (min-width: 768px) {
    .user-detail-modal-backdrop { align-items: center; }
    .user-detail-modal {
      width: 480px; max-width: 92vw; max-height: 82vh;
      border-radius: 16px;
    }
    .udm-header { border-radius: 16px 16px 0 0; }
  }

  /* ── Case Status Badge ── */
  .status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 14px; border-radius: 20px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.3px;
  }
  .status-badge.registered    { background:#f0f0f0; color:#555; }
  .status-badge.assigned      { background:#deeeff; color:#1a4a8a; }
  .status-badge.survey_done   { background:#e0fff4; color:#006a44; }
  .status-badge.ila_issued    { background:#f3e0ff; color:#6a008a; }
  .status-badge.lor_issued    { background:#fff3e0; color:#8a4a00; }
  .status-badge.reminder_1    { background:#fff8e0; color:#9a7600; }
  .status-badge.reminder_2    { background:#ffeccc; color:#a35a00; }
  .status-badge.reminder_3    { background:#ffdfb8; color:#aa4400; }
  .status-badge.final_notice  { background:#ffe0e0; color:#aa0000; }
  .status-badge.fsr_released  { background:#e0f0ff; color:#006aaa; }
  .status-badge.bill_raised   { background:#e8f5e9; color:#1a6a30; }
  .status-badge.closed        { background:#1a3a5c; color:#fff; }

  /* ── Status Timeline ── */
  .status-timeline { padding: 10px 0; }
  .status-tl-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 6px 0; position: relative;
  }
  .status-tl-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--primary); margin-top: 4px; flex-shrink: 0;
  }
  .status-tl-dot.latest { background: #1e7e4e; }
  .status-tl-info { flex: 1; }
  .status-tl-name { font-size: 13px; font-weight: 600; color: var(--text1); }
  .status-tl-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

  /* ── Assign Section ── */
  .assign-box {
    background: var(--surface2); border-radius: var(--radius-sm);
    border: 1px solid var(--border); padding: 12px; margin-bottom: 14px;
  }
  .assign-box-title { font-size: 12px; font-weight: 600; color: var(--text3); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }

  /* Toast */
  .toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1f2e;
    color: #fff;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 500;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    white-space: nowrap;
  }

  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  /* Divider */
  .divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }





  /* ── PWA UI ── */
  .offline-bar {
    position: fixed; top: 0; left: 0; right: 0;
    background: #c0392b; color: #fff;
    text-align: center; font-size: 12px; font-weight: 600;
    padding: 6px 12px; z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s;
  }
  .offline-bar.show { transform: translateY(0); }

  .install-banner {
    position: fixed; bottom: 130px; left: 12px; right: 12px;
    background: var(--primary); color: #fff;
    border-radius: var(--radius); padding: 14px 16px;
    display: none; align-items: center; gap: 12px;
    z-index: 200; box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  }
  .install-banner.show { display: flex; }
  .install-banner-text { flex: 1; }
  .install-banner-text p { font-size: 14px; font-weight: 600; margin: 0; }
  .install-banner-text span { font-size: 12px; opacity: 0.8; }
  .install-btn {
    background: var(--accent); color: #fff;
    border: none; border-radius: 8px;
    padding: 8px 16px; font-size: 13px;
    font-weight: 600; cursor: pointer; white-space: nowrap;
  }
  .install-close {
    background: none; border: none; color: rgba(255,255,255,0.6);
    font-size: 20px; cursor: pointer; padding: 0 2px; line-height: 1;
  }

  .sync-badge {
    position: fixed; bottom: 132px; right: 14px;
    background: var(--success); color: #fff;
    border-radius: 20px; padding: 6px 14px;
    font-size: 12px; font-weight: 600;
    display: none; align-items: center; gap: 6px;
    z-index: 200; box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  }
  .sync-badge.show { display: flex; }


  /* ── Insured Statement Form ── */
  .stmt-damage-table {
    width: 100%; border-collapse: collapse; font-size: 11px;
    min-width: 600px;
  }
  /* Recolored to match the light-blue label-chip theme (was solid dark navy) so table
     headers read as the same "theme" as the field labels above them, not a clashing
     second color scheme. 2026-07-23. */
  .stmt-damage-table th {
    background: #dceaf9; color: var(--primary); padding: 6px 4px;
    text-align: left; font-size: 10px; font-weight: 700;
    white-space: nowrap; border: 1px solid #a9c9e8;
  }
  .stmt-damage-table td { padding: 6px 4px; border: 1px solid #9fb3c8; }
  .stmt-damage-table tbody tr:nth-child(even) { background: var(--surface2); }
  .stmt-damage-table tbody tr:hover { background: #eef3f8; }
  /* Rounded-corner frame around every repeater table (Documents/Items/DOL/ILA/Raise Bill —
     all share .stmt-damage-table) — matches the app's existing global rounding (--radius/
     --radius-sm used on every input/button/panel) and the same wrapper pattern already
     used for .claims-data-table. overflow-x:auto (needed for horizontal scroll on mobile,
     these tables are wider than the screen) clips the table's square outer corners to this
     div's rounded ones — no change needed to the table/cells themselves. 2026-07-06. */
  .stmt-table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid #9fb3c8; border-radius: var(--radius-sm);
  }
  .stmt-table-wrap .stmt-damage-table { min-width: 600px; }
  /* Mobile "card" reflow for every .stmt-damage-table (Documents/Items/DOL/ILA/Raise Bill
     all share this class) — below phone width, showing a 600px-min table in a horizontal
     scroller was the worst possible UX (user report 2026-07-23). Instead each row becomes
     a stacked block and each cell prints its own column header as a label via
     data-label/::before, so no column is ever cut off or requires side-scrolling. This is
     purely visual: the underlying <table>/<td> DOM and all collect/restore/docx/pdf logic
     (which read cell inputs by id, never by table layout) are completely untouched — see
     stmtApplyTableLabels() below for how data-label gets stamped on without editing any of
     the ~15 row-builder functions individually. */
  @media (max-width: 640px) {
    .stmt-table-wrap { border: none; overflow: visible; }
    .stmt-table-wrap .stmt-damage-table { min-width: 0; width: 100%; }
    .stmt-damage-table.stmt-table-cards thead { display: none; }
    .stmt-damage-table.stmt-table-cards, .stmt-damage-table.stmt-table-cards tbody,
    .stmt-damage-table.stmt-table-cards tr { display: block; width: 100%; }
    .stmt-damage-table.stmt-table-cards tbody tr {
      margin-bottom: 10px; border: 1px solid #9fb3c8; border-radius: var(--radius-sm);
      overflow: hidden; background: var(--surface1, #fff);
    }
    .stmt-damage-table.stmt-table-cards tbody tr:nth-child(even) { background: var(--surface2); }
    /* Stacked (not side-by-side) — label chip on its own line, then the field on its own
       full-width line below, matching the look of the regular .stmt-field/.stmt-label
       sections (e.g. DOL's Building/Blocks fields) instead of a cramped label+input row.
       .stmt-td-input already declares width:100% so it stretches to fill the column even
       though align-items is flex-start (that only affects children with an auto width —
       the label chip stays content-sized, the input/select stretches full width). 2026-07-23. */
    .stmt-damage-table.stmt-table-cards td {
      display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
      width: 100%; box-sizing: border-box; border: none;
      border-bottom: 1px solid #dde5ee; padding: 8px 10px;
    }
    .stmt-damage-table.stmt-table-cards td:last-child { border-bottom: none; }
    .stmt-damage-table.stmt-table-cards td[data-label]:not([data-label=""])::before {
      content: attr(data-label);
      font-size: 10px; font-weight: 700; color: var(--primary); text-transform: uppercase;
      background: #dceaf9; border: 1px solid #a9c9e8;
      border-radius: var(--radius-sm); padding: 4px 8px;
    }
    .stmt-damage-table.stmt-table-cards td .stmt-row-delete-btn { align-self: flex-end; }
    .stmt-damage-table.stmt-table-cards tfoot tr { display: block; }
    .stmt-damage-table.stmt-table-cards tfoot td { display: block; width: 100%; box-sizing: border-box; }
  }
  .stmt-td-input {
    width: 100%; border: none; background: transparent;
    font-size: 11px; padding: 4px 3px; color: var(--text1);
    outline: none; min-width: 0;
  }
  .stmt-td-input:focus { background: #eef2ff; border-radius: 3px; }
  .stmt-row-delete-btn {
    background: #fdebeb; border: 1px solid #f3c6c6; color: #e53e3e;
    font-size: 13px; cursor: pointer; border-radius: 5px;
    width: 24px; height: 24px; line-height: 1; padding: 0;
  }
  .stmt-row-delete-btn:hover { background: #fbd5d5; }
  /* Toggle switches — used for the "Advice for the Insured" checklists (Marine + generic
     JIR) instead of plain checkboxes, per user request 2026-07-06. Same underlying
     <input type="checkbox"> (class/value/data-key unchanged), purely a visual re-skin —
     all existing querySelectorAll('.jir-advice-cb')/.stmt-jir-advice-cb JS is untouched. */
  .stmt-toggle-wrap {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 10px 12px; border-radius: 8px; background: var(--surface2);
    margin-bottom: 8px;
  }
  .stmt-toggle-input { position: absolute; opacity: 0; width: 0; height: 0; }
  .stmt-toggle-slider {
    position: relative; width: 38px; height: 22px; flex-shrink: 0;
    background: #ccc; border-radius: 11px; transition: background .15s;
  }
  .stmt-toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px;
    background: #fff; border-radius: 50%; transition: transform .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  }
  .stmt-toggle-input:checked + .stmt-toggle-slider { background: var(--primary); }
  .stmt-toggle-input:checked + .stmt-toggle-slider::before { transform: translateX(16px); }
  .stmt-toggle-text { font-size: 13px; color: var(--text1); line-height: 1.5; }
  .stmt-checkbox-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px; margin-top: 4px;
  }
  .stmt-chk {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text1); cursor: pointer;
    padding: 4px 8px; border-radius: 4px;
    border: 1px solid var(--border); background: var(--surface2);
  }
  .stmt-chk input { accent-color: var(--primary); }
  .stmt-section-head {
    background: var(--primary); color: #fff;
    font-size: 12px; font-weight: 700;
    letter-spacing: 0.6px; text-transform: uppercase;
    padding: 7px 14px; border-radius: 6px;
    margin: 18px 0 10px;
  }
  .stmt-field { margin-bottom: 14px; }
  /* "Chip"-style field labels — same look/radius as every button/input in the app
     (var(--radius-sm), the app's one shared control radius) so labels read as a clear,
     tappable-looking highlight above each field instead of plain grey text — improves
     scannability on both mobile and laptop. inline-block (not full-width block like
     before) so short labels stay compact; long bilingual labels still wrap normally.
     Purely visual — class/JS wiring for these labels is untouched. 2026-07-23. */
  .stmt-label {
    font-size: 12px; font-weight: 700;
    color: var(--primary); margin-bottom: 6px; display: inline-block;
    background: #dceaf9; border: 1px solid #a9c9e8;
    border-radius: var(--radius-sm); padding: 5px 11px; line-height: 1.35;
  }
  .stmt-preview-wrap {
    border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; background: #fff; margin-bottom: 16px;
  }
  .stmt-preview-wrap canvas { display: block; width: 100%; }
  .stmt-preview-label {
    font-size: 11px; color: var(--text3);
    text-align: center; padding: 6px;
    background: var(--surface2);
  }
  #stmt-canvas { display: none; }

  /* Signature pad */
  .sig-pad-wrap {
    border: 2px dashed var(--border); border-radius: var(--radius-sm);
    background: #fafafa; position: relative; overflow: hidden;
  }
  #sig-canvas, #thumb-canvas {
    display: block; width: 100%; height: 90px;
    cursor: crosshair; touch-action: none;
  }
  .sig-clear-btn {
    position: absolute; top: 4px; right: 6px;
    background: none; border: none; color: var(--danger);
    font-size: 12px; cursor: pointer; font-weight: 600;
  }

  /* ── Document Capture ── */
  .doc-page-strip {
    display: flex; gap: 8px; overflow-x: auto;
    padding: 8px 0; scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .doc-page-strip::-webkit-scrollbar { display: none; }
  .doc-page-thumb {
    position: relative; flex-shrink: 0;
    width: 72px; height: 90px;
    border-radius: 6px; overflow: hidden;
    border: 2px solid var(--border); background: var(--surface2);
    cursor: pointer;
  }
  .doc-page-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
  .doc-page-thumb .pg-num {
    position: absolute; bottom: 2px; right: 3px;
    background: rgba(0,0,0,0.6); color:#fff;
    font-size: 9px; border-radius: 3px; padding: 1px 4px;
  }
  .doc-page-thumb .pg-del {
    position: absolute; top: 2px; right: 2px;
    background: rgba(192,57,43,0.85); color:#fff;
    font-size: 11px; border-radius: 50%;
    width: 18px; height: 18px;
    display: flex; align-items:center; justify-content:center;
    cursor: pointer; font-weight:700;
  }

  .doc-name-input {
    font-size: 16px; font-weight: 600; color: var(--primary);
    border: none; border-bottom: 2px solid var(--primary);
    background: transparent; width: 100%;
    padding: 4px 2px; outline: none; margin-bottom: 12px;
  }

  /* Document list cards */
  .doc-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 12px 14px; margin-bottom: 10px;
    display: flex; align-items: center; gap: 12px;
  }
  .doc-card-icon {
    width: 44px; height: 44px; border-radius: 8px;
    background: #eef3fa; display: flex;
    align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
  }
  .doc-card-info { flex: 1; min-width: 0; }
  .doc-card-name {
    font-size: 14px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .doc-card-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
  .doc-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
  .doc-action-btn {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; padding: 5px 10px;
    font-size: 12px; cursor: pointer; color: var(--text2);
    white-space: nowrap;
  }
  .doc-action-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }

  /* ── Camera Panel ── */
  .cam-panel { background: #000; }
  .cam-video-wrap {
    position: relative; flex: 1;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; background: #000; min-height: 0;
  }
  #cam-video { width: 100%; height: 100%; object-fit: cover; display: block; }
  .cam-overlay-preview {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.62);
    padding: 6px 10px 8px;
    font-size: 11px; color: #fff; line-height: 1.7;
    pointer-events: none;
  }
  .cam-controls {
    background: #111; padding: 10px 14px 18px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0; gap: 10px;
  }
  .cam-strip {
    display: flex; gap: 7px; overflow-x: auto; flex: 1;
    padding: 2px 0; scrollbar-width: none;
  }
  .cam-strip::-webkit-scrollbar { display: none; }
  .cam-thumb {
    width: 54px; height: 54px; border-radius: 6px;
    object-fit: cover; flex-shrink: 0;
    border: 2px solid #555; cursor: pointer;
  }
  .cam-capture-btn {
    width: 66px; height: 66px; border-radius: 50%;
    background: #fff; border: 4px solid #666;
    cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.1s;
  }
  .cam-capture-btn:active { transform: scale(0.90); }
  .cam-capture-inner { width: 50px; height: 50px; border-radius: 50%; background: #fff; }
  .cam-gps-chip { font-size: 10px; color: #888; text-align: center; flex-shrink: 0; min-width: 56px; }
  .cam-gps-chip.ok  { color: #4caf50; }
  .cam-gps-chip.err { color: #f44336; }
  .cam-panel .panel-header { background: #000; border-bottom: 1px solid #222; }
  .cam-panel .panel-back { color: #fff; }
  .cam-panel h2 { color: #fff; font-size: 14px; }

  /* Photo grid */
  .photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 14px; }
  .photo-cell {
    aspect-ratio: 4/3; border-radius: 6px; overflow: hidden;
    cursor: pointer; position: relative; background: var(--surface2);
  }
  .photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .photo-cell-num {
    position: absolute; bottom: 3px; right: 4px;
    background: rgba(0,0,0,0.55); color: #fff;
    font-size: 10px; border-radius: 4px; padding: 1px 5px;
  }

  /* Photo cell selection (PDF picker) */
  .photo-cell.pickable::after {
    content: ''; position: absolute; inset: 0;
    border: 2px solid transparent; border-radius: 6px;
    transition: border-color 0.15s, background 0.15s;
  }
  .photo-cell.pickable.picked::after {
    border-color: var(--accent); background: rgba(232,160,32,0.18);
  }
  .photo-cell-check {
    position: absolute; top: 4px; left: 4px;
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(255,255,255,0.85); border: 2px solid #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: transparent;
  }
  .photo-cell.picked .photo-cell-check {
    background: var(--accent); color: #fff; border-color: var(--accent);
  }

  /* Photo PDF picker — photos-per-page selector */
  .photo-pdf-perpage-btn {
    border: 1px solid var(--border); background: var(--surface2); color: var(--text2);
    font-size: 12.5px; font-weight: 600; border-radius: 7px;
    width: 30px; height: 28px; cursor: pointer;
  }
  .photo-pdf-perpage-btn.active {
    background: var(--primary); border-color: var(--primary); color: #fff;
  }

  /* Photo viewer */
  .photo-viewer {
    position: fixed; inset: 0; z-index: 500;
    background: #000; display: none;
    flex-direction: column;
  }
  .photo-viewer.open { display: flex; }
  .photo-viewer-hdr {
    background: rgba(0,0,0,0.7); padding: 12px 14px;
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  }
  .photo-viewer-hdr span { color: #ccc; font-size: 12px; flex: 1; }
  #viewer-img { flex: 1; width: 100%; object-fit: contain; min-height: 0; }
  .photo-viewer-ftr {
    background: rgba(0,0,0,0.7); padding: 10px 14px;
    display: flex; gap: 10px; flex-shrink: 0;
  }

  /* ── Claim Form Panel ── */
  .slide-panel {
    position: fixed; inset: 0; z-index: 300;
    display: flex; flex-direction: column;
    background: var(--bg);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
  }
  .slide-panel.open { transform: translateY(0); }

  .panel-header {
    background: var(--primary); color: #fff;
    padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
  }
  .panel-header h2 { font-size: 17px; font-weight: 600; flex: 1; }
  .panel-back {
    background: rgba(255,255,255,0.12); border: none; color: #fff;
    height: 34px; padding: 0 12px 0 9px; border-radius: 17px;
    display: flex; align-items: center; gap: 5px;
    cursor: pointer; flex-shrink: 0;
    font-size: 13px; font-weight: 700;
    transition: background 0.15s, transform 0.1s;
  }
  .panel-back svg { width: 19px; height: 19px; flex-shrink: 0; }
  .panel-back:active { background: rgba(255,255,255,0.25); transform: scale(0.96); }

  .panel-body {
    flex: 1; overflow-y: auto;
    padding: 16px;
    max-width: 540px; margin: 0 auto; width: 100%;
    padding-bottom: 100px;
  }
  /* Panels that hold wide repeater tables (Claim Reg's set-offices, Statement/Marine JIR,
     Detail of Loss, ILA, Raise Bill) get a much wider column on laptop/desktop so those
     tables get real room instead of always horizontal-scrolling inside the normal 540px
     single-column form width. Other panels (login, plain claim-detail, etc.) are untouched.
     2026-07-23, user report: DOL tables were unusably cramped on laptop. */
  @media (min-width: 860px) {
    #panel-new-claim .panel-body,
    #panel-statement .panel-body,
    #panel-detail-of-loss .panel-body,
    #panel-ila .panel-body,
    #panel-raisebill .panel-body,
    #panel-admin-users .panel-body,
    #panel-admin-policies .panel-body,
    #panel-admin-insurer .panel-body,
    #panel-admin-deleted .panel-body {
      max-width: 90vw;
    }
  }

  /* 2026-08-23: the whole app was hard-capped at 600px (.dashboard/.claims-list)
     or 540px (.panel-body default) everywhere — fine on mobile, where 600px
     already fills the screen, but on a real laptop/desktop window that left
     content sitting as a narrow phone-width column marooned in a sea of
     blank --bg canvas either side, reading as unfinished rather than a
     proper responsive desktop layout. This gives the main scrolling views
     and the default (non-wide-table) panel width more generous, still
     comfortably-readable room, and lets the module-card grid use a
     responsive column count instead of stretching 3 fixed columns into
     oversized cards as the container widens. */
  @media (min-width: 860px) {
    .dashboard, .claims-list {
      max-width: 900px;
    }
    .panel-body {
      max-width: 680px;
    }
    .module-grid {
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
  }

  .panel-footer {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 12px 16px env(safe-area-inset-bottom, 8px);
    display: flex; gap: 10px;
  }

  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

  /* Claim file no badge */
  .cfn-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: #eef3fa; border: 1.5px solid #b5d4f4;
    border-radius: 8px; padding: 8px 12px;
    font-size: 14px; font-weight: 600; color: var(--primary);
    margin-bottom: 16px; width: 100%;
  }
  .cfn-badge span { font-size: 11px; color: var(--text3); font-weight: 400; margin-left: auto; }

  /* Claims List */
  .claims-list { padding: 12px 16px; max-width: 600px; width: 100%; margin: 0 auto; }

  .date-group-label {
    font-size: 11px; font-weight: 700;
    color: var(--text3); text-transform: uppercase;
    letter-spacing: 0.8px;
    margin: 16px 0 8px;
  }
  .date-group-label:first-child { margin-top: 4px; }

  .claim-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: box-shadow 0.15s;
    position: relative;
  }
  .claim-card:active { box-shadow: 0 2px 12px rgba(26,58,92,0.12); }
  .claim-card-top { display: flex; align-items: flex-start; gap: 10px; }
  .claim-card-badge {
    background: var(--primary); color: #fff;
    border-radius: 6px; padding: 4px 8px;
    font-size: 11px; font-weight: 700;
    white-space: nowrap; flex-shrink: 0;
  }
  .claim-card-main { flex: 1; min-width: 0; }
  .claim-card-insured {
    font-size: 15px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .claim-card-insurer { font-size: 12px; color: var(--text2); margin-top: 2px; }
  .claim-card-bottom {
    display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap;
  }
  .claim-tag {
    background: var(--surface2); border-radius: 20px;
    padding: 3px 10px; font-size: 11px; color: var(--text2);
  }
  .claim-tag.nature { background: #fff3e0; color: #8a4a00; }
  .claim-tag.policy { background: #e8f5e9; color: #1a6a30; }

  /* Detail view */
  .detail-row {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 10px 0; border-bottom: 0.5px solid var(--border);
    gap: 12px;
  }
  .detail-row:last-child { border-bottom: none; }
  .detail-label { font-size: 12px; color: var(--text3); flex-shrink: 0; }
  .detail-value { font-size: 14px; color: var(--text); font-weight: 500; text-align: right; word-break: break-all; }

  .empty-state {
    text-align: center; padding: 48px 24px;
    color: var(--text3);
  }
  .empty-state-icon { font-size: 48px; margin-bottom: 12px; display: block; }
  .empty-state p { font-size: 15px; margin-bottom: 6px; color: var(--text2); }
  .empty-state small { font-size: 13px; }

  /* Padding bottom for fixed nav */
  .has-bottom-nav { padding-bottom: 130px; }
