/* ===========================================================================
   Intuitive Surgical Intelligence — Strategic Command Center
   Inspired by Plaza Premium Intelligence dashboard aesthetic.
   =========================================================================== */

/* -------- Design Tokens -------- */
:root {
  /* Brand */
  --brand-900: #062a4f;
  --brand-800: #0a3d6e;
  --brand-700: #0a4d8c;
  --brand-600: #0e6cb6;
  --brand-500: #1f8fd1;
  --brand-400: #3aa9e0;
  --brand-300: #7dc6ee;
  --accent-teal: #0a8d6f;
  --accent-purple: #6a4cc4;

  /* Surfaces */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;

  /* Text */
  --text: #0f1c2e;
  --text-2: #46556b;
  --text-3: #7a8aa1;
  --text-inv: #ffffff;

  /* Status */
  --good: #10b981;
  --good-bg: #e6f7f0;
  --warn: #f59e0b;
  --warn-bg: #fef4e1;
  --bad: #ef4444;
  --bad-bg: #fdecec;
  --neutral: #6b7280;
  --neutral-bg: #eef2f7;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(11, 30, 51, .04), 0 1px 1px rgba(11, 30, 51, .03);
  --shadow-md: 0 4px 12px rgba(11, 30, 51, .06), 0 2px 4px rgba(11, 30, 51, .04);
  --shadow-lg: 0 16px 36px rgba(11, 30, 51, .12), 0 4px 10px rgba(11, 30, 51, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --topbar-h: 64px;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; }
a { text-decoration: none; color: inherit; }

/* -------- Top Bar -------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: var(--sidebar-w); }

.brand-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
  color: white;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.5px;
  box-shadow: 0 4px 12px rgba(14, 108, 182, .3);
}

.brand-title { font-weight: 700; font-size: 14px; color: var(--text); letter-spacing: -0.2px; }
.brand-tagline { font-size: 11px; color: var(--text-3); margin-top: 1px; letter-spacing: 0.2px; text-transform: uppercase; }

.topbar-status {
  display: flex; align-items: center; gap: 12px; flex: 1;
}

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 11px;
  background: var(--good-bg);
  color: var(--good);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-pill .dot {
  width: 6px; height: 6px; background: var(--good); border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, .6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-meta { font-size: 12px; color: var(--text-3); font-weight: 500; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-700) 0%, var(--brand-800) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(10, 77, 140, .25);
}
.btn-primary:hover { box-shadow: 0 6px 18px rgba(10, 77, 140, .35); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--surface-3);
  border-radius: 999px;
  margin-left: 8px;
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-700), var(--accent-purple));
  color: white;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.user-name { font-size: 12px; font-weight: 600; color: var(--text); }
.user-role { font-size: 10px; color: var(--text-3); }

/* -------- Layout -------- */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s ease;
}
.nav-item svg { color: var(--text-3); flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover svg { color: var(--brand-600); }

.nav-item.active {
  background: linear-gradient(90deg, rgba(10, 77, 140, .08), rgba(10, 77, 140, .02));
  color: var(--brand-700);
  font-weight: 600;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-700);
}
.nav-item.active svg { color: var(--brand-700); }

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  background: var(--bad);
  color: white;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  letter-spacing: 0;
}
.nav-badge.empty { background: var(--neutral-bg); color: var(--text-3); font-weight: 600; }

/* Sidebar grouping */
.nav { padding: 4px 0; }
.nav-group {
  margin-top: 14px;
  padding: 4px 6px 2px;
  border-radius: 10px;
}
/* Soft tint for AI-driven groups — visually distinct from data/execution groups */
.nav-group.is-ai {
  background: linear-gradient(180deg, rgba(106, 76, 196, 0.04) 0%, rgba(31, 143, 209, 0.03) 100%);
}
.nav-group-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 6px 8px 6px;
}
.nav-group.is-ai .nav-group-label { color: var(--accent-purple); }
.nav-group-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.nav-group-dot.nav-ai {
  background: linear-gradient(135deg, var(--accent-purple), var(--brand-500));
  box-shadow: 0 0 0 2px rgba(106, 76, 196, 0.16);
}
/* Slightly tighter nav items inside groups */
.nav-group .nav-item { padding: 8px 10px; }

/* Story summary tiles (for Storylines tab) */
.story-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* -------- Today's Pulse -------- */
.pulse-card {
  background: linear-gradient(135deg, #f6f9fd 0%, #ffffff 70%);
  border-left: 4px solid var(--brand-700);
  position: relative;
}
.pulse-dot-icon {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-700);
  margin-right: 8px;
  box-shadow: 0 0 0 0 rgba(10, 77, 140, .5);
  animation: pulse 2.5s infinite;
}
.pulse-text {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  letter-spacing: -0.1px;
  padding-left: 16px;
  border-left: 2px solid var(--surface-3);
  margin-left: 2px;
}
.pulse-text .placeholder { color: var(--text-3); font-style: italic; font-size: 13px; }

