/* Leopold Netzwerke — DATEV-Validator. Dezent, professionell, offline. */
:root {
  --navy: #1f3a5f;
  --navy-dark: #16293f;
  --accent: #2f7d63;
  --accent-dark: #245f4b;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e2e7ee;
  --text: #1d2733;
  --muted: #687587;
  --danger: #b5392f;
  --danger-bg: #fbeceb;
  --ok: #2f7d63;
  --ok-bg: #e9f4ef;
  --warn-bg: #fdf6e7;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff; padding: 0 24px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-center { justify-content: center; gap: 14px; margin-bottom: 22px; }
/* Auf der hellen Login-Card muss der Titel dunkel sein (nicht weiß). */
.brand-center .brand-mark { width: 46px; height: 46px; font-size: 18px; border-radius: 10px; }
.brand-center .brand-name { color: var(--text); font-size: 19px; line-height: 1.15; }
.brand-center .brand-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px; background: var(--accent);
  color: #fff; font-weight: 700; letter-spacing: .5px; font-size: 15px;
}
.brand-name { font-weight: 600; font-size: 17px; color: #fff; }
.brand-sub { display: block; font-weight: 400; font-size: 12px; color: #b9c6d8; }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a { color: #dce4ef; font-size: 14px; }
.topnav .who { color: #9fb0c6; font-size: 13px; }

/* Layout */
.container { width: 100%; max-width: 920px; margin: 28px auto; padding: 0 18px; flex: 1; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px 26px; margin-bottom: 22px; box-shadow: 0 1px 2px rgba(20,40,70,.04);
}
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 18px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

/* Forms */
.form label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.form input, .form select, select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  background: #fff; color: var(--text);
}
select { width: auto; min-width: 240px; }
/* Radio-/Checkbox-Eingaben NICHT als full-width-Block rendern (sonst verrutscht
   die Beschriftung). Sie behalten ihre native Größe und stehen links vom Text. */
.form input[type=radio], .form input[type=checkbox] {
  display: inline-block; width: auto; margin: 3px 0 0; padding: 0; flex: none;
}
.upload-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.upload-form input[type=file] { padding: 8px; border: 1px dashed #b9c4d4; border-radius: 8px; }

.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-block; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-secondary:hover { background: var(--navy-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: #eef2f7; text-decoration: none; }
button.btn-primary { width: auto; }

/* Login – Card vertikal mittig auf der Seite (edler Eindruck). */
.login-wrap {
  display: flex; justify-content: center; align-items: center;
  min-height: calc(100vh - 150px); padding: 32px 0;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 38px 34px; width: 100%; max-width: 400px; box-shadow: 0 8px 30px rgba(20,40,70,.10);
}
.login-lead { color: var(--muted); font-size: 14px; margin: 4px 0 22px; text-align: center; line-height: 1.55; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.table-scroll { overflow-x: auto; }
.mapping-table td { vertical-align: middle; }
.req { color: var(--danger); font-weight: 700; }

/* Badges */
.badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-converted, .badge-customer { background: var(--ok-bg); color: var(--ok); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-created, .badge-mapped { background: #eef2f7; color: var(--navy); }
.badge-admin { background: #e8eefc; color: #34508f; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #efc9c5; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #c4e3d6; }

/* KPI – große, gut lesbare Summen-Kacheln (grün/grau). */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 20px 0; }
.kpi {
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 18px; text-align: center;
  box-shadow: 0 1px 2px rgba(20,40,70,.04);
}
.kpi-green, .kpi-accent { background: var(--ok-bg); border-color: #c4e3d6; }
.kpi-val { display: block; font-size: 30px; font-weight: 700; color: var(--navy); letter-spacing: -.4px; line-height: 1.15; }
.kpi-green .kpi-val, .kpi-accent .kpi-val { color: var(--accent-dark); }
.kpi-lbl { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; font-weight: 600; }

.downloads { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* Log lists – gut lesbares Prüfprotokoll mit Ampelfarben */
.loglist { margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--text); max-height: 340px; overflow-y: auto; }
.loglist li { padding: 9px 12px; margin-bottom: 7px; border-radius: 8px; line-height: 1.45; }
.loglist-error li { color: #7d241d; background: var(--danger-bg); border-left: 3px solid var(--danger); }
.loglist-warn li { color: #7a5f16; background: var(--warn-bg); border-left: 3px solid #d6a73a; }

/* Hero + 3-Schritte */
.hero .lead { font-size: 15px; color: var(--text); max-width: 70ch; }
.lead { line-height: 1.6; }
.steps-title { font-size: 15px; margin: 22px 0 4px; color: var(--navy); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.step { display: flex; gap: 12px; align-items: flex-start; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.step-no { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.step strong { display: block; font-size: 14px; margin-bottom: 3px; }
.step p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }

/* Tooltips (rein CSS, offline) */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; margin-left: 6px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 11px; font-weight: 700;
  cursor: help; position: relative; vertical-align: middle; user-select: none;
}
.tip::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 9px);
  transform: translateX(-50%); width: max-content; max-width: 300px;
  background: var(--navy-dark); color: #fff; font-size: 12px; font-weight: 400;
  line-height: 1.45; text-align: left; padding: 9px 11px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(20,40,70,.22); opacity: 0; visibility: hidden;
  transition: opacity .12s ease; z-index: 30; pointer-events: none; white-space: normal;
}
.tip::before {
  content: ""; position: absolute; left: 50%; bottom: calc(100% + 3px);
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: var(--navy-dark); opacity: 0; visibility: hidden;
  transition: opacity .12s ease; z-index: 30;
}
.tip:hover::after, .tip:focus::after, .tip:hover::before, .tip:focus::before {
  opacity: 1; visibility: visible;
}

/* Hinweis-Feld (KI) */
.hint-field { font-size: 14px; font-weight: 600; }
.hint-field textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; font-family: inherit;
  background: #fff; color: var(--text); resize: vertical; line-height: 1.5;
}
.hint-field textarea::placeholder { color: #9aa7b6; }
.btn-sm { padding: 7px 12px; font-size: 13px; margin-top: 10px; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* Dialog-Modus (Chat) */
.chat-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .chat-layout { grid-template-columns: 1fr; } }
.result-col { border-left: 1px solid var(--line); padding-left: 20px; }
.result-col h2, .result-col h3 { margin: 0 0 8px; }
.result-col h3 { margin-top: 16px; }
.kpi-grid-sm { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi-grid-sm .kpi-val { font-size: 18px; }
.table-sm th, .table-sm td { padding: 5px 8px; font-size: 13px; }
.ops { margin: 12px 0; }
.ops-list { margin: 6px 0 0; padding-left: 20px; font-size: 13px; }
.ops-list li { margin: 4px 0; display: flex; justify-content: space-between;
  align-items: center; gap: 8px; }
.ops-undo { margin: 0; }
.ops-undo button { background: none; border: 0; color: #b3261e; cursor: pointer;
  font-size: 12px; padding: 2px 4px; }
.ops-undo button:hover { text-decoration: underline; }
.link-danger { background: none; border: 0; color: #b3261e; cursor: pointer;
  font: inherit; padding: 0; }
.link-danger:hover { text-decoration: underline; }
.link-action { background: none; border: 0; color: #29456f; cursor: pointer;
  font: inherit; padding: 0; margin-right: 8px; }
.link-action:hover { text-decoration: underline; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 10px; }
.inline-form input, .inline-form select { width: auto; }
.ops-code { margin-top: 3px; }
.ops-code summary { cursor: pointer; font-size: 12px; color: #29456f; }
.ops-code pre { overflow:auto; background:#f6f8fa; padding:8px; border-radius:6px;
  font-size: 12px; margin: 4px 0 0; }
.chat { display: flex; flex-direction: column; gap: 10px; margin: 14px 0;
  max-height: 52vh; overflow-y: auto; padding: 4px; }
.chat-msg { max-width: 82%; padding: 10px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.chat-user { align-self: flex-end; background: #29456f; color: #fff;
  border-bottom-right-radius: 4px; }
.chat-assistant { align-self: flex-start; background: #eef2f7; color: var(--text);
  border-bottom-left-radius: 4px; }
.chat-who { display: block; font-size: 11px; opacity: .7; margin-bottom: 3px; }

/* Einklappbare Detail-Zuordnung auf der Mapping-Seite */
.mapping-details { margin: 6px 0 14px; }
.mapping-details > summary {
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent, #29456f);
  padding: 8px 0; user-select: none;
}
.mapping-details[open] > summary { margin-bottom: 8px; }

/* Auswahl der Interpreter-Engine (Sicherer / Erweiterter Modus) */
.engine-field {
  margin: 14px 0; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 8px; background: #fafbfc;
}
.engine-field legend { font-size: 14px; font-weight: 600; padding: 0 6px; }
.engine-field .radio-row {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 8px;
  font-size: 14px; font-weight: 400; cursor: pointer;
}
.engine-field .radio-row input { margin-top: 3px; }

/* Info-Alert + Hinweis-Box */
.alert-info { background: #eaf1fb; color: #29456f; border: 1px solid #c5d6ef; }
.alert-warn { background: var(--warn-bg); color: #7a5f16; border: 1px solid #e6cf94; }
.hintbox { background: #f8fafc; border: 1px solid var(--line); border-left: 3px solid var(--navy); border-radius: 8px; padding: 12px 14px; font-size: 14px; white-space: pre-wrap; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* Validierungs-Checks (grün/gelb/rot) */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 8px; }
.chk-ico { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 12px; }
.chk-ok { background: var(--ok-bg); color: #235c47; }
.chk-ok .chk-ico { background: var(--ok); }
.chk-ok .chk-ico::after { content: "✓"; }
.chk-warn { background: var(--warn-bg); color: #8a6d1c; }
.chk-warn .chk-ico { background: #d6a73a; }
.chk-warn .chk-ico::after { content: "!"; }
.chk-err { background: var(--danger-bg); color: var(--danger); }
.chk-err .chk-ico { background: var(--danger); }
.chk-err .chk-ico::after { content: "×"; }

/* Drag-and-Drop-Upload */
.upload-form { flex-direction: column; align-items: stretch; }
.dropzone {
  position: relative; border: 2px dashed #b9c4d4; border-radius: 12px;
  background: #f8fafc; padding: 26px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent); outline: none; }
.dropzone.dragover { border-color: var(--accent); background: var(--ok-bg); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); background: var(--ok-bg); }
.dropzone input[type=file] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.dz-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 20px;
}
.dz-text { font-size: 15px; color: var(--text); }
.dz-sub { font-size: 12px; color: var(--muted); }
.upload-form .btn-primary { align-self: flex-start; margin-top: 12px; }

/* Aktions-Links in der Job-Historie */
.row-actions { display: flex; gap: 12px; flex-wrap: wrap; white-space: nowrap; }

/* Kontenrahmen-Auswahl */
.kr-field { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.kr-field select { margin-top: 6px; }

/* Tablet */
@media (max-width: 820px) {
  .container { margin: 20px auto; }
  .card { padding: 20px 20px; }
  .kpi-val { font-size: 26px; }
}

/* Handy */
@media (max-width: 600px) {
  .topbar { padding: 0 14px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px 0; }
  .topnav { gap: 10px; }
  .topnav .who { display: none; }
  .container { margin: 16px auto; padding: 0 14px; }
  .card { padding: 18px 16px; border-radius: 10px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }
  select { min-width: 0; width: 100%; }
  .tip::after { max-width: 220px; }
  .kpi-grid { gap: 12px; }
  .kpi { padding: 16px 14px; }
  .kpi-val { font-size: 24px; }
  .downloads { flex-direction: column; }
  .downloads .btn-primary, .downloads .btn-secondary, .downloads .btn-ghost { text-align: center; }
  .login-card { padding: 30px 22px; }
  .login-wrap { min-height: calc(100vh - 120px); padding: 24px 0; }
}
