/* ─── Reset & Basis ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:      #F5F6F8;
  --c-surface: #FFFFFF;
  --c-border:  #E2E4E9;
  --c-text:    #1A1D23;
  --c-muted:   #6B7280;
  --c-accent:  #1B4FCC;        /* Stückemann-Blau */
  --c-accent2: #0EA66B;        /* Grün für Erfolg */
  --c-danger:  #D93025;
  --c-tag-bg:  #EEF2FF;
  --c-tag-sel: #1B4FCC;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --transition: .15s ease;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100dvh;
  line-height: 1.5;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 80px;
}

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 12px;
  max-width: 560px;
  margin: 0 auto;
}
.app-header .logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--c-accent);
  letter-spacing: -.5px;
}
.app-header .subtitle {
  font-size: .78rem;
  color: var(--c-muted);
  margin-top: 1px;
}
.header-user {
  margin-left: auto;
  font-size: .78rem;
  color: var(--c-muted);
  text-align: right;
}
.header-user strong { display: block; color: var(--c-text); font-size: .85rem; }

/* ─── Autocomplete / Select ──────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-surface);
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(27,79,204,.12);
}
.field textarea { min-height: 80px; resize: vertical; }

.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--c-surface);
  border: 1.5px solid var(--c-accent);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow);
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-list li {
  list-style: none;
  padding: 11px 14px;
  cursor: pointer;
  font-size: .95rem;
  border-bottom: 1px solid var(--c-border);
  transition: background var(--transition);
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover, .autocomplete-list li.active {
  background: var(--c-tag-bg);
}
.autocomplete-list li .dept {
  font-size: .75rem;
  color: var(--c-muted);
  margin-left: 6px;
}

/* ─── Kategorie-Karten ───────────────────────────────────────────────────── */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.cat-card {
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cat-card:active { transform: scale(.97); }
.cat-card.selected {
  border-color: var(--c-accent);
  background: var(--c-tag-bg);
}
.cat-card .emoji { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.cat-card .label { font-size: .82rem; font-weight: 600; line-height: 1.3; }

/* ─── Kategorie-Detail (Subcats + Notiz) ────────────────────────────────── */
.cat-detail {
  display: none;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--c-border);
}
.cat-detail.open { display: block; }

.subcat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--c-border);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.chip.selected {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), transform var(--transition);
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--c-accent); color: #fff; width: 100%; }
.btn-primary:hover { opacity: .88; }
.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--c-border);
  color: var(--c-text);
}
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: .82rem; }

/* ─── Success-Screen ─────────────────────────────────────────────────────── */
.success-icon {
  width: 64px; height: 64px;
  background: #E6F8F1;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 16px;
}
.success-screen { text-align: center; }
.success-screen h2 { font-size: 1.3rem; margin-bottom: 8px; }
.success-screen p  { color: var(--c-muted); font-size: .9rem; }

/* ─── Admin ──────────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100dvh; }
.sidebar {
  width: 220px;
  background: var(--c-text);
  color: #fff;
  padding: 24px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  padding: 0 20px 24px;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 16px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  border-radius: 0;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.sidebar nav a .icon { font-size: 1rem; }
.admin-content { flex: 1; padding: 32px; overflow-x: auto; }
.admin-content h1 { font-size: 1.4rem; margin-bottom: 24px; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--c-accent); }
.stat-card .lbl { font-size: .78rem; color: var(--c-muted); margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--c-bg);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--c-bg); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 600;
}
.badge-blue { background: var(--c-tag-bg); color: var(--c-accent); }
.badge-green { background: #E6F8F1; color: #0A7C52; }
.badge-gray  { background: var(--c-bg); color: var(--c-muted); }

/* Bar chart */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-label { width: 180px; font-size: .83rem; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 20px; background: var(--c-bg); border-radius: 999px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--c-accent); border-radius: 999px; transition: width .5s ease; }
.bar-count { font-size: .78rem; color: var(--c-muted); width: 28px; text-align: right; flex-shrink: 0; }

/* Forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 16px;
}
.alert-success { background: #E6F8F1; color: #0A7C52; border: 1px solid #A7DFC8; }
.alert-error   { background: #FEE8E7; color: var(--c-danger); border: 1px solid #F5BFBB; }

/* Mobile Admin */
@media (max-width: 768px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; padding: 12px 0; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 0 12px; gap: 4px; }
  .sidebar nav a { white-space: nowrap; border-radius: var(--radius-sm); }
  .admin-content { padding: 16px; }
}

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--c-muted); font-size: .85rem; }
.text-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
