/* ============================================================
   BServ – VLH Corporate Identity
   Primärblau #015697 · Akzentgelb #ffde14 · Slate #3d5161
   Raleway (Headlines) + Open Sans (Fließtext), lokal gespiegelt
   ============================================================ */

@font-face { font-family: "Open Sans"; font-weight: 400; font-display: swap;
  src: url("/fonts/opensans-400.woff2") format("woff2"); }
@font-face { font-family: "Open Sans"; font-weight: 600; font-display: swap;
  src: url("/fonts/opensans-600.woff2") format("woff2"); }
@font-face { font-family: "Open Sans"; font-weight: 700; font-display: swap;
  src: url("/fonts/opensans-700.woff2") format("woff2"); }
@font-face { font-family: "Raleway"; font-weight: 600; font-display: swap;
  src: url("/fonts/raleway-600.woff2") format("woff2"); }
@font-face { font-family: "Raleway"; font-weight: 700; font-display: swap;
  src: url("/fonts/raleway-700.woff2") format("woff2"); }
@font-face { font-family: "Raleway"; font-weight: 800; font-display: swap;
  src: url("/fonts/raleway-800.woff2") format("woff2"); }

:root {
  --blue: #015697;
  --blue-700: #014477;
  --blue-800: #01345c;
  --blue-100: #e6eff6;
  --blue-050: #f2f7fb;
  --yellow: #ffde14;
  --yellow-dark: #d9bb00;
  --slate: #3d5161;
  --slate-600: #55697a;
  --ink: #1c2b36;
  --muted: #6c7a86;
  --line: #e2e8ef;
  --line-soft: #eef2f6;
  --bg: #eef2f6;
  --card: #ffffff;
  --red: #dc3545;
  --red-bg: #fdecee;
  --green: #198754;
  --green-bg: #e6f4ec;
  --amber: #b9770e;
  --amber-bg: #fdf3e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(29,43,54,.06), 0 1px 3px rgba(29,43,54,.05);
  --shadow: 0 2px 6px rgba(29,43,54,.07), 0 8px 24px rgba(29,43,54,.07);
  --shadow-lg: 0 12px 48px rgba(1,52,92,.22);
  --ring: 0 0 0 3px rgba(1,86,151,.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Open Sans", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 400px at 100% -10%, var(--blue-050), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .app-title, .logo { font-family: "Raleway", "Open Sans", sans-serif; }

/* ---------- Kopfzeile ---------- */
header.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 60px;
  position: sticky; top: 0; z-index: 30;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  background: var(--blue); color: #fff;
  font-weight: 800; font-size: 19px; letter-spacing: .5px;
  padding: 7px 11px; border-radius: 8px; line-height: 1;
  position: relative;
}
.logo::after {
  content: ""; position: absolute; right: -3px; bottom: -3px;
  width: 12px; height: 12px; background: var(--yellow);
  border-radius: 3px; border: 2px solid #fff;
}
.app-title { font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.app-title small { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted);
  font-family: "Open Sans", sans-serif; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.userchip {
  display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--slate);
  padding: 5px 6px 5px 5px; border-radius: 999px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--slate));
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; font-family: "Raleway", sans-serif;
}
.userchip .uinfo b { display: block; font-size: 12.5px; color: var(--ink); font-weight: 600; line-height: 1.1; }
.userchip .uinfo span { font-size: 11px; color: var(--muted); }

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--slate);
  padding: 8px 14px; font-weight: 600; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .14s, border-color .14s, box-shadow .14s, color .14s, transform .05s;
}
button:hover { background: var(--blue-050); border-color: var(--blue-100); color: var(--blue-700); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button.primary {
  background: var(--blue); border-color: var(--blue); color: #fff;
  box-shadow: 0 1px 2px rgba(1,52,92,.25);
}
button.primary:hover { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--blue-050); }
button.danger { color: var(--red); }
button.danger:hover { background: var(--red-bg); border-color: #f3c2c7; color: var(--red); }
button.sm { padding: 5px 10px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- Layout-Container ---------- */
.wrap { max-width: 1340px; margin: 0 auto; padding: 0 24px; }

/* ---------- Dashboard-Kacheln ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 22px auto 0; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue);
}
.stat.ok::before { background: var(--green); }
.stat.warn::before { background: var(--yellow); }
.stat.info::before { background: var(--slate); }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-family: "Raleway", sans-serif; font-size: 30px; font-weight: 800; color: var(--ink); line-height: 1.1; margin-top: 4px; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .spark { display: flex; gap: 3px; margin-top: 10px; height: 6px; }
.stat .spark span { flex: 1; border-radius: 2px; background: var(--line); }

/* ---------- Werkzeugleiste ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin: 20px auto 0;
}
.search {
  flex: 1; min-width: 280px; position: relative;
}
.search .icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search input {
  width: 100%; font: inherit; font-size: 14.5px;
  padding: 11px 14px 11px 40px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  box-shadow: var(--shadow-sm); color: var(--ink);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.select {
  position: relative; display: inline-flex; align-items: center;
}
.select select {
  font: inherit; font-weight: 600; font-size: 13.5px; color: var(--slate);
  padding: 10px 34px 10px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; box-shadow: var(--shadow-sm); appearance: none; cursor: pointer;
}
.select::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.select select:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }

/* ---------- Lizenz-Filter-Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px auto 0; }
.chip {
  border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--slate); display: inline-flex; gap: 8px; align-items: center;
  box-shadow: var(--shadow-sm); transition: all .14s;
}
.chip:hover { border-color: var(--blue-100); color: var(--blue-700); }
.chip .count { background: var(--bg); border-radius: 999px; padding: 1px 8px; font-weight: 700; font-size: 11.5px; color: var(--slate); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(1,86,151,.3); }
.chip.active .count { background: rgba(255,255,255,.24); color: #fff; }
.chip .dot { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- Tabelle ---------- */
.tablecard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  margin: 14px auto 40px;
}
.tabletop {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}
.tabletop .count-line { font-size: 13px; color: var(--muted); }
.tabletop .count-line b { color: var(--ink); font-weight: 700; }
.tablescroll { overflow: auto; max-height: calc(100vh - 340px); }
table { border-collapse: collapse; width: 100%; }
thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--slate); color: #fff;
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  padding: 11px 14px; white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:first-child { padding-left: 18px; }
thead th:hover { background: var(--slate-600); }
thead th .arrow { color: var(--yellow); margin-left: 5px; font-size: 10px; }
tbody td { padding: 10px 14px; border-top: 1px solid var(--line-soft); font-size: 13.5px; white-space: nowrap; color: var(--ink); }
tbody td:first-child { padding-left: 18px; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:nth-child(even) { background: #fbfcfd; }
tbody tr:hover { background: var(--blue-050); box-shadow: inset 3px 0 0 var(--blue); }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
td .name-main { font-weight: 600; }
td .name-sub { font-size: 11.5px; color: var(--muted); }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 17px; font-weight: 700; color: var(--slate); font-family: "Raleway", sans-serif; margin-bottom: 6px; }

/* Lizenz-Badges (blau abgestuft, unlimitiert = gelb) */
.badge {
  display: inline-block; border-radius: 6px; padding: 3px 9px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  background: var(--blue-100); color: var(--blue-800);
}
.badge.l50   { background: #eaf1f7; color: #35586f; }
.badge.l100  { background: #dcebf6; color: #175584; }
.badge.l200  { background: #cbe2f4; color: #0d4f83; }
.badge.l300  { background: #b6d6f0; color: #013a68; }
.badge.l400  { background: #a3caed; color: #012e55; }
.badge.l0    { background: var(--yellow); color: #4a3d00; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.pill.aktiv { color: var(--green); }
.pill.aktiv::before { background: var(--green); }
.pill.gekuendigt { color: var(--red); }
.pill.gekuendigt::before { background: var(--red); }
.pill.inaktiv { color: var(--muted); }
.pill.inaktiv::before { background: var(--muted); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(1,52,92,.42); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; z-index: 60;
  padding: 48px 16px; overflow-y: auto;
}
.modal-back.open { display: flex; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 680px; max-width: 100%; overflow: hidden;
  animation: pop .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { transform: translateY(14px) scale(.985); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  padding: 20px 26px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, var(--blue-050), #fff);
}
.modal-head .mh-icon {
  width: 40px; height: 40px; border-radius: 10px; background: var(--blue); color: #fff;
  display: grid; place-items: center; flex: none;
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; color: var(--ink); }
.modal-head .mh-sub { font-size: 12.5px; color: var(--muted); }
.modal-body { padding: 22px 26px; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.formgrid .full { grid-column: 1 / -1; }
label.field { display: block; font-size: 12px; font-weight: 700; color: var(--slate); letter-spacing: .2px; }
label.field .req { color: var(--red); }
label.field input, label.field select, label.field textarea {
  display: block; width: 100%; margin-top: 5px;
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  transition: border-color .14s, box-shadow .14s;
}
label.field textarea { resize: vertical; }
label.field input:focus, label.field select:focus, label.field textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: var(--ring);
}
.plz-ort { display: flex; gap: 8px; }
.plz-ort input.plz { width: 96px; }

/* Lizenz als Segment-Control */
.seg { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }
.seg label {
  flex: 1; min-width: 62px; text-align: center; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 6px;
  font-size: 13px; font-weight: 700; color: var(--slate); background: #fff;
  transition: all .12s;
}
.seg label:hover { border-color: var(--blue-100); background: var(--blue-050); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { }
.seg label.on { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 6px rgba(1,86,151,.28); }
.seg label.on.unl { background: var(--yellow); border-color: var(--yellow-dark); color: #4a3d00; }

.wechsel-note {
  margin-top: 14px; background: var(--amber-bg); border: 1px solid #f0dcae;
  border-radius: 10px; padding: 11px 13px;
}
.wechsel-note label.field { color: #7a5209; }

/* Historie-Timeline */
.hist { margin-top: 20px; border-top: 1px solid var(--line-soft); padding-top: 16px; }
.hist h3 { font-size: 13px; margin: 0 0 12px; color: var(--slate); text-transform: uppercase; letter-spacing: .4px; }
.hist ul { margin: 0; padding: 0 0 0 20px; list-style: none; position: relative; }
.hist ul::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.hist li { position: relative; padding: 0 0 14px 12px; font-size: 13px; }
.hist li::before {
  content: ""; position: absolute; left: -20px; top: 3px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--blue); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--blue-100);
}
.hist li .when { color: var(--muted); font-size: 12px; }
.hist li .change b { color: var(--blue-700); }
.hist li .who { color: var(--slate); }
.hist li .cmt { color: var(--muted); font-style: italic; }

.modal-foot {
  display: flex; gap: 10px; padding: 16px 26px; background: #fafbfc;
  border-top: 1px solid var(--line-soft); justify-content: flex-end;
}
.modal-foot .left { margin-right: auto; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff; border-radius: 10px;
  padding: 12px 20px 12px 16px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; z-index: 100;
  max-width: 90vw; display: flex; align-items: center; gap: 10px;
  border-left: 4px solid var(--green);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-left-color: var(--red); }

/* ---------- Login / 2FA ---------- */
.authwrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(1,86,151,.10), transparent 55%),
    radial-gradient(700px 500px at 90% 90%, rgba(255,222,20,.12), transparent 55%),
    var(--bg);
}
.authcard {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg);
  width: 430px; max-width: 100%; padding: 38px 40px; position: relative; overflow: hidden;
}
.authcard::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, var(--blue) 70%, var(--yellow) 70%); }
.authcard .logo { display: inline-block; margin-bottom: 16px; font-size: 22px; padding: 8px 13px; }
.authcard h1 { font-size: 22px; margin: 4px 0 6px; color: var(--ink); }
.authcard p.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; line-height: 1.55; }
.authcard label.lbl { display: block; font-size: 12px; font-weight: 700; color: var(--slate); margin-bottom: 6px; }
.authcard input[type="email"], .authcard input[type="text"] {
  width: 100%; font: inherit; font-size: 16px;
  padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; color: var(--ink);
  transition: border-color .14s, box-shadow .14s;
}
.authcard input:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.authcard input.code {
  text-align: center; font-size: 30px; font-weight: 700; letter-spacing: 12px;
  font-family: "Raleway", sans-serif; padding: 12px 8px;
}
.authcard button.primary { width: 100%; padding: 13px; font-size: 15px; justify-content: center; }
.authmsg { font-size: 13.5px; margin-top: 16px; padding: 11px 13px; border-radius: 10px; display: none; line-height: 1.45; }
.authmsg.ok { display: block; background: var(--green-bg); color: #10633c; }
.authmsg.err { display: block; background: var(--red-bg); color: #a51d29; }
.authfoot { margin-top: 22px; font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.5; }
.step { display: flex; gap: 8px; margin-bottom: 22px; }
.step .dot { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.step .dot.on { background: var(--blue); }
.qrbox { text-align: center; margin: 6px 0 16px; }
.qrbox img { width: 188px; height: 188px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.secretbox {
  font-family: Consolas, monospace; font-size: 12.5px; word-break: break-all;
  background: var(--blue-050); border: 1px dashed var(--blue-100); border-radius: 9px;
  padding: 9px 11px; margin-bottom: 16px; color: var(--slate); text-align: center;
}
.hint-steps { list-style: none; padding: 0; margin: 0 0 18px; }
.hint-steps li { font-size: 13px; color: var(--slate); padding: 5px 0 5px 26px; position: relative; }
.hint-steps li::before {
  content: counter(s); counter-increment: s; position: absolute; left: 0; top: 4px;
  width: 18px; height: 18px; border-radius: 50%; background: var(--blue-100); color: var(--blue-700);
  font-size: 11px; font-weight: 700; display: grid; place-items: center; font-family: "Raleway", sans-serif;
}
.hint-steps { counter-reset: s; }

/* ---------- Admin ---------- */
.admin-section { max-width: 1120px; margin: 24px auto; }
.admin-section h2 { font-size: 17px; color: var(--ink); margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card .lead { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.keyreveal {
  background: var(--blue-050); border: 1px solid var(--blue-100);
  border-radius: 10px; padding: 14px 16px; margin: 14px 0;
  font-family: Consolas, monospace; font-size: 13px; word-break: break-all; white-space: pre-wrap; color: var(--slate);
}
.inline-form { display: flex; gap: 10px; margin-bottom: 16px; }
.inline-form input { flex: 1; font: inherit; padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; }
.inline-form input:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
.card .tablescroll { max-height: none; }
.card thead th { background: var(--slate); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .formgrid { grid-template-columns: 1fr; }
  .wrap { padding: 0 14px; }
  header.topbar { padding: 0 14px; }
  .app-title small { display: none; }
  .userchip .uinfo { display: none; }
  .tablescroll { max-height: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 24px; }
}
