/* ============================================================================
   PrimeCare Home Health — production stylesheet
   Brand palette derived from the PrimeCare logo:
   - Purple  #6B2E89  (primary)
   - Orange  #F58220  (accent / "submit" warmth)
   - Blue    #1E3A8A  (secondary accent, links)
   Designed for iPad-first use: 16px+ form text (prevents iOS zoom), 44pt+ touch targets.
   ============================================================================ */

:root {
  /* Brand */
  --brand:        #6B2E89;
  --brand-hover:  #5A2474;
  --brand-soft:   #F4ECF7;   /* tinted background for hover/highlight rows */
  --brand-2:      #1E3A8A;   /* secondary accent */
  --accent:       #F58220;
  --accent-soft:  #FFF1E2;

  /* Neutrals */
  --bg:           #F7F5FA;   /* subtle purple-tinted background */
  --card:         #FFFFFF;
  --ink:          #1A1A2E;
  --ink-soft:     #2D2D44;
  --muted:        #6B6B80;
  --border:       #E2DEED;
  --border-strong:#C8C2DA;
  --row-hover:    #FAF7FC;

  /* Semantic */
  --danger:       #B91C1C;
  --danger-soft:  #FEE2E2;
  --warn:         #B45309;
  --warn-soft:    #FEF3C7;
  --warn-border:  #F0D8A0;
  --ok:           #15803D;
  --ok-soft:      #DCFCE7;

  /* Effects */
  --shadow-sm:    0 1px 2px rgba(26, 26, 46, 0.06);
  --shadow-md:    0 2px 8px rgba(26, 26, 46, 0.08);
  --shadow-lg:    0 8px 24px rgba(26, 26, 46, 0.12);
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --focus-ring:   0 0 0 3px rgba(107, 46, 137, 0.25);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.45;
  /* The page itself must never scroll sideways — if any child overflows, clip
     it rather than letting the whole layout (and the sticky header) shift.
     `clip` (not `hidden`) keeps the sticky header working; older browsers that
     don't support it simply fall back to today's behavior. */
  overflow-x: clip;
}

/* ============================================================================
   Header (top bar present on every authenticated screen)
   ============================================================================ */

header {
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: max(12px, env(safe-area-inset-top));
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-logo {
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
}
header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header .who {
  font-size: 12px;
  opacity: 0.9;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header button {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
header button:hover { background: rgba(255, 255, 255, 0.22); }
header button:active { background: rgba(255, 255, 255, 0.08); }

/* ============================================================================
   Main content area
   ============================================================================ */

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 120px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================================
   Forms
   ============================================================================ */

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 16px;   /* 16px+ prevents iOS auto-zoom */
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--brand); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
input:disabled, select:disabled, textarea:disabled {
  background: #F2F2F7;
  color: var(--muted);
  cursor: not-allowed;
}
/* Read-only computed display (Pt time, Chart, Miles). Looks like an input but
   is a plain reactive text element so the value always renders. */
output.calc {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 16px;
  background: #f1f5f9;
  color: var(--ink);
  font-weight: 600;
  box-sizing: border-box;
}
textarea { resize: vertical; min-height: 60px; }

.form-group { margin-bottom: 12px; }

/* Show/hide password toggle: input with an inline eye button on the right.
   The button must NOT inherit the global purple button styling. */
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 44px; }
button.pwd-eye,
button.pwd-eye:hover,
button.pwd-eye:active {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  padding: 6px;
  margin: 0;
  color: #6b7280;
  line-height: 0;
  cursor: pointer;
  box-shadow: none;
}
button.pwd-eye:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }

/* ============================================================================
   Buttons
   ============================================================================ */

