:root{
  --bg: #0b0c0f;
  --panel: #111218;
  --panel-2: #0f1015;
  --text: #f4f5f7;
  --muted: #b6bcc8;
  --muted-2: #8b93a3;
  --border: rgba(255,255,255,0.08);
  --border-2: rgba(255,255,255,0.12);
  --shadow: 0 16px 48px rgba(0,0,0,0.55);
  --shadow-soft: 0 10px 28px rgba(0,0,0,0.38);
  --radius: 18px;
  --radius-sm: 12px;
  --focus: 0 0 0 4px rgba(255,255,255,0.10);
  --accent: #ffffff;
  --danger: #ff6b6b;
  --ok: #b7ffcf;
}

/* Abo/Daycount Hinweis (Topics) */
.subinfo{
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
}
.subinfo strong{ font-weight: 700; }

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(255,255,255,0.06), transparent 55%),
    radial-gradient(900px 500px at 80% 10%, rgba(255,255,255,0.05), transparent 60%),
    var(--bg);
}

a{ color:inherit; text-decoration:none; }

.container{
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 18px 46px;
}

.nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(17,18,24,0.55);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1000;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
}

.logo{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,0.22), rgba(255,255,255,0.06));
  border:1px solid var(--border);
  position:relative;
  overflow:hidden;
}
.logo::after{
  content:"";
  position:absolute;
  inset:-20px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.24), transparent 55%);
  transform: rotate(18deg);
}

.brand .title{
  display:flex;
  flex-direction:column;
  line-height:1.1;
}
.brand .title strong{
  font-size: 16px;
  letter-spacing: .2px;
}
.brand .title span{
  font-size: 12px;
  color: var(--muted);
}

.nav-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  overflow: visible;
}

/* --- Header Dropdown Menü --- */
.menu{
  position: relative;
  display: inline-flex;
  align-items: center;
}

.menu-btn{
  user-select: none;
}

.menu-caret{
  opacity: .8;
  font-weight: 800;
}

.menu-panel{
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(17,18,24,0.92);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  display: none;
  z-index: 9999; /* FIX: über Cards/Content */
}

.menu.is-open .menu-panel{
  display: block;
}

.menu-item{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.menu-item:hover{
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}

.menu-item:focus{
  outline: none;
  box-shadow: var(--focus);
}

.menu-item-danger{
  color: #ffd0d0;
}

.menu-sep{
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 8px 2px;
}

.menu-form{
  margin: 0;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 12px;
  border-radius: 999px;
  border:1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 12.5px;
}

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: var(--text);
}

.btn{
  appearance:none;
  border:1px solid var(--border-2);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
  display:inline-flex;
  align-items:center;
  gap:10px;
}
.btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,0.10); }
.btn:active{ transform: translateY(0px); }
.btn:focus{ outline:none; box-shadow: var(--focus); }
.btn.primary{
  background: rgba(255,255,255,0.92);
  color:#111218;
  border-color: rgba(255,255,255,0.92);
}
.btn.primary:hover{ background: rgba(255,255,255,1); }
.btn.ghost{
  background: transparent;
}
.btn.danger{
  background: rgba(255,107,107,0.10);
  border-color: rgba(255,107,107,0.25);
  color: #ffd0d0;
}

.hero{
  margin-top: 18px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17,18,24,0.72), rgba(15,16,21,0.72));
  box-shadow: var(--shadow);
  position:relative;
  overflow:hidden;
}
.hero::before{
  content:"";
  position:absolute;
  inset:-80px -120px auto auto;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.14), transparent 60%);
  border-radius: 50%;
  pointer-events: none;
}
.hero h1{ margin:0; font-size: 34px; letter-spacing:.2px; }
.hero p{ margin: 10px 0 0; color: var(--muted); max-width: 64ch; }

.grid{
  display:grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 18px;
  margin-top: 18px;
}
@media (max-width: 900px){
  .grid{ grid-template-columns: 1fr; }
}

.card{
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17,18,24,0.55);
  box-shadow: var(--shadow-soft);
}
.card h2{
  margin:0 0 14px;
  font-size: 15px;
  color: var(--muted);
  letter-spacing:.2px;
  text-transform: uppercase;
}

