/* Netzwerk-Lotse Demo Backend — Design Tokens */

:root {
  --bg: #ffffff;
  --bg-elev: #f8f7f4;
  --bg-sunken: #f1efea;
  --surface: #ffffff;
  --border: #e5e2dc;
  --border-strong: #d4d0c7;
  --text: #1a1814;
  --text-muted: #6b665c;
  --text-dim: #9b9588;
  --accent: #1a3f60;        /* Navy — Netzwerk-Lotse Brand */
  --accent-hover: #0f2744;
  --accent-soft: #e6eef0;
  --success: #2f7a4d;
  --success-soft: #e3f0e8;
  --warn: #b86e1a;
  --warn-soft: #f6ebd9;
  --danger: #b23a3a;
  --danger-soft: #f4e1e1;
  --info: #2a5d8f;
  --info-soft: #e2ecf5;

  --shadow-sm: 0 1px 2px rgba(20,18,14,.04);
  --shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 4px 14px rgba(20,18,14,.06);
  --shadow-lg: 0 1px 0 rgba(255,255,255,.6) inset, 0 12px 40px rgba(20,18,14,.10);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elev: #161922;
  --bg-sunken: #0a0c10;
  --surface: #1a1e28;
  --border: #262b37;
  --border-strong: #343b4a;
  --text: #ecebe7;
  --text-muted: #9ea4b1;
  --text-dim: #5f6573;
  --accent: #6ec5d6;
  --accent-hover: #8ed4e0;
  --accent-soft: #1a3038;
  --success: #5fb87f;
  --success-soft: #16302a;
  --warn: #d6a45c;
  --warn-soft: #2e2618;
  --danger: #e07b7b;
  --danger-soft: #321a1f;
  --info: #7ab0e0;
  --info-soft: #18283c;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 4px 14px rgba(0,0,0,.4);
  --shadow-lg: 0 1px 0 rgba(255,255,255,.04) inset, 0 12px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Material Icons sizing */
.mi { font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal;
  font-size: 18px; line-height: 1; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr;
  -webkit-font-smoothing: antialiased; vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.mi.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.mi.sm { font-size: 16px; }
.mi.lg { font-size: 22px; }
.mi.xl { font-size: 28px; }

/* App shell */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  background: var(--bg-sunken);
}
.app.mobile { grid-template-columns: 1fr; }

/* Sidebar */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.sidebar-brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  letter-spacing: -.02em;
}
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand-text b { font-size: 13px; font-weight: 600; }
.sidebar-brand-text span { font-size: 11px; color: var(--text-muted); }

.sidebar-section {
  font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim); padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-elev); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .mi { font-size: 18px; }
.nav-item-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
  height: 56px;
}
.role-switch {
  display: flex; gap: 2px; padding: 3px; background: var(--bg-elev);
  border-radius: 9px; border: 1px solid var(--border);
}
.role-switch button {
  appearance: none; border: 0; background: transparent;
  padding: 5px 12px; border-radius: 7px;
  font: 500 12px var(--font); color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.role-switch button.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
}
.role-switch button .mi { font-size: 15px; }

.search-box {
  flex: 1; max-width: 380px;
  position: relative;
}
.search-box input {
  width: 100%; height: 34px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-elev); color: var(--text);
  padding: 0 10px 0 32px; font: 13px var(--font); outline: none;
}
.search-box input:focus { background: var(--surface); border-color: var(--border-strong); }
.search-box .mi { position: absolute; left: 9px; top: 8px; font-size: 17px; color: var(--text-dim); }

.topbar-spacer { flex: 1; }
.topbar-icon-btn {
  position: relative;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elev);
  display: grid; place-items: center; cursor: pointer; color: var(--text-muted);
}
.topbar-icon-btn:hover { background: var(--surface); color: var(--text); }
.topbar-icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg-elev);
}
.topbar-user {
  display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 30px; background: var(--bg-elev);
}
.topbar-user .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}
.topbar-user .name { font-size: 12px; font-weight: 500; }
.topbar-user .sub { font-size: 11px; color: var(--text-muted); }

