/* ===========================================================================
   GuardianLink RPM — Design System  ("Guardian Link" — navy + bright blue)
   Matched to the Guardian Link Solutions brand (shield + chain).
   Display: Fraunces (characterful serif)  ·  Body/UI: Hanken Grotesk
   Load once per page:  <link rel="stylesheet" href="styles.css">
   =========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Hanken+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* Brand (Guardian Link navy + the bright "chain" blue) */
  --brand:        #1d3c61;   /* GUARDIAN LINK navy */
  --brand-strong: #15304e;
  --brand-700:    #1a3556;
  --accent:       #2b9fd6;   /* bright link blue */
  --brand-soft:   #e7f1fb;   /* chip / highlight bg */
  --brand-ring:   rgba(43,159,214,.38);

  /* Neutrals (slate w/ a faint navy cast) */
  --bg:          #f4f7fb;
  --surface:     #ffffff;
  --surface-2:   #eef3f9;
  --border:      #e3e9f1;
  --border-2:    #d2deea;
  --text:        #12243a;
  --text-2:      #3a506b;
  --muted:       #6a7d93;

  /* Status */
  --ok:      #15803d;  --ok-bg:   #dcfce7;  --ok-bd:   #bbf7d0;
  --warn:    #b45309;  --warn-bg: #fef3c7;  --warn-bd: #fde68a;
  --danger:  #b91c1c;  --danger-bg:#fee2e2; --danger-bd:#fecaca;
  --info:    #1d6fa3;  --info-bg: #e0f0fb;  --info-bd: #b9ddf5;

  /* Sidebar (deep navy — matches the dark shield) */
  --side-bg-1: #1a3350;
  --side-bg-2: #102135;
  --side-text: #c2d2e6;
  --side-text-dim: #7e93ad;
  --side-active-bg: rgba(255,255,255,.10);
  --side-active-bar: var(--accent);

  --shadow-sm: 0 1px 2px rgba(13,30,53,.05);
  --shadow:    0 1px 2px rgba(13,30,53,.04), 0 6px 20px rgba(13,30,53,.08);
  --shadow-lg: 0 12px 40px rgba(13,30,53,.16);

  --r:    14px;
  --r-sm: 10px;
  --r-xs: 8px;
  --sidebar-w: 252px;
  --font-body: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* faint atmospheric background */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 500px at 100% -5%, rgba(43,159,214,.07), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(29,60,97,.06), transparent 55%);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; color: var(--text); letter-spacing: -.01em; margin: 0; }

