:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #18212d;
  --muted: #667085;
  --line: #e2e6ec;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok: #1a9c55;
  --warn: #c98a00;
  --err: #d0352b;
  --chassis: #2a3340;
  --chassis-2: #1d242e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --panel: #171e27; --ink: #e6ebf1; --muted: #8b97a8; --line: #273140;
    --chassis: #0b0f14; --chassis-2: #06090c;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.boot, .loading { padding: 48px; text-align: center; color: var(--muted); }
.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Header */
header.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
header.top .brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
header.top .brand .logo { width: 26px; height: 18px; border-radius: 3px; background: var(--chassis);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; }
header.top .brand .logo i { background: #3ccf7a; border-radius: 1px; }
header.top nav { display: flex; gap: 4px; flex: 1; }
header.top nav a { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
header.top nav a.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
header.top nav a:hover { color: var(--ink); }
header.top .user { color: var(--muted); display: flex; gap: 12px; align-items: center; white-space: nowrap; }
main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Buttons & Inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.danger.solid { background: var(--err); color: #fff; border-color: var(--err); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
input[type=text], input[type=password], input[type=number], input[type=search], select {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
label.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* Layout */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar h1 { font-size: 20px; margin: 0; margin-right: auto; }
.toolbar .sub { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.error-box { background: color-mix(in srgb, var(--err) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--err) 35%, transparent);
  color: var(--err); padding: 14px 16px; border-radius: var(--radius); margin-bottom: 14px; }
.warn-box { background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; }

/* Übersicht */
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sw-card { display: block; padding: 14px 16px; color: inherit; transition: transform .08s, border-color .08s; }
.sw-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.sw-card .row1 { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.sw-card .row2 { color: var(--muted); font-size: 12.5px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.sw-card.off { opacity: .8; }
.sw-card .err { color: var(--err); font-size: 12.5px; margin-top: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.dot.off { background: var(--err); }
.stats { display: flex; gap: 18px; color: var(--muted); }
.stats b { color: var(--ink); }

/* Frontpanel */
.chassis { background: linear-gradient(180deg, var(--chassis), var(--chassis-2)); border-radius: 12px; padding: 16px 18px 12px;
  display: flex; gap: 28px; align-items: flex-end; overflow-x: auto; margin-bottom: 18px; box-shadow: var(--shadow); }
.chassis .label { color: #9fb0c4; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.chassis .ident { color: #dfe7f1; font-weight: 600; font-size: 13px; align-self: center; min-width: 120px; }
.chassis .ident small { display: block; color: #8b9bb0; font-weight: 400; margin-top: 2px; }
.pgrid { display: grid; grid-template-rows: repeat(2, auto); grid-auto-flow: column; gap: 6px; }
.pgrid.one { grid-template-rows: auto; }
.ptile { width: 38px; height: 34px; border-radius: 4px; border: 2px solid #4a5768; background: #11161d; cursor: pointer;
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff;
  font-size: 10.5px; line-height: 1.1; padding: 0; user-select: none; }
.ptile.sfp { width: 42px; border-radius: 3px; }
.ptile .n { font-weight: 700; font-size: 12px; }
.ptile .v { opacity: .92; font-size: 9.5px; }
.ptile.access { background: var(--c); border-color: color-mix(in srgb, var(--c) 70%, #000); }
.ptile.trunk { background: repeating-linear-gradient(135deg, var(--c) 0 6px, color-mix(in srgb, var(--c) 60%, #000) 6px 12px); border-color: #c9d3df; }
.ptile.none, .ptile.slave { background: #2b3542; }
.ptile.disabled { opacity: .35; }
.ptile .led { position: absolute; top: 2px; right: 2px; width: 6px; height: 6px; border-radius: 50%; background: #4a5462; }
.ptile .led.up { background: #47e38a; box-shadow: 0 0 5px #47e38a; }
.ptile .poe { position: absolute; top: 1px; left: 3px; font-size: 8px; color: #ffd84d; }
.ptile.sel { outline: 3px solid #ffd84d; outline-offset: 1px; }
.ptile:hover { filter: brightness(1.15); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin: -8px 0 16px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 14px; height: 11px; border-radius: 2px; display: inline-block; }

/* Tabellen */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.clickable { cursor: pointer; }
table.t tr.clickable:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
table.t tr.selrow td { background: color-mix(in srgb, #ffd84d 14%, transparent); }
.pname { font-weight: 600; }
.pcomment { color: var(--muted); font-size: 12.5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--c, #888) 16%, transparent); color: color-mix(in srgb, var(--c, #888) 75%, var(--ink));
  border: 1px solid color-mix(in srgb, var(--c, #888) 35%, transparent); margin: 1px 2px 1px 0; white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--ink); }
.badge.trunk { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.badge.access { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

/* Bulk-Leiste */
.bulk { display: flex; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 12px; position: sticky; top: 64px; z-index: 5;
  background: color-mix(in srgb, #ffd84d 18%, var(--panel)); border-color: color-mix(in srgb, #ffd84d 50%, var(--line)); flex-wrap: wrap; }
.bulk b { margin-right: 8px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 22, .55); display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--panel); border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 760px; }
.modal h2 { margin: 0; padding: 18px 22px 0; font-size: 18px; }
.modal .body, .modal .body > form, .modal .body > div:only-child { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal .body > form, .modal .body > div:only-child { padding: 0; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); }
.modal .foot .left { margin-right: auto; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.seg label { padding: 7px 16px; cursor: pointer; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 240px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.vgrid label { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.vgrid label:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.swlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px; max-height: 260px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.results { border: 1px solid var(--line); border-radius: 8px; max-height: 300px; overflow-y: auto; }
.results div { padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; display: flex; gap: 8px; }
.results div:last-child { border-bottom: 0; }
.results .ok { color: var(--ok); } .results .no { color: var(--err); }
.hidden { display: none !important; }

/* VLAN-Details */
.vdetail td { background: color-mix(in srgb, var(--line) 35%, transparent); font-size: 13px; }
.vdetail .sw { display: grid; grid-template-columns: 200px 1fr; gap: 4px 12px; }
.vdetail .sw b { font-weight: 600; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }

/* Toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 420px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  font-size: 13.5px; white-space: pre-line; animation: tin .15s ease-out; }
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 720px) {
  header.top { padding: 0 12px; gap: 10px; }
  header.top .brand span { display: none; }
  main { padding: 14px; }
}
