/* ===== Filter bar ===== */
  .filterbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    box-shadow: var(--shadow-sm);
  }
  .field { display: flex; flex-direction: column; gap: 4px; }
  .field label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
  .field select, .field input {
    padding: 8px 10px; border: 1px solid var(--border-strong);
    border-radius: 6px; font-size: 13px; background: var(--surface); color: var(--text);
  }
  .toggle-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
  .toggle-group button { padding: 7px 12px; background: var(--surface); border: none; color: var(--text-muted); font-size: 12px; font-weight: 500; }
  .toggle-group button.active { background: var(--brand); color: #fff; }
  .switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
  .switch input { accent-color: var(--brand); }

  /* ===== KI Plausibility Card ===== */
  .ki-card {
    background: linear-gradient(135deg, #fef3c7 0%, #fef9e7 100%);
    border: 1px solid #f59e0b40;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex; gap: 14px; align-items: flex-start;
    box-shadow: var(--shadow-sm);
  }
  .ki-icon { width: 36px; height: 36px; border-radius: 8px; background: #fbbf24; color: #fff; display: grid; place-items: center; flex-shrink: 0; }
  .ki-body { flex: 1; }
  .ki-title { font-weight: 600; margin-bottom: 4px; }
  .ki-sub { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
  .ki-findings { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
  .ki-finding { font-size: 12px; color: #92400e; display: flex; align-items: flex-start; gap: 6px; }
  .ki-finding .dot { width: 4px; height: 4px; border-radius: 50%; background: #d97706; margin-top: 7px; flex-shrink: 0; }

  /* ===== Legend ===== */
  .legend {
    display: flex; gap: 18px; flex-wrap: wrap;
    padding: 10px 14px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 14px; font-size: 12px; color: var(--text-muted);
    box-shadow: var(--shadow-sm);
  }
  .legend-item { display: flex; align-items: center; gap: 6px; }
  .legend-dot { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.06); }

  /* ===== Grid ===== */
  .grid-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;                              /* sub-scroll im Grid (horizontal + vertikal) */
    /* min/max-height fix → grid behält bei Kollaps konstante Höhe, content bleibt
       ausreichend scrollbar damit Hysteresis greift, kein scroll-reset, kein Flicker. */
    min-height: 70vh;
    max-height: 75vh;
    box-shadow: var(--shadow-sm);
  }
  table.grid {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
  }
  table.grid th, table.grid td {
    padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  table.grid thead th {
    background: var(--bg);
    font-weight: 600; color: var(--text-muted); font-size: 11px;
    position: sticky; top: 0; z-index: 2;
    border-bottom: 1px solid var(--border-strong);
  }
  table.grid th.day-weekend { color: #cbd5e1; }
  table.grid th.day-workday { color: var(--brand-dark); }
  table.grid .row-label {
    text-align: left; font-weight: 500; padding-left: 12px;
    width: var(--col-label-w, 240px); min-width: 120px; max-width: 600px;
    position: sticky; left: 0; background: var(--surface); z-index: 1;
    /* sticky ist gleichzeitig containing block für absolute Children (col-resize) */
  }
  /* Resize-Slider — absolut positioniert relativ zum sticky-th */
  table.grid th.row-label .col-resize,
  table.grid td.row-label .col-resize {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 8px; cursor: col-resize;
    background: transparent; transition: background 0.12s;
    user-select: none; z-index: 4;
  }
  table.grid th.row-label .col-resize:hover,
  .col-resize.active { background: var(--brand); opacity: 0.5; }
  /* Ecke oben-links: sticky-top + sticky-left → höchster z-index */
  table.grid thead .row-label { background: var(--bg); z-index: 3; }
  /* KTR-Header-Zeile bleibt beim vertikalen Scrollen sichtbar so weit möglich */
  table.grid tr.ktr-header td { position: sticky; left: 0; }
  table.grid .row-label.muted { color: var(--text-muted); font-weight: 400; }
  /* Summenspalte (Total) + LA-Nummer rechts — beide sticky-right damit sie beim
     horizontalen Scrollen sichtbar bleiben. */
  table.grid .row-total {
    text-align: right; font-weight: 600; padding-right: 12px;
    width: 80px; min-width: 80px; background: var(--bg);
    position: sticky; right: 56px; z-index: 1;
    border-left: 1px solid var(--border);
  }
  table.grid .row-la {
    font-size: 11px; color: var(--text-muted); padding-right: 10px; text-align: right;
    width: 56px; min-width: 56px; background: var(--surface);
    position: sticky; right: 0; z-index: 1;
  }
  table.grid thead .row-total,
  table.grid thead .row-la { background: var(--bg); z-index: 3; }
  table.grid tr.ist-total .row-total,
  table.grid tr.ist-total .row-la { background: #f0fdf4; color: #15803d; }
  table.grid tr.ktr-header td {
    background: var(--brand-soft); color: var(--brand-dark);
    font-weight: 700; padding: 0; text-align: left;
    border-top: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--brand);
  }
  /* KTR-Header-Text bleibt beim horizontalen Scroll sichtbar */
  .ktr-sticky {
    position: sticky; left: 12px;
    display: inline-block;
    padding: 8px 0;
    white-space: nowrap;
  }
  /* Ist-Total-Zeile im sticky Header */
  table.grid tr.ist-total th { background: #f0fdf4; color: #15803d; font-weight: 700; top: 28px; z-index: 2; }
  table.grid tr.ist-total .row-label { background: #f0fdf4; color: #15803d; left: 0; z-index: 4; }
  /* Tag-Header-Reihe oben */
  table.grid tr.head-days th { top: 0; }
  table.grid tr:hover td:not(.row-label):not(.row-total):not(.row-la) { filter: brightness(0.97); }

  .cell {
    cursor: pointer; min-width: 28px; transition: filter 0.1s;
    border-radius: 0;
  }
  .cell.empty { color: transparent; }
  .cell.visiert { background: var(--status-visiert); color: #14532d; }
  .cell.nicht-visiert { background: var(--status-nicht-visiert); color: #7f1d1d; }
  .cell.verarbeitet { background: var(--status-verarbeitet); color: #1e293b; }
  .cell.ohne-la { background: var(--status-ohne-la); color: #78350f; }
  .cell.fehler { background: var(--status-fehler); color: #7f1d1d; font-weight: 700; }
  .cell.has-warning::after { content: ""; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: #f59e0b; margin-left: 2px; vertical-align: middle; }

  /* ===== Drill-down modal ===== */
  .modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px);
    display: none; align-items: center; justify-content: center; z-index: 50;
  }
  .modal-backdrop.open { display: flex; }
  .modal {
    background: var(--surface); border-radius: 12px; width: 780px; max-width: 96vw;
    max-height: 88vh; overflow: auto; box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
  }
  .modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
  .modal-header h3 { margin: 0; font-size: 15px; }
  .modal-body { padding: 0; }
  .modal-meta { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }

  /* ===== Rapport read-only view ===== */
  .rapport-statusbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex; align-items: center; gap: 12px;
    font-size: 12px; color: var(--text-muted);
  }
  .rapport-statusbar .edit-link { margin-left: auto; }

  .rapport-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
  .rapport-section:last-child { border-bottom: none; }
  .rapport-section h4 {
    margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-dim); font-weight: 600;
  }
  .info-row { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: baseline; font-size: 13px; }
  .info-row .label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; min-width: 60px; }
  .info-row .value { color: var(--text); font-weight: 500; }
  .info-row .value.strong { font-weight: 700; color: var(--brand-dark); }

  .time-row { display: grid; grid-template-columns: auto 60px auto 60px auto 70px auto 80px; gap: 12px; align-items: baseline; font-size: 13px; }
  .time-row .label { color: var(--text-muted); font-size: 11px; }
  .time-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }

  .reise-flow {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; background: var(--bg); border-radius: 8px; margin-bottom: 10px;
    flex-wrap: wrap;
  }
  .reise-flow .stop {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: 6px;
    font-size: 12px; font-weight: 500;
  }
  .reise-flow .stop .icon { width: 14px; height: 14px; color: var(--brand); }
  .reise-flow .arrow { color: var(--text-dim); font-size: 18px; }

  .checks { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; }
  .checks .check {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; background: var(--brand-soft); color: var(--brand-dark);
    border-radius: 6px; font-size: 12px; font-weight: 500;
  }
  .checks .check.off {
    background: var(--bg); color: var(--text-dim); font-weight: 400;
    border: 1px dashed var(--border-strong);
  }
  .checks .check .icon { width: 14px; height: 14px; }

  .bemerkung {
    padding: 10px 12px; background: var(--bg); border-left: 3px solid var(--brand);
    border-radius: 0 6px 6px 0; font-size: 13px; color: var(--text); line-height: 1.5;
    font-style: italic;
  }

  .meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; font-size: 12px; }
  .meta-grid .label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 6px; }
  .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--text-muted); }
