/* Angebote & Fahrten — Listenseite */

.off-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.off-search {
  flex: 1;
  min-width: 240px;
  max-width: 480px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  background: var(--color-surface);
}
.off-search:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 2px var(--color-brand-primary-soft);
}
.off-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-default);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}
.off-filter-btn:hover { background: var(--color-surface-muted); }
.off-filter-btn.is-active {
  background: var(--color-brand-primary-soft);
  color: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
}
.off-filter-cycle {
  font-size: 10px;
  opacity: 0.7;
}
.off-filter-spacer { flex: 1; }

/* Datums-Filter-Gruppe: Heute-Toggle + Date-Input + Clear-Button */
.off-date-group {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}
.off-date-group .off-filter-btn {
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--color-border);
}
.off-date-input {
  border: 0;
  background: var(--color-surface);
  padding: 0 10px;
  font: inherit;
  font-size: var(--font-size-sm);
  color: var(--color-text-default);
  outline: none;
  min-width: 130px;
}
.off-date-input:focus {
  background: var(--color-brand-primary-soft);
}
.off-date-group.is-date-active {
  border-color: var(--color-brand-primary);
}
.off-date-group.is-date-active .off-date-input {
  background: var(--color-brand-primary-soft);
  color: var(--color-brand-primary);
  font-weight: var(--font-weight-semibold);
}
.off-date-clear {
  border: 0;
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  padding: 0 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}
.off-date-clear:hover {
  background: #fee2e2;
  color: #991b1b;
}
.off-group-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}
.off-group-row select {
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  background: var(--color-surface);
}

/* Tabelle */
.off-list-wrap {
  padding: 14px 28px 28px;
}
.off-list-meta {
  font-size: var(--font-size-xs);
  margin-bottom: 10px;
}
.off-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: var(--font-size-sm);
}
.off-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--color-surface-alt);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.off-table .off-th-sort { cursor: pointer; user-select: none; }
.off-table .off-th-sort:hover { color: var(--color-text-default); }
.off-table .off-th-sort.is-sorted { color: var(--color-brand-primary); }
.off-table .off-sort-caret {
  opacity: 0;
  font-size: 10px;
  margin-left: 4px;
}
.off-table .off-th-sort.is-sorted .off-sort-caret { opacity: 1; }
.off-table .off-th-num { text-align: right; }
.off-table .off-th-actions { text-align: right; }

.off-table tbody tr {
  border-bottom: 1px solid var(--color-border);
}
.off-table tbody tr:hover {
  background: var(--color-surface-muted);
}
.off-table tbody tr.is-new-flash {
  background: var(--color-brand-primary-soft);
  animation: offFlash 1.6s ease-out forwards;
}
@keyframes offFlash {
  from { background: var(--color-brand-primary-soft); }
  to   { background: var(--color-surface); }
}
.off-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}
.off-table tbody td.off-td-num { text-align: right; font-variant-numeric: tabular-nums; }
.off-table tbody td.off-td-actions { text-align: right; white-space: nowrap; }

/* Gruppen-Headers */
.off-table tbody tr.off-group-row td {
  padding: 12px 12px 6px;
  background: var(--color-surface-muted);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  border-top: 2px solid var(--color-border);
}
.off-table tbody tr.off-group-row td .off-group-count {
  margin-left: 6px;
  font-weight: var(--font-weight-normal);
  opacity: 0.7;
}

