:root {
  --text: #eef3f2;
  --label: rgba(255, 255, 255, .5);
  --btn: #ccd0d2;
  --btn-hover: #dde1e3;
  --btn-text: #34383b;

  /* Login-Karte: bewusst deckend, damit Autofill exakt abgedeckt werden kann. */
  --karte: #383d40;
  --feld: #43484b;
  --feld-fokus: #484d50;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background-color: #33373a;
  background-image: radial-gradient(112% 82% at 50% 40%,
      #5e6366 0%, #4e5356 28%, #3e4346 56%, #303436 78%, #232628 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* ---- Kopfleiste der Login-Seite ---- */
.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  opacity: .92;
}
.back:hover { opacity: 1; }
.back svg { width: 8px; height: 13px; flex: none; }

/* ---- Wortmarke (Login + App-Leiste) ---- */
.wordmark {
  font-size: 31px;
  line-height: 1;
  letter-spacing: .4px;
  white-space: nowrap;
  color: #fff;
}
.wordmark .w-light { font-weight: 300; color: rgba(255, 255, 255, .72); }
.wordmark .w-bold  { font-weight: 600; }

/* ---- Login ---- */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 64px;
}
.auth { width: 360px; max-width: 100%; }
.mark { display: flex; justify-content: center; margin-bottom: 30px; }

.karte {
  padding: 30px 30px 32px;
  background: var(--karte);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  box-shadow: 0 26px 64px rgba(0, 0, 0, .38);
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  margin-bottom: 9px;
  font-size: 11px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--label);
}
.field input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--feld);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus {
  background: var(--feld-fokus);
  border-color: rgba(255, 255, 255, .4);
}

/*
 * Autofill: Chrome/Safari malen sonst einen weissen Balken ins Feld.
 * Der deckende Inset-Schatten hat exakt die Feldfarbe, die lange
 * transition verhindert das nachtraegliche Umfaerben.
 */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus,
.field input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--feld) inset;
  box-shadow: 0 0 0 1000px var(--feld) inset;
  transition: background-color 600000s 0s, color 600000s 0s;
}
.field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--feld-fokus) inset;
  box-shadow: 0 0 0 1000px var(--feld-fokus) inset;
}

.btn-primary {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 24px;
  border: 0;
  border-radius: 6px;
  background: var(--btn);
  color: var(--btn-text);
  font: inherit;
  font-size: 15px;
  letter-spacing: .2px;
  cursor: pointer;
  transition: background .15s, transform .06s;
}
.btn-primary:hover { background: var(--btn-hover); }
.btn-primary:active { transform: translateY(1px); }

/* ---- Meldungen ---- */
.flash {
  margin-bottom: 20px;
  padding: 11px 13px;
  border-left: 2px solid rgba(255, 140, 125, .85);
  border-radius: 3px;
  background: rgba(255, 120, 105, .13);
  color: #ffdad4;
  font-size: 13.5px;
  line-height: 1.45;
}
.flash.ok {
  border-left-color: rgba(130, 225, 180, .85);
  background: rgba(120, 220, 170, .13);
  color: #d8f3e5;
}

@media (max-width: 520px) {
  .topbar { padding: 14px 16px; }
  main { padding: 64px 20px 48px; }
  .mark { margin-bottom: 24px; }
  .wordmark { font-size: 27px; }
  .karte { padding: 26px 22px 28px; }
}

/* =========================================================
   Angemeldete Seiten (body.app)
   ========================================================= */
