/* ============ Fahrzeugbau Brandt — Bau & Verkauf ============ */
:root {
  --bg-0: #0a0d12;
  --bg-1: #11161e;
  --bg-2: #1a212c;
  --bg-3: #232c3a;
  --border: #2a3344;
  --text: #e6edf5;
  --text-dim: #8a96aa;
  --red: #d6213a;
  --red-dim: #8a1626;
  --gold: #d4a72c;
  --gold-dim: #8a6b1c;
  --silver: #c9d2dc;
  --green: #2ecc71;
  --amber: #f5a623;
  --shadow: 0 4px 20px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.hidden { display: none !important; }

/* ===== Login ===== */
.login-screen {
  position: fixed; inset: 0;
  background:
    radial-gradient(circle at 30% 20%, rgba(212,167,44,.15), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(214,33,58,.15), transparent 50%),
    linear-gradient(135deg, #0a0d12 0%, #11161e 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 36px 40px;
  min-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-signal { font-weight: 900; color: var(--red); letter-spacing: 2px; font-size: 30px; }
.logo-route  { font-weight: 900; color: var(--gold); letter-spacing: 2px; font-size: 30px; }
.logo-sub { color: var(--text-dim); font-size: 11px; letter-spacing: 3px; margin-top: 4px; }
.login-card h2 { font-size: 16px; font-weight: 500; margin-bottom: 18px; text-align: center; color: var(--text-dim); }
.login-card label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--text-dim); }
.login-card input { width: 100%; margin-top: 4px; }
.login-card button[type=submit] {
  width: 100%;
  background: linear-gradient(135deg, var(--red), var(--red-dim));
  color: white; border: none; border-radius: 4px;
  padding: 10px; font-weight: 600; font-size: 14px; letter-spacing: 1px;
  margin-top: 8px;
}
.login-card button[type=submit]:hover { filter: brightness(1.1); }
.login-error { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }
.login-hint { color: var(--text-dim); font-size: 11px; margin-top: 18px; text-align: center; }

/* ===== App layout ===== */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; min-height: 0;
}
.brand { padding: 20px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand-line { font-size: 18px; }
.brand-line .logo-signal, .brand-line .logo-route { font-size: 18px; letter-spacing: 1px; }
.brand-sub { color: var(--text-dim); font-size: 9px; letter-spacing: 2px; margin-top: 4px; }

#nav {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 8px;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}
/* Sidebar-Scrollbar etwas auffälliger als der Default */
#nav::-webkit-scrollbar { width: 8px; }
#nav::-webkit-scrollbar-track { background: var(--bg-1); }
#nav::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; border: 1px solid var(--border); }
#nav::-webkit-scrollbar-thumb:hover { background: var(--gold); }
.nav-section {
  font-size: 10px; color: var(--text-dim); letter-spacing: 2px;
  padding: 14px 10px 6px 10px; text-transform: uppercase;
}
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  background: transparent; color: var(--text-dim);
  border: none; border-radius: 4px; text-align: left;
  font-size: 13px; margin-bottom: 2px;
  transition: all .12s;
}
.nav-btn:hover { background: var(--bg-2); color: var(--text); }
.nav-btn.active {
  background: linear-gradient(90deg, rgba(212,167,44,.22), rgba(212,167,44,0));
  color: var(--text);
  border-left: 3px solid var(--gold);
  padding-left: 9px;
}
.nav-ic { width: 16px; color: var(--gold); text-align: center; font-size: 12px; }
.nav-btn.active .nav-ic { color: var(--red); }

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0;
  background: var(--bg-1);
  box-shadow: 0 -6px 12px rgba(0,0,0,.35);
  position: relative;
  z-index: 1;
}
#user-badge { font-size: 12px; color: var(--text-dim); }
#user-badge strong { color: var(--text); }
.logout-btn {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 6px; font-size: 12px;
}
.logout-btn:hover { color: var(--red); border-color: var(--red); }

