:root {
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* blue */
  --series-2: #1baf7a;   /* aqua */
  --series-3: #eda100;   /* yellow */
  --good: #0ca30c;
  --critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #199e70;
    --series-3: #c98500;
    --good: #0ca30c;
    --critical: #e66767;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

.topnav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topnav .brand {
  font-weight: 600;
  color: var(--text-primary);
  margin-right: auto;
}

.topnav a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.topnav a.active { color: var(--series-1); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
}

.flash {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.flash.success { background: rgba(12,163,12,0.12); color: var(--good); }
.flash.error { background: rgba(208,59,59,0.12); color: var(--critical); }

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

.filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

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

.field label {
  font-size: 12px;
  color: var(--text-secondary);
}

select, input[type=text], input[type=date], input[type=number], textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
}

textarea { resize: vertical; }

.btn {
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}
.btn.primary {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}
.btn.danger {
  color: var(--critical);
  border-color: var(--critical);
  background: transparent;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.stat-tile .label {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-tile .value {
  font-size: 28px;
  font-weight: 600;
  margin-top: 4px;
  color: var(--text-primary);
}

.stat-tile .unit {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 400;
}

h1, h2, h3 { color: var(--text-primary); }
h1 { font-size: 22px; }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--text-secondary); font-weight: 600; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) {
  text-align: left;
  font-variant-numeric: normal;
}
th { color: var(--text-muted); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: rgba(127,127,127,0.06); }

.thumb {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
}

.image-preview {
  max-width: 320px;
  max-height: 320px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 8px;
}

.tooltip-box {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: nowrap;
  visibility: hidden;
  z-index: 10;
}

.chart-wrap { position: relative; }

.axis-label { fill: var(--text-muted); font-size: 11px; }
.gridline { stroke: var(--gridline); stroke-width: 1; }
.baseline { stroke: var(--baseline); stroke-width: 1; }