/* Zellen-Inhalte */
.off-cell-when {
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.off-cell-when .off-day { font-weight: var(--font-weight-semibold); }
.off-cell-when .off-time { color: var(--color-text-muted); font-size: var(--font-size-xs); }
.off-cell-kunde { min-width: 140px; max-width: 200px; }
.off-cell-kunde .off-name {
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.off-cell-kunde .off-name-meta { font-size: var(--font-size-xs); }
.off-cell-titel { min-width: 220px; max-width: 360px; }
.off-cell-titel .off-titel {
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.off-cell-titel .off-route {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.off-cell-bus, .off-cell-fahrer {
  white-space: nowrap;
  color: var(--color-text-default);
}
.off-cell-empty { color: var(--color-text-subtle); font-style: italic; }

/* Angebotsnummer-Spalte: monospace + brand-tinted */
.off-cell-nr {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 80px;
}
.off-angebotsnummer {
  font-family: "SF Mono", "JetBrains Mono", monospace;
  font-size: var(--font-size-xs);
  color: var(--color-brand-primary);
  font-weight: var(--font-weight-semibold);
}

/* Local-only Badge */
.off-local-only-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  background: #fef3c7;
  color: #92400e;
  border-radius: var(--radius-pill);
  font-size: 9px;
  font-weight: var(--font-weight-semibold);
  vertical-align: middle;
}

/* Status-Badges (Legacy) — bleiben für ältere Aufrufer */
.off-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}
.off-badge-entwurf    { background: var(--color-surface-muted); color: var(--color-text-muted); }
.off-badge-versandt   { background: #dbeafe; color: #1e40af; }
.off-badge-angenommen { background: #dcfce7; color: #166534; }
.off-badge-abgelehnt  { background: #fee2e2; color: #991b1b; }
.off-badge-abgelaufen { background: var(--color-surface-muted); color: var(--color-text-muted); text-decoration: line-through; }
.off-badge-gefahren   { background: #d1fae5; color: #065f46; }

/* === Lifecycle-Chips (über der Filter-Bar) === */
.off-lifecycle-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.off-chip {
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  color: var(--color-text-default);
  transition: background 0.12s, border-color 0.12s;
}
.off-chip:hover { background: var(--color-surface-muted); }
.off-chip.is-active {
  background: var(--color-brand-primary-soft);
  border-color: var(--color-brand-primary);
  color: var(--color-brand-primary);
}

/* === Lifecycle-Badges in der Tabelle === */
.off-lifecycle {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}
.off-lifecycle-offer_draft         { background: var(--color-surface-muted); color: var(--color-text-muted); }
.off-lifecycle-offer_sent          { background: #dbeafe; color: #1e40af; }
.off-lifecycle-accepted_no_invoice { background: #dcfce7; color: #166534; }
/* Durchgeführt aber noch nicht verrechnet → orange Akzent als Buchhaltungs-Trigger */
.off-lifecycle-accepted_no_invoice.is-overdue { background: #fed7aa; color: #9a3412; }
.off-lifecycle-invoice_draft       { background: #e0e7ff; color: #3730a3; }
.off-lifecycle-invoice_finalized   { background: #ede9fe; color: #5b21b6; }
.off-lifecycle-invoice_sent        { background: #fef3c7; color: #92400e; }
.off-lifecycle-paid                { background: #d1fae5; color: #065f46; }
.off-lifecycle-offer_rejected      { background: #fee2e2; color: #991b1b; }
.off-lifecycle-offer_expired       { background: var(--color-surface-muted); color: var(--color-text-muted); }
.off-lifecycle-invoice_cancelled   { background: #fde2e2; color: #991b1b; }
.off-lifecycle-unknown             { background: var(--color-surface-muted); color: var(--color-text-muted); }

/* Nummer-Stack: Rechnungsnummer fett oben, Angebotsnummer als Sub */
.off-cell-nr-stack { display: flex; flex-direction: column; line-height: 1.2; }
.off-rechnungsnummer {
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
}
.off-cell-nr-sub {
  font-size: var(--font-size-xs);
  font-variant-numeric: tabular-nums;
}

/* Betrag — netto-Hinweis */
.off-amount-brutto { font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; }
.off-amount-net-label { font-size: var(--font-size-xs); opacity: 0.6; }

/* Action-Icon-Buttons — kompakt, ohne Border, Tooltip via title-Attribut */
.off-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin: 0 0 0 2px;
  border: 0;
  background: transparent;
  color: var(--color-text-subtle);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 100ms, background 100ms;
}
.off-icon-btn:hover {
  color: var(--color-text-default);
  background: var(--color-surface-muted);
}
.off-icon-btn.is-accept {
  color: #16a34a;
}
.off-icon-btn.is-accept:hover {
  color: #166534;
  background: #dcfce7;
}
.off-icon-btn.is-delete:hover {
  color: #991b1b;
  background: #fee2e2;
}
.off-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.off-icon-btn:disabled:hover {
  background: transparent;
  color: var(--color-text-subtle);
}
.off-icon-btn svg {
  display: block;
}

/* Empty-State */
.off-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.off-empty h3 {
  margin: 0 0 8px;
  font-size: var(--font-size-md);
  color: var(--color-text-default);
}

.off-load-more {
  text-align: center;
  margin-top: 16px;
}

/* Modals */
.off-modal {
  width: 100%;
  max-width: 480px;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  /* Kopf/Footer bleiben sichtbar, nur der Body scrollt — kein Dialog
     darf über den Viewport-Rand hinauslaufen. */
  max-height: calc(100dvh - 32px);
  flex-direction: column;
  overflow: hidden;
}
/* display nur im offenen Zustand — sonst wären die geschlossenen
   Dialoge sichtbar (überschreibt dialog:not([open]) { display:none }). */
.off-modal[open] { display: flex; }
.off-modal-body {
  overflow-y: auto;
  min-height: 0;
}
body:has(dialog.off-modal[open]) { overflow: hidden; }

/* Mail-Compose-Dialog — breiter Layout für Editor */
.off-mail-modal {
  max-width: 720px;
}
.off-modal-close {
  border: 0;
  background: transparent;
  font-size: 18px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.off-modal-close:hover {
  background: var(--color-surface-muted);
  color: var(--color-text-default);
}
.off-mail-body { padding: 16px 20px 20px; }
.off-mail-status { margin-bottom: 12px; font-size: var(--font-size-xs); }
.off-mail-status[data-type="error"] { color: #991b1b; }
.off-mail-form { display: flex; flex-direction: column; gap: 10px; }
.off-mail-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  align-items: center;
}
.off-mail-row-body { align-items: flex-start; }
.off-mail-row-body .off-mail-label { padding-top: 8px; }
.off-mail-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-medium);
}
.off-mail-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font: inherit;
  font-size: var(--font-size-sm);
}
.off-mail-input[readonly] { background: var(--color-surface-muted); color: var(--color-text-muted); }
.off-mail-input:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 2px var(--color-brand-primary-soft);
}
.off-mail-to-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.off-mail-body-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.off-mail-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font: inherit;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  resize: vertical;
  min-height: 200px;
  font-family: inherit;
}
.off-mail-textarea:focus {
  outline: none;
  border-color: var(--color-brand-primary);
  box-shadow: 0 0 0 2px var(--color-brand-primary-soft);
}
.off-mail-sig-hint {
  font-size: var(--font-size-xs);
  font-style: italic;
}
.off-mail-skip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.off-mail-skip input { cursor: pointer; }
.off-modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.off-modal::before {
  content: "";
  display: block;
  height: 4px;
  flex: none;
  background: linear-gradient(90deg, var(--color-brand-primary), color-mix(in srgb, var(--color-brand-primary) 75%, white));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.off-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 8px;
  border-bottom: 1px solid var(--color-border);
}
.off-modal-head h2 { margin: 0; font-size: var(--font-size-lg); }
.off-modal-body { padding: 16px 20px 20px; }
.off-modal-body > p:first-child { margin-top: 0; }
.off-modal-foot {
  display: flex;
  flex-wrap: wrap;            /* lange Button-Zeilen brechen um statt aus dem Dialog zu laufen */
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}


/* Multi-Tour-Hinweis in der Angebote-Liste */
.off-multi-tour-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-pill);
  background: #e0e7ff;
  color: #3730a3;
  vertical-align: middle;
}

/* Kunden-Anlage-Dialog (Freitext-Kunde → Lexware): jetzt Shared-Komponente —
   Styles in /__shared/frontend/styles/lex-customer-dialog.css */
