/* =====================================================================
   VSP Diligence OS — Global Stylesheet
   Calibrated to the existing LBO portal aesthetic (Vintage Stone brand).
   Dense, partner-grade Excel feel. Serif headers, sans body, gold + navy.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700&family=Cormorant+SC:wght@400;500;600&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Primary palette — locked to LBO portal */
  --gold: #A8884A;
  --gold-lt: #C9AA72;
  --gold-dk: #7A6234;
  --gold-08: rgba(168, 136, 74, 0.08);
  --gold-15: rgba(168, 136, 74, 0.15);
  --gold-18: rgba(168, 136, 74, 0.18);
  --gold-30: rgba(168, 136, 74, 0.30);

  --navy: #1A2C3D;
  --navy-lt: #2A3D52;
  --navy-dk: #0F1E2D;
  --navy-faint: rgba(26, 44, 61, 0.05);

  --ink-mid: #4A443C;
  --ink-soft: #6A645C;
  --ink-faint: #8A8278;

  --cream: #F5F0E5;
  --cream-2: #EDE8DF;
  --cream-3: #E5DFD3;
  --cream-4: #DCD5C7;

  /* Sentiment */
  --positive: #5C7A4A;
  --neutral: #8A7040;
  --negative: #8A5040;
  --positive-bg: rgba(92, 122, 74, 0.08);
  --neutral-bg: rgba(138, 112, 64, 0.10);
  --negative-bg: rgba(138, 80, 64, 0.08);
  --warning-bg: rgba(138, 112, 64, 0.10);

  /* Status — agent states */
  --status-idle: #8A8278;
  --status-queued: #8A7040;
  --status-running: #4A7A8A;
  --status-running-bg: rgba(74, 122, 138, 0.10);
  --status-done: #5C7A4A;
  --status-error: #8A5040;
  --status-blocked: #5A4A6A;

  /* Structural */
  --rule: rgba(168, 136, 74, 0.30);
  --rule-light: rgba(168, 136, 74, 0.12);
  --rule-dim: rgba(168, 136, 74, 0.06);

  --shadow-faint: 0 1px 0 rgba(26, 44, 61, 0.04);
  --shadow-soft: 0 4px 12px rgba(26, 44, 61, 0.10);
  --shadow-deep: 0 12px 32px rgba(26, 44, 61, 0.20);

  /* Typography */
  --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sc: 'Cormorant SC', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Layout */
  --sidebar-w: 220px;
  --header-h: 56px;
  --rail-left-w: 200px;
  --rail-right-w: 320px;
  --drawer-w: 40vw;
  --drawer-min-w: 480px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-mid);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.4;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--navy);
  color: var(--cream);
  padding: 10px 16px;
  z-index: 10000;
}
.skip-link:focus { left: 0; }

/* ==== Typography ==== */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  color: var(--navy);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.005em;
}
h1 { font-size: 28px; line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.15; }
h3 { font-size: 16px; line-height: 1.2; font-weight: 500; }
h4 { font-size: 13px; line-height: 1.25; font-weight: 600; }
h5 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; }

.sc-label {
  font-family: var(--font-sc);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 500;
}
.sc-label.muted { color: var(--ink-faint); }
.sc-label.navy { color: var(--navy); }

