/* Gemeinsames Design aller Seiten (Cross-Sales-dunkel). Farben aus dem Logo: Tiefschwarz + warmes Cremeweiß.
   Grundsätze: Schrift mind. 16 px, gute Kontraste, Bedienelemente mind. 44 px hoch (Daumen), einheitliche Abstände. */
:root {
  color-scheme: dark;
  --bg: #0b0c0e;
  --panel: #15171a;
  --panel-2: #1c1f23;
  --panel-3: #262a30;
  --text: #f4f2ed;
  --muted: #b0b6bf;          /* heller als zuvor: Kontrast auf --panel ca. 8:1 */
  --border: #30353c;
  --border-strong: #454b54;
  --accent: #f2f0eb;
  --accent-ink: #0b0c0e;
  --focus: #f0dfae;
  --green: #2f9e5b;
  --green-soft: rgba(47, 158, 91, 0.16);
  --red: #e5534b;
  --red-soft: rgba(229, 83, 75, 0.16);
  --orange: #d9822b;
  --orange-soft: rgba(217, 130, 43, 0.18);
  --purple: #b9a2ff;
  --purple-soft: rgba(167, 139, 250, 0.18);
  --live: #3d1414;
  --live-text: #ff9a94;
  --radius: 10px;
  --radius-lg: 14px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --shell-h: 58px;
  --tabs-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 1rem; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.has-shell { padding-bottom: env(safe-area-inset-bottom); }
h1 { font-size: 1.6rem; margin: 0 0 var(--space-2); font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 0 0 var(--space-3); font-weight: 650; line-height: 1.3; }
h3 { font-size: 0.9rem; margin: var(--space-5) 0 var(--space-2); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 650; color: var(--muted); }
p { margin: 0 0 var(--space-3); }
a { color: var(--focus); }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
[hidden] { display: none !important; }
::selection { background: rgba(242, 240, 235, 0.25); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Rahmen & Navigation ---------- */
#shell { display: contents; } /* damit die Kopfzeile beim Scrollen oben „klebt“ (sticky braucht die ganze Seite als Umgebung) */
.shell-top {
  position: sticky; top: 0; z-index: 30; height: var(--shell-h);
  display: flex; align-items: center; gap: var(--space-4); padding: 0 var(--space-4);
  background: #0e0f12; border-bottom: 1px solid var(--border);
}
.shell-brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--text); white-space: nowrap; }
.shell-logo { height: 34px; width: auto; display: block; }
.shell-title { display: flex; flex-direction: column; line-height: 1.15; border-left: 1px solid var(--border-strong); padding-left: var(--space-3); }
.shell-company { font-size: 0.8rem; letter-spacing: 4px; font-weight: 500; }
.shell-app { font-size: 0.85rem; color: var(--muted); }
.nav-desktop { display: flex; gap: var(--space-1); margin-left: var(--space-4); flex: 1; }
.nav-link {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4); min-height: 44px;
  color: var(--muted); text-decoration: none; border-radius: var(--radius); font-weight: 600;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.active { color: var(--accent-ink); background: var(--accent); }
