/* ==========================================================================
   Landingpage – gemeinsame Basis (Startseite + Admin)
   ========================================================================== */

@font-face {
  font-family: "Bricolage";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/bricolage-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/bricolage-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --rail-w: 272px;
  --radius: 14px;
  --font: "Bricolage", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Dunkel (Standard): Schieferblau statt Schwarz, damit die Dienstfarben tragen */
  --bg: #121826;
  --rail: #182033;
  --surface: #1e2840;
  --surface-2: #26314c;
  --line: #2c3854;
  --text: #e8edf5;
  --muted: #8f9bb3;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset;
  --accent: #5b8def;
  --danger: #ff6b6b;
  --ok: #4cc38a;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #dde3eb;
    --rail: #edf0f5;
    --surface: #f8f9fb;
    --surface-2: #e9edf3;
    --line: #ccd4e0;
    --text: #172033;
    --muted: #5b6880;
    --shadow: 0 1px 2px rgba(23, 32, 51, .06);
    --danger: #d64545;
    --ok: #1f8f5a;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #dde3eb;
  --rail: #edf0f5;
  --surface: #f8f9fb;
  --surface-2: #e9edf3;
  --line: #ccd4e0;
  --text: #172033;
  --muted: #5b6880;
  --shadow: 0 1px 2px rgba(23, 32, 51, .06);
  --danger: #d64545;
  --ok: #1f8f5a;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  font-feature-settings: "tnum" 0;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { top: 12px; }

/* ---------- Seitenleiste (immer sichtbar ab 900px) ---------- */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 14px 14px;
  background: var(--rail);
  border-right: 1px solid var(--line);
  z-index: 30;
}
.rail-head { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand-mark, .brand-logo {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
}
.brand-mark {
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-weight: 750; font-size: 15px; letter-spacing: -.02em;
}
.brand-logo { object-fit: contain; background: var(--accent); padding: 6px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 700; font-size: 17px; letter-spacing: -.01em; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-close { display: none; }

.search {
  position: relative;
  display: flex; align-items: center;
  margin: 0 2px;
}
.search svg { position: absolute; z-index: 1; left: 11px; color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.search input {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  position: absolute; z-index: 1; right: 9px;
  min-width: 20px; height: 20px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 5px;
  color: var(--muted); font: 600 11px var(--font);
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.tree { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.tree ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tree a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 38px;
  padding: 6px 10px 6px calc(10px + var(--depth, 0) * 18px);
  border-radius: 9px;
  color: var(--muted);
  font-weight: 500;
}
.tree a:hover { background: var(--surface); color: var(--text); }
.tree a.is-active { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: var(--shadow); }
.tree a.is-active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--c);
}
.tree a.is-trail { color: var(--text); }
.tree .dot {
  width: 24px; height: 24px; flex: none; border-radius: 7px;
  background: var(--c); display: grid; place-items: center;
}
.tree .dot:empty { width: 10px; height: 10px; border-radius: 50%; margin: 0 7px; }
.tree .dot img { width: 72%; height: 72%; object-fit: contain; }
.tree .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.rail-foot { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.ghost {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 36px; padding: 6px 10px;
  border: 0; border-radius: 9px; background: none;
  color: var(--muted); font-size: 14px; cursor: pointer; text-align: left;
}
.ghost:hover { background: var(--surface); color: var(--text); }
.ghost svg { width: 18px; height: 18px; }

.scrim { display: none; }

/* ---------- Inhalt ---------- */
main {
  margin-left: var(--rail-w);
  padding: 22px clamp(20px, 4vw, 56px) 64px;
  max-width: calc(var(--rail-w) + 1320px);
}
.top { display: flex; align-items: center; justify-content: flex-end; gap: 20px; min-height: 40px; }

/* ---------- Schnellzugriff mit Online-Status ---------- */
.quick {
  display: flex; gap: 6px; flex: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: none; padding: 2px;
}
.quick::-webkit-scrollbar { display: none; }
.quick > :first-child { margin-left: auto; }
.dev {
  --led: var(--muted);
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  height: 34px; padding: 0 12px 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 550; white-space: nowrap;
}
a.dev:hover { border-color: color-mix(in srgb, var(--led) 60%, var(--line)); }
.dev img { width: 22px; height: 22px; padding: 3px; object-fit: contain; border-radius: 6px; background: var(--accent); margin-left: -4px; }
.led {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--led);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--led) 22%, transparent);
}
.dev[data-state="unknown"] .led { opacity: .45; }
.dev[data-state="online"] { --led: var(--ok); }
.dev[data-state="offline"] { --led: var(--danger); }
.dev[data-state="offline"] .dev-name { color: var(--muted); }
.dev[data-state="none"] .led, .dev[data-state="na"] .led { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.menu { display: none; }
.clock { display: flex; align-items: baseline; gap: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.clock [data-time] { color: var(--text); font-size: 22px; font-weight: 600; letter-spacing: -.02em; }

.head { margin: 12px 0 26px; }
.head h1 {
  margin: 0;
  font-size: clamp(34px, 4.4vw, 52px);
  line-height: 1.02;
  font-weight: 760;
  letter-spacing: -.035em;
}
.head h1::after {
  content: ""; display: block; width: 44px; height: 5px; margin-top: 14px; border-radius: 3px; background: var(--cat, var(--accent));
}
.head .meta { margin: 10px 0 0; color: var(--muted); }
.trail { margin: 0 0 8px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; }
.trail a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.subs { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.subs a {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 550;
}
.subs a:hover { border-color: var(--c); }
.subs .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* ---------- Kacheln ---------- */
/* Freie Anordnung: feste Spaltenzahl, jede Kachel auf ihrem Feld (--x/--y) */
.grid.placed { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); grid-auto-rows: minmax(84px, auto); }
.grid.placed > .tile { grid-column: var(--x, auto); grid-row: var(--y, auto); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.tile {
  --c: var(--accent);
  display: flex; align-items: center; gap: 14px;
  min-height: 84px;
  padding: 14px 16px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .15s ease, background-color .15s ease;
}
.tile:hover {
  border-color: color-mix(in srgb, var(--c) 70%, var(--line));
  background: color-mix(in srgb, var(--c) 7%, var(--surface));
}
.tile:focus-visible { outline-offset: 3px; border-radius: var(--radius); }
.chip {
  width: 54px; height: 54px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: var(--c);
  color: #fff;
  overflow: hidden;
}
.chip img { width: 66%; height: 66%; object-fit: contain; }
.chip .initials { font-weight: 720; font-size: 19px; letter-spacing: -.03em; text-shadow: 0 1px 1px rgba(0,0,0,.15); }
.tile .body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.tile .title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 650; font-size: 16.5px; letter-spacing: -.01em; line-height: 1.25; }
.tile .tt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .sub { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .host {
  display: block;
  margin-top: 3px; color: var(--muted); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag {
  flex: none;
  padding: 1px 6px; border-radius: 5px;
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok); font-size: 11px; font-weight: 650; letter-spacing: .02em;
}
.tile .cat { color: var(--muted); margin-left: 6px; }
.tile.is-first { border-color: var(--accent); }

.empty {
  padding: 40px 24px; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); text-align: center;
}
.empty p { margin: 0 0 14px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600; border: 0; cursor: pointer;
}

/* ---------- Mobil: Seitenleiste wird zur Schublade ---------- */
@media (max-width: 899px) {
  .rail {
    width: min(86vw, 320px);
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.3);
  }
  body.rail-open .rail { transform: none; }
  body.rail-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(8, 12, 20, .45); }
  .rail-close {
    display: grid; place-items: center; width: 36px; height: 36px;
    border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: pointer;
  }
  main { margin-left: 0; padding: 12px 16px 48px; }
  .top { justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; }
  .quick { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 2px 16px; }
  .quick > :first-child { margin-left: 0; }
  .menu {
    display: grid; place-items: center; width: 40px; height: 40px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer;
  }
  .clock [data-date] { display: none; }
  .clock [data-time] { font-size: 18px; }
  .grid, .grid.placed { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
  .grid.placed > .tile { grid-column: auto; grid-row: auto; }
  .grid.placed { grid-auto-rows: auto; }
  .tile { min-height: 72px; padding: 12px; }
  .chip { width: 46px; height: 46px; border-radius: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
