/* TaxBot Mandanten Login — Design angelehnt an /taxbot/docs/Design (TaxBot AI App) */
/* Alles unter .tbml-wrap gebunden, um Theme-Kollisionen zu minimieren */

.tbml-wrap {
  --tbml-bg: #f3f4f6;
  --tbml-surface: #ffffff;
  --tbml-border: #e5e7eb;
  --tbml-text: #111827;
  --tbml-text-muted: #6b7280;
  --tbml-primary: #0f6fff;
  --tbml-primary-soft: #e5f0ff;
  --tbml-success: #00b3a4;
  --tbml-warning: #f97316;
  --tbml-danger: #dc2626;
  --tbml-radius: 8px;
  --tbml-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --tbml-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  box-sizing: border-box;
  font-family: var(--tbml-font);
  color: var(--tbml-text);
  line-height: 1.45;
}

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

/* ——— Auth (Schritte 1–2) + Registrierung ——— */
#tbml-root[data-active-step="1"],
#tbml-root[data-active-step="2"],
.tbml-wrap--register {
  background: var(--tbml-bg);
  padding: 24px 16px;
  border-radius: var(--tbml-radius);
}

.tbml-card {
  background: var(--tbml-surface);
  border: 1px solid var(--tbml-border);
  border-radius: var(--tbml-radius);
  box-shadow: var(--tbml-shadow);
  padding: 20px 22px;
}

.tbml-card--auth {
  max-width: 440px;
  margin: 0 auto;
}

.tbml-auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.tbml-brand__logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--tbml-primary), var(--tbml-success));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.tbml-brand__name,
.tbml-brand .tbml-brand__name {
  font-weight: 600;
  font-size: 1rem;
}

.tbml-auth-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 600;
}

.tbml-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--tbml-text);
  margin-top: 12px;
  margin-bottom: 6px;
}

.tbml-input,
#tbml-mandant,
.tbml-company-form input,
.tbml-company-form select {
  width: 100%;
  max-width: 100%;
  border-radius: 999px;
  border: 1px solid var(--tbml-border);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--tbml-text);
}

.tbml-input:focus,
#tbml-mandant:focus,
.tbml-company-form input:focus,
.tbml-company-form select:focus {
  outline: 2px solid var(--tbml-primary-soft);
  outline-offset: 1px;
  border-color: var(--tbml-primary);
}

.tbml-qr,
#tbml-qr {
  width: 100%;
  max-width: 280px;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--tbml-border);
  border-radius: var(--tbml-radius);
  display: block;
  margin: 12px 0;
}

.tbml-auth-actions {
  margin-top: 16px;
}

/* Buttons */
.tbml-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tbml-btn--primary {
  background: var(--tbml-primary);
  color: #fff;
}

.tbml-btn--primary:hover {
  filter: brightness(1.05);
}

.tbml-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--tbml-text-muted);
}

.tbml-btn--ghost:hover {
  color: var(--tbml-text);
  background: #f9fafb;
}

.tbml-btn--secondary {
  background: #fff;
  border-color: var(--tbml-border);
  color: var(--tbml-text);
}

.tbml-btn--secondary:hover {
  background: #f9fafb;
}

/* Register tabs */
.tbml-register-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}

.tbml-register-tabs button {
  border-radius: 999px;
  border: 1px solid var(--tbml-border);
  background: #fff;
  color: var(--tbml-text-muted);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.tbml-register-tabs button.is-active {
  background: var(--tbml-primary-soft);
  color: var(--tbml-primary);
  border-color: transparent;
}

.tbml-register-panel {
  display: none;
}

.tbml-register-panel.is-active {
  display: block;
}

.tbml-muted {
  color: var(--tbml-text-muted);
  font-size: 14px;
}

.tbml-text-sm {
  font-size: 13px;
}

.tbml-error {
  min-height: 1.2em;
  font-size: 14px;
}

/* Statuszeile: Standard gruen (ok), bei Fehlermeldungen rot (err) */
.tbml-status-line {
  color: inherit;
}

.tbml-app-shell > #tbml-error {
  margin: 0 20px 12px;
  padding: 10px 14px;
  border-radius: var(--tbml-radius);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.tbml-app-shell > #tbml-error.tbml-status-line--ok {
  color: #065f46;
}

