/* AF WWS – Designsystem */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface2: #fafaf9;
  --border: #e7e5e4;
  --border2: #d6d3d1;
  --text: #1c1917;
  --text-muted: #78716c;
  --header-bg: #1a1a1a;
  --header-text: #ffffff;
  --gold: #f0a500;
  --gold-dark: #c98c00;
  --green: #16a34a;
  --blue: #2563eb;
  --orange: #ea580c;
  --red: #dc2626;
  --grey: #94a3b8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --font-sans: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'SF Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--header-bg); color: var(--header-text);
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  box-shadow: var(--shadow);
}
.topbar .logo {
  font-weight: 700; font-size: 18px; letter-spacing: 0.5px;
  color: var(--gold);
}
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a {
  color: var(--header-text); padding: 8px 14px; border-radius: var(--radius);
  font-weight: 500; white-space: nowrap;
}
.topbar nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.topbar nav a.active { background: rgba(240,165,0,0.15); color: var(--gold); }
.topbar .user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: var(--radius);
  background: rgba(255,255,255,0.06);
}
.topbar .user .name { font-weight: 500; }
.topbar .user button {
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  color: var(--header-text); padding: 4px 10px; border-radius: 6px;
  cursor: pointer; font-size: 12px;
}
.topbar .user button:hover { background: rgba(255,255,255,0.08); }

main { padding: 24px 20px; max-width: 1400px; margin: 0 auto; }
h1 { margin: 0 0 16px; font-size: 24px; font-weight: 700; }
h2 { margin: 24px 0 12px; font-size: 18px; font-weight: 700; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 8px 14px; font: inherit; font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--gold); color: #1a1a1a; border-color: var(--gold); }
.btn.primary:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.btn.danger { background: var(--red); color: white; border-color: var(--red); }
.btn.danger:hover { filter: brightness(0.9); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-weight: 500; font-size: 13px; color: var(--text-muted); }
input, select, textarea {
  font: inherit; padding: 8px 10px;
  border: 1px solid var(--border2); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold);
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

/* ── Cards / Tiles ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow);
}
.kpi-tile .num { font-size: 32px; font-weight: 700; line-height: 1; font-family: var(--font-mono); }
.kpi-tile .lbl { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-tile.warn .num { color: var(--orange); }
.kpi-tile.danger .num { color: var(--red); }

/* ── Tabellen ── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  position: sticky; top: 56px; z-index: 10;
  background: var(--surface2); color: var(--text-muted);
  font-weight: 500; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--border2);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
}
table.data thead th:first-child { border-top-left-radius: var(--radius); }
table.data thead th:last-child  { border-top-right-radius: var(--radius); }
table.data tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.data tbody tr:nth-child(even) { background: var(--surface2); }
table.data tbody tr:hover { background: #fef3c720; }
table.data tbody tr.selected { background: #fef3c750; }
table.data .num, table.data .mono { font-family: var(--font-mono); }

/* ── Status-Chips ── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: #e7e5e4; color: var(--text);
}
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.s-avisiert      { background: #f1f5f9; color: var(--grey); }
.chip.s-angeliefert   { background: #dbeafe; color: var(--blue); }
.chip.s-in_bearbeitung{ background: #ffedd5; color: var(--orange); }
.chip.s-fertig        { background: #dcfce7; color: var(--green); }
.chip.s-versendet     { background: #dcfce7; color: var(--green); }
.chip.s-fakturiert    { background: #ede9fe; color: #7c3aed; }
.chip.s-storniert     { background: #fee2e2; color: var(--red); }
.chip.prio-hoch       { background: #fee2e2; color: var(--red); }
.chip.prio-normal     { background: #f5f5f4; color: var(--text-muted); }
.chip.prio-niedrig    { background: #f1f5f9; color: var(--grey); }

/* ── Deadline-Badges ── */
.deadline.ueberfaellig { color: var(--red); font-weight: 600; }
.deadline.heute { color: var(--orange); font-weight: 600; }
.deadline.morgen { color: var(--green); }

/* ── Bestand-Ampel ── */
.bestand.rot { color: var(--red); font-weight: 600; }
.bestand.gelb { color: var(--orange); font-weight: 600; }
.bestand.gruen { color: var(--green); }

/* ── Modal ── */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; max-width: 600px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Toolbar (Filter-Leiste) ── */
.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px; align-items: center;
}
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }

/* ── Login ── */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a1a, #2c2417);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 32px; max-width: 360px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card h1 { margin: 0 0 4px; color: var(--gold); font-size: 28px; }
.login-card .sub { color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }
.error-msg { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0; }

/* ── Mobile (Hallen-Workflows ≥ 380px) ── */
@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: 12px; }
  .topbar nav { gap: 2px; }
  .topbar nav a { padding: 6px 8px; font-size: 13px; }
  main { padding: 16px 12px; }
  table.data thead th, table.data tbody td { padding: 8px 6px; font-size: 12px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .row > * { min-width: unset; flex-basis: 100%; }
}

/* ── Utils ── */
.muted { color: var(--text-muted); }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.empty { padding: 40px; text-align: center; color: var(--text-muted); }
