/* ARK Leitstand — CI-Umsetzung nach ARK Corporate Identity Handbuch V1.0
   Dark-Mode primär, Sora (Display) + Inter (Body), minimalistisch, präzise. */

:root {
  --midnight: #0A1128;      /* Deep Midnight Blue — Grundfläche */
  --navy: #0B1F3B;          /* ARK Navy — Karten/Flächen */
  --infra: #1F4E79;         /* Infrastructure Blue — Linien, Sekundär */
  --line: rgba(31, 78, 121, 0.45);
  --text: #FFFFFF;
  --silver: #CED6E0;        /* Ice Silver — Sekundärtext hell */
  --steel: #7B8A97;         /* Steel Grey — Muted */
  --data: #2D7FF9;          /* Data Blue — Akzente, Links */
  --teal: #127376;          /* Operational Teal — Erfolg, sparsam */
  --teal-bright: #1FA3A7;   /* Teal-Variante für Text auf dunklem Grund */
  --signal: #C25B5B;        /* Funktionsfarbe Eskalation (außerhalb CI-Palette, nur Badges) */
  --font-display: 'Sora', Arial, sans-serif;
  --font-body: 'Inter', Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

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

.hidden { display: none !important; }

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

:focus-visible { outline: 2px solid var(--data); outline-offset: 2px; }

/* ── Login ─────────────────────────────────────────────────────────── */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--midnight);
  z-index: 100;
}
.login-card { width: 340px; text-align: center; }
.login-logo { width: 180px; margin-bottom: 8px; }
.login-sub {
  color: var(--steel);
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 40px;
}
.login-card form { text-align: left; }
.login-card input {
  width: 100%;
  background: var(--navy);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  margin: 6px 0 16px;
}
.login-card input:focus { border-color: var(--data); outline: none; }
.login-error { color: var(--signal); font-size: 13px; margin: -8px 0 12px; }

/* ── Grundgerüst ───────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 44px; }
.brand-icon { width: 34px; height: 34px; }
.brand-name {
  display: block; font-family: var(--font-display); font-weight: 700;
  font-size: 17px; letter-spacing: 0.06em;
}
.brand-sub {
  display: block; color: var(--steel);
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  color: var(--silver);
  padding: 9px 12px;
  border-radius: 4px;
  border-left: 2px solid transparent;
  font-weight: 500;
}
.nav-item:hover { color: var(--text); text-decoration: none; background: rgba(31,78,121,0.18); }
.nav-item.active {
  color: var(--text);
  border-left-color: var(--data);
  background: rgba(45,127,249,0.08);
}

.sidebar-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--steel);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal-bright);
}
.live-dot.on { animation: pulse 2.4s ease-in-out infinite; }
.live-dot.off { background: var(--steel); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.linklike {
  background: none; border: none; color: var(--steel);
  font: inherit; font-size: 12px; cursor: pointer; margin-left: auto;
}
.linklike:hover { color: var(--silver); }

.main { flex: 1; min-width: 0; }
.view { padding: 36px 44px 64px; max-width: 1200px; }

/* ── Typografie & Bausteine ────────────────────────────────────────── */
h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 22px; letter-spacing: 0.01em; margin-bottom: 4px;
}
.page-sub { color: var(--steel); font-size: 13px; margin-bottom: 32px; }

.label, th {
  font-family: var(--font-body); font-weight: 600;
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--steel);
}

.btn {
  font: inherit; font-weight: 500;
  border-radius: 4px; padding: 9px 18px;
  border: 1px solid var(--line);
  background: transparent; color: var(--silver);
  cursor: pointer;
}
.btn:hover { border-color: var(--infra); color: var(--text); }
.btn-primary { background: var(--data); border-color: var(--data); color: #fff; width: 100%; }
.btn-primary:hover { background: #4a92fa; color: #fff; }
.btn-teal { border-color: var(--teal); color: var(--teal-bright); }
.btn-danger { border-color: rgba(194,91,91,0.5); color: var(--signal); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }

/* ── KPI-Zeile (Hairline-Stil, keine Kacheln) ──────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
}
.kpi { padding: 20px 20px 18px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: none; }
.kpi-value {
  font-family: var(--font-display); font-weight: 700;
  font-size: 30px; font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-value .unit { font-size: 15px; color: var(--steel); font-weight: 600; }
.kpi-label { margin-top: 6px; }
.kpi.accent .kpi-value { color: var(--teal-bright); }
.kpi.alert .kpi-value { color: var(--signal); }

/* ── Pipeline-Band (Signatur-Element) ──────────────────────────────── */
.pipeline { margin-bottom: 40px; }
.pipeline-track { display: flex; gap: 3px; }
.pipeline-seg { flex: 1; }
.pipeline-bar { height: 4px; background: var(--infra); opacity: 0.35; }
.pipeline-seg.filled .pipeline-bar { opacity: 1; background: var(--data); }
.pipeline-seg.done .pipeline-bar { opacity: 1; background: var(--teal); }
.pipeline-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--steel); }
.pipeline-meta strong { color: var(--silver); font-variant-numeric: tabular-nums; }

