:root, [data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-card: #111;
  --bg-hover: #1a1a1a;
  --border: #222;
  --text: #e5e5e5;
  --text-dim: #666;
  --text-muted: #444;
  --accent: #B8EE41;
  --accent-dim: rgba(184, 238, 65, 0.15);
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --chart-grid: #1a1a1a;
  --chart-label: #444;
  --sparkline: #B8EE41;
  --sparkline-fill: rgba(184, 238, 65, 0.15);
  --td-border: rgba(255,255,255,0.03);
  --glass-bg: rgba(10, 10, 10, 0.75);
  --glass-border: rgba(255,255,255,0.06);
  --glass-blur: 20px;
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-card: #fff;
  --bg-hover: #f0f0f0;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-dim: #888;
  --text-muted: #aaa;
  --accent: #4a9c00;
  --accent-dim: rgba(74, 156, 0, 0.1);
  --danger: #dc2626;
  --chart-grid: #eee;
  --chart-label: #999;
  --sparkline: #4a9c00;
  --sparkline-fill: rgba(74, 156, 0, 0.1);
  --td-border: rgba(0,0,0,0.04);
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(0,0,0,0.08);
  --glass-blur: 20px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-card p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-card input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.login-card input:focus { border-color: var(--accent); }

.login-card button {
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-card button:hover { opacity: 0.9; }
.login-card button:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
}

/* Layout */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

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

.header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

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

.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.mode-switch button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.mode-switch button.active {
  background: var(--accent);
  color: #000;
}

/* Select / Dropdown */
select {
  appearance: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

select:focus { border-color: var(--accent); }

.date-range-control {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.date-range-control input {
  width: 126px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  outline: none;
  color-scheme: dark;
}

[data-theme="light"] .date-range-control input {
  color-scheme: light;
}

.date-range-control span {
  color: var(--text-dim);
  font-size: 11px;
}

/* ============================
   HERO: Globe + Floating Sidebar
   ============================ */
.hero {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 500px;
  max-height: 800px;
  margin-bottom: 24px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #050505;
}

[data-theme="light"] .hero {
  background: #050505;
}

.globe-container {
  position: absolute;
  inset: 0;
  z-index: 0;
}

[data-theme="light"] .globe-container {
}

.globe-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Globe HUD — right side overlay */
.globe-hud {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 2;
  text-align: right;
}

.globe-hud-count {
  font-size: 48px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 0 30px rgba(184, 238, 65, 0.3);
}

.globe-hud-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ============================
   SIDEBARS (floating over globe)
   ============================ */
.sidebar {
  position: absolute;
  top: 16px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
}

.sidebar-left {
  left: 0;
  width: 220px;
}

.sidebar-left .sidebar-metric {
  flex: 1;
  min-height: 0;
}

.sidebar-right {
  right: 0;
  width: 260px;
}

.sidebar-right {
  /* Traffic + Top Pages, each fills proportionally */
}

.sidebar-right .sidebar-chart {
  flex: 5;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-right .sidebar-chart .sidebar-chart-container {
  flex: 1;
  min-height: 0;
}

.sidebar-right .sidebar-section {
  flex: 5;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.sidebar-right .sidebar-section::-webkit-scrollbar { width: 4px; }
.sidebar-right .sidebar-section::-webkit-scrollbar-track { background: transparent; }
.sidebar-right .sidebar-section::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

.sidebar-metric {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 12px;
}

[data-theme="light"] .sidebar-metric {
  background: rgba(0, 0, 0, 0.45);
}

.sidebar-metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.sidebar-metric .label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-metric .value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.sidebar-metric .value.accent { color: var(--accent); }

.sidebar-metric .value-sm {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.sidebar-metric-compact {
  flex: 0 0 auto;
}

/* Sparkline */
.sparkline-wrap {
  margin-top: 8px;
  height: 28px;
}

.sparkline-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Sidebar Chart */
.sidebar-chart {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 12px;
}

[data-theme="light"] .sidebar-chart {
  background: rgba(0, 0, 0, 0.45);
}

.sidebar-chart-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sidebar-chart-container {
  width: 100%;
  height: 120px;
  position: relative;
}

.sidebar-chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Sidebar Sections (compact lists) */
.sidebar-section {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 12px;
}

[data-theme="light"] .sidebar-section {
  background: rgba(0, 0, 0, 0.45);
}

.sidebar-section-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sidebar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}

.sidebar-row-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  padding-right: 8px;
}

.sidebar-row-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}

.sidebar-empty {
  text-align: center;
  padding: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ============================
   TABLES (below hero)
   ============================ */
.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.table-card::-webkit-scrollbar { width: 4px; }
.table-card::-webkit-scrollbar-track { background: transparent; }
.table-card::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

.table-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.table-card table {
  width: 100%;
  border-collapse: collapse;
}

.table-card th {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.table-card th:last-child,
.table-card td:last-child {
  text-align: right;
}

.table-card td {
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--td-border);
}

.table-card td:first-child {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-cell { position: relative; }

.bar-bg {
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  background: var(--accent-dim);
  border-radius: 3px;
  z-index: 0;
}

.bar-text {
  position: relative;
  z-index: 1;
  padding-left: 6px;
}

/* Chart Card (legacy) */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.chart-card .chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
}

/* ============================
   FUNNELS
   ============================ */
.funnels-section {
  margin-bottom: 24px;
}

.funnels-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.funnels-header h3 {
  font-size: 14px;
  font-weight: 600;
}

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

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

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

.funnel-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.funnel-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.funnel-delete:hover { color: var(--danger); }

.funnel-overall-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.funnel-canvas-wrap {
  width: 100%;
  height: 240px;
  position: relative;
}

.funnel-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Realtime indicator */
.realtime {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.realtime-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Button */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: all 0.2s;
}

.btn:hover { background: var(--bg-hover); }
.btn-accent {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.btn-accent:hover { opacity: 0.9; background: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
}

.modal h3 { font-size: 16px; margin-bottom: 16px; }

.modal input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}

.modal input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 14px;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

/* App Ops */
.app-ops {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.ops-loading {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text-dim);
  font-size: 13px;
}

.ops-error {
  color: var(--danger);
}

.ops-page-head {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.ops-page-head h2 {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 700;
  margin: 6px 0;
}

.ops-page-head p {
  color: var(--text-dim);
  font-size: 12px;
}

.ops-status-pill {
  min-width: 170px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
  background: rgba(255,255,255,0.02);
}

.ops-status-pill span {
  font-size: 16px;
  font-weight: 700;
}

.ops-status-pill small {
  color: var(--text-dim);
  font-size: 11px;
}

.ops-status-pill.status-critical { border-color: rgba(239, 68, 68, 0.55); background: rgba(239, 68, 68, 0.08); }
.ops-status-pill.status-warning { border-color: rgba(245, 158, 11, 0.55); background: rgba(245, 158, 11, 0.08); }
.ops-status-pill.status-unavailable { border-color: var(--text-muted); }

.ops-decision-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ops-decision-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ops-decision-card.primary {
  border-color: rgba(184, 238, 65, 0.45);
  background: linear-gradient(180deg, var(--accent-dim), transparent 70%);
}

.ops-decision-card strong {
  font-size: 18px;
  line-height: 1.18;
}

.ops-decision-card p {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
}

.ops-hero {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.ops-status-card,
.ops-metric,
.ops-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ops-status-card {
  padding: 22px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 3px solid var(--accent);
}

.ops-status-card.status-critical { border-left-color: var(--danger); }
.ops-status-card.status-warning { border-left-color: #f59e0b; }
.ops-status-card.status-unavailable { border-left-color: var(--text-muted); }

.ops-kicker,
.ops-metric .label,
.ops-panel-header span {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.ops-status-title {
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -1px;
}

.ops-status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ops-status-meta span {
  color: var(--text-dim);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}

.ops-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ops-metric {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 124px;
}

.ops-metric strong {
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.8px;
}

.ops-metric small {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
}

.ops-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.ops-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 12px;
}

.ops-section-head h3 {
  font-size: 15px;
  font-weight: 700;
}

.ops-section-head span {
  color: var(--text-dim);
  font-size: 12px;
}

.growth-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.growth-target-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.growth-target-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.growth-target-title span {
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.8px;
}

.growth-target-title small {
  color: var(--text-dim);
  font-size: 13px;
}

.growth-target-input {
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.growth-target-input span {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.growth-target-input input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
  padding: 10px 12px;
}

.growth-metrics {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.growth-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.growth-step {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--accent);
}

.growth-step.alert-critical { background: var(--danger); }
.growth-step.alert-warning { background: #f59e0b; }
.growth-step.alert-info { background: var(--accent); }

.growth-funnel-table th:nth-child(2),
.growth-funnel-table td:nth-child(2),
.growth-funnel-table th:nth-child(4),
.growth-funnel-table td:nth-child(4) {
  min-width: 250px;
}

.growth-funnel-table th:nth-child(3),
.growth-funnel-table td:nth-child(3) {
  min-width: 96px;
}

.funnel-progress-row {
  display: grid;
  grid-template-columns: 112px minmax(128px, 1fr);
  align-items: center;
  gap: 10px;
}

.funnel-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.funnel-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.funnel-progress-fill.alert-critical { background: var(--danger); }
.funnel-progress-fill.alert-warning { background: #f59e0b; }
.funnel-progress-fill.alert-info { background: var(--accent); }

.funnel-progress-row span {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.funnel-gap {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.funnel-gap.zero {
  color: var(--text-dim);
}

.growth-assumptions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.growth-assumptions span {
  color: var(--text-dim);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}

.ops-panel {
  padding: 18px;
  min-height: 260px;
  overflow: hidden;
}

.ops-panel-wide {
  grid-column: span 1;
}

.ops-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ops-panel-header h3 {
  font-size: 14px;
  font-weight: 650;
}

.ops-chart-wrap {
  height: 210px;
}

.ops-chart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.ops-alert-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ops-scroll {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.ops-scroll::-webkit-scrollbar,
.ops-table-scroll::-webkit-scrollbar { width: 4px; height: 4px; }
.ops-scroll::-webkit-scrollbar-track,
.ops-table-scroll::-webkit-scrollbar-track { background: transparent; }
.ops-scroll::-webkit-scrollbar-thumb,
.ops-table-scroll::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 2px; }

.ops-alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ops-alert strong {
  font-size: 13px;
}

.ops-alert span {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
}

.ops-alert.alert-critical { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.08); }
.ops-alert.alert-warning { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.08); }
.ops-alert.alert-info { border-color: var(--border); background: rgba(255,255,255,0.02); }

.ops-panel table {
  width: 100%;
  border-collapse: collapse;
}

.ops-table-scroll {
  max-height: 340px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.ops-panel th {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ops-panel td {
  padding: 9px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--td-border);
}

.ops-panel th:last-child,
.ops-panel td:last-child {
  text-align: right;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--text-dim);
  font-size: 11px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--accent);
}

.legend-dot.acked { background: #22c55e; }
.legend-dot.failed { background: #f59e0b; }

/* App Ops dashboard: four-quadrant operating view */
.ops-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.ops-business-block,
.ops-money-block {
  grid-column: span 5;
}

.ops-funnel-block {
  grid-column: span 6;
}

.ops-health-block {
  grid-column: span 4;
}

.ops-block {
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow: visible;
}

.ops-block-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.ops-block-header h2 {
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
  margin-top: 5px;
}

.ops-block-header p {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
}

.ops-inline-input {
  width: 160px;
  flex: 0 0 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ops-inline-input span,
.ops-kpi span,
.ops-action-note span {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.35px;
  text-transform: uppercase;
}

.ops-inline-input input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  padding: 9px 11px;
}

.ops-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ops-kpi-grid-health {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.ops-kpi {
  min-width: 0;
  min-height: 102px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255,255,255,0.02);
}

.ops-kpi strong {
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.ops-kpi small {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.35;
}

.ops-action-note {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255,255,255,0.02);
  margin-top: 12px;
}

.ops-action-note.primary {
  border-color: rgba(184, 238, 65, 0.45);
  background: linear-gradient(180deg, var(--accent-dim), transparent 78%);
  margin-top: 0;
  margin-bottom: 12px;
}

.ops-action-note.compact {
  width: min(360px, 45%);
  margin-top: 0;
}

.ops-action-note strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.22;
  font-weight: 700;
}

.ops-action-note p {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
}

.ops-status-pill {
  min-width: 148px;
  padding: 10px 12px;
}

.ops-status-pill span {
  font-size: 14px;
}

.ops-health-block .ops-kpi-grid {
  gap: 8px;
}

.ops-health-block .ops-kpi {
  min-height: 82px;
  padding: 9px 8px;
  gap: 5px;
}

.ops-health-block .ops-kpi span {
  min-height: 21px;
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 9px;
  line-height: 1.15;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ops-health-block .ops-kpi strong {
  font-size: 19px;
}

.ops-health-block .ops-kpi small {
  min-height: 27px;
  display: -webkit-box;
  overflow: hidden;
  font-size: 10.5px;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ops-business-block,
.ops-money-block {
  padding: 14px;
}

.ops-business-block .ops-block-header,
.ops-money-block .ops-block-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
  margin-bottom: 10px;
}

.ops-business-block .ops-block-header > div:first-child,
.ops-money-block .ops-block-header > div:first-child {
  min-width: 0;
}

.ops-money-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
  min-width: 0;
}

.ops-money-summary > div {
  min-width: 0;
}

.ops-business-block .ops-block-header h2,
.ops-money-block .ops-block-header h2 {
  font-size: 20px;
  line-height: 1.08;
}

.ops-business-block .ops-block-header p,
.ops-money-block .ops-block-header p {
  font-size: 11px;
  line-height: 1.3;
  margin-top: 5px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ops-business-block .ops-source-line {
  color: var(--text-muted);
  margin-top: 2px;
}

.ops-business-block .ops-action-note,
.ops-money-block .ops-action-note {
  padding: 10px 11px;
  gap: 4px;
  margin-top: 0;
}

.ops-business-block .ops-action-note.primary {
  margin-top: 0;
  margin-bottom: 0;
}

.ops-business-block .ops-kpi-grid,
.ops-money-block .ops-kpi-grid {
  gap: 8px;
}

.ops-business-block .ops-kpi,
.ops-money-block .ops-kpi {
  min-height: 82px;
  padding: 9px 8px;
  gap: 5px;
}

.ops-business-block .ops-kpi > span,
.ops-money-block .ops-kpi > span,
.ops-business-block .ops-action-note span,
.ops-money-block .ops-action-note span,
.ops-money-block .ops-inline-input span {
  font-size: 9px;
  letter-spacing: 0.2px;
}

.ops-business-block .ops-kpi > span,
.ops-money-block .ops-kpi > span {
  min-height: 21px;
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.15;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ops-business-block .ops-kpi strong,
.ops-money-block .ops-kpi strong {
  font-size: 19px;
}

.ops-business-block .ops-kpi small,
.ops-money-block .ops-kpi small,
.ops-business-block .ops-action-note p,
.ops-money-block .ops-action-note p {
  font-size: 10.5px;
  line-height: 1.3;
}

.ops-business-block .ops-kpi small,
.ops-money-block .ops-kpi small,
.ops-business-block .ops-action-note p,
.ops-money-block .ops-action-note p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ops-business-block .ops-kpi small,
.ops-money-block .ops-kpi small {
  min-height: 27px;
}

.ops-business-block .ops-action-note strong,
.ops-money-block .ops-action-note strong {
  font-size: 14px;
  line-height: 1.18;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ops-money-block .ops-inline-input {
  width: 118px;
  flex-basis: auto;
  gap: 5px;
}

.ops-money-block .ops-inline-input input {
  font-size: 15px;
  padding: 8px 10px;
}

@media (min-width: 1181px) {
  .ops-business-block .ops-kpi-grid,
  .ops-money-block .ops-kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.ops-table-free-scroll {
  width: 100%;
  overflow: visible;
}

.ops-table-free-scroll table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
}

.growth-funnel-table th:nth-child(2),
.growth-funnel-table td:nth-child(2),
.growth-funnel-table th:nth-child(4),
.growth-funnel-table td:nth-child(4) {
  min-width: 220px;
}

.funnel-progress-row {
  grid-template-columns: minmax(88px, 1fr) 132px;
}

.funnel-progress-row span {
  text-align: right;
}

.ops-focus-grid {
  margin-top: 16px;
}

.ops-health-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.ops-subsection {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(255,255,255,0.02);
}

.ops-health-block .ops-chart-wrap {
  height: 190px;
}

.ops-health-block .ops-scroll {
  max-height: 260px;
}

.ops-health-block .ops-table-scroll {
  max-height: 320px;
  overflow: auto;
}

.ops-subsection table,
.ops-table-free-scroll table {
  width: 100%;
  border-collapse: collapse;
}

.ops-subsection th,
.ops-table-free-scroll th {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ops-subsection td,
.ops-table-free-scroll td {
  padding: 10px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--td-border);
  vertical-align: middle;
}

.ops-subsection th:not(:last-child),
.ops-subsection td:not(:last-child),
.ops-table-free-scroll th:not(:last-child),
.ops-table-free-scroll td:not(:last-child) {
  padding-right: 14px;
}

.ops-subsection th:last-child,
.ops-subsection td:last-child,
.ops-table-free-scroll th:last-child,
.ops-table-free-scroll td:last-child {
  text-align: right;
}

/* Snippet */
.snippet {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-dim);
  overflow-x: auto;
  word-break: break-all;
  white-space: pre-wrap;
  margin-top: 8px;
}

.share-bar {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Compare delta */
.delta {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.delta.up { color: var(--accent); }
.delta.down { color: var(--danger); }
.delta.neutral { color: var(--text-muted); }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* Logout button */
.logout-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}
.logout-btn:hover { color: var(--text); }

/* Responsive */
@media (max-width: 900px) {
  .hero {
    height: auto;
    min-height: 0;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: visible;
    background: transparent;
    border-radius: 0;
  }

  .sidebar {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    background: var(--bg-card);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .sidebar-left {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    order: 2;
  }

  .sidebar-left .sidebar-metric {
    flex: 1 1 45%;
  }

  .globe-container {
    position: relative;
    height: 400px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #050505;
    order: 1;
  }

  .sidebar-right {
    max-height: 400px;
    overflow-y: auto;
    order: 3;
  }

  .ops-decision-grid,
  .growth-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app { padding: 0 16px; }
  .header { padding: 12px 0; }
  .header-right {
    width: 100%;
    justify-content: flex-start;
  }
  .date-range-control {
    width: 100%;
    justify-content: space-between;
  }
  .date-range-control input {
    width: 44%;
  }
  .tables-grid { grid-template-columns: 1fr; }
  .ops-page-head {
    align-items: stretch;
    flex-direction: column;
  }
  .ops-status-pill {
    min-width: 0;
    text-align: left;
  }
  .ops-section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .ops-hero,
  .ops-grid,
  .growth-grid,
  .ops-decision-grid,
  .growth-metrics,
  .ops-metrics {
    grid-template-columns: 1fr;
  }
  .growth-target-panel {
    align-items: stretch;
    flex-direction: column;
  }
  .funnels-grid { grid-template-columns: 1fr; }
  .header-right { flex-wrap: wrap; }
}

@media (max-width: 1180px) {
  .ops-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .ops-business-block,
  .ops-money-block,
  .ops-funnel-block,
  .ops-health-block {
    grid-column: 1 / -1;
  }

  .ops-kpi-grid,
  .ops-kpi-grid-health {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ops-health-block .ops-kpi-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .ops-block-header {
    align-items: stretch;
    flex-direction: column;
  }

  .ops-action-note.compact {
    width: 100%;
  }

  .ops-inline-input {
    width: 100%;
    flex-basis: auto;
  }

  .ops-kpi-grid,
  .ops-kpi-grid-health {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ops-health-block .ops-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .growth-funnel-table thead {
    display: none;
  }

  .growth-funnel-table tbody,
  .growth-funnel-table tr,
  .growth-funnel-table td {
    display: block;
    width: 100%;
  }

  .growth-funnel-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--td-border);
  }

  .growth-funnel-table td {
    border-bottom: 0;
    padding: 5px 0;
    text-align: left;
  }

  .growth-funnel-table td:nth-child(2),
  .growth-funnel-table td:nth-child(3),
  .growth-funnel-table td:nth-child(4) {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 0;
  }

  .growth-funnel-table td:nth-child(2)::before {
    content: "Volume";
  }

  .growth-funnel-table td:nth-child(3)::before {
    content: "Gap";
  }

  .growth-funnel-table td:nth-child(4)::before {
    content: "Conversion";
  }

  .growth-funnel-table td:nth-child(2)::before,
  .growth-funnel-table td:nth-child(3)::before,
  .growth-funnel-table td:nth-child(4)::before {
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.35px;
    text-transform: uppercase;
  }
}

@media (max-width: 520px) {
  .ops-kpi-grid,
  .ops-kpi-grid-health {
    grid-template-columns: 1fr;
  }

  .ops-health-block .ops-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .funnel-progress-row {
    grid-template-columns: minmax(64px, 1fr) 116px;
    gap: 8px;
  }
}
