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

/* ── THEME VARIABLES ─────────────────── */
:root {
  --bg:        #0f0f12;
  --bg2:       #13131a;
  --bg3:       #0a0a0f;
  --bg4:       #1e1e28;
  --bg5:       #16161e;
  --border:    #2a2a35;
  --text:      #e8e8ec;
  --text2:     #888;
  --text3:     #666;
  --text4:     #555;
  --accent:    #7c6af7;
  --green:     #2ecc71;
  --red:       #e74c3c;
  --input-bg:  #0f0f12;
}

body.light {
  --bg:        #f4f4f8;
  --bg2:       #ffffff;
  --bg3:       #eeeef4;
  --bg4:       #e8e8f0;
  --bg5:       #f0f0f6;
  --border:    #d0d0de;
  --text:      #111118;
  --text2:     #555566;
  --text3:     #777788;
  --text4:     #999aaa;
  --accent:    #6254e8;
  --green:     #1a9e52;
  --red:       #cc2a1e;
  --input-bg:  #f8f8fc;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}

/* ── NAV ─────────────────────────────── */
.top-nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 20px;
  font-family: 'DM Mono', monospace;
}
.nav-links { display: flex; gap: 4px; }
.nav-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.nav-btn:hover { background: var(--bg4); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; }

/* ── PAGES ───────────────────────────── */
.page { display: none; }
.page.active { display: block; }
.main-content {
  padding: 28px 32px;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── CARDS ───────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 18px;
  font-family: 'DM Mono', monospace;
}

/* ── FORM ────────────────────────────── */
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: block;
}
.field-group { display: flex; flex-direction: column; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[readonly] { color: var(--text3); cursor: default; }
select option { background: var(--bg2); }

/* ── BUTTONS ─────────────────────────── */
.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-secondary { background: var(--bg4); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg4); }
.btn-danger { background: #e74c3c22; color: #e74c3c; border: 1px solid #e74c3c44; }
.btn-danger:hover { background: #e74c3c33; }
.btn-success { background: #2ecc7122; color: var(--green); border: 1px solid #2ecc7144; }
.btn-success:hover { background: #2ecc7133; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── TOTALS ──────────────────────────── */
.totals-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: #aaa;
  border-bottom: 1px solid var(--border);
}
.totals-row:last-child { border-bottom: none; }
.totals-row.total {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding-top: 12px;
}
.totals-row .amount {
  font-family: 'DM Mono', monospace;
  color: var(--accent);
}
.totals-row.total .amount { color: var(--green); font-size: 20px; }

/* ── TABLE ───────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text4);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
}
td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover td { background: var(--bg5); }
tbody tr:last-child td { border-bottom: none; }

/* ── BADGE ───────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
}
.badge-purple { background: var(--accent)22; color: var(--accent); }
.badge-green  { background: #2ecc7122; color: var(--green); }

/* ── MODAL ───────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #000000bb;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── ALERTS ──────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: #2ecc7115; border: 1px solid #2ecc7130; color: var(--green); }
.alert-error   { background: #e74c3c15; border: 1px solid #e74c3c30; color: #e74c3c; }
.alert-info    { background: var(--accent)15; border: 1px solid #7c6af730; color: var(--accent); }

/* ── SEARCH DROPDOWN ─────────────────── */
.search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
  box-shadow: 0 8px 24px #00000066;
}
.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result-item:hover { background: var(--bg4); }
.search-result-item:last-child { border-bottom: none; }

/* ── CUSTOMER INFO BOX ───────────────── */
.customer-info-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 13px;
}
.ci-row { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.ci-label { color: var(--text4); min-width: 80px; font-size: 11px; flex-shrink: 0; }
.ci-value { color: var(--text); }
.ci-pct { color: var(--accent); font-weight: 700; font-size: 22px; font-family: 'DM Mono', monospace; }

/* ── PAGE HEADER ─────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* ── STATS ───────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.stat-label {
  font-size: 11px;
  color: var(--text4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: 'DM Mono', monospace;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  font-family: 'DM Mono', monospace;
}

/* ── FILTERS ─────────────────────────── */
.filters-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filters-row input,
.filters-row select { max-width: 180px; }

/* ── MISC ────────────────────────────── */
.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.actions-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.empty-row td { text-align: center; color: var(--text3); padding: 32px !important; }

/* ── RESPONSIVE ──────────────────────── */
@media (max-width: 768px) {
  .form-grid-2,
  .form-grid-3 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 16px; }
  .top-nav { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 4px; }
  .filters-row input,
  .filters-row select { max-width: 100%; }
  .customer-info-box { grid-template-columns: 1fr; }
}

/* ── THEME TOGGLE ────────────────────── */
.theme-toggle {
  margin-left: auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg4);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--accent);
  transform: rotate(20deg);
}

/* ── LIGHT MODE OVERRIDES ────────────── */
body.light ::-webkit-scrollbar-track { background: #e8e8f0; }
body.light ::-webkit-scrollbar-thumb { background: #b0b0c8; }
body.light .search-results { box-shadow: 0 8px 24px #00000022; }
body.light .stat-value { color: var(--text); }
body.light table th { color: var(--text4); }
body.light .badge-purple { background: #6254e822; color: var(--accent); }
body.light .badge-green  { background: #1a9e5222; color: var(--green); }
body.light .alert-info   { background: #6254e810; border-color: #6254e830; color: var(--accent); }
body.light .alert-success{ background: #1a9e5210; border-color: #1a9e5230; color: var(--green); }
body.light .alert-error  { background: #cc2a1e10; border-color: #cc2a1e30; color: var(--red); }
body.light .btn-secondary { background: var(--bg4); color: var(--text); }
body.light .btn-secondary:hover { background: var(--bg3); }
body.light .btn-danger { background: #cc2a1e15; color: var(--red); border-color: #cc2a1e44; }
body.light .btn-success { background: #1a9e5215; color: var(--green); border-color: #1a9e5244; }
body.light .totals-row { color: var(--text2); }
body.light .totals-row.total { color: var(--text); }
body.light .totals-row .amount { color: var(--accent); }
body.light .totals-row.total .amount { color: var(--green); }
body.light .modal { box-shadow: 0 20px 60px #00000033; }

/* ── LOGIN SCREEN ────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.2s;
}
#login-screen.hidden { 
  display: none; 
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px #00000055;
}
.login-logo {
  font-size: 36px;
  text-align: center;
  margin-bottom: 8px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}
.login-subtitle {
  font-size: 12px;
  text-align: center;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'DM Mono', monospace;
  margin-bottom: 28px;
}

/* ── NAV RIGHT ───────────────────────── */
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.nav-user {
  font-size: 12px;
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}
.nav-user .role-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 5px;
}
.role-admin    { background: var(--accent); color: #fff; }
.role-mitarbeiter { background: var(--bg4); color: var(--text2); border: 1px solid var(--border); }

/* ── ADMIN ONLY VISIBILITY ───────────── */
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }

/* ── USER TABLE ROLE BADGE ───────────── */
.badge-admin { background: #7c6af722; color: #7c6af7; }
.badge-mitar { background: #2ecc7115; color: #2ecc71; }

/* Fix theme toggle margin when in nav-right */
.nav-right .theme-toggle { margin-left: 0; }
