:root {
  color-scheme: light;
  --background: #ffffff;
  --foreground: #0a0a0a;
  --muted: #f8fafc;
  --muted-strong: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e5e7eb;
  --primary: #0f172a;
  --primary-foreground: #ffffff;
  --success: #10b981;
  --warning: #f59e0b;
  --destructive: #ef4444;
  --info: #6366f1;
  --chart-1: #6366f1;
  --chart-2: #10b981;
  --chart-3: #f59e0b;
  --chart-4: #ef4444;
  --chart-5: #0ea5e9;
  --chart-6: #8b5cf6;
  --chart-7: #ec4899;
  --chart-8: #06b6d4;
  --chart-9: #84cc16;
  --chart-10: #f97316;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 6%);
  --shadow-md: 0 8px 20px rgb(15 23 42 / 8%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.app {
  min-height: 100dvh;
  background: var(--background);
}

.shell {
  width: min(100%, 1400px);
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
}

.sidebar {
  display: none;
  width: 192px;
  min-height: 100dvh;
  flex: 0 0 192px;
  border-right: 1px solid var(--border);
  background: rgb(248 250 252 / 35%);
  padding: 16px;
}

.side-brand {
  display: flex;
  height: 40px;
  align-items: center;
  padding: 0 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.side-nav {
  margin-top: 16px;
  display: grid;
  gap: 4px;
}

.side-link {
  display: flex;
  min-height: 32px;
  align-items: center;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.side-link.active {
  background: rgb(248 250 252 / 90%);
  color: var(--foreground);
  font-weight: 600;
}

.side-link:hover {
  background: rgb(248 250 252 / 85%);
  color: var(--foreground);
}

.content {
  min-width: 0;
  flex: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 80%);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  min-height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand strong {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted-foreground);
  font-size: 12px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 12px;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--warning);
}

.dot.ok {
  background: var(--success);
}

.dot.fail {
  background: var(--destructive);
}

main {
  min-width: 0;
  padding: 24px 16px 48px;
}

.page-heading {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-heading h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
}

.page-heading p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--foreground);
  padding: 0 10px;
  font-size: 14px;
}

.field.api {
  grid-column: span 2;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.btn {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--background);
  color: var(--foreground);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn:hover {
  background: var(--muted);
}

.btn.primary:hover {
  background: rgb(15 23 42 / 92%);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.7;
}

.grid {
  display: grid;
  gap: 16px;
}

.kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.analytics-board {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.board-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.board-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.board-heading p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 13px;
}

.group-tabs {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  border-bottom: 2px solid var(--border);
  background: var(--muted);
  padding: 4px 4px 0;
  box-shadow: inset 0 -2px 4px rgb(15 23 42 / 4%);
}

.group-tab {
  flex: 0 0 auto;
  min-height: 38px;
  margin-bottom: -2px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted-foreground);
  padding: 0 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.group-tab.active {
  border-color: var(--border);
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 -1px 4px rgb(15 23 42 / 6%);
}

.category-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 2px solid rgb(229 231 235 / 55%);
  background: var(--background);
  padding: 0 0 0 24px;
  box-shadow: var(--shadow-sm);
}

