/* Azure Infrastructure & LLM Cost Optimization — design tokens + components.
   Palette: validated reference palette (see dataviz skill references/palette.md).
   Layout language: executive summary console — header filter bar, flat KPI
   cards, horizontal tab bar, bordered surfaces for charts/tables. */

:root {
  color-scheme: light;
  --page-plane: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --success-text: #006300;

  --series-1: #2a78d6; /* blue */
  --series-2: #eb6834; /* orange */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green */
  --series-7: #4a3aa7; /* violet */
  --series-8: #e34948; /* red */
  --series-other: #c3c2b7;
  --forecast: #86b6ef;

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

  --callout-bg: #eef2fc;
  --callout-border: var(--series-1);

  --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.05);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-plane: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --success-text: #0ca30c;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #55544f;
  --forecast: #6da7ec;

  --callout-bg: #16203a;
  --callout-border: var(--series-1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page-plane: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --success-text: #0ca30c;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --series-other: #55544f;
    --forecast: #6da7ec;

    --callout-bg: #16203a;
    --callout-border: var(--series-1);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Shell ---------------- */
.exec-shell { max-width: 1280px; margin: 0 auto; padding: 24px 32px 56px; }

.exec-header { margin-bottom: 20px; }
.exec-title-row { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.exec-brand-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; color: #fff; margin-top: 2px;
  background: linear-gradient(135deg, var(--series-1), var(--series-7));
  display: flex; align-items: center; justify-content: center;
}
.exec-brand-icon svg { width: 22px; height: 22px; }
.exec-title-block { flex: 1; min-width: 0; }
.exec-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 3px; letter-spacing: -0.015em; }
.exec-subtitle { color: var(--text-muted); font-size: 0.84rem; }
.exec-subtitle-range {
  display: inline-block;
  font-weight: 700;
  color: var(--series-1);
  background: color-mix(in srgb, var(--series-1) 14%, transparent);
  border-radius: 5px;
  padding: 1px 8px;
  margin-left: 2px;
}
.exec-header .theme-toggle-mini { flex-shrink: 0; margin-top: 4px; }

.exec-filters { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }

.exec-main { max-width: 100%; }

/* ---------------- Colorful KPI cards ---------------- */
.kpi-row-flat { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  position: relative; overflow: hidden; isolation: isolate;
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 55%, #000) 100%);
  border: none; border-radius: 14px;
  padding: 16px 20px; display: flex; flex-direction: column; gap: 6px;
  color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.stat-card::before, .stat-card::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%; background: rgba(255,255,255,0.10);
}
.stat-card::before { width: 130px; height: 130px; right: -36px; top: -46px; }
.stat-card::after { width: 80px; height: 80px; right: 34px; bottom: -46px; background: rgba(255,255,255,0.07); }
.stat-top { display: flex; align-items: center; margin-bottom: 2px; }
.stat-icon-chip {
  width: 32px; height: 32px; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.22); color: #ffffff;
}
.stat-icon-chip svg { width: 15px; height: 15px; display: block; }
.stat-value-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; color: #fff; line-height: 1.15; }
.stat-footer { font-size: 0.78rem; color: rgba(255,255,255,0.85); }
.stat-label { font-weight: 600; color: rgba(255,255,255,0.95); }
.stat-compare-inline { color: rgba(255,255,255,0.78); }

/* ---------------- Cost Attribution buckets ---------------- */
.bucket-tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.bucket-tile-row .stat-card { min-height: 96px; justify-content: center; }
.bucket-tile-row .stat-value { font-size: 1.7rem; }

/* ---------------- Bottom line callout ---------------- */
.bottom-line-callout {
  display: flex; align-items: flex-start; gap: 10px; background: var(--callout-bg);
  border-left: 3px solid var(--callout-border); border-radius: 6px; padding: 12px 16px;
  font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 18px;
}
.bottom-line-icon { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; color: var(--callout-border); }
.bottom-line-icon svg { width: 16px; height: 16px; display: block; }
.bottom-line-callout strong { color: var(--text-primary); }

