:root {
  /* Eneron brand */
  --brand-navy: #173346;
  --brand-navy-ink: #0e1f2b;
  --brand-lightblue: #89c1d8;
  --brand-grey: #808080;
  --brand-grey-light: #cccccc;

  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-price: #4a95b8;
  --series-price-wash: rgba(74, 149, 184, 0.10);
  --series-setpoint: var(--brand-navy);
  --series-setpoint-wash: rgba(23, 51, 70, 0.08);
  --series-revenue: #008300;
  --series-revenue-wash: rgba(0, 131, 0, 0.10);
  --critical: #d03b3b;
  --tooltip-surface: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-price: var(--brand-lightblue);
    --series-price-wash: rgba(137, 193, 216, 0.14);
    --series-setpoint: #6f9ab3;
    --series-setpoint-wash: rgba(111, 154, 179, 0.14);
    --series-revenue: #4caf4c;
    --series-revenue-wash: rgba(76, 175, 76, 0.14);
    --critical: #e66767;
    --tooltip-surface: #262624;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.brand-logo {
  display: block;
  height: 28px;
  width: auto;
}

/* The source file is the navy-on-transparent "Positivanwendung" logo.
   Where it sits on a dark surface, flip it to white ("Negativanwendung")
   with a filter instead of needing a second asset. */
.brand-logo.on-dark {
  filter: brightness(0) invert(1);
}

.muted {
  color: var(--text-muted);
}

/* Login */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.login-card .brand-logo {
  margin-bottom: 20px;
}

@media (prefers-color-scheme: dark) {
  .login-card .brand-logo {
    filter: brightness(0) invert(1);
  }
}

.login-card h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 20px;
  font-size: 0.9rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-card label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 10px;
}

.login-card input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
  font-size: 0.95rem;
}

.login-card button {
  margin-top: 20px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--brand-navy-ink);
}

.form-error {
  color: var(--critical);
  font-size: 0.85rem;
  margin: 0 0 12px;
}

/* Dashboard */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  /* Fixed brand navy regardless of light/dark mode — matches the
     "Negativanwendung mit Claim" bar from the logo manual. */
  background: var(--brand-navy);
  color: #ffffff;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-left .brand-logo {
  height: 22px;
}

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
}

.topbar-right .muted {
  color: var(--brand-lightblue);
}

.logout-link {
  color: #ffffff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  padding: 6px 10px;
}

.logout-link:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #ffffff;
}

.content {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stat-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-sub {
  font-size: 0.75rem;
}

.card-hint {
  font-size: 0.82rem;
  margin: -6px 0 12px;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-row button {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
}

.filter-row button.active {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  color: #ffffff;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card h2 {
  font-size: 0.95rem;
  margin: 0 0 12px;
  font-weight: 600;
}

.unit-label {
  font-weight: 400;
  font-size: 0.8rem;
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 40px 0;
  text-align: center;
}

.table-wrap {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
}

tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

tbody td:first-child {
  color: var(--text-primary);
}

/* Chart internals (rendered by dashboard.js) */

.axis-line {
  stroke: var(--baseline);
  stroke-width: 1;
}

.gridline {
  stroke: var(--gridline);
  stroke-width: 1;
}

.axis-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.crosshair {
  stroke: var(--baseline);
  stroke-width: 1;
  pointer-events: none;
}

.hover-dot {
  stroke: var(--surface-1);
  stroke-width: 2;
  pointer-events: none;
}

.tooltip {
  position: absolute;
  background: var(--tooltip-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--text-primary);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

.tooltip .tooltip-value {
  font-weight: 600;
}
