/* ============================================================
   Ivy Operator Portal — Altura Ops design system
   Source: alturaops.pplx.app (matched exactly)
   ============================================================ */

:root {
  /* Surfaces */
  --bg:            #f7f5f1;   /* page bg — warm cream */
  --card:          #fbfaf7;   /* card bg — near white warm */
  --card-2:        #ffffff;   /* elevated panel */
  --muted-surface: #ebe6df;   /* secondary buttons, soft pills */

  /* Ink */
  --fg:            #0f272d;   /* primary text */
  --fg-soft:       #2d4046;
  --muted:         #55676c;   /* muted text */
  --muted-2:       #788982;

  /* Lines */
  --line:          #e2dcd4;
  --card-line:     #e6e1da;
  --line-soft:     #efeae2;
  --input-line:    #d4cdc3;

  /* Brand */
  --teal:          #0f3c47;   /* deep dark teal — sidebar, primary */
  --teal-2:        #1c4854;   /* lighter teal — active hover */
  --teal-ink:      #0f272d;
  --teal-on:       #f8f5f0;   /* text on teal */

  --gold:          #fbbd12;   /* amber gold — CTA, active accent */
  --gold-soft:     #fff4d1;
  --gold-line:     #f0c75a;

  --sage:          #788982;
  --sand:          #a2937f;
  --green:         #3d575b;

  --danger:        #c33035;
  --danger-soft:   #fbe8e8;
  --warn:          #d18419;
  --ok:            #2e7d5f;
  --ok-soft:       #dff1e7;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Tenor Sans", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Radius / shadow */
  --r-sm: 6px;
  --r:    8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(15,39,45,.04);
  --shadow:    0 2px 4px rgba(15,39,45,.06), 0 1px 2px -1px rgba(15,39,45,.04);
  --shadow-lg: 0 8px 24px rgba(15,39,45,.10);

  /* Spacing */
  --sidebar-w: 252px;
  --sidebar-w-collapsed: 60px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus { left: 12px; top: 12px; width: auto; height: auto; padding: 8px 12px; background: var(--gold); color: var(--teal); border-radius: 6px; z-index: 9999; }

/* ============================================================
   Shell layout
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 200ms ease;
}
body.sidebar-collapsed .shell {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}
body.sidebar-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .ni-label,
body.sidebar-collapsed .ni-group-label,
body.sidebar-collapsed .sidebar-foot,
body.sidebar-collapsed .sidebar-group-label { display: none !important; }
body.sidebar-collapsed .sidebar-nav .ni { justify-content: center; padding: 8px 6px; }
body.sidebar-collapsed .sidebar-nav .ni-icon { margin: 0; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; gap: 0; }

/* Collapsed sidebar — icon-only buttons with hover tooltip */
body.sidebar-collapsed .sidebar-nav .nav-item {
  justify-content: center;
  padding: 10px 0;
  width: 44px;
  height: 44px;
  margin: 2px auto;
  border-radius: 10px;
  position: relative;
  overflow: visible;
}
body.sidebar-collapsed .sidebar-nav .nav-item .ni-icon {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
body.sidebar-collapsed .sidebar-nav .nav-item .ni-icon svg {
  width: 20px;
  height: 20px;
}
body.sidebar-collapsed .sidebar-nav .ni-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  font-size: 10px;
  line-height: 16px;
  padding: 0 4px;
  border-radius: 8px;
}
body.sidebar-collapsed .sidebar-nav .nav-group {
  margin-bottom: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 6px;
}
body.sidebar-collapsed .sidebar-nav .nav-group:first-child {
  border-top: none;
  padding-top: 0;
}
/* Tooltip on hover */
body.sidebar-collapsed .sidebar-nav .nav-item::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 2000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
body.sidebar-collapsed .sidebar-nav .nav-item:hover::after {
  opacity: 1;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  background: var(--teal);
  color: var(--teal-on);
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid #0a2730;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid #112e35;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #0a2730;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 28px; height: 28px; display: block; }
.brand-text { line-height: 1.15; }
.brand-eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #97aab0;
  margin-bottom: 2px;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--teal-on);
  letter-spacing: 0.01em;
}

/* Sidebar nav */
.sidebar-nav { flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8aa1a8;
  padding: 0 10px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  color: #d9e2e4;
  padding: 8px 10px;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  border-radius: 6px;
  margin-bottom: 2px;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item .ni-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  color: #8aa1a8;
}
.nav-item:hover .ni-icon { color: var(--gold); }
.nav-item.is-active {
  background: var(--teal-2);
  color: #fff;
}
.nav-item.is-active .ni-icon { color: var(--gold); }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
}
.nav-item .ni-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: var(--danger);
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar-foot {
  padding: 12px 8px 4px;
  border-top: 1px solid #112e35;
  margin-top: 8px;
}
.sidebar-foot-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8aa1a8;
  margin-bottom: 6px;
}
.role-pill {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid #1c4854;
  color: var(--teal-on);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.role-pill:hover { background: rgba(255,255,255,0.10); }
.role-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
}
.role-caret { margin-left: auto; color: #97aab0; }

/* ============================================================
   Topbar + Main
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 34px; height: 34px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--muted-surface); color: var(--fg); }

.crumb { display: flex; align-items: baseline; gap: 8px; }
.crumb-section {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--fg);
  letter-spacing: 0.01em;
}
.crumb-sub {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.crumb-sub::before {
  content: "›";
  margin-right: 6px;
  color: var(--muted-2);
}

.topbar-right { display: flex; align-items: center; gap: 8px; }
.facility-switcher {
  display: flex;
  gap: 4px;
  background: var(--muted-surface);
  padding: 3px;
  border-radius: 8px;
}
.fac-pill {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.fac-pill:hover { color: var(--fg); }
.fac-pill.is-active {
  background: var(--gold);
  color: var(--teal-ink);
  font-weight: 600;
}

.app-root {
  padding: 28px 28px 60px;
  outline: none;
  max-width: 1440px;
  width: 100%;
}

/* ============================================================
   Page header / shell
   ============================================================ */
.page-head { margin-bottom: 24px; }
.page-eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 600;
  margin-bottom: 6px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  margin: 0 0 8px;
  color: var(--fg);
  letter-spacing: 0.005em;
  font-weight: 400;
}
.page-lede {
  color: var(--muted);
  font-size: 14px;
  max-width: 720px;
  margin: 0;
}
.page-head .head-actions {
  display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.card-tight { padding: 14px 16px; }
.card-elev { box-shadow: var(--shadow); background: var(--card-2); }

.card > h2,
.card > .card-head h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 400;
  margin: 0 0 14px;
  color: var(--fg);
  letter-spacing: 0.005em;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; }
.card-head .head-meta { font-size: 12px; color: var(--muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.card-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 880px) {
  .card-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--teal);
  color: var(--teal-on);
  border: 1px solid var(--teal);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-sm);
  transition: background 0.12s, transform 0.05s;
}
.btn:hover { background: var(--teal-2); }
.btn:active { transform: translateY(1px); }
.btn-cta {
  background: var(--gold);
  color: var(--teal-ink);
  border-color: var(--gold);
  font-weight: 600;
}
.btn-cta:hover { background: #ffc832; }
.btn-secondary {
  background: var(--muted-surface);
  color: var(--fg);
  border-color: var(--muted-surface);
}
.btn-secondary:hover { background: #ddd6cb; }
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--muted-surface); }
.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }

/* ============================================================
   Tables
   ============================================================ */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--fg);
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.is-clickable { cursor: pointer; }
.tbl tr.is-clickable:hover td { background: var(--bg); }