/* -------- Storylines -------- */
.story-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.story-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.story-card:hover {
  background: var(--surface);
  border-color: var(--brand-500);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.story-card.sev-high   { border-left-color: var(--bad); }
.story-card.sev-medium { border-left-color: var(--warn); }
.story-card.sev-low    { border-left-color: var(--brand-500); }

.story-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.story-sev-pill {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.story-sev-pill.high   { background: var(--bad-bg); color: var(--bad); }
.story-sev-pill.medium { background: var(--warn-bg); color: var(--warn); }
.story-sev-pill.low    { background: rgba(31,143,209,.15); color: var(--brand-700); }
.story-region {
  font-size: 11px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
}

.story-title {
  font-weight: 700; font-size: 15.5px;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.3;
}
.story-headline {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

.story-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.story-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-2);
  font-weight: 500;
}
.story-chip .chip-icon { font-size: 10px; color: var(--brand-600); }

.story-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.story-owner { font-size: 11.5px; color: var(--text-3); }
.story-owner strong { color: var(--text-2); font-weight: 600; }
.story-impact {
  font-size: 16px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.story-trace {
  font-size: 12px; font-weight: 600;
  color: var(--brand-700);
  display: inline-flex; align-items: center; gap: 4px;
}
.story-card:hover .story-trace span { transform: translateX(3px); }
.story-trace span { transition: transform .15s ease; display: inline-block; }

/* -------- Story drawer specifics -------- */
.story-narrative {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}
.system-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.system-tag {
  display: inline-flex; align-items: center;
  padding: 5px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.system-tag::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand-600);
  margin-right: 6px;
}

.story-link-list { display: flex; flex-direction: column; gap: 8px; }
.story-link {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .12s ease;
}
.story-link:hover { background: var(--surface-2); border-color: var(--brand-500); }
.story-link.sev-high   { border-left-color: var(--bad); }
.story-link.sev-medium { border-left-color: var(--warn); }
.story-link.sev-low    { border-left-color: var(--brand-500); }
.story-link.sev-neutral{ border-left-color: var(--neutral); }
.sl-body { flex: 1; min-width: 0; }
.sl-title { font-weight: 600; font-size: 13.5px; color: var(--text); line-height: 1.35; }
.sl-meta { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.sl-impact { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.sl-progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}
.sl-progress .fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--good), #34d399);
}
.sl-progress .fill.at-risk { background: linear-gradient(90deg, var(--warn), #fbbf24); }

/* -------- Overview pivot card -------- */
.overview-pivot { background: linear-gradient(180deg, #f9fbfe 0%, #ffffff 100%); }
.pivot-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pivot-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: all .15s ease;
}
.pivot-btn:hover { border-color: var(--brand-500); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.pivot-ico {
  width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.pivot-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.pivot-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.pivot-sub { font-size: 11.5px; color: var(--text-3); }
.pivot-arrow { color: var(--brand-600); font-weight: 600; transition: transform .15s ease; }
.pivot-btn:hover .pivot-arrow { transform: translateX(4px); }

/* -------- Summary tiles for tabs -------- */
.alert-summary, .system-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.sum-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.sum-label {
  font-size: 10.5px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
}
.sum-value { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 4px; letter-spacing: -0.4px; }
.sum-value.high { color: var(--bad); }
.sum-value.med { color: var(--warn); }
.sum-value.good { color: var(--good); }

.sidebar-section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--text-3);
  text-transform: uppercase;
  padding: 0 12px 8px;
}
.sidebar-label-row {
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-clear {
  background: none; border: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
}
.sidebar-clear:hover { color: var(--text); background: var(--surface-3); }

.recent-item {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-2);
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s ease;
}
.recent-item:hover { background: var(--surface-2); color: var(--text); }
.recent-icon {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
  font-size: 10px;
  color: var(--brand-600);
}
.recent-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.recent-time {
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.recent-empty {
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-3);
  font-style: italic;
  line-height: 1.4;
}

.sidebar-footer { margin-top: auto; padding-top: 20px; }
.kbd-hint {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-3);
}
.kbd-hint span {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text);
  font-size: 10px;
}

/* -------- Main Content -------- */
.main {
  flex: 1;
  padding: 24px 32px 80px;
  max-width: 1500px;
  width: 100%;
}

.tab { display: none; flex-direction: column; gap: 20px; }
.tab.active { display: flex; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.page-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text);
}
.page-sub { margin: 0; color: var(--text-3); font-size: 13px; }

.page-controls { display: flex; align-items: center; gap: 10px; }

.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  box-shadow: var(--shadow-sm);
}
.seg-btn {
  background: transparent;
  border: none;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-2);
  border-radius: 6px;
  font-weight: 500;
}
.seg-btn.active {
  background: var(--brand-700);
  color: white;
  box-shadow: 0 1px 3px rgba(10, 77, 140, .3);
}