.shell-user { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.shell-name { font-size: 0.95rem; display: inline-flex; align-items: center; gap: var(--space-2); }
.role-badge { font-size: 0.7rem; letter-spacing: 1px; text-transform: uppercase; background: var(--panel-3); border: 1px solid var(--border-strong); padding: 1px 8px; border-radius: 999px; color: var(--muted); }
.nav-tabs { display: none; }

@media (max-width: 860px) {
  .shell-title, .shell-name { display: none; }
  .nav-desktop { display: none; }
  .shell-user { margin-left: auto; }
  body.has-shell { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
  .nav-tabs {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: #0e0f12; border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-tabs .nav-link { flex-direction: column; justify-content: center; gap: 2px; min-height: var(--tabs-h); padding: 6px 2px; border-radius: 0; font-size: 0.72rem; text-align: center; }
  .nav-tabs .nav-icon { font-size: 1.35rem; line-height: 1; }
  .nav-tabs .nav-link.active { background: var(--panel-3); color: var(--text); box-shadow: inset 0 3px 0 var(--accent); }
}

/* ---------- Seitenfläche ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.page-head h1 { margin: 0; }
.panel, .card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) 18px; margin-bottom: var(--space-4); }
.panel > :last-child, .card > :last-child { margin-bottom: 0; }
.panel .board-block { background: var(--panel-2); border-color: var(--border-strong); }

/* ---------- Knöpfe ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 10px 16px; min-height: 44px; background: var(--panel-2); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  transition: background 0.12s, border-color 0.12s, filter 0.12s;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #5a616b; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover:not(:disabled) { background: var(--accent); filter: brightness(0.92); }
.btn-ghost { background: transparent; }
.btn-small { padding: 6px 12px; min-height: 36px; font-size: 0.9rem; }
.btn-danger { background: var(--red); color: #fff; border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--red); filter: brightness(1.1); }
.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); }

/* ---------- Formulare ---------- */
.field { margin-bottom: var(--space-3); }
label, .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; color: var(--muted); }
.label { text-transform: uppercase; letter-spacing: 1.2px; font-size: 0.8rem; }
textarea, input[type=text], input[type=password], input[type=email], input[type=tel], input[type=search], input[type=number],
input[type=date], input[type=datetime-local], select {
  font: inherit; font-size: 1rem; width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
}
textarea { resize: vertical; line-height: 1.45; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(240, 223, 174, 0.2); }
::placeholder { color: #7b828c; }
input[type=file] { font: inherit; width: 100%; color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 20px; height: 20px; flex: none; }
.chk { display: flex; gap: var(--space-3); align-items: center; min-height: 40px; color: var(--text); font-weight: 400; font-size: 1rem; cursor: pointer; margin: 0; }
.row { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 200px; }
.msg { margin-top: var(--space-3); min-height: 1.5em; overflow-wrap: anywhere; }
.msg.ok { color: #6fd79a; }
.msg.err { color: #ff8f88; }
code { word-break: break-all; background: var(--bg); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- Marken und Etiketten ---------- */
.badge { font-size: 0.7rem; padding: 1px 8px; border-radius: 999px; margin-left: 4px; vertical-align: 1px; font-weight: 700; letter-spacing: 1px; }
.badge.live { background: var(--red); color: #fff; }
.tag { font-size: 0.78rem; padding: 2px 8px; border-radius: 6px; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.tag.overdue { background: var(--red-soft); color: #ff9d97; }
.tag.due { background: var(--orange-soft); color: #f0a65d; }
.tag.nophone { background: var(--red-soft); color: #ff9d97; font-weight: 700; }
.tag.choice { background: var(--purple-soft); color: var(--purple); }

/* ---------- Kennzahlen ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); }
.tile { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.tile .v { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--text); font-size: 0.95rem; margin-top: 2px; }
.tile .e { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.tile.rate .v { color: var(--focus); }
.scope-note { color: var(--muted); font-size: 0.9rem; margin: calc(-1 * var(--space-2)) 0 var(--space-3); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 0.95rem; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.8px; white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Hinweise ---------- */
.notice { border: 1px solid var(--border-strong); border-left: 4px solid var(--orange); background: var(--orange-soft); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.notice.err { border-left-color: var(--red); background: var(--red-soft); }
.notice.ok { border-left-color: var(--green); background: var(--green-soft); }
details > summary { cursor: pointer; color: var(--focus); min-height: 44px; display: flex; align-items: center; gap: 6px; }

/* ---------- Anmeldung ---------- */
.auth { max-width: 460px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.auth-logo { display: block; width: min(260px, 70%); height: auto; margin: var(--space-5) auto var(--space-5); }

/* ---------- Hilfsklassen (kein Inline-Stil wegen Content-Security-Policy) ---------- */
.flush { margin: 0 !important; }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.m-4 { margin: var(--space-4); }
