:root {
  color-scheme: light;
  --theme-heading: #123a5c;
  --theme-primary-surface: #123a5c;
  --theme-danger-surface: #b3261e;
  --theme-success-surface: #16733b;
  --theme-on-solid: #fff;
  --theme-on-danger: #fff;
}

.environment-badge {
  position: sticky;
  top: 0;
  z-index: 35;
  box-sizing: border-box;
  width: 100%;
  padding: 6px 14px;
  border: 0;
  border-bottom: 1px solid #f1b35f;
  border-radius: 0;
  background: #fff3e2;
  color: #824500;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
}

.environment-badge + .kopf {
  top: 29px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --navy: #163f5c;
  --navy-deep: #d8ebf7;
  --blue: #65afe4;
  --blau: #65afe4;
  --orange: #f0a349;
  --orange-soft: #3b2c1d;
  --bg: #111c25;
  --hintergrund: #111c25;
  --surface: #1a2833;
  --papier: #1a2833;
  --line: #3a4b58;
  --linie: #3a4b58;
  --text: #edf4f8;
  --muted: #b5c5cf;
  --grau: #b5c5cf;
  --green: #62c887;
  --ok: #62c887;
  --red: #ff8b83;
  --warn: #ff8b83;
  --shadow: 0 10px 30px rgba(3, 10, 15, 0.28);
  --theme-heading: #e5f2fa;
  --theme-primary-surface: #245f86;
  --theme-danger-surface: #6d3135;
  --theme-success-surface: #216843;
  --theme-on-solid: #fff;
  --theme-on-danger: #ffe3e3;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background: var(--bg, #111c25) !important;
  color: var(--text, #edf4f8) !important;
}

html[data-theme="dark"]
  :where(
    .card,
    .karte,
    .metric,
    .box,
    .sheet,
    .management,
    .customer-card,
    .order,
    .messenger,
    .calendar-overview,
    #detail,
    .wrap-card,
    .panel,
    .question-dialog,
    .suggestion-panel,
    .agent-card,
    .daily-summary,
    .agent-details details,
    .learn-stat,
    .observation,
    .learn-case,
    .access-details,
    .daycol,
    .event,
    .billing-row,
    .reportcard,
    .report-row,
    .activeitem,
    .follow-item,
    .attention-item,
    .sms-preview,
    .reminder,
    .agent-item,
    .empty-agent,
    .intro,
    .user-card,
    .user-card > summary,
    .user-card > .details,
    .conversation,
    .token,
    .barbox,
    .safe-note,
    .customer-head,
    .visit,
    .visit details > summary,
    .photo,
    .raw,
    .suggestions,
    .report-billing-summary > div
  ) {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow) !important;
}

html[data-theme="dark"] .fee-card {
  border-color: #3d9a65 !important;
  background: #183126 !important;
}

html[data-theme="dark"] .fee-price {
  color: #8fdfad !important;
}

html[data-theme="dark"] .fee-confirm {
  border-color: #3d6f52 !important;
  background: #203d30 !important;
  color: var(--text) !important;
}

html[data-theme="dark"]
  :where(
    .side,
    .admin-side,
    .side-footer,
    .bottomnav,
    .mobile-more-panel,
    .chats,
    .conversation-head,
    .composer,
    .action-menu-panel,
    .mobil-menu-panel
  ) {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}

html[data-theme="dark"]
  :where(h1, h2, h3, h4, .company, .metric strong, .card strong, .karte strong, label, legend) {
  color: #e5f2fa !important;
}

html[data-theme="dark"]
  :where(
    summary,
    .name strong,
    .device-name,
    .visit-title,
    .position-text,
    .report-row strong,
    .current,
    .count,
    label > span
  ) {
  color: #e5f2fa !important;
}

html[data-theme="dark"]
  :where(
    .agent-item,
    .thread,
    .agent-card,
    .notice-detail,
    .follow-match,
    .source-box,
    .learn-stat,
    .observation,
    .info,
    .status-hero,
    .release-item,
    .report-billing-summary
  )
  strong {
  color: #e5f2fa !important;
}