/* -------- KPI Grid -------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: transform .12s ease, box-shadow .15s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-label {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text);
  margin-top: 6px;
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 8px;
  font-size: 11.5px;
  font-weight: 600;
}
.kpi-delta.good { color: var(--good); }
.kpi-delta.bad { color: var(--bad); }
.kpi-delta.neutral { color: var(--text-3); }

.kpi::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--brand-700);
  opacity: 0;
  transition: opacity .15s ease;
}
.kpi:hover::after { opacity: 1; }

/* -------- Cards -------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}
.card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
}

.card-tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.tag-good { background: var(--good-bg); color: var(--good); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-bad { background: var(--bad-bg); color: var(--bad); }
.tag-neutral { background: var(--neutral-bg); color: var(--neutral); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* -------- System grid -------- */
.system-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.system-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all .15s ease;
  position: relative;
  overflow: hidden;
}
.system-card:hover {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.system-strip {
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}
.system-card .row { display: flex; justify-content: space-between; align-items: center; }
.system-card .name { font-weight: 600; font-size: 13.5px; color: var(--text); padding-left: 4px; }
.system-card .cat {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  font-weight: 600;
}
.system-card .stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 12px;
  padding-left: 4px;
}
.system-card .stat-label { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; }
.system-card .stat-value { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 2px; }

/* -------- Alerts -------- */
.alert-list { display: flex; flex-direction: column; gap: 8px; }

.alert {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: all .15s ease;
}
.alert:hover { background: var(--surface-3); }

.alert-strip {
  width: 4px; border-radius: 4px; flex-shrink: 0;
}
.alert.high .alert-strip { background: var(--bad); }
.alert.medium .alert-strip { background: var(--warn); }
.alert.low .alert-strip { background: var(--brand-500); }
.alert.resolved .alert-strip { background: var(--neutral); }

.alert-body { flex: 1; }
.alert-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.alert-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.alert-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
}
.alert.high .alert-badge { background: var(--bad-bg); color: var(--bad); }
.alert.medium .alert-badge { background: var(--warn-bg); color: var(--warn); }
.alert.low .alert-badge { background: rgba(31, 143, 209, .15); color: var(--brand-600); }
.alert.resolved .alert-badge { background: var(--neutral-bg); color: var(--neutral); }

.alert-cat { font-size: 11px; color: var(--text-3); font-weight: 500; }
.alert-desc { font-size: 12.5px; color: var(--text-2); margin-top: 4px; line-height: 1.5; }
.alert-meta {
  display: flex; gap: 14px; margin-top: 8px;
  font-size: 11px; color: var(--text-3);
}
.alert-meta strong { color: var(--text-2); font-weight: 600; }

