/* Datenaufbereitung – Stylesheet
 * Primärfarbe: #cc1e1c · warme Neutraltöne · bewusst helles, sachliches UI
 * Schrift: Inter (Variable Font, lokal gehostet – kein externer Abruf)
 */

@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable-Italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  /* Marke */
  --brand: #cc1e1c;
  --brand-dark: #a81614;
  --brand-deep: #8c100f;
  --brand-tint: #fdf0ef;
  --brand-ring: rgba(204, 30, 28, .28);

  /* Neutrale Flächen (leicht warm) */
  --bg: #f6f4f3;
  --panel: #ffffff;
  --panel-alt: #faf8f7;
  --border: #e6e0dd;
  --border-strong: #cfc6c2;
  --text: #262020;
  --muted: #79706d;
  --faint: #a39a97;

  /* Semantik */
  --ok: #1a7a4d;
  --ok-bg: #e9f5ee;
  --err: #b3261e;
  --err-bg: #fceceb;
  --warn-bg: #fdf4e0;
  --warn-border: #ecd9a8;
  --warn-text: #7a5a08;
  --dup: #35507c;
  --dup-bg: #eef2f9;

  --shadow-sm: 0 1px 2px rgba(38, 32, 32, .06), 0 1px 6px rgba(38, 32, 32, .05);
  --shadow-md: 0 2px 6px rgba(38, 32, 32, .08), 0 8px 24px rgba(38, 32, 32, .09);
  --shadow-lg: 0 4px 12px rgba(38, 32, 32, .12), 0 24px 60px rgba(38, 32, 32, .18);

  --radius: 6px;
  --radius-lg: 10px;
  --topbar-h: 56px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; text-wrap: balance; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
a { color: var(--brand-dark); }

::selection { background: rgba(204, 30, 28, .16); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 500;
  padding: 6px 13px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer;
  line-height: 1.45;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgba(38, 32, 32, .05);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { background: var(--panel-alt); border-color: var(--faint); }
.btn:active:not(:disabled) { box-shadow: inset 0 1px 2px rgba(38, 32, 32, .08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand-ring);
  outline-offset: 1px;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand-dark);
  color: #fff;
  box-shadow: 0 1px 2px rgba(140, 16, 15, .35);
}
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-deep); }

.btn.danger { color: var(--err); border-color: #e5b7b3; background: var(--panel); }
.btn.danger:hover:not(:disabled) { background: var(--err-bg); border-color: #d99b96; }

.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: rgba(38, 32, 32, .06); border-color: transparent; }

.btn.icon { padding: 6px 10px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; }

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  max-width: 100%;
  transition: border-color .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }

