/* HAVECK 2.0 – Web Design System
   Zielgruppe: Muster-Behörde, behördliche Umgebung
   BITV 2.0 / WCAG 2.1 AA konform, hohe Informationsdichte, ruhige Farbpalette
*/

:root {
  /* Semantische Farben */
  --color-bg:           #F4F6F9;
  --color-surface:      #FFFFFF;
  --color-surface-alt:  #F9FAFC;
  --color-border:       #E3E7EE;
  --color-border-strong:#C7CED9;

  --color-text:         #1F2A3D;
  --color-text-muted:   #5B6575;
  --color-text-faint:   #8891A2;

  /* Behörden-angelehnte Akzente (dezent) */
  --color-primary:      #1D3557;   /* Anthrazit-Blau */
  --color-primary-hover:#16263F;
  --color-accent:       #B22234;   /* Akzent-Rot, sparsam */

  --color-success:      #2E7D32;
  --color-success-bg:   #E4F4E5;
  --color-warn:         #B26A00;
  --color-warn-bg:      #FFF4E1;
  --color-danger:       #B3261E;
  --color-danger-bg:    #FCE4E3;
  --color-info:         #0B5CAD;
  --color-info-bg:      #E3EEF9;

  /* Schatten & Abstände */
  --shadow-sm: 0 1px 2px rgba(20,30,50,.06);
  --shadow-md: 0 4px 12px rgba(20,30,50,.08);
  --shadow-lg: 0 12px 32px rgba(20,30,50,.10);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout Shell ===== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--color-primary);
  color: #E8EEF7;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .logo {
  width: 32px; height: 32px;
  background: var(--color-accent);
  border-radius: 6px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
  letter-spacing: -0.5px;
}
.sidebar .brand .brand-title { font-weight: 600; font-size: 15px; }
.sidebar .brand .brand-sub   { font-size: 11px; color: rgba(255,255,255,.6); letter-spacing: .4px; text-transform: uppercase; }

.nav { list-style: none; padding: 14px 10px; margin: 0; }
.nav-section {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  padding: 14px 10px 6px;
}
.nav-item a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: rgba(255,255,255,.82);
  border-radius: 6px;
  font-size: 13.5px;
}
.nav-item a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active a { background: rgba(255,255,255,.12); color: #fff; font-weight: 500; }
.nav-item .icon { width: 16px; height: 16px; opacity: .8; }

.main { display: flex; flex-direction: column; min-width: 0; }

/* ===== Topbar ===== */
.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar .breadcrumb { color: var(--color-text-muted); font-size: 13px; }
.topbar .breadcrumb strong { color: var(--color-text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.tenant-switch {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 12.5px;
  cursor: pointer;
  background: var(--color-surface-alt);
}
.tenant-switch:hover { border-color: var(--color-border-strong); }
.tenant-switch .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-accent);
}

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-primary);
  color: #fff; font-weight: 600; font-size: 13px;
  display: grid; place-items: center;
}

/* ===== Content ===== */
.content { padding: 28px; max-width: 1400px; width: 100%; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-title { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.3px; }
.page-subtitle { color: var(--color-text-muted); font-size: 13.5px; margin: 0; }

/* ===== Card ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex; justify-content: space-between; align-items: center;
}
.card-title { font-size: 14px; font-weight: 600; margin: 0; }
.card-body { padding: 20px; }
.card + .card { margin-top: 16px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-alt); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }

/* ===== Forms ===== */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row.full { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text);
}
.field label .req { color: var(--color-danger); margin-left: 2px; }
.field .hint { font-size: 11.5px; color: var(--color-text-muted); }

.input, .select, textarea {
  width: 100%;
  padding: 8px 12px;
  font: inherit; font-size: 13px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}
.input:focus, .select:focus, textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29,53,87,.12);
}
.input.invalid, .input[data-invalid] {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
}
.input-with-icon { position: relative; }
.input-with-icon .input { padding-right: 36px; }
.input-with-icon .trailing {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: var(--color-text-muted); cursor: pointer;
  padding: 4px; border-radius: 4px;
}
.input-with-icon .trailing:hover { background: var(--color-surface-alt); color: var(--color-primary); }

/* ===== Radio Groups ===== */
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-inline { display: flex; gap: 12px; flex-wrap: wrap; }

.radio-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: 20px;
  background: var(--color-surface);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.radio-pill:hover { background: var(--color-surface-alt); }
.radio-pill input { accent-color: var(--color-primary); }
.radio-pill.checked { border-color: var(--color-primary); background: var(--color-info-bg); color: var(--color-primary); font-weight: 500; }
.radio-pill.checked.pos { border-color: var(--color-success); background: var(--color-success-bg); color: var(--color-success); }
.radio-pill.checked.neg { border-color: var(--color-danger); background: var(--color-danger-bg); color: var(--color-danger); }