/* -------- Tables -------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.data-table th:first-child { border-radius: 8px 0 0 0; }
.data-table th:last-child { border-radius: 0 8px 0 0; }
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }

.data-table .num { font-variant-numeric: tabular-nums; font-weight: 500; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-dot.green { background: var(--good); }
.status-dot.amber { background: var(--warn); }
.status-dot.red { background: var(--bad); }

.select {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}

/* -------- AI Tools -------- */
.ai-tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.ai-tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  display: flex;
  gap: 14px;
  transition: all .15s ease;
  position: relative;
  overflow: hidden;
}
.ai-tool:hover {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.ai-tool::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(31, 143, 209, .04) 100%);
  pointer-events: none;
}
.ai-tool-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
  font-weight: 700;
}
.ai-tool-icon-1 { background: linear-gradient(135deg, #fef4e1, #fde7b8); color: #b87900; }
.ai-tool-icon-2 { background: linear-gradient(135deg, #e6f4fa, #c7e7f5); color: var(--brand-700); }
.ai-tool-icon-3 { background: linear-gradient(135deg, #efe9fb, #ddd0f5); color: var(--accent-purple); }
.ai-tool-icon-4 { background: linear-gradient(135deg, #e0f7ef, #b8eedb); color: var(--accent-teal); }

.ai-tool-title { font-weight: 600; font-size: 13.5px; color: var(--text); }
.ai-tool-desc { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.45; }
.ai-tool-cta {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-700);
  display: inline-flex; align-items: center; gap: 4px;
}
.ai-tool-cta span { transition: transform .15s ease; display: inline-block; }
.ai-tool:hover .ai-tool-cta span { transform: translateX(4px); }

.insight-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.insight-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s ease;
}
.insight-btn span { color: var(--brand-600); transition: transform .15s ease; }
.insight-btn:hover { border-color: var(--brand-500); background: var(--surface); }
.insight-btn:hover span { transform: translateX(4px); }

/* -------- AI output -------- */
.ai-output {
  margin-top: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  min-height: 80px;
  font-family: 'Inter', sans-serif;
  position: relative;
}
.ai-output-inline { margin-top: 14px; }
.ai-output .placeholder {
  color: var(--text-3); font-size: 13px; font-style: italic;
}
.ai-output kbd {
  display: inline-block;
  padding: 1px 6px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text);
  margin: 0 2px;
}

/* Markdown rendering inside AI output blocks and chat bubbles */
.ai-output, .bubble-msg.assistant { white-space: normal; }
.ai-output > *:first-child, .bubble-msg.assistant > *:first-child { margin-top: 0; }
.ai-output > *:last-child,  .bubble-msg.assistant > *:last-child  { margin-bottom: 0; }

.ai-output p,
.bubble-msg.assistant p {
  margin: 0 0 10px;
  line-height: 1.55;
}

.ai-output h3,
.bubble-msg.assistant h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  margin: 14px 0 6px;
  letter-spacing: -0.2px;
}
.ai-output h4,
.bubble-msg.assistant h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 4px;
  text-transform: none;
  letter-spacing: 0;
}
.ai-output h5,
.bubble-msg.assistant h5 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin: 10px 0 4px;
}

.ai-output ol,
.ai-output ul,
.bubble-msg.assistant ol,
.bubble-msg.assistant ul {
  margin: 0 0 10px;
  padding-left: 22px;
}
.ai-output ol,
.bubble-msg.assistant ol { list-style: decimal; }
.ai-output ul,
.bubble-msg.assistant ul { list-style: disc; }

.ai-output li,
.bubble-msg.assistant li {
  margin: 3px 0;
  line-height: 1.55;
}
.ai-output li::marker,
.bubble-msg.assistant li::marker { color: var(--brand-600); font-weight: 600; }

.ai-output strong,
.bubble-msg.assistant strong { color: var(--text); font-weight: 600; }
.ai-output em,
.bubble-msg.assistant em { color: var(--text-2); }

.ai-output code,
.bubble-msg.assistant code {
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--brand-700);
}

/* In dark blue user bubble, keep contrast */
.bubble-msg.user code {
  background: rgba(255,255,255,.15);
  border-color: rgba(255,255,255,.25);
  color: white;
}

.hidden { display: none !important; }

/* Loading shimmer */
@keyframes shimmer {
  0% { background-position: -300px 0; }
  100% { background-position: 300px 0; }
}
.loading {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  color: transparent !important;
  border-radius: 6px;
}

/* -------- Studio forms -------- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-field { margin-bottom: 12px; }
.form-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(31, 143, 209, .12); }

.slider-row { margin-bottom: 16px; }
.slider-row label {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 500; color: var(--text-2);
  margin-bottom: 6px;
}
.slider-val {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--brand-700);
  font-size: 12.5px;
}
.slider {
  width: 100%; height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--brand-700);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(10, 77, 140, .3);
  transition: transform .12s ease;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--brand-700);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

/* -------- Goals -------- */
.goal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.goal-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.goal-title { font-weight: 600; font-size: 14px; color: var(--text); }
.goal-owner { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.goal-stats {
  display: flex; gap: 16px; align-items: baseline; margin: 14px 0 8px;
}
.goal-curr { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; }
.goal-target { font-size: 13px; color: var(--text-3); }
.goal-bar {
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}
.goal-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .8s cubic-bezier(.16,1,.3,1);
}
.goal-fill.on-track { background: linear-gradient(90deg, var(--good), #34d399); }
.goal-fill.at-risk { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.goal-fill.behind { background: linear-gradient(90deg, var(--bad), #f87171); }
.goal-meta {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* -------- Bars (procedure mix) -------- */
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: 220px 1fr 80px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.bar-label .specialty {
  font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px;
  font-weight: 600;
}
.bar-label .name { color: var(--text); font-weight: 500; }
.bar-track {
  height: 22px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-600), var(--brand-400));
  border-radius: 6px;
  display: flex; align-items: center;
  padding: 0 8px;
  transition: width .8s cubic-bezier(.16,1,.3,1);
}
.bar-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); font-size: 12.5px; }

/* -------- Bubble grid (region growth) -------- */
.bubble-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 8px 0;
}
.bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: all .15s ease;
}
.bubble:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.bubble-name { font-weight: 600; color: var(--text); font-size: 14px; }
.bubble-rev { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 6px; letter-spacing: -0.4px; }
.bubble-rev .unit { font-size: 13px; color: var(--text-3); font-weight: 500; }
.bubble-meta { display: flex; gap: 14px; margin-top: 10px; }
.bubble-meta div { font-size: 11px; }
.bubble-meta div .lbl { color: var(--text-3); display: block; }
.bubble-meta div .v { font-weight: 600; color: var(--text); font-size: 13px; }

.bubble-growth {
  position: absolute; top: 14px; right: 14px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.bubble.hot .bubble-growth { background: var(--good-bg); color: var(--good); }
.bubble.warm .bubble-growth { background: var(--warn-bg); color: var(--warn); }
.bubble.cold .bubble-growth { background: var(--bad-bg); color: var(--bad); }

.bubble.hot { border-left: 3px solid var(--good); }
.bubble.warm { border-left: 3px solid var(--warn); }
.bubble.cold { border-left: 3px solid var(--bad); }

/* -------- Innovations -------- */
.innovation-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.inno-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  position: relative;
}
.inno-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.inno-title { font-weight: 600; font-size: 14.5px; color: var(--text); }
.inno-cat { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-top: 2px; }
.inno-desc { font-size: 13px; color: var(--text-2); margin-top: 10px; line-height: 1.55; }
.inno-meta { display: flex; gap: 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 11.5px; }
.inno-meta div .lbl { color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; font-size: 10px; font-weight: 600; }
.inno-meta div .v { font-weight: 600; color: var(--text); margin-top: 2px; font-size: 13px; }
.status-pill-sm {
  padding: 3px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
}
.status-pill-sm.research { background: rgba(106, 76, 196, .12); color: var(--accent-purple); }
.status-pill-sm.in-development { background: rgba(31, 143, 209, .15); color: var(--brand-700); }
.status-pill-sm.pilot { background: var(--good-bg); color: var(--good); }

/* -------- Modal -------- */
.modal {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal.open { display: flex; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 22, 41, .55);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  width: min(720px, 92vw);
  max-height: 80vh;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 700; font-size: 16px; color: var(--text); }
.modal-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-3); padding: 0 6px; line-height: 1; }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 16px 22px; overflow-y: auto; flex: 1; }
.ai-history { display: flex; flex-direction: column; gap: 10px; min-height: 80px; }
.bubble-msg { padding: 10px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; max-width: 92%; }
.bubble-msg.user { background: var(--brand-700); color: white; align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble-msg.assistant { background: var(--surface-2); color: var(--text); border-bottom-left-radius: 3px; white-space: pre-wrap; }

.suggested { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 500;
}
.chip:hover { background: var(--surface-3); border-color: var(--brand-500); color: var(--text); }

/* Message actions (under each assistant bubble) */
.msg-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  align-self: flex-start;
  margin: -4px 0 4px 4px;
}
.msg-action {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .12s ease;
  text-decoration: none;
}
.msg-action:hover { border-color: var(--brand-500); color: var(--brand-700); background: var(--surface-2); }
.msg-action svg { flex-shrink: 0; }

