/* Cabsol shared base styles — included by all pages */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:           #B82420;
  --red-dark:      #8f1c19;
  --red-light:     #fbe9e8;
  --red-text:      var(--red);
  --text:          #3a3a3a;
  --text-strong:   #1f1f1f;
  --text-muted:    #6b6b6b;
  --text-light:    #9b9b9b;
  --bg-soft:       #f6f6f7;
  --surface:       #ffffff;
  --border:        #e5e5e7;
  --border-strong: #d1d1d4;
  --success:       #2d8a4e;
  --success-light: #e8f5ec;
  --success-text:  var(--success);
  --success-border:#b7e0c9;
  --warning:       #c47a00;
  --warning-light: #fdf3e0;
  --warning-text:  var(--warning);
  --warning-border:#f0dcac;
  --danger:        #c93b3b;
  --danger-light:  #fbe7e7;
  --danger-text:   var(--danger);
  --danger-border: #f5c6c6;
  --info:          #2563b8;
  --info-light:    #e6eef9;
  --info-text:     var(--info);
  --info-border:   #bdd4f0;
  --purple:        #7c3aed;
  --purple-light:  #f0e8f8;
  --purple-text:   var(--purple);
  --purple-border: #ddc8f0;
  --shadow-soft:   rgba(0,0,0,0.10);
  --shadow-strong: rgba(0,0,0,0.1);
  /* Tooltip chips stay a fixed dark chip in both themes (not page-background-relative). */
  --tooltip-bg:    #1f1f1f;
  --tooltip-text:  #ffffff;
}

/* ── Dark theme ──
   Background/text/border tokens shift with the theme. The accent colors
   themselves (--red/--success/--warning/--danger/--info/--purple) stay
   identical in both modes on purpose — they're the ones used as *solid*
   fills with white text (buttons, solid badges) and changing them would
   break that contrast. Only the paired "-light" fill tokens (filled boxes:
   alerts, tags, badges) and their "-text"/"-border" companions (the text/
   border color used *on top of* that fill) get dark-mode overrides, since a
   pastel light-mode fill with dark accent text has no readable dark-mode
   equivalent unless the fill itself darkens and the text lightens together. */
[data-theme="dark"] {
  --text:          #e8e8e8;
  --text-strong:   #f5f5f5;
  --text-muted:    #999999;
  --text-light:    #777777;
  --bg-soft:       #121212;
  --surface:       #1e1e1e;
  --border:        #2e2e2e;
  --border-strong: #3d3d3d;
  --shadow-soft:   rgba(0,0,0,0.45);
  --shadow-strong: rgba(0,0,0,0.5);

  --red-light:      rgba(184, 36, 32, 0.18);
  --red-text:       #ff8a80;
  --success-light:  rgba(45, 138, 78, 0.20);
  --success-text:   #6fcf97;
  --success-border: rgba(45, 138, 78, 0.45);
  --warning-light:  rgba(196, 122, 0, 0.20);
  --warning-text:   #f5b642;
  --warning-border: rgba(196, 122, 0, 0.45);
  --danger-light:   rgba(201, 59, 59, 0.18);
  --danger-text:    #ff6b6b;
  --danger-border:  rgba(201, 59, 59, 0.45);
  --info-light:     rgba(37, 99, 184, 0.20);
  --info-text:      #6ea8fe;
  --info-border:    rgba(37, 99, 184, 0.45);
  --purple-light:   rgba(124, 58, 237, 0.20);
  --purple-text:    #c4a4f5;
  --purple-border:  rgba(124, 58, 237, 0.45);
}

