:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1a2130;
  --muted: #667085;
  --line: #e3e7ee;
  --primary: #2f57d6;
  --primary-ink: #ffffff;
  --sidebar: #131926;
  --sidebar-ink: #c6cede;
  --sidebar-active: #2f57d6;
  --ok: #1f9d63;
  --warn: #c98a12;
  --bad: #d0402b;
  --idle: #9aa4b6;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App-Gerüst ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 18px 14px;
  flex-shrink: 0;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.brand-mark { color: #6c8cff; font-size: 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--sidebar-ink);
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
.nav-sep { height: 1px; background: rgba(255,255,255,.09); margin: 12px 4px; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.page { padding: 24px; max-width: 1120px; }

/* ---- Rollen-Badge ---- */
.role-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.role-admin { color: #7a3ad0; border-color: #d9c8f2; background: #f5eefe; }
.role-editor { color: #1f6fd0; border-color: #cbdcf4; background: #eef4fd; }
.role-viewer { color: var(--muted); }

/* ---- Flash ---- */
.flash {
  padding: 11px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash-success { background: #e9f7ef; border-color: #bfe6cf; color: #14663f; }
.flash-error   { background: #fdece9; border-color: #f4c4bb; color: #9a2a19; }
.flash-info    { background: #eef3fd; border-color: #cbdcf4; color: #1f4a9a; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #eef1f6; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---- Werkzeugleiste über Tabellen ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar h2 { margin: 0; font-size: 18px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.crumbs a { color: var(--muted); }

/* ---- Karten ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .num { font-family: var(--mono); font-size: 28px; font-weight: 600; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---- Tabellen ---- */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.data th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 13px; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfd; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.empty { padding: 32px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---- Status-Punkte ---- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.s-frei .dot, .dot.frei { background: var(--idle); }
.s-belegt .dot, .dot.belegt { background: var(--ok); }
.s-reserviert .dot, .dot.reserviert { background: var(--warn); }
.s-defekt .dot, .dot.defekt { background: var(--bad); }

/* ---- Formulare ---- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
.input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
textarea.input { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-narrow { max-width: 520px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---- Port-Raster (Kernelement der Panel-Ansicht) ---- */
.portgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; margin-top: 8px; }
.port {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 8px 9px;
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  display: block;
  border-top: 3px solid var(--idle);
}
.port:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.port .pnum { font-family: var(--mono); font-weight: 600; font-size: 13px; }
.port .plabel { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port.belegt { border-top-color: var(--ok); }
.port.reserviert { border-top-color: var(--warn); }
.port.defekt { border-top-color: var(--bad); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; }

/* ---- Kabelfarbe-Chip ---- */
.cable { display: inline-flex; align-items: center; gap: 6px; }
.cable i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); display: inline-block; }

/* ---- Auth-Seiten ---- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--sidebar); }
.auth-card { background: var(--surface); border-radius: 12px; padding: 30px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.brand-lg { font-size: 20px; justify-content: center; margin-bottom: 22px; }
.auth-card .btn { width: 100%; justify-content: center; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 14px; }
.sso-divider { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0; position: relative; }
.sso-divider::before, .sso-divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--line); }
.sso-divider::before { left: 0; } .sso-divider::after { right: 0; }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .two-col { grid-template-columns: 1fr; }
}