/* Suggested-contacts panel under an assistant bubble */
.msg-contacts {
  align-self: flex-start;
  max-width: 92%;
  margin: -2px 0 4px 4px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-purple);
  border-radius: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.msg-contacts-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-purple);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 2px;
}
.contact-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.contact-name { font-weight: 600; color: var(--text); }
.contact-role { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.contact-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}
.contact-link.call { color: var(--good); border-color: var(--good-bg); }
.contact-link.call:hover { background: var(--good-bg); }
.contact-link.email { color: var(--brand-700); border-color: rgba(31,143,209,.2); }
.contact-link.email:hover { background: rgba(31,143,209,.08); }

.modal-foot {
  display: flex; gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.modal-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
  font-family: inherit;
}
.modal-input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(31, 143, 209, .12); }

/* -------- Alert drill-down drawer -------- */
.alert {
  cursor: pointer;
  position: relative;
}
.alert::after {
  content: '›';
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  color: var(--text-3);
  font-weight: 300;
  transition: transform .15s ease, color .15s ease;
}
.alert:hover::after { color: var(--brand-700); transform: translateY(-50%) translateX(3px); }

.drawer {
  position: fixed; inset: 0;
  z-index: 110;
  display: none;
}
.drawer.open { display: block; }
.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 22, 41, .45);
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
.drawer-panel {
  position: absolute;
  top: 0; right: 0;
  width: min(640px, 100vw);
  height: 100vh;
  background: var(--surface);
  box-shadow: -16px 0 36px rgba(11, 30, 51, .14);
  display: flex;
  flex-direction: column;
  animation: slideIn .22s cubic-bezier(.16,1,.3,1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(40px); opacity: .6; } to { transform: translateX(0); opacity: 1; } }