/* ===== Tables ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 14px; text-align: left; }
.table thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--color-text-muted); font-weight: 600;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.table tbody tr { border-bottom: 1px solid var(--color-border); }
.table tbody tr:hover { background: var(--color-surface-alt); }
.table tbody tr:last-child { border-bottom: none; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 500;
  border: 1px solid transparent;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warn    { background: var(--color-warn-bg);    color: var(--color-warn); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-muted   { background: #EEF0F4; color: var(--color-text-muted); }

/* ===== Stepper (MultiPage) ===== */
.stepper {
  display: flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
}
.step {
  flex: 1;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  border-right: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .12s;
  background: var(--color-surface);
}
.step:last-child { border-right: none; }
.step:hover { background: var(--color-surface-alt); }
.step .step-num {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
  flex-shrink: 0;
}
.step .step-label { font-size: 12.5px; color: var(--color-text-muted); }
.step .step-title { font-size: 13.5px; font-weight: 500; color: var(--color-text); }
.step.active {
  background: #fff;
  box-shadow: inset 0 -3px 0 var(--color-primary);
}
.step.active .step-num { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.step.active .step-title { color: var(--color-primary); }
.step.done .step-num { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.step.done .step-title { color: var(--color-success); }

/* ===== Kriterium-Zeile (Hauptkategorie der Clan-/Kriminalitätsprüfung) ===== */
.criterion {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}
.criterion + .criterion { margin-top: 10px; }
.criterion-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 14px 18px;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}
.criterion-title { font-weight: 600; font-size: 14px; }
.criterion-body { padding: 14px 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.criterion-body .begruendung textarea { min-height: 84px; resize: vertical; }
.criterion-desc { font-size: 12.5px; color: var(--color-text-muted); margin-top: 4px; }

.hint-box {
  background: var(--color-info-bg);
  border-left: 3px solid var(--color-info);
  color: var(--color-info);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-top: 8px;
}
.hint-box strong { color: var(--color-info); }

/* ===== KPI / Metric Cards ===== */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.metric {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.metric .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--color-text-muted); font-weight: 600; }
.metric .value { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; margin-top: 6px; }
.metric .delta { font-size: 12px; color: var(--color-success); margin-top: 2px; }
.metric .delta.neg { color: var(--color-danger); }

/* ===== Action Bar ===== */
.action-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  margin-top: -1px;
}
.action-bar .left { display: flex; gap: 8px; }
.action-bar .right { display: flex; gap: 8px; }

/* ===== File upload ===== */
.dropzone {
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all .12s;
}
.dropzone:hover { border-color: var(--color-primary); background: var(--color-info-bg); color: var(--color-primary); }
.dropzone strong { color: var(--color-primary); }

.file-row {
  display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  margin-top: 8px;
}
.file-row .fname { font-size: 13px; font-weight: 500; }
.file-row .fmeta { font-size: 11.5px; color: var(--color-text-muted); }
.file-row .icon {
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--color-info-bg); color: var(--color-info);
  display: grid; place-items: center; font-size: 14px;
}

/* ===== Login Page ===== */
.login-shell {
  min-height: 100vh;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--color-bg);
}
.login-hero {
  background: linear-gradient(145deg, #1D3557 0%, #16263F 100%);
  color: #fff;
  padding: 60px 64px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(178,34,52,.18), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(255,255,255,.05), transparent 50%);
  pointer-events: none;
}
.login-hero h1 {
  font-size: 36px; line-height: 1.15; font-weight: 600;
  margin: 0 0 16px;
  letter-spacing: -0.8px;
  position: relative;
}
.login-hero p { color: rgba(255,255,255,.75); font-size: 14.5px; max-width: 420px; position: relative; }
.login-hero .footer { position: relative; font-size: 12px; color: rgba(255,255,255,.5); }
.login-form-wrap {
  display: grid; place-items: center;
  padding: 40px;
}
.login-form {
  width: 100%; max-width: 380px;
}
.login-form .brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 32px;
}

/* ===== Result View ===== */
.result {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.result-header {
  padding: 24px 28px;
  background: var(--color-primary);
  color: #fff;
}
.result-header h2 { margin: 0; font-size: 18px; font-weight: 500; }
.result-header p { margin: 4px 0 0; opacity: .75; font-size: 12.5px; }

.result-summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--color-border);
}
.result-summary .box {
  padding: 20px 24px;
  border-right: 1px solid var(--color-border);
}
.result-summary .box:last-child { border-right: none; }
.result-summary .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--color-text-muted); font-weight: 600; }
.result-summary .value { font-size: 20px; font-weight: 600; margin-top: 4px; }

.result-body { padding: 24px 28px; }
.result-section { margin-bottom: 24px; }
.result-section h3 {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
  color: var(--color-text-muted);
  padding-bottom: 8px; margin: 0 0 12px;
  border-bottom: 1px solid var(--color-border);
}

.result-grid { display: grid; grid-template-columns: 220px 1fr; gap: 2px; font-size: 13px; }
.result-grid > div { padding: 7px 10px; }
.result-grid .k { color: var(--color-text-muted); }
.result-grid .v { font-weight: 500; }

/* ===== Utilities ===== */
.mt-0 { margin-top: 0; } .mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.text-muted { color: var(--color-text-muted); }
.text-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.sep { height: 1px; background: var(--color-border); margin: 16px 0; }

/* Print */
@media print {
  .sidebar, .topbar, .action-bar, .no-print { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .result { box-shadow: none; border: 1px solid #ccc; }
}

/* Icon-Sprite (Inline SVG wird per style-Eigenschaft in Elementen verwendet) */
.icon-sm { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }
