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

:root {
  --primary: #417B86;
  --primary-dark: #2f5a63;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;

  --status-offen: #94a3b8;
  --status-gesperrt: #ef4444;
  --status-besucht: #3b82f6;
  --status-vertrag: #22c55e;
  --status-niemand: #f97316;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ── NAV ── */
nav {
  background: var(--primary);
  color: white;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
nav .nav-right { display: flex; align-items: center; gap: 1rem; }
nav .nav-user { font-size: .85rem; opacity: .85; }
nav a { color: white; text-decoration: none; font-size: .9rem; opacity: .9; }
nav a:hover { opacity: 1; }

/* ── LAYOUT ── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title { font-size: 1.4rem; font-weight: 700; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ── CARDS / LISTS ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  overflow: hidden;
}
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.list-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.2rem;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.list-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); border-color: var(--primary); }
.list-card h3 { font-size: 1rem; font-weight: 600; }
.list-card .meta { font-size: .8rem; color: var(--text-muted); }
.list-card .count { font-size: .85rem; color: var(--primary); font-weight: 600; }
.list-card .card-actions { display: flex; justify-content: flex-end; margin-top: .5rem; }

/* ── TABLE ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .85rem;
}
th {
  background: #f8fafc;
  padding: .65rem .8rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── STATUS BADGES ── */
.status-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-offen       { background: #f1f5f9; color: #475569; }
.status-gesperrt    { background: #fee2e2; color: #991b1b; }
.status-besucht     { background: #dbeafe; color: #1e40af; }
.status-vertrag     { background: #dcfce7; color: #166534; }
.status-niemand     { background: #ffedd5; color: #9a3412; }

/* ── SELECTS IN TABLE ── */
.status-select, .kundentyp-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .3rem .5rem;
  font-size: .82rem;
  background: white;
  cursor: pointer;
  min-width: 160px;
}
.status-select:focus, .kundentyp-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filter-bar input, .filter-bar select {
  padding: .45rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  background: white;
}
.filter-bar input { min-width: 220px; }
.filter-bar input:focus, .filter-bar select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2f5a63 0%, #417B86 100%);
}
.login-box {
  background: white;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-box h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: .25rem; color: var(--primary); }
.login-box .subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.75rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.form-group input, .form-group select {
  width: 100%;
  padding: .6rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
}
.error-msg { color: var(--danger); font-size: .85rem; margin-top: .5rem; min-height: 1.2em; }
.btn-block { width: 100%; justify-content: center; padding: .7rem; font-size: 1rem; margin-top: .5rem; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  border-radius: 10px;
  padding: 1.75rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; }

/* ── TABS ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: .65rem 1.2rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── MISC ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state p { font-size: 1.05rem; margin-bottom: .5rem; }
.back-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-muted); font-size: .9rem; text-decoration: none; margin-bottom: 1rem; }
.back-link:hover { color: var(--primary); }

.stats-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .7rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* ── PROJEKT-KACHELN (Dashboard) ── */
.project-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.3rem;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  position: relative;
}
.project-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); border-color: var(--primary); }
.project-card h3 { font-size: 1.05rem; font-weight: 700; }
.project-card .meta { font-size: .8rem; color: var(--text-muted); }
.project-card .count { font-size: .85rem; color: var(--primary); font-weight: 600; }
.project-card-actions {
  display: flex; gap: .5rem; margin-top: .25rem; flex-wrap: wrap; justify-content: flex-end;
}
.map-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .3rem .7rem; border-radius: 6px; font-size: .8rem; font-weight: 600;
  background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0;
  cursor: pointer; text-decoration: none;
}
.map-btn:hover { background: #dcfce7; }

/* ── PROJEKTDETAIL-SEITE ── */
.map-frame-wrapper {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.map-frame-wrapper iframe {
  display: block;
  width: 100%;
  height: 320px;
  border: none;
}

.list-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  flex-wrap: wrap;
}
.list-summary-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); border-color: var(--primary); }
.list-summary-name { font-weight: 600; font-size: .95rem; flex: 1; min-width: 120px; }
.list-summary-stats { display: flex; gap: .4rem; flex-wrap: wrap; }
.list-stat-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .18rem .5rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700;
}
.list-stat-chip.s-offen       { background: #f1f5f9; color: #475569; }
.list-stat-chip.s-gesperrt    { background: #fee2e2; color: #991b1b; }
.list-stat-chip.s-besucht     { background: #dbeafe; color: #1e40af; }
.list-stat-chip.s-vertrag     { background: #dcfce7; color: #166534; }
.list-stat-chip.s-niemand     { background: #ffedd5; color: #9a3412; }
.list-summary-open {
  font-size: .8rem; color: var(--primary); font-weight: 600;
  white-space: nowrap; text-decoration: none;
}

/* ── ADMIN-MODAL: CHIPS + DROPDOWN ── */
.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 2rem; margin-bottom: .6rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: #d6e8eb; color: #2f5a63;
  border-radius: 20px; padding: .2rem .65rem;
  font-size: .8rem; font-weight: 600;
}
.chip button {
  background: none; border: none; cursor: pointer;
  color: #2f5a63; font-size: .9rem; line-height: 1; padding: 0;
}
.chip button:hover { color: var(--danger); }
.chip-add-row { display: flex; gap: .5rem; }
.chip-add-row select {
  flex: 1; padding: .4rem .6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .85rem; background: white;
}
.chip-placeholder { font-size: .82rem; color: var(--text-muted); }

/* ── ZUWEISUNGS-SEITE ── */
.assign-list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: .75rem;
}
.assign-list-card h4 { font-size: .95rem; font-weight: 600; margin-bottom: .6rem; }
.assigned-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; min-height: 1.5rem; }
.assigned-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: #d6e8eb; color: #2f5a63;
  border-radius: 20px; padding: .2rem .6rem;
  font-size: .8rem; font-weight: 600;
}
.assigned-chip button {
  background: none; border: none; cursor: pointer;
  color: #2f5a63; font-size: .85rem; line-height: 1;
  padding: 0 .1rem;
}
.assigned-chip button:hover { color: var(--danger); }
.assign-add-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.assign-add-row select {
  padding: .4rem .6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .85rem; background: white;
}
.assign-project-section { margin-bottom: 2rem; }
.assign-project-title {
  font-size: 1rem; font-weight: 700; margin-bottom: .75rem;
  padding-bottom: .4rem; border-bottom: 2px solid var(--border);
}

/* ── MOBILE ENTRY CARDS ── */
.entry-cards { display: none; flex-direction: column; gap: .75rem; }

.entry-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border-left: 4px solid var(--border);
  overflow: hidden;
}
.entry-card.s-offen       { border-left-color: #94a3b8; }
.entry-card.s-gesperrt    { border-left-color: #ef4444; }
.entry-card.s-besucht     { border-left-color: #3b82f6; }
.entry-card.s-vertrag     { border-left-color: #22c55e; }
.entry-card.s-niemand     { border-left-color: #f97316; }

.entry-card-header { padding: .9rem 1rem .6rem; }

/* Straße + HN gemeinsam als vollständige Adresse */
.entry-card-address {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  letter-spacing: -.01em;
}
.entry-card-address .hn {
  color: var(--primary);
}

.entry-card-meta {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .3rem;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .6rem;
}
.entry-card-meta .meta-item { display: flex; gap: .25rem; }
.entry-card-meta .meta-label { font-weight: 600; color: #94a3b8; }

.entry-card-controls {
  padding: .5rem 1rem .75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}
.entry-card-controls label {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.entry-card-controls select {
  width: 100%;
  padding: .6rem .5rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  background: white;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
  padding-right: 1.8rem;
}
.entry-card-controls select:focus {
  outline: none;
  border-color: var(--primary);
}

.entry-card-toggle {
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  padding: .5rem 1rem;
  text-align: left;
  font-size: .8rem;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.entry-card-toggle:hover { background: var(--bg); }
.entry-card-toggle .toggle-arrow { transition: transform .2s; font-style: normal; display: inline-block; }
.entry-card-toggle.open .toggle-arrow { transform: rotate(90deg); }

.entry-card-details {
  display: none;
  padding: .6rem 1rem .8rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  gap: .4rem .75rem;
  font-size: .82rem;
}
.entry-card-details.open { display: grid; grid-template-columns: 1fr 1fr; }
.entry-card-details .detail-row { display: flex; flex-direction: column; gap: .1rem; }
.entry-card-details .detail-label {
  font-size: .7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.entry-card-details .detail-val { color: var(--text); word-break: break-word; }

@media (max-width: 720px) {
  .container { padding: .75rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-title { font-size: 1.15rem; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: .5rem; }
  .filter-bar input { min-width: unset; }

  /* Switch table ↔ cards */
  .table-wrapper { display: none; }
  .entry-cards { display: flex; }

  nav { padding: 0 1rem; }
  nav .nav-user { display: none; }

  .stats-row { gap: .4rem; }
  .stat-chip { font-size: .72rem; padding: .2rem .5rem; }
}