.tbml-app-shell > #tbml-error.tbml-status-line--err {
  color: var(--tbml-danger);
  background: #fef2f2;
  border-color: #fecaca;
}

/* Inline-Fehlermeldungen im Dashboard (nicht die Statuszeile) */
p.tbml-error:not(#tbml-error):not(#tbml-register-error) {
  color: var(--tbml-danger);
}

#tbml-root[data-active-step="1"] > #tbml-error,
#tbml-root[data-active-step="2"] > #tbml-error {
  max-width: 440px;
  margin: 12px auto 0;
  padding: 0 8px;
  text-align: center;
  background: transparent !important;
  border: none !important;
}

#tbml-root[data-active-step="1"] > #tbml-error.tbml-status-line--ok,
#tbml-root[data-active-step="2"] > #tbml-error.tbml-status-line--ok {
  color: #065f46;
}

#tbml-root[data-active-step="1"] > #tbml-error.tbml-status-line--err,
#tbml-root[data-active-step="2"] > #tbml-error.tbml-status-line--err {
  color: #b91c1c;
}

#tbml-register-root .tbml-error {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--tbml-radius);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

#tbml-register-root .tbml-error.tbml-status-line--err {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--tbml-danger);
}

/* Schritt-Logik */
.tbml-step {
  display: none;
}

.tbml-step-active {
  display: block;
}

/* ——— Dashboard Shell (Schritt 3) ——— */
#tbml-root[data-active-step="3"],
.tbml-wrap--dashboard#tbml-dashboard-root {
  background: var(--tbml-bg);
  padding: 0;
  max-width: 1200px;
  margin: 0 auto;
  border-radius: var(--tbml-radius);
  overflow: hidden;
}

#tbml-root[data-active-step="3"] .tbml-app-shell,
.tbml-wrap--dashboard .tbml-app-shell {
  min-height: 360px;
}

.tbml-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--tbml-surface);
  border-bottom: 1px solid var(--tbml-border);
}

.tbml-topbar__left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.tbml-topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tbml-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tbml-mandant-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.tbml-mandant-strip__label {
  color: var(--tbml-text-muted);
}

.tbml-mandant-strip__value {
  font-weight: 600;
  background: #f9fafb;
  border: 1px solid var(--tbml-border);
  border-radius: 999px;
  padding: 4px 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tbml-user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 13px;
}

.tbml-user-meta__name {
  font-weight: 600;
  color: var(--tbml-text);
}

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

/* Hauptnavigation */
.tbml-main-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 20px;
  background: var(--tbml-surface);
  border-bottom: 1px solid var(--tbml-border);
}

.tbml-main-nav__item {
  font-size: 14px;
  color: var(--tbml-text-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.tbml-main-nav__item.is-active,
.tbml-main-nav__item:hover {
  background: var(--tbml-primary-soft);
  color: var(--tbml-primary);
}

/* Subheader + Meta */
.tbml-subheader {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--tbml-bg);
}

.tbml-page-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
}

.tbml-page-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--tbml-text-muted);
  max-width: 520px;
}

.tbml-subheader__right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.tbml-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.tbml-meta-row__label {
  color: var(--tbml-text-muted);
}

.tbml-meta-row__value {
  text-align: right;
}

/* Layout */
.tbml-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 16px;
  padding: 0 20px 24px;
  background: var(--tbml-bg);
}

.tbml-dashboard-view {
  min-width: 0;
}

/* Cards (Hauptbereich + Seitenleiste) */
.tbml-card--side {
  margin-bottom: 0;
  margin-top: 0;
}

