/* ==========================================================================
   Tabelle nach dem Clay-Prinzip (static/js/grid.js): Signale, Firmen, Arbeitsliste.
   Zeile = Firma, Spalte = Merkmal; feste linke Spalten (Marker, Firma), dünne Gitterlinien, eine Kopfzeile, die stehen bleibt.
   Spalten weichen bei Platzmangel nach Rang; unter 600 px wird jede Zeile zur Karte (.gt-grid.is-stack).
   ========================================================================== */
.gt-wrap { position: relative; flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--line); overscroll-behavior: contain; }
.gt-wrap.is-busy .gt-grid { opacity: .55; transition: opacity var(--dur-2) var(--ease-out); }
.gt-grid { min-width: var(--grid-min, 0); }
.gt-row {
  display: grid;
  grid-template-columns: var(--cols);
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  outline: 0;
}
.gt-row > [role="gridcell"], .gt-row > [role="columnheader"] {
  display: flex; align-items: center; min-width: 0;
  padding: 0 14px;
  border-right: 1px solid var(--line);
  background: inherit;
}
.gt-row > :last-child { border-right: 0; }
.gt-row > .gt-c-lead { justify-content: center; padding: 0 0 0 4px; border-right: 0; }
.gt-num { justify-content: flex-end; text-align: right; }

/* Kopfzeile der Tabelle */
.gt-row.is-head {
  position: sticky; top: 0; z-index: 3;
  min-height: 36px;
  color: var(--text-3); font-size: 12px; font-weight: var(--w-medium);
}
.gt-row.is-head > [role="columnheader"] { gap: 7px; }
.gt-row.is-head svg { width: 14px; height: 14px; color: var(--text-3); }
.gt-th {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; margin: 0 -6px; padding: 0 6px;
  border: 0; border-radius: var(--r-xs); background: transparent; color: inherit; font: inherit;
}
.gt-th:hover { background: var(--surface-2); color: var(--text); }
.gt-th .arr { opacity: 0; }
.gt-th:hover .arr { opacity: .6; }
[aria-sort] .gt-th, [aria-sort] .gt-th svg { color: var(--text); }
[aria-sort] .gt-th .arr { opacity: 1; }
.gt-c-add { justify-content: center; padding: 0 !important; }

/* Feste linke Spalten (Marker + Firma) beim waagerechten Scrollen */
.gt-c-lead, .gt-c-firma { position: sticky; z-index: 1; }
.gt-c-lead { left: 0; }
.gt-c-firma { left: 44px; }
.gt-row.is-head .gt-c-lead, .gt-row.is-head .gt-c-firma { z-index: 4; }
.gt-wrap.is-scrolled-x .gt-c-firma { box-shadow: 8px 0 12px -10px rgb(17 17 16 / .18); }

