:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface2: #f0efe9;
  --border: #dddcd6;
  --text: #1a1917;
  --text2: #6b6a64;
  --text3: #9a9890;
  --accent: #1a1917;
  --green: #2d6a2d;
  --green-bg: #e8f4e8;
  --red: #8a2020;
  --red-bg: #fae8e8;
  --amber: #7a4a10;
  --amber-bg: #fdf0dc;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1d1b;
    --surface2: #252422;
    --border: #2e2d2a;
    --text: #f0ede8;
    --text2: #9a9890;
    --text3: #6b6a64;
    --accent: #f0ede8;
    --green: #7fc47f;
    --green-bg: #1a2e1a;
    --red: #e88080;
    --red-bg: #2a1010;
    --amber: #e8b870;
    --amber-bg: #2a1e08;
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 15px; line-height: 1.5; }

/* Header */
.header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.header-inner { max-width: 1400px; margin: 0 auto; padding: 0 1.5rem; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header-icon { font-size: 20px; }
.header-title { font-weight: 600; font-size: 16px; }
.header-right { display: flex; align-items: center; gap: 10px; }

/* Sync-Status */
.sync-status { font-size: 12px; color: var(--text3); font-family: 'DM Mono', monospace; }
.sync-status.ok { color: var(--green); }
.sync-status.err { color: var(--red); }

/* Buttons */
.btn { padding: 7px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: opacity .15s, background .15s; font-family: inherit; }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { opacity: .82; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid transparent; }
.btn-danger:hover { opacity: .8; }

/* Main */
.main { max-width: 1400px; margin: 0 auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.stat-value { font-size: 28px; font-weight: 600; font-family: 'DM Mono', monospace; }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* Filter */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 220px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit; }
.search-input:focus { outline: none; border-color: var(--text3); }
.select-filter { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit; cursor: pointer; }
.select-filter:focus { outline: none; }

/* Tabelle */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.inv-table th { padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); background: var(--surface2); white-space: nowrap; }
.inv-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.inv-table tr:last-child td { border-bottom: none; }
.inv-table tbody tr:hover { background: var(--surface2); }
.col-num { text-align: right; width: 70px; }
.col-actions { width: 80px; text-align: right; }
.loading-row td { text-align: center; padding: 2rem; color: var(--text3); }

/* Badges */
.kat-badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 500; background: var(--surface2); color: var(--text2); white-space: nowrap; }
.menge-chip { font-family: 'DM Mono', monospace; font-size: 13px; }

/* Aktions-Buttons in Zeile */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
.row-btn { padding: 3px 8px; font-size: 12px; border-radius: 5px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text2); font-family: inherit; }
.row-btn:hover { background: var(--surface2); color: var(--text); }
.row-btn.del:hover { background: var(--red-bg); color: var(--red); border-color: transparent; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; }
.modal-overlay.open { display: block; }
.modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 201; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: min(680px, 96vw); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal.open { display: block; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem 1rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text2); padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--surface2); }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 1.25rem; border-top: 1px solid var(--border); margin-top: 1rem; }

/* Formular */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 500; color: var(--text2); }
.form-input { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 13.5px; font-family: inherit; transition: border-color .15s; }
.form-input:focus { outline: none; border-color: var(--text3); }

/* Import */
.import-hint { font-size: 13px; color: var(--text2); margin-bottom: 1rem; line-height: 1.6; }
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 2.5rem; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; color: var(--text2); font-size: 14px; }
.drop-zone:hover { border-color: var(--text3); background: var(--surface2); }
.drop-icon { font-size: 36px; margin-bottom: .5rem; }
.drop-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }
.import-status { margin-top: 1rem; font-size: 13px; padding: 8px 12px; border-radius: var(--radius); display: none; }
.import-status.ok { background: var(--green-bg); color: var(--green); display: block; }
.import-status.err { background: var(--red-bg); color: var(--red); display: block; }
.import-status.info { background: var(--amber-bg); color: var(--amber); display: block; }

/* Leer-Zustand */
.empty-state { text-align: center; padding: 3rem; color: var(--text3); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: .75rem; }

@media (max-width: 700px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .header-right .btn-ghost { display: none; }
}
.col-notizen { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Login-Screen ────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: min(400px, 92vw);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-icon { font-size: 36px; text-align: center; }
.login-title { font-size: 20px; font-weight: 600; text-align: center; margin: 0; }
.login-sub { font-size: 13px; color: var(--text2); text-align: center; margin: 0; }
.login-error { font-size: 13px; color: var(--red); min-height: 18px; }
.btn-full { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.user-email { font-size: 12px; color: var(--text3); font-family: 'DM Mono', monospace; }
