/* HelvaChat – Design-System. Eigenständig, kein CDN, keine Webfonts.
   Ruhig und schweizerisch: tiefes Petrol als Marke, Schweizer Rot nur als Marker, alles andere neutral. */
:root {
  --brand: #0f3d3e;
  --brand-hover: #155052;
  --action: #0f3d3e;         /* Aktionsfarbe = Marken-Petrol */
  --action-hover: #1a5a5c;
  --action-soft: #e6efee;
  --action-line: #b3c9c8;    /* Rahmen sekundärer Knöpfe und Segmente */
  --accent: #d52b1e;         /* Schweizer Rot: nur als Marker (aktiver Reiter), nie als Fläche */

  --ink: #111827;
  --ink-2: #4b5563;
  --ink-3: #6b7280;
  --ink-4: #9ca3af;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e5e7eb;
  --line-2: #d1d5db;

  --ok: #15803d;      --ok-soft: #e7f6ec;
  --warn: #b45309;    --warn-soft: #fdf2e1;
  --danger: #b91c1c;  --danger-soft: #fdecec;
  --info: #1d4ed8;    --info-soft: #e6eefc;

  --r: 8px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .06);
  --sidebar: 248px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--action); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.015em; line-height: 1.25; }
h1 .tool-logo { display: block; height: 24px; width: auto; margin: 2px 0 3px; }  /* Tool-Wortmarke statt Textzeile */
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; letter-spacing: -0.005em; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.micro { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; color: var(--ink-2); }
.ico { flex: 0 0 auto; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 22px 16px; }
.brand img { height: 26px; display: block; }
.company {
  margin: 0 12px 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.company .ico { color: var(--ink-3); }
.company select { border: 0; background: transparent; padding: 0; font: inherit; font-weight: 600; width: 100%; color: var(--ink); cursor: pointer; }
.company select:focus { outline: none; }
.company .name { font-weight: 600; }
nav.menu { padding: 8px 12px; flex: 1; overflow-y: auto; }
nav.menu .group { padding: 16px 10px 6px; }
nav.menu a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; font-size: 13.5px; line-height: 1.3;
}
nav.menu a .ico { color: var(--ink-4); }
nav.menu a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
nav.menu a.active { background: var(--action-soft); color: var(--action); box-shadow: inset 3px 0 0 var(--accent); }
nav.menu a.active .ico { color: var(--action); }
.userbox { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600;
  display: grid; place-items: center; flex: 0 0 auto; letter-spacing: .02em;
}
.userbox .meta { min-width: 0; flex: 1; font-size: 12.5px; line-height: 1.3; }
.userbox .meta .name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox .meta .role { color: var(--ink-3); }
.userbox a.out { color: var(--ink-4); display: inline-flex; padding: 4px; border-radius: 4px; }
.userbox a.out:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }

