/* VICECITY MDT — Behörden-Terminal-Design.
   Basis: LB-Tablet-MDT-Struktur, aber als professionelles Daten-Tool:
   dichte Panels mit Hairlines, Monospace für Daten (Kennzeichen, IDs, Beträge,
   Zeitstempel), Magenta strikt rationiert auf Aktiv-Zustände & Primär-Aktionen. */

:root {
  --bg: #141416;
  --panel: #1b1b1f;
  --panel-2: #222228;
  --panel-3: #2a2a31;
  --line: #2e2e35;
  --line-soft: rgba(255, 255, 255, 0.05);
  --ink: #ececf1;
  --ink-2: rgba(235, 235, 245, 0.55);
  --ink-3: rgba(235, 235, 245, 0.28);
  --theme: #ff0084;
  --theme-soft: rgba(255, 0, 132, 0.12);
  --red: #f0525f;
  --green: #34c77b;
  --orange: #f5a623;
  --blue: #4a9eef;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}
input, textarea, select, button { font-family: var(--font); font-size: 13.5px; color: var(--ink); }
input, textarea { user-select: text; }
::-webkit-scrollbar { width: 0; height: 0; }

/* Eyebrow: kleine Versal-Zeile mit nachlaufender Hairline — gliedert alles */
.group-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 22px 0 8px;
}
.group-label::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
.group-label:first-child { margin-top: 0; }

/* Mono überall dort, wo Daten stehen */
.row .value, .stat-tile .v, .callsign, .badge { font-family: var(--mono); }

/* ── Login: Terminal-Zugang ────────────────────────── */
#login {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse 60% 45% at 50% -10%, rgba(255, 0, 132, 0.05), transparent),
    var(--bg);
}
.login-card {
  width: 360px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px 28px 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-badge {
  width: 52px; height: 52px; margin-bottom: 4px;
  border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.login-badge svg { width: 26px; height: 26px; color: var(--theme); }
.login-card .eyebrow {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-3);
}
.login-card h1 { font-size: 19px; font-weight: 600; letter-spacing: -0.2px; }
.login-card .sub { color: var(--ink-2); font-size: 12.5px; }
.login-card input {
  background: var(--bg); border: 1px solid var(--line); outline: none;
  border-radius: 7px; padding: 11px 13px;
  transition: border-color 0.15s;
}
.login-card input:focus { border-color: var(--theme); }
.login-error { color: var(--red); font-size: 12px; min-height: 15px; }
.login-card .terms {
  border-top: 1px solid var(--line-soft); padding-top: 12px; margin-top: 4px;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); line-height: 1.5;
}

/* ── App-Layout ────────────────────────────────────── */
#app { position: absolute; inset: 0; display: none; flex-direction: column; }
#app.visible { display: flex; }

/* Header: schmale Dienstleiste */
#mdt-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
#mdt-header .mdt-info { display: flex; align-items: center; gap: 12px; }
#mdt-header .mdt-info .logo {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
#mdt-header .mdt-info .logo svg { width: 19px; height: 19px; color: var(--theme); }
#mdt-header .mdt-info .name { font-size: 13.5px; font-weight: 600; letter-spacing: -0.1px; }
#mdt-header .mdt-info .device {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-3); margin-top: 2px;
}
#mdt-header .date { text-align: center; font-size: 12.5px; color: var(--ink-2); }
#mdt-header .date .clock { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-top: 1px; }
#mdt-header .user { display: flex; align-items: center; gap: 12px; }
#mdt-header .user .details { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
#mdt-header .user .callsign {
  color: var(--theme); text-transform: uppercase;
  background: var(--theme-soft); border: 1px solid rgba(255, 0, 132, 0.25);
  border-radius: 4px; padding: 1px 7px;
  font-size: 10px; font-weight: 500; letter-spacing: 0.06em;
}
#mdt-header .user .uname { font-size: 13px; font-weight: 600; }
#mdt-header .user .rank { font-size: 11px; color: var(--ink-2); }
#mdt-header .user .avatar {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
}
#ingame-close {
  width: 38px; height: 38px; margin-left: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
#ingame-close:hover { border-color: var(--red); color: var(--red); }
#ingame-close svg { width: 13px; height: 13px; }

#mdt-main { flex: 1; display: flex; min-height: 0; }