/* ---------------- Horizontal tab bar ---------------- */
.tab-bar-horizontal { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab-bar-item {
  display: flex; align-items: center; gap: 7px; border: none; background: none; cursor: pointer;
  padding: 10px 14px; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-bar-item:hover { color: var(--text-primary); }
.tab-bar-item[aria-selected="true"] { color: var(--series-1); border-bottom-color: var(--series-1); }
.tab-bar-icon { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tab-bar-icon svg, .btn-icon svg { width: 15px; height: 15px; display: block; }
.btn-icon { display: flex; align-items: center; justify-content: center; }

.tab-panel { display: none; padding-top: 20px; }
.tab-panel.is-active { display: block; animation: fade-in 0.12s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- Segmented control / filters ---------------- */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 7px; padding: 2px; gap: 1px; }
.segmented button {
  border: none; background: transparent; padding: 5px 11px; border-radius: 5px;
  font-size: 0.76rem; font-weight: 600; color: var(--text-secondary); cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }

.theme-toggle-mini {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-secondary); font-size: 0.78rem; font-weight: 500; padding: 6px 9px; border-radius: 6px; cursor: pointer;
}
.theme-toggle-mini:hover { background: var(--surface-2); }
.nav-item:focus-visible, .theme-toggle-mini:focus-visible, .segmented button:focus-visible,
.viz-legend-item:focus-visible, .viz-table-toggle:focus-visible, .tab-bar-item:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 1px;
}

/* ---------------- Cards / sections ---------------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px;
}
.section-title { font-size: 0.88rem; font-weight: 700; margin: 0 0 2px; display: flex; align-items: center; gap: 7px; }
.section-title-note { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.anomaly-badge {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--status-critical) 16%, transparent); color: var(--status-critical);
}
.section-caption { color: var(--text-secondary); font-size: 0.78rem; margin: 0 0 12px; }
.card-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .card-grid-2 { grid-template-columns: 1fr; } }

/* ---------------- Slim inline notice ---------------- */
.notice {
  display: flex; align-items: flex-start; gap: 8px; font-size: 0.76rem; color: var(--text-secondary);
  padding: 10px 14px; margin-bottom: 16px; background: var(--surface-2); border-radius: 8px;
}
.notice-icon { flex-shrink: 0; width: 15px; height: 15px; margin-top: 1px; color: var(--status-warning); }
.notice-icon svg { width: 15px; height: 15px; display: block; }

/* ---------------- Recommendation rows ---------------- */
.rec-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.rec-row:last-child { border-bottom: none; }
.rec-severity-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.rec-body { flex: 1; min-width: 0; }
.rec-row-title { font-size: 0.82rem; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-tag {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 1px 6px; border-radius: 4px; color: #fff;
}
.rec-domain-tag {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 1px 6px; border-radius: 4px; color: var(--text-secondary); background: var(--surface-2); border: 1px solid var(--border);
}
.rec-row-detail { font-size: 0.76rem; color: var(--text-secondary); margin-top: 2px; }

/* ---------------- Excel-style tables ---------------- */
.data-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.data-table { border-collapse: collapse; width: 100%; font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 6px 11px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
.data-table thead th { color: var(--text-secondary); font-weight: 600; border-bottom: 2px solid var(--baseline); background: var(--surface-2); position: sticky; top: 0; }
.data-table td.dim-cell, .data-table thead th:first-child { text-align: left; color: var(--text-primary); font-weight: 600; }
.data-table td.total-cell { font-weight: 700; border-left: 2px solid var(--baseline); }
.data-table .delta-up { color: var(--status-critical); }
.data-table .delta-down { color: var(--success-text); }
.data-table .delta-flat { color: var(--text-muted); }
.data-table tbody tr:hover { background: var(--surface-2); }

/* ---------------- Chart chrome ---------------- */
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-chart-wrap { position: relative; }
.viz-grid { stroke: var(--grid); stroke-width: 1; }
.viz-baseline { stroke: var(--baseline); stroke-width: 1; }
.viz-axis-label { fill: var(--text-muted); font-size: 10.5px; font-family: system-ui, sans-serif; }
.viz-value-label { fill: var(--text-secondary); font-size: 10.5px; font-family: system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.rank-label { fill: var(--text-primary); font-weight: 600; }
.viz-line { stroke-width: 2; }
.viz-bar { cursor: pointer; transition: filter 0.1s ease; }
.viz-bar.is-hovered { filter: brightness(1.08); }
.viz-crosshair { stroke: var(--baseline); stroke-width: 1; pointer-events: none; }

.viz-legend { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 8px; justify-content: center; }
.viz-legend-item {
  display: inline-flex; align-items: center; gap: 6px; border: none; background: none; cursor: pointer;
  font-size: 0.76rem; color: var(--text-secondary); padding: 2px 0;
}
.viz-legend-item.is-off { opacity: 0.4; }
.viz-legend-swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.viz-legend-swatch.line { height: 2px; border-radius: 2px; }

.viz-table-toggle {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  font-size: 0.74rem; font-weight: 600; padding: 5px 11px; border-radius: 6px; cursor: pointer; margin-top: 8px;
}
.viz-table-toggle:hover { background: var(--page-plane); }
.viz-table-wrap { margin-top: 8px; max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.viz-data-table { border-collapse: collapse; width: 100%; font-size: 0.75rem; }
.viz-data-table th, .viz-data-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.viz-data-table th:first-child, .viz-data-table td:first-child { text-align: left; }
.viz-data-table thead th { background: var(--surface-2); position: sticky; top: 0; color: var(--text-secondary); }

/* ---------------- Donut chart ---------------- */
.viz-donut-wrap { display: flex; flex-direction: column; align-items: center; }
.viz-donut-seg { cursor: pointer; transition: filter 0.1s ease; }
.viz-donut-seg.is-hovered { filter: brightness(1.08); }
.viz-donut-pct { fill: #fff; font-size: 11px; font-weight: 700; font-family: system-ui, sans-serif; pointer-events: none; }
.viz-donut-center-value { fill: var(--text-primary); font-size: 20px; font-weight: 800; font-family: system-ui, sans-serif; }
.viz-donut-center-label { fill: var(--text-muted); font-size: 11px; font-family: system-ui, sans-serif; }

/* ---------------- Tooltip ---------------- */
.viz-tooltip {
  position: fixed; z-index: 1000; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 9px; box-shadow: 0 4px 16px rgba(11,11,11,0.16); pointer-events: none;
  font-size: 0.74rem; min-width: 130px;
}
.viz-tooltip-header { font-weight: 700; color: var(--text-primary); margin-bottom: 4px; font-size: 0.74rem; }
.viz-tooltip-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.viz-tooltip-key { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.viz-tooltip-name { color: var(--text-secondary); flex: 1; }
.viz-tooltip-value { color: var(--text-primary); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------------- Select / date inputs ---------------- */
select.window-select, input[type="date"].window-select {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  padding: 5px 9px; border-radius: 6px; font-size: 0.78rem; font-weight: 600;
}

/* ---------------- Empty / loading ---------------- */
.loading-state, .error-state { padding: 48px 20px; text-align: center; color: var(--text-secondary); font-size: 0.85rem; }
.error-state { color: var(--status-critical); }
.no-data-state { padding: 32px 20px; text-align: center; color: var(--text-secondary); font-size: 0.85rem; }

footer.app-footer { color: var(--text-muted); font-size: 0.72rem; padding: 8px 2px 4px; }

@media (max-width: 900px) {
  .exec-shell { padding: 18px 16px 40px; }
  .exec-title-row { flex-wrap: wrap; }
}
