/* ==========================================================================
   BUSINESS HEALTH DASHBOARD — "Command Center" dark theme.
   Scoped to /tools/business-dashboard.html only (body.cmd-dark).
   Status palette is fixed (never themed) per the dataviz color-formula;
   chart hues are the validated dark-mode categorical steps (blue/aqua/orange).
   ========================================================================== */

:root {
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  --cc-cash:     #3987e5;   /* validated dark categorical — blue */
  --cc-revenue:  #199e70;   /* validated dark categorical — aqua */
  --cc-expense:  #d95926;   /* validated dark categorical — orange */

  --cc-surface:  #0f2440;
  --cc-surface-2: rgba(255, 255, 255, 0.04);
  --cc-border:   rgba(0, 200, 224, 0.22);
  --cc-grid:     rgba(255, 255, 255, 0.09);
  --cc-ink:      #9db3c9;
  --cc-ink-2:    #6f8aa3;
}

/* ---------------------------------------------------------------- page bg */
body.cmd-dark {
  background:
    radial-gradient(circle at 14% 0%, rgba(0, 180, 216, 0.10), transparent 42%),
    radial-gradient(circle at 88% 18%, rgba(0, 180, 216, 0.08), transparent 46%),
    linear-gradient(180deg, #071a30 0%, #0b2545 45%, #0a2036 100%);
  color: #dce8f5;
}
body.cmd-dark .dash-header .kicker { color: var(--accent); }
body.cmd-dark .dash-header h1 { color: #fff; }
body.cmd-dark .dash-header .lede { color: var(--cc-ink); }
/* Kill the site-wide 76px section padding inside the dashboard grid */
body.cmd-dark .dash-wrap section { padding: 0; }
body.cmd-dark #contact { padding: 36px 0 48px; }

/* ----------------------------------------------------------------- layout */
.dash-header { padding: 22px 0 0; }
.dash-header h1 { font-size: 2rem; margin-bottom: 6px; }
.dash-header .lede { margin-bottom: 0; }

.dash-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
  padding: 14px 0 40px;
}

/* ---------------------------------------------------------------- controls */
.panel {
  background: var(--cc-surface-2);
  border: 1px solid var(--cc-border);
  border-radius: 14px;
  padding: 16px 16px 4px;
  position: sticky;
  top: 76px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 40px rgba(0, 180, 216, 0.06);
}
.panel h2 {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--accent);
  margin: 14px 0 4px;
}
.panel h2:first-child { margin-top: 0; }
.panel .panel-reset {
  width: 100%;
  margin: 2px 0 4px;
  background: rgba(0, 180, 216, 0.08);
  border: 1px solid var(--cc-border);
  color: #cfe6f5;
  border-radius: 8px;
  padding: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.panel .panel-reset:hover { background: rgba(0, 180, 216, 0.16); border-color: var(--accent); }

.slider-row { margin-bottom: 11px; }
.slider-row .row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.slider-row label { color: #cfe0ee; font-weight: 600; }
.slider-row .val { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #071a30;
  box-shadow: 0 0 10px 1px rgba(0, 180, 216, 0.75);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #071a30;
  box-shadow: 0 0 10px 1px rgba(0, 180, 216, 0.75);
  cursor: pointer;
}

/* ------------------------------------------------------------ card shell */
.cc-card {
  background: var(--cc-surface-2);
  border: 1px solid var(--cc-border);
  border-radius: 14px;
  padding: 14px 16px 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 30px rgba(0, 180, 216, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  position: relative;
}
/* Graph cards grow on hover (pointer devices only — no effect on touch) */
@media (hover: hover) {
  .cc-card { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
  .cc-card:hover {
    transform: scale(1.06);
    z-index: 5;
    border-color: rgba(0, 200, 224, 0.55);
    box-shadow: 0 8px 44px rgba(0, 0, 0, 0.45), 0 0 44px rgba(0, 180, 216, 0.28);
  }
}
.cc-card h3 { color: #fff; font-size: 1rem; margin-bottom: 2px; font-weight: 600; }
.cc-card .chart-note { color: var(--cc-ink); font-size: 0.78rem; margin-bottom: 6px; }
.cc-card svg { width: 100%; height: auto; display: block; overflow: visible; }
/* Neutralize the site-wide .callout banner styling from styles.css */
.cc-card .callout {
  font-size: 0.78rem;
  color: #ff9aa2;
  font-weight: 600;
  margin-top: 4px;
  background: none;
  border: none;
  padding: 0;
}
.cc-card .callout:empty { display: none; }

.section-title {
  color: #fff;
  font-size: 1.3rem;
  margin: 0 0 2px;
  font-family: Georgia, 'Times New Roman', serif;
}
.section-sub { color: var(--cc-ink); font-size: 0.88rem; margin-bottom: 10px; }

/* ------------------------------------------------------------- cc grid */
.cc-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 12px; }
.cc-col { display: flex; flex-direction: column; gap: 12px; }

.legend { display: flex; gap: 18px; margin-bottom: 6px; flex-wrap: wrap; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--cc-ink); }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; box-shadow: 0 0 6px currentColor; }

/* --------------------------------------------------------- summary tiles */
.summary-tile { display: flex; flex-direction: column; gap: 4px; }
.summary-tile .kpi-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--cc-ink-2);
}
.summary-tile .summary-value { font-size: 1.6rem; font-weight: 700; color: #fff; }
.summary-tile .summary-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.summary-tile .spark { width: 96px; height: 36px; flex-shrink: 0; }
.delta { font-size: 0.78rem; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: #43e097; }
.delta.down { color: #ff6b7a; }

/* ------------------------------------------------------------ ring gauges */
.ring-card { text-align: center; }
.ring-card svg { width: 108px !important; height: 108px; margin: 2px auto 0; display: inline-block !important; }

/* ------------------------------------------------------------------ tiles */
.kpi-block { margin-bottom: 14px; }
.kpi-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 4px;
}
.kpi-block-head h2 { color: #fff; font-size: 1.25rem; margin: 0; font-family: Georgia, 'Times New Roman', serif; }
.kpi-block-head p { color: var(--cc-ink); font-size: 0.86rem; margin: 0; }

/* Four small tiles per row so each metric group reads as one line */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi-wide { grid-column: span 2; }

.kpi-tile {
  background: var(--cc-surface-2);
  border: 1px solid var(--cc-border);
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
}
.kpi-tile .kpi-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cc-ink-2);
  margin-bottom: 5px;
}
.kpi-tile .kpi-value {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.22rem;
  color: #fff;
  line-height: 1.15;
  margin-bottom: 4px;
  text-shadow: 0 0 18px rgba(0, 180, 216, 0.25);
}
.kpi-tile .kpi-sub { font-size: 0.72rem; color: var(--cc-ink); margin-bottom: 6px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.pill.good     { background: rgba(12, 163, 12, 0.16);  color: #4ee34e; }
.pill.warning  { background: rgba(250, 178, 25, 0.16); color: var(--status-warning); }
.pill.serious  { background: rgba(236, 131, 90, 0.18); color: var(--status-serious); }
.pill.critical { background: rgba(208, 59, 59, 0.18);  color: #ff6b6b; }

/* ------------------------------------------------------------------- NPS */
.nps-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: visible;
  background: linear-gradient(to right,
    var(--status-critical) 0%, var(--status-critical) 25%,
    var(--status-warning) 25%, var(--status-warning) 62.5%,
    var(--status-good) 62.5%, var(--status-good) 100%);
  box-shadow: 0 0 14px rgba(0, 180, 216, 0.18);
}
.nps-thumb {
  position: absolute;
  top: -5px;
  width: 4px;
  height: 22px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-2px);
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.8);
}
.nps-scale { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--cc-ink); margin-top: 6px; }