html[data-theme="dark"]
  :where(.status-hero, .release-item, .result)
  :where(p, li, span) {
  color: inherit !important;
}

html[data-theme="dark"]
  :where(.status-meta, .integration p, .release-changes) {
  color: #c9d8e1 !important;
}

html[data-theme="dark"]
  :where(
    .small,
    .subtitle,
    .hinweis,
    .version,
    .platform-copyright,
    .mobile-platform-meta,
    .sms-network
  ) {
  color: var(--muted) !important;
}

html[data-theme="dark"] :where(input, select, textarea) {
  border-color: #526572 !important;
  background: #22323e !important;
  color: var(--text) !important;
}

html[data-theme="dark"] :where(input, select, textarea)::placeholder {
  color: #9cadb8;
  opacity: 1;
}

html[data-theme="dark"]
  :where(
    .secondary,
    .btn.zweit,
    .vf,
    .chip,
    .badge,
    .customer-result,
    .contact-result,
    .search-results button,
    .mobile-more-panel a,
    .action-menu-panel .btn,
    .switch a,
    .tag,
    .position-drag-handle,
    .position-move,
    .learn-filters a,
    .confidence,
    .observation-meta span,
    .case-details > summary,
    .pager a,
    .filters a,
    .pagination a
  ) {
  border-color: #4b6272 !important;
  background: #263b4a !important;
  color: #e6f2f8 !important;
}

html[data-theme="dark"]
  :where(.filters a.active, .pagination a.active, .learn-filters a.active, .pager a.active) {
  border-color: #65afe4 !important;
  background: #1f6fad !important;
  color: #fff !important;
}

html[data-theme="dark"] :where(.switch a.on) {
  border-color: #65afe4 !important;
  background: #1f6fad !important;
  color: #fff !important;
}

html[data-theme="dark"] .notice-agent,
html[data-theme="dark"] .suggestion-count,
html[data-theme="dark"] .billing-head .status,
html[data-theme="dark"] .billing-readiness .warn,
html[data-theme="dark"] .appointment-alert {
  border-color: #7f5a2d !important;
  background: #3b2c1d !important;
  color: #ffd39b !important;
}

html[data-theme="dark"] :where(.pill.high) {
  border-color: #94524d !important;
  background: #452626 !important;
  color: #ffb4ae !important;
}

html[data-theme="dark"] :where(.pill.normal, .pill.low, .source-state.neutral) {
  border-color: #4b6272 !important;
  background: #263b4a !important;
  color: #e6f2f8 !important;
}

html[data-theme="dark"] .appointment-alert.possible {
  border-color: #4b6272 !important;
  background: #263b4a !important;
  color: #e6f2f8 !important;
}

html[data-theme="dark"] .appointment-alert :where(h2, a),
html[data-theme="dark"] .appointment-alert.possible :where(h2, a) {
  color: inherit !important;
}

html[data-theme="dark"] body .position-order-controls > button {
  border-color: #4b6272 !important;
  background: #263b4a !important;
  color: #e6f2f8 !important;
}

html[data-theme="dark"] body .position-order-controls > button:hover {
  background: #304b5d !important;
}

html[data-theme="dark"] body .position-order-controls > button:disabled {
  background: #1e2c36 !important;
  color: #8295a1 !important;
}

html[data-theme="dark"]
  :where(
    .pill.ready,
    .source-state.ok,
    .status-hero.success,
    .result.ok,
    .status-icon,
    .release-item,
    .empty,
    .billing-readiness .ok,
    .confidence.high
  ) {
  border-color: #3f7153 !important;
  background: #1d3929 !important;
  color: #a8e5bd !important;
}

html[data-theme="dark"]
  :where(
    .notice,
    .hint,
    .internal,
    .dauer,
    .route .feld,
    .billing-box,
    .follow-match,
    .manual-note,
    .next-step-locked,
    .fact,
    .info,
    .security,
    .source-box,
    .position-choices,
    .positions,
    .article-preview,
    .privacy-note,
    .ability,
    .constitution-rule,
    .check,
    .backup-box,
    .integration,
    .archive-release,
    .section-nav a,
    .smsbox
  ) {
  border-color: #456071 !important;
  background: #203543 !important;
  color: #e5f0f5 !important;
}