.category-tab {
  flex: 0 0 auto;
  min-height: 40px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.category-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 20px;
  margin-left: 6px;
  border-radius: 999px;
  background: rgb(15 23 42 / 8%);
  color: inherit;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 800;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.page-grid {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

.panel:hover {
  border-color: #d9dee8;
  box-shadow: var(--shadow-md);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 700;
  letter-spacing: 0;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

.kpi {
  padding: 16px;
  min-height: 118px;
}

.kpi .label {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.kpi .value {
  margin-top: 10px;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
}

.kpi .hint {
  margin-top: 10px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.kpi.revenue {
  border-top-color: rgb(16 185 129 / 50%);
}

.kpi.orders {
  border-top-color: rgb(99 102 241 / 50%);
}

.kpi.roas {
  border-top-color: rgb(245 158 11 / 50%);
}

.chart-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--background);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

.chart-card:hover {
  border-color: #d9dee8;
  box-shadow: var(--shadow-md);
}

.chart-card[data-status="needs_new_view"] {
  border-style: dashed;
  background: linear-gradient(180deg, #fff 0%, rgb(245 158 11 / 5%) 100%);
}

.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chart-card-head h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  font-weight: 700;
}

.chart-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

.chip.ready {
  border-color: rgb(16 185 129 / 35%);
  background: rgb(16 185 129 / 10%);
  color: #047857;
}

.chip.needs-new-view {
  border-color: rgb(245 158 11 / 45%);
  background: rgb(245 158 11 / 12%);
  color: #92400e;
}

.chart-tools {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.chart-body {
  display: grid;
  align-content: start;
  flex: 1;
  min-height: 260px;
  margin-top: 16px;
}

.chart-contract {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  padding: 10px;
}

.contract-row {
  min-width: 0;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.contract-row strong {
  display: block;
  color: var(--foreground);
  font-size: 12px;
}

.chart-important {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.important-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.important-toggle .chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--muted);
}

.chart-important.collapsed .important-list {
  display: none;
}

.chart-important.collapsed .important-toggle .chevron {
  transform: rotate(-90deg);
}

.important-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--foreground);
  font-size: 12px;
  line-height: 1.65;
}

.chart-list {
  display: grid;
  gap: 12px;
}

.scorecard-chart {
  display: grid;
  gap: 10px;
  align-content: center;
  min-height: 210px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(135deg, rgb(99 102 241 / 10%), rgb(16 185 129 / 8%));
  padding: 18px;
}

.scorecard-value {
  color: var(--foreground);
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}

.scorecard-label {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
}

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

.kpi-tile {
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  padding: 12px;
}

.kpi-tile strong {
  display: block;
  font-size: 20px;
  line-height: 1;
}

.kpi-tile span {
  display: block;
  margin-top: 8px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.sparkline {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 10px;
}

.stacked-bar-chart,
.heatmap-chart,
.treemap-chart,
.scatter-chart {
  min-height: 220px;
}

.stacked-bar-chart {
  display: grid;
  gap: 12px;
}

.stack-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}

.stack-track {
  display: flex;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--muted-strong);
}

.stack-segment {
  min-width: 4px;
}

.heatmap-chart {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.heatmap-cell {
  display: grid;
  min-height: 42px;
  align-content: center;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 6px;
  color: #fff;
  padding: 8px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgb(15 23 42 / 7%);
}

.treemap-chart {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.8fr;
  gap: 8px;
}

.treemap-tile {
  display: grid;
  align-content: end;
  min-height: 84px;
  border-radius: 8px;
  color: #fff;
  padding: 10px;
  font-size: 12px;
  font-weight: 800;
}

.treemap-tile:nth-child(1) {
  grid-row: span 2;
}

.scatter-chart {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px),
    var(--muted);
  background-size: 25% 25%;
}

.scatter-point {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--color);
  box-shadow: 0 8px 18px rgb(15 23 42 / 18%);
  transform: translate(-50%, 50%);
}

.chart-visual {
  width: 100%;
  min-width: 0;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 240px;
  overflow: visible;
}

.grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.axis-text {
  fill: var(--muted-foreground);
  font-size: 11px;
}

.line-series {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.area-series {
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.point-dot {
  stroke: var(--background);
  stroke-width: 2;
}

.donut-chart {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.donut-svg {
  width: 190px;
  height: 190px;
}

.donut-center {
  fill: var(--foreground);
  font-size: 18px;
  font-weight: 800;
  text-anchor: middle;
}

.donut-sub {
  fill: var(--muted-foreground);
  font-size: 11px;
  text-anchor: middle;
}

.legend-list {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.legend-value {
  color: var(--muted-foreground);
  white-space: nowrap;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) minmax(90px, auto);
  gap: 10px;
  align-items: center;
  min-height: 32px;
}

.bar-label {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--muted-strong);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
}

.bar-meta {
  color: var(--muted-foreground);
  font-size: 12px;
  text-align: right;
}

.trend {
  min-height: 240px;
}

.funnel {
  display: grid;
  gap: 14px;
}

.funnel-step {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 80px;
  gap: 10px;
  align-items: center;
}

.job-list {
  display: grid;
  gap: 10px;
}

.job-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.job-row:last-child {
  border-bottom: 0;
}

.job-row strong {
  font-size: 13px;
}

.job-row span {
  color: var(--muted-foreground);
  font-size: 12px;
}

.table-chart {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.table-chart .job-row {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.ai-card {
  grid-column: 1 / -1;
}

.ai-card .chart-body {
  min-height: auto;
}

.ai-expert-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.ai-pane {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
}

.ai-pane-head {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
  padding: 10px 12px;
}

.ai-pane-head strong {
  font-size: 13px;
  line-height: 1.35;
}

.ai-pane-head span {
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 700;
}

.ai-task-list,
.ai-side-stack,
.analysis {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.ai-task {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--task-color, var(--chart-1));
  border-radius: 8px;
  background: var(--background);
  color: var(--foreground);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.ai-task:hover {
  background: color-mix(in srgb, var(--task-color, var(--chart-1)) 8%, white);
}

.ai-task.active {
  border-color: color-mix(in srgb, var(--task-color, var(--chart-1)) 44%, var(--border));
  background: color-mix(in srgb, var(--task-color, var(--chart-1)) 12%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--task-color, var(--chart-1)) 22%, transparent);
}

.ai-task-icon {
  display: inline-flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--task-color, var(--chart-1)) 18%, white);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 900;
}

.ai-task-body strong,
.ai-context-row strong,
.analysis-section strong,
.ai-mini-card strong,
.ai-step strong {
  display: block;
  font-size: 12px;
  line-height: 1.35;
}

.ai-task-body span,
.ai-context-row span,
.ai-mini-card span,
.ai-step-text span {
  display: block;
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.45;
}

.ai-safe-context {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 12px;
}

.ai-context-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.analysis {
  min-height: 100%;
}

.analysis-status {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

.analysis-status.live {
  border-color: rgb(16 185 129 / 35%);
  background: rgb(16 185 129 / 10%);
  color: #047857;
}

.analysis-status.cached {
  border-color: rgb(245 158 11 / 38%);
  background: rgb(245 158 11 / 11%);
  color: #92400e;
}

.analysis h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
}

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

.ai-expert-shell .analysis-grid {
  grid-template-columns: 1fr;
}

.analysis-section {
  min-width: 0;
  border: 1px solid var(--border);
  border-top: 3px solid var(--section-color, var(--chart-1));
  border-radius: 8px;
  background: var(--muted);
  padding: 12px;
}

.analysis-section ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--foreground);
  font-size: 13px;
  line-height: 1.6;
}

.ai-side-stack {
  padding: 12px;
}

.ai-mini-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  padding: 12px;
}

