:root {
  --bg-base: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1e293b;
  --bg-surface-hover: #273549;
  --border-subtle: #1e293b;
  --border-strong: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --brand-orange: #ff6600;
  --brand-orange-hover: #e65c00;
  --brand-orange-subtle: rgba(255, 102, 0, 0.12);
  --color-success: #10b981;
  --color-success-subtle: rgba(16, 185, 129, 0.12);
  --color-danger: #ef4444;
  --color-danger-subtle: rgba(239, 68, 68, 0.12);
  --color-info: #0ea5e9;
  --color-info-subtle: rgba(14, 165, 233, 0.12);
  --color-warning: #f59e0b;
  --color-warning-subtle: rgba(245, 158, 11, 0.12);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button:focus {
  outline: none;
}

button:focus-visible {
  outline: 2px solid var(--brand-orange);
  outline-offset: 1px;
}

/* App Header */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark-img {
  height: 32px;
  width: auto;
  display: block;
}

.brand-mark {
  background: var(--brand-orange);
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: -0.5px;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--color-info-subtle);
  color: var(--color-info);
  border: 1px solid rgba(14, 165, 233, 0.25);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--color-success);
}

.btn-drawer-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--brand-orange);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.15s ease;
}

.btn-drawer-trigger:hover {
  background-color: var(--brand-orange-hover);
}

/* Scorecard Strip */
.scorecards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px 24px 8px 24px;
}

.kpi-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

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

.kpi-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-feature-settings: "tnum";
}

.kpi-delta {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 2px;
}

.kpi-delta.positive { color: var(--color-success); }
.kpi-delta.negative { color: var(--color-danger); }
.kpi-delta.neutral { color: var(--color-info); }

.kpi-subtext {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Nav Tabs */
.nav-tab-bar {
  display: flex;
  gap: 4px;
  padding: 8px 24px 0 24px;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-base);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--brand-orange);
  border-bottom-color: var(--brand-orange);
  font-weight: 600;
}

/* Workspace Views */
.workspace-content {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-panel.active {
  display: flex;
}

/* Grid Layouts */
.grid-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

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

.panel-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* Data Tables */
.data-table-wrap {
  overflow-x: auto;
}

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

.data-table th {
  background-color: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.tag-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.tag-badge.danger {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.tag-badge.success {
  background: var(--color-success-subtle);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.tag-badge.info {
  background: var(--color-info-subtle);
  color: var(--color-info);
  border: 1px solid rgba(14, 165, 233, 0.2);
}

/* Chart Canvas */
.chart-wrapper {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Map Canvas */
#malaysia-map {
  height: 560px;
  width: 100%;
  border-radius: 6px;
  background-color: #0d131f;
}

/* BQCA Drawer / Assistant */
.bqca-drawer {
  position: fixed;
  top: 0;
  right: -520px;
  width: 520px;
  height: 100vh;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bqca-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface-elevated);
}

.drawer-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
}

.drawer-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}

.drawer-close-btn:hover {
  color: var(--text-primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* BQCA Context Strip */
.drawer-context-strip {
  background-color: #0b1528;
  border-bottom: 1px solid #1e3a8a;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.context-strip-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.context-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.context-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #38bdf8;
  font-family: var(--font-mono);
}

.context-strip-body {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px dashed rgba(56, 189, 248, 0.25);
  font-family: var(--font-mono);
}

/* Quick Prompt Chips */
.quick-chips-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.quick-chips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quick-chips-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.quick-chips-hint {
  font-size: 9px;
  color: var(--text-muted);
}

.quick-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 14px;
  text-align: left;
  line-height: 1.3;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--brand-orange);
  background-color: rgba(255, 102, 0, 0.1);
  color: #ffffff;
}

/* Chat Messages */
.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12px;
}

.chat-msg.user {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  align-self: flex-end;
  max-width: 90%;
  color: var(--text-primary);
}

.chat-msg.agent {
  background-color: #0b1324;
  border: 1px solid #1e3a8a;
  align-self: flex-start;
  width: 100%;
}

.trace-details {
  background-color: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 4px;
  overflow: hidden;
}

.trace-details.thought {
  border-color: rgba(56, 189, 248, 0.3);
}

.trace-details.sql {
  border-color: rgba(168, 85, 247, 0.3);
}

.trace-summary {
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  background-color: rgba(255, 255, 255, 0.02);
}

.trace-details.thought .trace-summary {
  color: #38bdf8;
}

