html, body {
  overflow-x: hidden !important;
  max-width: 100vw;
  position: relative;
}

/* =========================================================
   Arogya Workspace — Phase F-1
   Direction B: left rail + canvas + attention rail
   Mobile: drawer + bottom nav
   ========================================================= */

/* Explicit body background — prevents dark-mode black-on-load */
body {
  background: #FAFAF7;
  margin: 0;
}

/* ── Shell ───────────────────────────────────────────────────────────────── */

.ws-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  background: var(--color-background-tertiary);
  padding-top: env(safe-area-inset-top);
}
/* On iOS, fill the safe-area notch with teal to match the topbar */
@supports (padding-top: env(safe-area-inset-top)) {
  .ws-shell::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: env(safe-area-inset-top);
    background: #083D36;
    z-index: 100;
  }
}

/* ── Left rail ───────────────────────────────────────────────────────────── */

.ws-rail {
  width: 220px;
  flex-shrink: 0;
  background: #083D36;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
}
.ws-rail-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ws-rail-top { padding: 18px 14px 12px; }
.ws-rail-brand {
  font-size: 20px; font-weight: 700; color: #fff;
  letter-spacing: -.01em; margin-bottom: 12px;
  padding: 0 2px;
  display: flex; align-items: center; gap: 8px;
}
/* Family switcher */
.ws-rail-fam {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 0.5px solid rgba(255,255,255,0.12);
  border-radius: 10px; padding: 8px 10px;
  cursor: pointer; transition: background .12s;
}
.ws-rail-fam:hover { background: rgba(255,255,255,0.14); }
.ws-rail-fam-mono {
  width: 26px; height: 26px; border-radius: 6px;
  background: rgba(0,0,0,0.3); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.75);
}
.ws-rail-fam-name { font-size: 13px; font-weight: 500; color: #fff; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-rail-fam-chev { font-size: 13px; color: rgba(255,255,255,0.4); flex-shrink: 0; }
.ws-rail-fam-multi { cursor: pointer; }
.ws-rail-fam-multi:hover { background: rgba(255,255,255,0.16); }
.ws-rail-fam-menu {
  margin: 2px 8px 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  overflow: hidden;
}
.ws-rail-fam-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.7); text-decoration: none;
  transition: background .1s;
}
.ws-rail-fam-opt:hover { background: rgba(255,255,255,0.1); color: #fff; }
.ws-rail-fam-opt.active { color: #9FE1CB; }
/* Nav */
.ws-rail-nav { flex: 1; }
.ws-rail-sec {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .09em; color: rgba(255,255,255,0.35);
  padding: 12px 16px 5px;
}
.ws-rail-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.7);
  padding: 10px 16px; text-decoration: none; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  margin: 1px 8px; border-radius: 10px; width: calc(100% - 16px);
  transition: background .12s, color .12s;
}
.ws-rail-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.ws-rail-item.active {
  background: rgba(255,255,255,0.13);
  color: #fff; font-weight: 600;
}
.ws-rail-item i { font-size: 17px; flex-shrink: 0; width: 20px; text-align: center; }
/* Member items */
.ws-rail-member {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 16px; text-decoration: none; cursor: pointer;
  margin: 1px 8px; border-radius: 10px; width: calc(100% - 16px);
  transition: background .12s;
}
.ws-rail-member:hover { background: rgba(255,255,255,0.08); }
.ws-rail-member.active { background: rgba(255,255,255,0.13); }
.ws-rail-m-av {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.2);
}
.ws-rail-m-name { font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.85); flex: 1; }
.ws-rail-member.active .ws-rail-m-name { color: #fff; font-weight: 600; }
.ws-rail-flag {
  font-size: 10px; font-weight: 500; color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.1); border-radius: 999px;
  padding: 1px 6px; min-width: 18px; text-align: center; flex-shrink: 0;
  margin-right: 2px;
}
/* Add member */
.ws-rail-add {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.38);
  padding: 8px 16px; text-decoration: none; cursor: pointer;
  margin: 1px 8px; border-radius: 10px; width: calc(100% - 16px);
  transition: color .12s, background .12s;
}
.ws-rail-add:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.06); }
.ws-rail-add i { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
/* Bottom */
.ws-rail-bottom { padding: 10px 12px 16px; margin-top: auto; }
.ws-rail-disclaimer {
  background: rgba(0,0,0,0.2); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
  font-size: 10px; color: rgba(255,255,255,0.32); line-height: 1.6;
}
.ws-rail-foot-link {
  display: block; padding: 6px 4px;
  font-size: 14px; color: rgba(255,255,255,0.72);
  text-decoration: none; cursor: pointer;
}
.ws-rail-foot-link:hover { color: rgba(255,255,255,0.95); }
.ws-rail-foot-signout {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 4px; margin-top: 4px;
  font-size: 14px; color: rgba(255,255,255,0.72);
  text-decoration: none; cursor: pointer;
}
.ws-rail-foot-signout:hover { color: rgba(255,255,255,0.95); }
/* Legacy — kept for any templates still using ws-rail-item-muted */
.ws-rail-item-muted { color: rgba(255,255,255,0.45); font-weight: 400; }

/* ── Main area (top bar + content) ───────────────────────────────────────── */

.ws-main { flex: 1; display: flex; flex-direction: column; min-width: 0; max-width: 100%; overflow: hidden; background: var(--color-background-tertiary); }

/* Top bar */
.ws-top {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: 44px; flex-shrink: 0;
  background: var(--color-background-primary);
  border-bottom: 0.5px solid var(--color-border-tertiary);
  position: sticky; top: 0; z-index: 10;
}
.ws-menu-btn {
  display: none; /* hidden on desktop */ background: none; border: none;
  font-size: 18px; color: var(--color-text-secondary); cursor: pointer;
  padding: 4px; border-radius: 6px; flex-shrink: 0;
}
.ws-top-brand {
  display: none; /* hidden on desktop — branding is in the rail */
  align-items: center; gap: 6px; text-decoration: none;
  font-size: 14px; font-weight: 500; color: var(--color-text-primary);
}
.ws-top-brand i { font-size: 16px; color: #1D9E75; }
.ws-top-family {
  font-size: 12px; color: var(--color-text-secondary);
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
}
.ws-top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.ws-top-btn {
  width: 30px; height: 30px; border-radius: 8px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary); text-decoration: none;
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-secondary);
}
.ws-top-btn:hover { background: var(--color-background-primary); color: var(--color-text-primary); }

/* Content row: canvas + right attention rail */
.ws-content { display: flex; flex: 1; min-height: 0; overflow: hidden; max-width: 100%; }

/* Main canvas */
.ws-canvas { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; min-width: 0; max-width: 100%; }