body.app main {
  display: block;
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 34px 26px 72px;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  height: 64px;
  padding: 0 26px;
  background: rgba(30, 33, 35, .76);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.appbar .wordmark { font-size: 19px; text-decoration: none; }

.appnav { display: flex; align-items: center; gap: 22px; }
.appnav > a {
  color: rgba(255, 255, 255, .6);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.appnav > a:hover { color: #fff; }
.appnav > a.aktiv { color: #fff; border-bottom-color: rgba(255, 255, 255, .55); }

.appuser {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-left: 20px;
  border-left: 1px solid rgba(255, 255, 255, .14);
}
.appuser-text { display: flex; flex-direction: column; line-height: 1.25; }
.appuser-text .name { font-size: 14px; color: #fff; }
.appuser-text .rolle { font-size: 11.5px; color: rgba(255, 255, 255, .45); }
.avatar {
  width: 32px; height: 32px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  font-size: 12.5px; font-weight: 600; color: #fff;
}

/* ---- Seitenkopf ---- */
.seiten-kopf { margin-bottom: 26px; }
.seiten-kopf h1 { margin: 0 0 6px; font-size: 26px; font-weight: 600; letter-spacing: .2px; }
.seiten-kopf p  { margin: 0; font-size: 14px; color: rgba(255, 255, 255, .55); }

/* ---- Flaechen ---- */
.panel {
  margin-bottom: 20px;
  padding: 22px 24px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 6px;
}
.panel h2 { margin: 0 0 5px; font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.panel .sub { margin: 0 0 20px; font-size: 13px; color: rgba(255, 255, 255, .5); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.kachel {
  padding: 18px 20px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 6px;
}
.kachel .k-wert { font-size: 27px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kachel .k-label {
  margin-top: 5px;
  font-size: 11px;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .45);
}

/* ---- Tabelle ---- */
.tabelle-wrap { overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabelle th {
  text-align: left;
  padding: 0 14px 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .13);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .42);
  white-space: nowrap;
}
.tabelle td { padding: 12px 14px 12px 0; vertical-align: middle; }
.tabelle tr:not(.unterzeile) td { border-bottom: 1px solid rgba(255, 255, 255, .07); }
.tabelle tr.unterzeile td { padding: 10px 0 20px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.tabelle tr.unterzeile:last-child td { border-bottom: 0; padding-bottom: 4px; }
.muted { color: rgba(255, 255, 255, .45); }
.st-aktiv { color: #93d7ac; }
.st-gesperrt { color: rgba(255, 255, 255, .45); }

/* ---- Formulare in der App ---- */
.form-zeile { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.form-feld { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 170px; }
.form-feld label {
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: rgba(255, 255, 255, .45);
}

.tabelle input[type="text"],
.tabelle select,
.form-feld input,
.form-feld select {
  width: 100%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.tabelle input[type="text"]:focus,
.tabelle select:focus,
.form-feld input:focus,
.form-feld select:focus {
  border-color: rgba(255, 255, 255, .42);
  background: rgba(255, 255, 255, .09);
}
.form-feld input::placeholder { color: rgba(255, 255, 255, .3); }
option { background: #333739; color: #eef3f2; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 4px;
  background: var(--btn); color: var(--btn-text);
  font: inherit; font-size: 14px; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--btn-hover); }
.btn-klein { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-sec {
  background: transparent;
  border-color: rgba(255, 255, 255, .22);
  color: rgba(255, 255, 255, .82);
}
.btn-sec:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.btn-gefahr { color: #ffb3a6; border-color: rgba(255, 140, 125, .38); }
.btn-gefahr:hover { background: rgba(255, 120, 105, .14); color: #ffd2c9; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; color: rgba(255, 255, 255, .82); }

.aktionen { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

body.app .flash { margin-bottom: 20px; }

@media (max-width: 760px) {
  .appbar { height: auto; flex-direction: column; align-items: flex-start; gap: 12px; padding: 14px 18px; }
  .appnav { flex-wrap: wrap; gap: 16px; }
  .appuser { padding-left: 0; border-left: 0; }
  body.app main { padding: 24px 18px 56px; }
}

/* ---- Smarthome ---- */
.k-zeit { margin-top: 8px; font-size: 12px; color: rgba(255, 255, 255, .38); }
.k-zeit.veraltet, .muted.veraltet { color: #d9a98f; }
.kachel-alt { border-style: dashed; }
.kachel-alt .k-wert { opacity: .55; }

.sh-an  { color: #ffd98a; }
.sh-aus { color: rgba(255, 255, 255, .42); }

tr.verborgen td { opacity: .45; }

.feld-block { margin-bottom: 20px; }
.feld-block:last-of-type { margin-bottom: 22px; }
.feld-label {
  margin-bottom: 8px;
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: rgba(255, 255, 255, .45);
}
.code-zeile, .code-block {
  display: block;
  background: rgba(0, 0, 0, .26);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 4px;
  padding: 11px 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #dfe6e4;
  overflow-x: auto;
  white-space: pre;
  word-break: normal;
}
.code-block { margin: 0; line-height: 1.6; }
.tabelle code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---- Eintrags-Karten (Benutzer, Geräte) ---- */
.eintrag { padding: 20px 0; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.eintrag:first-of-type { padding-top: 2px; }
.eintrag:last-of-type { padding-bottom: 2px; border-bottom: 0; }
.eintrag.verborgen .eintrag-kopf, .eintrag.verborgen .form-zeile { opacity: .5; }

.eintrag-kopf {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 18px; margin-bottom: 15px;
}
.eintrag-titel { font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.eintrag-titel code {
  margin-left: 9px; font-weight: 400; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: rgba(255, 255, 255, .4);
}
.eintrag-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 16px; font-size: 13px; }
.eintrag-meta .wert { font-size: 15px; font-weight: 600; }

.form-feld.schmal { flex: 0 1 120px; min-width: 100px; }
.form-feld.mittel { flex: 0 1 180px; min-width: 150px; }
.form-zeile .aktionen { justify-content: flex-start; margin-left: auto; }
.form-zeile.passwort { margin-top: 12px; }

/* ---- Lampen-Kacheln ---- */
.kachel.licht { display: flex; flex-direction: column; }

.licht-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}
.licht-icon {
  width: 38px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .32);
  transition: background .2s, color .2s, box-shadow .2s;
}
.licht-icon svg { width: 21px; height: 21px; }
.licht.ist-an .licht-icon {
  background: color-mix(in srgb, currentColor 20%, transparent);
  box-shadow: 0 0 18px -2px color-mix(in srgb, currentColor 45%, transparent);
}

.licht-status {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .38);
}
.licht-status.ist-an { color: rgba(255, 255, 255, .8); }

.licht-name { font-size: 16px; font-weight: 600; letter-spacing: .2px; }

.licht-balken {
  height: 5px;
  margin: 13px 0 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
  color: rgba(255, 255, 255, .3);
}
.licht-balken span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: currentColor;
  transition: width .25s;
}

.licht-werte {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 2px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .5);
}
.licht-werte .farbe { display: inline-flex; align-items: center; gap: 7px; }
.farb-punkt {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3);
}

.licht-schalter { margin-top: 14px; }
.licht-schalter .btn { width: 100%; }
.licht-wartet {
  margin-top: 14px;
  padding: 7px 0;
  text-align: center;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .5);
}

.kachel .k-zeit { margin-top: auto; padding-top: 10px; }

.trenner { height: 1px; margin: 26px 0 24px; background: rgba(255, 255, 255, .09); }

.form-feld textarea {
  width: 100%;
  min-height: 132px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color .15s, background .15s;
}
.form-feld textarea:focus { border-color: rgba(255, 255, 255, .42); background: rgba(255, 255, 255, .09); }
.form-feld textarea::placeholder { color: rgba(255, 255, 255, .28); }
.form-feld label code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(255, 255, 255, .65);
}