/* ============================ SIDEBAR ==================================== */
#nav { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40; }

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--side-bg-1), var(--side-bg-2));
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: #fff;
  box-shadow: 0 4px 14px rgba(7,18,32,.40), inset 0 1px 0 rgba(255,255,255,.6);
}
.brand-mark svg, .brand-mark img { width: 30px; height: 30px; display: block; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: #fff; line-height: 1.1; }
.brand-sub  { font-size: 10px; letter-spacing: .16em; color: var(--side-text-dim); text-transform: uppercase; margin-top: 2px; }

.nav-group { margin-top: 14px; }
.nav-group-label {
  font-size: 10.5px; letter-spacing: .15em; text-transform: uppercase;
  color: var(--side-text-dim); padding: 0 12px 6px; font-weight: 700;
}
.sidebar a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 1px 0;
  border-radius: 10px; color: var(--side-text);
  font-size: 14px; font-weight: 500; position: relative;
  transition: background .15s ease, color .15s ease;
}
.sidebar a svg { width: 17px; height: 17px; opacity: .85; flex: none; }
.sidebar a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar a.active { background: var(--side-active-bg); color: #fff; }
.sidebar a.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--side-active-bar);
}

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.side-avatar {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: rgba(255,255,255,.12); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.side-user-name { font-size: 13px; color: #fff; font-weight: 600; }
.side-user-role { font-size: 11px; color: var(--side-text-dim); }
.side-signout {
  display: flex; align-items: center; gap: 9px; margin-top: 8px;
  padding: 8px 12px; border-radius: 9px; font-size: 13px; color: var(--side-text-dim) !important;
}
.side-signout:hover { background: rgba(255,255,255,.05); color: #fff !important; }

/* ============================ LAYOUT ===================================== */
.main {
  margin-left: var(--sidebar-w);
  padding: 30px 40px 64px;
  min-height: 100vh;
  max-width: 1320px;
}

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================ CARDS ====================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 9px; }
.card-title svg { width: 18px; height: 18px; color: var(--brand); }
.card-title-action { justify-content: space-between; gap: 12px; }
.card-title-action span { min-width: 0; }
.card-title-action .card-edit-link {
  flex: none;
  margin-left: auto;
  font-family: var(--font-body);
}

/* ============================ STATS ====================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat::after { content:""; position:absolute; top:0; left:0; width:3px; height:100%; background:linear-gradient(var(--accent),var(--brand)); opacity:.9; }
.stat-label { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 34px; font-weight: 600; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ============================ CHIPS / BADGES ============================= */
.chip, .badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.6;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.chip .dot, .badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok,     .badge.ok     { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok-bd); }
.chip.warn,   .badge.warn   { background: var(--warn-bg);   color: var(--warn);   border-color: var(--warn-bd); }
.chip.danger, .badge.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.chip.info,   .badge.info   { background: var(--info-bg);   color: var(--info);   border-color: var(--info-bd); }
.chip.brand,  .badge.brand  { background: var(--brand-soft);color: var(--brand-strong); border-color: #c2ddf4; }

/* ============================ BUTTONS ==================================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all .15s ease;
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: var(--border-2); background: #e9eff7; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 2px 8px rgba(29,60,97,.25); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: 0 2px 8px rgba(185,28,28,.18); }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ============================ TABLES ===================================== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}
table.data { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
table.data.patients-table { min-width: 1380px; }
table.data.claims-table { min-width: 980px; }
table.data.critical-table { min-width: 900px; }
table.data.users-table { min-width: 820px; }
table.data thead th {
  text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 13px 18px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
table.data tbody td { padding: 13px 18px; border-bottom: 1px solid var(--border); color: var(--text-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: #f3faf9; }
table.data td .strong, table.data td b { color: var(--text); font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============================ LIST ROWS (worklist / alerts) ============== */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: transform .1s ease, box-shadow .12s ease;
}
.row:hover { box-shadow: var(--shadow-sm); }
.row[onclick] { cursor: pointer; }
.row[onclick]:hover { transform: translateX(2px); }
.row.good   { background: var(--ok-bg);     border-color: var(--ok-bd); }
.row.warn   { background: var(--warn-bg);   border-color: var(--warn-bd); }
.row.bad,
.row.red    { background: var(--danger-bg); border-color: var(--danger-bd); }
.row.yellow { background: var(--warn-bg);   border-color: var(--warn-bd); }
.row .row-name { font-weight: 600; color: var(--text); }
.row .row-meta { color: var(--text-2); font-size: 13px; }
.row .spacer { margin-left: auto; }

.empty { color: var(--muted); font-style: italic; padding: 8px 2px; }

/* ============================ FORMS ====================================== */
label, .field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
input:not([type]), input[type=text], input[type=email], input[type=password],
input[type=date], input[type=datetime-local], input[type=number],
input[type=tel], input[type=search], input[type=month], input[type=file],
select, textarea {
  width: 100%; min-height: 42px; padding: 10px 12px; font-family: var(--font-body); font-size: 14px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-2); border-radius: 10px; outline: none;
  color-scheme: light;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--brand-strong) 50%),
    linear-gradient(135deg, var(--brand-strong) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select option {
  color: var(--text);
  background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--brand-ring); }
.field { margin-bottom: 16px; }
.autocomplete-field { position: relative; }
.autocomplete-menu {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(15, 35, 64, .16);
}
.autocomplete-menu[hidden] { display: none; }
.autocomplete-option {
  width: 100%;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-family: var(--font-body);
  cursor: pointer;
}
.autocomplete-option span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}
.autocomplete-option small {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.25;
}
.autocomplete-option:hover,
.autocomplete-option[aria-selected="true"] {
  background: #eef6ff;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(185,28,28,.12);
}
.field-error {
  display: block;
  margin-top: 6px;
  min-height: 16px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}
