/* Partner Cockpit — Mischung Richtung A (Struktur) × Richtung B (Farben & Cleanness)
 * Design P: kein Beige, kein Elfenbein, kein Creme; Schrift >= 13px; Klickziele >= 44px; keine Emojis.
 */

:root {
  --bg-page: #FFFFFF;
  --bg-rail: #FAFAFC;
  --bg-subtle: #F4F4F6;
  --bg-hover: #EFEFF3;
  --bg-elevated: #FFFFFF;
  --line: #E8E8ED;
  --line-strong: #D4D4DC;
  --text: #111113;
  --text-2: #52525B;
  --text-3: #6B6B76;
  --cta-bg: #111113;
  --cta-hover: #27272A;
  --cta-fg: #FFFFFF;
  --accent: #B45309;        /* Einziger stiller Design-P-Akzent (exklusiv für offene Entscheidungen) */
  --accent-soft: #F1F2F6;
  --ok-fg: #1E7A35;
  --ok-bg: #ECFDF3;
  --warn-fg: #3F3F46;
  --warn-bg: #F1F2F6;       /* Kühles Apple-Neutralgrau statt Creme/Beige */
  --err-fg: #B80012;
  --err-bg: #FEF2F2;
  --neutral-fg: #52525B;
  --neutral-bg: #F4F4F6;
  --radius-btn: 10px;
  --radius-card: 14px;
  --radius-modal: 20px;
  --dur: 180ms;
  --ease: cubic-bezier(.25, .8, .25, 1);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

/* Optionaler 1-Klick-Dunkelmodus (inspiriert von Richtung C: Apple Pro Dark Studio) */
:root[data-theme="dark"] {
  --bg-page: #0B0B0D;
  --bg-rail: #111114;
  --bg-subtle: #18181C;
  --bg-hover: #222228;
  --bg-elevated: #151518;
  --line: #27272E;
  --line-strong: #3A3A44;
  --text: #F5F5F7;
  --text-2: #B4B4BE;
  --text-3: #8E8E98;
  --cta-bg: #F5F5F7;
  --cta-hover: #E4E4EA;
  --cta-fg: #0B0B0D;
  --accent: #F59E0B;
  --accent-soft: #232429;
  --ok-fg: #34D669;
  --ok-bg: #0F2A18;
  --warn-fg: #D4D4DC;
  --warn-bg: #232429;
  --err-fg: #FF6961;
  --err-bg: #2D1214;
  --neutral-fg: #B4B4BE;
  --neutral-bg: #1F1F24;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, select {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

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

/* Login */
.login-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg-rail);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-page);
  border: 1px solid var(--line);
  border-radius: var(--radius-modal);
  padding: 32px 28px;
}

.login-title {
  margin: 22px 0 6px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-2);
}

