/* ==========================================================================
   ChatPrisma Pult Modular Styles (Linear / Apple Light B2B SaaS Theme)
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-hover: #f8fafc;
  --panel-bg: #f8fafc;
  --panel-header: #f1f5f9;

  --border: #e2e8f0;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #94a3b8;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --indigo: #4f46e5;
  --indigo-hover: #4338ca;
  --indigo-light: #eef2ff;
  --indigo-border: #c7d2fe;

  --emerald: #10b981;
  --emerald-light: #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-dark: #047857;

  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;
  --amber-dark: #b45309;

  --rose: #e11d48;
  --rose-light: #fff1f2;
  --rose-border: #fecdd3;
  --rose-dark: #be123c;

  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-light: #eff6ff;
  --blue-border: #bfdbfe;
  --blue-dark: #1e40af;

  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --purple-border: #ddd6fe;
  --purple-dark: #6d28d9;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: 20px clamp(12px, 3vw, 36px) 60px;
}

.mono {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}

/* ==========================================================================
   APP WINDOW SHELL & HEADER
   ========================================================================== */
.app-window {
  max-width: 1520px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: #fcfdfe;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.window-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--indigo-light);
  color: var(--indigo);
  border: 1px solid var(--indigo-border);
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.nav-tab {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  background: transparent;
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.7);
}

.nav-tab.active {
  background: var(--bg-surface);
  color: var(--indigo);
  box-shadow: var(--shadow-xs);
}

.nav-tab-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.nav-tab.active .nav-tab-badge {
  background: var(--indigo-light);
  color: var(--indigo);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Status Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.pill.ok {
  background: var(--emerald-light);
  color: var(--emerald-dark);
  border-color: var(--emerald-border);
}

.pill.ok::before {
  background: var(--emerald);
}

.pill.bad {
  background: var(--rose-light);
  color: var(--rose-dark);
  border-color: var(--rose-border);
}

.pill.bad::before {
  background: var(--rose);
}

.pill.info {
  background: var(--blue-light);
  color: var(--blue-dark);
  border-color: var(--blue-border);
}

.pill.info::before {
  background: var(--blue);
}

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

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

/* Buttons */
.button, .btn {
  background: var(--indigo);
  color: #ffffff;
  border: 1px solid var(--indigo);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: var(--transition);
}

.button:hover, .btn:hover {
  background: var(--indigo-hover);
  border-color: var(--indigo-hover);
}

.button.secondary, .btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.button.secondary:hover, .btn-secondary:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.button.outline, .btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.button.outline:hover, .btn-outline:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.button.sm, .btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

/* Sub-header / Status Strip */
.sub-strip {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.sub-strip-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.sub-strip-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Workspace Main Container */
.app-workspace {
  background: var(--bg-surface);
  min-height: 720px;
  position: relative;
}

.pult-view {
  display: none;
}

.pult-view.active {
  display: block;
}

/* ==========================================================================
   COMMON COMPONENTS: CARDS, GRIDS, EMPTY STATES, INSPECTOR
   ========================================================================== */
.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  background: #fafbfc;
  margin: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-muted);
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 580px;
  line-height: 1.5;
}

.empty-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.val-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  display: inline-block;
  color: var(--text-main);
}

