/* Design tokens per the dataviz skill's reference palette (references/palette.md) */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --slot-1: #2a78d6; /* blue */
  --slot-3: #1baf7a; /* aqua */
  --slot-7: #4a3aa7; /* violet */
  --slot-4: #eda100; /* yellow */
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #e66767;
    --slot-1: #3987e5;
    --slot-3: #199e70;
    --slot-7: #9085e9;
    --slot-4: #c98500;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
body { padding: 24px; max-width: 1180px; margin: 0 auto; }

header.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
header.app-header h1 { font-size: 20px; margin: 0 0 4px; }
header.app-header p.subtitle { color: var(--text-secondary); margin: 0; font-size: 13px; max-width: 60ch; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 24px; width: 24px; flex-shrink: 0; }
.brand-logo-lg { height: 40px; width: 40px; flex-shrink: 0; margin-bottom: 10px; }

.identity-panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  min-width: 340px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .field textarea {
  font: inherit;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  min-width: 140px;
}

section.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
section.card h2 { font-size: 15px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
section.card h2 .actions { font-size: 12px; font-weight: normal; }
section.card p.hint { color: var(--text-secondary); font-size: 12.5px; margin: 0 0 14px; }

button {
  font: inherit;
  cursor: pointer;
  background: var(--slot-1);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
}
button.secondary { background: transparent; color: var(--slot-1); border: 1px solid var(--slot-1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--gridline); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
td.mono, th.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.good { color: var(--good); border-color: var(--good); }
.badge.warning { color: #8a6100; border-color: var(--warning); background: rgba(250, 178, 25, 0.12); }
.badge.serious { color: #9c4a26; border-color: var(--serious); background: rgba(236, 131, 90, 0.12); }
.badge.critical { color: var(--critical); border-color: var(--critical); }
.badge.muted { color: var(--text-muted); border-color: var(--baseline); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.connector-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.connector-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.connector-card h3 { margin: 0 0 2px; font-size: 13.5px; }
.connector-card .url { font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-muted); word-break: break-all; }
.connector-card .caps { margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.connector-card .caps code { background: var(--page); padding: 1px 4px; border-radius: 4px; }

.query-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }

.result-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .result-columns { grid-template-columns: 1fr; } }
pre.result-json {
  background: var(--page);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  overflow: auto;
  max-height: 340px;
  margin: 0;
}
.rules-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rules-list li { font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.stateless-note {
  font-size: 11.5px;
  color: var(--text-muted);
  border-left: 2px solid var(--baseline);
  padding-left: 8px;
  margin-top: 10px;
}

footer.app-footer { text-align: center; color: var(--text-muted); font-size: 11.5px; margin: 32px 0 8px; }

/* ===================== Reports ===================== */
.rp-step-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.report-table-wrap { overflow-x: auto; border: 1px solid var(--gridline); border-radius: 8px; }
.report-table-wrap table { min-width: 100%; }
.report-table-wrap th, .report-table-wrap td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

/* ===================== Dashboards ===================== */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 14px; }
.widget-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--page); position: relative; }
.widget-card h4 { margin: 0 0 8px; font-size: 12.5px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.widget-card .widget-remove { background: transparent; color: var(--text-muted); border: none; padding: 0 2px; font-size: 14px; line-height: 1; }
.widget-card .widget-edit { background: transparent; color: var(--text-muted); border: none; padding: 0 2px; font-size: 12px; line-height: 1; margin-right: 2px; }
.widget-card .widget-edit:hover, .widget-card .widget-remove:hover { color: var(--slot-1); }
.widget-card .widget-error { color: var(--critical); font-size: 12px; }
.widget-chart-svg { width: 100%; height: auto; display: block; }
.widget-chart-svg text { fill: var(--text-secondary); font-size: 9px; }
.widget-chart-svg .grid-line { stroke: var(--gridline); stroke-width: 1; }
.widget-chart-svg .baseline { stroke: var(--baseline); stroke-width: 1; }
.widget-chart-svg .mark-bar { fill: var(--slot-1); }
.widget-chart-svg .mark-line { stroke: var(--slot-1); stroke-width: 2; fill: none; }
.widget-chart-svg .mark-dot { fill: var(--slot-1); }
.stat-tile { text-align: center; padding: 10px 0; }
.stat-tile .stat-value { font-size: 32px; font-weight: 700; line-height: 1.1; }
.stat-tile .stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.widget-table-wrap { max-height: 220px; overflow: auto; }
.widget-table-wrap table { font-size: 11px; }
details.widget-data-toggle { margin-top: 6px; }
details.widget-data-toggle summary { font-size: 11px; color: var(--text-muted); cursor: pointer; }

/* ===================== NLP ("Ask a question") ===================== */
#nlp-chart-wrap { margin: 10px 0; }
#nlp-chart-wrap .widget-table-wrap { max-height: 260px; }
#nlp-degraded-note { color: var(--serious); }

/* ===================== Login screen ===================== */
.login-screen {
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: var(--page);
  z-index: 50;
  padding: 20px;
}
.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card .subtitle { color: var(--text-secondary); font-size: 13px; margin: 0 0 22px; }
.login-card label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 4px; }
.login-card input {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}
.login-card code { background: var(--page); padding: 1px 4px; border-radius: 4px; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--gridline); }
.login-error {
  color: var(--critical);
  font-size: 12.5px;
  margin: 14px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(208, 59, 59, 0.1);
}

/* ===================== Modal (My account) ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px 24px;
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal h3 { margin-bottom: 6px; }