/* App-Grundraster (Richtung A Sidebar × Richtung B Reinweiß-Canvas) */
.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  padding: 24px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 4px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--cta-bg);
  color: var(--cta-fg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.brand-host {
  font-size: 13px;
  color: var(--text-3);
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.nav-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  padding: 0 10px 6px;
  letter-spacing: 0.01em;
}

.nav-btn, .company-btn {
  position: relative;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-btn:hover, .company-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Aktive Auswahl in Sidebar: ruhiges Tiefschwarz/Graphit (Bernstein bleibt exklusiv für offene Prüfungen) */
.nav-btn[aria-current="page"],
.company-btn[aria-pressed="true"] {
  background: var(--bg-page);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--text);
  border: 1px solid var(--line);
}

.nav-btn__inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-meta {
  font-size: 13px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.company-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Buttons (>= 44px Trefferfläche!) */
.btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.btn:active { transform: scale(.985); }

.btn--primary {
  background: var(--cta-bg);
  color: var(--cta-fg);
}
.btn--primary:hover { background: var(--cta-hover); }

.btn--outline {
  background: var(--bg-page);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn--outline:hover { background: var(--bg-subtle); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
}
.btn--ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn--danger {
  background: var(--err-bg);
  color: var(--err-fg);
  border-color: transparent;
}

.btn--sm { padding: 0 13px; font-size: 13px; }
.btn--full { width: 100%; }
.btn--icon { width: 44px; padding: 0; }

/* Haupt-Arbeitsbereich */
.workspace {
  padding: 32px 44px 56px;
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
}

.mobile-bar { display: none; }
.mobile-tabs { display: none; }

.eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
  text-transform: uppercase;
}

/* Hero-Summenzeile (Richtung B Editorial-Ruhe, jede Zahl 1x!) */
.hero-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.hero-figure {
  margin: 6px 0 6px;
  font-size: clamp(34px, 4vw, 44px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.hero-caption {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.preview-box, .sub-line, .decision-title, .batch-card {
  font-variant-numeric: tabular-nums;
}

.action-inline {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  min-height: 44px;
  padding: 6px 0;
}

.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
}

.hero-strip__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Abschnitte (haarliniengetrennt statt schwerer Kisten!) */
.section-block {
  padding-top: 30px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.section-hint {
  font-size: 13px;
  color: var(--text-3);
}

/* Responsive Tabellen nach modern-web-guidance (responsive-table) */
.table-wrapper {
  overflow-x: auto;
  max-inline-size: 100%;
  container-type: inline-size;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.clean-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.clean-table thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  background: var(--bg-page);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  padding: 12px 14px 12px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.clean-table tbody th,
.clean-table tbody td {
  padding: 15px 14px 15px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: left;
}

.clean-table tbody tr:last-child th,
.clean-table tbody tr:last-child td {
  border-bottom: 0;
}

.clean-table tbody th {
  font-weight: 600;
  color: var(--text);
}

.clean-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.clean-table .col-action {
  text-align: right;
  padding-right: 0;
}

.clean-table tbody td:last-child { padding-right: 0; }

.sub-line {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  margin-top: 2px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 13px;
}

.amount-strong {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.amount-neg {
  font-weight: 700;
  color: var(--err-fg);
}

/* Status-Pillen (Icon + Text, nie nur Farbe) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.pill--ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill--warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill--err { background: var(--err-bg); color: var(--err-fg); }
.pill--neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Offene Entscheidungen */
.decision-list {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.decision-row {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.decision-row:last-child { border-bottom: 0; }

.decision-row__main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.decision-dot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--accent);
  flex-shrink: 0;
}

.decision-title {
  font-weight: 600;
  font-size: 15px;
}

.empty-state {
  padding: 20px 0;
  font-size: 14px;
  color: var(--text-3);
}

/* Auszahlungs-Batches */
.batch-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.batch-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  background: var(--bg-page);
}

.batch-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.batch-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 14px;
}

/* Container-Query für mobile Tabellen-Karten (modern-web-guidance) */
@container (width < 640px) {
  .stack-table, .stack-table thead, .stack-table tbody, .stack-table tr, .stack-table th, .stack-table td {
    display: block;
  }
  .stack-table thead { display: none; }
  .stack-table tbody tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }
  .stack-table tbody tr:last-child { border-bottom: 0; }
  .stack-table tbody th {
    padding: 0 0 8px;
    border: 0;
    font-size: 15px;
  }
  .stack-table tbody td {
    padding: 5px 0;
    border: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    column-gap: 12px;
    text-align: right;
  }
  .stack-table tbody td::before {
    content: attr(data-label);
    font-size: 13px;
    color: var(--text-3);
    font-weight: 500;
    text-align: left;
  }
  .stack-table tbody td .sub-line {
    flex-basis: 100%;
    text-align: right;
  }
}

/* Natives <dialog> (modern-web-guidance: overscroll-behavior auf :modal & ::backdrop, kein display auf ungescopetem dialog!) */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-modal);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0;
  max-width: 520px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .18);
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(17, 17, 19, .38);
  overflow: hidden;
  overscroll-behavior: contain;
}

.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-note {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.field input, .field select {
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--line-strong);
  background: var(--bg-page);
  color: var(--text);
}

.preview-box {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-size: 14px;
  color: var(--text-2);
}

.form-error {
  margin: 0;
  min-height: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--err-fg);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--cta-bg);
  color: var(--cta-fg);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}

/* Bewegung nach apple-animationen: bei reduce bleibt sanftes Überblenden (nie abschalten!) */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 320ms var(--ease), transform 320ms var(--ease);
}

.reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    transform: none;
    transition: opacity 320ms ease;
  }
}

.motion-paused .reveal,
.motion-paused * {
  transition: none !important;
  animation: none !important;
}

/* Mobil-Layout (iOS Quiet Utility + Editorial Cleanliness, 0px Überlauf ab 375px!) */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }

  .workspace {
    padding: 16px 16px calc(88px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
  }

  .mobile-bar__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-bar__tools {
    display: flex;
    gap: 6px;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--bg-subtle);
  }

  .seg-btn {
    min-height: 44px;
    padding: 0 4px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .seg-btn[aria-pressed="true"] {
    background: var(--bg-page);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  }

  .hero-strip__actions {
    width: 100%;
  }
  .hero-strip__actions .btn {
    flex: 1 1 auto;
  }

  .decision-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .mobile-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--bg-page);
    border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }

  .tab-btn {
    min-height: 52px;
    border: 0;
    background: transparent;
    color: var(--text-3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
  }

  .tab-btn[aria-current="page"] {
    color: var(--text);
    font-weight: 700;
  }

  .toast {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  }
}