button {
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, transform 0.05s ease;
  min-height: 44px;
}
button:hover { background: var(--brand-hover); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

button.secondary {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
}
button.secondary:hover { background: var(--brand-soft); }
button.secondary.danger { color: var(--danger); border-color: var(--danger); }
button.secondary.danger:hover { background: var(--danger-soft); }

button.danger { background: var(--danger); }
button.danger:hover { background: #991717; }

/* Pay-period status pill: light GREEN = open, light RED = locked (readable dark
   text on a soft fill, replacing the hard-to-read solid-red unlock button). */
.period-status-btn {
  border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13px;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.1;
  display: inline-flex; align-items: center; gap: 6px;
}
.period-status-btn.open { background: #DCFCE7; color: #15803D; border-color: #BBF7D0; }
.period-status-btn.locked { background: #FDE2E1; color: #B42318; border-color: #F3C0BD; cursor: pointer; }
.period-status-btn.locked:hover:not(:disabled) { background: #FACFCB; }
.period-status-btn:disabled { opacity: 0.6; cursor: default; }

/* Per-nurse approval tables all share the SAME column geometry so columns line
   up across every nurse group (fixed layout + explicit widths). */
.nurse-group-detail table { table-layout: fixed; width: 100%; }
.nurse-group-detail table td,
.nurse-group-detail table th { overflow-wrap: anywhere; }

/* Users filter bar: search grows, the two selects are fixed, and the action
   buttons stay together on the right — all baselined at flex-end so the row is
   level (the generic .row forces flex:1 on every child and stacks on mobile). */
.user-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.user-toolbar .uf-search { flex: 1 1 150px; min-width: 150px; }
.user-toolbar .uf-sel { flex: 0 0 118px; }
.user-toolbar .toolbar-actions { flex: 0 0 auto; margin-left: auto; }
.toolbar-actions { display: flex; align-items: flex-end; gap: 8px; flex-wrap: nowrap; }
.toolbar-actions button { white-space: nowrap; }
@media (max-width: 640px) { .user-toolbar .toolbar-actions { margin-left: 0; } }

button.btn-primary { background: var(--brand); }
button.btn-block { width: 100%; }

button.link {
  background: transparent;
  color: var(--brand-2);
  border: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  min-height: 0;
  text-decoration: none;
}
button.link:hover { text-decoration: underline; }
button.link.secondary { color: var(--muted); }
button.link.danger { color: var(--danger); }

/* ============================================================================
   Toolbar (sticky bottom action bar on nurse view)
   ============================================================================ */

.toolbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  justify-content: space-between;
  z-index: 5;
  box-shadow: 0 -2px 12px rgba(26, 26, 46, 0.06);
}
.toolbar button { flex: 1; }

/* ============================================================================
   Badges
   ============================================================================ */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.draft     { background: #E5E7EB; color: #4B5563; }
.badge.submitted { background: var(--warn-soft); color: var(--warn); }
.badge.approved  { background: var(--ok-soft); color: var(--ok); }
.badge.queued    { background: var(--warn-soft); color: var(--warn); }

/* ============================================================================
   Visit blocks (nurse view)
   ============================================================================ */

.visit {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: #FCFBFE;
}
.visit h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--brand);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.visit .remove {
  background: transparent;
  color: var(--danger);
  border: 0;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  min-height: 0;
}
.visit .remove:hover { background: var(--danger-soft); }

/* ============================================================================
   Tables
   ============================================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
th {
  background: #F4F1F8;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}
tbody tr:hover { background: var(--row-hover); }

/* On phones, a wide table (e.g. the 11-column Trends "Per-nurse this period"
   table) would stretch the whole page past the screen edge — pushing the
   header off and forcing a sideways page scroll. Instead, make each table its
   own horizontal scroll area so the columns swipe left/right INSIDE the card
   while the page width stays fixed to the screen. */
@media (max-width: 700px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* On phones, stack multi-column form rows into a single column. iOS won't shrink
   native date/time/number pickers below their built-in width, so side-by-side
   inputs overflow and visually overlap their neighbor; one input per line fixes it. */
@media (max-width: 560px) {
  .row { flex-direction: column; }
  /* Keep small native pickers from spanning the whole width when stacked —
     a full-width box for a single time/number/date looks oversized. */
  .row input[type="time"],
  .row input[type="date"] { max-width: 200px; }
  .row input[type="number"] { max-width: 160px; }
}

/* ============================================================================
   Status messages
   ============================================================================ */

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  padding: 0;
}
.error:not(:empty) {
  background: var(--danger-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger);
}
.info { color: var(--muted); font-size: 13px; }
.success { color: var(--ok); font-size: 13px; font-weight: 600; }

.center { text-align: center; }
.muted { color: var(--muted); }
.spacer { height: 16px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
code {
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: 13px;
  background: #F2F2F7;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ============================================================================
   Login screen
   ============================================================================ */

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(150deg, var(--brand) 0%, #4A1E62 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-main {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.login-logo {
  width: 64px;
  height: 64px;
  background: #fff;
  border-radius: 14px;
  padding: 4px;
  box-shadow: var(--shadow-md);
}
.login-wordmark { color: #fff; line-height: 1.1; }
.login-wordmark-1 { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.login-wordmark-2 { font-size: 16px; font-weight: 600; opacity: 0.92; margin-top: 2px; }

.login-card {
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  border: 0;
}
.login-title {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.login-footer-help {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
/* Email 2FA code step */
.login-code-intro {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}
.login-code-actions {
  margin: 14px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}
.login-code-actions .link {
  font-size: 13px;
}
.login-footnote {
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  margin-top: 18px;
  text-align: center;
}

/* ============================================================================
   Install prompt modal (first-time iOS Safari visitors)
   ============================================================================ */

.install-prompt {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 30, 0.55);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  animation: fade-in 0.2s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.install-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.3s ease-out;
}
@keyframes slide-up { from { transform: translateY(20px); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.install-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 24px;
  line-height: 1;
  padding: 6px 10px;
  min-height: 0;
  cursor: pointer;
}
.install-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 10px;
}
.install-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--brand);
}
.install-card p {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--ink-soft);
}
.install-steps {
  text-align: left;
  margin: 0 0 18px;
  padding-left: 22px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
}
.share-icon {
  display: inline-block;
  background: var(--brand-2);
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
}

/* ============================================================================
   Patient picker
   ============================================================================ */

.patient-picker { margin-bottom: 10px; position: relative; }
.patient-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--brand-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.patient-chip strong { font-weight: 600; color: var(--ink); }
.patient-chip .muted { font-size: 13px; }

.patient-search { position: relative; }
.suggestions {
  position: absolute;
  top: 100%; left: 0; right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
  max-height: 320px;
  overflow-y: auto;
}
.suggestion {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 0;
  font-weight: 400;
  min-height: 0;
}
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover { background: var(--brand-soft); }
.suggestion .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.suggestion.add-new {
  color: var(--brand);
  font-weight: 600;
  background: var(--accent-soft);
}
.suggestion.add-new:hover { background: #FFE3C7; }
.suggestion-empty { padding: 12px 14px; font-size: 13px; color: var(--muted); }

.patient-create {
  background: var(--brand-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 6px;
}
.patient-create .create-actions { margin-top: 12px; gap: 8px; }

.dupe-block {
  margin-top: 10px;
  padding: 10px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
}
.dupe-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  text-align: left;
}

/* ============================================================================
   Sync pill (header — offline / queued / syncing state)
   ============================================================================ */

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(245, 130, 32, 0.18);
  color: #fff;
  border: 1px solid rgba(245, 130, 32, 0.55);
}
.sync-pill.offline {
  background: rgba(220, 38, 38, 0.22);
  color: #fff;
  border-color: rgba(220, 38, 38, 0.6);
}
.sync-pill.syncing {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
.sync-pill .sync-now {
  background: #fff;
  color: var(--brand);
  border: 0;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  min-height: 0;
}
.sync-pill .sync-now:hover { background: var(--brand-soft); }

/* ============================================================================
   Trends tab
   ============================================================================ */

.pipeline-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.pipeline-cell {
  padding: 14px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
  background: #fff;
}
.pipeline-cell.pipeline-draft     { background: #F3F4F6; border-color: #D1D5DB; }
.pipeline-cell.pipeline-submitted { background: var(--warn-soft); border-color: var(--warn-border); }
.pipeline-cell.pipeline-approved  { background: var(--ok-soft); border-color: #A3D8A3; }
.pipeline-num { font-size: 28px; font-weight: 800; color: var(--ink); line-height: 1; }
.pipeline-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.kpi-value { font-size: 26px; font-weight: 800; color: var(--ink); margin-top: 6px; }
.kpi-delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.delta-up      { color: var(--ok); }
.delta-down    { color: var(--danger); }
.delta-neutral { color: var(--muted); }

.sparkline { display: inline-block; vertical-align: middle; }

/* ============================================================================
   Per-nurse grouped view in Ops Console
   ============================================================================ */

.nurse-group { border-bottom: 1px solid var(--border); }
.nurse-group:last-child { border-bottom: 0; }
.nurse-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease;
}
.nurse-group-header:hover { background: var(--row-hover); }
.nurse-group-name { display: flex; align-items: center; gap: 8px; }
.nurse-group-name .chevron {
  display: inline-block;
  transition: transform 0.15s ease-out;
  color: var(--muted);
  font-size: 12px;
}
.nurse-group-name .chevron.open { transform: rotate(90deg); }
.nurse-group-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nurse-group-stats > span { color: var(--muted); }
.nurse-group-stats .badge { font-size: 10px; }
.nurse-group-detail {
  padding: 4px 16px 12px 28px;
  background: var(--row-hover);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.nurse-group-detail table { margin-top: 0; }
.nurse-group-detail th { background: transparent; font-size: 11px; }

/* Action links (Approve / Fix / Sheet / Submit for nurse / Undo) in the last
   column. Flexbox with ONE consistent gap replaces the old hand-tuned inline
   margins, which produced uneven spacing and ragged wrapping on the desktop. */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
}
.row-actions button.link { padding: 0; }

/* Phone: the 6-column approvals table can't fit — the shared "scroll tables
   sideways" rule collapses its fixed columns to one character wide (the long
   vertical mess). Restructure THIS table (only) into a stacked card per day:
   hide the header row, turn each row into a bordered card, and label each value
   from its column name via data-label. Desktop keeps the real table untouched. */
@media (max-width: 700px) {
  .nurse-group-detail { padding: 4px 8px 12px; }
  .nurse-group-detail table { display: block; overflow-x: visible; }
  .nurse-group-detail thead { display: none; }
  .nurse-group-detail tbody,
  .nurse-group-detail tr,
  .nurse-group-detail td { display: block; width: auto; }
  .nurse-group-detail tbody tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .nurse-group-detail td {
    border: 0;
    padding: 3px 0;
    overflow-wrap: anywhere;
  }
  .nurse-group-detail td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 76px;
    margin-right: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  /* Actions get their own full-width strip under the values, no label. */
  .nurse-group-detail td.cell-actions {
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }
  .nurse-group-detail td.cell-actions::before { display: none; }
  .row-actions { gap: 10px 22px; }
  .row-actions button.link { font-size: 15px; }
}

/* ============================================================================
   Ops tab toggle
   ============================================================================ */

.ops-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.ops-tabs button {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  min-height: 44px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.ops-tabs button:hover { color: var(--brand); }
.ops-tabs button.active {
  background: transparent;
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ============================================================================
   User-management table
   ============================================================================ */

.user-actions { white-space: nowrap; }
.user-actions button.link { margin-right: 10px; font-size: 12px; }
.user-actions button.link.danger { color: var(--danger); }
tr.inactive td { opacity: 0.55; }
tr.inactive .badge { opacity: 1; }

/* ============================================================================
   Modal
   ============================================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fade-in 0.15s ease-out;
}
.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.2s ease-out;
}
.modal h3 {
  margin-top: 0;
  color: var(--brand);
  font-size: 18px;
}
.modal .row { margin-bottom: 10px; }

/* ============================================================================
   One-time password reveal
   ============================================================================ */

.otp-reveal {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin: 12px 0;
}
.otp-reveal code {
  font-family: "SF Mono", "Consolas", "Monaco", monospace;
  font-size: 18px;
  font-weight: 700;
  background: transparent;
  flex: 1;
  user-select: all;
  letter-spacing: 0.05em;
  word-break: break-all;
  color: var(--ink);
}

/* ============================================================================
   Callouts (warn/info boxes for structured errors)
   ============================================================================ */

.callout {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-size: 13px;
}
.callout.warn {
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  color: var(--warn);
}
.callout ul { margin: 6px 0 0 18px; padding: 0; }
.callout li { margin: 3px 0; }

/* Approved-timesheet banner (above locked Save/Submit buttons) */
.toolbar .approved-banner {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 100%;
  margin-bottom: 8px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  color: var(--warn);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.04);
}

/* ============================================================================
   Expenses
   ============================================================================ */

.expenses-card .expenses-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.expense-row {
  display: grid;
  grid-template-columns: 130px 110px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.expense-row select,
.expense-row input { font-size: 14px; padding: 9px 10px; }
.expense-row .remove {
  background: transparent;
  color: var(--danger);
  border: 0;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  min-height: 0;
}
.expense-row .remove:hover { background: var(--danger-soft); }

/* ============================================================================
   Responsive: iPad / phone tweaks
   ============================================================================ */

@media (max-width: 540px) {
  main { padding: 12px; padding-bottom: 110px; }
  .card { padding: 14px; }
  header { padding: 10px 14px; }
  header h1 { font-size: 15px; }
  .header-logo { width: 24px; height: 24px; }
  .expense-row { grid-template-columns: 1fr 1fr; }
  .expense-row > input[type="text"] { grid-column: 1 / -1; }
  .expense-row .remove { grid-column: 1 / -1; text-align: right; }
  .pipeline-strip { grid-template-columns: 1fr; }
  .nurse-group-stats { gap: 8px; font-size: 12px; }
  .ops-tabs button { padding: 10px 12px; font-size: 12px; }
  .who { display: none; } /* free up header space on small screens */
}

/* ---- Offline / data-loss-prevention UI ---- */

/* Sign-in banner at the top of the nurse view when the token expired mid-shift. */
.auth-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: #7c3a00;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}
.auth-banner .link { color: var(--brand); font-weight: 700; }

/* Always-visible save status line above the Save/Submit buttons. */
.save-status {
  flex-basis: 100%;
  order: -1;
  font-size: 12px;
  min-height: 16px;
  text-align: center;
}
.save-status-saved { color: #15803d; }
.save-status-unsynced { color: var(--accent); font-weight: 600; }
.save-status-auth { color: #b91c1c; font-weight: 700; }

/* "New version available" toast pinned bottom-center. */
.update-toast {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--brand);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(26, 26, 46, 0.25);
  cursor: pointer;
  z-index: 50;
}
.update-toast:hover { background: var(--brand-hover); }

/* Receipt thumbnails: fixed-size so the generic `.row > * { flex:1 }` rule (and
   the mobile column-stacking) can't stretch the image to fill the screen. */
.receipt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.receipt-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  cursor: pointer;
}
.receipt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

/* Confirmation popup: brief centered card with a green check. */
.sync-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #14532d;
  padding: 16px 24px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(26, 26, 46, 0.25);
  border: 1px solid #bbf7d0;
  z-index: 60;
  pointer-events: none;
}
.sync-toast-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}
.sync-toast.error { color: #7f1d1d; border-color: #fecaca; }
.sync-toast.error .sync-toast-check { background: #dc2626; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