.form{
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.field .label{
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 7px;
}

.input{
  width:100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  color: var(--text);
  outline:none;
}
.input:focus{
  box-shadow: var(--focus);
  border-color: rgba(255,255,255,0.18);
}

.help{
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted-2);
}

.alert{
  border: 1px solid rgba(255,107,107,0.30);
  background: rgba(255,107,107,0.10);
  color: #ffd0d0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.alert-ok{
  border: 1px solid rgba(183,255,207,0.30);
  background: rgba(183,255,207,0.10);
  color: var(--ok);
}

.kpi{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.badge{
  display:inline-flex;
  align-items:center;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  font-size: 12px;
  color: var(--muted);
}

.kpi-sub{ color: var(--muted-2); font-size: 12px; }

.footer{
  margin-top: 18px;
  padding: 14px 4px;
  display:flex;
  justify-content:space-between;
  color: var(--muted-2);
  font-size: 12px;
}
/* ===== Historie (Charts) ===== */

.history-controls{
  margin-top: 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.seg{
  display:inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.14);
}

.seg-btn{
  appearance:none;
  border:1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.seg-btn:hover{
  background: rgba(255,255,255,0.06);
}
.seg-btn.is-active{
  background: rgba(255,255,255,0.92);
  color: #111218;
}

.history-grid{
  margin-top: 18px;
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 900px){
  .history-grid{ grid-template-columns: 1fr; }
}

.chart-card{
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17,18,24,0.45);
  box-shadow: var(--shadow-soft);
  min-height: 280px;
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.chart-title{
  font-size: 13px;
  color: var(--muted);
  letter-spacing:.2px;
  text-transform: uppercase;
  font-weight: 800;
}

.chart-card canvas{
  width:100% !important;
  height: 220px !important;
}
/* --- Ergänzungen für Profile-Seite (keine Inline-CSS in EJS) --- */
.inline-form{ display:inline; }

.hero.compact{ padding:22px; }
.page-title{ font-size:28px; margin-bottom:6px; }

/* Kleiner Button wie Logout, aber für "Speichern" */
.btn.sm{
  padding: 8px 12px;
  font-size: 14px;
  gap: 8px;
}

.hr{
  border:0;
  border-top:1px solid var(--border);
  margin: 12px 0;
}

/* ===== Dashboard (Topics) ===== */

/* Statusbar */
.status-bar{
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}

/* Gruppen-Karten: 2 nebeneinander, mobil 1 */
.group-grid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 820px){
  .group-grid{ grid-template-columns: 1fr; }
}

.group-card{
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17,18,24,0.45);
  box-shadow: var(--shadow-soft);
}

.group-card-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.group-card-title{
  display:flex;
  align-items:center;
  gap:10px;
}
.group-card-icon{ font-size: 18px; }
.group-card-sub{ white-space: nowrap; }

/* Werte innerhalb einer Gruppe */
.metric-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 520px){
  .metric-grid{ grid-template-columns: 1fr; }
}

.metric{
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 12px;
  background: rgba(0,0,0,0.14);
}

.metric-label{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight: 700;
  margin-bottom: 8px;
}

.metric-icon{
  width: 22px;
  height: 22px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size: 18px;
}

.metric-value{
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .2px;
}

/* bool-highlight (Default) */
.metric.is-on{
  border-color: rgba(183,255,207,0.35);
  background: rgba(183,255,207,0.06);
}
.metric.is-off{
  border-color: rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.14);
}
.metric.is-na{
  border-color: rgba(255,255,255,0.10);
  opacity: 0.85;
}

/* ===== Per-Topic Farben (frei wählbar) =====
   Jede Metric hat eine Klasse: .topic-<keyLowercase>
   Beispiel: key "ChargerStatus" => .topic-chargerstatus
*/

/* ChargerStatus: eigenes Grün */
.metric.topic-chargerstatus.is-on{
  border-color: rgba(80, 220, 140, 0.45);
  background: rgba(80, 220, 140, 0.10);
}

/* Alarm: kräftiger Rotton */
.metric.topic-alarm.is-on{
  border-color: rgba(255, 90, 90, 0.55);
  background: rgba(255, 90, 90, 0.14);
}