.content { flex: 1; min-width: 0; }
main { padding: 32px 40px 48px; max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; }
.page-head .crumb { font-size: 13px; margin-bottom: 6px; display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); }
.page-head .crumb:hover { color: var(--action); text-decoration: none; }
.section { margin-top: 28px; }
.section > .micro { margin-bottom: 10px; display: block; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth .panel { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 32px 32px 28px; box-shadow: var(--shadow); }
.auth .brand { padding: 0 0 22px; }
.auth .brand img { height: 28px; margin: 0 auto; }
.auth h2 { font-size: 18px; margin-bottom: 4px; }
.auth .lead { color: var(--ink-3); margin-bottom: 18px; }
.auth .foot { margin-top: 18px; font-size: 13px; color: var(--ink-3); text-align: center; }

/* ---------- Flächen ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card.flush .card-body { padding: 20px 22px; }
.grid { display: grid; gap: 16px; }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Tool-Kacheln */
.tile {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px; color: inherit; box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s; min-height: 168px;
}
a.tile:hover { text-decoration: none; border-color: var(--line-2); box-shadow: 0 2px 8px rgba(17,24,39,.08); }
.tile .tile-icon {
  width: 38px; height: 38px; border-radius: var(--r-sm); background: var(--action-soft); color: var(--action);
  display: grid; place-items: center; margin-bottom: 14px;
}
.tile.locked .tile-icon { background: var(--surface-2); color: var(--ink-4); }
.tile h3 { margin: 0 0 4px; font-size: 15px; }
.tile .desc { color: var(--ink-3); font-size: 13px; flex: 1; line-height: 1.45; }
.tile .foot { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* Status */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); flex: 0 0 auto; }
.status.ok::before { background: var(--ok); }
.status.warn::before { background: var(--warn); }
.status.danger::before { background: var(--danger); }
.status.info::before { background: var(--info); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em; padding: 2px 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.tag.info { background: var(--info-soft); border-color: transparent; color: var(--info); }

/* ---------- Formulare ---------- */
form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); font: inherit; font-size: 14px;
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--action-soft); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--ink-3); }
select { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; }
select.inline { width: auto; padding: 5px 28px 5px 8px; font-size: 13px; }
.help { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.check input { width: auto; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--action); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; line-height: 1.2;
  background: var(--action); color: #fff; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--action-hover); border-color: var(--action-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
/* Zweite Stufe: Umriss in Markenfarbe */
.btn.secondary { background: var(--surface); color: var(--action); border-color: var(--action-line); }
.btn.secondary:hover { background: var(--action-soft); border-color: var(--action); }
/* Dritte Stufe: Textlink (Zeilenaktionen) – grau, beim Überfahren Markenfarbe */
.btn.ghost { background: transparent; color: var(--ink-2); border-color: transparent; padding: 0 6px; font-weight: 500; }
.btn.ghost:hover { background: transparent; color: var(--action); text-decoration: underline; }
/* Löschen: immer roter Text, nie gefüllt */
.btn.danger { background: transparent; color: var(--danger); border-color: transparent; padding: 0 6px; font-weight: 500; }
.btn.danger:hover { background: transparent; color: #7f1d1d; text-decoration: underline; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost.sm, .btn.danger.sm { padding: 0 6px; }
.btn.block { width: 100%; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Segment-Filter (z. B. 7 Tage · 30 Tage) – eckig, aktiver Teil gefüllt */
.seg { display: inline-flex; border: 1px solid var(--action-line); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 18px; background: var(--surface); }
.seg a { padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--ink-2); border-right: 1px solid var(--action-line); }
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--action-soft); text-decoration: none; color: var(--action); }
.seg a.on, .seg a.on:hover { background: var(--action); color: #fff; }

/* Reiter unter dem Seitenkopf – oranger Strich markiert den aktiven */
.subnav { display: flex; gap: 22px; border-bottom: 1px solid var(--line-2); margin: -6px 0 24px; overflow-x: auto; }
.subnav a { padding: 8px 0 9px; font-size: 13.5px; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subnav a:hover { color: var(--action); text-decoration: none; }
.subnav a.on { color: var(--action); font-weight: 600; border-bottom-color: var(--accent); }

/* Schritt-Anzeige (Assistenten/Wizard): nummerierte Kreise, Häkchen für Erledigtes */
.steps { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.steps span { font-size: 13px; color: var(--ink-4); display: inline-flex; align-items: center; gap: 8px; }
.steps span i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-2); font-size: 11.5px; font-weight: 600; display: grid; place-items: center; }
.steps span.done { color: var(--ink-2); }
.steps span.done i { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.steps span.on { color: var(--action); font-weight: 600; }
.steps span.on i { background: var(--action); border-color: var(--action); color: #fff; }
form.inline { display: inline; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover td { background: #fbfcfd; }
tbody tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.dim { color: var(--ink-3); }
td.date { white-space: nowrap; color: var(--ink-3); font-variant-numeric: tabular-nums; }
td .primary { font-weight: 500; color: var(--ink); }

/* Dropzone */
.drop {
  border: 2px dashed var(--line-2); border-radius: var(--r); background: var(--surface);
  padding: 34px 24px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--action); background: var(--action-soft); }
.drop .ico { color: var(--ink-4); }
.drop.over .ico { color: var(--action); }
.drop b { display: block; margin: 8px 0 2px; font-size: 14px; }
.drop span { color: var(--ink-3); font-size: 12.5px; }

/* ---------- Meldungen ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--r-sm); margin-bottom: 20px; border: 1px solid; font-size: 13.5px; background: var(--info-soft); border-color: #c7d7f5; color: #1e3a8a; }
.flash.ok { background: var(--ok-soft); border-color: #bfe3cb; color: #14532d; }
.flash.warn { background: var(--warn-soft); border-color: #f3d9a4; color: #7c2d12; }
.flash.error { background: var(--danger-soft); border-color: #f2c2c2; color: #7f1d1d; }
.flash .ico { margin-top: 1px; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 16px; font-size: 13.5px; }
.notice { padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .v { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--ink-3); }

/* Log-Liste */
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.log li:last-child { border-bottom: 0; }
.log .t { color: var(--ink-3); font-variant-numeric: tabular-nums; }

@media (max-width: 880px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  nav.menu { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 8px; }
  nav.menu .group { display: none; }
  .userbox { border-top: 0; padding-top: 0; }
  main { padding: 20px 16px 40px; }
  .page-head { flex-direction: column; }
}

/* Mobile-Härtung: Inline-Spaltenraster der Formulare brechen auf schmalen Screens
   auf eine Spalte um (!important übersteuert bewusst die Inline-Styles). */
@media (max-width: 720px) {
  form .row, .row { grid-template-columns: 1fr !important; }
  .actions { flex-wrap: wrap; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; text-align: center; }
  table { font-size: 13px; }
  main { padding: 16px 12px 96px; }  /* Platz für die Hilfe-Blase */
  .card { padding: 16px 14px; }
  .tiles { grid-template-columns: 1fr !important; }
  input, select, textarea { font-size: 16px; }  /* verhindert iOS-Auto-Zoom beim Fokus */
}

/* Fortschrittsbalken (Indexierung) */
.pbar { width: 180px; max-width: 100%; height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; margin-top: 5px; margin-left: auto; }
.indet { animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .indet { animation: none; } }
