:root {
  --bg: #0f1720;
  --surface: #17212c;
  --surface-2: #1e2b38;
  --border: #2a3a4a;
  --text: #e6edf3;
  --text-dim: #8b9bab;
  --accent: #2ea86f;
  --warn: #d99b26;
  --crit: #d4574e;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 340px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p.sub { margin: 0 0 24px; color: var(--text-dim); font-size: 14px; }

/* ---------- Layout ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
header h1 { margin: 0; font-size: 17px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.status-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--crit);
}
.status-dot.online { background: var(--accent); }

section { margin-bottom: 28px; }
section > h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 12px;
  font-weight: 600;
}

/* ---------- Kacheln ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.tile .label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.tile .value { font-size: 26px; font-weight: 600; }
.tile .unit { font-size: 14px; color: var(--text-dim); margin-left: 3px; }
.tile.alert { border-color: var(--crit); }

/* ---------- Aktoren ---------- */
.actuators {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.act {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.act .name { font-size: 14px; }
.act .state {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.act .state.on { background: var(--accent); color: #06210f; font-weight: 600; }

.mode-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.hint { font-size: 12px; color: var(--text-dim); }

/* ---------- Formulare ---------- */
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }

input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  padding: 9px 16px;
  border: none;
  border-radius: 7px;
  background: var(--accent);
  color: #06210f;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
button:hover { opacity: 0.88; }
button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }

a { color: var(--accent); }

/* ---------- Diagramme ---------- */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 14px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.chart-card canvas { max-height: 240px; }

/* ---------- Meldungen ---------- */
.alert-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-dim);
  border-radius: 0 7px 7px 0;
  padding: 10px 14px;
  margin-bottom: 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.alert-row.warning { border-left-color: var(--warn); }
.alert-row.critical { border-left-color: var(--crit); }
.alert-row .time { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

.error-msg {
  background: rgba(212, 87, 78, 0.12);
  border: 1px solid var(--crit);
  color: #f0a8a2;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 16px;
}

.toast {
  position: fixed;
  bottom: 22px; right: 22px;
  background: var(--accent);
  color: #06210f;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--crit); color: #fff; }