/* BilgePump: Blau/Türkis */
.metric.topic-bilgepump.is-on{
  border-color: rgba(90, 190, 255, 0.55);
  background: rgba(90, 190, 255, 0.12);
}

/* NoCharge: Orange/Amber */
.metric.topic-nocharge.is-on{
  border-color: rgba(255, 180, 70, 0.55);
  background: rgba(255, 180, 70, 0.12);
}

/* ===== Kleine Buttons in der "Laden"-Card ===== */
.charge-controls{
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.charge-controls-title{
  font-size: 12px;
  color: var(--muted-2);
  margin-bottom: 10px;
}

.charge-controls-row{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip-btn{
  appearance:none;
  border: 1px solid var(--border-2);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor:pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.chip-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.08);
}

.chip-btn:focus{
  outline:none;
  box-shadow: var(--focus);
}

/* Active: grün */
.chip-btn.is-active{
  border-color: rgba(80, 220, 140, 0.55);
  background: rgba(80, 220, 140, 0.14);
  color: var(--text);
}


/* Toggle-Button innerhalb einer Metric-Kachel (Always Charge) */
.metric-toggle-btn{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: #f4f5f7;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.metric-toggle-btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,0.08);
}

.metric-toggle-btn:focus{
  outline: none;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.10);
}

/* Active (grün) – gleiche Logik wie chip-btn.is-active */
.metric-toggle-btn.is-active{
  border-color: rgba(80, 220, 140, 0.55);
  background: rgba(80, 220, 140, 0.14);
}

/* --- Admin Layout --- */
.admin-layout{
  display:grid;
  grid-template-columns: 1.05fr 1.45fr;
  gap: 16px;
  align-items:start;
}

.admin-h2{
  margin:0 0 10px 0;
}

.admin-list-head{
  display:flex;
  align-items:center;
  gap:12px;
  justify-content:space-between;
}

.admin-table-wrap{
  overflow:auto;
  border-radius: 12px;
}

.admin-table{
  width:100%;
  border-collapse:collapse;
  font-size: 14px;
}

.admin-table thead th{
  text-align:left;
  padding:10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space:nowrap;
}

.admin-table tbody td{
  padding:10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  vertical-align:top;
}

.admin-row{
  cursor:pointer;
}

.admin-row.is-selected td{
  background: rgba(255,255,255,0.04);
}

.admin-daycount{
  display:flex;
  gap:8px;
  align-items:center;
}

.admin-daycount-input{
  width: 90px;
}

.btn.small{
  padding: 8px 10px;
  font-size: 13px;
}

.btn.danger{
  border: 1px solid rgba(255,80,80,0.6);
  color: rgba(255,200,200,1);
}

.admin-detail-head{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.admin-pre{
  margin:0;
  padding:12px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
  overflow:auto;
  min-height: 120px;
}

/* responsive */
@media (max-width: 980px){
  .admin-layout{
    grid-template-columns: 1fr;
  }
}

.subscription-row {
  display: flex;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.subinfo {
  flex: 1;
}

.notify-box {
  width: 260px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
}

.notify-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.notify-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.notify-toggle input {
  cursor: pointer;
}

.notify-status {
  margin-top: 6px;
  font-size: 0.85em;
  opacity: 0.7;
}


/* ===== Home: Demo-Chart in Card ===== */
.home-chart-card{
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17,18,24,0.45);
  box-shadow: var(--shadow-soft);
}

.home-chart-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.home-chart-title{
  font-weight: 800;
  letter-spacing: .2px;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 13px;
}

.home-chart-sub{
  margin: 0;
  white-space: nowrap;
}

.home-chart-canvas{
  height: 240px;
  width: 100%;
}

.home-chart-canvas canvas{
  width: 100% !important;
  height: 240px !important;
}

/* ===== Footer Links (Legal) ===== */
.footer.footer-links{
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link{
  color: var(--muted-2);
  border-bottom: 1px solid transparent;
  transition: color .12s ease, border-color .12s ease;
}

.footer-link:hover{
  color: var(--text);
  border-color: rgba(255,255,255,0.22);
}

.footer-link.is-active{
  color: var(--text);
  border-color: rgba(255,255,255,0.35);
}

.footer-sep{
  color: rgba(255,255,255,0.22);
}