/* Single Dashboard Canvas Frame - Ultra Compact Vertical */
.clean-frame {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 270px 1fr;
  overflow: hidden;
}

/* Left Brief Overview Panel */
.frame-left {
  padding: 14px 14px;
  background: #fafcff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.frame-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  background: var(--soft);
  padding: 3px 8px;
  border-radius: 12px;
  margin-bottom: 6px;
}

.frame-left h1 {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--ink);
  margin-bottom: 6px;
}

.frame-desc {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  margin-bottom: 10px;
}

.frame-capabilities {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.frame-capabilities li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  line-height: 1.35;
  color: #334155;
}
.cap-dot {
  color: var(--blue);
  font-weight: 600;
  font-size: 12px;
}

.frame-action {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.custom-cta-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  transition: all .2s ease;
}
.custom-cta-btn:hover {
  background: var(--blue2);
}

/* Right Clean Dashboard Area */
.frame-right {
  padding: 12px 14px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  min-height: 0;
}
.dash-topbar { order: 1; }
.month-timeline-wrap { order: 2; }
.dash-chart-card { order: 3; flex: 1; min-height: 150px; display: flex; flex-direction: column; }
.kpi-section-wrapper { order: 4; }
#alert-panel { order: 5; }
.dash-sources-line { order: 6; }

/* Prominent Month Header & Day Timeline */
.month-timeline-wrap {
  margin-bottom: 8px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.month-tl-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.prominent-month {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}
.prominent-month span {
  color: var(--blue);
  font-weight: 600;
  font-size: 11.5px;
}
.selected-days-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--blue);
}

/* Day Track & Ticks */
.timeline {
  position: relative;
  width: 100%;
  height: 18px;
  background: #e9eff7;
  border-radius: 5px;
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
.tl-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  align-items: center;
  pointer-events: none;
}
.tl-tick {
  width: 1px;
  height: 8px;
  background: #cbd5e1;
}
.tl-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(37, 99, 235, 0.22);
  border-top: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  border-radius: 4px;
  cursor: grab;
}
.tl-range:active {
  cursor: grabbing;
}
.tl-handle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 10px;
  background: var(--blue);
  border-radius: 3px;
  transform: translateX(-50%);
  cursor: ew-resize;
  box-shadow: 0 1px 5px rgba(37, 99, 235, 0.35);
  z-index: 3;
}
.tl-handle::after {
  content: '';
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 4px;
  width: 2px;
  background: #fff;
  border-radius: 1px;
}

/* Day of Month Numbers Row under Track */
.tl-days-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 4px;
  font-size: 8px;
  font-weight: 600;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  overflow: hidden;
}
.tl-days-row span {
  flex: 1;
  text-align: center;
  min-width: 0;
}
.tl-days-row span.in-range {
  color: var(--ink);
}
.tl-days-row span.tl-day-blank {
  color: transparent;
  pointer-events: none;
}

/* Top bar */
.dash-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px solid #edf2f7;
  margin-bottom: 6px;
}
.dash-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

/* KPI Container with Vertical Mode Selector Balls */
.kpi-section-wrapper {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 8px;
  min-height: 98px; /* Fixed height to prevent layout jumping */
  touch-action: none; /* Prevents whole page scrolling when user swipes KPI cards */
}

.kpi-mode-balls {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  user-select: none;
}
.mode-ball {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #cbd5e1;
  cursor: pointer;
  transition: all .15s ease;
}
.mode-ball:hover {
  transform: scale(1.2);
}
.mode-ball.active {
  background: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* Main KPI Column with Top Month Badge / Bottom Day Stepper */
.kpi-main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Header line above KPI (shows month in monthly mode without blue bg) */
.kpi-top-meta {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  height: 18px;
}
.kpi-month-tag {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  letter-spacing: .02em;
  background: transparent;
  border: none;
  padding: 0;
}

/* Bottom day stepper under KPI (shows in daily mode) */
.kpi-bottom-stepper {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  height: 24px;
}

/* Metric Tiles (5 Clickable Cards) */
.dash-metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.d-tile {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 52px;
}
.d-tile:hover {
  border-color: var(--blue);
  background: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.08);
}
.d-tile.active {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 1.5px rgba(37, 99, 235, 0.25);
}
.d-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.d-tile small {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
}
.d-tile b {
  display: block;
  font-size: 16.5px;
  font-weight: 700;
  font-family: var(--sans), system-ui, sans-serif;
  color: var(--ink);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

/* Distinct Shape & Color Percentage Badges */
.badge-pct {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 500;
  padding: 1.5px 5px;
  border-radius: 4px;
}
.badge-green {
  background: #dcfce7;
  color: #064e3b;
  font-weight: 600;
}
.badge-red {
  background: #fee2e2;
  color: #7f1d1d;
  font-weight: 600;
}

/* Chart Canvas & Interactive Scrubber */
.dash-chart-card {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px 6px;
  margin-bottom: 6px;
  position: relative;
}
/* Chart Header */
.chart-bar-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
}
.chart-day-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chart-step-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: var(--ink);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 10.5px;
  transition: all .15s ease;
  user-select: none;
}
.chart-step-btn:hover:not(:disabled) {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.chart-step-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: #f8fafc;
}
.chart-current-day-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
}

.chart-stage-wrapper {
  position: relative;
  width: 100%;
  height: 132px;
  flex: 1;
  min-height: 110px;
  cursor: crosshair;
  touch-action: none;
}
.clean-svg {
  width: 100%;
  height: 100%;
  display: block;
}
#chart-line-path, #chart-rev-line, #chart-second-line-path, #chart-spend-line {
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
#chart-line-path, #chart-rev-line {
  stroke: var(--accent);
  stroke-width: 1.35;
}
#chart-spend-line, #chart-second-line-path {
  stroke-width: 1.2;
}
.chart-plot-mark {
  position: absolute;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  box-sizing: border-box;
}
.chart-plot-mark.mark-spend {
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  margin-top: -3.5px;
  background: #f59e0b;
}

