:root {
  --gvs-red: #BC2B3A;
  --gvs-red-dark: #9e2330;
  --gvs-orange: #EE8E4D;
  --navy: #112337;
  --ink: #2b2b2b;
  --muted: #7c7c7c;
  --line: #e2e2e2;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #efefef;

  --st-blau-bg: #E6F1FB;   --st-blau-tx: #0C447C;   --st-blau-bd: #378ADD;
  --st-gelb-bg: #FAEEDA;   --st-gelb-tx: #854F0B;   --st-gelb-bd: #BA7517;
  --st-gruen-bg: #EAF3DE;  --st-gruen-tx: #27500A;  --st-gruen-bd: #639922;
  --st-rot-bg: #FCEBEB;    --st-rot-tx: #791F1F;    --st-rot-bd: #E24B4A;

  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Montserrat", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--gvs-red); }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); padding: 12px 24px;
  border-bottom: 3px solid var(--gvs-red);
}
.appbar .brand { display: flex; align-items: center; gap: 14px; }
.appbar .brand img { height: 34px; }
.appbar .brand .title {
  font-size: 16px; font-weight: 600; color: var(--navy);
  border-left: 1px solid var(--line); padding-left: 14px;
}
.appbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--gvs-red); border-color: var(--gvs-red); color: #fff; }
.btn-primary:hover { background: var(--gvs-red-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { color: var(--st-rot-tx); border-color: var(--st-rot-bd); background: var(--st-rot-bg); }

/* ---------- Layout ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 24px 60px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="search"] {
  flex: 1; min-width: 200px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface);
}
.toolbar select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }

/* ---------- Status legend & badges ---------- */
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.legend .lbl { font-size: 12px; color: var(--muted); }
.badge {
  font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.badge::before { content: "●"; font-size: 9px; }
.st-unbearbeitet { background: var(--st-blau-bg); color: var(--st-blau-tx); }
.st-aufbereitbar { background: var(--st-gelb-bg); color: var(--st-gelb-tx); }
.st-wiederverkauf { background: var(--st-gruen-bg); color: var(--st-gruen-tx); }
.st-ruckfuehrung { background: var(--st-rot-bg); color: var(--st-rot-tx); }

/* ---------- Table ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.devices { width: 100%; border-collapse: collapse; font-size: 13px; }
table.devices thead th {
  background: var(--surface-2); color: var(--navy); text-align: left;
  padding: 11px 14px; font-weight: 600; font-size: 12px;
}
table.devices tbody td { padding: 11px 14px; border-bottom: 1px solid #eee; }
table.devices tbody tr { border-left: 4px solid transparent; cursor: pointer; }
table.devices tbody tr:hover { background: #fafafa; }
table.devices tbody tr.row-unbearbeitet { border-left-color: var(--st-blau-bd); }
table.devices tbody tr.row-aufbereitbar { border-left-color: var(--st-gelb-bd); }
table.devices tbody tr.row-wiederverkauf { border-left-color: var(--st-gruen-bd); }
table.devices tbody tr.row-ruckfuehrung { border-left-color: var(--st-rot-bd); }
.devid { font-family: "Consolas", ui-monospace, monospace; font-weight: 500; color: var(--navy); }
.files-cell { color: var(--muted); white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* ---------- Modal / Drawer ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(17,35,55,.45);
  display: flex; justify-content: flex-end; z-index: 50;
}
.drawer {
  width: 560px; max-width: 96vw; height: 100%; background: var(--surface);
  overflow-y: auto; box-shadow: -4px 0 24px rgba(0,0,0,.12);
}
.drawer header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface);
}
.drawer header .devid { font-size: 17px; }
.drawer .body { padding: 18px 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; font-weight: 600; color: var(--navy); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
.field textarea { resize: vertical; min-height: 64px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-title { font-size: 11px; font-weight: 600; color: var(--navy); text-transform: uppercase; letter-spacing: .4px; margin: 22px 0 10px; }

/* ---------- Attachments ---------- */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; width: 86px; height: 70px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: #e8e8e8; }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.thumb .del { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.55); color: #fff; border: none; border-radius: 4px; width: 20px; height: 20px; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.dropzone {
  width: 86px; height: 70px; border: 1.5px dashed var(--gvs-red); border-radius: 6px; color: var(--gvs-red);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; gap: 2px; text-align: center;
}
.doc { display: flex; align-items: center; justify-content: space-between; background: #f7f7f7; border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 6px; }
.doc a { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; overflow: hidden; }
.doc .meta { color: var(--muted); font-size: 11px; }

/* ---------- Login ---------- */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 32px; width: 360px; max-width: 100%; }
.login-box img { height: 40px; display: block; margin: 0 auto 4px; }
.login-box .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-box .field input { padding: 11px; }
.msg-error { background: var(--st-rot-bg); color: var(--st-rot-tx); padding: 9px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 100; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 200; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }

/* ---------- Users admin ---------- */
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th, .users-table td { padding: 9px 12px; border-bottom: 1px solid #eee; text-align: left; }