/* Sidebar: Register-Leiste, aktiv = Magenta-Kante */
#sidebar {
  width: 208px; flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 10px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  color: var(--ink-2); cursor: pointer;
  font-size: 13px; font-weight: 500;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active {
  background: var(--panel-2); color: var(--ink);
  border-left-color: var(--theme);
  border-radius: 0 6px 6px 0;
}
.app-icon { width: 17px; height: 17px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.app-icon svg { width: 15px; height: 15px; fill: currentColor; opacity: 0.8; }
.nav-item.active .app-icon svg { fill: var(--theme); opacity: 1; }

/* ── Content ───────────────────────────────────────── */
#content { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }
.screen { max-width: 1040px; margin: 0 auto; }

.large-title { font-size: 19px; font-weight: 600; letter-spacing: -0.2px; margin-bottom: 3px; }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.title-sub { color: var(--ink-2); font-size: 12.5px; }

/* Suchfeld */
.searchbar {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 9px 12px; margin-bottom: 16px;
  transition: border-color 0.15s;
}
.searchbar:focus-within { border-color: var(--theme); }
.searchbar svg { width: 13px; height: 13px; fill: var(--ink-3); flex-shrink: 0; }
.searchbar input { flex: 1; background: none; border: none; outline: none; }
.searchbar input::placeholder { color: var(--ink-3); }

/* Panels: EIN Rahmen, innen Hairlines (statt Karten-Stapel) */
.inset-group {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  overflow: hidden;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; min-height: 42px;
  position: relative;
}
.row + .row { border-top: 1px solid var(--line-soft); }
.row.tappable { cursor: pointer; transition: background 0.12s; }
.row.tappable:hover { background: var(--panel-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-size: 13px; font-weight: 500; }
.row .detail { font-size: 11.5px; color: var(--ink-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .value { color: var(--ink-2); font-size: 11.5px; flex-shrink: 0; }
.row .chevron { width: 6px; height: 10px; fill: var(--ink-3); flex-shrink: 0; }
.row-empty {
  padding: 20px 14px; color: var(--ink-3); font-size: 12.5px; text-align: center;
  background: var(--panel); border: 1px dashed var(--line); border-radius: 9px;
}
.inset-group .row-empty { border: none; border-radius: 0; }

/* Status-Badges: getönt + Kontur, Mono-Versalien — keine Bonbons */
.badge {
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; flex-shrink: 0;
  border: 1px solid;
}
.badge.red    { color: var(--red);    border-color: rgba(240, 82, 95, 0.35);  background: rgba(240, 82, 95, 0.08); }
.badge.green  { color: var(--green);  border-color: rgba(52, 199, 123, 0.35); background: rgba(52, 199, 123, 0.08); }
.badge.orange { color: var(--orange); border-color: rgba(245, 166, 35, 0.35); background: rgba(245, 166, 35, 0.08); }
.badge.blue   { color: var(--blue);   border-color: rgba(74, 158, 239, 0.35); background: rgba(74, 158, 239, 0.08); }
.badge.tint   { color: var(--theme);  border-color: rgba(255, 0, 132, 0.35);  background: var(--theme-soft); }
.badge.grey   { color: var(--ink-2);  border-color: var(--line);              background: var(--panel-2); }

/* Kennzahlen: eine Leiste, Zellen durch Hairlines getrennt */
.stat-grid {
  display: flex;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  margin-bottom: 20px; overflow: hidden;
}
.stat-tile { flex: 1; padding: 13px 18px; }
.stat-tile + .stat-tile { border-left: 1px solid var(--line-soft); }
.stat-tile .k {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); display: flex; align-items: center; gap: 6px;
}
.stat-tile .k .pin { width: 6px; height: 6px; border-radius: 50%; }
.stat-tile .v { font-size: 21px; font-weight: 500; margin-top: 6px; letter-spacing: -0.3px; }
.stat-tile .s { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 2px; }

/* Dashboard-Widgets */
.widget-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.widget { min-height: 0; display: flex; flex-direction: column; }
.widget .top { display: flex; justify-content: space-between; align-items: center; padding: 0 2px 8px; }
.widget .top .t {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-3);
}
.widget .items {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  max-height: 340px; overflow-y: auto;
}
.widget .items .row + .row { border-top: 1px solid var(--line-soft); }
.widget .items .row-empty { border: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); outline: none; cursor: pointer;
  border-radius: 7px; padding: 8px 14px;
  font-size: 12.5px; font-weight: 500;
  background: var(--panel-2); color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--panel-3); }
