  :root {
    --brand: #0d7377;
    --brand-mid: #14a085;
    --brand-light: #b2e0e0;
    --success: #009639;
    --danger: #DA291C;
    --warning: #FFB81C;
    --brand-dark: #0a2020;
    --surface: #d4eeee;
    --surface2: #e0f4f4;
    --surface3: #edfafa;
    --border: #8ecfcf;
    --text: #0d2b2b;
    --text-muted: #2d6b6b;
    --text-light: #3d9999;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(13,115,119,0.10);
    --shadow-md: 0 4px 16px rgba(13,115,119,0.15);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--surface2);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;    /* prevent any table overflow from widening the page */
    max-width: 100vw;
  }

  /* ── TOP BAR ── */
  .topbar {
    background: var(--brand);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }
.topbar-title {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    flex: 1;
  }
  .topbar-period {
    color: rgba(255,255,255,0.7);
    font-size: 13px;
  }

  .topbar-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.3;
    margin-right: 8px;
  }
  .topbar-clock-time {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    font-variant-numeric: tabular-nums;
  }
  .topbar-clock-date {
    color: rgba(255,255,255,0.75);
    font-size: 11px;
  }

  /* ── EMERGENCY BANNER ── */
  .emergency-banner {
    background: #B45309;
    color: #fff;
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
  }
  .emergency-banner .icon { font-size: 18px; }
  .emergency-banner .ec-pill {
    background: rgba(0,0,0,0.25);
    border-radius: 4px;
    padding: 2px 8px;
    white-space: nowrap;
  }

  /* ── BATTLE PLAN NUDGE BANNER ── */
  #battle-plan-nudge {
    position: sticky;
    top: 56px;           /* flush under the topbar (topbar height = 56px) */
    z-index: 90;         /* above scrolling content, below modals (z-index: 100+) */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    /* Prevent any transform/scale from ancestors collapsing this */
    transform: translateZ(0);
    will-change: transform;
  }
  .bp-nudge-inner {
    background: linear-gradient(135deg,#006064 0%,#00838f 50%,#00bcd4 100%);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
  .bp-nudge-text {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
  }
  .bp-nudge-emoji { font-size: 38px; flex-shrink: 0; line-height: 1; }
  .bp-nudge-heading { color: #fff; font-weight: 700; font-size: 17px; line-height: 1.3; }
  .bp-nudge-sub { color: rgba(255,255,255,0.88); font-size: 13px; margin-top: 3px; line-height: 1.5; }
  .bp-nudge-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .bp-day-btn {
    border: none; border-radius: 8px;
    padding: 11px 20px; font-size: 14px; font-weight: 700; cursor: pointer;
    white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    transition: transform 0.12s, box-shadow 0.12s;
  }
  .bp-day-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.22); }
  .bp-day-btn:active { transform: translateY(0); }
  .bp-day-mon { background: #fff8e1; color: #e65100; }
  .bp-day-wed { background: #e8f5e9; color: #2e7d32; }
  .bp-day-fri { background: #e3f2fd; color: #1565c0; }

  /* ── S14 BATTLE PLAN PAGE ── */

  /* Hero intro */
  .bp-hero {
    background: linear-gradient(135deg, #004d50 0%, #006064 40%, #00838f 75%, #0d9e9e 100%);
    border-radius: 22px;
    padding: 36px 32px 32px;
    color: #fff;
    margin-bottom: 24px;
    box-shadow: 0 12px 48px rgba(0,96,100,0.38);
    position: relative;
    overflow: hidden;
  }
  .bp-hero-glow {
    position: absolute; top: -60px; right: -60px;
    width: 220px; height: 220px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    pointer-events: none;
  }
  .bp-hero-content { position: relative; z-index: 1; }
  .bp-hero-title { font-size: 26px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.3px; }
  .bp-hero-tagline { font-size: 15px; font-weight: 600; opacity: 0.9; margin-bottom: 14px; letter-spacing: 0.2px; }
  .bp-hero-body { font-size: 13.5px; line-height: 1.75; opacity: 0.88; margin: 0 0 22px; max-width: 680px; }
  .bp-hero-pillars { display: flex; gap: 18px; flex-wrap: wrap; }
  .bp-hero-pillar {
    display: flex; align-items: center; gap: 12px;
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 14px; padding: 12px 16px;
    flex: 1; min-width: 180px;
  }
  .bp-hero-pillar-emoji { font-size: 26px; line-height: 1; flex-shrink: 0; }
  .bp-hero-pillar-name { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
  .bp-hero-pillar-desc { font-size: 12px; opacity: 0.82; }

  /* Section label */
  .bp-section-label {
    font-size: 13px; font-weight: 700; color: var(--brand);
    text-transform: uppercase; letter-spacing: 0.8px;
    margin-bottom: 14px;
  }

  /* Day tiles grid */
  .bp-tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
  }

  /* Glass day tile */
  .bp-day-tile {
    border-radius: 20px;
    padding: 26px 22px;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s, border-color 0.25s;
    position: relative; overflow: hidden;
    user-select: none;
    outline: none;
  }
  .bp-day-tile:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
  .bp-day-tile:hover { transform: translateY(-6px); }
  .bp-tile-monday {
    background: linear-gradient(135deg, rgba(230,81,0,0.12) 0%, rgba(255,248,225,0.65) 100%);
    border: 1.5px solid rgba(255,183,77,0.5);
    box-shadow: 0 6px 24px rgba(230,81,0,0.12);
  }
  .bp-tile-monday:hover { box-shadow: 0 16px 48px rgba(230,81,0,0.22); }
  .bp-tile-wednesday {
    background: linear-gradient(135deg, rgba(46,125,50,0.12) 0%, rgba(232,245,233,0.65) 100%);
    border: 1.5px solid rgba(129,199,132,0.5);
    box-shadow: 0 6px 24px rgba(46,125,50,0.12);
  }
  .bp-tile-wednesday:hover { box-shadow: 0 16px 48px rgba(46,125,50,0.22); }
  .bp-tile-friday {
    background: linear-gradient(135deg, rgba(21,101,192,0.12) 0%, rgba(227,242,253,0.65) 100%);
    border: 1.5px solid rgba(144,202,249,0.5);
    box-shadow: 0 6px 24px rgba(21,101,192,0.12);
  }
  .bp-tile-friday:hover { box-shadow: 0 16px 48px rgba(21,101,192,0.22); }
  .bp-tile-active {
    transform: translateY(-4px) !important;
    border-width: 2.5px !important;
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 4px rgba(13,115,119,0.18), 0 16px 48px rgba(0,0,0,0.18) !important;
  }
  .bp-tile-glow {
    position: absolute; top: -40px; right: -40px;
    width: 140px; height: 140px;
    border-radius: 50%;
    pointer-events: none;
  }
  .bp-tile-glow-mon { background: radial-gradient(circle, rgba(255,183,77,0.25) 0%, transparent 70%); }
  .bp-tile-glow-wed { background: radial-gradient(circle, rgba(129,199,132,0.25) 0%, transparent 70%); }
  .bp-tile-glow-fri { background: radial-gradient(circle, rgba(144,202,249,0.25) 0%, transparent 70%); }
  .bp-tile-emoji { font-size: 36px; line-height: 1; margin-bottom: 12px; }
  .bp-tile-day-name { font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
  .bp-tile-day-desc { font-size: 13px; line-height: 1.65; color: var(--text-muted); margin-bottom: 14px; }
  .bp-tile-prompt-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
  .bp-tile-prompt-chip {
    font-size: 11px; font-weight: 600;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 20px; padding: 4px 10px;
    color: var(--text-muted);
  }
  .bp-tile-cta {
    font-size: 12px; font-weight: 700; color: var(--brand);
    letter-spacing: 0.3px; margin-top: 4px;
  }

  /* Entry form glass */
  #bp-entry-form {
    background: linear-gradient(135deg, rgba(13,115,119,0.07) 0%, rgba(255,255,255,0.85) 100%);
    border: 1.5px solid rgba(13,115,119,0.25);
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    margin-bottom: 24px;
    overflow: hidden;
  }
  .bp-form-header {
    display: flex; align-items: center; gap: 16px;
    background: var(--brand);
    padding: 18px 24px;
    color: #fff;
  }
  .bp-form-header-icon { font-size: 24px; line-height: 1; }
  .bp-form-header-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
  .bp-form-header-sub { font-size: 12px; opacity: 0.85; }
  .bp-form-body { padding: 22px 24px; }
  .bp-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .bp-form-group { margin-bottom: 14px; }
  .bp-form-label { font-size: 12px; font-weight: 700; color: var(--brand); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
  .bp-form-input {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--border); border-radius: 10px;
    background: rgba(255,255,255,0.9); color: var(--text);
    font-size: 13px; box-sizing: border-box; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .bp-form-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13,115,119,0.12); }
  .bp-form-textarea { resize: vertical; min-height: 80px; }
  .bp-win-group { margin-bottom: 20px; }
  .bp-win-label { color: #2e7d32 !important; }
  .bp-win-input { background: rgba(232,245,233,0.9) !important; border-color: #a5d6a7 !important; }
  .bp-win-input:focus { border-color: #2e7d32 !important; box-shadow: 0 0 0 3px rgba(46,125,50,0.12) !important; }
  .bp-form-actions { display: flex; align-items: center; gap: 14px; }
  .bp-save-btn { min-width: 130px; }
  .bp-save-status { font-size: 13px; font-weight: 600; color: #2e7d32; }

  /* Journey log card */
  .bp-log-card {
    background: rgba(255,255,255,0.85);
    border: 1.5px solid rgba(13,115,119,0.2);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.07);
  }
  .bp-log-header {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, var(--brand) 0%, #00838f 100%);
    padding: 18px 24px;
    color: #fff;
  }
  .bp-log-header-icon { font-size: 26px; line-height: 1; }
  .bp-log-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
  .bp-log-sub { font-size: 12px; opacity: 0.85; }
  .bp-log-body { padding: 20px 24px; }
  .bp-journal-table { border-collapse: collapse; }
  .bp-journal-table th { background: var(--surface); font-size: 12px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.4px; }

  /* Support card */
  .bp-support-card {
    background: rgba(255,255,255,0.85);
    border: 1.5px solid rgba(13,115,119,0.2);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.07);
  }
  .bp-support-header {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, #004d50 0%, #006064 100%);
    padding: 18px 24px;
    color: #fff;
  }
  .bp-support-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
  .bp-support-sub { font-size: 12px; opacity: 0.85; }
  .bp-support-body { padding: 20px 24px; max-height: 520px; overflow-y: auto; scroll-behavior: smooth; }
  .bp-support-intro { font-size: 13px; line-height: 1.7; color: var(--text-muted); margin-bottom: 20px; }
  .bp-resource-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
  .bp-resource-tile {
    display: flex; align-items: flex-start; gap: 16px;
    background: linear-gradient(135deg, rgba(13,115,119,0.05) 0%, rgba(255,255,255,0.8) 100%);
    border: 1px solid rgba(13,115,119,0.15);
    border-radius: 14px; padding: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .bp-resource-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.09); }
  .bp-resource-icon {
    width: 48px; height: 48px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
  }
  .bp-resource-icon-phone { background: linear-gradient(135deg, #e3f2fd, #90caf9); }
  .bp-resource-icon-text  { background: linear-gradient(135deg, #f3e5f5, #ce93d8); }
  .bp-resource-icon-mind  { background: linear-gradient(135deg, #e8f5e9, #a5d6a7); }
  .bp-resource-icon-nhs   { background: linear-gradient(135deg, #e0f4f4, #80cbcb); }
  .bp-resource-icon-fear  { background: linear-gradient(135deg, #fff8e1, #ffe082); }
  .bp-resource-name { font-size: 14px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
  .bp-resource-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; line-height: 1.55; }
  .bp-resource-contact { font-size: 13px; color: var(--text); }
  .bp-honest-note {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border: 1px solid #ffcc80;
    border-radius: 14px; padding: 18px;
  }
  .bp-honest-note-title { font-weight: 700; font-size: 13px; color: #e65100; margin-bottom: 10px; }
  .bp-honest-note p { margin: 0 0 10px; font-size: 13px; line-height: 1.7; color: var(--text); }

  /* ── END S14 BATTLE PLAN PAGE ── */

  /* ── PATIENT HEADER ── */
  .patient-header {
    background: var(--brand);
    padding: 20px 24px 24px;
    color: #fff;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .patient-name {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
  }
  .patient-ids {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 16px;
  }
  .patient-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-top: 12px;
  }
  .stat-pill {
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(255,255,255,0.55);
    border-radius: 16px;
    padding: 10px 14px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.05);
    backdrop-filter: blur(4px);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }
  .stat-pill .label {
    font-size: 10px;
    font-weight: 600;
    color: #0d7377;
    opacity: 0.75;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .stat-pill .value {
    font-size: 16px;
    font-weight: 700;
    display: block;
    color: #0d6b70;
    line-height: 1.2;
  }
  .stat-pill.editable { cursor: pointer; }
  .stat-pill.editable:hover {
    background: rgba(255,255,255,1);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.10), 0 4px 6px -2px rgba(0,0,0,0.05);
  }
  .stat-pill.editable .edit-hint {
    font-size: 9px;
    font-weight: 500;
    color: #0d7377;
    opacity: 0.55;
    display: block;
    margin-top: 3px;
    letter-spacing: 0.2px;
  }
  /* Weight quick-update modal — fixed overlay so it escapes overflow:clip parents */
  .weight-popover-backdrop {
    display: none; position: fixed; inset: 0; z-index: 99998;
    background: rgba(0,0,0,0.45); align-items: center; justify-content: center;
  }
  .weight-popover-backdrop.open { display: flex; }
  .weight-popover {
    background: #fff; border: 2px solid var(--brand); border-radius: 12px;
    padding: 20px 22px; box-shadow: 0 8px 40px rgba(0,0,0,0.3); z-index: 99999;
    min-width: 220px; max-width: 90vw; width: 280px;
    position: relative;
  }
  .weight-popover-title { font-size: 14px; font-weight: 700; color: var(--brand); margin-bottom: 12px; text-align: center; }
  .weight-popover label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 6px; }
  .weight-popover input { width: 100%; padding: 9px 10px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 16px; box-sizing: border-box; }
  .weight-popover input:focus { border-color: var(--brand); outline: none; }
  .weight-popover button.wp-save { margin-top: 10px; width: 100%; padding: 10px; background: var(--brand); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 600; min-height: 44px; }
  .weight-popover button.wp-save:hover { opacity: 0.9; }
  .weight-popover button.wp-cancel { margin-top: 6px; width: 100%; padding: 8px; background: none; color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 13px; min-height: 40px; }
  .stat-pill.bg-low    { background: #fde8e8; border-color: #e53e3e; }
  .stat-pill.bg-low    .label { color: #9b1c1c; }
  .stat-pill.bg-low    .value { color: #e53e3e; }
  .stat-pill.bg-high   { background: #fff3cd; border-color: #d97706; }
  .stat-pill.bg-high   .label { color: #92400e; }
  .stat-pill.bg-high   .value { color: #b45309; }
  .stat-pill.bg-very-high { background: #fde8e8; border-color: #e53e3e; }
  .stat-pill.bg-very-high .label { color: #9b1c1c; }
  .stat-pill.bg-very-high .value { color: #e53e3e; }
  /* Blood-type pill */
  .stat-pill.blood-type { background: #fce8f3; border-color: #b91c6a; }
  .stat-pill.blood-type .label { color: #831843; }
  .stat-pill.blood-type .value { color: #be185d; font-size: 17px; }

  /* BMI-specific pill states */
  .stat-pill.bmi-underweight { background: #e0f0ff; border-color: #3b82f6; }
  .stat-pill.bmi-underweight .label { color: #1e40af; }
  .stat-pill.bmi-underweight .value { color: #1d4ed8; }
  .stat-pill.bmi-normal { background: #d1fae5; border-color: #10b981; }
  .stat-pill.bmi-normal .label { color: #065f46; }
  .stat-pill.bmi-normal .value { color: #059669; }
  .stat-pill.bmi-overweight { background: #fff3cd; border-color: #d97706; }
  .stat-pill.bmi-overweight .label { color: #92400e; }
  .stat-pill.bmi-overweight .value { color: #b45309; }
  .stat-pill.bmi-obese { background: #fde8e8; border-color: #e53e3e; }
  .stat-pill.bmi-obese .label { color: #9b1c1c; }
  .stat-pill.bmi-obese .value { color: #e53e3e; }

  /* ── PATIENT HEADER LAYOUT (vertical stack) ── */
  .patient-header-identity {
    margin-bottom: 12px;
  }
  #next-appt-badge {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    opacity: 0.92;
    margin: 4px 0 6px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
  }
  .patient-header-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    margin-bottom: 14px;
  }
  .daily-log-btn {
    background: rgba(255,255,255,0.14);
    border: 1.5px solid rgba(255,255,255,0.35);
    color: #fff;
    border-radius: 50px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.1px;
    transition: all 0.2s ease;
    backdrop-filter: blur(6px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.10), 0 2px 4px -1px rgba(0,0,0,0.06);
  }
  .daily-log-btn:hover,
  .daily-log-btn:focus-visible {
    background: rgba(255,255,255,0.26);
    border-color: rgba(255,255,255,0.6);
    transform: scale(1.03);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.10), 0 4px 6px -2px rgba(0,0,0,0.05);
  }
  .daily-log-btn:active { transform: scale(0.98); box-shadow: 0 2px 4px -1px rgba(0,0,0,0.08); }

  /* ── DAILY LOG MODAL ── */
  .dlm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
  }
  .dlm-overlay.open { display: flex; }
  .dlm-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    width: min(560px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .dlm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
  }
  .dlm-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
  }
  .dlm-close:hover { opacity: 1; }
  .dlm-body {
    padding: 20px;
    overflow-y: auto;
  }
  .dlm-date-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
  }
  .dlm-date-row label { font-weight: 600; font-size: 13px; min-width: 40px; }
  .dlm-date-row input { flex: 1; }
  .dlm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .dlm-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  .dlm-field input { width: 100%; box-sizing: border-box; }
  /* Theme all inputs / selects / textareas inside every quick-entry modal   */
  .dlm-body input,
  .dlm-body select,
  .dlm-body textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .dlm-body input:focus,
  .dlm-body select:focus,
  .dlm-body textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(13,115,119,0.18);
  }
  .dlm-body select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%230d7377'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 6px;
    padding-right: 28px;
  }
  .dlm-body textarea { resize: vertical; min-height: 70px; }
  /* Date/time inputs inside modals — calendar icon already themed globally */
  .dlm-body input[type="date"],
  .dlm-body input[type="time"] {
    background-image: none; /* let the global date rule handle the icon */
  }
  .dlm-body input[type="date"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230d7377' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 15px 15px;
    padding-right: 32px;
  }
  .dlm-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
    justify-content: flex-end;
  }
  .dlm-status {
    font-size: 13px;
    color: var(--success);
    font-weight: 600;
    margin-right: auto;
  }
  .row-del-btn {
    background: none; border: none; color: #cc0000; font-size: 16px;
    cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1;
    opacity: 0.6; transition: opacity 0.15s;
  }
  .row-del-btn:hover { opacity: 1; background: #fff0f0; }
  .am-pill {
    padding: 7px 14px; font-size: 13px; font-family: inherit; cursor: pointer;
    border: 1.5px solid var(--border); border-radius: 8px;
    background: var(--surface2); color: var(--text); transition: all 0.15s;
    text-align: left; width: 100%;
  }
  .am-pill.selected {
    background: var(--brand); color: #fff; border-color: var(--brand);
  }

  /* ── LAYOUT ── */
  .layout {
    display: flex;
    min-height: calc(100vh - 56px);
  }

  /* ── SIDEBAR (fixed overlay) ── */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    height: 100vh;
    z-index: 1000;
    background: var(--surface);
    border-right: 2px solid var(--border);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    padding: 16px 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.28s ease-in-out;
  }
  .sidebar.open { transform: translateX(0); }

  /* Backdrop that closes the sidebar on outside click */
  #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0,0,0,0.35);
  }
  #sidebar-backdrop.open { display: block; }
  .sidebar-section-label {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
  }
  .nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    transition: all 0.15s;
    line-height: 1.3;
  }
  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
    border-left-color: var(--brand);
  }
  .nav-item .num {
    font-size: 11px;
    background: var(--surface3);
    color: var(--text-light);
    border-radius: 4px;
    padding: 1px 5px;
    flex-shrink: 0;
    font-weight: 600;
  }
  .nav-item.active .num {
    background: var(--brand);
    color: #fff;
  }

  /* ── USER GUIDE NAV DROPDOWN ── */
  .nav-guide-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    transition: all 0.15s;
    line-height: 1.3;
    user-select: none;
  }
  .nav-guide-toggle:hover { background: var(--surface2); color: var(--text); }
  .nav-guide-toggle.open { color: var(--brand); font-weight: 600; }
  .nav-guide-toggle .guide-arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
  }
  .nav-guide-toggle.open .guide-arrow { transform: rotate(180deg); }
  .nav-guide-submenu {
    display: none;
    background: var(--surface2);
    border-left: 3px solid var(--brand);
    margin-left: 0;
  }
  .nav-guide-submenu.open { display: block; }
  .nav-guide-submenu .nav-sub-item {
    padding: 7px 16px 7px 28px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    border-left: none;
  }
  .nav-guide-submenu .nav-sub-item:hover { background: var(--surface3); color: var(--text); }
  .nav-guide-submenu .nav-sub-item.active { color: var(--brand); font-weight: 600; }

  /* ── USER GUIDE PAGE ── */
  .guide-section-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
  }
  .guide-section-selector label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
  }
  .guide-section-selector select {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
  }
  .guide-section-selector select:focus {
    outline: none;
    border-color: var(--brand);
  }
  .guide-panel { display: none; }
  .guide-panel.active { display: block; }
  .guide-intro {
    background: linear-gradient(135deg, var(--brand-light), var(--surface2));
    border-left: 4px solid var(--brand);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
  }
  .guide-intro strong { color: var(--brand); }
  .guide-term-list { list-style: none; padding: 0; margin: 0; }
  .guide-term-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    line-height: 1.6;
  }
  .guide-term-list li:last-child { border-bottom: none; }
  .guide-term-list li strong {
    display: block;
    color: var(--brand);
    font-size: 14px;
    margin-bottom: 3px;
  }
  .guide-tip {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #5d4037;
  }
  .guide-tip::before { content: "💡 Tip: "; font-weight: 700; }

  /* ── MAIN CONTENT ── */
  .main {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: 24px;
    overflow-x: clip;
    box-sizing: border-box;
  }

  /* ── HAMBURGER BUTTON ── */
  .topbar-menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.15s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .topbar-menu-btn:hover { background: rgba(255,255,255,0.15); }
  .menu-icon { font-size: 20px; line-height: 1; }
  .menu-text { font-size: 14px; font-weight: 600; margin-left: 6px; letter-spacing: 0.02em; }

  .section-page { display: none; }
  .section-page.active { display: block; }

  /* ── CARDS ── */
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: clip;
    margin-bottom: 20px;
  }
  .card-header {
    background: var(--brand);
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .card-header h2 { font-size: 15px; font-weight: 600; flex: 1; }
  .card-header .badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
  }
  .card-body { padding: 20px; }
  .card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    font-style: italic;
  }

  /* ── ALERT CARD ── */
  .alert-card {
    border-left: 4px solid;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
  }
  .alert-card.danger { background: #fef2f2; border-color: var(--danger); }
  .alert-card.warning { background: #fffbeb; border-color: var(--warning); }
  .alert-card.info { background: var(--brand-light); border-color: var(--brand-mid); }
  .alert-card .icon { font-size: 18px; line-height: 1; flex-shrink: 0; margin-top: 1px; }
  .alert-card .content .title { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
  .alert-card .content .desc { font-size: 13px; color: var(--text-muted); }
  .alert-card.danger .title { color: var(--danger); }
  .alert-card.warning .title { color: #92400e; }
  .alert-card.info .title { color: var(--brand); }

  /* ── FIELD GRID ── */
  .field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
  }
  .field-group { display: flex; flex-direction: column; gap: 4px; }
  .field-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .field-group .value {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    min-height: 36px;
    display: flex;
    align-items: center;
  }
  .field-group input, .field-group textarea, .field-group select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
  }
  .field-group input:focus, .field-group textarea:focus, .field-group select:focus {
    border-color: var(--brand-mid);
    box-shadow: 0 0 0 3px rgba(0,114,206,0.12);
  }
  .field-group textarea { resize: vertical; min-height: 60px; }

  /* ── EDITABLE TABLE ── */
  .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
  }
  .data-table th {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--brand-mid);
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .data-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }
  .data-table tr:last-child td { border-bottom: none; }
  .data-table tr:nth-child(even) td { background: var(--surface2); }
  .data-table td input, .data-table td select {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 13px;
    padding: 5px 6px;
    color: var(--text);
    font-family: inherit;
    outline: none;
    border-radius: 4px;
  }
  .data-table td input[type="time"] {
    min-width: 88px;   /* ensure HH:MM display never clips */
  }
  .data-table td input[type="date"] {
    min-width: 120px;  /* ensure YYYY-MM-DD display never clips */
  }

  /* ── THEMED DATE / TIME PICKERS (universal) ─────────────────────────── */
  /* Native date picker popup is fully replaced by the custom JS calendar.  */
  /* We keep color-scheme:light so the browser doesn't apply a dark-mode    */
  /* fallback on OS dark-mode, and hide the native indicator entirely.      */
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    accent-color: var(--brand);
    color-scheme: light;
  }
  /* Hide the browser's native calendar/clock icon — the JS popup replaces  */
  /* it for date; time keeps the native spinner which can't be replaced.    */
  input[type="date"]::-webkit-calendar-picker-indicator {
    display: none !important;
  }
  /* Show a styled custom calendar icon via background on date inputs that  */
  /* are inside a field-group (standalone cards) or data-table cells.       */
  /* Uses an inline NHS-teal SVG calendar so no extra HTTP request.         */
  .field-group input[type="date"],
  .data-table td input[type="date"],
  .tpn-row input[type="date"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230d7377' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 15px 15px;
    padding-right: 28px;
    cursor: pointer;
  }
  /* time inputs — style the native clock indicator to match site colour    */
  input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    border-radius: 3px;
    padding: 2px;
    filter: invert(29%) sepia(62%) saturate(480%) hue-rotate(147deg) brightness(85%) contrast(105%);
    opacity: 0.7;
    transition: opacity 0.15s;
  }
  input[type="time"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
  /* Focus rings */
  .field-group input[type="date"]:focus,
  .field-group input[type="time"]:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(13,115,119,0.18);
  }
  .data-table td input[type="date"]:focus,
  .data-table td input[type="time"]:focus {
    background-color: var(--surface2);
    box-shadow: 0 0 0 2px rgba(13,115,119,0.25);
  }
  .data-table td select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%230d7377'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 6px;
    border: 1.5px solid var(--brand);
    border-radius: 6px;
    padding: 5px 26px 5px 8px;
    width: 100%;
    cursor: pointer;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
  }
  .data-table td select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(13,115,119,0.25);
  }
  .data-table td input:focus, .data-table td select:focus {
    background: var(--surface2);
    box-shadow: 0 0 0 2px rgba(13,115,119,0.25);
  }
  /* Custom dropdown for table cells (escapes overflow:auto clipping) */
  .cd-trigger {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 5px 8px; font-size: 13px; font-family: inherit;
    color: var(--text); background: var(--surface); border: 1.5px solid var(--brand);
    border-radius: 6px; cursor: pointer; user-select: none; box-sizing: border-box;
  }
  .cd-trigger .cd-arrow { font-size: 9px; margin-left: 6px; color: #555; }
  .cd-popup {
    position: fixed; z-index: 10000; background: #fff;
    border: 1px solid var(--border); border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15); min-width: 130px;
    max-height: 260px; overflow-y: auto; overscroll-behavior: contain;
  }
  .cd-popup .cd-opt {
    padding: 8px 12px; font-size: 13px; font-family: inherit;
    cursor: pointer; color: var(--text);
  }
  .cd-popup .cd-opt:hover, .cd-popup .cd-opt.cd-selected { background: var(--surface2); }
  .cd-popup .cd-opt.cd-selected { font-weight: 600; }
  .data-table .day-label {
    font-weight: 600;
    color: var(--brand);
    font-size: 12px;
    white-space: nowrap;
    padding: 6px 10px;
  }
  .data-table .row-note {
    font-size: 11px;
    color: var(--danger);
    font-weight: 600;
    padding: 4px 10px;
    background: #fef2f2;
  }

  /* ── RED FLAG ROW ── */
  .data-table tr.red-flag td { background: #fff5f5 !important; }

  /* ── CONTACT CARD GRID ── */
  .contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
  }
  .contact-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
  }
  .contact-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
  }
  .contact-avatar.green { background: var(--success); }
  .contact-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
  .contact-role { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
  .contact-tel { font-size: 13px; color: var(--brand-mid); font-weight: 600; }

  /* ── TPN TABLE ── */
  .tpn-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    border-bottom: 1px solid var(--border);
  }
  .tpn-row:last-child { border-bottom: none; }
  .tpn-key {
    background: var(--surface2);
    padding: 10px 14px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
  }
  .tpn-val {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
  }

  /* ── SECTION OVERVIEW GRID ── */
  .overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
  }
  .overview-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    gap: 12px;
    align-items: flex-start;
  }
  .overview-tile:hover {
    border-color: var(--brand-mid);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
  }
  .overview-tile .tile-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: var(--brand-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
  }
.overview-tile .tile-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
  }

  /* ── MOOD / BG indicator ── */
  .bg-normal { color: var(--success); font-weight: 700; }
  .bg-high { color: var(--danger); font-weight: 700; }
  .bg-low { color: var(--warning); font-weight: 700; }

  /* ── BUTTONS ── */
  .btn {
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid;
    font-family: inherit;
    transition: all 0.15s;
  }
  .btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
  }
  .btn-primary:hover { background: #002570; }
  .btn-outline {
    background: transparent;
    color: var(--brand);
    border-color: var(--brand);
  }
  .btn-outline:hover { background: var(--brand-light); }
  .btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
  }
  .btn-del-row {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
  }
  .btn-del-row:hover { color: var(--danger); background: #fde8e8; }
  .btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    align-items: center;
  }
  .save-status {
    font-size: 12px;
    color: var(--success);
    display: none;
    align-items: center;
    gap: 4px;
  }
  .save-status.visible { display: flex; }
  .save-status.draft-unsaved {
    display: flex;
    color: #b45309;
    font-weight: 600;
  }

  /* ── DRAFT RESTORE BANNER ── */
  .draft-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    flex-wrap: wrap;
  }
  .draft-banner-icon { font-size: 16px; flex-shrink: 0; }
  .draft-banner-text { flex: 1; color: #92400e; font-weight: 500; }
  .draft-restore-btn { font-size: 12px; padding: 5px 12px; white-space: nowrap; }
  .draft-dismiss-btn {
    background: none; border: none; cursor: pointer;
    color: #92400e; font-size: 16px; line-height: 1;
    padding: 2px 4px; opacity: 0.6; flex-shrink: 0;
  }
  .draft-dismiss-btn:hover { opacity: 1; }

  @media (max-width: 700px) {
    .draft-banner { gap: 8px; padding: 10px 12px; }
    .draft-banner-text { width: 100%; }
    .draft-restore-btn { flex: 1; text-align: center; }
  }

  /* ── BATTLE PLAN JOURNEY MODAL ── */
  .bp-journey-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.55);
    z-index: 9000; display: flex; align-items: center; justify-content: center;
    padding: 20px; box-sizing: border-box;
  }
  .bp-journey-dialog {
    background: var(--surface3); border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    width: 100%; max-width: 520px; max-height: 90vh;
    overflow-y: auto; position: relative; padding: 28px 28px 24px;
    box-sizing: border-box;
  }
  .bp-journey-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--text-muted); line-height: 1; padding: 4px 8px;
    border-radius: 6px; transition: background 0.15s;
  }
  .bp-journey-close:hover { background: var(--surface); }
  .bp-journey-header {
    display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
    padding-bottom: 16px; border-bottom: 1px solid var(--border);
  }
  .bp-journey-emoji { font-size: 40px; line-height: 1; flex-shrink: 0; }
  .bp-journey-day { font-size: 18px; font-weight: 700; color: var(--brand); }
  .bp-journey-week { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
  .bp-journey-body { display: flex; flex-direction: column; gap: 14px; }
  .bp-jm-field { background: var(--surface); border-radius: 10px; padding: 14px; }
  .bp-jm-label { font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; color: var(--text-muted); margin-bottom: 6px; }
  .bp-jm-value { font-size: 14px; color: var(--text); line-height: 1.6; }
  .bp-jm-note { white-space: pre-wrap; }
  .bp-jm-win-box {
    background: #e8f5e9; border: 1px solid #a5d6a7; border-radius: 10px; padding: 16px;
  }
  .bp-jm-win-box .bp-jm-label { color: #2e7d32; }
  .bp-jm-win-text { font-size: 15px; font-weight: 600; color: #1b5e20; line-height: 1.5; }
  .bp-journey-row { cursor: pointer; transition: background 0.15s; }
  .bp-journey-row:hover { background: var(--surface) !important; }

  /* ── CALENDAR ROUTE TOAST ── */
  .cal-route-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1a6b4a;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 9999;
    max-width: 280px;
  }
  .cal-route-toast.visible { opacity: 1; }
  @media (max-width: 700px) {
    .cal-route-toast { bottom: 16px; right: 12px; left: 12px; max-width: none; }
  }

  /* ── ROUTED APPOINTMENT ROWS (auto-synced from source sections) ── */
  tr[data-routed="1"] td {
    background: color-mix(in srgb, var(--surface) 60%, var(--brand) 8%);
  }
  tr[data-routed="1"] input[readonly] {
    background: transparent;
    border: 1px solid transparent;
    cursor: default;
    color: var(--text);
    opacity: 0.85;
    pointer-events: none;
  }
  .appt-routed-val {
    display: block;
    font-size: 12px;
    color: var(--text);
    opacity: 0.85;
    padding: 4px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }
  .appt-routed-badge {
    font-size: 12px;
    margin-right: 4px;
    cursor: default;
    opacity: 0.7;
  }

  /* ── DATA BRIDGES ── */
  .bridge-card { border-left: 3px solid var(--brand); }
  .bridge-live-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #1a6b4a;
    background: #e6f4ed;
    border: 1px solid #a3d9b8;
    border-radius: 10px;
    padding: 1px 8px;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.02em;
  }
  .bridge-table { font-size: 12px; margin-bottom: 6px; }
  .bridge-table th, .bridge-table td { padding: 4px 8px; }
  .bridge-empty {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 0;
  }
  .bridge-empty a { color: var(--brand); }
  .bridge-footer {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .bridge-footer a { color: var(--brand); text-decoration: none; }
  .bridge-footer a:hover { text-decoration: underline; }

  /* ── GLOSSARY TABLE ── */
  .glossary-table { width: 100%; border-collapse: collapse; }
  .glossary-table th, .glossary-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 13px;
  }
  .glossary-table th {
    background: var(--surface2);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
  }
  .glossary-table .term { font-weight: 700; color: var(--brand); }

  /* ── SECTION HEADER ── */
  .section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
  }
  .section-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--brand);
  }
  .section-header .back-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 20px;
    padding: 4px;
    display: none;
    border-radius: 4px;
  }
  .section-header .back-btn:hover { color: var(--brand); background: var(--brand-light); }

  /* ── CALENDAR NAV ── */
  .cal-nav {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    width: fit-content;
  }
  .cal-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 16px;
    font-size: 18px;
    color: var(--brand);
    line-height: 1;
    transition: background 0.15s;
    font-family: inherit;
  }
  .cal-nav-btn:hover { background: var(--brand-light); }
  .cal-nav-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand);
    padding: 10px 20px;
    min-width: 180px;
    text-align: center;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    white-space: nowrap;
  }
  .cal-nav-today {
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-mid);
    font-family: inherit;
    transition: background 0.15s;
  }
  .cal-nav-today:hover { background: var(--brand-light); }

  /* ── NOTES AREA ── */
  .notes-area {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
  }
  .notes-area label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 6px;
  }
  .notes-area textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    resize: vertical;
    background: var(--surface);
    outline: none;
    min-height: 80px;
  }
  .notes-area textarea:focus {
    border-color: var(--brand-mid);
    box-shadow: 0 0 0 3px rgba(0,114,206,0.12);
  }

  /* ── SITE FOOTER ── */
  #site-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--brand-dark);
    color: rgba(255,255,255,0.75);
    font-size: 11px;
    padding: 5px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    z-index: 200;
    white-space: nowrap;
    overflow: hidden;
  }
  #site-footer-patient {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  #site-footer-patient span {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  #site-footer-patient span strong {
    color: #fff;
    font-weight: 600;
  }
  #site-footer-patient .footer-sep {
    color: rgba(255,255,255,0.3);
  }
  #site-footer-copy {
    flex-shrink: 0;
    opacity: 0.6;
  }
  .main { padding-bottom: 36px; }

  /* ── PRINT ── */
  @media print {
    .sidebar, .topbar, .btn-row, .emergency-banner, #battle-plan-nudge, .patient-header,
    .cal-nav, .cal-nav-today, #preview-card .card-header button,
    #site-footer { display: none !important; }
    .main { padding: 0; }
    .section-page { display: block !important; }
    .card { box-shadow: none; break-inside: avoid; }
    body { background: #fff; }
  }
  /* ── EXPORT RANGE BUTTONS ── */
  .export-range-btn.active, .export-qr-btn.active, .export-recipient-btn.active {
    background: var(--brand) !important;
    color: #fff !important;
    border-color: var(--brand) !important;
  }
  /* ── SUMMARY PREVIEW STYLES ── */
  .sum-header { background: var(--brand); color:#fff; padding:14px 18px; border-radius:var(--radius); margin-bottom:16px; }
  .sum-header h2 { font-size:16px; font-weight:700; }
  .sum-header p { font-size:12px; opacity:0.8; margin-top:3px; }
  .sum-section { margin-bottom:18px; border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
  .sum-section-title { background:var(--brand-light); color:var(--brand); font-weight:700; font-size:12px; text-transform:uppercase; letter-spacing:0.5px; padding:8px 14px; border-bottom:1px solid var(--border); }
  .sum-section-body { padding:12px 14px; }
  .sum-row { display:flex; gap:8px; border-bottom:1px solid var(--border); padding:5px 0; font-size:12px; }
  .sum-row:last-child { border-bottom:none; }
  .sum-key { color:var(--text-muted); min-width:110px; flex-shrink:0; }
  .sum-val { color:var(--text); font-weight:500; }
  .sum-alert { background:#fef2f2; border-left:3px solid var(--danger); padding:7px 10px; border-radius:4px; font-size:12px; font-weight:600; color:var(--danger); margin-bottom:8px; }
  .sum-table { width:100%; border-collapse:collapse; font-size:11px; }
  .sum-table th { background:var(--brand-light); color:var(--brand); padding:5px 7px; text-align:left; font-weight:700; border-bottom:1px solid var(--border); }
  .sum-table td { padding:4px 7px; border-bottom:1px solid var(--border); }
  .sum-table tr:last-child td { border-bottom:none; }
  .sum-generated { font-size:11px; color:var(--text-light); text-align:right; margin-top:12px; }

  /* ── RESPONSIVE ── */
  @media (max-width: 700px) {

    /* ── TOPBAR ── */
    /* ── TOPBAR: two-row layout on mobile ── */
    .topbar {
      padding: 0;
      height: auto;
      flex-wrap: wrap;
      gap: 0;
      align-items: stretch;
    }
    /* Row 1: menu btn + logo + title (clock hidden from row 1) */
    .topbar-menu-btn {
      order: 1; min-height: 44px; min-width: 44px;
      padding: 6px 10px; flex-shrink: 0;
    }
    .topbar-logo-wrap { order: 2; width: 26px; height: 26px; align-self: center; flex-shrink: 0; }
    .topbar-title {
      order: 3; flex: 1; font-size: 14px; font-weight: 700;
      padding: 0 8px; white-space: nowrap; overflow: hidden;
      text-overflow: ellipsis; display: flex; align-items: center;
    }
    /* Row 2: full-width user strip (clock now lives inside .topbar-user) */
    .topbar-user {
      order: 4;
      width: 100%;
      display: flex;
      align-items: center;
      gap: 8px;
      background: rgba(0,0,0,0.20);
      border-top: 1px solid rgba(255,255,255,0.12);
      padding: 4px 10px;
      flex-wrap: nowrap;
    }
    .topbar-name-btn { font-size: 12px; font-weight: 600; flex: 1; text-align: left; min-height: 34px; padding: 2px 4px; }
    .topbar-wizard-btn { font-size: 11px; padding: 4px 8px; min-height: 34px; white-space: nowrap; }
    .topbar-logout { font-size: 11px; padding: 4px 8px; min-height: 34px; white-space: nowrap; }
    .topbar-clock { margin-right: 0; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
    .topbar-clock-time { font-size: 11px; font-weight: 700; }
    .topbar-clock-date { font-size: 10px; color: rgba(255,255,255,0.65); }
    .topbar-period { display: none; }

    /* ── EMERGENCY BANNER ── */
    .emergency-banner { font-size: 11px; padding: 8px 12px; }

    /* ── LAYOUT ── */
    .main {
      padding: 12px;
      overflow-x: clip;
      width: 100%;
      min-width: 0;
      box-sizing: border-box;
    }

    /* ── CARDS ── */
    .card { margin-bottom: 12px; }
    .card-body { padding: 12px; }

    /* ── TABLES ── */
    /* Wrap every overflow-x:auto div in a proper scroll region */
    [style*="overflow-x:auto"],
    [style*="overflow-x: auto"] {
      display: block !important;
      width: 100% !important;
      max-width: 100% !important;
      overflow-x: scroll !important;       /* scroll (not auto) — always shows on Android */
      -webkit-overflow-scrolling: touch;
      box-sizing: border-box;
    }
    /* Table scroll wrappers — no right-edge fade, just clean horizontal scroll */
    .table-scroll-wrapper {
      -webkit-mask-image: none !important;
      mask-image: none !important;
    }

    /* Shrink table font + padding so content is readable while scrolling */
    .data-table { font-size: 12px; }
    .data-table th { padding: 7px 5px; font-size: 10px; letter-spacing: 0; }
    .data-table td { padding: 4px 5px; }
    .data-table input[type="text"],
    .data-table input:not([type]) {
      font-size: 12px;
      padding: 4px 5px;
      min-width: 0;
      width: 100%;
      box-sizing: border-box;
    }

    /* Force wide tables to be wider than the wrapper so scroll activates */
    #page-s7 .data-table { min-width: 540px; }
    #page-s5 .data-table { min-width: 560px; }
    #page-s5 .data-table td input[type="text"] { width: 100%; box-sizing: border-box; }
    #page-s3a .data-table,
    #page-s3b .data-table,
    #page-s8 .data-table,
    #page-s9 .data-table { min-width: 420px; }

    /* Custom dropdown smaller on mobile */
    .cd-trigger { font-size: 12px; padding: 4px 6px; }

    /* ── BUTTON ROWS ── */
    .btn-row {
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
    }
    .btn-row .btn,
    .btn-row button.btn {
      width: 100%;
      text-align: center;
      justify-content: center;
      box-sizing: border-box;
    }

    /* ── SECTION HEADER ── */
    .section-header { margin-bottom: 12px; }
    .section-header h1 { font-size: 15px; white-space: normal; line-height: 1.3; }
    .section-header .back-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
      background: var(--brand);
      color: #fff;
      border: none;
      border-radius: 20px;
      padding: 7px 14px;
      font-size: 13px;
      font-weight: 600;
      cursor: pointer;
      box-shadow: 0 2px 6px rgba(0,0,0,0.18);
    }

    .mobile-wizard-btn { display:flex; }

    /* ── INDEX OVERVIEW ── */
    .overview-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }

    /* ── PATIENT STATS ── */
    .patient-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat-card { padding: 10px 6px; }
    .stat-value { font-size: 18px; }

    /* ── PATIENT HEADER ── */
    .patient-header { padding: 14px 12px 16px; }
    .patient-name { font-size: 17px; }
    #next-appt-badge { font-size: 13px; }
    /* Button row: 3-column grid on mobile so buttons are equal size */
    .patient-header-actions {
      display: grid !important;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
    }
    .daily-log-btn {
      flex: unset;
      white-space: normal;
      font-size: 12px;
      padding: 10px 14px;
      text-align: center;
      min-height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      box-sizing: border-box;
      border-radius: 50px;
    }

    /* ── MODALS (Add Medication / Add Appointment / Daily Log) ── */
    .dlm-overlay { padding: 12px; align-items: flex-end; }
    .dlm-box {
      width: 100% !important;
      max-width: 100% !important;
      max-height: 85vh;
      border-radius: 12px 12px 0 0;   /* sheet slides up from bottom */
    }
    .dlm-body { padding: 14px; }
    .dlm-header { padding: 12px 16px; font-size: 14px; }
    .dlm-grid { grid-template-columns: 1fr !important; }  /* single column on mobile */
    .dlm-footer {
      flex-wrap: wrap;
      gap: 8px;
      padding: 12px 14px;
    }
    .dlm-footer .btn {
      flex: 1;
      text-align: center;
      min-width: 100px;
    }

    /* ── BATTLE PLAN NUDGE: stick below 48px topbar on mobile ── */
    #battle-plan-nudge { top: 48px; }
    .bp-nudge-inner {
      flex-direction: column;
      align-items: stretch;
      padding: 12px 14px;
      gap: 10px;
      box-sizing: border-box;
      overflow: hidden;
    }
    .bp-nudge-text { gap: 10px; }
    .bp-nudge-emoji { font-size: 26px; }
    .bp-nudge-heading { font-size: 14px; }
    .bp-nudge-sub { font-size: 11px; }
    .bp-nudge-actions {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
      width: 100%;
    }
    .bp-day-btn {
      font-size: 11px !important;
      padding: 8px 4px !important;
      white-space: normal !important;
      line-height: 1.3;
      border-radius: 6px;
      word-break: break-word;
      min-height: 54px;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      text-align: center !important;
    }

    /* ── S14 BATTLE PLAN MOBILE ── */
    .bp-hero { padding: 24px 18px; border-radius: 16px; }
    .bp-hero-title { font-size: 20px; }
    .bp-hero-tagline { font-size: 13px; }
    .bp-hero-body { font-size: 13px; }
    .bp-hero-pillars { flex-direction: column; gap: 10px; }
    .bp-tiles-grid { grid-template-columns: 1fr; }
    .bp-form-row { grid-template-columns: 1fr; }
    .bp-form-body { padding: 16px; }
    .bp-log-body, .bp-support-body { padding: 14px 16px; }
    .bp-log-header, .bp-support-header, .bp-form-header { padding: 14px 16px; }

    /* ── FIELD GRIDS: single column on mobile ── */
    .field-grid,
    .field-grid[style*="grid-template-columns"] {
      grid-template-columns: 1fr !important;
    }
    /* full-width overrides still respected */
    .field-grid .field-group[style*="grid-column"] {
      grid-column: 1 / -1 !important;
    }

    /* ── BUTTONS: minimum 44px touch target ── */
    .btn {
      min-height: 44px;
      padding: 10px 16px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }

    /* ── ROW DELETE BUTTONS: bigger touch target ── */
    .row-del-btn {
      padding: 8px 10px;
      font-size: 18px;
      min-width: 36px;
      min-height: 36px;
    }

    /* ── STAT PILLS: ensure min touch height ── */
    .stat-pill {
      min-height: 44px;
      display: flex;
      flex-direction: column;
      justify-content: center;
    }

    /* ── TPN ROW: stack label above value ── */
    .tpn-row {
      grid-template-columns: 1fr;
    }
    .tpn-key {
      border-right: none;
      border-bottom: 1px solid var(--border);
      padding: 6px 12px 4px;
    }
    .tpn-val {
      padding: 4px 12px 8px;
    }

    /* ── CALENDAR NAV: shrink month label so buttons stay on screen ── */
    .cal-nav-label {
      min-width: 120px;
      font-size: 14px;
      padding: 8px 10px;
    }

    /* ── GUIDE SECTION SELECTOR: stack vertically ── */
    .guide-section-selector {
      flex-direction: column;
      align-items: stretch;
    }
    .guide-section-selector select {
      min-width: 0;
      width: 100%;
    }

    /* ── WIZARD FIELD GRID: single column ── */
    .wizard-field-grid {
      grid-template-columns: 1fr !important;
    }

    /* ── DATE PICKER: don't overflow viewport ── */
    #date-picker-popup {
      width: min(276px, calc(100vw - 24px));
    }

    /* ── WEIGHT POPOVER: bound to viewport ── */
    .weight-popover {
      min-width: 0;
      width: calc(100vw - 48px);
      max-width: 260px;
      left: 0;
      transform: none;
    }

    /* ── FOOTER: slightly more readable ── */
    #site-footer {
      font-size: 12px;
    }

    /* ── MODAL HEIGHT: protect landscape/short screens ── */
    .dlm-box {
      max-height: 80vh;
    }

    /* ── TABLES: ensure all section tables have min-width for horizontal scroll ── */
    #page-s6 .data-table,
    #page-s7 .data-table,
    #page-s13 .data-table,
    #page-s14 .data-table,
    #page-s18 .data-table,
    #page-s19 .data-table,
    #page-s21 .data-table { min-width: 420px; }

    /* ── TOP BAR CLOCK: slightly more readable ── */
    .topbar-clock-date { font-size: 11px; }

    /* ── FOOTER: drop out of fixed position on mobile ── */
    #site-footer {
      position: static;
      white-space: normal;
      flex-wrap: wrap;
      font-size: 11px;
      padding: 10px 12px;
      gap: 4px;
    }
    #site-footer-patient { flex-wrap: wrap; gap: 6px; }
    .footer-legal-links { gap: 6px; }
    .main { padding-bottom: 0; }
  }

  /* ── NARROW PHONES (375px and below, e.g. iPhone SE, Galaxy Fold) ── */
  @media (max-width: 400px) {
    .topbar-title { font-size: 12px; }
    .menu-text { display: none; } /* narrow phones: icon only, no "Menu" label */

    /* Overview tiles: single column on smallest screens */
    .overview-grid { grid-template-columns: 1fr !important; }

    /* Auth card: tighter padding */
    .auth-card { padding: 24px 16px; }

    /* Card body: tighter padding */
    .card-body { padding: 10px; }

    /* Section header title smaller */
    .section-header h1 { font-size: 14px; }

    /* Patient header name */
    .patient-name { font-size: 15px; }

    /* Patient header button grid: 2 columns on very small screens */
    .patient-header-actions {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  /* ── LANDSCAPE + SHORT SCREEN (phones rotated) ── */
  @media (orientation: landscape) and (max-height: 500px) {
    .dlm-box { max-height: 80vh; border-radius: 8px; }
    .dlm-overlay { align-items: center; padding: 8px; }
    .wizard-modal { max-height: 95vh; }
    .patient-header { padding: 8px 12px; }
    .topbar { height: 44px; }
    #battle-plan-nudge { top: 44px; }
  }

  /* ── AUTH SCREEN ── */
  #auth-screen {
    position: fixed; inset: 0;
    background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    padding: 24px;
  }
  #auth-screen.hidden { display: none; }
  #app.hidden { display: none; }

  .auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 40px 36px;
    width: 100%; max-width: 420px;
  }
  .auth-logo {
    text-align: center;
    margin-bottom: 28px;
  }
  .auth-logo h1 {
    font-size: 20px; font-weight: 700;
    color: var(--brand);
    margin-bottom: 4px;
  }
  .auth-logo p { font-size: 13px; color: var(--text-muted); }
  .auth-tabs {
    display: flex; gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
  }
  .auth-tab {
    flex: 1; padding: 10px;
    text-align: center; font-size: 14px; font-weight: 600;
    cursor: pointer; border: none; background: transparent;
    color: var(--text-muted); transition: background 0.15s;
  }
  .auth-tab.active { background: var(--brand); color: #fff; }
  .auth-form { display: flex; flex-direction: column; gap: 14px; }
  .auth-form label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; display: block; }
  .auth-form input {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; color: var(--text);
    outline: none; transition: border-color 0.15s;
  }
  .auth-form input:focus { border-color: var(--brand); }
  .auth-submit {
    background: var(--brand); color: #fff;
    border: none; border-radius: var(--radius);
    padding: 12px; font-size: 15px; font-weight: 600;
    cursor: pointer; margin-top: 4px;
    transition: background 0.15s;
  }
  .auth-submit:hover { background: var(--brand-mid); }
  .auth-error {
    background: #fee; border: 1px solid #fcc;
    color: #c00; border-radius: var(--radius);
    padding: 10px 12px; font-size: 13px;
    display: none;
  }
  .auth-error.visible { display: block; }
  .auth-forgot { text-align:right; margin-top:-6px; }
  .auth-forgot a { font-size:12px; color:var(--brand); cursor:pointer; text-decoration:none; }
  .auth-forgot a:hover { text-decoration:underline; }
  .auth-back { font-size:12px; color:var(--brand); cursor:pointer; background:none; border:none; padding:0; text-decoration:none; }
  .auth-back:hover { text-decoration:underline; }

  /* ── TOPBAR USER INFO ── */
  .topbar-user {
    color: rgba(255,255,255,0.85); font-size: 13px;
    display: flex; align-items: center; gap: 12px;
  }
  .topbar-logout {
    background: rgba(255,255,255,0.15); color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px; padding: 4px 10px;
    font-size: 12px; cursor: pointer;
    transition: background 0.15s;
  }
  .topbar-logout:hover { background: rgba(255,255,255,0.25); }

  /* ── CHANGE NAME MODAL ── */
  .name-change-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.55); z-index:2000; display:flex; align-items:center; justify-content:center; padding:16px; }
  .name-change-overlay.hidden { display:none; }
  .name-change-modal { background:var(--surface); border-radius:12px; width:100%; max-width:460px; box-shadow:0 20px 60px rgba(0,0,0,0.3); overflow:hidden; }
  .name-change-modal .modal-header { display:flex; align-items:center; justify-content:space-between; padding:18px 20px 12px; border-bottom:1px solid var(--border); }
  .name-change-modal .modal-header h2 { font-size:15px; font-weight:700; color:var(--brand); margin:0; }
  .name-change-modal .modal-body { padding:20px; display:flex; flex-direction:column; gap:14px; }
  .name-change-modal label { font-size:12px; font-weight:600; color:var(--text-muted); display:block; margin-bottom:4px; }
  .name-change-modal input, .name-change-modal select { width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:6px; font-size:14px; background:var(--surface3); color:var(--text); box-sizing:border-box; }
  .name-change-modal .modal-footer { display:flex; justify-content:flex-end; gap:10px; padding:12px 20px 18px; }
  .topbar-name-btn { background:none; border:none; color:#fff; font-size:13px; font-weight:500; cursor:pointer; padding:2px 4px; border-radius:4px; transition:background 0.15s; text-decoration:underline dotted rgba(255,255,255,0.5); }
  .topbar-name-btn:hover { background:rgba(255,255,255,0.15); }

  /* ── ONBOARDING WIZARD ── */
  .wizard-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.55); z-index:2000; display:flex; align-items:center; justify-content:center; padding:16px; }
  .wizard-overlay.hidden { display:none; }
  .wizard-modal { background:var(--surface); border-radius:12px; width:100%; max-width:620px; max-height:90vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,0.3); display:flex; flex-direction:column; }
  .wizard-header { display:flex; align-items:center; justify-content:space-between; padding:20px 24px 12px; border-bottom:1px solid var(--border); flex-shrink:0; position:sticky; top:0; background:var(--surface); z-index:3; }
  .wizard-header h2 { font-size:16px; font-weight:700; color:var(--brand); margin:0; }
  .wizard-close-btn { background:none; border:none; font-size:18px; cursor:pointer; color:var(--text-muted); padding:4px 8px; border-radius:4px; }
  .wizard-close-btn:hover { background:var(--border); }
  .wizard-progress-track { height:4px; background:var(--border); margin:12px 24px 0; border-radius:2px; }
  .wizard-progress-fill { height:100%; background:var(--brand); border-radius:2px; transition:width 0.3s ease; }
  .wizard-step-label { font-size:11px; color:var(--text-muted); text-align:right; padding:4px 24px 0; }
  .wizard-step { display:none; padding:20px 24px; }
  .wizard-step.active { display:block; }
  .wizard-step h3 { font-size:15px; font-weight:700; color:var(--text); margin:0 0 6px; }
  .wizard-subtitle { font-size:13px; color:var(--text-muted); margin:0 0 16px; }
  .wizard-field-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  .wizard-field-col { display:flex; flex-direction:column; gap:12px; }
  .wizard-field label { display:block; font-size:11px; font-weight:600; color:var(--text-muted); margin-bottom:4px; text-transform:uppercase; letter-spacing:0.4px; }
  .wizard-field input, .wizard-field textarea, .wizard-field select { width:100%; box-sizing:border-box; padding:8px 10px; border:1px solid var(--border); border-radius:6px; font-size:13px; font-family:inherit; color:var(--text); background:var(--surface3); }
  .wizard-field textarea { min-height:64px; resize:vertical; }
  .wizard-footer { display:flex; justify-content:space-between; align-items:center; padding:16px 24px; border-top:1px solid var(--border); gap:12px; position:sticky; bottom:0; background:var(--surface); z-index:2; flex-shrink:0; }
  .wizard-footer .wizard-saving { flex:1; text-align:center; }
  .wizard-saving { font-size:12px; color:var(--text-muted); }
  .wz-toggle-group { display:flex; gap:8px; }
  .wz-toggle-btn { flex:1; padding:8px 12px; border:1px solid var(--border); border-radius:6px; font-size:13px; font-family:inherit; cursor:pointer; background:var(--surface3); color:var(--text); font-weight:500; transition:background 0.15s,border-color 0.15s,color 0.15s; }
  .wz-toggle-btn:hover { background:var(--brand-light); border-color:var(--brand-mid); }
  .wz-toggle-btn.active { background:var(--brand); border-color:var(--brand); color:#fff; }
  .wz-detail-box { margin-top:10px; padding:12px; background:var(--brand-light); border-radius:8px; border:1px solid var(--border); display:flex; flex-direction:column; gap:12px; }
  .nav-wizard-btn { display:flex; align-items:center; gap:8px; padding:10px 16px; cursor:pointer; font-size:13px; color:#fff; background:var(--brand-mid); border:none; width:100%; text-align:left; font-family:inherit; font-weight:600; border-top:1px solid var(--border); margin-top:8px; }
  .nav-wizard-btn:hover { background:var(--brand); }
  .mobile-wizard-btn { display:none; align-items:center; gap:6px; padding:7px 12px; cursor:pointer; font-size:13px; color:#fff; background:var(--brand-mid); border:none; border-radius:6px; font-family:inherit; font-weight:600; white-space:nowrap; }
  .mobile-wizard-btn:hover { background:var(--brand); }
  .topbar-wizard-btn { display:flex; align-items:center; gap:4px; padding:4px 10px; cursor:pointer; font-size:12px; color:#fff; background:var(--brand-mid); border:none; border-radius:5px; font-family:inherit; font-weight:600; white-space:nowrap; }
  .topbar-wizard-btn:hover { background:var(--brand); }

  /* ── WIZARD STEP 5 — CONDITIONS GRID ── */
  .wz-section-title { font-size:12px; font-weight:700; color:var(--brand); text-transform:uppercase; letter-spacing:0.5px; margin:20px 0 8px; padding-bottom:6px; border-bottom:2px solid var(--border); }
  .wz-group-label { font-size:11px; font-weight:700; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.5px; margin:16px 0 8px; }
  .wz-conds-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
  .wz-cond-card { display:flex; flex-direction:column; gap:8px; padding:10px 12px; background:var(--surface2); border:1px solid var(--border); border-radius:8px; }
  .wz-cond-info { display:flex; align-items:flex-start; gap:8px; }
  .wz-cond-icon { font-size:18px; flex-shrink:0; line-height:1.2; }
  .wz-cond-name { font-size:12px; font-weight:700; color:var(--text); margin:0 0 2px; }
  .wz-cond-desc { font-size:11px; color:var(--text-muted); line-height:1.35; }
  .wz-cond-card .wz-toggle-group { gap:6px; }
  .wz-cond-card .wz-toggle-btn { padding:5px 8px; font-size:12px; }
  @media (max-width:600px) {
    .wz-conds-grid { grid-template-columns:1fr; }
  }

  /* ── DATE PICKER ── */
  /* ── DATE PICKER ── */
  #date-picker-popup {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    width: 276px;
    user-select: none;
    font-family: inherit;
    overflow: hidden;
  }
  .dp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--brand);
  }
  .dp-header button {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: background 0.15s;
  }
  .dp-header button:hover { background: rgba(255,255,255,0.28); }
  .dp-title { font-weight: 700; font-size: 14px; color: #fff; }
  .dp-today-btn {
    display: block;
    width: calc(100% - 20px);
    margin: 0 10px 10px;
    padding: 7px;
    background: var(--brand);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    font-family: inherit;
  }
  .dp-today-btn:hover { background: var(--brand-mid); }
  .dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    padding: 10px 10px 8px;
    background: #fff;
  }
  .dp-day-name {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 4px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .dp-day {
    text-align: center;
    font-size: 13px;
    padding: 0;
    width: 34px;
    height: 34px;
    line-height: 34px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text);
    margin: 0 auto;
    transition: background 0.12s;
  }
  .dp-day:hover { background: var(--brand-light); color: var(--brand); }
  .dp-day.today { font-weight: 700; color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
  .dp-day.selected { background: var(--brand); color: #fff; font-weight: 700; }
  .dp-day.selected.today { box-shadow: none; }
  .dp-day.other-month { color: #bbb; }
  .dp-day.empty { cursor: default; }

  /* ── TIME PICKER ── */
  #time-picker-popup {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    width: 240px;
    user-select: none;
    font-family: inherit;
    overflow: hidden;
  }
  /* Header — identical to date picker & card headers */
  .tp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--brand);
  }
  .tp-title { font-weight: 700; font-size: 14px; color: #fff; }
  .tp-header button {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: background 0.15s;
  }
  .tp-header button:hover { background: rgba(255,255,255,0.28); }
  /* Two scroll columns */
  .tp-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 12px 10px 8px;
    background: #fff;
  }
  .tp-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 2px;
  }
  .tp-col-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  /* Up/down arrow buttons — same style as dp-header nav buttons but teal-on-white */
  .tp-arrow {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--brand);
    font-size: 16px;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: background 0.15s;
    line-height: 1;
  }
  .tp-arrow:hover { background: var(--brand-light); border-color: var(--brand); }
  /* The large value display in the centre of each column */
  .tp-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--brand);
    line-height: 1;
    padding: 10px 0;
    min-width: 56px;
    text-align: center;
    border-radius: 10px;
    background: var(--surface3);
    border: 1.5px solid var(--border);
    margin: 4px 0;
  }
  /* Separator colon */
  .tp-sep {
    font-size: 28px;
    font-weight: 700;
    color: var(--brand);
    padding: 0 4px;
    margin-top: 52px; /* align with value boxes */
    line-height: 1;
  }
  /* Now button — solid brand, identical to Today button */
  .tp-now-btn {
    display: block;
    width: calc(100% - 20px);
    margin: 4px 10px 10px;
    padding: 7px;
    background: var(--brand);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    font-family: inherit;
  }
  .tp-now-btn:hover { background: var(--brand-mid); }
  input[data-time-picker] { cursor: pointer; }
}