.trace-details.sql .trace-summary {
  color: #c084fc;
}

.trace-body {
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  line-height: 1.45;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
}

.trace-body.sql-code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #93c5fd;
  background-color: #050811;
}

.sql-code-box {
  background-color: #080c14;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #38bdf8;
  overflow-x: auto;
  white-space: pre-wrap;
  margin: 6px 0;
}

.agent-summary {
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 12px;
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-elevated);
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background-color: var(--bg-base);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
}

.chat-input:focus {
  outline: 2px solid var(--brand-orange);
  outline-offset: 1px;
}

.btn-send {
  background-color: var(--brand-orange);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.btn-send:hover {
  background-color: var(--brand-orange-hover);
}

/* Responsive adjustments */
@media (max-width: 960px) {
  .grid-2col, .grid-equal-2col {
    grid-template-columns: 1fr;
  }
  .bqca-drawer {
    width: 100%;
    right: -100%;
  }
}

/* ============================================================================
   Google Maps InfoWindow Dark Enterprise Card Overrides
   ============================================================================ */
.gm-style .gm-style-iw-c {
  padding: 0 !important;
  border-radius: 12px !important;
  background-color: #0f172a !important;
  border: 1px solid #1e293b !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.75), 0 8px 10px -6px rgba(0, 0, 0, 0.6) !important;
  max-width: 300px !important;
  max-height: none !important;
  overflow: hidden !important;
}

.gm-style .gm-style-iw-d {
  overflow: visible !important;
  padding: 0 !important;
  max-height: none !important;
}

/* Hide Google Maps top header bar that pushes content down */
.gm-style .gm-style-iw-chr {
  position: absolute !important;
  top: 6px !important;
  right: 6px !important;
  z-index: 20 !important;
  height: auto !important;
  padding: 0 !important;
}

.gm-style .gm-style-iw-ch {
  display: none !important;
}

/* Style the close button as a clean floating dark pill */
.gm-style .gm-ui-hover-effect {
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 50% !important;
  width: 26px !important;
  height: 26px !important;
  top: 0 !important;
  right: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  backdrop-filter: blur(6px);
  opacity: 0.95 !important;
  transition: background 0.15s ease, transform 0.15s ease;
}

.gm-style .gm-ui-hover-effect:hover {
  background: #ff6600 !important;
  border-color: #ff6600 !important;
  transform: scale(1.05);
}

.gm-style .gm-ui-hover-effect > span {
  background-color: #f8fafc !important;
  margin: 0 !important;
}

/* InfoWindow Bottom Pointer Arrow in Dark Slate */
.gm-style .gm-style-iw-tc::after {
  background: #0f172a !important;
}

.map-popup-card {
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, sans-serif);
  color: #f8fafc;
  width: 280px;
  background: #0f172a;
  overflow: hidden;
  box-sizing: border-box;
}

.map-popup-hero {
  position: relative;
  width: 100%;
  height: 108px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  overflow: hidden;
  border-bottom: 1px solid #1e293b;
}

.map-popup-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.25s ease;
}

.map-popup-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.2) 55%, rgba(15, 23, 42, 0.3) 100%);
  pointer-events: none;
}

.map-popup-badge-row {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}

.map-popup-body {
  padding: 10px 12px 12px 12px;
}

.map-popup-title {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}

.map-popup-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
}

.map-popup-competitors {
  background: #131c31;
  border: 1px solid #1e293b;
  border-radius: 7px;
  padding: 6px 8px;
  margin-top: 6px;
}

.map-popup-comp-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  margin-bottom: 4px;
}

.map-popup-comp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.map-popup-comp-chip {
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 4px;
  padding: 3px 5px;
  text-align: center;
}

.map-popup-comp-name {
  display: block;
  font-size: 9px;
  color: #94a3b8;
  font-weight: 500;
}

.map-popup-comp-dist {
  display: block;
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  font-weight: 700;
  color: #e2e8f0;
  margin-top: 1px;
}

.map-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 10px;
  color: #64748b;
}


/* ============================================================================
   Data provenance: real (Google Maps) vs illustrative datasets
   ============================================================================ */
.provenance-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  padding: 8px 24px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.provenance-banner strong {
  color: var(--text-primary);
  font-weight: 600;
}

.prov-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}

