:root {
  color-scheme: light;
  --page-plane:      #faf6ee;
  --surface-1:       #fffdf8;
  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --text-muted:      #898781;
  --gridline:        #e1e0d9;
  --baseline:        #c3c2b7;
  --border:          rgba(11,11,11,0.10);
  --series-1:        #2a78d6;
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  --cat-1: #2a78d6;
  --cat-2: #eb6834;
  --cat-3: #1baf7a;
  --cat-4: #eda100;
  --cat-5: #e87ba4;
  --cat-6: #008300;
  --cat-7: #4a3aa7;
  --cat-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page-plane:      #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-1:        #3987e5;
    --status-good:     #0ca30c;
    --status-warning:  #fab219;
    --status-serious:  #ec835a;
    --status-critical: #d03b3b;
    --cat-1: #3987e5;
    --cat-2: #d95926;
    --cat-3: #199e70;
    --cat-4: #c98500;
    --cat-5: #d55181;
    --cat-6: #008300;
    --cat-7: #9085e9;
    --cat-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-plane:      #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-1:        #3987e5;
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  --cat-1: #3987e5;
  --cat-2: #d95926;
  --cat-3: #199e70;
  --cat-4: #c98500;
  --cat-5: #d55181;
  --cat-6: #008300;
  --cat-7: #9085e9;
  --cat-8: #e66767;
}
:root[data-theme="light"] {
  color-scheme: light;
  --page-plane:      #faf6ee;
  --surface-1:       #fffdf8;
  --text-primary:    #0b0b0b;
  --text-secondary:  #52514e;
  --text-muted:      #898781;
  --gridline:        #e1e0d9;
  --baseline:        #c3c2b7;
  --border:          rgba(11,11,11,0.10);
  --series-1:        #2a78d6;
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  --cat-1: #2a78d6;
  --cat-2: #eb6834;
  --cat-3: #1baf7a;
  --cat-4: #eda100;
  --cat-5: #e87ba4;
  --cat-6: #008300;
  --cat-7: #4a3aa7;
  --cat-8: #e34948;
}

* { box-sizing: border-box; }

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

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 14px 64px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.7rem;
}
.title-emoji {
  margin-right: 0.35em;
}
.byline {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.app-header .subtitle {
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.privacy-note {
  margin: 0 0 18px;
  color: var(--status-good);
  font-size: 0.82rem;
  font-weight: 600;
}
.header-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.lang-btn, .theme-btn {
  flex-shrink: 0;
  font-size: 0.82rem;
  padding: 8px 12px;
  min-height: 40px;
}
.theme-btn {
  font-size: 1.1rem;
  line-height: 1;
  padding: 8px 11px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  margin-bottom: 14px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.form-grid [hidden] {
  display: none;
}
.form-grid input,
.form-grid select,
.name-field input {
  font: inherit;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page-plane);
  color: var(--text-primary);
  min-height: 42px;
}
.form-grid input:focus,
.form-grid select:focus,
.name-field input:focus {
  outline: 2px solid var(--series-1);
  outline-offset: 1px;
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.name-field input { font-weight: 600; font-size: 1rem; }

.btn-primary, .btn-ghost {
  font: inherit;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 42px;
}
.btn-primary {
  background: var(--series-1);
  color: #fff;
  border-color: var(--series-1);
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--page-plane); }

/* ---------- People chips ---------- */
.people-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.person-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  cursor: pointer;
  font-size: 0.88rem;
  min-height: 40px;
  color: var(--text-secondary);
}
.person-chip .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.person-chip.active {
  border-color: var(--chip-color, var(--series-1));
  background: color-mix(in srgb, var(--chip-color, var(--series-1)) 12%, var(--page-plane));
  color: var(--text-primary);
  font-weight: 600;
}
.person-chip .chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
}
.person-chip .chip-remove:hover { color: var(--status-critical); }
.add-person-btn {
  border-style: dashed;
}

/* ---------- Drinks table ---------- */
.drinks-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 0.88rem;
}
.drinks-table th, .drinks-table td {
  text-align: left;
  padding: 9px 6px;
  border-bottom: 1px solid var(--gridline);
}
.drinks-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.drinks-table td.num { font-variant-numeric: tabular-nums; }
.remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 8px;
  border-radius: 6px;
  min-height: 36px;
  min-width: 36px;
}
.remove-btn:hover { color: var(--status-critical); background: var(--page-plane); }

.empty-state {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.stat-tile {
  background: var(--page-plane);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat-tile .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-tile .stat-value {
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
}
.stat-tile .stat-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.stat-tile .stat-value.status-good { color: var(--status-good); }
.stat-tile .stat-value.status-warning { color: #a56c00; }
.stat-tile .stat-value.status-critical { color: var(--status-critical); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .stat-tile .stat-value.status-warning { color: var(--status-warning); }
}
:root[data-theme="dark"] .stat-tile .stat-value.status-warning { color: var(--status-warning); }

/* ---------- Legend ---------- */
.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.legend-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  cursor: pointer;
  font-size: 0.85rem;
  min-height: 38px;
  transition: opacity 0.12s ease;
}
.legend-chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-chip .legend-name {
  color: var(--text-primary);
  font-weight: 600;
}
.legend-chip .legend-value {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.legend-chip.dimmed { opacity: 0.4; }
.legend-chip.emphasized { border-color: var(--chip-color, var(--series-1)); }

.chart-card { margin-top: 18px; }
.chart-card h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
}
.unit-tag {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.82rem;
}
.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-wrap:focus { outline: none; }
.chart-wrap svg { display: block; width: 100%; height: auto; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page-plane);
  font-size: 0.76rem;
  padding: 7px 10px;
  border-radius: 6px;
  transform: translate(-50%, -110%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s ease;
  z-index: 2;
}
.chart-tooltip .tt-time {
  color: var(--gridline);
  margin-bottom: 3px;
}
.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-tooltip .tt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chart-tooltip .tt-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.chart-tooltip.visible { opacity: 1; }

.zones-caption {
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.data-table-wrap {
  margin-top: 14px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.data-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.data-table-wrap th, .data-table-wrap td {
  padding: 6px 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
.data-table-wrap th:first-child, .data-table-wrap td:first-child { text-align: left; }
.data-table-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  color: var(--text-muted);
  font-weight: 500;
}

.disclaimer {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 24px;
}