/* ============================================================
   Status / badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  background: var(--muted-surface);
  color: var(--fg-soft);
  border: 1px solid var(--line);
}
.badge-danger  { background: var(--danger-soft); color: var(--danger); border-color: #f0c8c8; }
.badge-warn    { background: #fdf2dc; color: #92580a; border-color: #f4d999; }
.badge-ok      { background: var(--ok-soft); color: var(--ok); border-color: #c7e6d4; }
.badge-info    { background: #e8eff3; color: var(--teal); border-color: #cfdfe6; }
.badge-gold    { background: var(--gold-soft); color: #6c4d05; border-color: var(--gold-line); }

.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot.is-red { background: var(--danger); }
.status-dot.is-amber { background: var(--warn); }
.status-dot.is-green { background: var(--ok); }

/* ============================================================
   Hero block (dashboard intent strip)
   ============================================================ */
.hero {
  background: var(--teal);
  color: var(--teal-on);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(251,189,18,0.10), transparent 60%);
  pointer-events: none;
}
.hero-eyebrow {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold); font-weight: 600; margin-bottom: 8px;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  margin: 0 0 10px;
  color: #fff;
}
.hero p { margin: 0; color: rgba(248,245,240,0.85); max-width: 720px; font-size: 13.5px; }
.hero-meta {
  display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap;
}
.hero-stat {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 130px;
}
.hero-stat-label { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.hero-stat-value { font-family: var(--font-display); font-size: 22px; color: #fff; margin-top: 4px; }
.hero-stat-sub { font-size: 11px; color: rgba(248,245,240,0.65); margin-top: 2px; }

/* ============================================================
   "Are they doing it" — accountability table
   ============================================================ */
.acct-card { border-left: 3px solid var(--danger); }
.acct-card.is-ok { border-left-color: var(--ok); }
.acct-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.acct-item:last-child { border-bottom: 0; padding-bottom: 0; }
.acct-item:first-child { padding-top: 0; }
.acct-title { font-weight: 600; color: var(--fg); font-size: 14px; }
.acct-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.acct-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--muted); }

/* Owner script (yellow callout) */
.owner-script {
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin-top: 10px;
}
.owner-script-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: #6c4d05;
  margin-bottom: 4px;
}
.owner-script-body { font-size: 13px; color: var(--teal-ink); line-height: 1.5; font-style: italic; }
.owner-script-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ============================================================
   PIP cards
   ============================================================ */
.pip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.pip-card {
  background: var(--card-2);
  border: 1px solid var(--card-line);
  border-radius: var(--r);
  padding: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
  cursor: pointer;
}
.pip-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow);
}
.pip-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.pip-card-title { font-weight: 600; color: var(--fg); font-size: 13.5px; line-height: 1.35; }
.pip-card-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.pip-card-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.pip-card-ai { border-left: 3px solid var(--gold, #C69A4B); }
.pip-card-locked { background: rgba(120, 113, 108, 0.08); }
.pip-card-locked .pip-card-head h3 { color: var(--muted); }
.pip-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.pip-badge-ai { background: #1e3a8a; color: #fff; }
.pip-badge-draft { background: #d97706; color: #fff; }
.pip-badge-locked { background: #166534; color: #fff; }

/* PIP edit modal */
.pip-edit-form { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.pip-edit-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.pip-edit-form input[type="text"], .pip-edit-form input[type="date"], .pip-edit-form textarea, .pip-edit-form select {
  font-family: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg);
}
.pip-edit-form textarea { resize: vertical; min-height: 60px; }
.edit-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit-iv { border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.edit-iv legend { font-size: 12px; font-weight: 700; padding: 0 6px; }
.edit-iv-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }

/* Survey-manager toasts */
.sm-toast-success { background: #166534; color: #fff; }
.sm-toast-error { background: #b91c1c; color: #fff; }

/* ============================================================
   Tabs (inside a page, for PIP detail etc.)
   ============================================================ */
.page-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.page-tab {
  background: transparent;
  border: 0;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.page-tab:hover { color: var(--fg); }
.page-tab.is-active {
  color: var(--teal);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

/* ============================================================
   Form / inputs
   ============================================================ */
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="search"], textarea, select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--input-line);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--fg);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus {
  outline: 0;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15,60,71,0.10);
}
textarea { resize: vertical; min-height: 80px; }
label { font-size: 12.5px; font-weight: 500; color: var(--fg); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============================================================
   Upload zone
   ============================================================ */
.upload-zone {
  background: #fff;
  border: 2px dashed var(--input-line);
  border-radius: var(--r-lg);
  padding: 28px 20px;
  text-align: center;
  transition: border-color 0.12s, background 0.12s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.is-drag {
  border-color: var(--gold);
  background: #fffbf0;
}
.upload-zone-icon {
  width: 36px; height: 36px;
  color: var(--muted-2);
  margin: 0 auto 10px;
}
.upload-zone-title { font-weight: 600; color: var(--fg); margin-bottom: 4px; font-size: 14px; }
.upload-zone-sub { font-size: 12px; color: var(--muted); }

/* ============================================================
   Meeting / agenda
   ============================================================ */
.agenda-list { list-style: none; padding: 0; margin: 0; }
.agenda-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.agenda-item:last-child { border-bottom: 0; }
.agenda-check {
  width: 18px; height: 18px;
  border: 1.5px solid var(--input-line);
  border-radius: 4px;
  cursor: pointer;
}
.agenda-check.is-done {
  background: var(--ok);
  border-color: var(--ok);
  position: relative;
}
.agenda-check.is-done::after {
  content: "✓"; color: #fff; position: absolute; top: -3px; left: 2px; font-size: 14px; font-weight: 700;
}
.agenda-text { font-size: 13.5px; }
.agenda-text.is-done { color: var(--muted-2); text-decoration: line-through; }
.agenda-owner {
  font-size: 11px;
  background: var(--muted-surface);
  color: var(--fg-soft);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 500;
}

/* ============================================================
   F-tag library
   ============================================================ */
/* Legacy .ftag-row grid styles removed — the rebuild uses <table.ftag-table> */
.ftag-tag {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: var(--teal);
}
.ftag-name { font-size: 13.5px; color: var(--fg); font-weight: 500; }
.ftag-mean { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,39,45,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-card {
  background: var(--card-2);
  border-radius: var(--r-lg);
  width: min(640px, 100%);
  max-height: 86vh;
  overflow: auto;
  border-top: 3px solid var(--gold);
  box-shadow: var(--shadow-lg);
}
.modal-card.is-wide { width: min(880px, 100%); }
.modal-head {
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.modal-head h3 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 18px; color: var(--fg); }
.modal-body { padding: 20px 22px; }
.modal-close {
  background: transparent; border: 0;
  font-size: 22px; line-height: 1; color: var(--muted);
  padding: 0; width: 28px; height: 28px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--muted-surface); color: var(--fg); }

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty h3 { font-family: var(--font-display); font-weight: 400; color: var(--fg); margin: 0 0 6px; }
.empty p { margin: 0 0 14px; font-size: 13px; }

/* ============================================================
   Misc
   ============================================================ */
.storage-banner {
  background: #fff3cd;
  border-bottom: 1px solid #f4d999;
  color: #6c4d05;
  padding: 8px 24px;
  font-size: 12.5px;
}
.save-toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--teal);
  color: var(--teal-on);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.16s;
}
.save-toast.is-visible { opacity: 1; }

.floating-tooltip {
  position: fixed;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 999;
  max-width: 280px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted-2);
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 16px;
  font-size: 13px;
}
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; color: var(--fg); }

/* Two-column layouts */
.split-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
@media (max-width: 1024px) { .split-2 { grid-template-columns: 1fr; } }

/* ============================================================
   Sidebar collapsed (mobile)
   ============================================================ */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    z-index: 100;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0;
    background: rgba(15,39,45,0.40); z-index: 50;
  }
  .app-root { padding: 18px; }
}

/* ============================================================
   Legacy shim — old route renderers still emit .page-shell markup.
   Make them look at home on the new Altura theme until rewritten.
   ============================================================ */
.page-shell { padding: 0; background: transparent; }
.page-shell-inner, .container { max-width: 1440px; }
.page-shell .page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 22px;
}
.page-shell .page-header .eyebrow { margin: 0 0 4px; }
.page-shell .page-header .page-title {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 400; letter-spacing: 0.005em;
  margin: 0 0 6px; color: var(--fg);
}
.page-shell .page-header .page-lede { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 720px; }
.page-shell .page-actions { display: flex; gap: 8px; }
.page-shell .page-actions button,
.page-shell .page-actions .button {
  background: var(--gold); color: var(--teal-ink);
  border: 1px solid var(--gold);
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  border-radius: var(--r-sm); cursor: pointer;
}