.field-error:empty { min-height: 0; margin-top: 0; }
.field.is-hidden { display: none !important; }
.field-script {
  grid-column: 1 / -1;
  margin-bottom: 8px;
}
.call-script {
  width: 100%;
  min-height: 42px;
  padding: 11px 13px;
  border: 1px solid #c7dced;
  border-radius: 10px;
  background: #f5fbff;
  color: var(--text-2);
  font-size: 13.5px;
}
.ix-section {
  margin-top: 6px;
}
.ix-section-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 14px 0 8px;
}
.call-script-section {
  padding: 13px 14px;
  margin: 0 0 12px;
  border: 1px solid #c7dced;
  border-radius: 10px;
  background: #f8fcff;
}
.call-script-title {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.call-script-body {
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-line;
}
.hmo-only { display: none; }
.hmo-only.is-visible { display: block; }
.inline-hmo-only { display: none; }
.inline-hmo-only.is-visible { display: block; }

.main.form-page {
  max-width: none;
  padding-right: 56px;
}
.intake-form {
  width: 100%;
  max-width: none;
  padding: 28px 32px 30px;
}
.intake-form .card-title {
  margin: 30px 0 14px;
  padding-top: 2px;
}
.intake-form .card-title:first-child { margin-top: 0; }
.intake-form .form-grid {
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 22px 28px;
  align-items: start;
}
.intake-form .field { margin-bottom: 0; }
.intake-form label { color: var(--brand-strong); }
.intake-form input:not([type]),
.intake-form input[type=text],
.intake-form input[type=email],
.intake-form input[type=password],
.intake-form input[type=date],
.intake-form input[type=datetime-local],
.intake-form input[type=number],
.intake-form input[type=tel],
.intake-form input[type=search],
.intake-form select,
.intake-form textarea {
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 15px;
  background-color: #fff;
}
.intake-form input::placeholder,
.intake-form textarea::placeholder { color: #8394a8; }
.form-note {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.reading-import-card textarea {
  min-height: 180px;
}
.form-result {
  margin-top: 12px;
}
.intake-form .btn-row { margin-top: 24px; }

/* inline date/control bars (billing/report filters) keep buttons aligned */
.control-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.control-bar input { width: auto; }
.list-toolbar,
.sticky-list-toolbar {
  position: sticky;
  top: 0;
  z-index: 25;
}
.list-toolbar {
  background: var(--surface);
}
.sticky-list-toolbar {
  box-shadow: var(--shadow);
}

/* ============================ TABS / CHART HUB =========================== */
.tabbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.tabbar .tab {
  border: 0; border-radius: 10px; background: transparent; color: var(--text-2);
  padding: 9px 14px; font: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: background .12s ease, color .12s ease;
}
.tabbar .tab:hover { background: var(--surface-2); color: var(--brand); }
.tabbar .tab.active { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(29,60,97,.18); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.chart-hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 22px; align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 18px;
}
.chart-eyebrow {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); font-weight: 800; margin-bottom: 4px;
}
.chart-hero h1 { font-size: 31px; line-height: 1.12; margin-bottom: 6px; }
.chart-meta { color: var(--text-2); font-size: 14px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 18px; }
.detail-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-item { min-width: 0; }
.detail-label {
  font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 800; margin-bottom: 3px;
}
.detail-value { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.chart-inline-edit {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.chart-inline-edit .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.chart-inline-actions {
  margin-top: 16px;
}

/* ================= FLOATING TIMER + CATEGORIZATION MODAL ================ */
.rpm-floating-timer {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  width: min(420px, calc(100vw - 48px));
}
.rpm-floating-timer[hidden] { display: none !important; }
.rpm-timer-widget {
  padding: 14px 16px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(13,30,53,.18);
}
.rpm-timer-eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.rpm-timer-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rpm-timer-clock {
  min-width: 72px;
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.rpm-timer-meta {
  min-width: 0;
  flex: 1 1 auto;
}
.rpm-timer-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.rpm-timer-patient {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.rpm-timer-patient { color: var(--brand); }
.rpm-timer-text,
.rpm-timer-message {
  color: var(--text-2);
  font-size: 13px;
}
.rpm-timer-message {
  min-height: 18px;
  margin-top: 8px;
}
.rpm-timer-btn,
.rpm-timer-icon-btn {
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.rpm-timer-btn {
  min-height: 36px;
  padding: 8px 12px;
}
.rpm-timer-btn:hover,
.rpm-timer-icon-btn:hover {
  border-color: var(--accent);
}
.rpm-timer-btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}
.rpm-timer-btn-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}
.rpm-timer-btn-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}
.rpm-timer-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
}
.rpm-timer-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 20, 34, .42);
}
.rpm-timer-modal-panel {
  width: min(480px, 100%);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.rpm-timer-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.rpm-timer-modal-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
}
.rpm-timer-modal-patient {
  margin: 8px 0 16px;
  color: var(--text-2);
  font-weight: 700;
}
.rpm-timer-field {
  display: block;
  margin-bottom: 14px;
}
.rpm-timer-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 800;
}
.rpm-timer-field textarea {
  resize: vertical;
}
.rpm-timer-modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.rpm-timer-action-spacer {
  flex: 1 1 auto;
}