/* Interactive Cursor and Softer Bottom Floating Tooltip */
.chart-scrubber-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(37, 99, 235, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
  z-index: 2;
}
.chart-tooltip-bubble {
  position: absolute;
  bottom: 4px;
  transform: translateX(-50%);
  background: rgba(241, 245, 249, 0.94);
  color: #1e293b;
  border: 1px solid #cbd5e1;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .12s ease, left .08s ease;
  z-index: 3;
}
.chart-tooltip-bubble span {
  color: #475569;
  font-weight: 500;
}
.chart-tooltip-bubble b {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 3px;
}

.chart-axis-hours {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  margin-top: 2px;
  border-top: 1px solid #edf2f7;
  font-size: 8.5px;
  font-weight: 600;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

/* Bottom Integrations Line */
.dash-sources-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #edf2f7;
  font: 9px var(--mono);
  color: #64748b;
}
.source-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}
.source-tags span {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  color: #334155;
  font-size: 8.5px;
}

/* Bottom Minimal Pagination */
.minimal-nav-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.m-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  cursor: pointer;
  transition: all .2s ease;
}
.m-dot.active {
  width: 22px;
  border-radius: 8px;
  background: var(--blue);
}

/* Theme Toggle Button in Header */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all .2s ease;
}
.theme-toggle-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Dark Theme Variables and Overrides - Light & High Contrast Typography */
body.dark-theme {
  --ink: #f8fafc;
  --text: #cbd5e1;
  --soft: #1e293b;
  --pale: #0f172a;
  --line: #334155;
  background: #090d16;
  color: #f8fafc;
}
body.dark-theme .theme-toggle-btn {
  border-color: #475569;
  color: #f8fafc;
}
body.dark-theme .theme-toggle-btn:hover {
  background: #1e293b;
}
body.dark-theme .clean-frame {
  background: #0f172a;
  border-color: #334155;
}
body.dark-theme .frame-left {
  background: #0d1527;
  border-right-color: #334155;
}
body.dark-theme .frame-left h1 {
  color: #ffffff;
}
body.dark-theme .frame-desc {
  color: #cbd5e1;
}
body.dark-theme .frame-capabilities li {
  color: #e2e8f0;
}
body.dark-theme .frame-capabilities li b {
  color: #ffffff;
}
body.dark-theme .frame-right {
  background: #0f172a;
}
body.dark-theme .dash-name {
  color: #ffffff;
}
body.dark-theme .prominent-month {
  color: #f1f5f9;
}
body.dark-theme .prominent-month span {
  color: #60a5fa;
}
body.dark-theme .selected-days-badge {
  color: #93c5fd;
}
body.dark-theme .tl-days-row {
  color: #cbd5e1;
}
body.dark-theme .kpi-month-tag {
  color: #93c5fd;
}
body.dark-theme .month-timeline-wrap {
  background: #162035;
  border-color: #334155;
}
body.dark-theme .timeline {
  background: #25334d;
}
body.dark-theme .tl-tick {
  background: #475569;
}
body.dark-theme .d-tile {
  background: #162035;
  border-color: #334155;
}
body.dark-theme .d-tile small {
  color: #cbd5e1;
}
body.dark-theme .d-tile b {
  color: #ffffff;
}
body.dark-theme .d-tile:hover {
  background: #1c2b47;
  border-color: var(--blue);
}
body.dark-theme .d-tile.active {
  background: #162035;
  border-color: var(--blue);
}
body.dark-theme .dash-chart-card {
  background: #141f36;
  border-color: #334155;
}
body.dark-theme .chart-bar-info {
  color: #cbd5e1;
}
body.dark-theme #active-chart-title {
  color: #ffffff !important;
}
body.dark-theme .chart-step-btn {
  background: #1e293b;
  border-color: #475569;
  color: #f8fafc;
}
body.dark-theme .chart-step-btn:hover:not(:disabled) {
  background: var(--blue);
}
body.dark-theme .chart-tooltip-bubble {
  background: rgba(15, 23, 42, 0.96);
  color: #ffffff !important;
  border-color: #475569;
}
body.dark-theme .chart-tooltip-bubble span {
  color: #cbd5e1 !important;
}
body.dark-theme .chart-tooltip-bubble b {
  color: #ffffff !important;
}
body.dark-theme .badge-green {
  background: #86efac !important;
  color: #052e16 !important;
  font-weight: 700;
}
body.dark-theme .badge-red {
  background: #fca5a5 !important;
  color: #450a0a !important;
  font-weight: 700;
}
body.dark-theme .chart-axis-hours {
  border-top-color: #334155;
  color: #cbd5e1;
}
body.dark-theme .dash-sources-line {
  border-top-color: #334155;
  color: #cbd5e1;
}
body.dark-theme .source-tags span {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}
body.dark-theme div[style*="border-top:1px dashed"] {
  border-top-color: #334155 !important;
  color: #cbd5e1 !important;
}
body.dark-theme div[style*="border-top:1px dashed"] b {
  color: #ffffff !important;
}

/* Responsive */
@media(max-width: 900px) {
  .clean-frame {
    grid-template-columns: 1fr;
  }
  .frame-left {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }
  .frame-right {
    padding: 12px;
  }
  .dash-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media(max-width: 640px) {
  .dash-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-stage-wrapper {
    height: 75px;
  }
  .chart-axis-hours span {
    font-size: 8px;
  }
  .tl-days-row {
    font-size: 8px;
    letter-spacing: 0;
  }
}