/* legacy button-primary etc. */
.button { font-family: var(--font-sans); font-weight: 500; font-size: 13px; cursor: pointer; }
.button-primary {
  background: var(--teal); color: var(--teal-on); border: 1px solid var(--teal);
  padding: 8px 14px; border-radius: var(--r-sm);
}
.button-primary:hover { background: var(--teal-2); }
.button-secondary {
  background: var(--muted-surface); color: var(--fg); border: 1px solid var(--muted-surface);
  padding: 8px 14px; border-radius: var(--r-sm);
}
.button-ghost {
  background: transparent; color: var(--fg); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: var(--r-sm);
}

/* Premium-card / facility-card / dash variants (used by many legacy files) */
.premium-card, .facility-card, .facility-card-deep,
.spend-card, .top-red-card, .acct-list > article, .dash-deep,
.empty-state-card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.premium-card h2, .premium-card h3,
.facility-card h2, .facility-card h3,
.facility-card-deep h2, .facility-card-deep h3,
.spend-card h2, .spend-card h3 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--fg);
  letter-spacing: 0.005em;
  margin: 0 0 10px;
}

.card-head-inline {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.card-head-inline h3 {
  font-family: var(--font-display); font-weight: 400; margin: 0;
  font-size: 17px; color: var(--fg);
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.facility-deep-grid, .top-red-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px;
}
.dash-hero {
  background: var(--teal); color: var(--teal-on);
  border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 18px;
}
.dash-hero .eyebrow { color: var(--gold); }
.dash-hero .hero-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: 26px; margin: 8px 0 8px; color: #fff;
}
.dash-hero .hero-copy { color: rgba(248,245,240,0.85); margin: 0; max-width: 720px; font-size: 13.5px; }

.spend-table, .tbl-legacy { width: 100%; border-collapse: collapse; font-size: 13px; }
.spend-table th, .tbl-legacy th {
  text-align: left; font-size: 11px; font-weight: 600;
  letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted-2);
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.spend-table td, .tbl-legacy td {
  padding: 12px; border-bottom: 1px solid var(--line-soft);
  color: var(--fg);
}

.facility-tabs, .facility-tab-row {
  display: flex; gap: 4px; padding: 3px;
  background: var(--muted-surface); border-radius: 8px;
  width: fit-content; margin-bottom: 18px;
}
.facility-tab {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 14px; font-size: 12.5px; font-weight: 500;
  border-radius: 6px; cursor: pointer;
}
.facility-tab.is-active {
  background: var(--gold); color: var(--teal-ink); font-weight: 600;
}

.status-dot.status-red { background: var(--danger); }
.status-dot.status-yellow { background: var(--warn); }
.status-dot.status-green { background: var(--ok); }
.acct-pill {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.acct-pill.acct-red { background: var(--danger-soft); color: var(--danger); }
.acct-pill.acct-yellow { background: #fdf2dc; color: #92580a; }
.acct-pill.acct-green { background: var(--ok-soft); color: var(--ok); }

.risk-score-block { text-align: right; }
.risk-score {
  font-family: var(--font-display);
  font-size: 28px; color: var(--fg);
}
.risk-band-label { font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--muted-2); }
.sff-alert {
  background: var(--danger-soft); border: 1px solid #f0c8c8;
  color: var(--danger); padding: 6px 10px; border-radius: 6px;
  font-size: 12px; margin: 10px 0;
}
.dash-stats-row {
  display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0;
  font-size: 12.5px; color: var(--muted);
}
.dash-stats-row strong { display: block; color: var(--fg); font-size: 16px; }
.dash-stats-row .is-bad { color: var(--danger); }
.acct-summary { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0 14px; }
.acct-tone { font-size: 12px; color: var(--muted); }
.facility-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* knowledge / library / qapi modules generally use these */
.knowledge-grid, .qapi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px;
}

.empty-state-card { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state-card h3 { font-family: var(--font-display); color: var(--fg); font-weight: 400; }
.empty-state-icon { font-size: 32px; color: var(--muted-2); margin-bottom: 8px; }

/* ============================================================
   REBUILD PASS — pages added by rebuild.js
   ============================================================ */

/* Tighter app padding — page felt airy/strange */
.app-root { padding: 20px 24px 48px; max-width: 1380px; }
.page-head { margin-bottom: 18px; }
.page-title { font-size: 26px; margin: 0 0 6px; }
.card { padding: 18px 18px; margin-bottom: 14px; }
.card > h2, .card > .card-head h2, .card-head-inline h2 { font-size: 15px; margin-bottom: 12px; }
.card-head-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head-inline h2, .card-head-inline h3 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0;
  letter-spacing: 0.01em;
  font-weight: 400;
  color: var(--fg);
  display: inline-flex; align-items: center; gap: 8px;
}
.card-head-inline h3 { font-size: 13.5px; }

/* Drop zone v2 — proper, professional drop affordance */
.upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.upload-row.single { grid-template-columns: 1fr; }
.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.drop-zone-v2 {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card);
  border: 1.5px dashed #c9bfb0;
  border-radius: var(--r-lg);
  padding: 18px 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  min-height: 100px;
}
.drop-zone-v2:hover {
  border-color: var(--gold);
  background: #fffdf5;
  box-shadow: 0 1px 0 rgba(15,60,71,0.04);
}
.drop-zone-v2.has-file {
  border-style: solid;
  border-color: #c9c0b1;
  background: var(--card);
}
.drop-zone-v2 .dz-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--muted-surface);
  color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.drop-zone-v2.has-file .dz-icon { background: var(--gold-soft); color: var(--teal); }