body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  border-bottom: 1px solid var(--border);
  padding: 0;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: min(95vw, 1800px);
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: stretch;
  height: 60px;
}
.logo-wrap {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; text-decoration: none;
  margin-right: 32px; flex-shrink: 0;
}
.logo-text { font-weight: 700; font-size: 26px; letter-spacing: -0.02em; color: var(--text-strong); }
.topbar-nav { display: flex; align-items: stretch; gap: 0; flex: 1; justify-content: center; }
.nav-link {
  display: flex; align-items: center;
  padding: 0 18px;
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text-strong); }
.nav-link.active { color: var(--red); border-bottom-color: var(--red); }
.topbar-right { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
.topbar-user { font-size: 13px; color: var(--text-muted); }
.topbar-user strong { color: var(--text-strong); font-weight: 600; }
.btn-link {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; color: var(--text-muted);
  text-decoration: underline; padding: 0;
}
.btn-link:hover { color: var(--red); }
.pilot-tag {
  background: var(--red-light); color: var(--red-text);
  padding: 5px 12px; border-radius: 3px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: 4px;
  font-size: 13px; margin-bottom: 16px; display: none;
}
.alert.show { display: block; }
.alert-error   { background: var(--danger-light);  color: var(--danger-text);  border: 1px solid var(--danger-border); }
.alert-success { background: var(--success-light); color: var(--success-text); border: 1px solid var(--success-border); }
.alert-warning { background: var(--warning-light); color: var(--warning-text); border: 1px solid var(--warning-border); }
.alert-info    { background: var(--info-light);    color: var(--info-text);    border: 1px solid var(--info-border); }

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner-sm { width: 12px; height: 12px; border-width: 2px; }

/* ── User menu dropdown ── */
.topbar-user-menu { position: relative; display: flex; align-items: center; }
.btn-user-menu {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--red); color: white;
  border: none; border-radius: 4px;
  padding: 7px 14px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
  white-space: nowrap;
}
.btn-user-menu:hover { background: var(--red-dark); }
.user-menu-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; min-width: 180px;
  box-shadow: 0 4px 16px var(--shadow-soft);
  z-index: 200; display: none; overflow: hidden;
}
.user-menu-dropdown.open { display: block; }
.user-menu-item {
  display: block; width: 100%;
  padding: 10px 16px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--text); text-decoration: none;
  background: none; border: none; border-radius: 0;
  text-align: left; cursor: pointer;
  transition: background 0.12s;
  box-sizing: border-box;
}
.user-menu-item:hover { background: var(--bg-soft); color: var(--text-strong); }
.user-menu-item-logout {
  border-top: 1px solid var(--border);
  color: var(--danger-text);
}
.user-menu-item-logout:hover { background: var(--danger-light); }

/* ── Theme toggle ── */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  background: none; border: 1px solid var(--border-strong); border-radius: 6px;
  cursor: pointer; color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { background: var(--bg-soft); color: var(--text-strong); }
.theme-toggle svg { width: 20px; height: 20px; display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── Checkboxes ── */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  margin: 0;
  vertical-align: middle;
  transition: background 0.15s, border-color 0.15s;
}
input[type="checkbox"]:hover { border-color: var(--red); }
input[type="checkbox"]:checked {
  background: var(--red);
  border-color: var(--red);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ── Customer/site entity badges + autocomplete picker (upload.html, generate.html) ── */
.entity-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 1px 7px;
  border-radius: 10px; vertical-align: middle; white-space: nowrap; flex-shrink: 0;
  background: var(--info-light); color: var(--info-text); border: 1px solid var(--info-border);
}
.entity-badge-site      { background: var(--purple-light); color: var(--purple-text); border: 1px solid var(--purple-border); }
.entity-badge-unmatched { background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border-strong); }
.btn-edit-entity {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 1px 3px; display: inline-flex; align-items: center; vertical-align: middle;
}
.btn-edit-entity:hover { color: var(--text); }