/* ------------------------------------------------- fullscreen chart modal */
.fs-clickable { cursor: pointer; }

.cc-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 14, 28, 0.86);
  backdrop-filter: blur(5px);
  padding: 18px;
  cursor: pointer;                 /* whole overlay is "click to close" */
}
.cc-modal[hidden] { display: none; }

.cc-modal-card {
  width: min(1080px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: linear-gradient(180deg, #0d2342, #0a1c33);
  border: 1px solid var(--cc-border);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(0, 180, 216, 0.15);
}
.cc-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.cc-modal-head h3 { color: #fff; font-size: 1.15rem; margin: 0; font-weight: 600; }
.cc-modal .chart-note { color: var(--cc-ink); font-size: 0.8rem; margin-bottom: 8px; }
.cc-modal .legend:empty { display: none; }
.cc-modal svg { width: 100%; height: auto; display: block; overflow: visible; }

.range-picker { display: flex; gap: 6px; cursor: default; }
.range-picker button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--cc-border);
  color: #cfe6f5;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.range-picker button:hover { background: rgba(0, 180, 216, 0.18); }
.range-picker button.active {
  background: var(--accent);
  color: #071a30;
  border-color: var(--accent);
}

/* --------------------------------------------------------- responsive */
@media (max-width: 1050px) {
  .cc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .dash-wrap { grid-template-columns: 1fr; }
  .panel { position: static; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-wide { grid-column: auto; }
}