.drawer-head {
  position: relative;
  padding: 16px 22px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%);
}
.drawer-eyebrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.drawer-sev {
  padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.drawer-sev.high { background: var(--bad-bg); color: var(--bad); }
.drawer-sev.medium { background: var(--warn-bg); color: var(--warn); }
.drawer-sev.low { background: rgba(31, 143, 209, .15); color: var(--brand-700); }
.drawer-cat, .drawer-status {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.drawer-cat::before, .drawer-status::before { content: '·'; margin-right: 6px; color: var(--border-strong); }
.drawer-eyebrow .drawer-cat:first-of-type::before { display: none; }

.drawer-title {
  margin: 0 40px 4px 0;
  font-size: 17px; font-weight: 700; line-height: 1.3;
  color: var(--text); letter-spacing: -0.3px;
}
.drawer-desc {
  margin: 0 0 10px;
  color: var(--text-2);
  font-size: 12.5px; line-height: 1.45;
}
.drawer-meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.drawer-meta div { display: flex; flex-direction: column; gap: 2px; }
.dm-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.dm-val { font-size: 13px; font-weight: 600; color: var(--text); }

.drawer-close {
  position: absolute;
  top: 18px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 30px; height: 30px;
  font-size: 18px; line-height: 1;
  color: var(--text-3);
  display: grid; place-items: center;
  transition: all .15s ease;
}
.drawer-close:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.dtab {
  display: inline-flex; align-items: center; gap: 6px;
  background: none;
  border: none;
  padding: 10px 14px 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.dtab:hover { color: var(--text-2); }
.dtab.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-700);
  font-weight: 600;
}
.dtab-ico { font-size: 13px; opacity: .85; }
.dtab.active .dtab-ico { opacity: 1; }
.dtab-badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--surface-3);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-2);
  margin-left: 2px;
}
.dtab.active .dtab-badge {
  background: rgba(10, 77, 140, .12);
  color: var(--brand-700);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 18px;
}
.dt-panel { display: none; flex-direction: column; gap: 10px; animation: dtFade .18s ease; }
.dt-panel.active { display: flex; }
@keyframes dtFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.drawer-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px 12px;
}
.drawer-section-flat { background: transparent; border: none; padding: 0 2px; }

.ds-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  margin-bottom: 8px;
}
.ds-title { font-weight: 600; font-size: 13px; color: var(--text); letter-spacing: -0.1px; }
.ds-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.signal-stat { text-align: right; }
.signal-current {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
}
.signal-threshold { font-size: 11px; color: var(--text-3); }

.dp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.dp-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
}
.dp-k { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.dp-v { font-size: 14px; font-weight: 600; color: var(--text); margin-top: 2px; }
.dp-trend { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.dp-trend.up { color: var(--good); }
.dp-trend.down { color: var(--bad); }

.aff-list { display: flex; flex-direction: column; gap: 4px; }
.aff-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
}
.aff-bullet {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brand-500);
  flex-shrink: 0;
}
.aff-body { flex: 1; min-width: 0; }
.aff-entity { font-size: 13px; font-weight: 600; color: var(--text); }
.aff-kind { font-size: 11.5px; color: var(--text-3); }
.aff-exposure { font-size: 11.5px; color: var(--text-2); font-weight: 500; text-align: right; flex-shrink: 0; }

.action-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.action-list li {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px; color: var(--text);
  line-height: 1.4;
}
.action-list li::before {
  content: '→';
  color: var(--brand-700);
  font-weight: 700;
  flex-shrink: 0;
}

.related-row { display: flex; flex-wrap: wrap; gap: 6px; }
.related-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s ease;
  display: inline-flex; align-items: center; gap: 4px;
}
.related-chip:hover { border-color: var(--brand-500); color: var(--brand-700); }
.related-chip::after { content: '↗'; font-size: 10px; opacity: .6; }

.drawer-ask {
  display: flex; gap: 8px;
  margin-top: 8px;
}
.drawer-ask .input { flex: 1; }

/* -------- Export menu -------- */
.export-wrap { position: relative; }
#btn-export { display: inline-flex; align-items: center; gap: 6px; }
.export-menu {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 240px;
  display: none;
  z-index: 30;
  animation: dtFade .14s ease;
}
.export-menu.open { display: block; }
.export-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
}
.export-item:hover { background: var(--surface-2); }
.export-item svg { color: var(--brand-600); flex-shrink: 0; margin-top: 1px; }
.export-item-title { font-size: 12.5px; font-weight: 600; color: var(--text); }
.export-item-sub { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }

/* -------- Print styles (PDF export uses window.print) -------- */
@media print {
  body { background: white !important; }
  .topbar, .sidebar, .modal, .drawer, .msg-actions, .msg-contacts,
  .page-controls, #pulse-refresh, #story-pulse-refresh, .pivot-row,
  .seg, .btn { display: none !important; }
  .layout { display: block !important; margin-top: 0 !important; }
  .main { padding: 16px !important; max-width: none !important; width: 100% !important; }
  .tab.active { display: flex !important; flex-direction: column; gap: 14px; }
  .tab:not(.active) { display: none !important; }
  .card {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #d4d4d4 !important;
  }
  .grid-2, .kpi-grid, .system-grid, .story-grid, .goal-grid, .innovation-grid, .bubble-grid {
    page-break-inside: avoid;
  }
  .pulse-card { background: white !important; }
  canvas { max-width: 100% !important; }
  /* Header band on the print so reader knows where it came from */
  .main::before {
    content: 'Intuitive Surgical Intelligence — Strategic Command Center';
    display: block;
    font: 700 14px Inter, sans-serif;
    color: #0a4d8c;
    padding-bottom: 10px;
    border-bottom: 2px solid #0a4d8c;
    margin-bottom: 16px;
  }
}

