/* ==========================================================================
   POLIS – Stylesheet (Behoerden-/Dashboard-Look, dunkelblau/grau, nuechtern)
   ========================================================================== */

:root {
  --navy-900: #0f1b33;
  --navy-800: #15233f;
  --navy-700: #1b2c4d;
  --navy-600: #24395f;
  --blue-600: #1d4ed8;
  --blue-500: #2563eb;
  --blue-100: #dbe5fb;
  --grey-50:  #f4f6f9;
  --grey-100: #eef1f6;
  --grey-200: #e2e7ef;
  --grey-300: #cdd5e1;
  --grey-400: #9aa6b8;
  --grey-600: #5b6678;
  --ink:      #1f2a3d;
  --ink-soft: #4b5666;
  --muted:    #6b7686;
  --white:    #ffffff;

  --green-600: #15803d; --green-100:#dcfce7;
  --amber-600: #b45309; --amber-100:#fef3c7;
  --red-600:   #b91c1c; --red-100:  #fee2e2;
  --slate-600: #475569; --slate-100:#e2e8f0;
  --violet-600:#6d28d9; --violet-100:#ede9fe;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(15, 27, 51, .08), 0 2px 8px rgba(15, 27, 51, .06);
  --shadow-lg: 0 8px 28px rgba(15, 27, 51, .18);
  --sidebar-w: 244px;
  --topbar-h: 60px;
  --banner-h: 26px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--grey-50);
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--navy-800); line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
small { color: var(--muted); }
.icon { vertical-align: -.18em; flex: 0 0 auto; }
code, .mono { font-family: var(--mono); font-size: .92em; }