/* ============================ MISC ======================================= */
.muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
canvas { max-width: 100%; }

/* ============================ RESPONSIVE ================================= */
@media (max-width: 1200px) {
  .intake-form .form-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}

@media (max-width: 900px) {
  #nav { position: static; width: auto; }
  .sidebar { width: auto; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 6px; }
  .sidebar .nav-group { margin-top: 0; display: flex; align-items: center; gap: 4px; }
  .nav-group-label, .side-foot, .brand-sub { display: none; }
  .main { margin-left: 0; padding: 20px; }
  .main.form-page { padding: 20px; }
  .intake-form { padding: 22px; }
  .filterbar { flex-direction: column; align-items: stretch; }
  .filterbar .spacer { display: none; }
  .chart-hero, .two-col { grid-template-columns: 1fr; }
  .detail-grid.compact { grid-template-columns: 1fr; }
  .rpm-floating-timer {
    right: 16px;
    bottom: 16px;
    width: min(420px, calc(100vw - 32px));
  }
}

@media (max-width: 640px) {
  .intake-form .form-grid { grid-template-columns: 1fr; }
}

/* ===================== FILTER BAR + PAGINATION (shared) =================== */
.filterbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.filterbar .fb-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.filterbar input[type="date"], .filterbar input[type="month"],
.filterbar input[type="search"], .filterbar input[type="text"], .filterbar select {
  height: 36px; padding: 0 10px; border: 1px solid var(--border-2);
  border-radius: var(--r-xs); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13.5px;
}
.filterbar input:focus, .filterbar select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--brand-ring);
}
.filterbar .spacer { flex: 1 1 auto; }

.preset {
  display: inline-flex; align-items: center; height: 32px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .12s ease;
}
.preset:hover { border-color: var(--accent); color: var(--brand); }
.preset.active { background: var(--brand-soft); border-color: var(--accent); color: var(--brand-strong); }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 14px 4px 2px; font-size: 13px;
}
.pager .pager-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pager .pager-info { color: var(--text-2); }
.pager .pager-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.pager .pager-size select {
  width: auto;
  min-height: 32px;
  height: 32px;
  padding: 0 30px 0 10px;
  border-radius: var(--r-xs);
  font-size: 13px;
}
.pager .pager-btns { display: flex; align-items: center; gap: 6px; }
.pager button {
  height: 32px; min-width: 34px; padding: 0 12px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text); border-radius: var(--r-xs);
  font: inherit; font-weight: 600; cursor: pointer; transition: all .12s ease;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--brand); }
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.pager .pager-page { padding: 0 8px; color: var(--text-2); font-weight: 600; }

/* Dashboard metric grid — exactly 4 per row (even rows), responsive down. */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .metric-grid { grid-template-columns: 1fr; } }

/* Clickable / alert metric cards (dashboard) */
.stat.clickable { cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease, transform .06s ease; }
.stat.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.stat.clickable:active { transform: translateY(1px); }
.stat.alert { border-color: var(--danger-bd); background: var(--danger-bg); }
.stat.alert .stat-value { color: var(--danger); }
.stat.alert .stat-label { color: var(--danger); }

/* Show/hide password toggle (login + reset pages; see pw-toggle.js) */
.pw-field { position: relative; }
.pw-field input { width: 100%; padding-right: 40px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}
.pw-toggle:hover { color: var(--text); background: rgba(7, 18, 32, .05); }