/* Summary Grid */
.summary-strip {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

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

.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.summary-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Split Layout with Inspector */
.workspace-split {
  display: grid;
  grid-template-columns: 1fr 440px;
  min-height: 760px;
}

@media (max-width: 1080px) {
  .workspace-split {
    grid-template-columns: 1fr;
  }
}

.split-main {
  padding: 24px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.split-sidebar {
  background: #fafbfc;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

/* ==========================================================================
   VIEW 0: HYPOTHESES HADI & 6-STAGE PIPELINE
   ========================================================================== */
.hadi-container {
  padding: 24px clamp(16px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.pipeline-progress-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  background: var(--bg-subtle);
  padding: 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

@media (max-width: 900px) {
  .pipeline-progress-bar {
    grid-template-columns: repeat(3, 1fr);
  }
}

.pipeline-step {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition);
}

.pipeline-step.active {
  border-color: var(--indigo);
  background: var(--indigo-light);
}

.pipeline-step.done {
  border-color: var(--emerald-border);
  background: var(--emerald-light);
}

.pipeline-step-num {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.pipeline-step.active .pipeline-step-num {
  color: var(--indigo);
}

.pipeline-step.done .pipeline-step-num {
  color: var(--emerald-dark);
}

.pipeline-step-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.hypotheses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.hypothesis-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.hypothesis-card:hover {
  border-color: var(--indigo-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.hypothesis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hypothesis-id {
  font-size: 13px;
  font-weight: 800;
  color: var(--indigo);
  font-family: 'JetBrains Mono', monospace;
}

.hypothesis-sector {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.hypothesis-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.hypothesis-state {
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Hypothesis Detail View */
.detail-view {
  padding: 24px clamp(16px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.detail-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.honesty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.honesty-card {
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.honesty-card.ok {
  border-color: var(--emerald-border);
  background: #fcfdfd;
}

.honesty-card.warn {
  border-color: var(--amber-border);
  background: #fffdfa;
}

.honesty-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Architect Section */
.architect-section {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.architect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

/* ==========================================================================
   VIEW 1: BLOCKMAP ARCHITECTURE & LAYERS
   ========================================================================== */
.blockmap-container {
  display: flex;
  flex-direction: column;
}

.blockmap-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  min-width: 260px;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 2px var(--indigo-border);
}

.layer-group {
  margin-bottom: 24px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.layer-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.layer-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layer-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

.layer-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.layer-blocks-grid {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.block-node {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
  position: relative;
}

.block-node:hover {
  border-color: var(--indigo-border);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.block-node.active-block {
  border: 2px solid var(--indigo);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.block-node.active-block::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--indigo);
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

.block-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.block-id-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.block-node.active-block .block-id-tag {
  color: var(--indigo);
}

.block-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.block-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.block-footer-meta {
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid #f8fafc;
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.entry-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--emerald-light);
  color: var(--emerald-dark);
  border: 1px solid var(--emerald-border);
  text-transform: uppercase;
}

/* Inter-layer Connectors */
.layer-connector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 0;
}

.connector-line {
  height: 1px;
  background: var(--border);
  flex: 1;
}

.connector-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
}

/* Block Inspector Sidebar */
.inspector-title-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
}

.inspector-block-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.attributes-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.attr-row {
  display: flex;
  align-items: flex-start;
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  gap: 10px;
}

.attr-row:last-child {
  border-bottom: none;
}

.attr-key {
  width: 120px;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-muted);
}

.attr-val {
  flex: 1;
  font-weight: 500;
  color: var(--text-main);
  word-break: break-all;
}

/* ==========================================================================
   VIEW 2: ORDERS FLOW (COMMERCIAL PIPELINE)
   ========================================================================== */
.orders-container {
  display: flex;
  flex-direction: column;
}

.orders-context-bar {
  padding: 16px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.context-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.context-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.context-metrics {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.metric-pill {
  display: flex;
  flex-direction: column;
  background: var(--bg-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.metric-pill-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-pill-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

/* 9-stage Pipeline Stepper */
.order-stepper {
  padding: 20px 24px;
  background: #fcfdfe;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  overflow-x: auto;
}

@media (max-width: 1200px) {
  .order-stepper {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stage-step {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
  cursor: pointer;
}

.stage-step:hover {
  border-color: var(--border-strong);
}

.stage-step.active {
  border-color: var(--blue-border);
  background: var(--blue-light);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.stage-step.done {
  border-color: var(--emerald-border);
  background: #fcfefe;
}

.stage-badge-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.stage-step.active .stage-badge-num {
  background: var(--blue);
  color: #ffffff;
}

.stage-step.done .stage-badge-num {
  background: var(--emerald-light);
  color: var(--emerald-dark);
  border: 1px solid var(--emerald-border);
}

.stage-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

/* Orders List & Table */
.orders-table-wrapper {
  padding: 20px 24px;
  overflow-x: auto;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.orders-table th {
  background: var(--bg-subtle);
  padding: 10px 14px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.orders-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.orders-table tr:hover td {
  background: #f8fafc;
}

/* ==========================================================================
   VIEW 3: FUNNEL & DROP-OFF CONVERSION ANALYTICS
   ========================================================================== */
.funnel-view-container {
  padding: 24px clamp(16px, 3vw, 36px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Persistent Demo Banner (Warning) */
.demo-warning-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #92400e;
  font-size: 13px;
  font-weight: 600;
}

.demo-warning-banner strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Funnel Header Intro */
.funnel-intro-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.funnel-intro-strip h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.funnel-intro-strip p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 760px;
  margin-top: 4px;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.kpi-value.blue { color: var(--blue); }
.kpi-value.indigo { color: var(--indigo); }
.kpi-value.emerald { color: var(--emerald-dark); }
.kpi-value.purple { color: var(--purple-dark); }
.kpi-value.rose { color: #e11d48; }
.kpi-value.amber { color: #d97706; }
.kpi-value.teal { color: #0d9488; }
.kpi-value.sky { color: #0284c7; }

.kpi-subtext {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 5-Step Funnel Bars */
.funnel-bars-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-xs);
}

.funnel-step-row {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 960px) {
  .funnel-step-row {
    grid-template-columns: 1fr;
  }
}

.funnel-bar {
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  box-shadow: var(--shadow-xs);
}

.funnel-bar.step-1 { background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%); width: 100%; color: #ffffff; }
.funnel-bar.step-2 { background: linear-gradient(135deg, #e11d48 0%, #be123c 100%); width: 100%; color: #ffffff; }
.funnel-bar.step-3 { background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%); width: 100%; color: #ffffff; }
.funnel-bar.step-4 { background: linear-gradient(135deg, #9333ea 0%, #7e22ce 100%); width: 100%; color: #ffffff; }
.funnel-bar.step-5 { background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%); width: 100%; color: #ffffff; }
.funnel-bar.step-6 { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); width: 100%; color: #ffffff; }
.funnel-view-container .funnel-bars-container .funnel-bar.step-client {
  background: #e2e8f0 !important;
  border: 1px solid #94a3b8;
  color: #0f172a !important;
  width: 100%;
}
.funnel-view-container .funnel-bars-container .funnel-bar.step-client .funnel-bar-title,
.funnel-view-container .funnel-bars-container .funnel-bar.step-client .funnel-bar-val {
  color: #0f172a !important;
  opacity: 1;
}
.funnel-view-container .funnel-bars-container .funnel-bar.step-client .funnel-bar-sub {
  color: #334155 !important;
  opacity: 1;
}
.checkpoint-age {
  margin-top: 4px;
  color: #475569;
  font-size: 11px;
  white-space: nowrap;
}

.funnel-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.funnel-bar-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.funnel-bar-val {
  font-size: 18px;
  font-weight: 800;
}

.funnel-bar-sub {
  font-size: 11px;
  opacity: 0.9;
}

.dropoff-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dropoff-metric {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--rose-dark);
}

.dropoff-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================================================
   AUTH MODAL DIALOG
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-dialog {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.auth-error {
  color: var(--rose-dark);
  font-size: 12px;
  font-weight: 600;
}

/* ==========================================================================
   DIRECTIONS & STAGES PIPELINE (SECRETARY FUNNELS)
   ========================================================================== */

.directions-view-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.directions-intro-strip {
  padding: 24px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 18px;
}

.directions-header-text h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 4px;
}

.directions-header-text p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  max-width: 680px;
}

.direction-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.direction-meta-bar {
  padding: 12px 28px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.direction-meta-left {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Horizontal Stages Kanban Board */
.stages-board {
  display: flex;
  gap: 16px;
  padding: 24px 28px;
  overflow-x: auto;
  min-height: 480px;
  align-items: flex-start;
}

.stage-column {
  flex: 0 0 320px;
  min-width: 300px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  box-shadow: var(--shadow-xs);
}

.stage-column-header {
  padding: 14px 16px;
  background: var(--panel-header);
  border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.stage-column-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-column-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-count-pill {
  font-weight: 700;
  font-size: 11px;
}

.stage-column-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stage-tasks-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.stage-empty-slot {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

/* Task Cards */
.stage-task-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  cursor: pointer;
}

.stage-task-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.stage-task-card.important {
  border-left: 3px solid var(--amber);
}

.stage-task-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.stage-task-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
}

.stage-task-snippet {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.stage-task-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  gap: 8px;
}

.stage-task-date {
  font-size: 11px;
  color: var(--text-muted);
}

.stage-task-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Journal Timeline */
.journal-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.journal-entry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-xs);
}

.journal-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}

.journal-entry-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.journal-entry-date {
  font-size: 11px;
  color: var(--text-muted);
}

.journal-entry-content {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}

.task-detail-section {
  display: flex;
  flex-direction: column;
}