/* -------- Innovation drawer -------- */
.inno-card { cursor: pointer; transition: all .15s ease; }
.inno-card:hover { border-color: var(--brand-500); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.inno-card { position: relative; }
.inno-card::after {
  content: '›';
  position: absolute;
  right: 16px; top: 18px;
  font-size: 22px;
  color: var(--text-3);
  font-weight: 300;
  line-height: 1;
  transition: color .12s ease, transform .12s ease;
}
.inno-card:hover::after { color: var(--brand-700); transform: translateX(2px); }

.inno-status-pill {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.inno-status-pill.research      { background: rgba(106, 76, 196, .14); color: var(--accent-purple); }
.inno-status-pill.in-development{ background: rgba(31, 143, 209, .15); color: var(--brand-700); }
.inno-status-pill.pilot         { background: var(--good-bg); color: var(--good); }

/* Milestone timeline */
.milestone-timeline {
  position: relative;
  display: flex; flex-direction: column;
  gap: 10px;
  padding-left: 22px;
}
.milestone-timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--surface-3);
  border-radius: 2px;
}
.milestone {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.milestone::before {
  content: '';
  position: absolute;
  left: -19px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  z-index: 1;
}
.milestone.done::before        { background: var(--good); border-color: var(--good); }
.milestone.in-progress::before { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 0 4px rgba(245,158,11,.2); }
.milestone.planned::before     { background: var(--surface); border-color: var(--border-strong); }
.milestone-date {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  width: 70px;
  flex-shrink: 0;
}
.milestone-label { font-size: 12.5px; color: var(--text); line-height: 1.4; }
.milestone-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.milestone-tag.done        { background: var(--good-bg); color: var(--good); }
.milestone-tag.in-progress { background: var(--warn-bg); color: var(--warn); }
.milestone-tag.planned     { background: var(--surface-3); color: var(--text-3); }

/* -------- Goal drawer -------- */
.goal-card { cursor: pointer; transition: all .15s ease; position: relative; }
.goal-card:hover { border-color: var(--brand-500); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.goal-card::after {
  content: '›';
  position: absolute;
  right: 18px; top: 18px;
  font-size: 22px;
  color: var(--text-3);
  font-weight: 300;
  line-height: 1;
  transition: color .12s ease, transform .12s ease;
}
.goal-card:hover::after { color: var(--brand-700); transform: translateX(2px); }

.g-status-pill {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.g-status-pill.on-track  { background: var(--good-bg);   color: var(--good); }
.g-status-pill.at-risk   { background: var(--warn-bg);   color: var(--warn); }
.g-status-pill.behind    { background: var(--bad-bg);    color: var(--bad); }

.g-progress-block { margin-top: 4px; }
.g-progress-row {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.g-progress-current { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.g-progress-unit { font-size: 12px; color: var(--text-3); font-weight: 500; }
.g-progress-target { font-size: 12.5px; color: var(--text-3); }
.g-progress-pct {
  margin-left: auto;
  font-size: 13px; font-weight: 700; color: var(--brand-700);
  font-variant-numeric: tabular-nums;
}
.g-progress-meta {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px; color: var(--text-3);
}

.g-verdict { background: linear-gradient(180deg, #fbfdff 0%, #ffffff 100%); border-left: 3px solid var(--brand-700); }
.g-verdict-text { font-size: 14px; line-height: 1.5; color: var(--text); font-weight: 500; }
.g-verdict-text .placeholder { font-weight: 400; }
.conf-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
}
.conf-pill.conf-high   { background: var(--good-bg); color: var(--good); }
.conf-pill.conf-medium { background: var(--warn-bg); color: var(--warn); }
.conf-pill.conf-low    { background: var(--bad-bg);  color: var(--bad); }

/* Goal-drawer loader */
.g-loader {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 0;
}
.g-loader .brief-spinner { width: 22px; height: 22px; border-width: 2.5px; margin: 0; flex-shrink: 0; }
.g-loader-text { font-size: 13px; color: var(--text-3); font-style: italic; }

#g-refresh.is-loading {
  opacity: 0.55;
  cursor: not-allowed;
  position: relative;
  padding-left: 26px;
}
#g-refresh.is-loading::before {
  content: '';
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 10px; height: 10px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: brief-spin 0.9s linear infinite;
}

/* Shimmer skeleton rows for the lists while the AI explainer is loading */
.skeleton-row {
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite;
  list-style: none;
  border: 1px solid var(--border);
}
.g-driver-list .skeleton-row::before,
.action-list .skeleton-row::before { content: ''; }

.g-drivers-grid { gap: 10px; }
.g-drivers-pos { border-left: 3px solid var(--good); }
.g-drivers-neg { border-left: 3px solid var(--bad); }
.g-drivers-pos .ds-title { color: var(--good); }
.g-drivers-neg .ds-title { color: var(--bad); }
.g-driver-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.g-driver-list li {
  display: flex; gap: 7px; align-items: flex-start;
  font-size: 12.5px; line-height: 1.4;
  color: var(--text);
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.g-driver-list li::before {
  content: '·';
  color: var(--text-3);
  font-weight: 700;
  flex-shrink: 0;
}
.g-drivers-pos .g-driver-list li::before { content: '▲'; color: var(--good); font-size: 9px; padding-top: 4px; }
.g-drivers-neg .g-driver-list li::before { content: '▼'; color: var(--bad);  font-size: 9px; padding-top: 4px; }

.g-actions-sec { border-left: 3px solid var(--accent-purple); }
.g-actions-sec .ds-title { color: var(--accent-purple); }

@media (max-width: 720px) {
  .g-drivers-grid { grid-template-columns: 1fr; }
}

/* -------- Morning Briefing Modal -------- */
.briefing-modal-card {
  width: min(880px, 94vw);
  max-height: 88vh;
}
.briefing-head {
  background: linear-gradient(135deg, #f6f9fd 0%, #ffffff 60%);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  position: relative;
}
.brief-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--brand-700);
}
.brief-sun {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  background: linear-gradient(135deg, #ffd66e, #ff9d3e);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  box-shadow: 0 0 0 3px rgba(255, 157, 62, 0.18);
}
.brief-date {
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text); margin-top: 6px;
}
.brief-head-actions { display: flex; align-items: center; gap: 8px; }

.briefing-body {
  padding: 22px 24px 28px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}

.brief-hero {
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
  color: white;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(10, 77, 140, .22);
}
.brief-hero-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.85;
}
.brief-hero-text {
  font-size: 18px;
  line-height: 1.4;
  margin-top: 6px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.brief-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.brief-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px 16px;
  border-left-width: 3px;
}
.brief-section.wins   { border-left-color: var(--good); }
.brief-section.flags  { border-left-color: var(--bad); }
.brief-section.pulse  { border-left-color: var(--brand-500); }
.brief-section.actions{ border-left-color: var(--accent-purple); background: linear-gradient(180deg, #faf7ff 0%, #ffffff 100%); }

.brief-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 10px;
}
.brief-section.wins   .brief-section-title { color: var(--good); }
.brief-section.flags  .brief-section-title { color: var(--bad); }
.brief-section.pulse  .brief-section-title { color: var(--brand-700); }
.brief-section.actions .brief-section-title { color: var(--accent-purple); }
.brief-ico {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: 5px;
  font-size: 11px;
}
.brief-section.wins   .brief-ico { background: var(--good-bg); color: var(--good); }
.brief-section.flags  .brief-ico { background: var(--bad-bg);  color: var(--bad); }
.brief-section.pulse  .brief-ico { background: rgba(31,143,209,.15); color: var(--brand-700); }
.brief-section.actions .brief-ico { background: rgba(106,76,196,.15); color: var(--accent-purple); }

.brief-section ul,
.brief-section ol {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.brief-section li {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}
.brief-section.wins li::before  { content: '▲'; color: var(--good); flex-shrink: 0; font-size: 9px; padding-top: 4px; }
.brief-section.flags li::before { content: '!';  color: var(--bad); font-weight: 700; flex-shrink: 0; font-size: 12px; padding-top: 1px; line-height: 1; }
.brief-section.actions { grid-column: 1 / -1; }
.brief-section.actions ol { counter-reset: act; }
.brief-section.actions li::before {
  counter-increment: act;
  content: counter(act);
  background: var(--accent-purple);
  color: white;
  font-weight: 700;
  font-size: 11px;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.brief-section.pulse p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

/* Loading state */
.brief-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.brief-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: brief-spin 0.9s linear infinite;
  margin-bottom: 14px;
}
@keyframes brief-spin { to { transform: rotate(360deg); } }
.brief-loading-text { font-size: 13px; font-style: italic; }

.brief-error {
  padding: 18px;
  background: var(--bad-bg);
  border: 1px solid var(--bad);
  border-radius: 10px;
  color: var(--bad);
  font-size: 13px;
}

.brief-footer {
  display: flex; justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
}
.brief-footer .brief-cta { color: var(--brand-700); cursor: pointer; font-weight: 600; }
.brief-footer .brief-cta:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .brief-grid { grid-template-columns: 1fr; }
}

/* -------- Responsive -------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .ai-tools { grid-template-columns: repeat(2, 1fr); }
  .system-grid { grid-template-columns: repeat(2, 1fr); }
  .bubble-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .system-grid { grid-template-columns: 1fr; }
  .ai-tools { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .goal-grid, .innovation-grid, .bubble-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .topbar-status { display: none; }
  .user-chip .user-meta { display: none; }
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