/* Right attention rail */
.ws-attention {
  width: 260px; flex-shrink: 0;
  background: var(--color-background-secondary);
  border-left: 0.5px solid var(--color-border-tertiary);
  overflow-y: auto; padding: 12px 0;
}
.ws-attn-hdr {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-tertiary);
  padding: 0 12px 8px; display: flex; align-items: center; gap: 5px;
}
.ws-attn-card {
  margin: 0 10px 7px; padding: 9px 10px;
  border-radius: var(--border-radius-md);
  font-size: 13px; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 6px;
  border: 0.5px solid;
}
.ws-attn-card i { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.ws-attn-info   { background: #E6F1FB; border-color: #85B7EB; color: #0C447C; }
.ws-attn-amber  { background: #FAEEDA; border-color: #FAC775; color: #633806; }
.ws-attn-red    { background: #FCEBEB; border-color: #F09595; color: #791F1F; }
.ws-attn-empty  { font-size: 11px; color: var(--color-text-tertiary); padding: 0 12px; font-style: italic; }

/* Mobile attention strip (hidden on desktop) */
.ws-attn-strip { display: none; }

/* Mobile scrim */
.ws-scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 49; }

/* Mobile bottom nav */
.ws-bottom-nav { display: none; }

/* ── Login page ──────────────────────────────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #062A1C 0%, #0A3D2B 35%, #0D5C40 65%, #1D9E75 100%);
}

/* Decorative floating circles */
.login-shell::before {
  content: '';
  position: absolute;
  top: -80px; right: -80px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(29, 158, 117, 0.18);
  pointer-events: none;
}
.login-shell::after {
  content: '';
  position: absolute;
  bottom: -60px; left: -60px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(29, 158, 117, 0.12);
  pointer-events: none;
}
.login-deco-mid {
  position: absolute;
  top: 50%; left: -40px;
  transform: translateY(-60%);
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}
.login-deco-top {
  position: absolute;
  top: 30px; left: 40%;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}
.login-deco-br {
  position: absolute;
  bottom: 80px; right: 60px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  pointer-events: none;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 390px;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 1;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28), 0 4px 16px rgba(0,0,0,0.12);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 600;
  color: #0A3D2B;
  margin-bottom: 6px;
}
.login-logo-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0D5C40, #1D9E75);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(13,92,64,0.3);
}
.login-logo-icon i { font-size: 22px; color: #ffffff; }

.login-tagline {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1D9E75;
  margin-bottom: 20px;
}

.login-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px;
  color: #111827;
  line-height: 1.3;
}
.login-sub {
  font-size: 13px;
  color: #6B7280;
  margin: 0 0 28px;
  line-height: 1.6;
}
.login-error {
  font-size: 12px; color: #791F1F;
  background: #FCEBEB; border: 0.5px solid #F09595;
  border-radius: 8px; padding: 10px 12px;
  margin-bottom: 16px; text-align: left;
}
.login-google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 16px; border-radius: 10px;
  background: #111827;
  color: #ffffff;
  font-size: 14px; font-weight: 500; text-decoration: none;
  border: none; cursor: pointer;
  transition: background .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.login-google-btn:hover {
  background: #1f2937;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.22);
}
.login-google-btn:active { transform: translateY(0); }

.login-legal {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 14px;
  line-height: 1.6;
}
.login-legal a { color: #1D9E75; text-decoration: none; }
.login-legal a:hover { text-decoration: underline; }

.login-divider {
  height: 0.5px;
  background: #E5E7EB;
  margin: 20px 0;
}

.login-note {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 0;
  line-height: 1.55;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
}
.login-note i { font-size: 12px; color: #1D9E75; flex-shrink: 0; margin-top: 1px; }


/* ── Home canvas ─────────────────────────────────────────────────────────── */

.home-canvas { padding: 20px; }
.home-fam-lbl { font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--color-text-tertiary); margin-bottom: 10px; }

/* ── Hero section ── */
.home-hero {
  background: linear-gradient(135deg, #2D4538 0%, #4D7561 100%);
  border-radius: 14px;
  padding: 18px 22px 20px;
  margin-bottom: 20px;
  box-shadow: rgba(0,0,0,0.1) 0px -8px 16px 0px inset;
}
.home-hero-meta {
  font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: rgba(255,255,255,0.45); margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.home-hero-badge {
  background: rgba(255,255,255,0.12); padding: 1px 7px; border-radius: 10px;
  color: rgba(255,255,255,0.55);
}
.home-hero-body { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.home-hero-left { flex: 1; min-width: 0; }
.home-hero-greeting { font-size: 22px; font-weight: 500; color: #fff; margin: 0 0 4px; line-height: 1.25; }
.home-hero-sub { font-size: 12px; color: rgba(255,255,255,0.5); margin: 0; }
.home-hero-stats { display: flex; gap: 20px; flex-shrink: 0; text-align: center; padding-top: 2px; }
.home-hero-stat-num { font-size: 28px; font-weight: 500; color: #fff; line-height: 1; }
.home-hero-stat-lbl { font-size: 9px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: rgba(255,255,255,0.4); margin-top: 3px; }

/* ── Member cards v2 ── */
.home-member-grid-v2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 520px) { .home-member-grid-v2 { grid-template-columns: 1fr; } }

.home-mc-v2 {
  background: #fff;
  border: 0.5px solid #E4E1D8;
  border-radius: 14px;
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit;
  box-shadow: rgba(0,0,0,0.06) 0px 4px 10px 0px;
}
.home-mc-v2:hover { box-shadow: rgba(0,0,0,0.1) 0px 6px 16px 0px; }
.home-mc-av {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 500; color: #fff; flex-shrink: 0;
}
.home-mc-av-add {
  background: #F2EFE7 !important; border: 1px dashed #C8C4B8 !important;
  box-shadow: none !important;
}
.home-mc-av-add i { color: #8a93a0; font-size: 20px; }
.home-mc-info { flex: 1; min-width: 0; }
.home-mc-name { font-size: 15px; font-weight: 500; color: #1f2a36; margin-bottom: 2px; }
.home-mc-rel  { font-size: 12px; color: #8a93a0; margin-bottom: 7px; }
.home-mc-docs { font-size: 12px; color: #8a93a0; display: flex; align-items: center; gap: 4px; }
.home-mc-docs i { font-size: 12px; }
.home-mc-arr  { font-size: 16px; color: #c8c4ba; flex-shrink: 0; }
.home-mc-add  { background: #FAFAF7 !important; border: 1px dashed #C8C4B8 !important; box-shadow: none !important; }
.home-members-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 12px; }
.home-member-card {
  display: flex; align-items: flex-start; gap: 13px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-top: 2px solid #9FE1CB;
  border-radius: var(--border-radius-lg); padding: 16px 16px 14px;
  text-decoration: none; transition: border-color .12s, box-shadow .12s;
}
.home-member-card:hover {
  border-color: #5DCAA5;
  box-shadow: 0 2px 10px rgba(8,80,65,.08);
}
.home-member-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: #083D36; color: #9FE1CB;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; margin-top: 1px;
}
.home-member-avatar.avatar-pet { background: #FAEEDA; color: #633806; }
.home-member-avatar i { font-size: 20px; }
.home-member-info { flex: 1; min-width: 0; }
.home-member-name { font-size: 15px; font-weight: 600; color: var(--color-text-primary); margin-bottom: 3px; }
.home-member-meta { font-size: 12px; color: var(--color-text-tertiary); }
.home-member-arrow { font-size: 14px; color: var(--color-text-tertiary); flex-shrink: 0; }
.home-empty { font-size: 13px; color: var(--color-text-secondary); font-style: italic; }

/* ── Member canvas ───────────────────────────────────────────────────────── */

.member-canvas { padding: 0; }
.ws-tab-nav {
  display: flex; border-bottom: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-primary);
  padding: 0 16px; gap: 0; position: sticky; top: 44px; z-index: 5;
}
.ws-tab {
  display: flex; align-items: center; gap: 5px;
  font-size: 14px; padding: 11px 16px; text-decoration: none;
  color: var(--color-text-secondary); border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.ws-tab:hover { color: var(--color-text-primary); }
.ws-tab.active { color: var(--color-text-primary); font-weight: 500; border-bottom-color: #1D9E75; }
.ws-tab i { font-size: 14px; }
.ws-tab-content { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {

  /* Hide desktop rail */
  .ws-rail {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .22s ease;
    z-index: 50;  /* must beat member-ai-topbar z-index:30 */
  }
  .ws-shell.drawer-open .ws-rail { transform: translateX(0); }
  .ws-shell.drawer-open .ws-scrim { display: block; }

  /* Show mobile controls */
  .ws-menu-btn { display: flex; }
  .ws-top-brand { display: flex; }
  .ws-top-family { display: none; }

  /* Hide desktop right rail */
  .ws-attention { display: none; }

  /* Show mobile attention strip */
  .ws-attn-strip {
    display: block;
    border-bottom: 0.5px solid var(--color-border-tertiary);
    background: var(--color-background-secondary);
  }
  .ws-attn-strip-toggle {
    display: flex; align-items: center; gap: 7px;
    width: 100%; padding: 9px 14px; font-size: 12px;
    color: var(--color-text-secondary); background: none; border: none;
    cursor: pointer; font-weight: 500; text-align: left;
  }
  .ws-attn-strip-toggle i:first-child { color: #EF9F27; }
  .ws-attn-chev { margin-left: auto; font-size: 12px; transition: transform .15s; }
  .ws-attn-strip-body { padding: 0 10px 8px; }

  /* Bottom nav — teal background */
  .ws-bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    background: #083D36;
    border-top: none;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 30;
  }
  .ws-bnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 3px; padding: 8px 4px 5px; font-size: 10px; font-weight: 500;
    color: rgba(255,255,255,0.55); text-decoration: none;
    background: none; border: none; cursor: pointer;
  }
  .ws-bnav-item i { font-size: 21px; }
  .ws-bnav-item.active, .ws-bnav-item:focus { color: #fff; }
  .ws-bnav-add {
    background: #1D9E75; color: #fff; border-radius: 50%;
    width: 46px; height: 46px; flex: none; margin: -6px 8px 0;
    display: flex; align-items: center; justify-content: center;
    flex-direction: row; padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  .ws-bnav-add i { font-size: 24px; }
  .ws-bnav-add span { display: none; }

  /* Push canvas up from bottom nav */
  .ws-canvas { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }

  /* Home canvas single column */
  .home-canvas { padding: 16px; }
  .home-members-grid { grid-template-columns: 1fr; }

  /* Member tab content tighter */
  .ws-tab-content { padding: 10px; }
  .ws-tab-nav { top: 44px; overflow-x: auto; }
}

/* ── F-2: Upload panel ──────────────────────────────────────────────────── */

.up-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
/* Prevent display:flex from fighting display:none set via JS */
.up-overlay[style*="display: none"],
.up-overlay[style*="display:none"] { display: none !important; }
@media (min-width: 600px) {
  .up-overlay { align-items: center; }
}
.up-panel {
  background: var(--color-background-primary);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  padding: 0 0 16px;
}
@media (min-width: 600px) {
  .up-panel { border-radius: var(--border-radius-lg); }
}
.up-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 0.5px solid var(--color-border-tertiary);
  position: sticky; top: 0; background: var(--color-background-primary); z-index: 1;
}
.up-panel-tabs { display: flex; gap: 4px; }
.up-tab {
  font-size: 12px; padding: 6px 12px; border-radius: 6px;
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-secondary);
  color: var(--color-text-secondary); cursor: pointer;
  display: flex; align-items: center; gap: 5px;
}
.up-tab.active {
  background: var(--color-background-primary);
  color: var(--color-text-primary); font-weight: 500;
  border-color: var(--color-border-secondary);
}
.up-close {
  background: none; border: none; font-size: 18px;
  color: var(--color-text-tertiary); cursor: pointer;
  padding: 4px; border-radius: 6px;
}
.up-close:hover { background: var(--color-background-secondary); }
.up-for-whom { padding: 14px 16px 0; }
.up-field-label { display: block; font-size: 11px; font-weight: 500; color: var(--color-text-secondary); margin-bottom: 5px; }
.up-select, .up-input {
  width: 100%; font-size: 13px; padding: 8px 10px;
  border-radius: var(--border-radius-md);
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-primary);
  color: var(--color-text-primary);
}
.up-field-row { display: flex; gap: 10px; padding: 10px 16px 0; }
.up-field { display: flex; flex-direction: column; }
.up-input { padding: 7px 10px; }
.up-drop-zone {
  margin: 12px 16px 0; border: 1.5px dashed var(--color-border-secondary);
  border-radius: var(--border-radius-lg); padding: 28px 16px;
  text-align: center; cursor: pointer; transition: border-color .12s, background .12s;
}
.up-drop-zone:hover, .up-drop-zone.drag-over {
  border-color: #1D9E75; background: #E1F5EE;
}
.up-drop-zone i { font-size: 28px; color: var(--color-text-tertiary); display: block; margin-bottom: 8px; }
.up-drop-text { font-size: 13px; color: var(--color-text-secondary); margin: 0 0 4px; }
.up-drop-hint { font-size: 11px; color: var(--color-text-tertiary); margin: 0; }
.up-link { color: #185FA5; cursor: pointer; }
.up-file-list { margin: 8px 16px 0; }
.up-file-row {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px;
  background: var(--color-background-secondary);
  border-radius: var(--border-radius-md); margin-bottom: 5px; font-size: 12px;
}
.up-file-row i { font-size: 14px; color: var(--color-text-secondary); }
.up-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-file-size { color: var(--color-text-tertiary); flex-shrink: 0; }
.up-file-row button { background: none; border: none; color: var(--color-text-tertiary); cursor: pointer; font-size: 14px; padding: 2px; }
.up-status { margin: 10px 16px 0; padding: 9px 12px; border-radius: var(--border-radius-md); font-size: 12px; line-height: 1.45; }
.up-status-ok  { background: #E1F5EE; color: #083D36; border: 0.5px solid #9FE1CB; }
.up-status-err { background: #FCEBEB; color: #791F1F; border: 0.5px solid #F09595; }
.up-submit-btn {
  margin: 12px 16px 0; width: calc(100% - 32px); padding: 11px 16px;
  border-radius: var(--border-radius-md); background: var(--color-text-primary);
  color: var(--color-background-primary); font-size: 14px; font-weight: 500;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.up-submit-btn:disabled { opacity: .4; cursor: default; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── F-2: Queue / upload history ────────────────────────────────────────── */

.queue-canvas { padding: 20px; max-width: 800px; }
.queue-header { margin-bottom: 18px; }
.queue-title { font-size: 20px; font-weight: 500; margin: 0 0 3px; }
.queue-sub { font-size: 12px; color: var(--color-text-tertiary); margin: 0; }
.queue-empty { text-align: center; padding: 40px 0; }
.queue-empty i { font-size: 32px; color: var(--color-text-tertiary); display: block; margin-bottom: 10px; }
.queue-empty p { font-size: 13px; color: var(--color-text-secondary); margin: 4px 0; }
.queue-list { display: flex; flex-direction: column; gap: 0; border: 0.5px solid var(--color-border-tertiary); border-radius: var(--border-radius-lg); overflow: hidden; background: var(--color-background-primary); }
.queue-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-bottom: 0.5px solid var(--color-border-tertiary); }
.queue-row:last-child { border-bottom: none; }
.queue-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.queue-info { flex: 1; min-width: 0; }
.queue-filename { font-size: 13px; font-weight: 500; color: var(--color-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.queue-meta { font-size: 11px; color: var(--color-text-tertiary); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.queue-channel-web { font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #E6F1FB; color: #0C447C; border: 0.5px solid #85B7EB; }
.queue-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.queue-status-badge { font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.qsb-done       { background: #E1F5EE; color: #083D36; }
.qsb-failed     { background: #FCEBEB; color: #791F1F; }
.qsb-processing { background: #FAEEDA; color: #633806; }
.qsb-pending    { background: var(--color-background-secondary); color: var(--color-text-tertiary); border: 0.5px solid var(--color-border-tertiary); }
.queue-link { font-size: 15px; color: #185FA5; text-decoration: none; }
.queue-reassign-btn { background: none; border: none; font-size: 15px; color: var(--color-text-tertiary); cursor: pointer; padding: 2px; border-radius: 4px; }
.queue-reassign-btn:hover { background: var(--color-background-secondary); }
.queue-reassign-panel { margin-top: 6px; display: flex; align-items: center; }
.ws-upload-btn {
  background: #1D9E75; border-color: #1D9E75; color: #fff;
  width: auto; padding: 0 12px; gap: 5px;
  font-size: 12px; font-weight: 500;
  box-shadow: rgba(29,158,117,0.4) 0px 4px 12px 0px, rgba(0,0,0,0.15) 0px -2px 5px 0px inset;
}
.ws-upload-btn:hover { background: #0F6E56; border-color: #0F6E56; transform: translateY(-1px); }

/* ── Upload progress stages ─────────────────────────────────────────────── */
.up-attribution-note {
  font-size: 11px; color: var(--color-text-tertiary);
  padding: 8px 16px 0; display: flex; align-items: flex-start; gap: 5px;
  line-height: 1.5;
}
.up-attribution-note a { color: #185FA5; }
.up-action-row { padding: 12px 16px 0; }
.up-done-btn {
  width: 100%; padding: 11px 16px; border-radius: var(--border-radius-md);
  background: #1D9E75; color: #fff;
  font-size: 14px; font-weight: 500; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.up-prog-row {
  padding: 10px 16px 8px; border-bottom: 0.5px solid var(--color-border-tertiary);
}
.up-prog-row:last-child { border-bottom: none; }
.up-prog-name {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--color-text-primary);
  margin-bottom: 6px; overflow: hidden;
}
.up-prog-name i { font-size: 14px; color: var(--color-text-tertiary); flex-shrink: 0; }
.up-prog-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-prog-stages { display: flex; flex-wrap: wrap; gap: 5px; }
.up-stage {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
}
.up-stage i { font-size: 11px; }
.up-stage-ok   { background: #E1F5EE; color: #083D36; }
.up-stage-err  { background: #FCEBEB; color: #791F1F; }
.up-stage-spin { background: #FAEEDA; color: #633806; }

/* ── Home member cards — richer ─────────────────────────────────────────── */
.home-member-docs {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--color-text-tertiary); margin-top: 4px;
}
.home-member-docs i { font-size: 12px; }

/* ── Records two-column layout (desktop only) ───────────────────────────── */
.web-records-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}
.web-records-col-left,
.web-records-col-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@media (max-width: 900px) {
  .web-records-cols {
    grid-template-columns: 1fr;
  }
}

/* ── Home member card actions ───────────────────────────────────────────── */
.home-member-card-wrap { position:relative; }
.home-member-actions {
  position:absolute; top:50%; right:40px; transform:translateY(-50%);
  display:none; gap:4px;
}
.home-member-card-wrap:hover .home-member-actions { display:flex; }
.home-member-action-btn {
  width:28px; height:28px; border-radius:8px; font-size:14px;
  display:flex; align-items:center; justify-content:center;
  border:0.5px solid var(--color-border-tertiary);
  background:var(--color-background-primary);
  color:var(--color-text-secondary); cursor:pointer; text-decoration:none;
}
.home-member-action-btn:hover { background:var(--color-background-secondary); color:var(--color-text-primary); }
.home-add-card { border-style:dashed; }
.home-add-card:hover { background:var(--color-background-secondary); }

/* ── Global search bar in top bar ───────────────────────────────────────── */
.ws-search-wrap {
  flex: 1; max-width: 380px; margin: 0 8px; display: flex;
}
.ws-search-form { display:flex; align-items:center; width:100%; position:relative; }
.ws-search-input {
  width: 100%; padding: 6px 32px 6px 30px;
  border-radius: 20px; border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-secondary); font-size: 12px;
  color: var(--color-text-primary); font-family: inherit;
}
.ws-search-input:focus { outline:none; border-color:#1D9E75; background:var(--color-background-primary); }
.ws-search-icon { position:absolute; left:9px; font-size:13px; color:var(--color-text-tertiary); pointer-events:none; }
.ws-search-submit { position:absolute; right:6px; background:none; border:none; cursor:pointer; font-size:13px; color:var(--color-text-tertiary); padding:0; }
.ws-search-submit:hover { color:#1D9E75; }
@media (max-width:768px) { .ws-search-wrap { display:none; } }

/* ── Records two-column (JS-driven grid, replaces CSS columns) ──────────── */
.web-sys-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  margin-top: 12px;
}
.web-sys-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}
@media (max-width: 900px) {
  .web-sys-grid { grid-template-columns: 1fr; }
}

/* ── Web records accordion — new 3-level design ─────────────────────────── */
.web-rec-wrap { margin-top:12px; }
.web-rec-header { display:flex; align-items:center; justify-content:space-between; padding:0 2px 10px; }
.web-rec-title { font-size:13px; font-weight:500; color:var(--color-text-primary); display:flex; align-items:center; gap:6px; }
.web-rec-title i { font-size:14px; color:#1D9E75; }
.web-rec-sub { font-size:11px; color:var(--color-text-tertiary); }

/* Level 1 — System */
.web-sys { border:0.5px solid var(--color-border-tertiary); border-radius:var(--border-radius-md); overflow:hidden; margin-bottom:8px; }
.web-sys-summary { list-style:none; background:var(--color-background-secondary); padding:12px 14px; display:flex; align-items:center; gap:8px; cursor:pointer; user-select:none; }
.web-sys-summary::-webkit-details-marker { display:none; }
.web-sys-dot { width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.web-sys-name { font-size:13px; font-weight:700; color:var(--color-text-primary); flex:1; text-transform:uppercase; letter-spacing:.04em; }
.web-sys-counts { display:flex; align-items:center; gap:6px; }
.web-sys-total { font-size:11px; color:var(--color-text-tertiary); }
.web-sys-flagged { font-size:11px; background:#FCEBEB; color:#791F1F; padding:1px 8px; border-radius:20px; }
.web-sys-chev { font-size:13px; color:var(--color-text-tertiary); transition:transform .2s; }
.web-sys[open] .web-sys-chev { transform:rotate(180deg); }
.web-sys-body { background:var(--color-background-primary); }

/* Level 2 — Panel */
.web-panel { border-top:0.5px solid var(--color-border-tertiary); }
.web-panel-summary { list-style:none; padding:8px 14px 8px 28px; display:flex; align-items:center; gap:8px; cursor:pointer; user-select:none; background:var(--color-background-primary); }
.web-panel-summary::-webkit-details-marker { display:none; }
.web-panel-chev { font-size:12px; color:var(--color-text-tertiary); flex-shrink:0; transition:transform .15s; }
.web-panel[open] .web-panel-chev { transform:rotate(90deg); }
.web-panel-name { font-size:12px; font-weight:500; color:var(--color-text-primary); flex:1; }
.web-panel-meta { display:flex; align-items:center; gap:6px; }
.web-panel-count { font-size:11px; color:var(--color-text-tertiary); }
.web-panel-flagged { font-size:11px; background:#FCEBEB; color:#791F1F; padding:1px 7px; border-radius:20px; }

/* Level 3 — Metric rows */
.web-metric-table { padding:0 14px 0 46px; background:var(--color-background-primary); }
.web-metric-cols-hdr {
  display:grid; grid-template-columns:1fr 80px 90px 68px 52px; gap:8px; align-items:center;
  padding:5px 0; border-bottom:0.5px solid var(--color-border-secondary);
  background:var(--color-background-secondary); margin:0 -14px 0 -46px; padding-left:46px; padding-right:14px;
}
.web-metric-cols-hdr span { font-size:10px; font-weight:500; text-transform:uppercase; letter-spacing:.06em; color:var(--color-text-tertiary); }
.web-metric-row {
  display:grid; grid-template-columns:1fr 80px 90px 68px 52px; gap:8px; align-items:center;
  padding:6px 0; border-bottom:0.5px solid var(--color-border-tertiary); font-size:12px;
}
.web-metric-row:last-child { border-bottom:none; }
.web-m-name { color:var(--color-text-secondary); display:flex; align-items:center; gap:5px; }
.web-m-trend { font-size:10px; color:var(--color-text-tertiary); display:inline-flex; align-items:center; gap:2px; }
.web-m-trend i { font-size:10px; }
.web-m-val { color:var(--color-text-primary); font-variant-numeric:tabular-nums; }
.web-m-val a { text-decoration:none; }
.web-m-val a:hover { text-decoration:underline; }
.web-m-unit { font-size:10px; color:var(--color-text-tertiary); }
.web-m-range { font-size:11px; color:var(--color-text-tertiary); font-variant-numeric:tabular-nums; }
.web-m-status { font-size:11px;display:flex;align-items:center;gap:3px; }
.web-m-date { font-size:11px; color:var(--color-text-tertiary); font-variant-numeric:tabular-nums; }

/* Status dot — red for any out-of-range value */
.status-dot { display:inline-block;width:7px;height:7px;border-radius:50%;background:#E24B4A;flex-shrink:0;margin-right:2px; }

/* Status colour classes — compound selectors (both classes on same element) */
.status-normal, .in-range { color:var(--color-text-secondary) !important; }
/* Flagged row — bold entire row + subtle background tint */
.web-metric-row.web-metric-flagged {
  background: rgba(250, 238, 218, 0.45);
}
.web-metric-row.web-metric-flagged .web-m-name,
.web-metric-row.web-metric-flagged .web-m-date { font-weight:600; color:var(--color-text-primary); }
/* Value cell colouring — already bold from status classes below */
.web-m-val.status-high, .web-m-val.status-critical { color:#791F1F !important; font-weight:600; }
.web-m-val.status-low  { color:#854F0B !important; font-weight:600; }
/* Status badge pill */
.web-m-status.status-high,
.web-m-status.status-critical { background:#FCEBEB; color:#791F1F !important; padding:2px 8px; border-radius:20px; font-weight:600; }
.web-m-status.status-low   { background:#FAEEDA; color:#854F0B !important; padding:2px 8px; border-radius:20px; font-weight:600; }
.web-m-status.status-normal { background:#E1F5EE; color:#083D36 !important; padding:2px 8px; border-radius:20px; }
/* Responsive — single column on narrow screens */
@media (max-width:640px) {
  /* Auto-width columns — let status pill and date take as much as they need */
  .web-metric-cols-hdr, .web-metric-row {
    grid-template-columns: 1fr auto auto auto;
    gap: 6px;
    padding: 7px 0;
  }
  /* Hide Range column entirely on mobile (was already hidden) */
  .web-metric-cols-hdr span:nth-child(3), .web-m-range { display: none; }
  /* Tighter font and no-wrap to prevent visual collision */
  .web-m-name { font-size: 12px; line-height: 1.3; }
  .web-m-val  { font-size: 12px; white-space: nowrap; }
  .web-m-status {
    font-size: 10px !important;
    padding: 2px 6px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .web-m-date { font-size: 10px; white-space: nowrap; flex-shrink: 0; }
  .web-m-unit { font-size: 9px; }
  /* Reduce left indent so name column has more room */
  .web-metric-table { padding: 0 12px 0 30px; }
  .web-metric-cols-hdr { padding-left: 30px; margin-left: -30px; }
}

/* ── Inline trend chart (web Records accordion) ─────────────────────────── */
.web-trend-wrap {
  display: none;
  grid-column: 1 / -1;   /* span all 5 metric columns */
  padding: 10px 0 6px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
}
.web-trend-wrap.open { display: block; }
.web-trend-canvas { width: 100%; height: 180px; display: block; }

/* Colored left border on Level 1 — override border-radius on left side */
.web-sys { border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0; }

/* ── Modals (trend chart + add reminder) ────────────────────────────────── */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:200;
  display:flex; align-items:center; justify-content:center; padding:16px;
}
.modal-overlay.hidden { display:none; }
.modal-box {
  background:var(--color-background-primary); border-radius:var(--border-radius-lg);
  border:0.5px solid var(--color-border-tertiary); width:100%; max-width:560px;
  max-height:90vh; overflow-y:auto; padding:20px;
}
.modal-hdr { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.modal-title { font-size:15px; font-weight:500; color:var(--color-text-primary); }
.modal-close { background:none; border:none; cursor:pointer; font-size:18px; color:var(--color-text-tertiary); padding:0; }
.modal-close:hover { color:var(--color-text-primary); }
.modal-field { margin-bottom:14px; }
.modal-label { display:block; font-size:11px; font-weight:500; color:var(--color-text-secondary); margin-bottom:5px; }
.modal-input, .modal-select { width:100%; box-sizing:border-box; font-size:13px; padding:8px 10px; border-radius:var(--border-radius-md); border:0.5px solid var(--color-border-tertiary); background:var(--color-background-primary); color:var(--color-text-primary); }
.modal-input:focus, .modal-select:focus { outline:none; border-color:#1D9E75; }
.modal-type-row { display:flex; gap:8px; }
.modal-type-btn { flex:1; padding:7px; border-radius:var(--border-radius-md); border:0.5px solid var(--color-border-tertiary); background:var(--color-background-secondary); font-size:12px; cursor:pointer; color:var(--color-text-secondary); }
.modal-type-btn.active { background:#E1F5EE; border-color:#1D9E75; color:#083D36; font-weight:500; }
.modal-save-btn { width:100%; padding:10px; border-radius:var(--border-radius-md); background:#1D9E75; color:#fff; font-size:14px; font-weight:500; border:none; cursor:pointer; margin-top:4px; }
.modal-save-btn:disabled { opacity:.4; }
.modal-save-btn:not(:disabled):hover { background:#0F6E56; }
/* Trend table */
.trend-table { width:100%; border-collapse:collapse; font-size:12px; margin-top:14px; }
.trend-table th { font-size:10px; font-weight:500; text-transform:uppercase; letter-spacing:.06em; color:var(--color-text-tertiary); padding:5px 8px; border-bottom:0.5px solid var(--color-border-secondary); text-align:left; }
.trend-table td { padding:6px 8px; border-bottom:0.5px solid var(--color-border-tertiary); }
.trend-table tr:last-child td { border-bottom:none; }
.trend-val-flag { color:#A32D2D; font-weight:500; }

/* ── Search bar: slimmer idle, dramatically prominent when active ────────── */
/* Idle: compact and unobtrusive */
.search-bar {
  padding: 6px 12px !important;
  transition: padding 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease, background 0.18s ease;
}
.search-bar input {
  font-size: 12px;
  transition: font-size 0.18s ease;
}
/* Active: visibly larger — user knows they are in search mode */
.search-bar:focus-within {
  width: 60%;                   /* narrows to bring Clear button within reach */
  padding: 11px 16px !important;
  border-color: #1D9E75 !important;
  border-width: 1.5px !important;
  box-shadow: 0 0 0 4px rgba(29,158,117,0.15), 0 2px 8px rgba(0,0,0,0.06) !important;
  background: #fff !important;
}
@media (max-width: 768px) {
  .search-bar:focus-within { width: 100%; }
  /* Hide "Add Health Data" label on mobile — bottom nav + is sufficient */
  .ws-upload-btn span { display: none; }
  .ws-upload-btn { padding: 0 10px; min-width: 36px; }
}
.search-bar:focus-within input {
  font-size: 15px !important;
  color: var(--color-text-primary);
}
.search-bar:focus-within .ti-search {
  color: #1D9E75 !important;
  font-size: 16px !important;
}

/* ── Member header edit pencil (web-only, overlaid top-right of card) ───── */
.member-header-edit-btn {
  position: absolute;
  top: 18px; right: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--color-text-tertiary);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.member-header-edit-btn:hover {
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
}

/* ── Search bar X clear button ──────────────────────────────────────────── */
#search-clear-btn {
  display: none;        /* shown via JS (inline-flex) when input has content */
  align-items: center; justify-content: center;
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 20px;
  color: var(--color-text-secondary);
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
  gap: 3px;
}
#search-clear-btn:hover { background: var(--color-background-primary); color: var(--color-text-primary); border-color: var(--color-border-secondary); }

/* ── Search bar: stronger active state ──────────────────────────────────── */
.search-bar {
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:focus-within {
  border-color: #1D9E75;
  box-shadow: 0 0 0 3px rgba(29,158,117,0.14);
}
.search-bar:focus-within input {
  font-size: 14px;
  color: var(--color-text-primary);
}
.search-bar:focus-within .ti-search { color: #1D9E75 !important; }

/* ── Ask Arogya button in top bar (replaces search form) ────────────────── */
.ws-ask-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 20px; border-radius: 20px;
  background: #083D36; color: #E1F5EE;
  border: none;
  font-size: 13px; font-weight: 500;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
  box-shadow: rgba(8,80,65,0.4) 0px 4px 14px 0px, rgba(0,0,0,0.2) 0px -3px 6px 0px inset;
}
.ws-ask-btn:hover { background: #0A6652; color: #E1F5EE; border-color: transparent; transform: translateY(-1px); box-shadow: rgba(8,80,65,0.5) 0px 6px 18px 0px, rgba(0,0,0,0.2) 0px -3px 6px 0px inset; }
.ws-ask-btn i { font-size: 13px; }

/* ── Rail upload job cards ───────────────────────────────────────────────── */
.rail-job-card {
  margin: 0 10px 9px;
  padding: 9px 10px;
  background: var(--color-background-primary);
  border-radius: var(--border-radius-md);
  border: 0.5px solid var(--color-border-tertiary);
}
.rjc-name {
  font-size: 11px; color: var(--color-text-secondary);
  margin-bottom: 8px; word-break: break-all; line-height: 1.3;
}
/* 4-stage progress track */
.rjc-track {
  display: flex; align-items: center; margin-bottom: 4px;
}
.rjt {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.rjt.rjt-pending  { background: var(--color-background-secondary); border: 1.5px solid var(--color-border-secondary); }
.rjt.rjt-active   { background: #E1F5EE; border: 1.5px solid #1D9E75; animation: rjtPulse 1.2s ease-in-out infinite; }
.rjt.rjt-done     { background: #1D9E75; border: 1.5px solid #1D9E75; color: #fff; }
.rjt.rjt-failed   { background: #FCEBEB; border: 1.5px solid #E24B4A; color: #E24B4A; }
@keyframes rjtPulse { 0%,100%{opacity:1} 50%{opacity:.45} }
.rjl              { flex: 1; height: 1.5px; background: var(--color-border-secondary); }
.rjl.rjl-done     { background: #1D9E75; }
.rjc-labels {
  display: flex; justify-content: space-between;
  font-size: 9px; color: var(--color-text-tertiary);
  margin-bottom: 6px; padding: 0 1px; letter-spacing: 0;
}
/* Attribution section */
.rjc-attr { margin-top: 2px; }
.rja-saved { font-size: 11px; color: var(--color-text-secondary); line-height: 1.4; }
.rja-toggle {
  font-size: 10px; color: var(--color-text-tertiary); background: none;
  border: none; cursor: pointer; padding: 0 2px; text-decoration: underline;
}
.rja-change {
  display: none; flex-direction: column; gap: 5px; margin-top: 6px;
}
.rja-sel {
  font-size: 11px; padding: 4px 6px; border-radius: 6px;
  border: 0.5px solid var(--color-border-secondary); width: 100%;
  background: var(--color-background-secondary); font-family: inherit;
}
.rja-btn {
  font-size: 11px; padding: 4px 10px; border-radius: 6px;
  border: none; background: #1D9E75; color: #fff; cursor: pointer; align-self: flex-start;
}
.rja-btn:hover { background: #178a63; }

/* ── Global window drag-drop overlay ────────────────────────────────────── */
#global-drop-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(29,158,117,0.07);
  border: 3px dashed #1D9E75;
  display: none;        /* shown as flex by JS */
  align-items: center; justify-content: center;
}
.gdrop-inner {
  background: #fff; border-radius: 16px;
  padding: 28px 36px; text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  pointer-events: none;
}

/* Rail card failure message */
.rjc-fail-msg {
  font-size: 10px;
  color: #A32D2D;
  line-height: 1.4;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 0.5px solid #FCEBEB;
}

/* ── Rail card top row (name + dismiss button) ─────────── */
.rjc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 6px;
}
.rjc-name { flex: 1; font-size: 11px; font-weight: 600; color: var(--color-text-primary); word-break: break-all; }
.rjc-dismiss {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  font-size: 13px; line-height: 1; color: var(--color-text-tertiary);
  padding: 0 2px; margin-top: -1px;
}
.rjc-dismiss:hover { color: var(--color-text-secondary); }

/* ── Collapsed success card ─────────────────────────────── */
.rjc-collapsed .rjc-track,
.rjc-collapsed .rjc-labels,
.rjc-collapsed .rjc-attr { display: none; }
.rjc-collapsed .rjc-name::before {
  content: '\2713\00a0';
  color: #1D9E75;
  font-weight: 700;
}

/* ── Attribution: Tier 2 proposed ───────────────────────── */
.rja-proposed { margin-top: 6px; }
.rja-proposed-lbl { font-size: 11px; color: var(--color-text-secondary); line-height: 1.4; display: block; margin-bottom: 5px; }
.rja-conf { color: var(--color-text-tertiary); font-size: 10px; }
.rja-btn-row { display: flex; gap: 5px; margin-bottom: 3px; }
.rja-btn-confirm {
  background: #1D9E75; color: #fff; border: none;
  border-radius: 4px; font-size: 10px; font-weight: 600;
  padding: 4px 10px; cursor: pointer;
}
.rja-btn-confirm:hover { background: #178a64; }
.rja-btn-confirm:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Attribution: Tier 3 unidentified ───────────────────── */
.rja-tier3 { margin-top: 6px; }
.rja-tier3 span { font-size: 11px; color: #9A5800; line-height: 1.4; display: block; margin-bottom: 5px; }

/* ── Attribution: Tier 1 saved ──────────────────────────── */
.rja-saved { margin-top: 6px; font-size: 11px; color: var(--color-text-secondary); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

/* ── Change row (shared across tiers) ───────────────────── */
.rja-change { display: none; flex-direction: row; gap: 4px; margin-top: 4px; align-items: center; }
.rja-sel { font-size: 10px; border: 1px solid var(--color-border-secondary); border-radius: 4px; padding: 3px 4px; background: var(--color-bg-primary); flex: 1; }
.rja-btn { background: var(--color-bg-secondary); border: 1px solid var(--color-border-secondary); border-radius: 4px; font-size: 10px; padding: 4px 8px; cursor: pointer; }
.rja-btn:hover { background: var(--color-bg-tertiary); }
.rja-toggle { background: none; border: none; font-size: 10px; color: #1D9E75; cursor: pointer; padding: 0; text-decoration: underline; }

/* ── Failure message ─────────────────────────────────────── */
.rjc-fail-msg { font-size: 10px; color: #A32D2D; line-height: 1.4; margin-top: 5px; padding-top: 5px; border-top: 0.5px solid #FCEBEB; }

/* ── Upload rail accordion header ─────────────────────────── */
.rail-uploads-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px 5px;
  cursor: pointer;
  border-radius: 6px;
  margin-bottom: 2px;
  user-select: none;
}
.rail-uploads-header:hover { background: var(--color-background-secondary, #f5f5f2); }
.rail-uploads-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.rail-uploads-summary {
  font-size: 10px;
  color: var(--color-text-tertiary);
  margin-left: 2px;
}

/* ── Rail card: name + dismiss row ────────────────────────── */
.rjc-top { display:flex; align-items:flex-start; justify-content:space-between; gap:4px; margin-bottom:6px; }
.rjc-name { flex:1; font-size:11px; font-weight:600; color:var(--color-text-primary); word-break:break-all; }
.rjc-dismiss { flex-shrink:0; background:none; border:none; cursor:pointer; font-size:14px; line-height:1; color:var(--color-text-tertiary); padding:0 2px; margin-top:-1px; }
.rjc-dismiss:hover { color:var(--color-text-secondary); }

/* ── Rail card: attribution row ────────────────────────────── */
.rja-saved { margin-top:6px; font-size:11px; color:var(--color-text-secondary); display:flex; align-items:center; gap:5px; flex-wrap:wrap; }
.rja-change { display:none; flex-direction:row; gap:4px; margin-top:4px; align-items:center; }
.rja-sel { font-size:10px; border:1px solid var(--color-border-secondary); border-radius:4px; padding:3px 4px; background:#fff; color:#333; flex:1; }
.rja-btn { background:#f0f0ed; border:1px solid #ccc; border-radius:4px; font-size:10px; color:#333; padding:4px 10px; cursor:pointer; white-space:nowrap; }
.rja-btn:hover { background:#e5e5e0; }
.rja-btn:disabled { opacity:0.5; cursor:not-allowed; }
.rja-toggle { background:none; border:none; font-size:10px; color:#1D9E75; cursor:pointer; padding:0; text-decoration:underline; white-space:nowrap; }

/* ── Failure message ───────────────────────────────────────── */
.rjc-fail-msg { font-size:10px; color:#A32D2D; line-height:1.4; margin-top:5px; padding-top:5px; border-top:0.5px solid #FCEBEB; }

/* ── Tab canvas: smooth transition on load ─────────────────── */
#ws-tab-canvas { transition: opacity 0.15s ease; }

/* ── Accordion sections (details/summary) ─────────────────────────────────── */
.arog-accordion { border-radius: var(--border-radius-lg); overflow: hidden; margin-bottom: 12px; }
.arog-accordion > summary { list-style: none; cursor: pointer; user-select: none; }
.arog-accordion > summary::-webkit-details-marker { display: none; }
.arog-accordion > summary::marker { display: none; }
.arog-accordion-chev { transition: transform .2s; margin-left: auto; flex-shrink: 0; }
.arog-accordion[open] .arog-accordion-chev { transform: rotate(180deg); }
details[open] .arog-accordion-chev { transform: rotate(180deg); }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { display: none; }


/* ═══════════════════════════════════════════════════════════════════════════
   Member AI topbar — shared across member.html and home.html
   ═══════════════════════════════════════════════════════════════════════════ */

/* Topbar height varies by breakpoint — child elements (tab-nav-row) use this */
:root { --member-topbar-h: 58px; }
@media (max-width: 768px) { :root { --member-topbar-h: 50px; } }

.member-ai-topbar {
  background: #083D36;
  padding: 8px 16px 8px 14px;
  display: flex; align-items: center; gap: 0;
  flex-shrink: 0; position: sticky; top: 0; z-index: 30;
}

.member-menu-btn {
  width: 36px; height: 36px; border-radius: 7px;
  background: rgba(255,255,255,0.1); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; margin-right: 10px;
  -webkit-tap-highlight-color: transparent;
}
.member-menu-btn i { font-size: 18px; color: rgba(255,255,255,0.85); }

/* Scope dropdown */
.member-scope-wrap { position: relative; flex-shrink: 0; }
.member-scope-btn {
  background: rgba(255,255,255,0.12); border: none; cursor: pointer;
  color: #fff; font-size: 14px; font-weight: 700;
  padding: 5px 10px; border-radius: 8px;
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-sans); letter-spacing: -0.01em;
  white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.member-scope-btn:hover { background: rgba(255,255,255,0.18); }
.member-scope-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-secondary);
  border-radius: 10px; padding: 4px 0;
  min-width: 200px; z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.scope-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; font-size: 13px; font-weight: 500;
  color: var(--color-text-primary); text-decoration: none;
  cursor: pointer; white-space: nowrap;
}
.scope-opt:hover { background: var(--color-background-secondary); }
.scope-opt-active { color: #083D36; background: #E1F5EE; }
.scope-opt-active:hover { background: #D0F0E6; }

.member-scope-divider {
  width: 1.5px; height: 28px; background: rgba(255,255,255,0.25);
  flex-shrink: 0; margin: 0 12px;
}

/* Desktop search bar */
.member-ai-bar-inner {
  flex: 0 0 400px; background: #fff;
  border-radius: 10px; display: flex; align-items: center;
  gap: 8px; padding: 8px 8px 8px 13px; cursor: text;
  min-height: 42px;
}
.member-search-input {
  flex: 1; border: none; outline: none;
  font-size: 13px; font-family: var(--font-sans);
  background: transparent; color: var(--color-text-primary);
}
.member-search-input::placeholder { color: #B0ADA8; font-size: 13px; }
.member-mic-btn {
  background: none; border: none; cursor: pointer;
  color: #B0ADA8; display: flex; align-items: center;
  padding: 2px; flex-shrink: 0;
}
.member-mic-btn i { font-size: 16px; }
.member-search-send {
  background: #083D36; color: #fff; border: none;
  border-radius: 8px; padding: 7px 14px;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; flex-shrink: 0; font-family: var(--font-sans);
  white-space: nowrap;
}
.member-search-send i { font-size: 15px; color: #9FE1CB; }
.member-topbar-spacer { flex: 1; min-width: 18%; }
/* ── Topbar "Add health data" button — shown on all pages ── */
.topbar-add-btn {
  margin-left: auto;
  background: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  color: #083D36; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  font-family: var(--font-sans);
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18), 0 1px 2px rgba(0,0,0,0.10);
  letter-spacing: 0.01em;
}
.topbar-add-btn:hover  { background: #f0faf6; box-shadow: 0 3px 8px rgba(0,0,0,0.22); }
.topbar-add-btn:active { background: #e0f5ed; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.topbar-add-btn i { font-size: 14px; color: #083D36; }
@media (max-width: 768px) {
  .topbar-add-btn {
    padding: 8px 12px;
    border-radius: 8px;
    margin-right: 110px;
  }
  .topbar-add-btn-label { display: none; }
}




/* Tablet (769–900px): compress topbar to prevent overflow */
@media (min-width: 769px) and (max-width: 900px) {
  .member-ai-bar-inner { flex: 0 0 240px; }
  .member-scope-btn    { max-width: 120px; font-size: 13px; }
  .topbar-add-btn      { padding: 6px 12px; font-size: 11px; }
  .topbar-add-btn-label { display: none; }
}
/* Mobile-only ask pill — hidden on desktop */
.member-mobile-ask {
  /* Right-aligned: keeps name/scope on the left, button on the right.
     Stays absolute (sticky topbar is its positioning context) but
     uses right:12px instead of the old left:50%/translateX(-50%). */
  position: absolute;
  right: 12px;
  top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 7px 16px;
  color: #fff; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; white-space: nowrap;
  font-family: var(--font-sans);
}
.member-mobile-ask i { font-size: 15px; color: #9FE1CB; }
.member-mobile-ask:active { background: rgba(255,255,255,0.25); }
@media (min-width: 769px) {
  .member-mobile-ask { display: none !important; }
}
@media (max-width: 768px) {
  .member-ai-topbar { padding: 10px 12px !important; }
  /* DO NOT add position: relative — it breaks the sticky behaviour and
     content scrolls over the topbar. position:sticky already creates a
     positioning context for the absolutely-positioned mobile ask pill. */
  .member-scope-divider { display: none; }
  .member-ai-bar-inner { display: none !important; }
  .member-topbar-spacer { display: none !important; }
  .member-scope-btn { font-size: 13px; padding: 4px 8px; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   Horizontal scroll defenders — catch any wide child that escapes its parent
   ═══════════════════════════════════════════════════════════════════════════ */
.ws-shell, .ws-main, .ws-content, .ws-canvas, .home-canvas, #home-canvas {
  overflow-x: hidden;
  max-width: 100%;
}
/* Condition cards & metric chip rows — flex children need min-width:0 so
   the parent doesn't get forced wider by intrinsic child sizes. */
.cond-metrics-row { max-width: 100%; }
.chp-cards-list, .chp-card { min-width: 0; max-width: 100%; }
/* Family chip strip on home — same pattern */
.home-fam-strip { max-width: 100%; }


/* ═══════════════════════════════════════════════════════════════════════════
   Mobile-only tweaks for summary sections (cd: tighter mobile UI)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* Active Health Conditions: full-width cards on mobile */
  .chp-cond-grid { grid-template-columns: 1fr !important; }

  /* Hide "X on treatment" badge in section header on mobile (clutter) */
  /* Hide "X flagged" badge in Watching section header on mobile */
  .sec-count { display: none !important; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   Records tab — filter bar (cd: prevent iOS zoom, fix mobile usability)
   ═══════════════════════════════════════════════════════════════════════════ */
.rec-filter-input {
  flex: 1; border: 0.5px solid var(--color-border-secondary);
  border-radius: 7px; padding: 6px 10px;
  font-size: 13px; font-family: var(--font-sans);
  outline: none;
  background: var(--color-background-primary);
  color: var(--color-text-primary);
}
.rec-filter-btn {
  font-size: 12px; font-weight: 500;
  padding: 6px 10px; border-radius: 6px;
  border: 0.5px solid var(--color-border-secondary);
  background: var(--color-background-primary);
  color: var(--color-text-secondary);
  cursor: pointer; white-space: nowrap;
  font-family: var(--font-sans);
}
.rec-filter-select { padding: 6px 8px; }

/* Mobile: bump to 16px to disable iOS auto-zoom on focus */
@media (max-width: 768px) {
  .rec-filter-input,
  .rec-filter-btn,
  .rec-filter-select {
    font-size: 16px !important;
  }
  .rec-filter-input { padding: 8px 12px; }
  .rec-filter-btn { padding: 8px 12px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   History Timeline v2 — unified component for Upload History + Member History
   ═══════════════════════════════════════════════════════════════════════════ */

/* Filter bar (only on Upload History) */
.htl-filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 16px;
}
.htl-filter-lbl {
  font-size: 11px; color: var(--color-text-tertiary);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 500;
}
.htl-fchip {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 14px; padding: 5px 12px;
  font-size: 12px; color: var(--color-text-secondary);
  text-decoration: none; transition: background .12s, color .12s;
}
.htl-fchip:hover { background: var(--color-background-secondary); }
.htl-fchip.on {
  background: #083D36; color: #fff; border-color: #083D36;
}
.htl-counter {
  margin-left: auto; font-size: 12px;
  color: var(--color-text-tertiary);
}

/* Timeline wrap — provides padding for the left spine column */
.htl-wrap { padding-left: 80px; position: relative; }
.htl-timeline { position: relative; }
.htl-timeline::before {
  content: ''; position: absolute;
  left: -18px; top: 14px; bottom: 8px;
  width: 1.5px;
  background: var(--color-border-secondary);
}

.htl-month {
  font-size: 11px; color: var(--color-text-tertiary);
  font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  margin: 18px 0 8px;
}

.htl-row { position: relative; margin-bottom: 7px; }
.htl-date {
  position: absolute; left: -80px; top: 8px;
  width: 56px; text-align: right;
}
.htl-d {
  font-size: 22px; font-weight: 500;
  color: var(--color-text-primary); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.htl-mo {
  font-size: 12px; font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase; letter-spacing: .06em;
  margin-top: 4px;
}
.htl-yr {
  font-size: 10px; color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}

.htl-dot {
  position: absolute; left: -22px; top: 15px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--color-background-primary);
  border: 1.5px solid var(--color-border-secondary);
  z-index: 1;
}
.htl-dot.dot-lab   { border-color: #0F6E56; }
.htl-dot.dot-rx    { border-color: #854F0B; }
.htl-dot.dot-scan  { border-color: #534AB7; }
.htl-dot.dot-visit { border-color: #185FA5; }
.htl-dot.dot-sym   { border-color: #A32D2D; }
.htl-dot.dot-vac   { border-color: #5F5E5A; }

/* The card itself */
.htl-card {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.htl-card:hover { border-color: var(--color-border-secondary); }
.htl-card-head {
  padding: 10px 12px;
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Type tag */
.htl-tag {
  font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: .04em;
  flex-shrink: 0; margin-top: 2px;
  font-family: var(--font-sans);
}
.htl-tag.tag-lab   { background: #E1F5EE; color: #083D36; }
.htl-tag.tag-rx    { background: #FAEEDA; color: #854F0B; }
.htl-tag.tag-scan  { background: #EEEDFE; color: #3C3489; }
.htl-tag.tag-visit { background: #EAF0FB; color: #185FA5; }
.htl-tag.tag-sym   { background: #FCEBEB; color: #791F1F; }
.htl-tag.tag-vac   { background: #F1EFE8; color: #444441; }

/* Info column */
.htl-info { flex: 1; min-width: 0; }
.htl-l1 {
  font-size: 13px; font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.35;
}
.htl-l2 {
  font-size: 12px; color: var(--color-text-tertiary);
  margin-top: 3px; line-height: 1.4;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.htl-l3 {
  display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px;
}
.htl-panel-chip {
  font-size: 10px; padding: 2px 8px; border-radius: 3px;
  background: var(--color-background-secondary);
  color: var(--color-text-secondary);
  font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
}
.htl-panel-chip.pn-cbc     { background: #FCEBEB; color: #791F1F; }
.htl-panel-chip.pn-lft     { background: #FAEEDA; color: #854F0B; }
.htl-panel-chip.pn-kft     { background: #EEEDFE; color: #3C3489; }
.htl-panel-chip.pn-lipid   { background: #FAEEDA; color: #854F0B; }
.htl-panel-chip.pn-thyroid { background: #EEEDFE; color: #3C3489; }
.htl-panel-chip.pn-hba1c   { background: #FCEBEB; color: #791F1F; }

/* Right side — person pill + kebab */
.htl-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; margin-top: 1px;
}
.htl-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  padding: 3px 10px 3px 4px; border-radius: 12px;
  white-space: nowrap;
}
.htl-pill-avt {
  width: 18px; height: 18px; border-radius: 50%;
  color: #fff; font-size: 9px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.htl-pill.p-coral  { background: #FAECE7; color: #993C1D; }
.htl-pill.p-purple { background: #EEEDFE; color: #3C3489; }
.htl-pill.p-amber  { background: #FAEEDA; color: #854F0B; }
.htl-pill.p-red    { background: #FCEBEB; color: #A32D2D; }
.htl-pill.p-slate  { background: #EAF0FB; color: #185FA5; }
.htl-pill.p-sage   { background: #EAF3DE; color: #3B6D11; }
.htl-pill.p-custom { background: var(--color-background-secondary); color: var(--color-text-secondary); }

.htl-menu {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--color-text-tertiary);
  font-size: 14px; cursor: pointer;
  border-radius: 5px;
  font-family: var(--font-sans);
}
.htl-menu:hover { background: var(--color-background-secondary); }

/* Expansion body */
.htl-exp {
  display: none;
  padding: 0 12px 12px;
  border-top: 0.5px solid var(--color-border-tertiary);
  font-size: 12px;
  flex-direction: column; gap: 10px;
}
.htl-card.open .htl-exp { display: flex; padding-top: 12px; }
.htl-card.open { border-color: var(--color-border-secondary); }
.htl-exp-row {
  display: flex; gap: 14px; align-items: flex-start;
}
.htl-exp-lbl {
  font-size: 10px; color: var(--color-text-tertiary);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 500;
  min-width: 80px; padding-top: 2px; flex-shrink: 0;
}
.htl-exp-val {
  flex: 1; color: var(--color-text-primary); line-height: 1.55;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.htl-exp-mono {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-secondary);
}

/* Medications */
.htl-med {
  font-size: 12px;
  color: var(--color-text-primary);
  line-height: 1.55;
  padding: 2px 0;
}
.htl-med + .htl-med { margin-top: 4px; }
.htl-med-low {
  color: #888780;
  font-style: italic;
}
.htl-conf-tag {
  font-size: 9px; font-weight: 500;
  background: #FAEEDA; color: #854F0B;
  padding: 1px 6px; border-radius: 3px;
  margin-left: 6px; font-style: normal;
  text-transform: uppercase; letter-spacing: .04em;
}

/* Value chips inside expansion */
.htl-exp-chips {
  display: flex; gap: 5px; flex-wrap: wrap;
}
.htl-val-chip {
  font-size: 11px; padding: 2px 7px; border-radius: 3px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.htl-val-chip.vc-bad     { background: #FCEBEB; color: #791F1F; }
.htl-val-chip.vc-warn    { background: #FAEEDA; color: #854F0B; }
.htl-val-chip.vc-good    { background: #E1F5EE; color: #083D36; }
.htl-val-chip.vc-neutral { background: var(--color-background-secondary); color: var(--color-text-secondary); }

/* Action buttons */
.htl-exp-actions {
  display: flex; gap: 6px; padding-top: 4px;
  flex-wrap: wrap;
}
.htl-act-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 6px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  font-size: 12px; color: var(--color-text-primary);
  cursor: pointer; font-family: var(--font-sans);
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.htl-act-btn i { font-size: 13px; }
.htl-act-btn:hover { background: var(--color-background-secondary); border-color: var(--color-border-secondary); }
.htl-act-btn.htl-primary {
  background: #083D36; color: #fff; border-color: #083D36;
}
.htl-act-btn.htl-primary:hover { background: #04342C; border-color: #04342C; }
.htl-act-btn.htl-danger { color: #791F1F; }
.htl-act-btn.htl-danger:hover { background: #FCEBEB; border-color: #F09595; }

/* Empty state */
.htl-empty {
  text-align: center; padding: 40px 20px;
  color: var(--color-text-tertiary);
}
.htl-empty i { font-size: 32px; margin-bottom: 10px; display: block; }
.htl-empty-title { font-size: 14px; font-weight: 500; color: var(--color-text-secondary); margin: 0 0 4px; }
.htl-empty-sub { font-size: 12px; margin: 0; }

/* Failed jobs section — collapsed by default */
.htl-failed {
  margin-top: 24px;
  background: #FCEBEB;
  border: 0.5px solid #F09595;
  border-radius: 8px;
}
.htl-failed-hdr {
  padding: 10px 14px;
  font-size: 12px; font-weight: 500;
  color: #791F1F;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  list-style: none;
}
.htl-failed-hdr::-webkit-details-marker { display: none; }
.htl-failed-body { padding: 0 12px 12px; }
.htl-failed-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-top: 0.5px solid #F09595;
  font-size: 12px;
}
.htl-failed-meta { flex: 1; min-width: 0; }
.htl-failed-name { font-weight: 500; color: var(--color-text-primary); }
.htl-failed-sub { font-size: 11px; color: var(--color-text-tertiary); margin-top: 2px; }

/* ─── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .htl-wrap { padding-left: 0; }
  .htl-timeline::before { display: none; }
  .htl-date { display: none; }
  .htl-dot { display: none; }

  .htl-card-head {
    padding: 9px 11px;
    gap: 7px;
    flex-wrap: wrap;
  }
  .htl-tag { font-size: 9px; padding: 2px 7px; }
  .htl-l1 {
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .htl-l2 {
    font-size: 10px;
    margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* Hide panel chips on mobile — keep mobile compact */
  .htl-l3 { display: none; }
  .htl-info { flex: 1 1 100%; order: 2; min-width: 0; }
  .htl-tag { order: 1; }
  .htl-right { order: 1; margin-left: auto; }
  .htl-pill {
    font-size: 10px; padding: 2px 7px 2px 3px;
    border-radius: 11px;
  }
  .htl-pill-avt { width: 15px; height: 15px; font-size: 8px; }
  .htl-pill-name { display: none; }  /* avatar dot only on mobile */

  .htl-exp-row {
    flex-direction: column; gap: 4px;
  }
  .htl-exp-lbl { padding-top: 0; }
  .htl-act-btn { font-size: 12px; padding: 8px 12px; }

  .htl-filterbar {
    gap: 5px; margin-bottom: 12px;
  }
  .htl-filter-lbl { display: none; }
  .htl-fchip { font-size: 11px; padding: 4px 10px; }
  .htl-counter { font-size: 11px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ch+: Flagged-only slider switch (next to search bar, Records tab only)
   ═══════════════════════════════════════════════════════════════════════════ */
.flagged-switch-wrap {
  display: none;  /* hidden by default; .show added by JS when Records tab active */
  align-items: center; gap: 7px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}
.flagged-switch-wrap.show { display: inline-flex; }
.flagged-switch-lbl {
  font-size: 12px; font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
}
.flagged-switch {
  position: relative;
  width: 36px; height: 20px;
  border-radius: 10px;
  background: #C8C4B8;
  border: none; padding: 0;
  cursor: pointer;
  transition: background .18s;
  flex-shrink: 0;
}
.flagged-switch:hover { background: #B5B0A2; }
.flagged-switch.on { background: #083D36; }
.flagged-switch.on:hover { background: #04342C; }
.flagged-switch-knob {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform .18s;
}
.flagged-switch.on .flagged-switch-knob {
  transform: translateX(16px);
}

@media (max-width: 768px) {
  .flagged-switch-lbl { display: none; }  /* switch-only on mobile */
}

/* Generic search-hidden marker — works for any card/row */
.search-hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   ch+: Desktop sidebar collapse to icons-only
   When .ws-shell has .sidebar-collapsed:
     - Sidebar shrinks 220px → 56px showing just member avatar dots
     - Right "Needs attention" rail expands 260px → 320px
     - Member names, section labels, brand text hide; icons stay
   ═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  /* Sidebar collapse */
  .ws-shell.sidebar-collapsed .ws-rail {
    width: 56px;
    transition: width .22s ease;
  }
  .ws-shell:not(.sidebar-collapsed) .ws-rail {
    transition: width .22s ease;
  }

  /* Right rail expansion — fills the freed-up space */
  .ws-shell.sidebar-collapsed .ws-attention {
    width: 320px;
    transition: width .22s ease;
  }
  .ws-shell:not(.sidebar-collapsed) .ws-attention {
    transition: width .22s ease;
  }

  /* Hide the things that don't fit in 56px */
  .ws-shell.sidebar-collapsed .ws-rail-brand span,
  .ws-shell.sidebar-collapsed .ws-rail-fam,
  .ws-shell.sidebar-collapsed .ws-rail-sec,
  .ws-shell.sidebar-collapsed .ws-rail-m-name,
  .ws-shell.sidebar-collapsed .ws-rail-flag,
  .ws-shell.sidebar-collapsed .ws-rail-bottom {
    display: none;
  }

  /* ch+: kill the text-node leak in workspace nav links
     ("Family home", "Medical activities", "Ask Arogya AI", "Upload history" are
     raw text nodes next to the icon — display:none on the parent would hide
     the whole item, so we zero the font-size and restore it on the icon). */
  .ws-shell.sidebar-collapsed .ws-rail-item {
    font-size: 0;
    padding: 9px 0;
    margin: 1px 6px;
    width: calc(100% - 12px);
    justify-content: center;
    gap: 0;
  }
  .ws-shell.sidebar-collapsed .ws-rail-item i {
    font-size: 18px;
    width: auto;
  }

  /* Tighten padding so avatars sit cleanly centered */
  .ws-shell.sidebar-collapsed .ws-rail-top {
    padding: 18px 6px 8px;
  }
  .ws-shell.sidebar-collapsed .ws-rail-brand {
    justify-content: center;
    margin-bottom: 10px;
    font-size: 22px;
  }
  .ws-shell.sidebar-collapsed .ws-rail-nav {
    padding-top: 4px;
  }
  .ws-shell.sidebar-collapsed .ws-rail-member {
    justify-content: center;
    padding: 6px 4px;
    margin: 2px 4px;
    border-radius: 8px;
    gap: 0;
  }
  /* Active member highlight extends across the narrow rail */
  .ws-shell.sidebar-collapsed .ws-rail-member.active {
    background: rgba(255, 255, 255, 0.10);
  }
  /* Slightly larger avatar in collapsed mode — it's the only thing shown */
  .ws-shell.sidebar-collapsed .ws-rail-m-av {
    width: 32px; height: 32px;
    font-size: 13px;
  }
}

/* On mobile, .sidebar-collapsed is a no-op — drawer behaviour overrides it */
@media (max-width: 768px) {
  .ws-shell.sidebar-collapsed .ws-rail {
    width: 280px;  /* normal drawer width */
  }
}

/* ───────────────────────────────────────────────────────────────────
   v4.3 IA additions (build er)
   - Noto Sans per-script font @import
   - :lang() selectors for correct line-height per script
   - Global .form-label rule
   - Responsive sidebar hide on mobile
   ─────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;500;600&family=Noto+Sans+Tamil:wght@400;500;600&family=Noto+Sans+Telugu:wght@400;500;600&family=Noto+Sans+Bengali:wght@400;500;600&family=Noto+Sans+Gujarati:wght@400;500;600&family=Noto+Sans+Kannada:wght@400;500;600&family=Noto+Sans+Malayalam:wght@400;500;600&display=swap');

:lang(hi), :lang(mr) { font-family: 'Noto Sans Devanagari', var(--font-sans); line-height: 1.85; }
:lang(ta)            { font-family: 'Noto Sans Tamil',      var(--font-sans); line-height: 1.90; }
:lang(te)            { font-family: 'Noto Sans Telugu',     var(--font-sans); line-height: 1.85; }
:lang(bn)            { font-family: 'Noto Sans Bengali',    var(--font-sans); line-height: 1.80; }
:lang(gu)            { font-family: 'Noto Sans Gujarati',   var(--font-sans); line-height: 1.85; }
:lang(kn)            { font-family: 'Noto Sans Kannada',    var(--font-sans); line-height: 1.85; }
:lang(ml)            { font-family: 'Noto Sans Malayalam',  var(--font-sans); line-height: 1.90; }

/* Global form label — v4.3 hierarchy (13px / 600 / brand colour) */
.form-label,
form label,
.field-label {
  font-size: var(--form-label-size);
  font-weight: var(--form-label-weight);
  color: var(--form-label-color);
  letter-spacing: 0.1px;
  margin-bottom: 8px;
  display: block;
}
.form-label .req,
.form-label .required,
form label .req,
form label .required { color: #DC2626; }

.form-label .opt,
form label .opt {
  color: #9CA3AF;
  font-weight: 400;
  font-size: 11px;
}

/* Responsive sidebar — mobile hide of the workspace rail is already
   handled by the existing @media (max-width: 768px) block above
   (`.ws-rail { position: fixed; transform: translateX(-100%); ... }`
   plus `.ws-shell.drawer-open .ws-rail { transform: translateX(0) }`).
   No additional rule needed here. */

/* ───────────────────────────────────────────────────────────────────
   v4.3 IA — topbar partial, FAB (build er)
   Note: desktop sidebar collapse is already handled by the existing
   `.ws-shell.sidebar-collapsed .ws-rail` CSS block (workspace.css ~L1894+)
   and `wsToggleDrawer()` JS in workspace.html. wsToggleSidebar() in
   nav.js is a thin alias to that existing function.
   ─────────────────────────────────────────────────────────────────── */

/* Collapsible sidebar — handled by existing .ws-shell.sidebar-collapsed rules. */

/* New topbar partial (.ws-topbar) — fresh shell, brand-green chrome.
   Currently only used by templates that opt in via {% include "partials/topbar.html" %}.
   Existing pages keep using .member-ai-topbar. */
.ws-topbar {
  height: var(--topbar-height);
  background: var(--color-brand);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 30;
}
.ws-topbar-hamburger,
.ws-topbar-back {
  width: 34px; height: 34px;
  border: none; background: transparent;
  border-radius: 7px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ws-topbar-hamburger:hover,
.ws-topbar-back:hover { background: rgba(255,255,255,0.1); }
.ws-topbar-hamburger i,
.ws-topbar-back i { font-size: 18px; }
.ws-topbar-titleblock { line-height: 1.15; }
.ws-topbar-title {
  font-size: 14px; font-weight: 500; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-topbar-subtitle {
  font-size: 11px; color: rgba(255,255,255,0.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ws-topbar-context-pill {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  padding: 5px 10px 5px 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.ws-topbar-context-pill:hover { background: rgba(255,255,255,0.18); }
.ws-topbar-context-av {
  width: 22px; height: 22px; border-radius: 50%;
  background: #D97706;
  font-size: 10px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.ws-topbar-context-name {
  font-size: 13px; font-weight: 500; color: #fff;
  white-space: nowrap;
}
.ws-topbar-context-caret { font-size: 13px; color: rgba(255,255,255,0.6); }
.ws-topbar-ai-search {
  flex: 1; max-width: 540px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  padding: 6px 10px;
}
.ws-topbar-ai-search i { font-size: 15px; color: rgba(255,255,255,0.55); flex-shrink: 0; }
.ws-topbar-ai-search input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: inherit; font-size: 13px; color: #fff;
  min-width: 0;
}
.ws-topbar-ai-search input::placeholder { color: rgba(255,255,255,0.5); }
.ws-topbar-spacer { flex: 1; }
.ws-topbar-doctor-cta {
  background: var(--color-amber-action);
  color: #1B1C1A;
  border: none;
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12px; font-weight: 600;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.ws-topbar-doctor-cta i { font-size: 14px; }
.ws-topbar-acct-chip {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
}
.ws-topbar-acct-chip:hover { background: rgba(255,255,255,0.22); }
.ws-topbar-acct-initial {
  font-size: 11px; font-weight: 700; color: #fff;
}
@media (max-width: 768px) {
  .ws-topbar { padding: 0 10px; gap: 6px; }
  .ws-topbar-ai-search { display: none; }  /* mobile uses FAB instead */
  .ws-topbar-title { font-size: 13px; }
}

/* Floating Ask Arogya AI button (.ws-fab) — corner button on every
   authenticated page except /ask. */
.ws-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  background: var(--color-brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(8, 61, 54, 0.28);
  z-index: 60;            /* above bottom nav (z:30), below modals */
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ws-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(8, 61, 54, 0.35); }
.ws-fab:active { transform: translateY(0); }
.ws-fab i { font-size: 24px; color: #fff; }
/* Mobile: sit above the bottom nav */
@media (max-width: 768px) {
  .ws-fab {
    bottom: var(--fab-offset-bottom);
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .ws-fab i { font-size: 22px; }
}

/* ───────────────────────────────────────────────────────────────────
   v4.3 Watching strip — slim tiles (build er)
   Lives at the top of the Records tab. Horizontal-scroll list of
   flagged metrics. Tap a tile to open the trend chart.
   ─────────────────────────────────────────────────────────────────── */
.wt-strip {
  margin: 4px 0 14px;
}
.wt-strip-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px 8px;
  font-family: var(--font-sans);
}
.wt-strip-hdr i { font-size: 14px; color: var(--color-brand); }
.wt-strip-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-primary);
}
.wt-strip-count {
  font-size: 10px;
  color: var(--color-text-tertiary);
}
.wt-strip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.wt-strip-scroll::-webkit-scrollbar { height: 4px; }
.wt-strip-scroll::-webkit-scrollbar-thumb {
  background: var(--color-border-secondary);
  border-radius: 4px;
}
.wt-tile {
  flex: 0 0 78px;
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-left: 3px solid var(--color-text-tertiary);  /* overridden inline */
  border-radius: 8px;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.wt-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.wt-tile:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}
.wt-tile-name {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wt-tile-vrow {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-top: 1px;
}
.wt-tile-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1;
}
.wt-tile-unit {
  font-size: 9px;
  color: var(--color-text-secondary);
}
.wt-tile-range {
  font-size: 9px;
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

/* ───────────────────────────────────────────────────────────────────
   v4.3 Add Sheet bottom sheet (build er)
   Opens from ⊕ centre button. 3 cards: Upload / Activity / Quick note.
   ─────────────────────────────────────────────────────────────────── */
.add-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.1s ease, transform 0.06s ease;
}
.add-card:hover {
  border-color: var(--color-border-secondary);
  transform: translateY(-1px);
}
.add-card:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 1px;
}
.add-card-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: rgba(8, 61, 54, 0.08);
  color: var(--color-brand);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.add-card-icon i { font-size: 18px; }
.add-card-text { flex: 1; min-width: 0; }
.add-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-primary);
  line-height: 1.2;
}
.add-card-sub {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
  line-height: 1.3;
}
.add-card-chev {
  font-size: 14px;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}


/* ═════════════════════════════════════════════════════════════════════════
 * Build `es` — Records Hub + Doctor Directory styles
 * ═════════════════════════════════════════════════════════════════════════ */

/* Records Hub landing — 6 lens cards */
.records-hub-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 640px) {
  .records-hub-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .records-hub-grid { grid-template-columns: repeat(6, 1fr); }
}

.lens-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 12px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.lens-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.lens-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #E6F1FB;
  color: #185FA5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
}
.lens-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.lens-card-count {
  font-size: 11px;
  color: var(--color-text-tertiary);
  margin-top: 2px;
}
.lens-card-count-muted { opacity: 0.6; }

/* Series cards in Conditions lens */
.series-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 10px;
  margin-bottom: 8px;
}

/* Status pills (used by series, episodes) */
.status-pill {
  font-size: 10px;
  font-weight: 500;
  border-radius: 8px;
  padding: 2px 8px;
  white-space: nowrap;
}
.status-active   { background: #E6F1FB; color: #0C447C; }
.status-closed   { background: #F3F4F6; color: #4B5563; }
.status-merged   { background: #F0E7FF; color: #5B21B6; }
.status-deleted  { background: #FEE2E2; color: #991B1B; }
.status-orphaned { background: #FEF3C7; color: #92400E; display: inline-flex; align-items: center; gap: 3px; }

/* Series ⋮ kebab menu */
.series-kebab { position: relative; }
.series-kebab-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.series-kebab-btn:hover { background: #F3F4F6; color: var(--color-text-primary); }
.series-kebab-btn .ti { font-size: 18px; }
.series-kebab-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  min-width: 180px;
  z-index: 20;
  overflow: hidden;
}
.series-kebab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  color: var(--color-text-primary);
}
.series-kebab-item:hover { background: #F9FAFB; }
.series-kebab-item .ti { font-size: 14px; color: var(--color-text-tertiary); }
.series-kebab-item-danger { color: #B91C1C; }
.series-kebab-item-danger .ti { color: #B91C1C; }

/* Body system tiles */
.body-system-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 480px) { .body-system-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 768px) { .body-system-grid { grid-template-columns: repeat(4, 1fr); } }
.body-system-tile {
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: transform 0.12s ease;
}
.body-system-tile:hover { transform: translateY(-1px); }
.body-system-tile-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #E6F1FB;
  color: #185FA5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin: 0 auto 8px;
}
.body-system-tile-empty .body-system-tile-icon { background: #F3F4F6; color: #9CA3AF; }
.body-system-tile-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.2;
}
.body-system-tile-stats {
  font-size: 9px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
}
.body-system-tile-flag {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #C2410C;
  color: #fff;
  font-size: 8px;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 500;
}

/* Episode card (Episodes lens) */
.episode-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  margin-bottom: 6px;
  text-decoration: none;
  color: inherit;
}

/* Incident row (Episode Detail) */
.incident-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  margin-bottom: 6px;
}
.incident-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex: 0 0 auto;
}
.incident-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-quaternary);
  border-radius: 4px;
}
.incident-delete-btn:hover { color: #B91C1C; background: #FEE2E2; }

/* Timeline */
.timeline-event {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--color-border-tertiary);
}
.timeline-event-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex: 0 0 auto;
}

/* Filter chips (Doctors list, etc.) */
.filter-chip {
  font-size: 12px;
  padding: 6px 12px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 16px;
  background: #fff;
  color: var(--color-text-primary);
  text-decoration: none;
  white-space: nowrap;
}
.filter-chip.active {
  background: #085041;
  color: #fff;
  border-color: #085041;
}

/* Doctor card */
.doctor-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 10px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
}
.doctor-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #E6F1FB;
  color: #185FA5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex: 0 0 auto;
}

/* Medication row */
.medication-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  margin-bottom: 6px;
}
.medication-row-history { background: #FAFAFA; opacity: 0.92; }
.medication-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FEF3C7;
  color: #92400E;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex: 0 0 auto;
}

/* Buttons used across new pages */
.es-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 0.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
}
.es-btn-primary { background: #085041; color: #fff; }
.es-btn-primary:hover { background: #06402F; }
.es-btn-secondary { background: #fff; color: var(--color-text-primary); border-color: var(--color-border-tertiary); }
.es-btn-secondary:hover { background: #F9FAFB; }
.es-btn-danger-outline { background: #fff; color: #B91C1C; border-color: #FCA5A5; }
.es-btn-danger-outline:hover { background: #FEE2E2; }

/* Confirmation modal */
.es-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.es-modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  max-width: 420px;
  margin: 0 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.18);
}
