/* PMTPM — Schweizer institutionelles App-Design (achromatic-ledger / framed-sheet). */

:root {
  --ground: #f6f7f9;
  --surface: #ffffff;
  --raised: #f9fafb;
  --active: #eceef2;
  --border: #e4e7ec;
  --rule: #f0f2f5;
  --control: #cbd5e1;
  --text: #111827;
  --muted: #4b5563;
  --faint: #6b7280;
  --primary: #111827;
  --accent: #1b4965;
  --positive: #166534;
  --pill-positive-bg: #dcfce7;
  --pill-positive-ink: #14532d;
  --negative: #b91c1c;
  --pill-negative-bg: #fee2e2;
  --pill-negative-ink: #7f1d1d;
  --pill-neutral-bg: #f3f4f6;
  --pill-neutral-ink: #374151;
  --radius-card: 6px;
  --radius-control: 5px;
  --radius-chip: 4px;
  --gap: 16px;
  --pad: 24px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

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

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

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

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

/* Shell */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ground);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--faint);
}

.mandant-switcher {
  padding: 0 8px;
}

.mandant-switcher label {
  display: block;
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 4px;
}

.mandant-switcher select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--control);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 0 8px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

.nav-link:hover {
  background: var(--active);
  color: var(--text);
  text-decoration: none;
}

.nav-link.is-active {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

.nav-link.is-active .nav-dot {
  background: var(--accent);
}

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

.user-meta {
  font-size: 12px;
  color: var(--muted);
}

/* Main Sheet */
.canvas {
  background: var(--surface);
  margin: 8px 8px 8px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--pad);
  min-width: 0;
}

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

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

.page-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Buttons & Controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--raised); text-decoration: none; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover { background: #1f2937; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-accent:hover { opacity: 0.92; }

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 14px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 20px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

.filter-field label {
  font-size: 11px;
  color: var(--faint);
}

.filter-field select,
.filter-field input {
  height: 32px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 0 8px;
}

/* Divided KPI Strip (no icon tiles, tabular-nums) */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  margin-bottom: 20px;
  overflow: hidden;
}

.kpi-cell {
  padding: 16px 18px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-cell.is-lead {
  border-top: 2px solid var(--accent);
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.01em;
}

.kpi-cell.is-lead .kpi-value {
  font-size: 26px;
}

.kpi-meta {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.delta-pos { color: var(--positive); }
.delta-neg { color: var(--negative); }
.delta-neu { color: var(--faint); }

/* Status Pills (pale tint + dark text) */
.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-chip);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.pill-gruen, .pill-aktiv { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill-rot, .pill-abgelehnt { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill-na, .pill-ersetzt, .pill-leerstand {
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}

/* Panels & Grid */
.panel-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  margin-bottom: 20px;
}

.panel-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  margin-bottom: 20px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 18px 20px;
  margin-bottom: 20px;
  min-width: 0;
}

.panel-grid-2 .panel,
.panel-grid-3 .panel {
  margin-bottom: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.panel-note {
  font-size: 12px;
  color: var(--faint);
}

.chart-box {
  width: 100%;
  height: 250px;
}

/* Institutional Tables (rules + alignment, no zebra striping) */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table th.num { text-align: right; }

table.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

table.data-table tbody tr:hover {
  background: var(--raised);
}

/* Forms & Settings */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

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

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

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="file"],
.form-field select {
  height: 36px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  padding: 0 10px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}

.form-help {
  font-size: 12px;
  color: var(--faint);
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-error {
  background: var(--pill-negative-bg);
  border-color: #fecaca;
  color: var(--pill-negative-ink);
}

.alert-success {
  background: var(--pill-positive-bg);
  border-color: #bbf7d0;
  color: var(--pill-positive-ink);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  font-size: 13px;
}

/* Login Screen */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ground);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
}

.login-card h1 {
  margin: 12px 0 6px;
  font-size: 20px;
  font-weight: 600;
}

.login-card p.sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
}

.login-card .form-field { margin-bottom: 14px; }
.login-card .btn-primary { width: 100%; height: 38px; margin-top: 6px; }

/* Bewertungs-Tabs & DCF-Cockpit (2. DCF-Variante) */
.tab-bar {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  margin-bottom: 16px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.tab-btn:hover { background: var(--active); color: var(--text); text-decoration: none; }
.tab-btn.is-active {
  background: var(--accent);
  color: #ffffff;
}

.alert-ok {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-control);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.dcf-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.dcf-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 16px;
}

.dcf-meta-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
}

.dcf-meta-k { font-size: 11px; color: var(--faint); }
.dcf-meta-v { font-size: 13px; color: var(--text); }

table.dcf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.dcf-table th,
table.dcf-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  white-space: nowrap;
}

table.dcf-table thead th {
  background: var(--raised);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

table.dcf-table thead tr.dcf-grp-row th {
  background: var(--accent);
  color: #ffffff;
  text-align: center;
  font-size: 11px;
}

table.dcf-table thead tr.dcf-grp-row th.dcf-grp-ist { background: #475569; }
table.dcf-table thead tr.dcf-grp-row th.dcf-grp-exit { background: #0f766e; }

table.dcf-table .dcf-sticky {
  position: sticky;
  left: 0;
  background: var(--surface);
  text-align: left;
  min-width: 210px;
  z-index: 1;
}

table.dcf-table thead .dcf-sticky { background: var(--raised); z-index: 2; }
table.dcf-table thead tr.dcf-grp-row .dcf-sticky { background: var(--accent); text-align: left; }

table.dcf-table td.dcf-ist { background: #f8fafc; color: var(--muted); }
table.dcf-table tr.dcf-sum td { background: #edf2f7; font-weight: 600; }
table.dcf-table tr.dcf-sum-accent td {
  background: #e2e8f0;
  font-weight: 700;
  border-top: 1.5px solid var(--accent);
  border-bottom: 1.5px solid var(--accent);
}
table.dcf-table tr.dcf-ratio td { color: var(--faint); font-size: 11px; background: #fafbfc; }
table.dcf-table tr.dcf-barwert td { background: #f0f9ff; font-weight: 600; }

.dcf-cell-input {
  width: 88px;
  height: 24px;
  padding: 1px 5px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.dcf-cell-input:hover,
.dcf-cell-input:focus {
  border-color: var(--control);
  background: #ffffff;
  outline: none;
}

.dcf-cell-input.is-override {
  background: #fef3c7;
  border-color: #d97706;
  font-weight: 600;
}

.dcf-textarea {
  width: 100%;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  resize: vertical;
}

/* RBAC, Benutzerverwaltung & Passkeys */
.role-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--text);
  margin-left: 4px;
}

.passkey-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 14px 0;
  color: var(--faint);
  font-size: 12px;
}
.passkey-divider::before,
.passkey-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--rule);
}
.passkey-divider span { padding: 0 10px; }

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.admin-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.admin-details-body {
  margin-top: 8px;
  padding: 10px;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
  min-width: 310px;
}

/* Responsive Collapse */
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    gap: 12px;
  }
  .nav-list { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar-footer { flex-direction: row; justify-content: space-between; align-items: center; }
  .canvas { margin: 8px; padding: 16px; }
  .panel-grid-2, .panel-grid-3 { grid-template-columns: 1fr; }
}