/* ===== Main ===== */
.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 56px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar h1 { font-size: 16px; font-weight: 500; letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.server-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.server-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.server-status.online .dot { background: var(--green); }
.server-status.offline .dot { background: var(--red); }
.clock { font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; color: var(--silver); }
.sync-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: 'Consolas','Monaco',monospace; font-size: 12px;
  color: var(--text-dim);
  padding: 2px 8px; border: 1px solid var(--border); border-radius: 3px;
  background: var(--bg-2);
}
.sync-badge .sync-ic { font-size: 11px; color: var(--gold); }

.view-container { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== Cards / Panels ===== */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 16px;
}
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-h h3 { font-size: 13px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--silver); }
.card-h .accent { width: 4px; height: 16px; background: var(--red); display: inline-block; margin-right: 10px; vertical-align: middle; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ===== Stats ===== */
.stat {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  padding: 14px 16px;
}
.stat.red    { border-left-color: var(--red); }
.stat.amber  { border-left-color: var(--amber); }
.stat.green  { border-left-color: var(--green); }
.stat .l { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--text); }
.stat .s { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; background: var(--bg-2); }
tbody tr:hover { background: rgba(212,167,44,.06); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }

/* ===== Status pills ===== */
.pill {
  display: inline-block;
  padding: 3px 10px 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--bg-3);
  background: var(--bg-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: 'Consolas','Monaco',monospace;
  color: var(--text);
  line-height: 1.4;
}
.pill-on    { border-left-color: var(--green); color: var(--green); background: rgba(46,204,113,.06); }
.pill-off   { border-left-color: var(--red);   color: var(--red);   background: rgba(214,33,58,.06); }
.pill-warn  { border-left-color: var(--amber); color: var(--amber); background: rgba(245,166,35,.06); }
.pill-info  { border-left-color: var(--gold);  color: var(--gold);  background: rgba(212,167,44,.06); }
.pill-mute  { border-left-color: var(--bg-3);  color: var(--text-dim); }

/* ===== Status (mit Farbbalken — für Rechner) ===== */
.status {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: 'Consolas','Monaco',monospace;
  overflow: hidden;
  line-height: 1.4;
}
.status .status-bar { display: inline-block; width: 6px; align-self: stretch; background: var(--bg-3); }
.status .status-icon { padding: 0 8px; font-size: 13px; font-weight: 900; border-right: 1px solid var(--border); background: rgba(0,0,0,.25); }
.status .status-label { padding: 4px 10px; color: var(--text); }
.status .status-num { padding: 4px 8px 4px 0; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.status-ok   .status-bar  { background: var(--green); }
.status-ok   .status-icon { color: var(--green); }
.status-ok   .status-label{ color: var(--green); }
.status-warn .status-bar  { background: var(--amber); }
.status-warn .status-icon { color: var(--amber); }
.status-warn .status-label{ color: var(--amber); }
.status-err  .status-bar  { background: var(--red); }
.status-err  .status-icon { color: var(--red); }
.status-err  .status-label{ color: var(--red); }
.status-err  .status-num  { color: var(--red); font-weight: 700; }

/* ===== Buttons ===== */
.btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  transition: all .12s;
}
.btn:hover { border-color: var(--gold); }
.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-dim));
  border-color: transparent; color: white; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.1); border-color: transparent; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  border-color: transparent; color: white; font-weight: 600;
}
.btn-gold:hover { filter: brightness(1.1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 4px 8px; }
.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red); color: white; }

.btn-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0;
  border: 1px solid var(--border); border-radius: 3px;
  background: var(--bg-2); color: var(--text-dim);
  font-size: 14px; line-height: 1; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-x::before { content: '\00d7'; font-family: 'Segoe UI', sans-serif; font-size: 16px; margin-top: -1px; }