/* Page */
.page {
  padding: 24px 28px 80px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 {
  font-size: 22px; font-weight: 600; letter-spacing: -.01em;
  margin: 0 0 4px;
}
.page-head .sub { color: var(--text-muted); font-size: 13px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 500 13px var(--font);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-elev); border-color: var(--border-strong); }
.btn .mi { font-size: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; justify-content: center; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-elev); }

/* KPI cards */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.kpi-foot { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.kpi-foot.up { color: var(--success); }
.kpi-foot.down { color: var(--danger); }
.kpi .mi-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); }
.kpi-row { display: flex; align-items: center; justify-content: space-between; }

/* Card */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg-elev); }
.tbl .mono { font-family: var(--font-mono); font-size: 12px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badge / status */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 12px;
  background: var(--bg-elev); color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge.ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.acc { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Layout */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Sparkline / bar */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 40px; }
.spark .b { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .8; min-height: 2px; }
.spark .b.dim { background: var(--border-strong); }

/* Bandwidth bar */
.bw {
  height: 6px; background: var(--bg-elev); border-radius: 3px; overflow: hidden;
  position: relative;
}
.bw > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bw.warn > span { background: var(--warn); }
.bw.err > span { background: var(--danger); }

/* Building visualizer */
.building {
  display: grid; gap: 4px;
  grid-template-columns: repeat(4, 1fr);
}
.unit-cell {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  transition: background .12s, border-color .12s;
}
.unit-cell:hover { background: var(--surface); border-color: var(--accent); }
.unit-cell.online { border-left: 3px solid var(--success); }
.unit-cell.warn { border-left: 3px solid var(--warn); }
.unit-cell.offline { border-left: 3px solid var(--danger); }
.unit-cell.vacant { opacity: .5; border-left: 3px solid var(--text-dim); }
.unit-cell .head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; }
.unit-cell .name { font-size: 11px; color: var(--text-muted); }
.unit-cell .meta { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }

/* Smart-Tenant-Core widget */
.stc {
  background: linear-gradient(180deg, var(--surface), var(--bg-elev));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; display: grid; grid-template-columns: auto 1fr; gap: 18px;
}
.stc-device {
  width: 110px; height: 130px; border-radius: 12px;
  background: #1c2230; color: #d8e4ec;
  position: relative;
  box-shadow: 0 6px 18px rgba(20,18,14,.18), 0 0 0 1px rgba(0,0,0,.05);
  overflow: hidden;
  display: flex; flex-direction: column; padding: 9px;
}
.stc-device::before {
  content: ''; position: absolute; left: 8px; right: 8px; top: 8px; bottom: 35px;
  background: #f5f3eb; border-radius: 4px;
}
.stc-device .eink {
  position: absolute; left: 12px; right: 12px; top: 12px; bottom: 39px;
  color: #1c2230; padding: 6px; font-family: var(--font-mono); font-size: 9px;
  display: flex; flex-direction: column; gap: 2px;
}
.stc-device .eink b { font-size: 10px; }
.stc-device .led { position: absolute; bottom: 8px; left: 10px; width: 5px; height: 5px;
  border-radius: 50%; background: #5fb87f; box-shadow: 0 0 6px #5fb87f; }
.stc-device .label { position: absolute; bottom: 6px; right: 10px; font-size: 8px;
  letter-spacing: .12em; color: #6b7280; }

.stc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-content: center; }
.stc-stat { display: flex; flex-direction: column; gap: 2px; }
.stc-stat b { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.stc-stat span { font-size: 11px; color: var(--text-muted); }

/* Form rows */
.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-row label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-row input, .form-row select, .form-row textarea {
  font: 13px var(--font); color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; outline: none;
}
.form-row input:focus, .form-row textarea:focus { background: var(--surface); border-color: var(--border-strong); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,18,14,.4);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: var(--bg); padding: 9px 16px;
  border-radius: 22px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* QR */
.qr-box {
  background: #fff; padding: 10px; border-radius: 10px; display: inline-block;
  border: 1px solid var(--border);
}

/* Mieter mobile UI */
.mobile-app {
  background: var(--bg);
  height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.mobile-head {
  padding: 12px 18px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.mobile-head .greet { font-size: 12px; color: var(--text-muted); }
.mobile-head .greet b { display: block; font-size: 17px; color: var(--text); font-weight: 600; }
.mobile-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 6px 8px 22px;
}
.mobile-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; color: var(--text-muted); padding: 6px 4px;
  border-radius: 8px; cursor: pointer;
}
.mobile-tab.active { color: var(--accent); }
.mobile-tab .mi { font-size: 22px; }
.mobile-content { flex: 1; overflow-y: auto; padding: 4px 16px 12px; }

.m-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px; margin-bottom: 12px;
}
.m-card h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.m-card .sub { font-size: 12px; color: var(--text-muted); }

.m-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.m-list-item:last-child { border-bottom: 0; }
.m-list-item .ic {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
}
.m-list-item .body { flex: 1; }
.m-list-item .body b { display: block; font-size: 13px; }
.m-list-item .body span { font-size: 11px; color: var(--text-muted); }

.tile-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  min-height: 90px;
}
.tile.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tile-head { display: flex; align-items: center; justify-content: space-between; }
.tile-head .mi { font-size: 22px; }
.tile-name { font-size: 12px; font-weight: 600; }
.tile-state { font-size: 10px; opacity: .8; }