html[data-theme="dark"] .environment-badge {
  border-color: #7f5a2d !important;
  background: #3b2c1d !important;
  color: #ffd39b !important;
}

html[data-theme="dark"] :where(.notice.error, .error, .danger) {
  border-color: #94524d !important;
}

/* Primäre Techniker- und Verwaltungsaktionen brauchen auf dem dunklen
   Hintergrund einen deutlich dunkleren Blauton als die Akzentfarbe. */
html[data-theme="dark"] body
  :where(
    .button:not(.secondary):not(.danger),
    .btn:not(.zweit):not(.leise):not(.danger)
  ) {
  background: var(--theme-primary-surface) !important;
  color: var(--theme-on-solid) !important;
}

html[data-theme="dark"] :where(.all-clear, .notice-detail) {
  border-color: #3f7153 !important;
  background: #1d3929 !important;
  color: #a8e5bd !important;
}

html[data-theme="dark"]
  :where(
    table,
    th,
    td,
    .item,
    .attention-item,
    .follow-item,
    .billing-row,
    .activeitem,
    .thread,
    .bubble,
    details
  ) {
  border-color: var(--line) !important;
}

html[data-theme="dark"] th {
  background: #21313d !important;
  color: #c1d0d9 !important;
}

html[data-theme="dark"] tbody tr:hover,
html[data-theme="dark"] :where(.billing-row, .order, .item):hover {
  background: #223540 !important;
}

html[data-theme="dark"] .model-table tr {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] a:not(.button):not(.btn) {
  color: #8ac7ef;
}

html[data-theme="dark"] :where(.dayhead, .event .time, .event .title) {
  color: #e5f2fa !important;
}

html[data-theme="dark"] :where(.side, .admin-side) a,
html[data-theme="dark"] .bottomnav > a,
html[data-theme="dark"] .bottomnav > .mobile-more > summary {
  color: #dbeaf3 !important;
}

html[data-theme="dark"] :where(.side, .admin-side) a.active,
html[data-theme="dark"] .bottomnav > a.active {
  background: #dcecf6 !important;
  color: #102f47 !important;
}

html[data-theme="dark"] .mobile-more-panel {
  border-color: #526572 !important;
  background: #182a36 !important;
  color: #edf4f8 !important;
}

html[data-theme="dark"] .mobile-more-panel a {
  border: 1px solid #4b6272 !important;
  background: #263b4a !important;
  color: #f4f8fb !important;
}

html[data-theme="dark"] .mobile-more-panel a.active {
  border-color: #6fb7e7 !important;
  background: #dcecf6 !important;
  color: #102f47 !important;
}

html[data-theme="dark"] .mobile-platform-meta {
  color: #c5d4dd !important;
}

html[data-theme="dark"] :where(img, canvas, video, svg) {
  filter: none !important;
}

html[data-theme="dark"] :where(.signature, .unterschrift-feld, #padOverlay) {
  background: #fff !important;
  color: #334552 !important;
}

html[data-theme="dark"] .haken {
  border-color: #526572 !important;
  background: #203543 !important;
  color: #edf4f8 !important;
}

html[data-theme="dark"] .haken span {
  color: #edf4f8 !important;
}

html[data-theme="dark"] .barmark {
  border: 1px solid #62c887 !important;
  background: #246b41 !important;
  color: #fff !important;
}