.prov-dot.real { background: #34a853; }
.prov-dot.illustrative { background: transparent; border: 1.5px dashed #94a3b8; }

.panel-tag.src-real {
  font-family: var(--font-sans);
  background: rgba(52, 168, 83, 0.12);
  color: #6ee7a0;
  border-color: rgba(52, 168, 83, 0.35);
}

.panel-tag.src-illustrative {
  font-family: var(--font-sans);
  background: transparent;
  color: #94a3b8;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  font-weight: 500;
}

/* Forecast mechanics explainer */
.forecast-mechanics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.fm-step {
  display: flex;
  gap: 10px;
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px 14px;
}

.fm-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 102, 0, 0.15);
  color: #ff8533;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fm-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.fm-body {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (max-width: 1200px) {
  .forecast-mechanics { grid-template-columns: repeat(2, 1fr); }
}

/* Presenter mode: slightly larger type for boardroom screens */
.exec-mode .tab-btn { font-size: 13px; }
.exec-mode .panel-title { font-size: 15px; }

/* Branch 3-month outlook */
.bf-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.bf-card { background: #0b1120; border: 1px solid #1e293b; border-radius: 8px; padding: 10px 12px; }
.bf-label { font-size: 10.5px; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.bf-value { font-size: 20px; font-weight: 700; color: #f8fafc; margin: 4px 0 2px; }
.bf-sub { font-size: 11px; color: #94a3b8; line-height: 1.45; }
.bf-note { font-size: 10.5px; color: #64748b; margin-top: 8px; }
.bf-loading { font-size: 11.5px; color: #94a3b8; padding: 14px 0; }
.bf-error { font-size: 11.5px; color: #f43f5e; padding: 12px; border: 1px dashed #7f1d1d; border-radius: 8px; }
@media (max-width: 1100px) { .bf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ============================================================================
   UI review pass: shared helpers, Customer Voice, drawer, branch selector
   ============================================================================ */
:root {
  --bg-hover: var(--bg-surface-hover);
  --border-color: var(--border-strong);
  --color-danger-strong: #fca5a5;
}

button:focus { outline: none; }
button:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand-orange);
  outline-offset: 1px;
}

.grid-2col > *, .grid-equal-2col > * { min-width: 0; }

.panel-meta { font-size: 12px; color: var(--text-muted); }
.panel-meta.is-error { color: var(--color-danger-strong); }
.panel-note { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.muted { color: var(--text-muted); font-size: 12px; }
.text-danger { color: var(--color-danger-strong); font-size: 12px; }
.panel-error, .table-error {
  color: var(--color-danger-strong);
  font-size: 12px;
  padding: 12px;
  border: 1px dashed rgba(239, 68, 68, 0.4);
  border-radius: 6px;
}
.table-error { border-radius: 0; text-align: center; }
.table-loading { color: var(--text-muted); text-align: center; padding: 18px !important; }

.tag-badge.neutral {
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.tag-badge.error {
  background: var(--color-danger-subtle);
  color: var(--color-danger-strong);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-pill.is-down .status-dot { background-color: var(--color-danger); }
.status-pill.is-down { color: var(--color-danger-strong); }

/* Sentiment tiles */
.sent-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sent-tile {
  background: #0b1120;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
}
.sent-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.sent-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-feature-settings: "tnum"; }
.sent-value.pos { color: var(--color-success); }
.sent-value.neu { color: var(--text-secondary); }
.sent-value.neg { color: #f87171; }
.churn-signal {
  background: rgba(127, 29, 29, 0.25);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
}
.churn-signal-title { font-size: 12px; font-weight: 700; color: var(--color-danger-strong); margin-bottom: 4px; }
.churn-signal-body { font-size: 12.5px; color: var(--text-primary); line-height: 1.5; }

/* Live review analyser */
.live-review { display: flex; flex-direction: column; gap: 10px; }
.live-review-row { display: flex; gap: 10px; align-items: stretch; }
.live-review-input {
  flex: 1;
  min-height: 64px;
  resize: vertical;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  padding: 10px 12px;
}
.btn-primary-lg {
  background: var(--brand-orange);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-primary-lg:hover { background: var(--brand-orange-hover); }
.btn-primary-lg:disabled { opacity: 0.6; cursor: progress; }
.field-hint { font-size: 12px; color: var(--color-warning); }
.live-review-result {
  background: #0b1120;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lr-chips { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12px; }
.lr-k { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-right: 4px; }
.lr-line { font-size: 13px; color: var(--text-primary); line-height: 1.5; }
.lr-action { color: #fdba74; }

/* Review log table */
.review-log { table-layout: fixed; }
.review-log td { vertical-align: top; font-size: 12.5px; line-height: 1.45; }
.review-log .stars { color: #fbbf24; white-space: nowrap; }
.cell-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cell-cause { color: var(--text-secondary); }
.cell-action { color: #fdba74; }
.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.clamp-3.expanded { -webkit-line-clamp: unset; display: block; }

/* Map legend and branch selector */
.map-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); flex-wrap: wrap; }
#malaysia-map { isolation: isolate; }
#branch-deep-dive-section { scroll-margin-top: 80px; display: flex; flex-direction: column; gap: 16px; }
.branch-selector { border-left: 3px solid var(--brand-orange); }
.branch-selector-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.branch-selector-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.branch-selector-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.select-sm { flex: 0 0 auto; width: 170px; }
.select-branch { flex: 0 1 auto; width: 320px; max-width: 100%; }
.branch-reviews-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }

/* Drawer message parts */
.bqca-drawer { max-width: 90vw; }
.agent-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.agent-name { font-size: 12px; font-weight: 700; color: var(--brand-orange); }
.agent-timer { font-size: 11px; color: var(--text-muted); font-feature-settings: "tnum"; }
.agent-working { font-size: 12px; color: var(--text-secondary); }
.agent-summary { font-size: 13px; }
.agent-summary p { margin: 0 0 8px 0; }
.agent-summary ul { margin: 0 0 8px 18px; padding: 0; }
.agent-summary code { font-family: var(--font-mono); font-size: 11.5px; background: #0b1120; padding: 1px 4px; border-radius: 3px; }
.user-context { font-size: 11px; color: rgba(255, 255, 255, 0.75); margin-top: 4px; }
.followup-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin: 10px 0 6px; }
.followup-chip { text-align: left; }

/* Presenter mode */
.exec-mode .exec-hide { display: none !important; }
.exec-mode .branch-bottom-row { grid-template-columns: 1fr; }
.exec-mode .panel-tag,
.exec-mode .tag-badge,
.exec-mode .kpi-label,
.exec-mode .kpi-subtext,
.exec-mode .data-table th,
.exec-mode .bf-label,
.exec-mode .bf-note,
.exec-mode .fm-body,
.exec-mode .provenance-banner { font-size: 12px; }
.exec-mode .data-table { font-size: 13px; }
[hidden] { display: none !important; }

/* Drawer readability */
.context-title, .quick-chips-title { font-family: var(--font-sans); font-size: 11px; }
.context-strip-body { font-family: var(--font-sans); font-size: 12.5px; color: var(--text-primary); border-style: solid; }
.chip-btn { font-size: 12px; }
.chat-msg.agent .data-table th { font-size: 10.5px; white-space: nowrap; padding: 8px 10px; }
.chat-msg.agent .data-table td { white-space: nowrap; padding: 8px 10px; font-size: 12px; }
.tag-badge { white-space: nowrap; }
.agent-summary .agent-subhead { font-weight: 700; color: var(--text-primary); margin-top: 10px; }

.exec-mode .tab-btn:not([data-exec="1"]) { display: none; }

/* Loaders */
.chart-loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(17, 24, 39, 0.82);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}
.chart-loader.is-error { color: var(--color-danger-strong); }
.chart-loader.is-error .spinner { display: none; }
#malaysia-map { position: relative; }
.spinner {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 102, 0, 0.25);
  border-top-color: var(--brand-orange);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.bf-loading { display: flex; align-items: center; gap: 10px; }
#branch-deep-dive-section .panel-box,
#branch-deep-dive-section .kpi-card { transition: opacity 0.2s ease; }
#branch-deep-dive-section.is-loading .panel-box:not(.branch-selector) { opacity: 0.55; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ============================================================================
   Chat panel: docked beside the dashboard on wide screens, overlay below 1280px
   ============================================================================ */
:root { --chat-w: 520px; }
.bqca-drawer { width: var(--chat-w); right: calc(-1 * var(--chat-w) - 8px); }
.bqca-drawer.open { right: 0; }
body.chat-docked { padding-right: var(--chat-w); transition: padding-right 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
body.chat-docked .bqca-drawer { box-shadow: none; max-width: none; }
body.chat-resizing, body.chat-resizing * { cursor: col-resize !important; user-select: none !important; }
body.chat-resizing, body.chat-resizing .bqca-drawer { transition: none !important; }

.drawer-resize-grip {
  position: absolute; left: -4px; top: 0; bottom: 0; width: 8px;
  cursor: col-resize; z-index: 2; display: none;
}
body.chat-docked .drawer-resize-grip { display: block; }
.drawer-resize-grip::after {
  content: ""; position: absolute; left: 3px; top: 50%; width: 2px; height: 40px;
  margin-top: -20px; border-radius: 2px; background: var(--border-strong); transition: background 0.15s ease;
}
.drawer-resize-grip:hover::after, .drawer-resize-grip:focus-visible::after,
body.chat-resizing .drawer-resize-grip::after { background: var(--brand-orange); }
.drawer-resize-grip:focus { outline: none; }

/* Header button while a question is running, and after an unseen answer lands */
.btn-drawer-trigger { position: relative; }
.btn-drawer-trigger.is-busy { background-color: #9a3d00; font-feature-settings: "tnum"; }
.btn-drawer-trigger.is-busy:hover { background-color: #b34700; }
.trigger-dot {
  display: none; position: absolute; top: -4px; right: -4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--color-success); border: 2px solid var(--bg-surface);
}
.btn-drawer-trigger.has-answer .trigger-dot { display: block; }

.answer-toast {
  position: fixed; right: 24px; top: 64px; z-index: 250;
  display: flex; align-items: center; gap: 12px; max-width: 420px;
  padding: 12px 14px; border-radius: 8px;
  background: var(--bg-surface-elevated); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--color-success); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 13px;
}
.answer-toast[hidden] { display: none; }
.answer-toast-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.answer-toast-text span { color: var(--text-secondary); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.answer-toast .btn-send { padding: 6px 12px; font-size: 12px; }

/* Live steps while the agent works */
.agent-steps { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.agent-steps li { display: flex; gap: 8px; align-items: baseline; color: var(--text-secondary); }
.agent-steps li::before { content: ""; flex: 0 0 6px; height: 6px; border-radius: 50%; background: var(--color-success); transform: translateY(-1px); }
.agent-steps li.is-current { color: var(--text-primary); }
.agent-steps li.is-current::before { background: var(--brand-orange); animation: step-pulse 1s ease-in-out infinite; }
.agent-steps .step-detail { color: var(--text-muted); font-size: 11px; }
.agent-steps .step-time { margin-left: auto; color: var(--text-muted); font-size: 11px; font-feature-settings: "tnum"; }
@keyframes step-pulse { 50% { opacity: 0.35; } }
.agent-cancel { align-self: flex-start; margin-top: 8px; padding: 4px 10px; font-size: 11px; }
.chat-input:disabled, .btn-send:disabled { opacity: 0.55; cursor: not-allowed; }

/* Charts returned by the agent */
.agent-chart { margin-top: 8px; padding: 10px 8px 6px; border: 1px solid var(--border-subtle); border-radius: 6px; background: #0d1526; min-height: 60px; }
.agent-chart .vega-embed { width: 100%; }
.agent-chart-error { font-size: 12px; color: var(--text-muted); }
.data-toggle { align-self: flex-start; margin-top: 6px; padding: 4px 10px; font-size: 11px; }

@media (max-width: 960px) {
  .bqca-drawer { width: 100%; max-width: none; right: -100%; }
  .answer-toast { left: 12px; right: 12px; max-width: none; }
}

/* Persona views */
.persona-banner {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 20px;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--brand-orange);
  border-radius: 8px;
  padding: 14px 20px;
}
.persona-role { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.persona-owns { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.4; }
.persona-qs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.persona-qs-label { width: 100%; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.persona-q {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  color: var(--text-primary);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 7px 14px;
  cursor: pointer;
  max-width: 100%;
}
.persona-q:hover { border-color: var(--brand-orange); background-color: var(--brand-orange-subtle); }
.persona-q:focus { outline: none; }
.persona-q:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 1px; }
.tab-panel .scorecards-container.persona-kpis { padding: 0; grid-template-columns: repeat(4, 1fr); }
.persona-kpis .kpi-value { font-size: 24px; }

.mnp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.mnp-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
}
.mnp-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.mnp-net { font-size: 26px; font-weight: 700; font-feature-settings: "tnum"; margin: 6px 0 4px; }
.mnp-net.pos { color: var(--color-success); }
.mnp-net.neg { color: var(--color-danger); }
.mnp-split { font-size: 12px; color: var(--text-secondary); }
.status-pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.status-pill.warn { background: var(--color-warning-subtle); color: var(--color-warning); }
.status-pill.bad { background: var(--color-danger-subtle); color: var(--color-danger); }
.status-pill.ok { background: var(--color-success-subtle); color: var(--color-success); }

@media (max-width: 1100px) {
  .persona-banner { grid-template-columns: 1fr; }
  .tab-panel .scorecards-container.persona-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* State demand map (Commercial & Marketing) */
.demand-map-wrap { position: relative; height: 470px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border-subtle); }
#demand-map { position: absolute; inset: 0; background-color: var(--bg-base); }
.demand-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-secondary); }
.demand-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.state-side { gap: 14px; }
.state-card { display: flex; flex-direction: column; gap: 10px; }
.state-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.state-card-name { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.state-card-sub { font-size: 12px; color: var(--text-muted); }
.state-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.state-metric { background-color: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 8px 10px; }
.state-metric-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.state-metric-value { font-size: 16px; font-weight: 700; color: var(--text-primary); font-feature-settings: "tnum"; margin-top: 2px; }
.state-metric-note { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.state-action { font-size: 13px; line-height: 1.5; color: var(--text-primary); background-color: var(--bg-surface-elevated); border-left: 3px solid var(--brand-orange); border-radius: 4px; padding: 8px 10px; }
.state-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.state-btn { font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; border-radius: 6px; padding: 7px 12px; cursor: pointer; border: 1px solid var(--border-strong); background-color: var(--bg-surface-elevated); color: var(--text-primary); }
.state-btn.primary { background-color: var(--brand-orange); border-color: var(--brand-orange); color: #ffffff; }
.state-btn:hover { border-color: var(--brand-orange); }
.state-btn:focus { outline: none; }
.state-btn:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 1px; }
.state-rank-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.state-rank-row { display: flex; justify-content: space-between; gap: 8px; width: 100%; font-family: var(--font-sans); font-size: 13px; color: var(--text-primary); background: none; border: none; border-bottom: 1px solid var(--border-subtle); padding: 6px 4px; border-radius: 4px; cursor: pointer; text-align: left; }
.state-rank-row:hover { color: var(--brand-orange); }
.state-rank-row.is-selected { background-color: var(--brand-orange-subtle); color: var(--brand-orange); font-weight: 600; }
.state-rank-row:focus { outline: none; }
.state-rank-row:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 1px; }
.state-rank-row span:last-child { color: var(--text-secondary); font-feature-settings: "tnum"; }
.table-reset { font-family: var(--font-sans); font-size: 12px; color: var(--brand-orange); background: none; border: none; cursor: pointer; padding: 0; margin-left: 8px; }
.table-reset:hover { text-decoration: underline; }
.table-reset:focus { outline: none; }
.table-reset:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 1px; }

/* Retention panel */
.retention-panel { display: flex; flex-direction: column; gap: 14px; }
.ret-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ret-stat { background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 12px 14px; }
.ret-stat-value { font-size: 22px; font-weight: 600; color: var(--text-primary); font-feature-settings: "tnum"; }
.ret-stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.ret-body { gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
.ret-sub-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; }
.ret-ask { font-family: var(--font-sans); font-size: 12px; color: var(--brand-orange); background: var(--brand-orange-subtle); border: 1px solid var(--brand-orange); border-radius: 12px; padding: 2px 10px; }
.ret-ask:hover { background: var(--brand-orange); color: var(--text-primary); }
.ret-ask:focus { outline: none; }
.ret-ask:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 1px; }
@media (max-width: 1100px) { .ret-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Saved & Pinned Sessions Bar in Ask the Data Drawer */
.drawer-session-bar {
  padding: 10px 16px;
  background-color: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.session-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.session-bar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.select-session {
  width: 100%;
  font-size: 12.5px;
  padding: 6px 10px;
  background-color: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
}
.select-session:focus { outline: none; }
.select-session:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 1px; }
.btn-pin-session {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  transition: all 0.15s ease;
}
.btn-pin-session:focus { outline: none; }
.btn-pin-session:focus-visible { outline: 2px solid var(--brand-orange); outline-offset: 1px; }
.btn-pin-session.is-pinned {
  background-color: var(--brand-orange-subtle);
  border-color: var(--brand-orange);
  color: var(--brand-orange);
}
.agent-steps.saved-steps {
  margin: 0 0 6px 0;
  padding-left: 18px;
}