.dz-main { flex: 1; min-width: 0; }
.dz-title { font-weight: 600; font-size: 14px; color: var(--fg); margin-bottom: 3px; }
.dz-help { margin-bottom: 6px; }
.dz-cta {
  color: var(--teal);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
}
.dz-file { font-size: 12.5px; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.dz-file .dot.ok { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

/* ---- Weekly calendar (Clinical Week) ---- */
.week-cal-card .card-head-inline svg { color: var(--teal); }
.week-cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.wk-col {
  background: #fdfbf6;
  border: 1px solid var(--card-line);
  border-radius: var(--r-md);
  min-height: 150px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.wk-col.is-today { border-color: var(--gold); background: #fffbe9; box-shadow: 0 0 0 1px var(--gold) inset; }
.wk-col-head {
  display: flex; align-items: baseline; gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--card-line);
  background: var(--card);
}
.wk-dow { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); font-weight: 600; }
.wk-day { font-family: var(--font-display); font-size: 15px; color: var(--fg); }
.wk-today-pill { margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: 0.1em; background: var(--gold); color: var(--teal-ink); padding: 1px 6px; border-radius: 10px; }
.wk-col-body { padding: 6px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.wk-empty { color: var(--muted-2); font-size: 12px; text-align: center; padding: 12px 0; }
.wk-mtg {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.wk-mtg:hover { border-color: var(--gold); background: #fffdf5; }
.wk-mtg-time { font-size: 10.5px; font-weight: 600; color: var(--teal); margin-bottom: 1px; }
.wk-mtg-title { font-size: 11.5px; color: var(--fg); line-height: 1.3; }

/* Today meeting list */
.today-mtg-list { display: flex; flex-direction: column; gap: 8px; }
.today-mtg-row {
  display: grid; grid-template-columns: 70px 1fr auto auto; gap: 14px; align-items: center;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  text-align: left;
}
.today-mtg-row:hover { border-color: var(--gold); background: #fffdf5; }
.tmr-time { font-family: var(--font-display); font-size: 16px; color: var(--teal); }
.tmr-title { font-weight: 600; font-size: 13.5px; color: var(--fg); }
.tmr-cadence { font-size: 11.5px; margin-top: 2px; }
.tmr-attendees { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tmr-cta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--teal); font-weight: 500; }

/* Meeting templates grid */
.mt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.mt-card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.mt-card-head .eyebrow { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 2px; font-weight: 600; }
.mt-card-head h3 { font-family: var(--font-display); font-size: 14.5px; margin: 0; font-weight: 400; color: var(--fg); }
.mt-attendees { line-height: 1.45; }

/* ---- AI summary card (Daily Standup) ---- */
.ai-summary-card .card-head-inline svg { color: var(--gold); }
.ai-sum-block { padding: 10px 0; border-bottom: 1px solid var(--card-line); }
.ai-sum-block:last-child { border-bottom: 0; }
.ai-sum-block-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.ai-sum-block-head strong { font-size: 13px; color: var(--fg); }
.ai-sum-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--fg); line-height: 1.55; }
.ai-sum-list li { margin-bottom: 3px; }

/* Workflow card */
.workflow-card { background: #fdfbf6; }
.workflow-steps { margin: 0; padding-left: 20px; font-size: 13px; color: var(--fg); line-height: 1.6; }
.workflow-steps li { margin-bottom: 4px; }
.bullet-list { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.6; }
.bullet-list li { margin-bottom: 3px; }

/* Empty card */
.empty-card { padding: 18px; text-align: center; }
.empty-card-inline { padding: 14px; background: #fdfbf6; border-radius: 8px; border: 1px dashed var(--card-line); margin: 8px 0; text-align: center; }

/* Glance stats */
.glance-card { padding: 14px 18px; }
.glance-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.gs { display: flex; flex-direction: column; gap: 2px; }
.gs-num { font-family: var(--font-display); font-size: 26px; color: var(--teal); line-height: 1; }
.gs-lbl { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

/* ---- Hall Audit cards + table ---- */
.hall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.hall-card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--r-md);
  padding: 14px;
}
.hall-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.hall-card-head h3 { font-family: var(--font-display); font-size: 16px; margin: 0; font-weight: 400; color: var(--fg); }
.hall-card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.ha-detail { display: flex; flex-direction: column; gap: 14px; max-height: 78vh; }
.ha-detail-head h2 { font-family: var(--font-display); font-size: 18px; margin: 4px 0; font-weight: 400; }
.ha-table-wrap { overflow: auto; border: 1px solid var(--card-line); border-radius: 8px; max-height: 60vh; }
.ha-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ha-table th { background: #fdfbf6; padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--card-line); font-weight: 600; font-size: 10.5px; letter-spacing: 0.04em; }
.ha-table th.ha-col { writing-mode: vertical-rl; transform: rotate(180deg); height: 130px; padding: 6px 4px; font-weight: 500; vertical-align: bottom; }
.ha-table td { padding: 8px 6px; border-bottom: 1px solid var(--card-line); vertical-align: middle; }
.ha-table .ha-cell { text-align: center; padding: 4px 2px; }
.ha-tri {
  width: 24px; height: 24px;
  border-radius: 4px;
  border: 1px solid var(--card-line);
  background: var(--card);
  font-size: 13px; font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  margin: 0 1px;
  line-height: 1;
}
.ha-tri:hover { border-color: var(--teal); }
.ha-tri.is-pass { background: rgba(46,125,95,0.15); color: var(--ok); border-color: var(--ok); }
.ha-tri.is-fail { background: rgba(195,48,53,0.15); color: var(--danger); border-color: var(--danger); }
.ha-note { width: 100%; font-size: 12px; padding: 4px 6px; border: 1px solid var(--card-line); border-radius: 4px; }
.ha-detail-foot { display: flex; gap: 8px; justify-content: flex-end; }

/* ---- KPI row ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card {
  background: var(--card); border: 1px solid var(--card-line); border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-num { font-family: var(--font-display); font-size: 26px; color: var(--teal); line-height: 1; font-weight: 400; }
.kpi-lbl { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

/* ---- Modern PIP cards ---- */
.pip-modern-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.pip-modern-card {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.pip-modern-card:hover { border-color: var(--teal); box-shadow: 0 1px 0 rgba(15,60,71,0.04); }
.pip-modern-tag-row { display: flex; gap: 6px; align-items: center; }
.pip-tag-chip {
  background: var(--teal); color: var(--teal-on);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 7px; border-radius: 4px;
}
.pip-status-chip {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.1em;
  padding: 2px 7px; border-radius: 3px; text-transform: uppercase;
}
.pip-status-chip.is-active { background: var(--gold-soft); color: var(--warn); border: 1px solid #f0d28a; }
.pip-status-chip.is-other { background: #eee; color: var(--muted); }
.pip-modern-title { font-family: var(--font-display); font-size: 16px; margin: 0; font-weight: 400; color: var(--fg); line-height: 1.25; }
.pip-modern-problem { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0; }
.pip-modern-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--card-line);
  border-bottom: 1px solid var(--card-line);
}
.pip-modern-stats > div { display: flex; flex-direction: column; gap: 1px; align-items: center; }
.ps-num { font-family: var(--font-display); font-size: 18px; color: var(--teal); }
.ps-lbl { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }

/* ---- PIP detail (modal) — tabs ---- */
.pip-detail { display: flex; flex-direction: column; gap: 14px; max-height: 78vh; }
.pip-detail-head h2 { font-family: var(--font-display); font-size: 20px; margin: 4px 0; font-weight: 400; }
.pip-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--card-line); }
.pip-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.pip-tab:hover { color: var(--fg); }
.pip-tab.is-active { color: var(--teal); border-bottom-color: var(--gold); }
.pip-tab-bodies { flex: 1; overflow-y: auto; padding: 4px 2px; }
.pip-tab-body { display: block; }
.pip-tab-body.hidden { display: none; }
.pip-section { margin-bottom: 18px; }
.pip-section h4 { font-family: var(--font-display); font-size: 13.5px; margin: 0 0 6px; font-weight: 500; color: var(--fg); text-transform: uppercase; letter-spacing: 0.05em; }
.pip-section p { font-size: 13px; color: var(--fg); line-height: 1.55; margin: 0 0 6px; }
.root-cause-list { margin: 0; padding-left: 20px; font-size: 13px; color: var(--fg); line-height: 1.6; }
.root-cause-list li { margin-bottom: 3px; }
.row-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row-actions input { padding: 6px 8px; border: 1px solid var(--card-line); border-radius: 4px; font-size: 12.5px; }
.closure-list { list-style: none; padding: 0; margin: 0; }
.closure-list li { padding: 6px 0; font-size: 13px; }

/* ---- Heat map ---- */
.heat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.heat-cell {
  border: 1px solid rgba(195,48,53,0.3);
  border-radius: var(--r-md);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  transition: transform 0.12s;
}
.heat-cell:hover { transform: translateY(-1px); }
.heat-tag { font-family: var(--font-display); font-size: 15px; color: var(--danger); font-weight: 600; }
.heat-count { font-size: 12px; font-weight: 600; color: var(--fg); }
.heat-name { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

/* ---- F-tag library rows ---- */
.ftag-table tr.ftag-row { cursor: pointer; transition: background 0.1s; }
.ftag-table tr.ftag-row:hover { background: #fffdf5; }
.link-text { color: var(--teal); font-weight: 500; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }
.link-button { background: transparent; border: 0; color: var(--teal); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; }
.link-button:hover { text-decoration: underline; }
.head-search {
  padding: 7px 12px;
  border: 1px solid var(--card-line);
  border-radius: 6px;
  font-size: 13px;
  width: 280px;
  max-width: 280px;
  background: var(--card);
}
.page-head .head-actions input.head-search { flex: 0 0 280px; }

/* Generic data table — used across rebuild routes */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table thead th {
  text-align: left; font-weight: 600; color: var(--muted-2);
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 8px 10px; border-bottom: 1px solid var(--card-line);
}
table.data-table tbody td {
  padding: 9px 10px; border-bottom: 1px solid #f2ece1; vertical-align: top;
  color: var(--fg);
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #fffdf5; }

/* F-tag table column hygiene */
.ftag-table { table-layout: fixed; width: 100%; }
.ftag-table th, .ftag-table td { vertical-align: top; padding: 10px 12px; }
.ftag-table td.muted { color: var(--muted); }
.ftag-table .link-text { color: var(--teal); font-size: 12.5px; white-space: nowrap; }

/* ---- Alert card (Direct Supply reality) ---- */
.alert-card { background: #fdfbf6; border-left: 3px solid var(--gold); }

/* ---- Daily Brief font fix (admin-portal renderer) ---- */
.ai-brief-panel { padding: 16px 18px; }
.ai-brief-panel h3 { font-family: var(--font-display); font-size: 15px; font-weight: 400; margin: 0; }
.ai-brief-body { margin-top: 10px; }
.ai-brief-body .brief-loading { font-size: 13px; color: var(--muted); font-style: italic; }
.ai-brief-text {
  font-family: var(--font-body) !important;
  font-size: 13px;
  color: var(--fg);
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
  padding: 12px 14px;
  background: var(--muted-surface);
  border-radius: 8px;
  border-left: 3px solid var(--gold);
}

/* ---- Form stack (used in QAPI new-PIP modal) ---- */
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-stack label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.form-stack label input { padding: 8px 10px; border: 1px solid var(--card-line); border-radius: 6px; font-size: 13px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.import-result h3 { font-family: var(--font-display); font-size: 17px; margin: 4px 0 8px; font-weight: 400; }

/* ---- Badge tones used by rebuild ---- */
.badge-ok { background: rgba(46,125,95,0.12); color: var(--ok); border: 1px solid rgba(46,125,95,0.25); }
.badge-warn { background: rgba(209,132,25,0.12); color: var(--warn); border: 1px solid rgba(209,132,25,0.3); }
.badge-danger { background: rgba(195,48,53,0.12); color: var(--danger); border: 1px solid rgba(195,48,53,0.3); }
.badge-info { background: rgba(15,60,71,0.10); color: var(--teal); border: 1px solid rgba(15,60,71,0.2); }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 10px; }

/* ---- Make sure modal card never traps clicks (safety net) ---- */
.modal-card input,
.modal-card textarea,
.modal-card select,
.modal-card button { pointer-events: auto; }

/* Mobile: hide vertical text on hall audit columns */
@media (max-width: 720px) {
  .ha-table th.ha-col { writing-mode: horizontal-tb; transform: none; height: auto; }
  .upload-row { grid-template-columns: 1fr; }
  .week-cal { grid-template-columns: repeat(7, minmax(80px, 1fr)); overflow-x: auto; }
}

/* ============================================================
   QAPI ENGINE — sub-tabs, glance cards, packet preview
   ============================================================ */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 20px;
  padding: 4px;
  background: var(--surface-sunken, #f3f1ec);
  border-radius: 10px;
  width: fit-content;
}
.sub-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--text-muted, #6b6760);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  background: transparent;
}
.sub-tab:hover { color: var(--text, #2a2823); background: rgba(0,0,0,0.04); }
.sub-tab.is-active {
  background: var(--surface, #fff);
  color: var(--text, #2a2823);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* QAPI glance grid */
.qapi-glance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.qapi-glance-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e8e4dc);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text, #2a2823);
  transition: all 0.15s;
}
.qapi-glance-card:not(.is-static):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: var(--accent, #fbbd12);
}
.qapi-glance-card .qg-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #6b6760);
  font-weight: 600;
}
.qapi-glance-card .qg-num {
  font-size: 32px;
  font-weight: 700;
  font-family: 'Tenor Sans', serif;
  letter-spacing: -0.01em;
  line-height: 1;
}
.qapi-glance-card .qg-lbl { color: var(--text-muted, #6b6760); font-size: 13px; }
.qapi-glance-card .qg-cta {
  margin-top: 4px;
  color: var(--accent-strong, #b8870c);
  font-size: 13px;
  font-weight: 500;
}
.qapi-glance-card.is-static { background: var(--surface-sunken, #faf8f3); }

/* QAPI flow steps */
.qapi-flow {
  margin: 8px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text, #2a2823);
}
.qapi-flow li { line-height: 1.55; }

/* Progress mini bar */
.progress-mini {
  width: 120px;
  height: 6px;
  background: var(--surface-sunken, #f3f1ec);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-mini-fill {
  height: 100%;
  background: var(--accent, #fbbd12);
  transition: width 0.3s ease;
}

/* QAPI packet preview */
.qapi-packet-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.packet-section {
  border: 1px solid var(--border, #e8e4dc);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface, #fff);
}
.packet-section.is-submitted {
  border-color: #c8e6c9;
  background: linear-gradient(to bottom right, #f7fbf7, #fff);
}
.packet-section.is-pending { background: var(--surface-sunken, #faf8f3); }
.packet-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border, #e8e4dc);
}
.packet-section-head h3 { margin: 2px 0; font-size: 17px; }
.packet-section-head .eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted, #6b6760);
  font-weight: 600;
}
.packet-content {
  line-height: 1.55;
  white-space: pre-wrap;
  font-size: 14px;
}
.packet-auto ul {
  margin: 8px 0;
  padding-left: 18px;
  font-size: 13px;
}
.packet-auto li { margin: 3px 0; color: var(--text-muted, #6b6760); }

/* Section title in admin table */
.section-title { font-weight: 600; }

/* Row layout helpers used in QAPI */
.row-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0;
}
textarea.full {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #e8e4dc);
  resize: vertical;
  line-height: 1.5;
}
textarea.full:focus {
  outline: none;
  border-color: var(--accent, #fbbd12);
  box-shadow: 0 0 0 3px rgba(251, 189, 18, 0.12);
}

/* QAPI auto list */
.qapi-auto-list {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.6;
}
.qapi-auto-list li { color: var(--text, #2a2823); margin: 4px 0; }

/* Badges - additional variants */
.badge-danger {
  background: #fdecec;
  color: #b3261e;
  border-color: #f5c6c6;
}
.badge-muted {
  background: var(--surface-sunken, #f3f1ec);
  color: var(--text-muted, #6b6760);
  border-color: var(--border, #e8e4dc);
}

/* Print-friendly export */
@media print {
  .sidebar, .facility-tabs, .page-head .head-actions, .sub-tabs,
  .row-actions, .button { display: none !important; }
  .main, .shell { overflow: visible !important; height: auto !important; }
  .card { break-inside: avoid; page-break-inside: avoid; }
}

/* ============================================================
   Financials module
   ============================================================ */
.fin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e8e4dc);
  border-radius: 12px;
  margin-bottom: 16px;
}
.fin-filters { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.fin-filters label { display: flex; flex-direction: column; font-size: 11px; color: var(--text-muted, #6b6760); font-weight: 500; gap: 4px; }
.fin-filters select { padding: 7px 10px; border: 1px solid var(--border, #e8e4dc); border-radius: 8px; background: #fff; font-size: 13px; min-width: 180px; }
.fin-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.fin-tab {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted, #6b6760);
  font-weight: 500;
  transition: all 0.15s;
}
.fin-tab:hover { background: var(--surface-sunken, #f5f3ee); color: var(--text, #28251d); }
.fin-tab.is-active {
  background: var(--surface-sunken, #f5f3ee);
  border-color: var(--border, #e8e4dc);
  color: var(--text, #28251d);
}

.fin-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.fin-tile {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e8e4dc);
  border-radius: 12px;
  padding: 16px 18px;
}
.fin-tile-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted, #6b6760); letter-spacing: 0.05em; font-weight: 600; }
.fin-tile-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text, #28251d);
  font-variant-numeric: tabular-nums;
}
.fin-tile-sub { font-size: 12px; margin-top: 4px; }

.delta-pos { color: #437A22; font-weight: 600; }
.delta-neg { color: #A12C7B; font-weight: 600; }
.delta-flat { color: var(--text-muted, #6b6760); }

.fin-chart-wrap { position: relative; height: 320px; padding: 8px 0; }

.fin-tbl { font-size: 13px; }
.fin-tbl th, .fin-tbl td { vertical-align: top; }
.fin-tbl td.num, .fin-tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fin-tbl .small { font-size: 11px; }
.fin-tbl .muted { color: var(--text-muted, #6b6760); }

.fin-bar { background: var(--surface-sunken, #f5f3ee); height: 6px; border-radius: 3px; overflow: hidden; min-width: 80px; }
.fin-bar-fill { background: #20808D; height: 100%; border-radius: 3px; }

/* ============================================================
   Financials v2 — new component styles
   ============================================================ */

/* Insights panel */
.fin-insights-panel {
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.fin-insights-toggle { cursor: pointer; }
.fin-insight-card[data-severity="high"] { border-left-color: #c33035 !important; }
.fin-insight-card[data-severity="med"]  { border-left-color: #d18419 !important; }
.fin-insight-card[data-severity="low"]  { border-left-color: #2e7d5f !important; }

/* Drill drawer */
.fin-drill-drawer { position: fixed; inset: 0; z-index: 1200; pointer-events: none; }
.fin-drill-drawer.is-open { pointer-events: all; }
.fin-drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(15,39,45,0.3);
  opacity: 0;
  transition: opacity 0.2s;
}
.fin-drill-drawer.is-open .fin-drawer-overlay { opacity: 1; }
.fin-drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 580px; max-width: 96vw;
  background: var(--card-2);
  box-shadow: -4px 0 32px rgba(15,39,45,0.12);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.fin-drill-drawer.is-open .fin-drawer-panel { transform: translateX(0); }
.fin-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-line);
  flex-shrink: 0;
}
.fin-drawer-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--muted); padding: 0 4px; line-height: 1;
}
.fin-drawer-body {
  flex: 1; overflow-y: auto; padding: 16px 20px;
}

/* AI Chat panel */
.fin-chat-panel {
  position: fixed; right: 0; bottom: 0; top: var(--topbar-h);
  width: 360px;
  background: var(--card-2);
  border-left: 1px solid var(--card-line);
  box-shadow: -4px 0 20px rgba(15,39,45,0.08);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 900;
}
.fin-chat-panel.is-open { transform: translateX(0); }
.fin-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-line);
  flex-shrink: 0;
}
.fin-chat-toggle { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.fin-chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.fin-chat-bubble {
  padding: 8px 12px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.5;
  max-width: 90%;
}
.fin-chat-user {
  background: var(--teal); color: var(--teal-on);
  align-self: flex-end;
  border-radius: 8px 8px 2px 8px;
}
.fin-chat-ai {
  background: var(--muted-surface);
  align-self: flex-start;
  border-radius: 8px 8px 8px 2px;
}
.fin-chat-suggestions { display: flex; flex-direction: column; gap: 6px; }
.fin-chat-sugg {
  background: none; border: 1px solid var(--card-line);
  border-radius: 6px; padding: 6px 10px;
  font-size: 12px; cursor: pointer; text-align: left;
  color: var(--teal);
  transition: background 0.15s;
}
.fin-chat-sugg:hover { background: var(--muted-surface); }
.fin-chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--card-line); flex-shrink: 0;
}
.fin-chat-input {
  flex: 1; padding: 8px 10px;
  border: 1px solid var(--input-line); border-radius: 6px;
  font-size: 13px; font-family: var(--font-sans);
}
.fin-chat-send {
  background: var(--teal); color: var(--teal-on);
  border: none; border-radius: 6px; padding: 8px 14px;
  font-size: 13px; cursor: pointer;
}
.fin-chat-fab {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--teal); color: var(--teal-on);
  border: none; border-radius: 24px; padding: 10px 18px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-lg); z-index: 899;
  display: flex; align-items: center; gap: 6px;
  transition: transform 0.15s;
}
.fin-chat-fab:hover { transform: translateY(-2px); }

/* Sortable table */
.fin-table-sortable-wrap { }
.fin-table-sortable-scroll { overflow-x: auto; }
.fin-table-sortable { width: 100%; border-collapse: collapse; }
.fin-table-sortable thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.fin-st-th:hover { background: var(--muted-surface) !important; }
.fin-table-totals {
  font-weight: 700;
  border-top: 2px solid var(--line);
}
.fin-totals-row td { font-weight: 700; border-top: 2px solid var(--line); padding-top: 8px !important; }
.fin-search-bar {
  font-family: var(--font-sans);
}
.fin-col-filter-input { font-family: var(--font-sans); }
.fin-filter-row td { background: var(--muted-surface); }

/* KPI Tiles v2 */
.fin-tile-clickable { cursor: pointer; transition: box-shadow 0.15s, transform 0.1s; }
.fin-tile-clickable:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.fin-tile-census { background: linear-gradient(135deg, #f7f5f1, #e6f2f3) !important; }

/* Unit economics */
.fin-unit-econ-grid { font-size: 12px; }

/* Correlation heatmap */
.fin-correlation-heatmap { overflow-x: auto; }

/* Upload zone */
.fin-upload-zone {
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  padding: 32px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px;
}
.fin-upload-zone.drag-over {
  border-color: var(--teal);
  background: var(--muted-surface);
}

/* Variance table */
.fin-var-row:hover { background: var(--muted-surface); }

/* Delta */
.delta-pos { color: #2e7d5f; }
.delta-neg { color: #c33035; }
.delta-flat { color: var(--muted); }

/* ---- QAPI Engine — AI Systemic Suggestions ---- */
.qapi-systemic-panel {
  background: linear-gradient(135deg, #f4f9f7 0%, #f7f4ef 100%);
  border: 1px solid #d8e6e0;
  border-left: 4px solid #0f766e;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.qapi-systemic-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.qapi-systemic-head h3 {
  margin: 0 0 2px;
  font-size: 1.05rem;
  color: #0f766e;
}
.qapi-systemic-head p { margin: 0; }
.qapi-systemic-head-actions { display: flex; gap: 6px; }
.qapi-systemic-headline {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 6px 0 4px;
  color: var(--text, #1f2a37);
}
.qapi-systemic-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; color: #555;
}
.qapi-systemic-loading .spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #cbd5e1; border-top-color: #0f766e;
  animation: qapi-spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes qapi-spin { to { transform: rotate(360deg); } }
.qapi-systemic-error {
  background: #fef2f2; border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: 8px; color: #991b1b;
}
.qapi-systemic-error p { margin: 0 0 6px; }
.systemic-issue-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px; margin-top: 10px;
}
.systemic-issue-card {
  background: #fff; border: 1px solid #e5ebe9; border-left: 3px solid #0f766e;
  border-radius: 10px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.systemic-issue-card.priority-high { border-left-color: #c33035; }
.systemic-issue-card.priority-medium { border-left-color: #d97706; }
.systemic-issue-card.priority-low { border-left-color: #6b7280; }
.systemic-issue-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
}
.systemic-issue-head h4 {
  margin: 0; font-size: 0.98rem; line-height: 1.3; color: #1f2a37;
}
.systemic-priority {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; background: #f1f5f4; color: #4b5563;
  white-space: nowrap; flex-shrink: 0;
}
.priority-high .systemic-priority { background: #fee2e2; color: #991b1b; }
.priority-medium .systemic-priority { background: #fef3c7; color: #92400e; }
.priority-low .systemic-priority { background: #f3f4f6; color: #4b5563; }
.systemic-issue-meta {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  font-size: 0.78rem;
}
.systemic-ftag {
  background: #eef2ff; color: #3730a3;
  padding: 1px 6px; border-radius: 4px; font-weight: 600;
  font-size: 0.72rem; margin-right: 4px;
}
.trend-escalating { color: #c33035 !important; }
.trend-improving { color: #2e7d5f !important; }
.trend-stable { color: #6b7280 !important; }
.systemic-rootcause, .systemic-focus {
  font-size: 0.85rem; line-height: 1.4; margin: 0; color: #374151;
}
.systemic-rootcause strong, .systemic-focus strong { color: #0f766e; }
.systemic-samples summary {
  cursor: pointer; font-size: 0.82rem; color: #0f766e; font-weight: 500;
}
.systemic-samples ul {
  margin: 6px 0 0 18px; padding: 0; font-size: 0.82rem; color: #4b5563;
}
.systemic-samples li { margin-bottom: 4px; }
.systemic-actions {
  margin-top: 4px; display: flex; justify-content: flex-end;
}
.qapi-quick-wins {
  margin-top: 14px; background: #fff; border: 1px solid #e5ebe9;
  border-radius: 8px; padding: 8px 12px;
}
.qapi-quick-wins summary {
  cursor: pointer; font-weight: 600; color: #0f766e;
}
.qapi-quick-wins ul {
  margin: 8px 0 0 18px; padding: 0; font-size: 0.88rem;
}
.qapi-quick-wins li { margin-bottom: 4px; color: #374151; }

/* ---- QAPI Engine v2 — rebuild.js port additions ---- */
.systemic-issue-title {
  margin: 0; font-size: 1.0rem; line-height: 1.3; color: #1f2a37;
}
.priority-chip {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; background: #f1f5f4; color: #4b5563;
  white-space: nowrap; font-weight: 600;
}
.priority-high .priority-chip { background: #fee2e2; color: #991b1b; }
.priority-medium .priority-chip { background: #fef3c7; color: #92400e; }
.priority-low .priority-chip { background: #f3f4f6; color: #4b5563; }
.trend-chip {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
  background: #f1f5f9; color: #475569; font-weight: 600;
}
.trend-chip.trend-escalating { background: #fee2e2; color: #b91c1c; }
.trend-chip.trend-improving { background: #dcfce7; color: #15803d; }
.trend-chip.trend-stable, .trend-chip.trend-flat { background: #f1f5f9; color: #475569; }
.ftag-chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.ftag-chip {
  background: #eef2ff; color: #3730a3;
  padding: 1px 6px; border-radius: 4px; font-weight: 600;
  font-size: 0.72rem;
}
.systemic-root, .systemic-focus {
  font-size: 0.85rem; line-height: 1.4; margin: 0; color: #374151;
}
.systemic-root strong, .systemic-focus strong { color: #0f766e; }
.systemic-observations summary {
  cursor: pointer; font-size: 0.82rem; color: #0f766e; font-weight: 500;
}
.systemic-observations ul {
  margin: 6px 0 0 18px; padding: 0; font-size: 0.82rem; color: #4b5563;
}
.systemic-observations li { margin-bottom: 4px; }
.systemic-issue-actions {
  margin-top: 4px; display: flex; justify-content: flex-end;
}
.systemic-exec-summary {
  background: #fff; border: 1px solid #e5ebe9;
  border-left: 3px solid #0f766e;
  border-radius: 8px; padding: 10px 14px;
  margin: 8px 0 4px; font-size: 0.92rem; line-height: 1.5; color: #1f2a37;
}
.systemic-exec-summary strong { color: #0f766e; }

/* QAPI PIP edit modal */
.qapi-pip-edit-form { display: flex; flex-direction: column; gap: 12px; }
.qapi-pip-edit-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.82rem; font-weight: 600; color: #374151;
}
.qapi-pip-edit-form label input,
.qapi-pip-edit-form label textarea,
.qapi-pip-edit-form label select {
  font-weight: 400; font-size: 0.92rem;
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font-family: inherit;
}
.qapi-pip-edit-form textarea { resize: vertical; min-height: 60px; }
.form-row-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.qapi-iv-list { display: flex; flex-direction: column; gap: 6px; }
.qapi-iv-row {
  display: grid;
  grid-template-columns: 2fr 1fr 130px 32px;
  gap: 6px; align-items: center;
}
.qapi-iv-row input, .qapi-iv-row select {
  padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 5px;
  font-size: 0.88rem; font-family: inherit;
}

/* AI Draft / Locked badges on PIP cards */
.pip-modern-card.is-locked {
  background: #fafaf6; border-color: #d4d4aa;
}
.pip-modern-tag-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ============================================================
   Dashboard v3 — Simplified KPI view (mobile-first, polished)
   ============================================================ */

/* Section eyebrows */
.dash-section-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: #64748b; font-weight: 700;
}
.dash-section-hint {
  font-size: 11px; color: #94a3b8; font-weight: 500;
}

/* Upload reminders strip — compact rows on mobile, grid on desktop */
.dash-upload-strip {
  background: #fff;
  border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 14px; margin: 12px 0 18px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.dash-upload-strip-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 10px; padding: 0 2px;
}
.dash-upload-grid {
  display: grid; gap: 8px;
  grid-template-columns: 1fr; /* mobile: stacked rows */
}
@media (min-width: 640px) { .dash-upload-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .dash-upload-grid { grid-template-columns: repeat(4, 1fr); } }

.dash-up {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0;
  background: #fff; border-radius: 10px; cursor: pointer;
  text-align: left; transition: all .15s ease;
  font-family: inherit;
}
.dash-up:hover, .dash-up:active {
  border-color: #94a3b8; background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(15,23,42,.06);
}
.dash-up-icon {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.dash-up-icon svg { width: 18px; height: 18px; }
.dash-up-body { flex: 1; min-width: 0; }
.dash-up-label {
  font-size: 14px; font-weight: 700; color: #0f172a; line-height: 1.2;
}
.dash-up-sub {
  font-size: 11.5px; color: #64748b; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-up-status {
  flex-shrink: 0; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  padding: 4px 8px; border-radius: 999px; line-height: 1;
}
.dash-up-green { background: #dcfce7; color: #15803d; }
.dash-up-amber { background: #fef3c7; color: #b45309; }
.dash-up-red   { background: #fee2e2; color: #b91c1c; }

/* CEO daily action recommendation */
.dash-today-move {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #fff;
  border: 1px solid #e2e8f0; border-left: 4px solid #2563eb; border-radius: 14px;
  padding: 16px 18px; margin: 0 0 18px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
}
.dash-today-move[data-tone="red"] { border-left-color: #dc2626; }
.dash-today-move[data-tone="amber"] { border-left-color: #d97706; }
.dash-today-move[data-tone="green"] { border-left-color: #16a34a; }
.dash-today-main { min-width: 0; }
.dash-today-main h2 {
  margin: 4px 0 6px; color: #0f172a; font-size: 20px; line-height: 1.15;
  letter-spacing: 0; font-weight: 800;
}
.dash-today-main p {
  margin: 0; color: #334155; font-size: 14px; line-height: 1.45;
}
.dash-today-why {
  margin-top: 8px; color: #64748b; font-size: 12px; line-height: 1.35;
}
.dash-today-btn {
  flex: 0 0 auto; white-space: nowrap;
}
@media (max-width: 720px) {
  .dash-today-move { align-items: stretch; flex-direction: column; gap: 12px; }
  .dash-today-btn { width: 100%; }
  .dash-today-main h2 { font-size: 18px; }
}

/* Survey launch guide */
.dash-survey-guide {
  margin: 14px 0 16px;
  background: #fff;
  border: 1px solid #dbeafe;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}
.dash-survey-guide-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.dash-survey-guide-head h2 {
  margin: 3px 0 5px;
  font-size: 20px;
  line-height: 1.2;
  color: #0f172a;
}
.dash-survey-guide-head p {
  margin: 0;
  max-width: 780px;
  color: #475569;
  font-size: 13.5px;
  line-height: 1.5;
}
.dash-survey-guide-grid {
  display: grid;
  gap: 10px;
}
@media (min-width: 860px) {
  .dash-survey-guide-grid { grid-template-columns: repeat(4, 1fr); }
}
.dash-survey-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
  min-height: 132px;
}
.dash-survey-step:hover,
.dash-survey-step:focus-visible {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
}
.dash-survey-step-num {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.dash-survey-step-body {
  min-width: 0;
  display: grid;
  gap: 5px;
}
.dash-survey-step-body strong {
  color: #0f172a;
  font-size: 13.5px;
  line-height: 1.25;
}
.dash-survey-step-body span {
  color: #475569;
  font-size: 12.5px;
  line-height: 1.4;
}
.dash-survey-step-body em {
  color: #1d4ed8;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}
@media (max-width: 720px) {
  .dash-survey-guide-head { flex-direction: column; }
  .dash-survey-guide-head .button { width: 100%; }
  .dash-survey-step { min-height: 0; }
}

/* KPI tiles grid */
.dash-grid {
  display: grid; gap: 12px;
  grid-template-columns: 1fr; /* mobile: 1 col */
  margin-top: 4px;
}
@media (min-width: 720px) { .dash-grid { grid-template-columns: 1fr 1fr; gap: 16px; } }

.dash-tile {
  position: relative;
  background: #fff;
  border: 1px solid #e2e8f0; border-radius: 14px;
  padding: 16px 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  overflow: hidden;
}
.dash-tile.dash-skel { padding: 14px; }
.dash-tile-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.dash-tile-payroll    .dash-tile-accent { background: linear-gradient(90deg, #16a34a, #22c55e); }
.dash-tile-financials .dash-tile-accent { background: linear-gradient(90deg, #db2777, #ec4899); }
.dash-tile-hr         .dash-tile-accent { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.dash-tile-clinical   .dash-tile-accent { background: linear-gradient(90deg, #0891b2, #06b6d4); }

.dash-tile-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  margin-top: 4px;
}
.dash-tile-head h3 {
  margin: 0; font-size: 13px; color: #475569; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
}
.dash-tile-period {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: #94a3b8; font-weight: 600;
}
.dash-tile-stat {
  font-size: 34px; font-weight: 800; color: #0f172a; line-height: 1;
  letter-spacing: -.02em;
  padding: 2px 0;
}
.dash-tile-stat .dash-empty-stat { color: #cbd5e1; }
.dash-tile-footer {
  font-size: 12.5px; color: #475569; line-height: 1.4;
}
.dash-muted { color: #94a3b8; font-size: 12px; }
.dash-trend { font-weight: 700; }
.dash-trend.is-up { color: #16a34a; }
.dash-trend.is-down { color: #dc2626; }
.is-up { color: #16a34a; }
.is-down { color: #dc2626; }

/* Financials & Clinical 3-stat rows */
.dash-fin-row, .dash-clin-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.dash-fin-row > div, .dash-clin-row > div {
  display: flex; flex-direction: column; gap: 2px;
  background: #f8fafc; border-radius: 8px; padding: 8px 10px;
}
.dash-fin-lbl {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px;
  color: #64748b; font-weight: 700;
}
.dash-fin-val {
  font-size: 17px; font-weight: 800; color: #0f172a;
  letter-spacing: -.01em; line-height: 1.1;
}
.dash-clin-sub { font-size: 10px; color: #94a3b8; font-weight: 500; }

/* AI commentary block */
.dash-ai-block {
  background: linear-gradient(135deg, #fdf2f8 0%, #fff 100%);
  border: 1px solid #fbcfe8; border-left: 3px solid #db2777;
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: #1e293b;
}
.dash-ai-head {
  font-weight: 700; color: #9d174d; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.dash-ai-body ul { margin: 2px 0 0 14px; padding: 0; }
.dash-ai-body li { margin: 3px 0; line-height: 1.45; }
.dash-ai-loading { color: #94a3b8; font-style: italic; font-size: 12px; }

/* Toggle button */
.dash-tile-toggle {
  background: transparent; border: 0;
  margin-top: 4px; padding: 8px 0 2px;
  cursor: pointer; color: #2563eb; font-size: 12px;
  font-weight: 700; text-align: left;
  border-top: 1px solid #f1f5f9;
}
.dash-tile-toggle:hover { color: #1d4ed8; }

/* Expand area */
.dash-tile-expand {
  margin-top: 8px; padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
}
.dash-fac-block { margin-bottom: 14px; }
.dash-fac-block:last-child { margin-bottom: 0; }
.dash-fac-head {
  font-size: 12px; font-weight: 700; color: #334155;
  padding: 6px 0; margin-bottom: 4px;
}

.tbl-compact { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl-compact th {
  font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
  padding: 6px 8px; text-align: left; color: #64748b;
  border-bottom: 1px solid #e2e8f0; background: #f8fafc;
}
.tbl-compact td {
  padding: 7px 8px; border-bottom: 1px solid #f1f5f9;
  color: #334155;
}
.tbl-compact tr:last-child td { border-bottom: 0; }

/* HR progress bar */
.dash-pct-bar {
  position: relative; background: #f1f5f9; border-radius: 4px;
  height: 18px; min-width: 100px;
}
.dash-pct-fill {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  height: 100%; border-radius: 4px; transition: width .3s ease;
}
.dash-pct-bar span {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; color: #0f172a;
}

/* Skeleton loader */
.skel {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%; border-radius: 6px;
  animation: dash-skel-pulse 1.4s ease-in-out infinite;
}
@keyframes dash-skel-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Mobile: tighter tile padding */
@media (max-width: 540px) {
  .dash-tile { padding: 14px 14px 10px; }
  .dash-tile-stat { font-size: 28px; }
  .dash-fin-val { font-size: 15px; }
}

/* ============================================================
   CUBE UPLOAD PAGE (v3)
   ============================================================ */
.cube-up-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 20px; margin: 16px 0;
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.cube-up-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px;
  border: 2px dashed #fcd34d; border-radius: 10px;
  background: #fffbeb;
  padding: 32px 16px;
  transition: background .15s ease, border-color .15s ease;
}
.cube-up-drop.is-drag { background: #fef3c7; border-color: #f59e0b; }
.cube-up-title { font-size: 16px; font-weight: 700; color: #78350f; }
.cube-up-sub { font-size: 13px; color: #57534e; max-width: 460px; line-height: 1.5; }
.cube-up-drop .btn-primary {
  margin-top: 4px; background: #b45309; color: #fff; border: none;
  padding: 8px 18px; border-radius: 6px; font-weight: 600; cursor: pointer;
}
.cube-up-drop .btn-primary:hover { background: #92400e; }
.cube-up-status { margin-top: 14px; font-size: 13px; }
.cube-up-ok { color: #166534; }
.cube-up-notes { margin: 6px 0 0; padding-left: 20px; font-size: 12px; color: #57534e; }

.cube-snap-card, .cube-snap-block {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 14px 16px; margin: 12px 0;
}
.cube-snap-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: #64748b; font-weight: 700; margin-bottom: 8px;
}
.cube-snap-big {
  font-size: 28px; font-weight: 700; color: #0f172a;
  margin-bottom: 10px;
}
.cube-snap-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin-bottom: 6px;
}
.cube-snap-grid > div { display: flex; flex-direction: column; gap: 2px; }
.cube-snap-grid .muted { font-size: 11px; }
.cube-snap-grid strong { font-size: 16px; }
@media (max-width: 560px) {
  .cube-snap-grid { grid-template-columns: repeat(2, 1fr); }
}