/* -- Demo-Banner ---------------------------------------------------------- */
.demo-banner {
  height: var(--banner-h);
  background: repeating-linear-gradient(45deg, #b45309, #b45309 12px, #a3490a 12px, #a3490a 24px);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  position: sticky; top: 0; z-index: 50;
}

/* -- Topbar --------------------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  background: var(--navy-800);
  color: #fff;
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  position: sticky; top: var(--banner-h); z-index: 40;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), var(--shadow);
}
.brand-link { display: flex; align-items: center; gap: 11px; color: #fff; }
.brand-link:hover { text-decoration: none; }
.brand-mark {
  background: var(--blue-600); color: #fff; font-weight: 800; letter-spacing: .04em;
  padding: 6px 8px; border-radius: var(--radius-sm); font-size: 13px;
  border: 1px solid rgba(255,255,255,.15);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 16px; letter-spacing: .04em; }
.brand-text small { color: #aebbd4; font-size: 11px; }

.quicksearch {
  margin-left: auto; display: flex; align-items: center; gap: 0;
  background: var(--navy-700); border: 1px solid var(--navy-600);
  border-radius: 999px; padding: 0 6px 0 12px; min-width: 320px; max-width: 440px; flex: 1;
}
.quicksearch .icon { color: #9fb0cf; }
.quicksearch input {
  flex: 1; background: transparent; border: 0; color: #fff; padding: 9px 8px; outline: none;
  font-size: 13.5px;
}
.quicksearch input::placeholder { color: #8294b4; }
.quicksearch button {
  background: var(--blue-600); color: #fff; border: 0; border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.quicksearch button:hover { background: var(--blue-500); }

.userbox { display: flex; align-items: center; gap: 12px; }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.user-meta strong { font-size: 13px; }

/* -- Layout --------------------------------------------------------------- */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - var(--topbar-h) - var(--banner-h)); }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--navy-900);
  padding: 14px 12px; display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: calc(var(--topbar-h) + var(--banner-h));
  height: calc(100vh - var(--topbar-h) - var(--banner-h));
  overflow-y: auto;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  color: #6f80a3; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; padding: 8px 10px 4px;
}
.navlink {
  display: flex; align-items: center; gap: 11px;
  color: #c4cee2; padding: 9px 11px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
}
.navlink:hover { background: var(--navy-700); color: #fff; text-decoration: none; }
.navlink.active { background: var(--blue-600); color: #fff; }
.navlink .icon { color: inherit; opacity: .9; }
.nav-footer {
  margin-top: auto; padding: 10px; display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--navy-700); color: #8294b4;
}

.content { flex: 1; min-width: 0; padding: 22px 26px 48px; }

/* -- Seitentitel / Toolbar ------------------------------------------------ */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.page-head .titles { display: flex; flex-direction: column; gap: 2px; }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: 9px; }
.breadcrumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.breadcrumbs a { color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* -- Karten/Panels -------------------------------------------------------- */
.card {
  background: var(--white); border: 1px solid var(--grey-200);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col-main-side { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }

/* -- Statistik-Kacheln ---------------------------------------------------- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat {
  background: var(--white); border: 1px solid var(--grey-200); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; display: flex; align-items: center; gap: 14px;
}
.stat .stat-ic {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: var(--blue-100); color: var(--blue-600); flex: 0 0 auto;
}
.stat .stat-ic.amber { background: var(--amber-100); color: var(--amber-600); }
.stat .stat-ic.red { background: var(--red-100); color: var(--red-600); }
.stat .stat-ic.green { background: var(--green-100); color: var(--green-600); }
.stat .stat-ic.violet { background: var(--violet-100); color: var(--violet-600); }
.stat .stat-val { font-size: 26px; font-weight: 800; color: var(--navy-800); line-height: 1; }
.stat .stat-lbl { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
a.stat:hover { text-decoration: none; border-color: var(--grey-300); }

/* -- Tabellen ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--grey-200); }
table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 13.5px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; vertical-align: middle; }
table.data thead th {
  background: var(--grey-100); color: var(--ink-soft); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--grey-200);
  white-space: nowrap;
}
table.data tbody tr { border-top: 1px solid var(--grey-100); }
table.data tbody tr:hover { background: var(--grey-50); }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data .mono { color: var(--ink-soft); }
.row-link { color: inherit; font-weight: 600; }
.empty {
  text-align: center; color: var(--muted); padding: 40px 16px; background: #fff;
  border: 1px dashed var(--grey-300); border-radius: var(--radius);
}

/* -- Avatare / Miniaturbilder -------------------------------------------- */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: var(--grey-200); border: 1px solid var(--grey-300); flex: 0 0 auto;
}
.avatar.lg { width: 120px; height: 120px; border-radius: 12px; }
.avatar-fallback {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--navy-700); color: #fff; font-weight: 700; font-size: 13px; flex: 0 0 auto;
}
.avatar-fallback.lg { width: 120px; height: 120px; border-radius: 12px; font-size: 34px; }
.media-row { display: flex; align-items: center; gap: 10px; }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 10px; }
.thumb-grid img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; border: 1px solid var(--grey-200); }
.foto-anhang { position: relative; }
.foto-anhang .del { position: absolute; top: 6px; right: 6px; }
.thumb-card {
  display: inline-flex; flex-direction: column; gap: 6px; padding: 8px;
  border: 1px solid var(--grey-200); border-radius: 8px; cursor: pointer; background: #fff;
}
.thumb-card:hover { border-color: #94a3b8; }
.thumb-card img { border-radius: 6px; object-fit: cover; }
/* Markiertes Foto (zum Entfernen vorgemerkt) deutlich hervorheben. */
.thumb-card:has(input:checked) { border-color: #dc2626; background: #fef2f2; }

/* -- Badges --------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  background: var(--slate-100); color: var(--slate-600);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.green  { background: var(--green-100); color: var(--green-600); }
.badge.amber  { background: var(--amber-100); color: var(--amber-600); }
.badge.red    { background: var(--red-100);   color: var(--red-600); }
.badge.blue   { background: var(--blue-100);  color: var(--blue-600); }
.badge.violet { background: var(--violet-100);color: var(--violet-600); }
.badge.grey   { background: var(--grey-200);  color: var(--ink-soft); }
.badge.plain::before { display: none; }

.role-chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.12); color: #dbe5fb; white-space: nowrap;
}
.role-admin { background: var(--red-100); color: var(--red-600); }
.role-ermittler { background: var(--blue-100); color: var(--blue-600); }
.role-sachbearbeiter { background: var(--green-100); color: var(--green-600); }
.role-streife { background: var(--slate-100); color: var(--slate-600); }
.sidebar .role-chip, .topbar .role-chip { background: rgba(255,255,255,.14); color: #dbe5fb; }

/* -- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  background: var(--grey-100); color: var(--ink); transition: background .12s, border-color .12s;
  white-space: nowrap; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-500); }
.btn-secondary { background: #fff; border-color: var(--grey-300); color: var(--ink); }
.btn-secondary:hover { background: var(--grey-50); }
.btn-ghost { background: transparent; color: #cdd9f0; border-color: rgba(255,255,255,.18); }
.btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: #a11414; }
.btn-sm { padding: 5px 9px; font-size: 12.5px; }
.btn-icon { padding: 6px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* -- Formulare ------------------------------------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: 11.5px; color: var(--muted); }
input[type=text], input[type=search], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=email], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--grey-300); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--ink); background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { resize: vertical; min-height: 92px; }
.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; }
fieldset { border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; }
fieldset legend { font-weight: 700; color: var(--navy-700); padding: 0 6px; font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--grey-200); }

/* -- Filterleiste --------------------------------------------------------- */
.filterbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px;
  background: #fff; border: 1px solid var(--grey-200); border-radius: var(--radius); padding: 12px 14px;
}
.filterbar .field { min-width: 150px; }
.filterbar .grow { flex: 1; min-width: 220px; }

/* -- Detailansicht -------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: 180px 1fr; gap: 9px 16px; }
.detail-grid dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.detail-grid dd { margin: 0; color: var(--ink); }
.section-title { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; color: var(--navy-700); }
.section-title .icon { color: var(--blue-600); }

/* -- Flash-Nachrichten ---------------------------------------------------- */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; border: 1px solid;
}
.flash-success { background: var(--green-100); color: var(--green-600); border-color: #bbf7d0; }
.flash-error, .flash-danger { background: var(--red-100); color: var(--red-600); border-color: #fecaca; }
.flash-info { background: var(--blue-100); color: var(--blue-600); border-color: #c7d7fa; }
.flash-warning { background: var(--amber-100); color: var(--amber-600); border-color: #fde68a; }

/* -- Karten (Leaflet) ----------------------------------------------------- */
.map { width: 100%; height: 360px; border-radius: var(--radius); border: 1px solid var(--grey-200); z-index: 1; }
.map.tall { height: 460px; }
.map-full { height: calc(100vh - var(--topbar-h) - var(--banner-h)); border-radius: 0; border: 0; }
.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content strong { color: var(--navy-800); }
.map-legend {
  background: #fff; padding: 8px 10px; border-radius: 6px; box-shadow: var(--shadow); font-size: 12px;
  line-height: 1.7;
}
.map-legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.layer-toggles { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.layer-toggles label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; cursor: pointer; }

/* -- Pagination ----------------------------------------------------------- */
.pagination { display: flex; align-items: center; gap: 6px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 11px; border-radius: var(--radius-sm); border: 1px solid var(--grey-300);
  background: #fff; color: var(--ink-soft); font-size: 13px;
}
.pagination a:hover { background: var(--grey-50); text-decoration: none; }
.pagination .current { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.pagination .disabled { opacity: .45; pointer-events: none; }
.result-count { color: var(--muted); font-size: 13px; }

/* -- Login ---------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 70% -10%, var(--navy-700), var(--navy-900));
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 30px 28px;
}
.login-card .brand-mark { font-size: 16px; }
.login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-head strong { font-size: 20px; color: var(--navy-800); letter-spacing: .04em; }
.login-head small { color: var(--muted); display: block; font-size: 12px; }
.login-card .form-actions { border: 0; margin-top: 16px; padding-top: 0; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--grey-200); padding-top: 14px; }
.login-hint code { background: var(--grey-100); padding: 1px 5px; border-radius: 4px; }

/* -- Fehlerseite ---------------------------------------------------------- */
.errorpage { text-align: center; max-width: 520px; margin: 40px auto; }
.error-code { font-size: 64px; font-weight: 800; color: var(--blue-600); line-height: 1; }

/* -- Utilities ------------------------------------------------------------ */
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.divider { height: 1px; background: var(--grey-200); margin: 16px 0; border: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kv { color: var(--ink); }

/* -- Responsiv ------------------------------------------------------------ */
@media (max-width: 1000px) {
  .grid-2, .grid-3, .grid-4, .col-main-side, .form-grid { grid-template-columns: 1fr; }
  .quicksearch { min-width: 180px; }
  .user-meta { display: none; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; }
  .layout { flex-direction: column; }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .nav-footer { display: none; }
  .content { padding: 16px; }
  .brand-text small { display: none; }
}
