:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1f2126;
  --text-muted: #8b93a1;
  --border: #edeef1;
  --border-strong: #dfe1e6;
  --accent: #e08a1e;
  --accent-bg: #fff4e5;
  --diff-bg: #fdeaea;
  --diff-text: #c0392b;
  --radius: 12px;
  /* categorical series slots (dataviz reference palette, validated on the white card surface) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
}

.back-button:hover { background: var(--bg); }

h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: 0 1px 2px rgba(20, 20, 30, 0.03);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 7px 6px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  white-space: nowrap;
}

thead th {
  padding-top: 10px;
  padding-bottom: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

th:first-child, td:first-child { padding-left: 12px; }
th:last-child, td:last-child { padding-right: 12px; }

td.numeric, th.numeric { text-align: right; }
.group-start { border-left: 1px solid var(--border-strong); }

.entity {
  font-weight: 600;
  white-space: nowrap;
}

a { color: var(--text); }
a.run-link { font-weight: 600; text-decoration: none; }
a.run-link:hover { color: var(--accent); text-decoration: underline; }

.diff {
  display: inline-block;
  background: var(--diff-bg);
  color: var(--diff-text);
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 999px;
}

.diff small {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  opacity: 0.85;
}

tbody tr.totals {
  background: var(--bg);
  font-weight: 600;
  border-top: 2px solid var(--border-strong);
}

tbody tr.totals small {
  display: block;
  font-weight: 400;
  color: var(--text-muted);
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 28px 0 12px;
}

h2 .count {
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-error { background: var(--diff-bg); color: var(--diff-text); }
.badge-warning { background: var(--accent-bg); color: #b36b00; }
.badge-neutral { background: #eef0f3; color: #5f6673; }

td.message { color: var(--text-muted); font-size: 0.85rem; white-space: normal; }

/* keeps the vehicle visible while the wide comparison table scrolls horizontally */
.sticky { position: sticky; left: 0; z-index: 1; background: var(--card-bg); }
thead th.sticky { z-index: 2; }
tbody tr:hover .sticky { background: #fafbfc; }
tbody tr.totals .sticky { background: var(--bg); }

.header-link { margin-left: auto; font-size: 0.88rem; color: var(--text-muted); text-decoration: none; }
.header-link:hover { color: var(--accent); }

.status-select {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
}
.status-select.tone-success { background: #e8f6ee; color: #1e7a45; border-color: #bfe5cf; }
.status-select.tone-error { background: var(--diff-bg); color: var(--diff-text); border-color: #f3c4bf; }
.status-select.tone-neutral { background: #eef0f3; color: #5f6673; }

.review-note input {
  font: inherit;
  font-size: 0.82rem;
  width: 110px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
}
.review-note input:focus { outline: none; border-color: var(--accent); background: var(--card-bg); }

/* the row the review form redirected back to */
tr:target td, tr:target .sticky { background: #fff8ec; }

.badge-success { background: #e8f6ee; color: #1e7a45; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.filters input, .filters select {
  font: inherit;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card-bg);
}
.filters input[name="entity"] { width: 220px; }

.button-primary, .button-secondary {
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-size: 0.9rem;
  padding: 7px 16px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
}
.button-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); font-weight: 600; }
.button-secondary { background: var(--card-bg); color: var(--text); border: 1px solid var(--border-strong); }

.pagination { display: flex; align-items: center; gap: 12px; margin-top: 14px; color: var(--text-muted); font-size: 0.9rem; }
.muted { color: var(--text-muted); font-weight: 400; }
td.empty { text-align: center; color: var(--text-muted); padding: 24px; }


.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label { font-size: 0.8rem; color: var(--text-muted); }
.kpi-value { font-size: 1.9rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
}
.chart-card { padding: 14px 16px 8px; overflow: visible; }
.chart-card h3 { margin: 0; font-size: 0.95rem; }
.chart-note { margin: 2px 0 8px; font-size: 0.8rem; color: var(--text-muted); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart .grid line.zero { stroke: #b9bdc6; }
.chart .tick { font-size: 11px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart .end-label { font-size: 12px; fill: var(--text); font-weight: 600; }
.chart .crosshair { stroke: #9aa0ab; stroke-width: 1; }

.chart-legend { display: flex; gap: 16px; font-size: 0.82rem; margin-bottom: 4px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.line-key { display: inline-block; width: 16px; height: 2px; border-radius: 1px; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(20, 20, 30, 0.08);
  padding: 8px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
  z-index: 3;
}
.tip-date { color: var(--text-muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-name { color: var(--text-muted); }

.data-table { margin-top: 12px; }
.data-table summary { cursor: pointer; padding: 12px 16px; font-size: 0.88rem; color: var(--text-muted); }
.empty-state { padding: 24px 16px; margin: 0; color: var(--text-muted); text-align: center; }

/* informational, Buildibox-only values: no tracker counterpart, no diff */
td.info { color: var(--text-muted); }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.bulk-bar select { font: inherit; padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: 8px; }
.bulk-bar button:disabled { opacity: 0.45; cursor: default; }
.bulk-hint { color: var(--text-muted); font-size: 0.8rem; }
.bulk-item, .bulk-all { margin: 0 4px 0 0; vertical-align: -2px; cursor: pointer; }
td.count-error { color: var(--diff-text); font-weight: 600; }
.stale-hint { display: block; margin-top: 2px; font-size: 0.72rem; color: #b36b00; cursor: help; }

/* layout: collapsible sidebar + content (styled after the Buildibox app shell) */
.app { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; padding: 0 1.5rem 1.5rem; }
.sidebar {
  flex: 0 0 188px;
  width: 188px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px 8px;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  transition: width 0.15s ease, flex-basis 0.15s ease;
  z-index: 4;
}
.sidebar-head { padding: 0 8px 22px; }
.logo { display: inline-block; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; color: var(--text); text-decoration: none; }
img.logo-full { display: block; height: 22px; width: auto; }
.logo-dot { color: #f2b705; }
.logo-short { display: none; }
.sidebar-toggle {
  position: absolute;
  top: 22px;
  right: -12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
}
.sidebar-toggle:hover { color: var(--text); }
.sidebar-toggle:focus-visible, .sidebar-nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sidebar-section { padding: 0 10px 8px; font-size: 0.85rem; color: var(--text-muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.sidebar-nav a svg { flex: 0 0 auto; color: var(--text-muted); }
.sidebar-nav a:hover { background: #f7f7f8; }
.sidebar-nav a.active { background: #f5f5f6; color: #e9a200; font-weight: 500; }
.sidebar-nav a.active svg { color: #e9a200; }

/* page title strip, as in the Buildibox app */
.topbar {
  margin: 0 -1.5rem 1.25rem;
  padding: 14px 1.5rem;
  min-height: 56px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.25rem; font-weight: 600; }

.sidebar-collapsed .sidebar { flex-basis: 60px; width: 60px; }
.sidebar-collapsed .logo-full,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .sidebar-section { display: none; }
.sidebar-collapsed .logo-short { display: inline; }
.sidebar-collapsed .sidebar-head { padding: 0 0 22px; text-align: center; }
.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
.sidebar-collapsed .sidebar-nav a { justify-content: center; padding: 10px 0; }

/* sidebar foot: settings, logged-in user, logout */
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin: 0; }
.user-avatar {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-bg); color: #b36b00; font-size: 0.8rem; font-weight: 700;
}
.user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; }
.logout-button {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.logout-button:hover { background: #f7f7f8; color: var(--text); }
.logout-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sidebar-collapsed .sidebar-user { flex-direction: column; padding: 6px 0; gap: 6px; }

/* settings panel */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border-strong); }
.tabs a { padding: 8px 14px; color: var(--text-muted); text-decoration: none; font-size: 0.9rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.form-card { padding: 16px; }
.form-card-narrow { max-width: 520px; }
.form-card h3 { margin: 0 0 12px; font-size: 0.95rem; }
.form-card p.hint { margin: -6px 0 12px; font-size: 0.8rem; color: var(--text-muted); }
.stacked-form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.stacked-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.stacked-form input {
  font: inherit; font-size: 0.9rem; font-weight: 400; color: var(--text);
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--card-bg);
}
.stacked-form input:focus { outline: none; border-color: var(--accent); }
.stacked-form input::placeholder { color: var(--text-muted); }
.stacked-form .button-primary { align-self: flex-start; }
.inline-form { display: inline; margin: 0; }
.button-link { font: inherit; font-size: 0.85rem; padding: 0; border: none; background: none; color: var(--diff-text); cursor: pointer; }
.button-link:hover { text-decoration: underline; }
.button-link:disabled { color: var(--text-muted); cursor: default; text-decoration: none; }
code.key-prefix { font-size: 0.82rem; color: var(--text-muted); }

.flash { margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; font-size: 0.9rem; }
.flash-success { background: #e8f6ee; color: #1e7a45; }
.flash-error { background: var(--diff-bg); color: var(--diff-text); }

.new-key { margin: 0 0 14px; padding: 14px 16px; border: 1px solid #f3d9a6; background: var(--accent-bg); border-radius: var(--radius); }
.new-key p { margin: 0 0 8px; font-size: 0.9rem; }
.new-key-row { display: flex; gap: 8px; align-items: center; }
.new-key-row input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; line-height: 1.5; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--card-bg); }

/* login page (no sidebar) */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 28px 24px; }
.login-card img { display: block; height: 24px; margin: 0 0 18px; }
.login-card h1 { font-size: 1.15rem; font-weight: 600; margin: 0 0 16px; }
.login-card .stacked-form { max-width: none; }
.login-card .button-primary { align-self: stretch; justify-content: center; }
