:root{
  /* Layout */
  --radius: 18px;
  --radius2: 22px;
  --space: 16px;
  --space2: 18px;

  /* Fonts */
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";

  /* Accents */
  --accent:#7c5cff;
  --accent2:#33d6ff;
  --warn:#ffcc66;
  --bad:#ff5c7a;
  --good:#37d67a;

  /* Dark default tokens */
  --bg: #0b1020;
  --bg2:#0f1730;

  --card: rgba(255,255,255,.06);
  --card2: rgba(255,255,255,.08);

  --stroke: rgba(255,255,255,.12);
  --stroke2: rgba(255,255,255,.18);

  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.70);

  --shadow: 0 18px 50px rgba(0,0,0,.45);
  --shadow2: 0 10px 30px rgba(0,0,0,.35);

  --okBg: rgba(55,214,122,.14);
  --warnBg: rgba(255,204,102,.14);
  --badBg: rgba(255,92,122,.14);
  --okBr: rgba(55,214,122,.28);
  --warnBr: rgba(255,204,102,.28);
  --badBr: rgba(255,92,122,.28);
}

html[data-theme="light"]{
  --bg:#f6f8ff;
  --bg2:#eef2ff;

  --card: rgba(12,18,40,.055);
  --card2: rgba(12,18,40,.085);

  --stroke: rgba(12,18,40,.14);
  --stroke2: rgba(12,18,40,.20);

  --text: rgba(12,18,40,.96);
  --muted: rgba(12,18,40,.74);

  --shadow: 0 16px 44px rgba(10,20,40,.14);
  --shadow2: 0 10px 28px rgba(10,20,40,.12);

  --accent:#5a49ff;
  --accent2:#0bbbd9;

  --okBg: rgba(55,214,122,.16);
  --warnBg: rgba(255,204,102,.18);
  --badBg: rgba(255,92,122,.16);
  --okBr: rgba(55,214,122,.30);
  --warnBr: rgba(255,204,102,.32);
  --badBr: rgba(255,92,122,.30);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--sans);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), var(--bg2));
  overflow-x:hidden;
  min-height: 100svh;
}
[hidden]{ display:none !important; }
a{ color:inherit; text-decoration:none; }
button, input, select{ font: inherit; }
img{ max-width:100%; display:block; }

:focus-visible{
  outline: 3px solid rgba(124,92,255,.35);
  outline-offset: 2px;
}

.sr-only{
  position:absolute!important;
  width:1px!important;
  height:1px!important;
  padding:0!important;
  margin:-1px!important;
  overflow:hidden!important;
  clip:rect(0,0,0,0)!important;
  white-space:nowrap!important;
  border:0!important;
}

.skip-link{
  position:absolute;
  left:-999px;
  top: 10px;
  background: var(--card);
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  border-radius: 12px;
  z-index: 99;
}
.skip-link:focus{ left: 10px; }

/* Layout */
.container{
  width: min(1120px, 100%);
  margin: 0 auto;
  padding-inline: var(--space);
}

.topbar{
  padding: calc(12px + env(safe-area-inset-top)) 0 0;
}
.topbar-inner{
  display:flex;
  flex-direction:column;
  gap: 10px;
}
.topbar-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  flex-wrap:wrap;
}
.top-actions{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  align-items:center;
}

.shell{
  padding-block: 14px calc(14px + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------------
   Buttons / UI (vereinheitlicht wie projectcostplan: Pill + Icon + Label)
   ------------------------------------------------------------------ */
.btn{
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor:pointer;
  user-select:none;
  transition: transform .05s ease, filter .18s ease, background .18s ease, border-color .18s ease;
  box-shadow: var(--shadow2);
  display:inline-flex;
  align-items:center;
  gap: 10px;
  max-width: 100%;
}
.btn:hover{ filter: brightness(1.03); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }

.btn-primary{
  background: linear-gradient(135deg, rgba(124,92,255,.95), rgba(51,214,255,.65));
  border-color: rgba(255,255,255,.22);
  color: #0b1020;
  font-weight: 900;
}
html[data-theme="light"] .btn-primary{ color:#0b1020; }

.btn-danger{
  border-color: rgba(227,66,66,.65);
  background: #e34242;
  color: #fff;
}

.btn-toggle .btn-ico{
  width: 22px; height: 22px;
  display:grid; place-items:center;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.08);
  font-size: 14px;
  line-height: 1;
}
html[data-theme="light"] .btn-toggle .btn-ico{
  background: rgba(255,255,255,.75);
}

.btn-label{ font-weight: 900; }

/* Home Button */
.home-btn{
  padding: 10px 14px;
  min-height: 52px;
}
.home-logo{
  width: 34px;
  height: 34px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  padding: 6px;
  flex: 0 0 auto;
}
.home-text{
  display:flex;
  flex-direction:column;
  line-height: 1.1;
  min-width: 0;
}
.home-domain{
  font-weight: 950;
  letter-spacing: .2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.home-sub{
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

/* Panel / Cards / Headings */
.panel{
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border: 1px solid var(--stroke);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  padding: 14px;
  overflow:hidden;
}

.panel-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  flex-wrap:wrap;
  margin-bottom: 12px;
}

.page-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  flex: 1 1 360px;
  min-width: 0;
}
.page-title-row .h1{ margin:0; min-width:0; }
.page-title-row .right-head{
  display:flex; gap: 10px; align-items:center; flex-wrap:wrap; justify-content:flex-end;
}

.h1{ margin:0; font-size: clamp(20px, 3vw, 30px); line-height:1.1; }
.h2{ margin: 0; font-size: 17px; line-height:1.2; }
.h3{ font-weight: 950; font-size: 15px; margin:0; }
.subtle{ color: var(--muted); }
.mono{ font-family: var(--mono); }

.divider{
  height:1px;
  background: var(--stroke);
  margin: 14px 0;
}

.tabs{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--stroke);
  padding: 8px;
  border-radius: 999px;
  width: 100%;
}
.tab{
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 12px;
  cursor:pointer;
}
.tab.is-active{
  background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(51,214,255,.08));
  border-color: var(--stroke2);
  color: var(--text);
}