/* ════════════════════════════════════════
   WATERMARK HISTORY CARDS
   ════════════════════════════════════════ */
.wm-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}
.wm-card.wm-locked {
  background: var(--surface3);
  border-color: var(--border);
}
.wm-card.wm-editing {
  background: var(--surface2);
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(13,115,119,0.12);
}
.wm-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 20px;
  margin-bottom: 10px;
}
.wm-field-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.wm-field-value {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}
.wm-field-value:empty::after { content: '—'; color: var(--text-muted); opacity: 0.55; }
.wm-actions {
  display: flex;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.wm-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  min-height: 30px;
  transition: background 0.13s, color 0.13s;
}
.wm-btn-edit { background: transparent; border-color: var(--brand); color: var(--brand); }
.wm-btn-edit:hover { background: var(--brand); color: #fff; }
.wm-btn-del { background: transparent; border-color: #c62828; color: #c62828; }
.wm-btn-del:hover { background: #c62828; color: #fff; }
.wm-btn-save { background: var(--brand); border-color: var(--brand); color: #fff; }
.wm-btn-save:hover { background: var(--brand-mid); border-color: var(--brand-mid); }
.wm-btn-cancel { background: transparent; border-color: var(--border); color: var(--text-muted); }
.wm-btn-cancel:hover { background: var(--surface); }
.wm-empty, .tbl-empty-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
  font-style: italic;
}
.wm-add-panel {
  background: var(--surface3);
  border: 1px dashed var(--brand);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.wm-add-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 12px;
}
.wm-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.wm-form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 3px;
}
.wm-form-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
.wm-form-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(13,115,119,0.10); }
.wm-card.wm-editing .wm-form-grid { margin-bottom: 12px; }
@media (max-width: 600px) {
  .wm-form-grid { grid-template-columns: 1fr; }
  .wm-fields { grid-template-columns: 1fr 1fr; }
}

/* ── Condition Tab Bar ───────────────────────────────────────── */
.cond-tabbar { display:flex; flex-wrap:nowrap; overflow-x:auto; gap:4px; padding:12px 0 0; margin-bottom:16px; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.cond-tabbar::-webkit-scrollbar { display:none; }
.cond-tab { flex:0 0 auto; padding:10px 18px; border-radius:50px; border:1px solid var(--border); background:var(--surface2); color:var(--text-muted); font-size:13px; font-weight:500; cursor:pointer; font-family:inherit; white-space:nowrap; transition:background 0.12s,color 0.12s,border-color 0.12s; user-select:none; }
.cond-tab:hover { background:var(--surface); color:var(--text); border-color:var(--brand-mid); }
.cond-tab.cond-tab-active { background:var(--brand); color:#fff; border-color:var(--brand); font-weight:600; }

/* ── Global Save Toast ───────────────────────────────────────── */
.pp-toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(16px); background:var(--brand); color:#fff; font-size:13.5px; font-weight:600; padding:11px 24px; border-radius:50px; box-shadow:0 4px 20px rgba(0,0,0,0.18); z-index:99999; opacity:0; pointer-events:none; transition:opacity 0.22s,transform 0.22s; white-space:nowrap; }
.pp-toast.pp-toast-show { opacity:1; transform:translateX(-50%) translateY(0); }
.pp-toast.pp-toast-error { background:#c0392b; }
@media (max-width:700px) { .pp-toast { font-size:13px; padding:10px 18px; bottom:16px; max-width:calc(100vw - 32px); white-space:normal; text-align:center; } }

/* ── Global Passport Search (topbar) ─────────────────────────── */
#gs-wrap { position:relative; flex:0 0 auto; width:220px; }
.gs-box { display:flex; align-items:center; gap:7px; background:rgba(255,255,255,0.15); border:1.5px solid rgba(255,255,255,0.25); border-radius:50px; padding:6px 14px; transition:background 0.18s,border-color 0.18s; }
.gs-box:focus-within { background:rgba(255,255,255,0.22); border-color:rgba(255,255,255,0.55); }
.gs-icon { font-size:13px; flex-shrink:0; opacity:0.8; }
#global-search-input { flex:1; border:none; background:transparent; outline:none; font-size:13px; color:#fff; font-family:inherit; min-width:0; width:100%; }
#global-search-input::placeholder { color:rgba(255,255,255,0.6); }
.gs-dropdown { position:absolute; top:calc(100% + 8px); right:0; left:auto; width:360px; background:var(--surface); border:1.5px solid var(--border); border-radius:16px; box-shadow:0 8px 32px rgba(0,0,0,0.18),0 2px 8px rgba(0,0,0,0.1); z-index:9999; overflow-y:auto; max-height:420px; }
.gs-result-row { display:flex; align-items:center; gap:10px; padding:10px 16px; border-bottom:1px solid var(--border); transition:background 0.1s; }
.gs-result-row:last-child { border-bottom:none; }
.gs-result-row:hover { background:var(--surface2); }
.gs-result-icon { font-size:15px; flex-shrink:0; }
.gs-result-label { flex:1; font-size:13px; color:var(--text); font-weight:500; min-width:0; }
.gs-tag { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:0.4px; padding:2px 8px; border-radius:50px; flex-shrink:0; }
.gs-tag-condition { background:rgba(var(--brand-rgb,0,94,184),0.1); color:var(--brand); }
.gs-tag-section { background:rgba(0,0,0,0.06); color:var(--text-muted); }
.gs-add-btn { flex-shrink:0; padding:5px 12px; border-radius:50px; border:1.5px solid var(--brand); background:transparent; color:var(--brand); font-size:11.5px; font-weight:600; cursor:pointer; font-family:inherit; transition:all 0.18s; white-space:nowrap; }
.gs-add-btn:hover:not(:disabled) { background:var(--brand); color:#fff; }
.gs-add-btn.gs-added { border-color:#22c55e; background:rgba(34,197,94,0.1); color:#16a34a; cursor:default; }
.gs-go-btn { flex-shrink:0; padding:5px 12px; border-radius:50px; border:1.5px solid var(--border); background:transparent; color:var(--text-muted); font-size:11.5px; font-weight:600; cursor:pointer; font-family:inherit; transition:all 0.18s; white-space:nowrap; }
.gs-go-btn:hover { border-color:var(--brand-mid); color:var(--text); background:var(--surface2); }
.gs-no-results { padding:14px 16px; font-size:13px; color:var(--text-muted); text-align:center; }
@media (max-width:900px) { #gs-wrap { width:160px; } .gs-dropdown { width:300px; } }
@media (max-width:700px) {
  #gs-wrap { width:36px; overflow:visible; }
  .gs-box { padding:6px 10px; gap:0; }
  #global-search-input { display:none; }
  .gs-box:focus-within #global-search-input { display:block; }
  .gs-dropdown { width:calc(100vw - 32px); right:-8px; }
  .gs-tag { display:none; }
}

/* ── INFO HUB CARDS (tinted, soft) ───────────────────────────── */
.info-hub > .card-header { background:rgba(var(--brand-rgb,0,94,184),0.06); border-bottom:1px solid rgba(var(--brand-rgb,0,94,184),0.12); }
.info-hub > .card-header h2 { color:var(--brand); font-size:15px; font-weight:600; }
.info-hub { background:rgba(var(--brand-rgb,0,94,184),0.03); border-color:rgba(var(--brand-rgb,0,94,184),0.15) !important; }
.info-hub .card-body { font-size:13.5px; line-height:1.75; color:var(--text-muted); }
.info-hub .card-body p { margin-bottom:10px; }
.info-hub .card-body ul { padding-left:18px; margin-bottom:10px; }
.info-hub .card-body li { margin-bottom:4px; }
.info-hub .card-body strong { color:var(--text); font-weight:600; }
.info-hub .card-body a { color:var(--brand); }

/* ── ONBOARDING GATEWAY ───────────────────────────────────────── */
#onboarding-gateway { position:fixed; inset:0; z-index:999; display:flex; align-items:center; justify-content:center; }
#onboarding-gateway.hidden { display:none; }
.ogw-backdrop { position:absolute; inset:0; background:rgba(8,30,30,0.82); backdrop-filter:blur(4px); display:flex; align-items:center; justify-content:center; padding:16px; }
.ogw-card { background:var(--surface); border:1px solid var(--border); border-radius:16px; box-shadow:0 24px 64px rgba(0,0,0,0.35); width:100%; max-width:780px; max-height:92vh; display:flex; flex-direction:column; overflow:hidden; }

/* Header */
.ogw-header { background:var(--brand); padding:20px 24px; display:flex; align-items:center; gap:16px; flex-shrink:0; }
.ogw-logo { font-size:36px; line-height:1; flex-shrink:0; }
.ogw-title { font-size:20px; font-weight:700; color:#fff; letter-spacing:0.2px; }
.ogw-sub { font-size:13px; color:rgba(255,255,255,0.78); margin-top:3px; }

/* Tabs */
.ogw-tabs { display:flex; gap:0; border-bottom:2px solid var(--border); background:var(--surface2); flex-shrink:0; overflow-x:auto; scrollbar-width:none; }
.ogw-tabs::-webkit-scrollbar { display:none; }
.ogw-tab { flex:1; min-width:120px; padding:13px 10px; font-size:13px; font-weight:600; color:var(--text-muted); background:transparent; border:none; border-bottom:3px solid transparent; cursor:pointer; font-family:inherit; white-space:nowrap; transition:color 0.15s,border-color 0.15s,background 0.15s; margin-bottom:-2px; }
.ogw-tab:hover { color:var(--text); background:var(--surface3); }
.ogw-tab-active { color:var(--brand); border-bottom-color:var(--brand); background:var(--surface); font-weight:700; }

/* Panels */
.ogw-panel { flex:1; overflow-y:auto; padding:22px 24px; scroll-behavior:smooth; }
.ogw-panel-hidden { display:none; }
.ogw-panel-title { font-size:18px; font-weight:700; color:var(--brand); margin:0 0 8px; }
.ogw-panel-intro { font-size:14px; color:var(--text-muted); margin:0 0 20px; line-height:1.6; border-bottom:1px solid var(--border); padding-bottom:16px; }

/* Guide steps */
.ogw-guide-steps { display:flex; flex-direction:column; gap:14px; }
.ogw-step { display:flex; gap:14px; padding:14px; background:var(--surface2); border-radius:10px; border:1px solid var(--border); }
.ogw-step-num { width:30px; height:30px; border-radius:50%; background:var(--brand); color:#fff; font-size:14px; font-weight:700; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.ogw-step-head { font-size:14px; font-weight:700; color:var(--brand); margin-bottom:5px; }
.ogw-step-body { font-size:13px; color:var(--text); line-height:1.65; margin:0; }

/* Info blocks */
.ogw-info-blocks { display:flex; flex-direction:column; gap:12px; }
.ogw-info-block { display:flex; gap:14px; padding:14px 16px; border-radius:10px; border:1px solid var(--border); background:var(--surface2); }
.ogw-info-icon { font-size:24px; flex-shrink:0; line-height:1.2; }
.ogw-info-head { font-size:14px; font-weight:700; color:var(--brand); margin-bottom:5px; }
.ogw-info-body { font-size:13px; color:var(--text); line-height:1.65; margin:0; }
.ogw-info-server { border-left:4px solid var(--brand); }
.ogw-info-local { border-left:4px solid var(--brand-mid); }
.ogw-info-save { border-left:4px solid #e67e22; }
.ogw-info-session { border-left:4px solid var(--text-muted); }
.ogw-info-qr { border-left:4px solid var(--success); }

/* Disclaimer */
.ogw-disclaimer-alert { display:flex; gap:14px; align-items:flex-start; background:#fef2f2; border:2px solid #DA291C; border-radius:10px; padding:16px; margin-bottom:18px; }
.ogw-disclaimer-icon { font-size:28px; flex-shrink:0; line-height:1.1; }
.ogw-disclaimer-alert-text { font-size:14px; color:#7a0000; line-height:1.6; }
.ogw-disclaimer-blocks { display:flex; flex-direction:column; gap:12px; }
.ogw-disclaimer-block { padding:14px 16px; border-radius:10px; background:var(--surface2); border:1px solid var(--border); border-left:4px solid var(--danger); }
.ogw-disclaimer-head { font-size:14px; font-weight:700; color:var(--brand); margin-bottom:6px; }
.ogw-disclaimer-body { font-size:13px; color:var(--text); line-height:1.65; margin:0; }

/* Footer */
.ogw-footer { padding:16px 24px; border-top:2px solid var(--border); background:var(--surface2); display:flex; align-items:center; gap:16px; flex-wrap:wrap; flex-shrink:0; }
.ogw-checkbox-label { display:flex; align-items:center; gap:10px; font-size:13px; font-weight:600; color:var(--text); cursor:pointer; flex:1; min-width:200px; }
.ogw-checkbox-label input[type="checkbox"] { width:18px; height:18px; accent-color:var(--brand); flex-shrink:0; cursor:pointer; }
.ogw-enter-btn { min-width:240px; font-size:15px; padding:12px 24px; }
.ogw-enter-btn:disabled { opacity:0.45; cursor:not-allowed; }

/* Responsive */
@media (max-width:600px) {
  .ogw-card { max-height:100vh; border-radius:0; }
  .ogw-panel { padding:16px; }
  .ogw-header { padding:14px 16px; }
  .ogw-footer { padding:12px 16px; flex-direction:column; align-items:stretch; }
  .ogw-enter-btn { width:100%; text-align:center; }
  .ogw-tab { min-width:90px; font-size:12px; padding:11px 8px; }
}

/* ══ FOOTER LEGAL LINKS ══ */
.footer-legal-links { display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:center; margin-top:6px; }
.footer-legal-btn { background:none; border:none; color:var(--text-muted); font-size:12px; cursor:pointer; padding:2px 4px; text-decoration:underline; text-underline-offset:2px; transition:color 0.15s; }
.footer-legal-btn:hover { color:var(--brand-mid); }

/* ══ LEGAL POLICY MODALS ══ */
.legal-backdrop { position:fixed; inset:0; z-index:2000; background:rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; padding:16px; }
.legal-backdrop.hidden { display:none; }
.legal-modal { background:var(--surface); border-radius:14px; box-shadow:0 20px 60px rgba(0,0,0,0.45); width:100%; max-width:780px; max-height:90vh; display:flex; flex-direction:column; overflow:hidden; }
.legal-modal-header { display:flex; align-items:center; justify-content:space-between; padding:16px 22px; background:var(--brand); color:#fff; flex-shrink:0; }
.legal-modal-title { font-size:18px; font-weight:700; margin:0; color:#fff; }
.legal-close-btn { background:rgba(255,255,255,0.15); border:1px solid rgba(255,255,255,0.35); border-radius:8px; color:#fff; font-size:13px; font-weight:600; padding:8px 14px; cursor:pointer; transition:background 0.15s; }
.legal-close-btn:hover { background:rgba(255,255,255,0.25); }
.legal-modal-body { overflow-y:auto; padding:24px; flex:1; }
.legal-sheet { display:block; }
.legal-sheet-hidden { display:none; }
.legal-effective { font-size:12px; color:var(--text-muted); margin-bottom:20px; }
.legal-section { margin-bottom:20px; padding-bottom:20px; border-bottom:1px solid var(--border); }
.legal-section:last-child { border-bottom:none; margin-bottom:0; padding-bottom:0; }
.legal-section h3 { font-size:15px; font-weight:700; color:var(--brand); margin:0 0 8px; }
.legal-section p { font-size:13px; color:var(--text); line-height:1.7; margin:0 0 8px; }
.legal-section p:last-child { margin-bottom:0; }
.legal-section ul { font-size:13px; color:var(--text); line-height:1.7; margin:6px 0 0 18px; padding:0; }
.legal-section ul li { margin-bottom:4px; }
.legal-section a { color:var(--brand-mid); }
.legal-section-highlight { background:var(--surface2); border-radius:10px; border-left:4px solid var(--brand-mid); padding:16px; margin-bottom:20px; }
.legal-section-highlight h3 { color:var(--brand); }
.legal-cookie-table { width:100%; border-collapse:collapse; font-size:12.5px; margin-top:10px; }
.legal-cookie-table th { background:var(--brand); color:#fff; padding:8px 10px; text-align:left; font-weight:600; }
.legal-cookie-table td { padding:8px 10px; border-bottom:1px solid var(--border); color:var(--text); line-height:1.55; vertical-align:top; }
.legal-cookie-table tr:last-child td { border-bottom:none; }
.legal-cookie-table code { font-size:11.5px; background:var(--surface2); padding:1px 5px; border-radius:4px; }
@media (max-width:600px) {
  .legal-modal { max-height:100vh; border-radius:0; }
  .legal-modal-body { padding:16px; }
}

/* ══ WIZARD: MOBILE TABLE STACKING (≤768px) ══ */
@media (max-width: 768px) {
  /* The wizard modal itself needs to scroll, not clip */
  .wizard-modal { max-height: 100dvh; border-radius: 0; }

  /* Make the wrapper div scrollable only horizontally on desktop;
     on mobile we stack, so remove overflow-x:auto behaviour */
  .wizard-step [style*="overflow-x:auto"] { overflow-x: visible !important; }

  /* Stack table elements as block */
  .wizard-step .data-table,
  .wizard-step .data-table thead,
  .wizard-step .data-table tbody,
  .wizard-step .data-table tr,
  .wizard-step .data-table td { display: block; width: 100%; box-sizing: border-box; }

  /* Hide the desktop column headers — labels come from data-label */
  .wizard-step .data-table thead { display: none; }

  /* Each row becomes a card */
  .wizard-step .data-table tbody tr {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  /* Each cell: label above, input below */
  .wizard-step .data-table td {
    padding: 0;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  /* Hide cells with no data-label (e.g. the hidden contacts[0] slot, delete btn) */
  .wizard-step .data-table td:not([data-label]) { display: none; }

  /* Injected label via pseudo-element */
  .wizard-step .data-table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
  }

  /* Full-width, finger-friendly inputs and selects inside stacked cells */
  .wizard-step .data-table td input,
  .wizard-step .data-table td select,
  .wizard-step .data-table td textarea {
    width: 100% !important;
    box-sizing: border-box;
    min-height: 40px;
    font-size: 14px !important;
    padding: 8px 10px !important;
  }
}

/* ══ PASSWORD SHOW/HIDE TOGGLE ══ */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { flex: 1; padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 0;
  width: 40px; height: 100%;
  min-height: 44px;
  background: none; border: none;
  cursor: pointer; font-size: 16px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.pw-toggle:hover { color: var(--brand-mid); }
.pw-toggle.active { color: var(--brand); }

/* ══ BATTLE PLAN DAY REMINDER BANNER ══ */
.bp-reminder-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-mid));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  box-shadow: var(--shadow-md);
  flex-wrap: wrap;
}
.bp-reminder-sub {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.88;
}
@media (max-width: 700px) {
  .bp-reminder-banner { font-size: 14px; padding: 12px 14px; gap: 8px; }
}

/* ══ TOPBAR LOGO ══ */
.topbar-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: #fff;
  border-radius: 50%;
  overflow: hidden;
  padding: 3px;
  box-sizing: border-box;
  flex-shrink: 0;
}
.topbar-logo { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ── DAILY LOG ABBREVIATION GUIDE ── */
.cal-abbrev-guide {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface2);
}
.cal-abbrev-guide summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.cal-abbrev-guide summary::-webkit-details-marker { display: none; }
.cal-abbrev-guide[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cal-abbrev-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 4px 0;
}
.cal-abbrev-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.cal-abbrev-item:nth-last-child(-n+2) { border-bottom: none; }
.cal-abbrev-code {
  font-weight: 700;
  color: var(--brand);
  min-width: 54px;
  flex-shrink: 0;
  font-size: 12px;
}
.cal-abbrev-desc {
  color: var(--text-muted);
  line-height: 1.4;
}
@media (max-width: 700px) {
  .cal-abbrev-grid { grid-template-columns: 1fr; }
  .cal-abbrev-item:nth-last-child(-n+2) { border-bottom: 1px solid var(--border); }
  .cal-abbrev-item:last-child { border-bottom: none; }
}

