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

:root {
  /* ── Backgrounds ── */
  --bg:       #191b1e;
  --surface:  #1f2226;
  --surface2: #272b30;
  --surface3: #31363c;

  /* ── Borders ── */
  --border:      #363b42;
  --border-warm: #424850;

  /* ── Accent — sage / muted olive ── */
  --accent:       #7d9b76;
  --accent-dim:   rgba(125,155,118,0.12);
  --accent-glow:  rgba(125,155,118,0.18);
  --accent-light: #9ab893;

  /* ── Plan colours — earthy triad ── */
  --starter:    #7d9b76;   /* sage green  */
  --pro:        #9ba8b0;   /* cool stone  */
  --enterprise: #6b8fa8;   /* dusty slate */

  /* ── Semantic ── */
  --green: #7d9b76;
  --red:   #b87c6a;

  /* ── Text ── */
  --text:       #e4e8ec;
  --text-muted: #7a8390;
  --text-dim:   #9aa0a8;

  /* ── Misc ── */
  --radius:    14px;
  --radius-sm: 8px;

  /* ── Noise texture seed ── */
  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  height: 100vh;
  overflow: hidden;
}

/* Warm grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse 80% 50% at 10% 100%, rgba(125,155,118,0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 0%,   rgba(196,168,130,0.04) 0%, transparent 60%),
    linear-gradient(rgba(125,155,118,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125,155,118,0.015) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Subtle grain noise */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: var(--grain);
  background-size: 256px 256px;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

.dashboard {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  padding: 16px 24px 12px;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 18px var(--accent-glow);
}

.brand-icon svg { width: 22px; height: 22px; }

.brand-text h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand-text p {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 4px;
}

.toggle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.toggle-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-light);
  box-shadow: 0 0 10px var(--accent-glow);
}

.divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  position: relative;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.25s;
  border-radius: 1px;
}

.kpi-card:hover {
  border-color: var(--border-warm);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3), 0 0 16px var(--accent-glow);
}

.kpi-card:hover::before { opacity: 0.6; }

.kpi-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.kpi-value {
  font-family: 'DM Mono', monospace;
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin: 6px 0 8px;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.kpi-delta.up {
  color: var(--green);
  background: rgba(125,155,118,0.12);
}

.kpi-delta.down {
  color: var(--red);
  background: rgba(184,124,106,0.12);
}

.kpi-delta.warn {
  color: var(--pro);
  background: rgba(155,168,176,0.12);
}

.kpi-sublabel {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* KPI card info btn */
.kpi-card .info-btn {
  position: absolute;
  top: 14px;
  right: 14px;
}

/* ── CHARTS GRID ── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 10px;
  position: relative;
  transition: border-color 0.2s;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-card:hover {
  border-color: var(--border-warm);
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.chart-title {
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.01em;
}

.chart-subtitle {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  letter-spacing: 0.03em;
}

.chart-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ── TOOLTIP / QUESTION MARK ── */
.info-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s;
  line-height: 1;
}

.info-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.info-btn .tooltip {
  visibility: hidden;
  opacity: 0;
  position: fixed;
  width: 220px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  line-height: 1.6;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 12px var(--accent-glow);
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  text-align: left;
}

.info-btn .tooltip::before {
  content: '';
  position: absolute;
  right: 6px;
  top: -5px;
  width: 8px;
  height: 8px;
  background: var(--surface2);
  border-left: 1px solid var(--accent);
  border-top: 1px solid var(--accent);
  transform: rotate(45deg);
}

.info-btn.tooltip-visible .tooltip {
  visibility: visible;
  opacity: 1;
}

/* ── LEGEND ── */
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── GAUGE SECTION ── */
.gauge-grid {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.gauge-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}

.gauge-wrap canvas {
  width: 90% !important;
  flex: 1;
  min-height: 0;
}

.gauge-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
}

.gauge-value {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.3px;
}

.gauge-name {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── FOOTER ── */
footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

footer p {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  font-style: italic;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--accent-light);
  font-family: 'DM Mono', monospace;
}

.live-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--accent); }
  50% { opacity: 0.4; box-shadow: none; }
}

/* ── FADE IN ── */
.fade-in {
  animation: fadeIn 0.6s ease forwards;
  opacity: 0;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.12s; }
.kpi-card:nth-child(3) { animation-delay: 0.19s; }
.kpi-card:nth-child(4) { animation-delay: 0.26s; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  header { flex-direction: column; align-items: flex-start; }
}

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