/* Versal-Label als wiederkehrendes Ordnungselement */
.side-title, .field > label:not(.check), table.list th, .menu .menu-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}
.field label.check { font-size: 13px; color: var(--text); }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(204, 30, 28, .07), transparent 60%),
    linear-gradient(165deg, #f8f6f5, #efe9e7);
  z-index: 60;
}
.login-box {
  width: 340px; max-width: calc(100vw - 32px);
  background: var(--panel);
  padding: 30px 28px 26px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 11px;
}
.login-box h1 { font-size: 19px; margin: 0; display: flex; align-items: center; gap: 10px; }
.login-box h1::before {
  content: "▦";
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--brand); color: #fff; font-size: 15px;
  box-shadow: 0 2px 6px rgba(140, 16, 15, .35);
}
.login-box p { margin: 0 0 4px; font-size: 13px; }
.login-error {
  background: var(--err-bg); color: var(--err);
  border: 1px solid #eec7c4;
  padding: 8px 11px; border-radius: var(--radius); font-size: 13px;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 20;
}
.topbar::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-deep));
}
.brand {
  font-weight: 700; letter-spacing: -.01em;
  margin-right: 10px; white-space: nowrap;
  display: flex; align-items: center; gap: 9px;
}
.brand::before {
  content: "▦";
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--brand); color: #fff; font-size: 13px;
}
.topbar-group { display: flex; align-items: center; gap: 6px; }
.topbar-spacer { flex: 1; }
.file-badge {
  font-size: 12px; color: var(--muted);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 12px;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-badge.dirty { border-color: rgba(204, 30, 28, .35); color: var(--brand-dark); background: var(--brand-tint); }
.file-badge.dirty::after { content: " ●"; font-size: 9px; vertical-align: 1px; }

/* ---------- Leerer Zustand ---------- */
.empty {
  height: calc(100vh - var(--topbar-h));
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.empty-inner {
  text-align: center; max-width: 500px;
  background: var(--panel); padding: 40px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--brand);
  background: var(--brand-tint);
  border: 1px solid rgba(204, 30, 28, .18);
  border-radius: 14px;
}
.empty-inner h2 { font-size: 18px; }
.empty-inner p { line-height: 1.6; max-width: 42ch; margin-left: auto; margin-right: auto; }

/* ---------- Workspace ---------- */
.workspace {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}
.sidebar {
  width: 252px; flex: 0 0 252px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px 12px;
}
.side-section { margin-bottom: 22px; }
.side-title {
  margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.chip {
  background: var(--panel-alt); color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 0 7px; font-size: 11px; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.tool {
  display: block; width: 100%; text-align: left;
  font: inherit; font-weight: 500; font-size: 13px;
  padding: 8px 10px; margin-bottom: 5px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.tool:hover {
  border-color: rgba(204, 30, 28, .4);
  background: var(--brand-tint);
  box-shadow: inset 2px 0 0 var(--brand);
}

.col-list { display: flex; flex-direction: column; gap: 2px; }
.col-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 5px; font-size: 13px;
}
.col-item:hover { background: var(--panel-alt); }
.col-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.col-item.hidden-col .name { color: var(--faint); text-decoration: line-through; }
.col-item .mini { border: none; background: none; cursor: pointer; color: var(--faint); padding: 1px 3px; font-size: 11px; }
.col-item .mini:hover { color: var(--brand-dark); }
.col-item .mini:disabled { opacity: .3; cursor: default; }
.col-item .grip { color: var(--faint); cursor: grab; user-select: none; font-size: 13px; }
.col-item:hover .grip { color: var(--muted); }
.col-item.dragging { opacity: .45; }
.col-item.drop-above { box-shadow: inset 0 2px 0 var(--brand); }
.col-item.drop-below { box-shadow: inset 0 -2px 0 var(--brand); }

.issue-summary { font-size: 13px; color: var(--muted); line-height: 1.5; }
.issue-summary .bad { color: var(--err); font-weight: 600; font-variant-numeric: tabular-nums; }
.issue-summary .good { color: var(--ok); font-weight: 600; }
.issue-line { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }

/* ---------- Hauptbereich ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.search { width: 270px; }
.sep { width: 1px; height: 20px; background: var(--border); }

.grid-wrap { flex: 1; overflow: auto; position: relative; background: var(--panel); }

/* ---------- Tabelle ---------- */
.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}
.grid th, .grid td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0;
  vertical-align: top;
}
.grid thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border-strong);
}
.grid thead tr.filters th { top: 36px; z-index: 4; background: #fdfcfb; }

.th-inner {
  display: flex; align-items: center; gap: 4px;
  padding: 0 9px; height: 36px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted);
}
.th-inner .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.th-inner .label:hover { color: var(--brand-dark); }
.th-inner .sort { color: var(--brand); font-size: 10px; }
.th-inner .colmenu {
  border: none; background: none; cursor: pointer;
  color: var(--faint); padding: 0 3px; font-size: 13px; border-radius: 3px;
}
.th-inner .colmenu:hover { color: var(--brand-dark); background: rgba(204, 30, 28, .08); }
.filters input {
  width: 100%; border: none; border-radius: 0;
  padding: 5px 9px; font-size: 12px; background: transparent;
}
.filters input:focus-visible { outline: 2px solid var(--brand-ring); outline-offset: -2px; }
.filters th.active-filter { background: var(--brand-tint); box-shadow: inset 0 -2px 0 var(--brand); }