/* ==== App layout ==== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ==== Sidebar ==== */
.sidebar {
  background: var(--navy);
  color: var(--cream);
  padding: 18px 0 12px;
  border-right: 1px solid var(--gold-15);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  padding: 0 18px 20px;
  border-bottom: 1px solid rgba(168, 136, 74, 0.18);
  margin-bottom: 12px;
}
.sidebar-brand .brand-mark {
  font-family: var(--font-sc);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--gold);
  margin-bottom: 4px;
}
.sidebar-brand .brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.05;
  color: var(--cream);
  font-weight: 400;
}
.sidebar-brand .brand-name em {
  font-style: italic;
  color: var(--gold-lt);
}
.sidebar-brand .brand-sub {
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.nav-section { padding: 8px 0 6px; }
.nav-section-title {
  font-family: var(--font-sc);
  font-size: 9px;
  letter-spacing: 0.25em;
  color: rgba(201, 170, 114, 0.55);
  padding: 0 18px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px;
  color: rgba(245, 240, 229, 0.78);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 13px;
  border-left: 2px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s ease;
}
.nav-item:hover {
  color: var(--cream);
  background: rgba(168, 136, 74, 0.06);
  text-decoration: none;
}
.nav-item.active {
  color: var(--gold-lt);
  background: rgba(168, 136, 74, 0.10);
  border-left-color: var(--gold);
}
.nav-item .nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  background: rgba(168, 136, 74, 0.10);
  padding: 1px 5px;
  border-radius: 2px;
}
.nav-item.active .nav-badge { color: var(--gold-lt); background: rgba(168, 136, 74, 0.18); }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(168, 136, 74, 0.12);
  font-family: var(--font-ui);
  font-size: 10px;
  color: var(--ink-faint);
}
.sidebar-footer .ws-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.sidebar-footer .ws-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--status-idle);
}
.sidebar-footer .ws-dot.connected { background: var(--positive); box-shadow: 0 0 6px var(--positive); }
.sidebar-footer .ws-dot.reconnecting { background: var(--neutral); animation: pulse 1.2s infinite ease-in-out; }
.sidebar-footer .ws-dot.disconnected { background: var(--negative); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ==== App header (deal context bar) ==== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--cream);
  border-bottom: 1px solid var(--rule);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  min-width: 0;
}
.app-header .header-crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sc);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
  min-width: 0;
}
.app-header .header-crumbs a { color: var(--gold-dk); }
.app-header .header-crumbs .crumb-sep { color: var(--ink-faint); }
.app-header .header-deal {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--navy);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .header-deal em { color: var(--gold-dk); font-style: italic; }
.app-header .header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-soft);
  padding-left: 14px;
  border-left: 1px solid var(--rule-light);
}
.app-header .header-user .user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--cream);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sc);
  font-size: 10px;
  letter-spacing: 0.08em;
  border: 1px solid var(--gold-30);
}

/* ==== Main area ==== */
.main {
  background: var(--cream);
  padding: 22px 28px 60px;
  flex: 1;
  min-width: 0;
}
.main.flush { padding: 0; }
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  gap: 18px;
  flex-wrap: wrap;
}
.view-header .view-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--navy);
  font-weight: 500;
}
.view-header .view-sub {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 4px;
}
.view-header .view-actions { display: flex; gap: 8px; align-items: center; }

/* ==== Buttons ==== */
.btn {
  font-family: var(--font-sc);
  font-size: 9px;
  letter-spacing: 0.2em;
  padding: 7px 13px;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold-dk);
  cursor: pointer;
  text-transform: uppercase;
  font-weight: 500;
  transition: all 0.12s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--gold-08); color: var(--gold-dk); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: var(--cream); border-color: var(--gold); }
.btn.primary:hover { background: var(--gold-dk); border-color: var(--gold-dk); }
.btn.navy { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.btn.navy:hover { background: var(--navy-lt); }
.btn.ghost { border-color: var(--rule); color: var(--ink-soft); }
.btn.ghost:hover { background: var(--cream-3); border-color: var(--gold-30); color: var(--ink-mid); }
.btn.danger { color: var(--negative); border-color: var(--negative); }
.btn.danger:hover { background: var(--negative-bg); }
.btn.sm { padding: 4px 9px; font-size: 8px; }
.btn.xs { padding: 2px 6px; font-size: 8px; letter-spacing: 0.15em; }
.btn.icon-only { padding: 6px 8px; }

.btn-group {
  display: inline-flex;
  border: 1px solid var(--rule);
}
.btn-group .btn {
  border: none;
  border-right: 1px solid var(--rule);
  background: var(--cream-2);
}
.btn-group .btn:last-child { border-right: none; }
.btn-group .btn.active { background: var(--gold); color: var(--cream); }

/* ==== Cards ==== */
.card {
  background: var(--cream-2);
  border: 1px solid var(--gold-15);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.card.tight { padding: 12px 16px; margin-bottom: 10px; }
.card.flush { padding: 0; }
.card-title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--navy);
  font-weight: 500;
  margin-bottom: 4px;
}
.card-subtitle {
  font-family: var(--font-sc);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--gold);
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule-light);
}
.card-header h3 { margin: 0; }
.card-divider { height: 1px; background: var(--rule-light); margin: 12px 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }

/* ==== KPI tile ==== */
.kpi-tile {
  background: var(--cream-2);
  border: 1px solid var(--gold-15);
  padding: 14px 16px;
}
.kpi-tile .kpi-label {
  font-family: var(--font-sc);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--gold);
  margin-bottom: 6px;
}
.kpi-tile .kpi-value {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--navy);
  font-weight: 500;
  line-height: 1;
}
.kpi-tile .kpi-sub {
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 4px;
  font-style: italic;
}
.kpi-tile.dark { background: var(--navy); border-color: var(--gold-30); }
.kpi-tile.dark .kpi-label { color: var(--gold-lt); }
.kpi-tile.dark .kpi-value { color: var(--cream); }
.kpi-tile.dark .kpi-sub { color: rgba(245, 240, 229, 0.70); }

