/* Medsight staff portal styles. Split out of staff.html so the browser can
 * cache them across deploys and sessions instead of re-downloading the
 * whole portal on every load. Loaded from <head> in staff.html.
 */
  :root {
    --navy: #1c3a5e;
    --navy-deep: #142b46;
    --blue: #2b73b8;
    --blue-light: #e7f0fa;
    --green: #5aa744;
    --green-dark: #4a8f37;
    --green-light: #eaf5e7;
    --text: #324154;
    --muted: #5c6b7a;
    --line: #e4ecf3;
    --danger: #c0392b;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(28,58,94,.06), 0 2px 6px rgba(28,58,94,.05);
    --shadow: 0 10px 30px rgba(28,58,94,.10);
    --ease: cubic-bezier(.22,1,.36,1);
    /* Surfaces + accent tints */
    --bg: #f3f7fa;
    --card: #fff;
    --field: #f4f8fb;
    --amber-bg: #fff4e0;
    --amber-text: #a06b12;
    --amber-deep: #7a5410;
    --amber-line: #f0d9a8;
    --danger-bg: #fdecea;
  }
  * { margin:0; padding:0; box-sizing:border-box; }
  body {
    font-family:"Source Sans 3","Segoe UI",sans-serif;
    color:var(--text);
    background:var(--bg);
    line-height:1.6;
    -webkit-font-smoothing:antialiased;
  }
  h1,h2,h3,h4 { font-family:"DM Sans",sans-serif; color:var(--navy); line-height:1.2; letter-spacing:-.02em; }
  a { color:var(--blue); }
  .hidden { display:none !important; }

  /* Top bar (brand gradient hairline along the bottom edge) */
  .topbar {
    background:var(--card);
    border-bottom:1px solid var(--line);
    padding:12px 20px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    position:sticky; top:0; z-index:20;
  }
  .topbar::after {
    content:"";
    position:absolute;
    left:0; right:0; bottom:-1px;
    height:2px;
    background:linear-gradient(90deg, var(--green) 0%, var(--blue) 100%);
  }
  .topbar .brand {
    display:flex; align-items:center; gap:10px;
    font-family:"DM Sans",sans-serif; font-weight:800; color:var(--navy); text-decoration:none;
  }
  .topbar .brand img { height:38px; width:auto; }
  .topbar .brand .tag {
    font-size:.72rem; font-weight:700; letter-spacing:.1em; text-transform:uppercase;
    background:var(--blue-light); color:var(--blue); padding:4px 10px; border-radius:999px;
  }
  .topbar .who { font-size:.9rem; color:var(--muted); display:flex; align-items:center; gap:12px; }
  .mode-pill {
    font-size:.72rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
    padding:3px 10px; border-radius:999px;
  }
  .mode-server { background:var(--green-light); color:var(--green-dark); }
  .mode-local { background:var(--amber-bg); color:var(--amber-text); }

  .wrap { max-width:1100px; margin:0 auto; padding:28px 20px 80px; }

  /* ---------- App shell (sidebar + main) ---------- */
  .app-shell { display:flex; align-items:flex-start; max-width:1240px; margin:0 auto; }
  /* The sidebar is pinned to the true viewport edge (not the centered
     app-shell column) on desktop, so there's never a gap beside it. */
  .sidebar {
    width:238px; flex-shrink:0; position:fixed; left:0; top:63px;
    height:calc(100vh - 63px); background:var(--card); border-right:1px solid var(--line);
    padding:18px 14px; display:flex; flex-direction:column; gap:3px; overflow-y:auto;
    z-index:30;
  }
  .app-main { flex:1; min-width:0; padding:28px 30px 80px; margin-left:238px; }
  .nav-label {
    font-size:.68rem; font-weight:700; letter-spacing:.09em; text-transform:uppercase;
    color:var(--muted); padding:16px 12px 6px;
  }
  .nav-item {
    position:relative;
    display:flex; align-items:center; gap:12px; width:100%; text-align:left;
    padding:10px 12px; border:none; background:none; border-radius:10px; cursor:pointer;
    font-family:"DM Sans",sans-serif; font-weight:600; font-size:.95rem; color:var(--text);
    transition:background .15s var(--ease), color .15s;
  }
  .nav-item svg { flex-shrink:0; color:var(--muted); transition:color .15s; }
  .nav-item:hover { background:var(--bg); color:var(--navy); }
  .nav-item:hover svg { color:var(--navy); }
  .nav-item.active { background:var(--green-light); color:var(--green-dark); }
  .nav-item.active svg { color:var(--green-dark); }
  .nav-item:focus-visible { outline:3px solid var(--blue); outline-offset:2px; }
  .nav-item .enq-badge { margin-left:auto; }
  .sidebar-user {
    margin-top:auto; padding-top:16px; border-top:1px solid var(--line);
    display:flex; flex-direction:column; gap:12px;
  }
  .sidebar-user .user-top { display:flex; align-items:center; gap:11px; }
  .sidebar-user .avatar {
    width:40px; height:40px; flex-shrink:0; border-radius:50%;
    background:linear-gradient(135deg,var(--green),var(--blue));
    color:#fff; display:grid; place-items:center;
    font-family:"DM Sans",sans-serif; font-weight:800; font-size:.95rem;
  }
  .sidebar-user .user-meta { display:flex; flex-direction:column; gap:3px; min-width:0; }
  .sidebar-user #who-name {
    font-family:"DM Sans",sans-serif; font-weight:700; color:var(--navy); font-size:.95rem;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  .sidebar-user .pills { display:flex; gap:6px; flex-wrap:wrap; }
  .sidebar-user #btn-logout { width:100%; }

  /* Sidebar toggle: collapses to icons on desktop, opens a drawer on mobile */
  .hamburger {
    display:grid; width:40px; height:40px; border:1.5px solid var(--line); border-radius:10px;
    background:var(--card); color:var(--navy); cursor:pointer; place-items:center; flex-shrink:0;
  }
  .hamburger:hover { border-color:var(--navy); }

  /* Collapsed (icon-only) sidebar — desktop only. */
  @media (min-width: 901px) {
    .app-shell.sidebar-collapsed .sidebar { width:76px; padding:18px 12px; }
    .app-shell.sidebar-collapsed .app-main { margin-left:76px; }
    .app-shell.sidebar-collapsed .nav-txt,
    .app-shell.sidebar-collapsed .sidebar-user .user-meta { display:none; }
    .app-shell.sidebar-collapsed .nav-label {
      font-size:0; height:0; padding:0; margin:10px 8px; border-top:1px solid var(--line);
    }
    .app-shell.sidebar-collapsed .nav-item { justify-content:center; padding:12px 0; }
    .app-shell.sidebar-collapsed .nav-item .enq-badge { position:absolute; top:3px; right:5px; margin-left:0; }
    .app-shell.sidebar-collapsed .sidebar-user .user-top { justify-content:center; }
    .app-shell.sidebar-collapsed #btn-logout { padding:8px; }
    .app-shell.sidebar-collapsed #btn-logout .nav-txt { display:none; }
  }

  @media (max-width: 900px) {
    .sidebar {
      position:fixed; top:63px; left:0; height:calc(100dvh - 63px); width:264px; z-index:60;
      transform:translateX(-100%); transition:transform .26s var(--ease);
      box-shadow:var(--shadow);
    }
    .app-shell.sidebar-open .sidebar { transform:translateX(0); }
    .app-shell.sidebar-open::before {
      content:""; position:fixed; top:63px; left:0; right:0; bottom:0;
      background:rgba(20,43,70,.42); z-index:55;
    }
    .app-main { padding:22px 16px 72px; margin-left:0; }
  }

  /* Buttons */
  .btn {
    display:inline-flex; align-items:center; justify-content:center; gap:8px;
    padding:10px 20px; border-radius:999px; border:none; cursor:pointer;
    font-family:"DM Sans",sans-serif; font-weight:700; font-size:.95rem;
    text-decoration:none; transition:transform .15s var(--ease), box-shadow .2s, background .2s;
  }
  .btn-primary { background:linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%); color:#fff; box-shadow:0 6px 16px rgba(90,167,68,.3); }
  .btn-primary:hover { background:var(--green-dark); transform:translateY(-1px); }
  .btn-primary[disabled] { opacity:.6; cursor:wait; transform:none; }
  .btn-ghost { background:var(--card); color:var(--navy); border:1.5px solid var(--line); }
  .btn-ghost:hover { border-color:var(--navy); }
  .btn-danger { background:var(--card); color:var(--danger); border:1.5px solid #f1d3ce; }
  .btn-danger:hover { background:var(--danger-bg); }
  .btn-sm { padding:7px 14px; font-size:.85rem; }
  .btn:focus-visible { outline:3px solid var(--blue); outline-offset:2px; }

  /* ---------- Login ---------- */
  .login-shell {
    min-height:calc(100vh - 63px);
    display:grid; place-items:center; padding:30px 20px;
    background:
      radial-gradient(50% 60% at 15% 10%, rgba(90,167,68,.10), transparent 60%),
      radial-gradient(50% 60% at 90% 90%, rgba(43,115,184,.10), transparent 60%),
      #f3f7fa;
  }
  .login-card { width:100%; max-width:420px; padding:38px 34px; text-align:center;
    background:var(--card); border:1px solid var(--line); border-radius:20px; box-shadow:var(--shadow); }
  .login-card .lock {
    width:58px; height:58px; margin:0 auto 16px; border-radius:16px;
    background:linear-gradient(135deg,var(--green-light),var(--blue-light));
    display:grid; place-items:center; color:var(--blue);
  }
  .login-card h1 { font-size:1.5rem; margin-bottom:6px; }
  .login-card .sub { color:var(--muted); font-size:.95rem; margin-bottom:22px; }
  .field { text-align:left; margin-bottom:16px; }
  .field label { display:block; font-weight:700; color:var(--navy); font-size:.9rem; margin-bottom:6px; }
  .field input, .field select, .field textarea {
    width:100%; padding:11px 14px; border:1.5px solid var(--line); border-radius:10px;
    font-size:1rem; font-family:inherit; color:var(--text); background:var(--field);
    transition:border-color .2s, box-shadow .2s;
  }
  .field input:focus, .field select:focus, .field textarea:focus {
    outline:none; border-color:var(--blue); background:var(--card); box-shadow:0 0 0 4px rgba(43,115,184,.12);
  }
  .login-error { color:var(--danger); font-weight:600; font-size:.9rem; min-height:22px; margin-top:10px; }
  .login-note { font-size:.8rem; color:var(--muted); margin-top:18px; }

  /* ---------- Dashboard ---------- */
  .dash-head { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:14px; margin-bottom:22px; }
  .dash-head h1 { font-size:1.6rem; }
  .storage-note {
    background:var(--blue-light); border:1px solid #cfe0f2; color:var(--navy);
    border-radius:10px; padding:12px 16px; font-size:.88rem; margin-bottom:22px;
  }
  .report-list { display:flex; flex-direction:column; gap:12px; }
  .report-search { position:relative; margin-bottom:16px; }
  .report-search .search-ico {
    position:absolute; left:16px; top:50%; transform:translateY(-50%);
    color:var(--muted); pointer-events:none;
  }
  .report-search input {
    width:100%; padding:12px 44px; border:1.5px solid var(--line); border-radius:999px;
    font-size:1rem; font-family:inherit; color:var(--text); background:var(--card);
    transition:border-color .2s, box-shadow .2s;
  }
  .report-search input:focus {
    outline:none; border-color:var(--blue); box-shadow:0 0 0 4px rgba(43,115,184,.12);
  }
  .report-search input::-webkit-search-cancel-button { display:none; }
  .search-clear {
    position:absolute; right:12px; top:50%; transform:translateY(-50%);
    width:28px; height:28px; border:none; border-radius:50%; cursor:pointer;
    background:var(--line); color:var(--navy); font-size:1.2rem; line-height:1;
    display:grid; place-items:center;
  }
  .search-clear:hover { background:#d7e2ec; }
  .report-item {
    background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
    padding:18px 20px; display:flex; flex-wrap:wrap; align-items:center; gap:14px;
    box-shadow:var(--shadow-sm); transition:box-shadow .2s, transform .2s var(--ease);
  }
  .report-item:hover { box-shadow:var(--shadow); transform:translateY(-2px); }
  .report-item .meta { flex:1; min-width:220px; }
  .report-item .meta .title { font-family:"DM Sans",sans-serif; font-weight:700; color:var(--navy); font-size:1.05rem; }
  .report-item .meta .sub { font-size:.85rem; color:var(--muted); }
  .report-item .actions { display:flex; gap:8px; flex-wrap:wrap; }
  .empty {
    text-align:center; padding:56px 20px; color:var(--muted);
    background:var(--card); border:1.5px dashed var(--line); border-radius:var(--radius);
  }
  .empty h3 { margin-bottom:6px; }
  .badge-status {
    font-size:.72rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
    padding:3px 10px; border-radius:999px;
  }
  .badge-draft { background:var(--amber-bg); color:var(--amber-text); }
  .badge-final { background:var(--green-light); color:var(--green-dark); }
  .badge-new { background:var(--blue-light); color:var(--blue); }
  .badge-stale { background:var(--danger-bg); color:var(--danger); }

  /* Dashboard stat cards */
  .stats-row {
    display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));
    gap:12px; margin-bottom:18px;
  }
  .stat-card {
    background:var(--card); border:1px solid var(--line); border-radius:12px;
    padding:14px 16px; box-shadow:var(--shadow-sm);
    border-top:3px solid var(--navy);
  }
  .stat-card .num { font-family:"DM Sans",sans-serif; font-weight:800; font-size:1.7rem; line-height:1.1; color:var(--navy); }
  .stat-card .lbl { font-size:.8rem; color:var(--muted); font-weight:600; margin-top:2px; }
  .stat-card.amber { border-top-color:#e6a23c; }
  .stat-card.amber .num { color:var(--amber-text); }
  .stat-card.green { border-top-color:var(--green); }
  .stat-card.green .num { color:var(--green-dark); }
  .stat-card.blue { border-top-color:var(--blue); }
  .stat-card.blue .num { color:var(--blue); }

  /* Draft/Final filter chips */
  .filter-chips { display:flex; gap:8px; margin:-4px 0 14px; flex-wrap:wrap; }
  .chip {
    border:1.5px solid var(--line); background:var(--card); border-radius:999px;
    padding:6px 16px; font-weight:700; font-size:.85rem; color:var(--muted);
    cursor:pointer; font-family:"DM Sans",sans-serif;
    transition:background .15s ease, color .15s ease, border-color .15s ease;
  }
  .chip:hover:not(.active) { border-color:var(--navy); color:var(--navy); }
  .chip.active { background:var(--navy); border-color:var(--navy); color:#fff; }
  .chip:focus-visible { outline:3px solid var(--blue); outline-offset:2px; }

  .enq-badge {
    display:inline-grid; place-items:center; min-width:20px; height:20px; padding:0 6px;
    margin-left:6px; border-radius:999px; background:var(--green); color:#fff;
    font-size:.72rem; font-weight:700;
  }
  .enquiry-item.unhandled { border-left:4px solid var(--green); }
  .enq-status {
    padding:7px 10px; border-radius:8px; font-size:.85rem; font-weight:700;
    font-family:"DM Sans",sans-serif; cursor:pointer; border:1.5px solid var(--line);
    background:var(--card); color:var(--text);
  }
  .enq-status.enq-new { border-color:var(--green); color:var(--green-dark); background:var(--green-light); }
  .enq-status.enq-contacted { border-color:#e6a23c; color:var(--amber-text); background:var(--amber-bg); }
  .enq-status.enq-scheduled { border-color:var(--blue); color:var(--blue); background:var(--blue-light); }
  .enq-status.enq-completed { border-color:var(--line); color:var(--muted); background:#f2f5f8; }
  /* GP referral request pipeline */
  .enq-status.ref-pending { border-color:#e6a23c; color:var(--amber-text); background:var(--amber-bg); }
  .enq-status.ref-sent { border-color:var(--blue); color:var(--blue); background:var(--blue-light); }
  .enq-status.ref-accepted { border-color:var(--green); color:var(--green-dark); background:var(--green-light); }
  .enq-status.ref-declined { border-color:var(--line); color:var(--muted); background:#f2f5f8; }
  .enquiry-item .contact-row { font-size:.9rem; color:var(--text); margin-top:4px; }
  .enquiry-item .contact-row a { color:var(--blue); text-decoration:none; font-weight:600; }
  .enquiry-item .msg { margin-top:8px; font-size:.92rem; color:var(--muted); white-space:pre-wrap; }

  .badge-role { font-size:.72rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase; padding:3px 10px; border-radius:999px; }
  .badge-admin { background:var(--blue-light); color:var(--blue); }
  .badge-pharm { background:var(--field); color:var(--muted); }
  .team-item select {
    padding:7px 10px; border:1.5px solid var(--line); border-radius:8px; font-size:.85rem;
    font-family:inherit; color:var(--text); background:var(--card); cursor:pointer;
  }
  .team-item .you { font-size:.78rem; color:var(--muted); font-weight:600; }

  /* Two-factor authentication */
  .tfa-secret {
    display:block; font-family:ui-monospace, Menlo, Consolas, monospace;
    font-size:1.05rem; letter-spacing:.16em; background:#f2f5f8;
    border:1px solid var(--line); border-radius:8px; padding:10px 14px;
    margin:8px 0 12px; word-break:break-all; color:var(--navy);
  }
  .tfa-code {
    width:140px; padding:10px 12px; border:1.5px solid var(--line); border-radius:10px;
    font-size:1.1rem; letter-spacing:.2em; text-align:center; font-family:inherit;
  }
  .tfa-code:focus { outline:none; border-color:var(--blue); box-shadow:0 0 0 4px rgba(43,115,184,.12); }

  .activity-list { display:flex; flex-direction:column; gap:2px; background:var(--card); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow-sm); }
  .activity-row { display:flex; align-items:center; gap:12px; padding:11px 18px; border-bottom:1px solid var(--line); font-size:.9rem; }
  .activity-row:last-child { border-bottom:none; }
  .activity-row .act-when { color:var(--muted); font-size:.82rem; white-space:nowrap; min-width:130px; }
  .activity-row .act-tag { font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.04em; padding:2px 8px; border-radius:6px; background:var(--field); color:var(--navy); white-space:nowrap; }
  .activity-row .act-tag.del { background:var(--danger-bg); color:var(--danger); }
  .activity-row .act-tag.new { background:var(--green-light); color:var(--green-dark); }
  .activity-row .act-who { font-weight:700; color:var(--navy); }
  .activity-row .act-detail { color:var(--muted); flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  @media (max-width:640px){ .activity-row { flex-wrap:wrap; } .activity-row .act-when { min-width:0; } }

  /* Visits calendar */
  .visit-day-head {
    font-family:"DM Sans",sans-serif; font-weight:800; color:var(--navy);
    font-size:.95rem; margin:18px 0 8px; display:flex; align-items:center; gap:10px;
  }
  .visit-day-head .count { font-size:.75rem; font-weight:700; color:var(--muted); }
  .visit-time {
    font-family:"DM Sans",sans-serif; font-weight:800; color:var(--blue);
    font-size:1.05rem; min-width:74px;
  }
  .visit-past { opacity:.62; }
  .visit-input {
    padding:7px 10px; border:1.5px solid var(--line); border-radius:8px;
    font-size:.85rem; font-family:inherit; color:var(--text); background:var(--card);
  }
  .visit-input:focus { outline:none; border-color:var(--blue); box-shadow:0 0 0 4px rgba(43,115,184,.12); }

  /* Follow-up reminders */
  .followups { margin-bottom:18px; }
  .followup-item { border-left:4px solid #e6a23c; }

  /* Practice insights (KPIs) */
  .insights-card {
    background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
    box-shadow:var(--shadow-sm); margin-bottom:18px; overflow:hidden;
  }
  .insights-card summary {
    list-style:none; cursor:pointer; padding:14px 18px;
    font-family:"DM Sans",sans-serif; font-weight:700; color:var(--navy); font-size:.98rem;
    display:flex; align-items:center; gap:10px;
  }
  .insights-card summary::-webkit-details-marker { display:none; }
  .insights-body { padding:4px 18px 20px; }
  .insights-grid { display:grid; grid-template-columns:1.2fr 1fr; gap:22px; }
  @media (max-width:760px){ .insights-grid { grid-template-columns:1fr; } }
  .kpi-bars { display:flex; align-items:flex-end; gap:10px; height:110px; margin-top:10px; }
  .kpi-bar { flex:1; display:flex; flex-direction:column; align-items:center; gap:4px; height:100%; justify-content:flex-end; }
  .kpi-bar .bar {
    width:100%; max-width:44px; border-radius:6px 6px 0 0; min-height:3px;
    background:linear-gradient(180deg, var(--blue), var(--navy));
  }
  .kpi-bar .val { font-size:.75rem; font-weight:800; color:var(--navy); font-family:"DM Sans",sans-serif; }
  .kpi-bar .lbl { font-size:.68rem; color:var(--muted); font-weight:600; }
  .kpi-facts { display:flex; flex-direction:column; gap:10px; }
  .kpi-fact { display:flex; justify-content:space-between; gap:12px; font-size:.9rem; border-bottom:1px dashed var(--line); padding-bottom:8px; }
  .kpi-fact:last-child { border-bottom:none; }
  .kpi-fact .k { color:var(--muted); }
  .kpi-fact .v { font-weight:700; color:var(--navy); text-align:right; }
  .kpi-note { font-size:.75rem; color:var(--muted); margin-top:12px; }

  /* Interaction warnings in the editor */
  .ix-warnings { display:flex; flex-direction:column; gap:8px; margin-bottom:14px; }
  .ix-warning {
    display:flex; gap:10px; align-items:flex-start;
    background:var(--amber-bg); border:1px solid var(--amber-line); color:var(--amber-deep);
    border-radius:10px; padding:10px 14px; font-size:.88rem;
  }
  .ix-warning strong { color:var(--amber-text); }
  .ix-warning svg { flex-shrink:0; margin-top:3px; color:#e6a23c; }

  /* Email receipt badges on report rows */
  .badge-sent { background:var(--blue-light); color:var(--blue); }
  .badge-opened { background:var(--green-light); color:var(--green-dark); }

  /* Claims (PPA) */
  .claim-item { border-left:4px solid var(--blue); }
  .claim-item.overdue { border-left-color:var(--danger); }
  .claim-select { font-size:.82rem; border:1px solid var(--line); border-radius:8px; padding:4px 8px; background:var(--card); color:var(--text); }
  .badge-claim-lodged { background:var(--amber-bg); color:var(--amber-text); }
  .badge-claim-paid { background:var(--green-light); color:var(--green-dark); }
  .badge-claim-overdue { background:var(--danger-bg); color:var(--danger); }

  /* Patients view */
  .patient-meta { display:flex; gap:14px; flex-wrap:wrap; font-size:.85rem; color:var(--muted); margin-top:4px; }
  .badge-eligible { background:var(--green-light); color:var(--green-dark); }

  /* Booking availability editor */
  .avail-days { display:grid; grid-template-columns:repeat(auto-fill, minmax(210px, 1fr)); gap:8px; }
  .avail-day { display:flex; align-items:center; gap:8px; background:var(--field); border:1px solid var(--line); border-radius:10px; padding:8px 10px; font-size:.88rem; }
  .avail-day input[type="time"] { border:1px solid var(--line); border-radius:6px; padding:3px 5px; font-size:.84rem; }
  .avail-day.off input[type="time"] { opacity:.35; pointer-events:none; }

  /* Visit route + calendar links */
  .visit-links { display:flex; gap:10px; flex-wrap:wrap; margin:6px 0 12px; }
  .visit-links a { font-size:.83rem; font-weight:700; color:var(--teal); text-decoration:none; }
  .visit-links a:hover { text-decoration:underline; }

  /* Offline indicator */
  .offline-pill {
    position:fixed; bottom:16px; left:50%; transform:translateX(-50%); z-index:900;
    background:#7a5410; color:#fff; border-radius:999px; padding:8px 18px;
    font-size:.85rem; font-weight:700; box-shadow:var(--shadow);
  }

  /* Idle lock */
  .idle-lock {
    position:fixed; inset:0; z-index:1000; display:flex; align-items:center; justify-content:center;
    background:rgba(20,43,70,.55); backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  }
  .idle-card {
    background:var(--card); border-radius:16px; box-shadow:var(--shadow); text-align:center;
    padding:34px 36px; max-width:400px; width:calc(100% - 40px);
  }
  .idle-card h2 { margin:10px 0 6px; color:var(--navy); }
  .idle-row { display:flex; gap:8px; margin-top:16px; }
  .idle-row input { flex:1; border:1px solid var(--line); border-radius:10px; padding:10px 12px; font-size:.95rem; }

  /* Global search (Cmd/Ctrl+K) */
  .gs-overlay {
    position:fixed; inset:0; z-index:950; background:rgba(20,43,70,.45);
    display:flex; align-items:flex-start; justify-content:center; padding:12vh 16px 16px;
  }
  .gs-card { width:100%; max-width:560px; background:var(--card); border-radius:16px; box-shadow:var(--shadow); overflow:hidden; }
  .gs-card input {
    width:100%; border:none; padding:16px 20px; font-size:1.05rem; font-family:inherit; color:var(--text);
    border-bottom:1px solid var(--line);
  }
  .gs-card input:focus { outline:none; }
  .gs-results { max-height:46vh; overflow-y:auto; }
  .gs-item {
    display:flex; align-items:center; gap:12px; width:100%; text-align:left;
    padding:11px 20px; border:none; background:none; cursor:pointer; font-family:inherit; font-size:.93rem;
    border-bottom:1px solid var(--line); color:var(--text);
  }
  .gs-item:hover, .gs-item:focus-visible { background:var(--blue-light); outline:none; }
  .gs-item .gs-type {
    font-size:.68rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em;
    padding:2px 8px; border-radius:6px; background:var(--field); color:var(--navy); flex-shrink:0; min-width:64px; text-align:center;
  }
  .gs-item .gs-sub { color:var(--muted); font-size:.8rem; margin-left:auto; white-space:nowrap; }
  .gs-empty { padding:18px 20px; color:var(--muted); font-size:.9rem; }
  .gs-hint { padding:8px 20px 12px; color:var(--muted); font-size:.75rem; border-top:1px solid var(--line); }

  /* Enquiry contact log */
  .enq-notes { width:100%; margin-top:8px; font-size:.86rem; }
  .enq-notes summary { cursor:pointer; font-weight:700; color:var(--blue); list-style:none; }
  .enq-notes summary::-webkit-details-marker { display:none; }
  .note-row { padding:6px 0; border-bottom:1px dashed var(--line); }
  .note-row .note-meta { color:var(--muted); font-size:.76rem; }
  .note-add { display:flex; gap:8px; margin-top:8px; }
  .note-add input { flex:1; }

  /* Duplicate-patient hint */
  .dup-hint {
    background:var(--amber-bg); border:1px solid var(--amber-line); color:var(--amber-deep);
    border-radius:10px; padding:10px 14px; font-size:.88rem; margin-bottom:14px;
  }

  /* Deprescribing + preventive-care prompts (editor) */
  #clinical-prompts { display:flex; flex-direction:column; gap:8px; margin-bottom:14px; }
  .cp-item {
    display:flex; gap:10px; align-items:flex-start;
    background:var(--blue-light); border:1px solid #c9ddf2; color:#1c3a5e;
    border-radius:10px; padding:10px 14px; font-size:.88rem;
  }
  .cp-item .cp-kind {
    flex-shrink:0; font-size:.66rem; font-weight:800; letter-spacing:.06em; text-transform:uppercase;
    background:var(--card); color:var(--blue); border-radius:6px; padding:2px 7px; margin-top:2px;
  }
  .cp-item button { margin-left:auto; flex-shrink:0; white-space:nowrap; }

  /* Kanban pipeline board (Enquiries) */
  .kanban { display:grid; grid-template-columns:repeat(4, minmax(190px, 1fr)); gap:12px; overflow-x:auto; }
  .kanban-col { background:var(--field); border:1px solid var(--line); border-radius:12px; padding:10px; min-height:180px; }
  .kanban-col.drag-over { background:var(--blue-light); border-color:var(--blue); }
  .kanban-col h4 { font-size:.8rem; text-transform:uppercase; letter-spacing:.05em; color:var(--muted); margin-bottom:10px; }
  .kanban-card {
    background:var(--card); border:1px solid var(--line); border-radius:10px; padding:9px 11px;
    margin-bottom:8px; font-size:.86rem; cursor:grab; box-shadow:var(--shadow-sm);
  }
  .kanban-card.dragging { opacity:.45; }
  .kanban-card .kc-name { font-weight:700; color:var(--navy); }
  .kanban-card .kc-sub { color:var(--muted); font-size:.78rem; }
  @media (max-width: 900px) { .kanban { grid-template-columns:repeat(2, minmax(160px, 1fr)); } }

  /* Messages (two-way SMS) */
  .msg-thread-item { cursor:pointer; }
  .msg-unread-dot { width:9px; height:9px; border-radius:50%; background:var(--blue); display:inline-block; margin-right:6px; }
  .msg-bubbles { display:flex; flex-direction:column; gap:6px; margin:12px 0; }
  .msg-bubble { max-width:78%; border-radius:12px; padding:8px 12px; font-size:.9rem; }
  .msg-bubble.in { background:var(--field); align-self:flex-start; }
  .msg-bubble.out { background:var(--green-light); align-self:flex-end; }
  .msg-bubble .msg-meta { font-size:.72rem; color:var(--muted); margin-top:3px; }

  /* Invoice aging strip */
  .aging-strip { display:grid; grid-template-columns:repeat(4, 1fr); gap:10px; margin-bottom:16px; }
  .aging-cell { background:var(--card); border:1px solid var(--line); border-radius:12px; padding:10px 14px; }
  .aging-cell .num { font-family:"DM Sans",sans-serif; font-weight:800; font-size:1.15rem; color:var(--navy); }
  .aging-cell .lbl { font-size:.75rem; color:var(--muted); }
  .aging-cell.hot .num { color:var(--danger); }
  @media (max-width: 700px) { .aging-strip { grid-template-columns:repeat(2, 1fr); } }

  /* Report photo attachments */
  .photo-grid { display:flex; gap:10px; flex-wrap:wrap; margin:10px 0; }
  .photo-thumb { position:relative; width:110px; }
  .photo-thumb img { width:110px; height:82px; object-fit:cover; border-radius:8px; border:1px solid var(--line); display:block; }
  .photo-thumb button {
    position:absolute; top:-7px; right:-7px; width:22px; height:22px; border-radius:50%;
    border:none; background:var(--danger); color:#fff; font-size:.85rem; line-height:1; cursor:pointer;
  }

  /* Blackout dates (booking availability) */
  .blocked-chip {
    display:inline-flex; align-items:center; gap:6px; background:var(--amber-bg); color:var(--amber-deep);
    border:1px solid var(--amber-line); border-radius:999px; padding:3px 6px 3px 12px; font-size:.82rem; font-weight:700;
  }
  .blocked-chip button {
    border:none; background:none; color:var(--amber-text); cursor:pointer; font-size:1rem; line-height:1; padding:2px 6px;
  }

  /* System status (setup health check) */
  .status-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:8px; }
  .status-row {
    display:flex; align-items:center; gap:10px; background:var(--field); border:1px solid var(--line);
    border-radius:10px; padding:9px 12px; font-size:.88rem;
  }
  .status-row .dot { font-weight:800; }
  .status-row.ok .dot { color:var(--green-dark); }
  .status-row.off .dot { color:var(--muted); }

  /* Final-report lock banner */
  .final-banner {
    display:flex; align-items:center; gap:12px; flex-wrap:wrap;
    background:var(--blue-light); border:1px solid #cfe0f2; color:var(--navy);
    border-radius:10px; padding:10px 16px; font-size:.9rem; margin-bottom:16px;
  }
  #report-form.locked { opacity:.62; pointer-events:none; }

  /* Field-level validation hint (Medicare checksum) */
  .field-warn { font-size:.8rem; color:var(--danger); font-weight:600; margin-top:4px; min-height:0; }

  /* Feedback display on enquiry cards */
  .fb-stars { color:#f0a63c; letter-spacing:.06em; }

  /* Patient action plan (large print) */
  #report-doc.patient-plan { font-size:1.12rem; line-height:1.65; }
  #report-doc.patient-plan h1 { font-size:1.5rem; text-transform:none; letter-spacing:0; }
  #report-doc.patient-plan h2 { font-size:1.18rem; margin:22px 0 8px; color:var(--navy); }
  #report-doc.patient-plan td, #report-doc.patient-plan th { font-size:1.02rem; padding:10px 12px; }
  #report-doc.patient-plan li { margin-bottom:8px; }

  /* ---------- Editor ---------- */
  .editor-head { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin-bottom:20px; }
  .editor-head .left { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
  .autosave { font-size:.82rem; color:var(--muted); }
  .autosave.saved { color:var(--green-dark); font-weight:600; }
  .autosave.error { color:var(--danger); font-weight:600; }

  /* Interview tools bar (on-device recorder) */
  .tools-bar {
    background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
    box-shadow:var(--shadow-sm); padding:12px 16px; margin-bottom:18px;
  }
  .tools-controls { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
  .tools-note { font-size:.78rem; color:var(--muted); margin-top:8px; }
  .rec-dot {
    width:9px; height:9px; border-radius:50%; background:var(--danger); flex-shrink:0;
  }
  #btn-record.recording {
    border-color:var(--danger); color:var(--danger); background:var(--danger-bg);
  }
  #btn-record.recording .rec-dot { animation:recPulse 1.2s ease-in-out infinite; }
  @keyframes recPulse { 0%,100% { opacity:1; } 50% { opacity:.25; } }
  .rec-timer {
    font-family:"DM Sans",sans-serif; font-weight:800; color:var(--danger);
    font-variant-numeric:tabular-nums; font-size:.95rem;
  }
  .rec-audio { height:36px; max-width:280px; }

  /* Common-phrase snippet picker under recommendation/monitoring boxes */
  .snippet-select {
    margin-top:6px; width:100%; padding:8px 10px;
    border:1.5px dashed var(--line); border-radius:8px;
    color:var(--muted); font-size:.83rem; font-family:inherit;
    background:var(--card); cursor:pointer;
  }
  .snippet-select:focus { outline:none; border-color:var(--blue); }

  .section-card { margin-bottom:18px; overflow:hidden; }
  .section-card summary {
    list-style:none; cursor:pointer; padding:18px 22px;
    display:flex; align-items:center; gap:12px;
    font-family:"DM Sans",sans-serif; font-weight:700; color:var(--navy); font-size:1.05rem;
    background:var(--card);
  }
  .section-card summary::-webkit-details-marker { display:none; }
  .section-card summary .num {
    width:30px; height:30px; border-radius:9px; flex-shrink:0;
    background:linear-gradient(135deg,var(--green-light),var(--blue-light));
    color:var(--blue); display:grid; place-items:center; font-size:.9rem;
  }
  .section-card summary .chev { margin-left:auto; transition:transform .25s var(--ease); color:var(--muted); }
  .section-card[open] summary .chev { transform:rotate(180deg); }
  .section-card {
    background:var(--card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow-sm);
  }
  .section-body { padding:6px 22px 24px; }
  .grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:0 18px; }
  @media (max-width:700px){ .grid-2 { grid-template-columns:1fr; } }
  .hint { font-size:.82rem; color:var(--muted); margin:-8px 0 14px; }

  /* Repeating rows */
  .rep-row {
    border:1px solid var(--line); border-radius:12px; padding:16px 16px 8px;
    margin-bottom:14px; background:var(--field); position:relative;
  }
  .rep-row .rep-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
  .rep-row .rep-title { font-weight:700; color:var(--blue); font-size:.82rem; letter-spacing:.06em; text-transform:uppercase; }
  .rep-remove {
    background:none; border:none; color:var(--danger); cursor:pointer; font-weight:700; font-size:.85rem;
    padding:4px 8px; border-radius:6px;
  }
  .rep-remove:hover { background:var(--danger-bg); }
  .add-row {
    background:none; border:1.5px dashed var(--blue); color:var(--blue); width:100%;
    padding:11px; border-radius:10px; cursor:pointer; font-weight:700; font-family:"DM Sans",sans-serif; font-size:.92rem;
  }
  .add-row:hover { background:var(--blue-light); }

  /* ---------- Preview ---------- */
  .preview-bar { display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between; margin-bottom:18px; }
  #report-doc {
    background:#fff; border:1px solid var(--line); border-radius:6px;
    box-shadow:var(--shadow); max-width:880px; margin:0 auto;
    padding:56px 62px; font-size:.95rem; color:#1a1a1a; font-family:Arial, "Source Sans 3", sans-serif;
  }
  #report-doc h1 {
    font-size:1.15rem; text-align:center; text-transform:uppercase; letter-spacing:.04em;
    color:var(--navy); font-family:Arial,sans-serif; margin-bottom:4px;
  }
  #report-doc .doc-brand { text-align:center; font-weight:700; color:var(--green-dark); margin-bottom:2px; font-size:.9rem; }
  #report-doc .doc-conf { text-align:center; font-size:.72rem; color:#888; margin-bottom:22px; letter-spacing:.03em; }
  #report-doc h2 { font-size:.95rem; font-family:Arial,sans-serif; color:#000; margin:20px 0 6px; }
  #report-doc table { width:100%; border-collapse:collapse; margin-bottom:8px; }
  #report-doc td, #report-doc th {
    border:1px solid #444; padding:7px 10px; vertical-align:top; font-size:.88rem; text-align:left;
  }
  #report-doc th { background:#eef3f8; font-weight:700; }
  #report-doc ul { margin:4px 0 4px 18px; }
  #report-doc li { margin-bottom:4px; }
  #report-doc .refs { font-size:.8rem; }
  #report-doc .refs p { margin-bottom:6px; }
  #report-doc .differs { font-weight:700; }
  #report-doc .plan-opt { white-space:nowrap; }
  #report-doc p { margin-bottom:8px; }

  @media (max-width:720px){
    #report-doc { padding:22px 12px; }
    #report-doc td, #report-doc th { padding:6px; overflow-wrap:anywhere; }
    #report-doc .plan-opt { white-space:normal; }
  }

  @media print {
    body { background:#fff; }
    body > *:not(#view-preview) { display:none !important; }
    #view-preview .preview-bar { display:none !important; }
    .wrap { padding:0; max-width:none; }
    #report-doc { border:none; box-shadow:none; padding:0; max-width:none; }
    /* Keep each finding's row (and section headings) together across pages. */
    #report-doc tr { break-inside:avoid; }
    #report-doc h2 { break-after:avoid; }
  }

/* AI drafting — draft buttons sit beside the prose fields they fill, styled as
   a quiet secondary action so they never compete with Save or Finalise. */
.ai-draft {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand, #2b73b8);
  background: #fff;
  border: 1.5px solid var(--brand, #2b73b8);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ai-draft:hover:not(:disabled),
.ai-draft:focus-visible:not(:disabled) { background: var(--brand, #2b73b8); color: #fff; }
.ai-draft:disabled { opacity: 0.6; cursor: progress; }

/* "What gets sent" — the pharmacist can read the exact de-identified payload
   before any of it leaves the practice. */
.ai-payload-preview { margin-top: 14px; }
.ai-payload-preview > summary {
  cursor: pointer; font-size: 0.82rem; font-weight: 700; color: var(--muted, #5c6b7a);
}
.ai-payload-preview pre {
  max-height: 320px; overflow: auto; margin-top: 8px; padding: 12px;
  background: #f6fafd; border: 1px solid var(--line, #e4ecf3); border-radius: 10px;
  font-size: 0.75rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}

/* Text for screen readers only (e.g. a label for an input with a visible placeholder). */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Claude drafting: panel in the report editor, checklist, list badge */
.badge-claude { background: #efe9fb; color: #4b2a8a; }
.claude-panel { margin: 0 0 16px; padding: 14px 16px; border: 1px solid #ddd3f3; border-radius: 12px; background: #faf8ff; }
.claude-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.claude-meta { margin: 12px 0 6px; font-size: .9rem; }
.claude-progress { margin: 0 0 6px; font-weight: 700; font-size: .88rem; color: #4b2a8a; }
.claude-checklist { list-style: none; margin: 0; padding: 0; }
.claude-checklist li { padding: 6px 0; border-top: 1px solid #ece6f8; font-size: .92rem; }
.claude-checklist label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.claude-checklist input { margin-top: 4px; width: 16px; height: 16px; flex-shrink: 0; }
.claude-ref { font: 700 .72rem "DM Sans", sans-serif; letter-spacing: .04em; color: #4b2a8a; background: #efe9fb;
  border-radius: 999px; padding: 1px 8px; flex-shrink: 0; margin-top: 2px; }
.claude-steps { margin: 0 0 6px 20px; font-size: .92rem; }
.claude-steps li { margin-bottom: 6px; }

/* Interview mode: full screen, large touch targets for a tablet at the kitchen table */
body.iv-open { overflow: hidden; }
.interview { position: fixed; inset: 0; z-index: 200; background: #f6f8fb; display: flex; flex-direction: column; }
.iv-top { background: #fff; border-bottom: 1px solid var(--line, #e4ecf3); padding: 12px 16px 8px; }
.iv-top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 860px; margin: 0 auto; }
.iv-top h2 { margin: 0; font-size: 1.25rem; }
.iv-progress { font-size: .85rem; color: var(--muted, #5c6b7a); }
.iv-steps { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; max-width: 860px; margin: 0 auto; scrollbar-width: thin; }
.iv-step { flex: 0 0 auto; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1.5px solid #dbe3ec;
  background: #fff; font: 600 .88rem "DM Sans", sans-serif; color: #1c3a5e; cursor: pointer; }
.iv-step.done { border-color: #9cc78f; color: #2f6125; }
.iv-step.on { background: #1c3a5e; border-color: #1c3a5e; color: #fff; }
.iv-body { flex: 1; overflow-y: auto; padding: 16px; width: 100%; max-width: 860px; margin: 0 auto; box-sizing: border-box; }
.iv-q { background: #fff; border: 1px solid #e4ecf3; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.iv-q-text { display: block; font-weight: 700; color: #1c3a5e; font-size: 1.05rem; margin-bottom: 10px; }
.iv-choices { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.iv-choice { min-width: 96px; min-height: 48px; border-radius: 12px; border: 1.5px solid #cfd9e4; background: #fff;
  font: 700 1rem "DM Sans", sans-serif; color: #1c3a5e; cursor: pointer; }
.iv-choice.on[data-iv-a="yes"] { background: #3d7d30; border-color: #3d7d30; color: #fff; }
.iv-choice.on[data-iv-a="no"] { background: #1c3a5e; border-color: #1c3a5e; color: #fff; }
.iv-choice.on[data-iv-a="na"] { background: #eef2f6; border-color: #9aa8b5; color: #324154; }
.iv-note { width: 100%; box-sizing: border-box; font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid #dbe3ec; resize: vertical; }
.iv-med { background: #fff; border: 1px solid #e4ecf3; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; display: grid; gap: 8px; }
.iv-med-new { border-style: dashed; }
.iv-med-name { font-weight: 800; color: #1c3a5e; font-size: 1.05rem; }
.iv-med label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; color: #324154; }
.iv-med input[type="text"], .iv-med textarea { font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 10px; border: 1.5px solid #dbe3ec; }
.iv-med .iv-check { display: flex; gap: 10px; align-items: center; }
.iv-med .iv-check input { width: 22px; height: 22px; }
.iv-hint { color: var(--muted, #5c6b7a); font-size: .95rem; margin: 4px 0 12px; }
.iv-sum h3 { font-size: 1.05rem; margin: 18px 0 8px; color: #1c3a5e; }
.iv-prompts li { background: #fff7e6; border: 1px solid #f3dca8; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; list-style: none; }
.iv-prompts, .iv-gaps { padding: 0; margin: 0; }
.iv-gaps li { list-style: none; margin-bottom: 4px; }
.iv-link { background: none; border: 0; padding: 6px 0; color: #1f5a94; font: inherit; text-decoration: underline; cursor: pointer; text-align: left; min-height: 36px; }
.iv-finish { display: flex; gap: 10px; flex-wrap: wrap; }
.iv-foot { background: #fff; border-top: 1px solid #e4ecf3; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.iv-foot .btn { min-height: 48px; min-width: 120px; justify-content: center; }
.iv-saved { font-size: .85rem; color: var(--muted, #5c6b7a); }
.iv-addmed { margin-top: 8px; }