/* Toggle switch */
.switch {
  position: relative; width: 36px; height: 20px;
  background: var(--border-strong); border-radius: 10px; cursor: pointer;
  transition: background .15s;
}
.switch::after {
  content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: left .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch.on { background: var(--accent); }
.switch.on::after { left: 18px; }

/* Ticket */
.ticket-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.ticket-row:last-child { border-bottom: 0; }
.ticket-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* Activity feed */
.activity { display: flex; flex-direction: column; }
.activity-row {
  display: flex; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.activity-row:last-child { border-bottom: 0; }
.activity-ic {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-elev); color: var(--text-muted); flex: none;
}
.activity-ic.ok { background: var(--success-soft); color: var(--success); }
.activity-ic.warn { background: var(--warn-soft); color: var(--warn); }
.activity-ic.err { background: var(--danger-soft); color: var(--danger); }
.activity-body { flex: 1; font-size: 12.5px; }
.activity-body b { font-weight: 600; }
.activity-body .t { font-size: 11px; color: var(--text-muted); }

/* Range slider for smart home */
.rng { width: 100%; appearance: none; background: transparent; height: 24px; }
.rng::-webkit-slider-runnable-track {
  background: var(--bg-elev); height: 6px; border-radius: 3px;
}
.rng::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); margin-top: -6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* Floor plan */
.floor {
  display: grid; gap: 6px;
}
.floor-row { display: grid; grid-template-columns: 60px 1fr; gap: 8px; align-items: center; }
.floor-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-align: right; padding-right: 8px; }
.floor-units { display: grid; gap: 6px; grid-auto-flow: column; grid-auto-columns: 1fr; }

/* Topology mini */
.topo {
  position: relative; height: 200px; padding: 14px;
  background: repeating-linear-gradient(45deg, var(--bg-elev) 0 1px, transparent 1px 12px),
              var(--surface);
  border-radius: 10px;
}

/* Misc */
.muted { color: var(--text-muted); }
.right { text-align: right; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.fs-11 { font-size: 11px; } .fs-12 { font-size: 12px; } .fs-14 { font-size: 14px; }
.fw-6 { font-weight: 600; }
.mono { font-family: var(--font-mono); }

/* Responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: 16px; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .role-switch button { padding: 5px 8px; font-size: 11px; }
  .role-switch button span:not(.mi) { display: none; }
  .search-box { display: none; }
  .topbar-user .name, .topbar-user .sub { display: none; }
}