/* ==== Form fields ==== */
.field { display: block; margin-bottom: 12px; }
.field-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field-input, .field-select, .field-textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--gold-15);
  background: var(--cream);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--navy);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  border-radius: 0;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold-08);
}
.field-textarea { min-height: 80px; resize: vertical; font-family: var(--font-body); }
.field-help { font-size: 11px; color: var(--ink-faint); margin-top: 3px; font-style: italic; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.field-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

select.field-input, .field-select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 24px;
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--gold); }

.search-input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--gold-15);
  background: var(--cream) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A8278' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 10px center no-repeat;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--navy);
}
.search-input:focus { outline: none; border-color: var(--gold); }

/* ==== Tables ==== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 12px;
}
.data-table th {
  font-family: var(--font-sc);
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--gold-dk);
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--rule);
  font-weight: 500;
  background: transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table th.sortable:hover { color: var(--gold); }
.data-table th.sortable .sort-ind { opacity: 0.4; margin-left: 4px; font-size: 8px; }
.data-table th.sortable.sorted .sort-ind { opacity: 1; color: var(--gold); }
.data-table th.numeric, .data-table td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule-light);
  color: var(--ink-mid);
}
.data-table tbody tr { transition: background 0.08s; }
.data-table tbody tr:hover { background: var(--cream-3); cursor: pointer; }
.data-table tbody tr.selected { background: var(--gold-08); }
.data-table td.primary { font-family: var(--font-display); color: var(--navy); font-size: 14px; font-weight: 500; }

/* ==== Status pills ==== */
.pill {
  display: inline-block;
  font-family: var(--font-sc);
  font-size: 9px;
  letter-spacing: 0.16em;
  padding: 2px 8px;
  border: 1px solid;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
}
.pill.ok { color: var(--positive); border-color: var(--positive); background: var(--positive-bg); }
.pill.warn { color: var(--neutral); border-color: var(--neutral); background: var(--warning-bg); }
.pill.bad { color: var(--negative); border-color: var(--negative); background: var(--negative-bg); }
.pill.gold { color: var(--gold-dk); border-color: var(--gold); background: var(--gold-08); }
.pill.navy { color: var(--navy); border-color: var(--navy); background: var(--navy-faint); }
.pill.ghost { color: var(--ink-soft); border-color: var(--rule); background: transparent; }
.pill.solid-navy { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.pill.solid-gold { background: var(--gold); color: var(--cream); border-color: var(--gold); }

.stage-pill {
  display: inline-block;
  font-family: var(--font-sc);
  font-size: 9px;
  letter-spacing: 0.16em;
  padding: 3px 10px;
  color: var(--cream);
  text-transform: uppercase;
  line-height: 1.4;
}
.stage-pill[data-stage="screen"] { background: #6A7A8A; }
.stage-pill[data-stage="ioi"] { background: #5A6A8A; }
.stage-pill[data-stage="lol"] { background: #5A8A8A; }
.stage-pill[data-stage="dd"] { background: var(--gold); }
.stage-pill[data-stage="ic"] { background: var(--navy); }
.stage-pill[data-stage="close"] { background: var(--positive); }
.stage-pill[data-stage="passed"] { background: var(--negative); }
.stage-pill[data-stage="dead"] { background: var(--ink-faint); }

/* ==== Tabs ==== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}
.tab {
  padding: 9px 18px;
  font-family: var(--font-sc);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.12s;
  text-transform: uppercase;
}
.tab:hover { color: var(--ink-mid); }
.tab.active { color: var(--gold-dk); border-bottom-color: var(--gold); }

/* ==== Empty state ==== */
.empty {
  background: var(--cream-2);
  border: 1px dashed var(--gold-30);
  padding: 50px 30px;
  text-align: center;
  color: var(--ink-faint);
}
.empty h3 { color: var(--navy); margin-bottom: 6px; }
.empty p { color: var(--ink-soft); margin: 0 0 18px; font-family: var(--font-body); font-size: 14px; }

/* ==== Loading ==== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--ink-faint);
}
.loading-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--rule);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  margin-top: 14px;
  font-family: var(--font-sc);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
}

.skeleton {
  background: linear-gradient(90deg, var(--cream-2) 25%, var(--cream-3) 50%, var(--cream-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 2px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton.line { height: 12px; margin-bottom: 8px; }
.skeleton.line.short { width: 40%; }
.skeleton.line.mid { width: 70%; }
.skeleton.block { height: 80px; }

/* ==== Toast ==== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--navy);
  color: var(--cream);
  padding: 11px 16px;
  border: 1px solid var(--gold);
  font-family: var(--font-ui);
  font-size: 13px;
  z-index: 9000;
  box-shadow: var(--shadow-soft);
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.18s ease-out;
}
.toast.success { border-color: var(--positive); }
.toast.error { border-color: var(--negative); }
.toast.warn { border-color: var(--neutral); }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ==== Modal ==== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 44, 61, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  animation: fadeIn 0.12s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--cream);
  border: 1px solid var(--gold);
  padding: 26px 30px;
  width: 520px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-deep);
}
.modal h2 { margin-bottom: 6px; }
.modal-sub { font-family: var(--font-body); font-style: italic; color: var(--gold-dk); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ==== Drawer (citation) ==== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 44, 61, 0.40);
  z-index: 7000;
  animation: fadeIn 0.12s ease-out;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--drawer-w);
  min-width: var(--drawer-min-w);
  max-width: 760px;
  background: var(--cream);
  border-left: 1px solid var(--gold);
  box-shadow: -8px 0 24px rgba(26, 44, 61, 0.18);
  z-index: 7001;
  display: flex;
  flex-direction: column;
  animation: slideLeft 0.18s ease-out;
}
@keyframes slideLeft { from { transform: translateX(20px); opacity: 0.5; } to { transform: translateX(0); opacity: 1; } }

/* ==== Tooltip ==== */
.tip {
  position: absolute;
  background: var(--navy);
  color: var(--cream);
  padding: 6px 10px;
  font-family: var(--font-ui);
  font-size: 11px;
  border: 1px solid var(--gold);
  max-width: 260px;
  z-index: 9500;
  pointer-events: none;
  line-height: 1.4;
  box-shadow: var(--shadow-soft);
}

/* ==== Misc utilities ==== */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.italic { font-style: italic; }
.muted { color: var(--ink-faint); }
.dim { color: var(--ink-soft); }
.numeric { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.no-wrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

/* ==== Filter bar ==== */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-bar .field-select,
.filter-bar .field-input {
  width: auto;
  min-width: 140px;
  padding: 5px 22px 5px 8px;
  font-size: 12px;
}
.filter-bar .search-input { min-width: 240px; }

/* ==== Cost badge ==== */
.cost-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-dk);
  background: var(--gold-08);
  border: 1px solid var(--gold-15);
  padding: 2px 6px;
  border-radius: 2px;
}
.cost-badge .cost-icon { font-size: 9px; color: var(--gold); }
.cost-badge.warn { color: var(--neutral); border-color: var(--neutral); background: var(--warning-bg); }
.cost-badge.bad { color: var(--negative); border-color: var(--negative); background: var(--negative-bg); }

/* ==== Confidence bar ==== */
.conf-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-soft);
}
.conf-bar .conf-track {
  width: 60px;
  height: 4px;
  background: var(--cream-3);
  border-radius: 2px;
  overflow: hidden;
}
.conf-bar .conf-fill {
  height: 100%;
  background: var(--gold);
  transition: width 0.2s;
}
.conf-bar .conf-fill.low { background: var(--negative); }
.conf-bar .conf-fill.mid { background: var(--neutral); }
.conf-bar .conf-fill.high { background: var(--positive); }

/* ==== Status dot ==== */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--status-idle);
  flex-shrink: 0;
}
.status-dot[data-status="idle"] { background: var(--status-idle); }
.status-dot[data-status="queued"] { background: var(--status-queued); }
.status-dot[data-status="running"] { background: var(--status-running); box-shadow: 0 0 6px var(--status-running); animation: pulse 1s infinite; }
.status-dot[data-status="done"] { background: var(--status-done); }
.status-dot[data-status="error"] { background: var(--status-error); }
.status-dot[data-status="blocked"] { background: var(--status-blocked); }

/* ==== Section header ==== */
.section-header {
  margin-top: 16px;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule-light);
}

/* ==== Print ==== */
@media print {
  .sidebar, .app-header, .view-header .view-actions,
  .drawer, .drawer-overlay, .modal-overlay, .toast,
  .btn, .right-rail, .left-rail { display: none !important; }
  .app-shell { grid-template-columns: 1fr !important; }
  .main { padding: 20px !important; }
  .card { break-inside: avoid; page-break-inside: avoid; }
}