/* ── Tabellen ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(31,78,121,0.22);
  color: var(--silver);
  vertical-align: top;
}
td.num { font-variant-numeric: tabular-nums; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: rgba(31,78,121,0.14); color: var(--text); }
.cell-strong { color: var(--text); font-weight: 500; }
.cell-muted { color: var(--steel); font-size: 12.5px; }
.empty { color: var(--steel); padding: 40px 0; text-align: center; }

/* ── Status-Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 3px;
  border: 1px solid var(--line); color: var(--silver);
  white-space: nowrap;
}
.badge.confirmed { border-color: var(--teal); color: var(--teal-bright); }
.badge.notifying { border-color: var(--data); color: var(--data); }
.badge.escalated { border-color: var(--signal); color: var(--signal); }
.badge.in-progress { border-color: var(--data); color: var(--data); animation: pulse 2.4s ease-in-out infinite; }
.badge.cancelled, .badge.failed, .badge.no-answer, .badge.busy { color: var(--steel); }
.badge.transferred { border-color: var(--teal); color: var(--teal-bright); }

/* ── Toolbar / Filter ──────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.chip {
  font: inherit; font-size: 12.5px;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  color: var(--steel); padding: 5px 14px; cursor: pointer;
}
.chip:hover { color: var(--silver); }
.chip.active { border-color: var(--data); color: var(--data); }

/* ── Drawer ────────────────────────────────────────────────────────── */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(4,8,22,0.6); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--navy);
  border-left: 1px solid var(--line);
  z-index: 50;
  display: flex; flex-direction: column;
  transform: translateX(0);
  animation: slidein 0.18s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0.6; } to { transform: translateX(0); opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px; border-bottom: 1px solid var(--line);
}
.drawer-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.drawer-close {
  background: none; border: none; color: var(--steel);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.drawer-close:hover { color: var(--text); }
.drawer-body { padding: 24px 26px 48px; overflow-y: auto; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; margin-bottom: 26px; }
.kv dt { color: var(--steel); font-size: 12.5px; padding-top: 1px; }
.kv dd { color: var(--silver); }
.kv dd.strong { color: var(--text); font-weight: 500; }

.section-title { margin: 26px 0 12px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Bestätigungs-Zitat */
.quote {
  border-left: 2px solid var(--teal);
  background: rgba(18,115,118,0.08);
  padding: 12px 16px; margin: 10px 0 4px;
  color: var(--silver); font-style: italic;
}
.quote-meta { color: var(--steel); font-size: 12px; margin-top: 6px; font-style: normal; }

/* Historie */
.timeline { list-style: none; }
.timeline li {
  display: grid; grid-template-columns: 118px 1fr; gap: 14px;
  padding: 7px 0; border-bottom: 1px solid rgba(31,78,121,0.18);
  font-size: 12.5px;
}
.timeline time { color: var(--steel); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Transkript im Ledger-Stil (kein Chat-Bubble-Look) */
.transcript { border-top: 1px solid var(--line); }
.t-row {
  display: grid; grid-template-columns: 84px 1fr; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid rgba(31,78,121,0.18);
}
.t-speaker { font-size: 10.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; padding-top: 3px; }
.t-speaker.user { color: var(--silver); }
.t-speaker.assistant { color: var(--data); }
.t-speaker.system { color: var(--steel); }
.t-text { color: var(--silver); }
.t-row.system .t-text { color: var(--steel); font-size: 12.5px; }

/* ── Formulare (Partner) ───────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin: 14px 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; background: var(--midnight);
  border: 1px solid var(--line); border-radius: 4px;
  color: var(--text); font: inherit; padding: 8px 11px;
}
.field input:focus { border-color: var(--data); outline: none; }

.card {
  background: var(--navy); border: 1px solid var(--line);
  border-radius: 6px; padding: 22px 24px; margin-bottom: 28px;
}

/* ── Statistik-Charts ──────────────────────────────────────────────── */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 22px; margin-top: 10px; }
.chart-card { background: var(--navy); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px 14px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.chart-title .label { color: var(--silver); }
.chart-title .chart-sum { font-family: var(--font-display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .bar { fill: var(--data); rx: 2; }
.chart-svg .bar:hover { fill: #5b9bfa; }
.chart-svg .gridline { stroke: rgba(31,78,121,0.28); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--steel); font-size: 9px; font-family: var(--font-body); }
.chart-svg .value-label { fill: var(--silver); font-size: 9.5px; font-family: var(--font-body); font-weight: 600; }

/* Horizontale Balkenliste (Standorte, Partner-Quote) */
.hbar-row { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; padding: 5px 0; }
.hbar-label { color: var(--silver); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; }
.hbar-fill { height: 10px; background: var(--data); border-radius: 2px; min-width: 2px; }
.hbar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-size: 12.5px; }

/* Status-Verteilungsband: 2px Lücken, immer mit Text-Label */
.statusband { display: flex; gap: 2px; height: 14px; border-radius: 3px; overflow: hidden; margin: 6px 0 10px; }
.statusband > div { min-width: 3px; }
.statusband-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--silver); }
.statusband-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }

.st-captured { background: #CED6E0; }
.st-notifying { background: var(--data); }
.st-confirmed { background: var(--teal-bright); }
.st-escalated { background: var(--signal); }
.st-cancelled { background: var(--steel); }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center;
    padding: 14px 18px; border-right: none; border-bottom: 1px solid var(--line);
    gap: 16px;
  }
  .sidebar-brand { margin-bottom: 0; }
  .brand-sub { display: none; }
  .nav { flex-direction: row; gap: 4px; overflow-x: auto; }
  .nav-item { border-left: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 7px 10px; white-space: nowrap; }
  .nav-item.active { border-bottom-color: var(--data); background: none; }
  .sidebar-foot { margin-top: 0; margin-left: auto; }
  .live-label, .linklike { display: none; }
  .view { padding: 22px 16px 48px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 10px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot.on, .badge.in-progress { animation: none; }
  .drawer { animation: none; }
}

/* Testmodus-Banner (Einstellungen → Testmodus) */
.test-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 24px;
  background: #B45309;
  color: #fff;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}