.ai-quota-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.ai-quota-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  padding: 8px;
}

.ai-quota-cell strong {
  font-size: 16px;
}

.ai-progress {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.ai-step {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.ai-step-text {
  min-width: 0;
}

.ai-step-dot {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border-radius: 999px;
  background: var(--muted-foreground);
}

.ai-step.active .ai-step-dot {
  background: var(--info);
}

.ai-step.done .ai-step-dot {
  background: var(--success);
}

.data-model-card {
  grid-column: 1 / -1;
}

.data-model-card .chart-body {
  gap: 16px;
  min-height: auto;
}

.schema-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.schema-node {
  min-width: 0;
  border: 1px solid var(--border);
  border-top: 4px solid var(--schema-color, var(--chart-1));
  border-radius: 8px;
  background: linear-gradient(180deg, rgb(255 255 255 / 96%), rgb(248 250 252 / 78%));
  padding: 12px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 75%);
}

.schema-fact {
  grid-column: 2;
  grid-row: 2;
  background: linear-gradient(135deg, rgb(99 102 241 / 12%), rgb(16 185 129 / 10%));
}

.schema-dimension.date {
  grid-column: 1;
  grid-row: 1;
}

.schema-dimension.brand {
  grid-column: 2;
  grid-row: 1;
}

.schema-dimension.channel {
  grid-column: 3;
  grid-row: 1;
}

.schema-dimension.campaign {
  grid-column: 1;
  grid-row: 3;
}

.schema-dimension.device {
  grid-column: 3;
  grid-row: 3;
}

.schema-kind {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--schema-color, var(--chart-1)) 14%, white);
  color: var(--foreground);
  padding: 0 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.schema-table {
  display: block;
  margin-top: 8px;
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.schema-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.schema-field {
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--schema-color, var(--chart-1)) 28%, var(--border));
  border-radius: 6px;
  background: rgb(255 255 255 / 78%);
  color: var(--muted-foreground);
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.model-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.model-detail {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  padding: 12px;
}

.model-detail strong {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
}

.model-detail ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.65;
}

.model-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.model-flow-step {
  min-width: 0;
  border: 1px solid var(--border);
  border-left: 4px solid var(--schema-color, var(--chart-1));
  border-radius: 8px;
  background: var(--background);
  padding: 10px;
}

.model-flow-step strong,
.model-flow-step span {
  display: block;
  overflow-wrap: anywhere;
}

.model-flow-step strong {
  font-size: 12px;
}

.model-flow-step span {
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.45;
}

.empty {
  color: var(--muted-foreground);
  font-size: 13px;
}

.toast {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid rgb(245 158 11 / 35%);
  border-radius: 8px;
  background: rgb(245 158 11 / 10%);
  color: #92400e;
  display: none;
  font-size: 13px;
}

.toast.show {
  display: block;
}

@media (min-width: 1024px) {
  .sidebar {
    display: block;
  }

  .topbar-inner {
    padding: 0 24px;
  }

  main {
    padding: 24px 32px 48px;
  }
}

@media (max-width: 980px) {
  .filters,
  .kpis,
  .chart-grid,
  .ai-expert-shell,
  .analysis-grid,
  .model-detail-grid,
  .model-flow {
    grid-template-columns: 1fr 1fr;
  }

  .ai-expert-shell {
    grid-template-columns: 1fr;
  }

  .field.api {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .topbar-inner,
  .status-row {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .topbar-inner,
  .filters,
  .kpis,
  .chart-grid,
  .analysis-grid,
  .ai-context-row,
  .ai-quota-grid,
  .model-detail-grid,
  .model-flow {
    grid-template-columns: 1fr;
    display: grid;
  }

  .board-heading,
  .chart-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .category-tabs {
    padding-left: 8px;
  }

  .field.api {
    grid-column: span 1;
  }

  .actions {
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .bar-row,
  .funnel-step {
    grid-template-columns: 1fr;
  }

  .donut-chart {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .donut-svg {
    width: 170px;
    height: 170px;
  }

  .legend-list {
    width: 100%;
  }

  .bar-meta {
    text-align: left;
  }

  .schema-board {
    grid-template-columns: 1fr;
  }

  .schema-fact,
  .schema-dimension.date,
  .schema-dimension.brand,
  .schema-dimension.channel,
  .schema-dimension.campaign,
  .schema-dimension.device {
    grid-column: auto;
    grid-row: auto;
  }
}