.btn-x:hover { border-color: var(--red); background: rgba(214,33,58,.18); color: var(--red); }
.btn-x:active { background: var(--red); color: white; border-color: var(--red); }
th .btn-x { width: 20px; height: 20px; }
th .btn-x::before { font-size: 14px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar input[type=text], .toolbar select { min-width: 200px; }
.spacer { flex: 1; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 560px; max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-h {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-h h3 { font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: var(--silver); }
.modal-b { padding: 20px; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.modal label input, .modal label select, .modal label textarea { width: 100%; margin-top: 4px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-close { background: transparent; border: none; color: var(--text-dim); font-size: 18px; }

/* ===== Calculator ===== */
.calc-grid { display: grid; grid-template-columns: 360px 1fr; gap: 16px; }
.calc-out {
  background: var(--bg-2);
  border-left: 3px solid var(--gold);
  padding: 14px 16px;
  border-radius: 4px;
  margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.calc-out .lbl { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.calc-out .val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-total {
  background: linear-gradient(135deg, rgba(214,33,58,.15), rgba(214,33,58,.04));
  border-left-color: var(--red);
}
.calc-total .val { font-size: 22px; color: var(--red); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab {
  background: transparent; border: none; color: var(--text-dim);
  padding: 10px 18px; font-size: 13px;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--red); }
.tab:hover { color: var(--text); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ===== Einklappbare Karten ===== */
.card.collapsible .collapsible-h {
  cursor: pointer; user-select: none; transition: background .12s;
  padding: 4px 8px; margin: -4px -8px; border-radius: 3px;
}
.card.collapsible .collapsible-h:hover { background: rgba(212,167,44,.05); }
.card.collapsible .collapse-arrow {
  display: inline-block; color: var(--gold); font-size: 12px;
  margin-right: 4px; width: 12px; transition: transform .15s;
}
.card.collapsible.is-collapsed { padding-bottom: 18px; }
.card.collapsible.is-collapsed .collapsible-h { margin-bottom: 0; }
.card.collapsible.is-collapsed .collapsible-body { display: none; }

/* ===== Material-Link (klickbar für Bestand-Modal) ===== */
.mat-link {
  display: inline-block; cursor: pointer; padding-right: 16px;
  position: relative; color: var(--text); text-decoration: none;
}
.mat-link::after {
  content: '✎'; position: absolute; right: 0; top: 0;
  font-size: 11px; color: var(--text-dim); opacity: 0;
  transition: opacity .12s;
}
.mat-link:hover { color: var(--gold); }
.mat-link:hover::after { opacity: 1; color: var(--gold); }

/* ===== Bauteile-Tabelle (LKW/PKW Rechner) ===== */
.bauteile-tbl td, .bauteile-tbl th { vertical-align: middle; padding: 7px 10px; }
.bauteile-tbl td.num, .bauteile-tbl th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bauteile-tbl tr.spezial-row td { background: rgba(245,166,35,.04); border-left: 2px solid var(--amber); }
.bauteile-tbl tbody tr:hover { background: rgba(212,167,44,.04); }

/* ===== Lager-Auswahl-Chips ===== */
.lager-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border); border-left: 4px solid var(--bg-3);
  border-radius: 3px; background: var(--bg-2);
  color: var(--text-dim); cursor: pointer;
  font-family: 'Consolas','Monaco',monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; transition: all .12s;
}
.lager-chip::before { content: '○'; font-size: 13px; margin-top: -1px; }
.lager-chip:hover { border-left-color: var(--gold); color: var(--text); }
.lager-chip.active {
  border-color: var(--gold); border-left-color: var(--gold);
  background: rgba(212,167,44,.12); color: var(--gold);
}
.lager-chip.active::before { content: '●'; }

/* ===== Sidebar-Badge (z.B. Bestellungen-Counter) ===== */
.nav-badge {
  display: inline-block;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-family: 'Consolas','Monaco',monospace;
  min-width: 16px; text-align: center;
}

/* ===== Notiz-Marker auf Bauaufträgen / Bestellungen ===== */
.note-marker {
  display: inline-block;
  color: var(--gold);
  font-size: 13px;
  margin-left: 6px;
  cursor: help;
}
.note-marker:hover { color: var(--red); }

/* ===== Storno-Countdown-Badge ===== */
.storno-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  background: rgba(214,33,58,.18);
  color: var(--red);
  border: 1px solid rgba(214,33,58,.35);
  border-radius: 2px;
  font-family: 'Consolas','Monaco',monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  vertical-align: middle;
}

/* ===== Bestellungen-Cards (Online-Anfragen) ===== */
.bestellungen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.bestellung-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  padding: 18px;
  display: flex; flex-direction: column;
}
.bestellung-h {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding-bottom: 12px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.bestellung-nr {
  font-family: 'Consolas','Monaco',monospace;
  font-weight: 700; color: var(--gold);
  font-size: 14px;
}
.bestellung-date { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.bestellung-body { flex: 1; }
.bestellung-modell {
  font-size: 16px; font-weight: 700;
  color: var(--text); margin-bottom: 10px;
}
.bestellung-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  font-size: 12px;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: 4px;
  margin-bottom: 12px;
}
.bestellung-meta strong { color: var(--text); font-size: 13px; }
.bestellung-kunde {
  padding: 10px 12px;
  background: rgba(212,167,44,.06);
  border-left: 2px solid var(--gold);
  border-radius: 3px;
  margin-bottom: 12px;
}
.bestellung-notiz {
  padding: 10px 12px;
  background: var(--bg-2);
  border-left: 2px solid var(--bg-3);
  border-radius: 3px;
  font-size: 13px; font-style: italic; line-height: 1.5;
  margin-bottom: 12px;
}
.bestellung-f {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: 12px; border-top: 1px solid var(--border);
}

/* ===== Lounge / Chat ===== */
.chat-card {
  display: flex; flex-direction: column;
  height: 100%; min-height: 480px; margin: 0;
}
.chat-stream {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 6px 4px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.chat-msg {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--bg-3);
  border-radius: 4px;
  padding: 8px 12px;
  margin: 0 6px;
}
.chat-msg:first-child { margin-top: 6px; }
.chat-msg:last-child  { margin-bottom: 6px; }
.chat-msg-mine {
  border-left-color: var(--gold);
  background: rgba(212,167,44,.06);
}
.chat-msg-h {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 11px;
}
.chat-msg-from { color: var(--text); font-size: 12px; font-weight: 700; }
.chat-msg-role {
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1px;
  font-size: 10px;
}
.chat-msg-time {
  margin-left: auto;
  color: var(--text-dim);
  font-family: 'Consolas','Monaco',monospace;
  font-size: 11px;
}
.chat-msg-del {
  background: transparent; border: none;
  color: var(--text-dim); cursor: pointer;
  font-size: 16px; line-height: 1;
  padding: 0 4px; margin-left: 2px;
  border-radius: 3px;
}
.chat-msg-del:hover { color: var(--red); background: rgba(214,33,58,.12); }
.chat-msg-body {
  margin-top: 4px;
  font-size: 13px; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word;
  color: var(--text);
}
.chat-form {
  display: flex; gap: 8px;
  padding-top: 12px; margin-top: 12px;
  border-top: 1px solid var(--border);
}
.chat-form textarea {
  flex: 1; resize: none;
  font-family: inherit;
  line-height: 1.45;
}
.chat-send { align-self: stretch; padding: 0 22px; min-width: 100px; }

/* ===== Misc ===== */
.empty { text-align: center; padding: 40px; color: var(--text-dim); font-size: 13px; }
.muted { color: var(--text-dim); }
.right { text-align: right; }
.mono { font-family: 'Consolas', 'Monaco', monospace; }
.tag { display: inline-block; padding: 2px 8px; background: var(--bg-2); border-radius: 3px; font-size: 11px; color: var(--text-dim); margin-right: 4px; }