.tbml-card--side + .tbml-card--side {
  margin-top: 16px;
}

.tbml-card__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--tbml-border);
}

.tbml-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.tbml-card__body {
  padding: 12px 16px 16px;
}

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

.tbml-stat__label {
  display: block;
  font-size: 12px;
  color: var(--tbml-text-muted);
  margin-bottom: 4px;
}

.tbml-stat__value {
  font-size: 16px;
  font-weight: 600;
}

/* Badges */
.tbml-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 4px;
}

.tbml-badge:first-child {
  margin-left: 0;
}

.tbml-badge--success {
  background: #ecfdf5;
  color: #047857;
}

.tbml-badge--warning {
  background: #fffbeb;
  color: #b45309;
}

.tbml-badge--neutral {
  background: #e5e7eb;
  color: #374151;
}

/* Panels im dynamischen Inhalt */
.tbml-panel {
  background: var(--tbml-surface);
  border: 1px solid var(--tbml-border);
  border-radius: var(--tbml-radius);
  box-shadow: var(--tbml-shadow);
  padding: 12px 16px 16px;
  margin-top: 16px;
}

.tbml-panel:first-child {
  margin-top: 0;
}

.tbml-panel h4,
.tbml-panel h5 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
}

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

.tbml-chip-wrap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tbml-chip {
  background: var(--tbml-primary-soft);
  border: 1px solid #dbeafe;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

/* Tabellen */
.tbml-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--tbml-border);
  border-radius: var(--tbml-radius);
  background: #fff;
}

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

.tbml-table th,
.tbml-table td {
  border-bottom: 1px solid var(--tbml-border);
  text-align: left;
  padding: 8px 6px;
  vertical-align: top;
}

.tbml-company-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.tbml-company-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

.tbml-company-form label.tbml-check {
  grid-column: 1 / -1;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  text-align: left;
}

.tbml-company-form label.tbml-check input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0.2rem 0 0 0;
  width: auto;
  min-width: 1rem;
}

.tbml-check__text {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.45;
  font-weight: 400;
}

.tbml-company-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tbml-mini-btn {
  border: 1px solid var(--tbml-border);
  background: #fff;
  color: var(--tbml-text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}

.tbml-mini-btn:hover {
  background: #f9fafb;
}

.tbml-pill-ok,
.tbml-pill-warn,
.tbml-pill-err {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.3;
  margin-bottom: 4px;
}

.tbml-pill-ok {
  background: #ecfdf3;
  border: 1px solid #86efac;
  color: #166534;
}

.tbml-pill-warn {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
}

.tbml-pill-err {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.tbml-audit-list {
  margin: 0;
  padding-left: 18px;
}

.tbml-audit-list li {
  margin-bottom: 6px;
}

.tbml-manual-quartal h5 {
  margin: 0 0 10px;
  font-size: 14px;
}

/* Spezielle Aktions-Buttons (Legacy-IDs) */
#tbml-start-btn:not(.tbml-btn),
#tbml-back-btn:not(.tbml-btn) {
  border-radius: 999px;
}

#tbml-submit-btn {
  background: var(--tbml-success);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}

#tbml-request-key-btn {
  background: #fff;
  color: var(--tbml-primary);
  border: 1px solid var(--tbml-border);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
}

#tbml-preflight-btn {
  background: var(--tbml-primary-soft);
  color: var(--tbml-primary);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}

/* Toolbar in Belege-Ansicht */
.tbml-belege-toolbar,
.tbml-wrap .tbml-company-form[style*="margin-bottom"] {
  background: var(--tbml-surface);
  border: 1px solid var(--tbml-border);
  border-radius: var(--tbml-radius);
  padding: 12px;
}

@media (max-width: 960px) {
  .tbml-layout {
    grid-template-columns: 1fr;
  }

  .tbml-user-meta {
    align-items: flex-start;
  }

  .tbml-card__body--grid {
    grid-template-columns: 1fr;
  }
}