.tabpane{ display:none; }
.tabpane.is-active{ display:block; }

.grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items:start;
}
@media (max-width: 920px){
  .grid-2{ grid-template-columns: 1fr; }
  .panel{ padding: 12px; }
}

.card{
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
  padding: 14px;
  overflow:hidden;
}
.card-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap:wrap;
}
.card-head.tight{ margin-bottom: 12px; }
.card-head > div .subtle{
  display:block;
  margin-top: 10px;
}

/* Badges */
.badge{
  display:inline-flex;
  align-items:center;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 100%;
  gap: 6px;
}

/* Live-Badge Zustände */
#liveBadge.is-on{
  background: rgba(63, 134, 37, 1);   /* grün */
  border-color: rgba(0, 0, 0, 1);
  color: rgba(255, 255, 255, 1);
}

#liveBadge.is-off{
  background: rgba(120, 120, 120, .14);  /* grau */
  border-color: rgba(120, 120, 120, .30);
  color: rgba(120, 120, 120, .95);
}

html[data-theme="light"] .badge{
  background: rgba(255,255,255,.80);
  border-color: var(--stroke);
  color: var(--muted);
}
.badge-row{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  justify-content:flex-end;
  align-items:center;
}

.status{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--text);
  font-weight: 900;
  white-space:nowrap;
}
.status.ok{ background: var(--okBg); border-color: var(--okBr); }
.status.warn{ background: var(--warnBg); border-color: var(--warnBr); }
.status.bad{ background: var(--badBg); border-color: var(--badBr); }

.kpi{
  font-size: clamp(18px, 3vw, 30px);
  font-weight: 950;
  line-height:1;
  font-family: var(--mono);
  letter-spacing: .2px;
}
.kpi-sub{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.kv{
  display:grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 10px;
  align-items:center;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--card);
}
.kv + .kv{ margin-top: 10px; }
.kv .key{ color: var(--muted); font-size: 12px; }
.kv .val{ font-family: var(--mono); font-weight: 950; }

.spark{
  width: 100%;
  height: 56px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.05);
  overflow:hidden;
}
html[data-theme="light"] .spark{ background: rgba(255,255,255,.65); }

.log{
  display:flex;
  flex-direction:column;
  gap: 10px;
  max-height: 320px;
  overflow:auto;
  padding-right: 4px;
}
.log-item{
  border: 1px solid var(--stroke);
  background: var(--card);
  border-radius: 16px;
  padding: 10px 12px;
}
.log-item .row{
  display:flex;
  gap: 10px;
  justify-content:space-between;
  align-items:baseline;
  flex-wrap:wrap;
}
.log-item .t{ font-family: var(--mono); font-weight: 950; }
.log-item .m{ color: var(--muted); font-size: 12px; margin-top: 6px; }

.field{ display:flex; flex-direction:column; gap: 6px; min-width:0; }
.label{ color: var(--muted); font-size: 12px; }
.input{
  width: 100%;
  min-width: 0;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.10);
  border-radius: 14px;
  padding: 10px 12px;
  outline:none;
  color: var(--text);
}
html[data-theme="light"] .input{
  background: rgba(255,255,255,.92);
  border-color: rgba(12,18,40,.16);
  color: var(--text);
}
.input:focus{
  border-color: rgba(124,92,255,.6);
  box-shadow: 0 0 0 3px rgba(124,92,255,.14);
}

.form-grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  align-items:end;
}
@media (max-width: 560px){
  .form-grid{ grid-template-columns: 1fr; }
}

.note{
  padding: 12px;
  border-radius: 16px;
  border: 1px dashed var(--stroke2);
  background: rgba(0,0,0,.06);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
html[data-theme="light"] .note{ background: rgba(255,255,255,.78); }

@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior:auto !important; }
}