.picker-field { margin-bottom: 12px; position: relative; }
.picker-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.picker-field input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 4px; font-family: inherit; font-size: 15px;
  color: var(--text); background: var(--surface);
  transition: border-color 0.15s; outline: none;
}
.picker-field input:focus { border-color: var(--red); }
.picker-field input:disabled { background: var(--bg-soft); color: var(--text-light); }
.picker-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 12px var(--shadow-strong);
  max-height: 180px; overflow-y: auto; z-index: 50; display: none;
}
.picker-suggestions.show { display: block; }
.picker-suggestion-item { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.picker-suggestion-item:hover { background: var(--bg-soft); }

/* ── Undo toast (soft-delete "Rückgängig") ──────────────────────────────────────
   Stacking toasts anchored bottom-right. Slide up in, right-to-left progress bar,
   slide down out. Colours are entirely theme-variable-driven, so light + dark
   both work via the [data-theme] attribute — no hard-coded hex values. */
.undo-toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 600;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
  pointer-events: none;
}
.undo-toast {
  pointer-events: auto;
  min-width: 280px; max-width: 380px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px var(--shadow-strong);
  overflow: hidden;
  transform: translateY(140%); opacity: 0;
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.28s ease-out;
}
.undo-toast.show { transform: translateY(0); opacity: 1; }
.undo-toast.hide {
  transform: translateY(140%); opacity: 0;
  transition: transform 0.2s ease-in, opacity 0.2s ease-in;
}
.undo-toast-body { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.undo-toast-message { flex: 1; font-size: 13px; font-weight: 500; line-height: 1.35; }
.undo-toast-btn {
  flex-shrink: 0; background: transparent; border: none;
  color: var(--info-text); font-weight: 700; font-size: 13px; font-family: inherit;
  cursor: pointer; padding: 5px 8px; border-radius: 4px; transition: background 0.15s;
}
.undo-toast-btn:hover { background: var(--info-light); }
.undo-toast-btn:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
/* Thin bar along the bottom edge; shrinks right→left over the toast's lifetime. */
.undo-toast-progress {
  height: 3px; background: var(--info);
  transform: scaleX(1); transform-origin: right;
}
.undo-toast.running .undo-toast-progress {
  transition: transform 5000ms linear; /* transitionDuration overridden inline in JS */
  transform: scaleX(0);
}

/* CA-A1: visually hidden but exposed to assistive tech — used for the shared
   aria-live status region (Cabsol.a11y.announce) driving throttled SSE-generation
   announcements. Standard clip-rect technique so screen readers still read it. */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* .icon-btn — icon-only row action button. Previously copy-pasted inline into
   admin.html/components.html; hoisted here so offers-in-progress.html (undo-toast
   delete button) and any future page share one definition. Identical rules, so
   the existing inline copies (which still win by source order) render the same. */
.icon-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 4px; padding: 5px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: border-color 0.15s, color 0.15s, background 0.15s;
  line-height: 0;
}
.icon-btn:hover { border-color: var(--text-muted); color: var(--text-strong); background: var(--bg-soft); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn:disabled:hover { border-color: var(--border); color: var(--text-muted); background: none; }

/* Auth-code modal (Step 54) — shared by the login second factor and step-up
   confirmation (Cabsol.promptAuthCode). Built dynamically in shared.js; theme-variable
   driven so light + dark both work. z-index above the undo toast (600). */
.authcode-overlay {
  position: fixed; inset: 0; z-index: 700;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45); padding: 20px;
}
.authcode-modal {
  width: 100%; max-width: 380px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 40px var(--shadow-strong);
  padding: 22px;
}
.authcode-title { font-size: 17px; font-weight: 700; color: var(--text-strong); margin-bottom: 8px; }
.authcode-desc  { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
.authcode-error { margin-bottom: 12px; }
.authcode-input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px; letter-spacing: 0.3em; text-align: center;
  color: var(--text-strong); background: var(--surface);
  outline: none; transition: border-color 0.15s;
}
.authcode-input:focus { border-color: var(--red); }
.authcode-actions { display: flex; gap: 10px; margin-top: 16px; }
.authcode-actions button {
  flex: 1; padding: 11px 16px; border-radius: 6px;
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.authcode-cancel { background: transparent; color: var(--text-muted); border: 1px solid var(--border-strong); }
.authcode-cancel:hover:not(:disabled) { border-color: var(--text-muted); color: var(--text-strong); }
.authcode-submit { background: var(--red); color: #fff; border: 1px solid var(--red); }
.authcode-submit:hover:not(:disabled) { background: var(--red-dark); }
.authcode-actions button:disabled { opacity: 0.6; cursor: not-allowed; }