.grid td.cell {
  padding: 6px 9px;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  font-variant-numeric: tabular-nums;
}
.grid td.cell:focus {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: #fff;
  position: relative; z-index: 3;
}
.grid tbody tr:nth-child(even) td { background: #fbfaf9; }
.grid tbody tr:hover td { background: #f6f2f0; }
.grid tbody tr.selected td { background: var(--brand-tint); }
.grid td.invalid { background: var(--err-bg) !important; box-shadow: inset 3px 0 0 var(--err); }
.grid td.dup { background: var(--dup-bg) !important; }
.grid tr.dup-row td:first-child { box-shadow: inset 3px 0 0 var(--dup); }
/* Manuell zu prüfende Felder (z. B. ungültige E-Mails) – bernsteinfarben.
 * Höhere Spezifität als Zebra/Hover; rote Regelverstöße (!important) gewinnen. */
.grid td.cell.review { background: var(--warn-bg); box-shadow: inset 3px 0 0 #e0a52e; }

.col-num, .col-sel {
  width: 48px; text-align: center; color: var(--faint);
  background: var(--panel-alt) !important;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.grid td.col-num { padding: 6px 6px; font-size: 11px; }
.col-sel { width: 34px; }
.grid td.col-sel { padding: 6px 0; text-align: center; }
.grid thead th.col-num, .grid thead th.col-sel { z-index: 6; }

.no-rows { padding: 48px; text-align: center; color: var(--muted); }

/* ---------- Statuszeile ---------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 14px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.status-left { display: flex; gap: 16px; flex-wrap: wrap; }
.status-left strong { color: var(--text); }
.pager { display: flex; align-items: center; gap: 4px; }
.page-info { min-width: 110px; text-align: center; }
.mini-select { padding: 2px 4px; font-size: 12px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(38, 28, 28, .5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--panel);
  border-radius: var(--radius-lg);
  border-top: 3px solid var(--brand);
  box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: modal-in .16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal.wide { width: 800px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--border);
  background: var(--panel-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}
.modal-foot .left { margin-right: auto; }

.field { margin-bottom: 15px; }
.field > label { display: block; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field input[type=text], .field input[type=number], .field select, .field textarea { width: 100%; }
.row2 { display: flex; gap: 14px; }
.row2 > * { flex: 1; }

.checklist {
  max-height: 210px; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px;
  background: var(--panel);
}
.checklist label {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 13px;
}
.checklist label:hover { background: var(--brand-tint); }

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th, table.list td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--border); }
table.list td { font-variant-numeric: tabular-nums; }
table.list tr:last-child td { border-bottom: none; }
table.list td.actions { text-align: right; white-space: nowrap; }

.notice {
  background: var(--dup-bg); border: 1px solid #ccd8ea; color: #2c4368;
  padding: 10px 12px; border-radius: var(--radius); font-size: 13px; margin-bottom: 15px;
  line-height: 1.5;
}
.notice.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }

/* ---------- Spaltenmenü ---------- */
.menu {
  position: fixed; z-index: 45;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 5px; min-width: 216px; max-height: 70vh; overflow: auto;
}
.menu button {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 13px;
  padding: 6px 10px; border: none; background: none;
  border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.menu button:hover { background: var(--brand-tint); }
.menu button.danger { color: var(--err); }
.menu button.danger:hover { background: var(--err-bg); }
.menu .menu-sep { height: 1px; background: var(--border); margin: 5px 3px; }
.menu .menu-label { padding: 7px 10px 3px; }

/* ---------- Toasts / Busy / Drop ---------- */
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #2b2323; color: #fff; padding: 10px 15px;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13px;
  max-width: 360px;
  border-left: 3px solid var(--faint);
  animation: slide-in .18s ease-out;
}
.toast.error { border-left-color: #ff6f6a; background: #571512; }
.toast.ok { border-left-color: #4fce8d; background: #123d27; }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } }

.busy {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(246, 244, 243, .82);
  backdrop-filter: blur(1px);
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  color: var(--muted);
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border-strong); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.drop-hint {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(204, 30, 28, .08);
  border: 3px dashed var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 600; color: var(--brand-dark);
  pointer-events: none;
}
.drop-hint > div {
  background: var(--panel); padding: 14px 26px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}

/* ---------- Assistent (geführter Ablauf) ---------- */
.wiz-steps { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.wiz-step {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 7px; font-size: 13px;
  color: var(--muted); cursor: default;
}
.wiz-step .wiz-num {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--panel-alt); color: var(--faint);
  border: 1px solid var(--border-strong);
}
.wiz-step .wiz-label { flex: 1; }
.wiz-step.done { color: var(--text); }
.wiz-step.done .wiz-num { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.wiz-step.current { background: var(--brand-tint); color: var(--brand-dark); font-weight: 600; }
.wiz-step.current .wiz-num { background: var(--brand); color: #fff; border-color: var(--brand-dark); }
.wiz-step.clickable { cursor: pointer; }
.wiz-step.clickable:hover { background: var(--panel-alt); }

.wiz-card {
  background: var(--panel); border: 1px solid var(--border);
  border-top: 3px solid var(--brand); border-radius: 8px;
  padding: 12px; margin-bottom: 12px;
}
.wiz-card h4 { margin: 0 0 6px; font-size: 14px; }
.wiz-card p { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.wiz-card .btn { width: 100%; margin-top: 4px; }

/* ---------- Rot/Grün-Diff-Vorschau ---------- */
.diff-old {
  color: var(--err); background: var(--err-bg);
  padding: 1px 3px; border-radius: 3px; text-decoration: line-through;
  text-decoration-color: rgba(179, 38, 30, .5);
}
.diff-new {
  color: var(--ok); background: var(--ok-bg);
  padding: 1px 3px; border-radius: 3px; font-weight: 600;
}
.diff-old.plain, .diff-new.plain { text-decoration: none; }
table.diff { width: 100%; border-collapse: collapse; font-size: 13px; }
table.diff th, table.diff td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border);
  vertical-align: top; word-break: break-word;
}
table.diff th {
  color: var(--muted); font-size: 12px; font-weight: 600;
  position: sticky; top: 0; background: var(--panel); z-index: 1;
}
table.diff th.old-head { color: var(--err); }
table.diff th.new-head { color: var(--ok); }
table.diff td.cnum { color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; width: 46px; }
.diff-scroll { max-height: 48vh; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.ws-mark { background: rgba(179, 38, 30, .18); border-radius: 2px; color: var(--err); }

.checklist-cols { display: flex; flex-direction: column; gap: 1px; max-height: 320px; overflow: auto; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .search { width: 160px; }
}