/* Zustände */
.gt-row:not(.is-head):not(.is-skel) { cursor: default; scroll-margin-top: 36px; transition: background-color var(--dur-1) var(--ease-out); }
.gt-row:not(.is-head):not(.is-skel):hover { background: var(--ld-n-50); }
.gt-row.is-sel { background: var(--surface-2); }
.gt-row.is-cursor, .gt-row.is-open { background: var(--surface-sunken); }
.gt-row.is-cursor > .gt-c-lead, .gt-row.is-open > .gt-c-lead { box-shadow: inset 2px 0 0 var(--text); }
.gt-row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.gt-row.is-dim .gt-two b, .gt-row.is-dim .gt-sig .t { color: var(--text-2); }
.gt-row.is-dim .av { opacity: .55; }
[data-theme="dark"] .gt-row:not(.is-head):not(.is-skel):hover { background: #1E1E1C; }
[data-theme="dark"] .gt-row.is-cursor, [data-theme="dark"] .gt-row.is-open { background: var(--surface-2); }
[data-theme="dark"] .gt-row.is-sel { background: #2A2A27; }

/* Markerspalte: Marker, bei Hover/Auswahl das Kontrollkästchen */
.gt-lead { position: relative; display: grid; place-items: center; width: 28px; height: 28px; }
.gt-lead .mark { --mark-size: 12px; border-width: 1.5px; }
.gt-lead .mark.is-watch { color: var(--text-2); }
.gt-cb {
  position: absolute; inset: 4px;
  display: grid; place-items: center; padding: 0;
  border: 1.5px solid var(--field); border-radius: 5px; background: var(--surface);
  color: var(--action-text); opacity: 0;
  transition: opacity var(--dur-1) var(--ease-out);
}
.gt-cb svg { width: 12px; height: 12px; stroke-width: 2; opacity: 0; }
.gt-cb[aria-checked="true"], .gt-cb[aria-checked="mixed"] { border-color: var(--action); background: var(--action); }
.gt-cb[aria-checked="true"] svg { opacity: 1; }
.gt-cb[aria-checked="mixed"]::after { content: ""; position: absolute; width: 8px; height: 2px; border-radius: 1px; background: var(--action-text); }
.gt-row:hover .gt-cb, .gt-cb:focus-visible, .gt-cb[aria-checked="true"], .gt-cb[aria-checked="mixed"], .gt-grid.has-sel .gt-cb { opacity: 1; }
@media (hover: none) { .gt-row.is-head .gt-cb { opacity: 1; } }

/* Zellen */
.gt-firma { display: flex; align-items: center; gap: 11px; min-width: 0; }
.gt-firma .av { width: 28px; height: 28px; border-radius: 7px; }
.gt-firma .av img { width: 18px; height: 18px; }
.gt-two { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gt-two b, .gt-two span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-two b { font-weight: var(--w-medium); }
.gt-two span { color: var(--text-3); font-size: 12px; }
.gt-two .t { color: var(--text); font-size: 14px; }
.gt-star { width: 13px; height: 13px; margin-left: 5px; color: var(--text); fill: currentColor; vertical-align: -1px; }
.gt-sig { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; }
.gt-sig .gt-two { flex: 0 1 auto; }
.gt-sig.is-warn .t { color: var(--danger); }
.gt-warn { width: 15px; height: 15px; color: var(--danger); }
.gt-more-n {
  flex: none; padding: 1px 6px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  color: var(--text-3); font: 12px/1.4 var(--font-mono);
}
.gt-cats { display: flex; align-items: center; gap: 8px; }
.gt-cats .ci { display: grid; place-items: center; width: 14px; height: 14px; }
.gt-cats .ci svg { width: 14px; height: 14px; color: var(--text); }
.gt-cats .ci.off::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); }
.gt-text { min-width: 0; color: var(--text-2); }
.gt-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gt-muted { color: var(--text-3); }
.gt-strength { display: inline-flex; align-items: center; gap: 9px; font-variant-numeric: tabular-nums; }
.gt-strength b { min-width: 2ch; font-weight: var(--w-medium); text-align: right; }
.gt-when { color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Laden, leer */
.gt-row.is-skel > [role="gridcell"] .skel { width: 70%; height: 12px; }
.gt-grid > .empty, .gt-grid > .err { margin: 40px 24px; }
.gt-tail { display: flex; justify-content: center; padding: 16px; }
.gt-tail:empty { display: none; }


/* ---- Stapelansicht (schmale Tabelle, < 600 px) */
.gt-grid.is-stack .gt-row.is-head { display: none; }
.gt-grid.is-stack .gt-row:not(.is-head) {
  grid-template-columns: 36px minmax(0, 1fr) auto;
  grid-template-areas: "lead firma score" "lead sig sig" "lead when when";
  row-gap: 4px; padding: 12px 16px 12px 4px;
}
.gt-grid.is-stack .gt-row > [role="gridcell"] { padding: 0; border: 0; }
.gt-grid.is-stack .gt-c-lead { grid-area: lead; position: static; align-items: flex-start; padding-top: 2px; }
.gt-grid.is-stack .gt-c-firma { grid-area: firma; position: static; }
.gt-grid.is-stack .gt-c-signal { grid-area: sig; padding-left: 39px !important; }
.gt-grid.is-stack .gt-c-score { grid-area: score; }
.gt-grid.is-stack .gt-c-when { grid-area: when; justify-content: flex-start; padding-left: 39px !important; font-size: 12px; }
.gt-grid.is-stack .gt-c-when .gt-when { color: var(--text-3); }
.gt-grid.is-stack .gt-sig .gt-two span { white-space: normal; }

/* ---- In Firmen und Arbeitsliste (table.js): Kopfzeile, Gruppen, Merken-Knopf, Arbeitsstand */
.gt-body { display: block; }
.gt-group {
  display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 16px 0 58px;
  border-bottom: 1px solid var(--line); background: var(--surface-sunken);
  color: var(--text-2); font-size: 12px; font-weight: var(--w-medium);
}
.gt-group svg { width: 14px; height: 14px; color: var(--text-3); }
.gt-group.is-muted { color: var(--text-3); font-weight: 400; }
.gt-firma { position: relative; }
.gt-firma .gt-two { flex: 1; }
.gt-star-btn {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: var(--r-xs); background: transparent; color: var(--text-3); opacity: 0;
  transition: opacity var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.gt-star-btn svg { width: 15px; height: 15px; }
.gt-star-btn:hover { background: var(--surface-2); color: var(--text); }
.gt-star-btn.is-on { color: var(--text); }
.gt-star-btn.is-on svg { fill: currentColor; }
.gt-row:hover .gt-star-btn, .gt-row.is-cursor .gt-star-btn, .gt-star-btn:focus-visible { opacity: 1; }
.gt-star-btn.is-on { opacity: 0; }
.gt-row:hover .gt-star-btn.is-on, .gt-row.is-cursor .gt-star-btn.is-on { opacity: 1; }
@media (hover: none) { .gt-star-btn { opacity: 1; } }
.gt-two .badge-new { margin-left: 6px; vertical-align: 1px; }
.gt-link:hover span { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.gt-c-signal .pending { margin: 0; }
.gt-c-signal .pending.is-sub { display: none; }
.gt-c-signal { gap: 8px; }
.gt-row.flash { animation: gt-flash 1.6s var(--ease-out); }
@keyframes gt-flash { from { background: var(--success-soft); } }
.gt-row.enter { animation: gt-enter var(--dur-4) var(--ease-out); }
@keyframes gt-enter { from { opacity: 0; transform: translateY(-6px); background: var(--surface-2); } }
.gt-grid.is-stack .gt-c-contact { grid-area: when; padding-left: 39px !important; }
.gt-grid.is-stack .gt-c-contact .gt-two { flex-direction: row; gap: 6px; }
.gt-grid.is-stack .gt-group { padding-left: 16px; }

/* ---- Seitenköpfe wie bei Signale: Titel 28 px, Anzahl daneben in Text-3 (nicht Mono) */
:is(.rh-title, .page-head h1) .count { margin-left: 6px; font: 400 14px/1 var(--font-sans); letter-spacing: 0; color: var(--text-3); }
.rh-title, .page-head h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.025em; }

/* ---- Reiter Personen, Stellen, Änderungen (firmen-rows.js): gleiche Optik wie das Raster */
.fm-rl .tbl-head { min-height: 36px; border-top: 0; font: 500 12px/1.4 var(--font-sans); letter-spacing: 0; color: var(--text-3); }
.fm-rl .th-sort { gap: 6px; }
.fm-rl .th-dir { font-family: var(--font-sans); font-size: 11px; }
.fm-rl .tr { min-height: 56px; cursor: default; }
.fm-rl .tr:hover { background: var(--ld-n-50); }
.fm-rl .tr.is-cursor, .fm-rl .tr.is-open { background: var(--surface-sunken); }
[data-theme="dark"] .fm-rl .tr:hover { background: #1E1E1C; }
[data-theme="dark"] .fm-rl .tr.is-cursor, [data-theme="dark"] .fm-rl .tr.is-open { background: var(--surface-2); }
@container fmtbl (min-width: 881px) {
  .fm-rl .tbl-head > .th, .fm-rl .tbl-head > .fm-rest > .th { align-self: stretch; border-right: 1px solid var(--line); }
  .fm-rl .tr > .td, .fm-rl .tr > .fm-rest > .td { align-self: stretch; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); }
  .fm-rl .tr > .fm-rest > .fm-c-ct { flex-direction: row; align-items: center; justify-content: flex-start; gap: 2px; }
  .fm-rl .tbl-head > .fm-rest > .th:last-child, .fm-rl .tr > .fm-rest > .td:last-child { border-right: 0; }
}