.theme-picker {
  display: grid;
  gap: 5px;
  color: var(--muted, #667784);
  font-size: 11px;
  font-weight: 750;
}

.theme-picker select {
  width: 100%;
  min-height: 38px !important;
  padding: 7px 9px !important;
  border: 1px solid var(--line, #dce4ea) !important;
  border-radius: 9px !important;
  background: var(--surface, #fff) !important;
  color: var(--text, #1a2a37) !important;
  font: inherit;
}

.theme-picker.compact {
  position: relative;
  display: block;
  width: 40px;
  min-width: 40px;
  max-width: none;
  margin-inline: 0;
  padding: 0;
  border: 0;
}

.theme-menu-trigger {
  display: grid;
  width: 40px;
  min-height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line, #dce4ea);
  border-radius: 9px;
  background: var(--surface, #fff);
  color: var(--text, #1a2a37);
  cursor: pointer;
  list-style: none;
}

.theme-menu-trigger::-webkit-details-marker {
  display: none;
}

.theme-current-icon {
  font-size: 18px;
  line-height: 1;
}

.theme-picker.compact > .theme-options {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 90;
  display: none;
  width: 168px;
  padding: 8px;
  border: 1px solid var(--line, #dce4ea);
  border-radius: 11px;
  background: var(--surface, #fff);
  box-shadow: 0 12px 30px rgba(10, 31, 51, 0.2);
}

.theme-picker.compact[open] > .theme-options {
  display: grid;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
}

.theme-option {
  width: 100% !important;
  min-width: 0;
  min-height: 36px !important;
  display: grid !important;
  place-items: center;
  gap: 0;
  margin: 0 !important;
  padding: 3px 1px !important;
  border: 1px solid var(--line, #dce4ea) !important;
  border-radius: 8px !important;
  background: var(--surface, #fff) !important;
  color: var(--text, #1a2a37) !important;
  box-shadow: none !important;
  cursor: pointer;
  line-height: 1 !important;
}

.theme-option > span {
  font-size: 14px;
  line-height: 1;
}

.theme-option > small {
  color: inherit;
  font-size: 8.5px;
  line-height: 1.1;
}

.theme-option[aria-pressed="true"] {
  border-color: #4c96c8 !important;
  background: #e5f1f8 !important;
  color: #123a5c !important;
  box-shadow: inset 0 -3px 0 var(--orange, #e18b2d) !important;
}

html[data-theme="dark"] .theme-option {
  border-color: #526572 !important;
  background: #263b4a !important;
  color: #edf4f8 !important;
}

html[data-theme="dark"] .theme-option[aria-pressed="true"] {
  border-color: #72b9e8 !important;
  background: #dcecf6 !important;
  color: #102f47 !important;
}

html[data-theme="dark"] .theme-menu-trigger,
html[data-theme="dark"] .theme-picker.compact > .theme-options {
  border-color: #526572;
  background: #263b4a;
  color: #edf4f8;
}

html[data-theme="dark"] .conversation {
  background: #13232e !important;
}

html[data-theme="dark"] .bubble {
  border: 1px solid #425966 !important;
  background: #263b4a !important;
  color: #edf4f8 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .bubble.out {
  border-color: #3a7da6 !important;
  background: #245f86 !important;
  color: #fff !important;
}

html[data-theme="dark"] .bubble .meta {
  color: #c5d4dd !important;
  opacity: 1;
}

html[data-theme="dark"] .bubble.out .meta {
  color: #dcecf6 !important;
}

html[data-theme="dark"] .bubble .event {
  color: #9bd2f2 !important;
}

html[data-theme="dark"] .bubble.out .event {
  color: #fff !important;
}

.box > .theme-picker {
  margin-top: 20px;
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid #4ea2dc !important;
  outline-offset: 3px !important;
}

@media (max-width: 900px) {
  .theme-picker.compact {
    width: 44px;
    min-width: 44px;
  }

  .theme-menu-trigger {
    width: 44px;
    min-height: 44px;
  }
}

@media print {
  :root,
  html[data-theme="dark"] {
    color-scheme: light !important;
    --bg: #fff;
    --hintergrund: #fff;
    --surface: #fff;
    --papier: #fff;
    --text: #000;
    --muted: #444;
    --grau: #444;
    --line: #c6d2dd;
    --linie: #c6d2dd;
  }

  html,
  body,
  .sheet,
  #druck {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  .theme-picker,
  .environment-badge {
    display: none !important;
  }
}
