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

:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface2: #f1f0ec;
  --border: rgba(0,0,0,0.1);
  --border2: rgba(0,0,0,0.2);
  --text: #1a1a1a;
  --text2: #666;
  --text3: #999;
  --blue-bg: #E6F1FB; --blue-txt: #0C447C; --blue-bd: rgba(24,95,165,0.3);
  --green-bg: #EAF3DE; --green-txt: #27500A; --green-bd: rgba(59,109,17,0.3);
  --amber-bg: #FAEEDA; --amber-txt: #633806; --amber-bd: rgba(133,79,11,0.3);
  --teal-bg: #E1F5EE; --teal-txt: #085041; --teal-bd: rgba(15,110,86,0.3);
  --gray-bg: #F1EFE8; --gray-txt: #444441; --gray-bd: rgba(95,94,90,0.3);
  --red-bg: #FCEBEB; --red-txt: #791F1F;
  --radius: 8px; --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; }

/* Nav */
.topnav { background: var(--surface); border-bottom: 0.5px solid var(--border); padding: 0 20px; height: 52px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-logo { font-size: 20px; }
.nav-brand { font-weight: 500; font-size: 15px; color: var(--text); text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-user { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.badge-admin { background: var(--blue-bg); color: var(--blue-txt); font-size: 10px; padding: 2px 6px; border-radius: 20px; font-weight: 500; }

/* Page */
.page-content { max-width: 1400px; margin: 0 auto; padding: 16px 20px; }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 32px; width: 360px; text-align: center; }
.login-logo { font-size: 36px; margin-bottom: 10px; }
.login-card h1 { font-size: 18px; font-weight: 500; margin-bottom: 4px; }
.login-sub { color: var(--text2); font-size: 13px; margin-bottom: 24px; }
.login-card .form-group { text-align: left; margin-bottom: 12px; }

/* Stats */
.stats-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 10px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 90px; }
.stat-card.warn { background: var(--amber-bg); border-color: var(--amber-bd); }
.stat-card.info { background: var(--blue-bg); border-color: var(--blue-bd); }
.stat-card.ok { background: var(--teal-bg); border-color: var(--teal-bd); }
.stat-num { font-size: 22px; font-weight: 500; }
.stat-lbl { font-size: 11px; color: var(--text2); }
.stat-card.warn .stat-lbl, .stat-card.warn .stat-num { color: var(--amber-txt); }
.stat-card.info .stat-lbl, .stat-card.info .stat-num { color: var(--blue-txt); }
.stat-card.ok .stat-lbl, .stat-card.ok .stat-num { color: var(--teal-txt); }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filter-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.toolbar-right { display: flex; gap: 6px; }
.search-input { min-width: 150px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 7px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: 0.5px solid var(--border2); background: var(--surface); color: var(--text); text-decoration: none; transition: background 0.15s; }
.btn:hover { background: var(--surface2); }
.btn-primary { background: var(--blue-bg); color: var(--blue-txt); border-color: var(--blue-bd); }
.btn-primary:hover { opacity: 0.85; }
.btn-sec { background: var(--surface); color: var(--text2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* Inputs */
input[type=text], input[type=email], input[type=number], input[type=password], input[type=datetime-local], select, textarea {
  width: 100%; padding: 7px 10px; border: 0.5px solid var(--border2); border-radius: var(--radius); font-size: 13px; color: var(--text); background: var(--surface); font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #378ADD; box-shadow: 0 0 0 2px rgba(55,138,221,0.15); }
textarea { resize: vertical; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; color: var(--text2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-row.full, .form-group.flex2 { grid-column: 1 / -1; }
.form-section { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text3); margin: 16px 0 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.form-hint { font-size: 11px; color: var(--text3); margin: 6px 0 10px; }
.form-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 24px; max-width: 640px; }
.form-title { font-size: 16px; font-weight: 500; margin-bottom: 16px; }

/* Table */
.table-wrap { overflow-x: auto; }
.main-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; border: 0.5px solid var(--border); font-size: 13px; }
.main-table th { font-size: 11px; font-weight: 500; color: var(--text2); padding: 9px 12px; text-align: left; border-bottom: 0.5px solid var(--border); background: var(--surface2); white-space: nowrap; }
.main-table td { padding: 9px 12px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.main-table tr:last-child td { border-bottom: none; }
.main-table tr.auftrag-row:hover td { background: var(--surface2); }
.num { text-align: right; }
.bold { font-weight: 500; }
.muted { color: var(--text3); }
.name-main { font-weight: 500; }
.name-sub { font-size: 11px; color: var(--text2); margin-top: 1px; }
.td-notiz { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text2); }
.td-termin { font-size: 12px; white-space: nowrap; }
.td-actions { white-space: nowrap; text-align: center; }
.termin-offen { color: var(--amber-txt); font-size: 12px; }
.zeit-done { color: var(--teal-txt); font-size: 12px; }
.zeit-input { width: 65px; padding: 3px 6px; font-size: 12px; }
.icon-btn { background: none; border: none; cursor: pointer; padding: 4px 5px; border-radius: 5px; font-size: 14px; color: var(--text2); transition: background 0.1s; }
.icon-btn:hover { background: var(--surface2); }
.icon-btn.danger:hover { background: var(--red-bg); }
.gruppe-header td { background: var(--surface2); font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; padding: 5px 12px !important; }
.empty-state { text-align: center; padding: 48px; color: var(--text3); font-size: 14px; background: var(--surface); border-radius: var(--radius-lg); border: 0.5px solid var(--border); }

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-neu { background: var(--blue-bg); color: var(--blue-txt); }
.badge-offen { background: var(--amber-bg); color: var(--amber-txt); }
.badge-termin { background: var(--green-bg); color: var(--green-txt); }
.badge-erledigt { background: var(--teal-bg); color: var(--teal-txt); }
.badge-abgesagt { background: var(--gray-bg); color: var(--gray-txt); }

/* Admin */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 20px; }
.admin-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card-title { font-size: 14px; font-weight: 500; margin-bottom: 14px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
.admin-table th { font-size: 11px; font-weight: 500; color: var(--text2); padding: 6px 8px; border-bottom: 0.5px solid var(--border); text-align: left; }
.admin-table td { padding: 7px 8px; border-bottom: 0.5px solid var(--border); }
.admin-table tr:last-child td { border-bottom: none; }
.plz-table-wrap { max-height: 220px; overflow-y: auto; border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.status-ok { color: var(--teal-txt); font-size: 12px; }
.status-off { color: var(--text3); font-size: 12px; }
code { font-family: monospace; background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* Modal */
.modal-bg { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-box { background: var(--surface); border-radius: var(--radius-lg); border: 0.5px solid var(--border); padding: 22px; width: 440px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }

/* Alert */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--red-bg); color: var(--red-txt); }
.alert-ok { background: var(--teal-bg); color: var(--teal-txt); }

/* Mobile */
@media (max-width: 700px) {
  .admin-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stats-bar { gap: 6px; }
  .stat-card { min-width: 70px; padding: 8px 10px; }
  .filter-form { flex-direction: column; align-items: stretch; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: flex-end; }
  .main-table th:nth-child(8), .main-table td:nth-child(8),
  .main-table th:nth-child(9), .main-table td:nth-child(9) { display: none; }
}