.btn.primary { background: var(--theme); border-color: var(--theme); color: #fff; }
.btn.primary:hover { background: #e00075; }
.btn.destructive { color: var(--red); }
.btn.destructive:hover { border-color: rgba(240, 82, 95, 0.4); }
.btn.small { padding: 5px 10px; font-size: 11.5px; border-radius: 6px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn svg { width: 11px; height: 11px; flex-shrink: 0; }

/* Filter (Segmented) */
.segmented { display: inline-flex; gap: 6px; margin-bottom: 14px; }
.segmented button {
  border: 1px solid var(--line); cursor: pointer;
  background: var(--panel); color: var(--ink-2);
  padding: 6px 12px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  transition: all 0.15s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--theme-soft); border-color: rgba(255, 0, 132, 0.35); color: var(--theme); }

/* Switch */
.switch { width: 38px; height: 22px; border-radius: 100px; background: var(--panel-3); border: 1px solid var(--line); position: relative; cursor: pointer; transition: background 0.2s, border-color 0.2s; flex-shrink: 0; }
.switch.on { background: var(--theme); border-color: var(--theme); }
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
}
.switch.on::after { transform: translateX(16px); }

/* Bürger-Detail: Dienstausweis-Kopf */
.person-head {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 16px 18px; margin-bottom: 14px;
}
.person-head .avatar {
  width: 58px; height: 58px; border-radius: 8px; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--ink-2);
}
.person-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.person-head .meta { font-family: var(--mono); color: var(--ink-2); font-size: 11px; margin-top: 4px; }
.person-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 4px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }

.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); cursor: pointer; font-size: 12px; font-weight: 500;
  margin-bottom: 12px; background: none; border: none; padding: 4px 0;
  transition: color 0.15s;
}
.back-btn:hover { color: var(--ink); }
.back-btn svg { width: 7px; height: 11px; fill: currentColor; }

/* Modal */
#sheet-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
#sheet-backdrop.visible { display: flex; }
.sheet {
  width: 560px; max-width: 92vw; max-height: 84vh;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; overflow: hidden;
  animation: sheetIn 0.18s ease-out;
}
@keyframes sheetIn { from { transform: translateY(10px); opacity: 0; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.sheet-head .t { font-size: 13.5px; font-weight: 600; }
.sheet-head .cancel { color: var(--ink-2); cursor: pointer; background: none; border: none; font-size: 12.5px; padding: 0; }
.sheet-head .cancel:hover { color: var(--ink); }
.sheet-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.sheet-body label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}
.sheet-body input, .sheet-body textarea, .sheet-body select {
  background: var(--bg); border: 1px solid var(--line); outline: none;
  border-radius: 7px; padding: 9px 12px; width: 100%; resize: vertical;
  transition: border-color 0.15s;
}
.sheet-body input:focus, .sheet-body textarea:focus { border-color: var(--theme); }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* Strafenkatalog-Picker */
.charge-pick { max-height: 220px; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; }
.charge-pick .row { background: transparent; padding: 7px 12px; min-height: 34px; cursor: pointer; }
.charge-pick .row:hover { background: var(--panel-2); }
.charge-pick .row.sel { background: var(--theme-soft); }
.charge-pick .row.sel .title { color: var(--theme); }
.charge-pick .row .value { font-family: var(--mono); }
.charge-sum { font-size: 12px; color: var(--ink-2); }
.charge-sum b { color: var(--ink); font-family: var(--mono); font-weight: 500; }

/* Katalog-Accordion */
.acc .acc-head { min-height: 46px; }
.acc .acc-chev { width: 7px; height: 11px; fill: var(--ink-3); flex-shrink: 0; transition: transform 0.2s; }
.acc.expanded .acc-chev { transform: rotate(90deg); }
.acc .acc-body { display: none; border-top: 1px solid var(--line-soft); }
.acc.expanded .acc-body { display: block; }
.acc .acc-body .row { padding-left: 30px; }
.acc .acc-body .row + .row { border-top: 1px solid var(--line-soft); }

/* Toast */
#toast {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(70px);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 18px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  z-index: 99; transition: transform 0.25s ease-out; pointer-events: none;
}
#toast.visible { transform: translateX(-50%) translateY(0); }
#toast.err { color: var(--red); }

.spinner {
  width: 20px; height: 20px; margin: 24px auto; border-radius: 50%;
  border: 2px solid var(--panel-3); border-top-color: var(--ink-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
