/* QB-Produktion: globale Hell-/Dunkel-Darstellung. */

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid #ffffff20;
  border-radius: 10px;
  background: #ffffff0c;
  color: #eef5f1;
  cursor: pointer;
  text-align: left;
}

.theme-toggle:hover, .theme-toggle:focus-visible {
  border-color: #d7813a;
  background: #ffffff16;
  outline: none;
}

.theme-toggle > span:first-child {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #d7813a;
  color: #1a1511;
  font-size: 18px;
}

.theme-toggle strong, .theme-toggle small { display: block; }
.theme-toggle strong { font-size: 13px; }
.theme-toggle small { margin-top: 2px; color: #aebdb6; font-size: 10px; }
.sidebar .theme-toggle { margin: 0 12px 10px; padding: 7px 10px; }
.topbar-theme-toggle { margin-left: auto; padding: 6px 10px; }
.pwa-install-button[hidden] { display: none !important; }
.topbar .pwa-install-button { margin-left: 0; }

html[data-theme="dark"] {
  color-scheme: dark;
  --navy: #171819;
  --blue: #f39a49;
  --cyan: #f39a49;
  --paper: #171819;
  --ink: #f2f2f0;
  --muted: #a9acb1;
  --line: #3b3d40;
  --danger: #f39a49;
  --ok: #f39a49;
  --warn: #f39a49;
  background: #171819;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-content { background: #171819; color: var(--ink); }
html[data-theme="dark"] a { color: #f39a49; }
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] strong { color: #f2f2f0; }
html[data-theme="dark"] .muted,
html[data-theme="dark"] .hint,
html[data-theme="dark"] small { color: var(--muted); }

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .topbar { background: #171819; box-shadow: 0 2px 18px #0008; }
html[data-theme="dark"] .nav-group-toggle { color: #a9acb1; }
html[data-theme="dark"] .sidebar nav a { color: #f2f2f0; }
html[data-theme="dark"] .sidebar nav a {
  position: relative;
  overflow: hidden;
  transition: background-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease;
}
html[data-theme="dark"] .sidebar nav a:hover,
html[data-theme="dark"] .sidebar nav a:focus-visible {
  background: linear-gradient(100deg, #f39a4926, #f39a4912);
  color: #fff;
  box-shadow: inset 2px 0 #f39a49, 0 0 16px #f39a4918;
  outline: none;
}
html[data-theme="dark"] .sidebar nav a.nav-current {
  background: linear-gradient(135deg, #f39a49, #f39a49);
  color: #fff;
  box-shadow: 0 6px 18px #0008, 0 0 16px #f39a4924;
}

html[data-theme="dark"] .qb-brand b {
  transition: color .25s ease, text-shadow .25s ease;
}
@media (hover: hover) {
  html[data-theme="dark"] .qb-brand:hover b,
  html[data-theme="dark"] .qb-brand:focus-visible b {
    color: #f39a49;
    text-shadow: 0 0 9px #f39a4999, 0 0 20px #f39a4944;
  }
  html[data-theme="dark"] .sidebar nav a:hover { transform: translateX(2px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .scanner-card,
html[data-theme="dark"] .kpis article,
html[data-theme="dark"] .flow-panel,
html[data-theme="dark"] .flow-metrics article,
html[data-theme="dark"] .flow-job,
html[data-theme="dark"] .flow-warning-panel,
html[data-theme="dark"] .inventory-panel,
html[data-theme="dark"] .inventory-metrics article,
html[data-theme="dark"] .data-panel,
html[data-theme="dark"] .diagnostic-card,
html[data-theme="dark"] .help-topic,
html[data-theme="dark"] .integration-card,
html[data-theme="dark"] .storage-group,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .recipe-card,
html[data-theme="dark"] .report-card,
html[data-theme="dark"] .print-card {
  background: #222426;
  border-color: var(--line);
  box-shadow: 0 7px 22px #0005;
  color: var(--ink);
}

html[data-theme="dark"] .flow-hero,
html[data-theme="dark"] .data-hero,
html[data-theme="dark"] .export-hero,
html[data-theme="dark"] .inventory-head,
html[data-theme="dark"] .integration-head,
html[data-theme="dark"] .diagnostic-summary,
html[data-theme="dark"] .storage-head {
  background: linear-gradient(135deg, #171819, #222426);
  border-color: #3b3d40;
  color: var(--ink);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #171819;
  border-color: #3b3d40;
  color: #f2f2f0;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #a9acb1; }
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: #f39a49;
  box-shadow: 0 0 0 3px #f39a492c;
  outline: none;
}
html[data-theme="dark"] option { background: #171819; color: #f2f2f0; }

html[data-theme="dark"] .primary { background: #f39a49; color: #171819; }
html[data-theme="dark"] .primary:hover { background: #f39a49; }
html[data-theme="dark"] .secondary,
html[data-theme="dark"] .inventory-action,
html[data-theme="dark"] .data-link {
  background: #2b2d30;
  border-color: #3b3d40;
  color: #f2f2f0;
}
html[data-theme="dark"] .secondary:hover,
html[data-theme="dark"] .inventory-action:hover,
html[data-theme="dark"] .data-link:hover { background: #3b3d40; border-color: #f39a49; }

html[data-theme="dark"] table,
html[data-theme="dark"] .data-table,
html[data-theme="dark"] .inventory-table { color: var(--ink); }
html[data-theme="dark"] th,
html[data-theme="dark"] .data-table thead th,
html[data-theme="dark"] .inventory-table thead th {
  background: #171819;
  border-color: var(--line);
  color: #a9acb1;
}
html[data-theme="dark"] td,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .inventory-table td { border-color: var(--line); }
html[data-theme="dark"] tbody tr:hover,
html[data-theme="dark"] .data-table tbody tr:hover,
html[data-theme="dark"] .inventory-table tbody tr:hover { background: #f39a4912; }

html[data-theme="dark"] .article-tabs,
html[data-theme="dark"] .data-tabs,
html[data-theme="dark"] .storage-toolbar,
html[data-theme="dark"] .flow-panel-head,
html[data-theme="dark"] .data-panel-head,
html[data-theme="dark"] .storage-group summary,
html[data-theme="dark"] .scanner-card-head,
html[data-theme="dark"] .pallet-dialog header { background: #171819; border-color: var(--line); }

html[data-theme="dark"] .pallet-dialog,
html[data-theme="dark"] dialog {
  background: #222426;
  border-color: #3b3d40;
  color: var(--ink);
  box-shadow: 0 24px 70px #000c;
}
html[data-theme="dark"] dialog::backdrop { background: #171819c7; }

html[data-theme="dark"] .alert,
html[data-theme="dark"] .flow-notice,
html[data-theme="dark"] .help-notice,
html[data-theme="dark"] .export-note { background: #2b2d30; border-color: #3b3d40; color: #f39a49; }
html[data-theme="dark"] .alert.success,
html[data-theme="dark"] .live,
html[data-theme="dark"] .audit-ok { background: #173426; color: #79dda0; }
html[data-theme="dark"] .alert.error,
html[data-theme="dark"] .audit-bad { background: #3b201e; color: #ff938a; }

html[data-theme="dark"] .data-code,
html[data-theme="dark"] .code,
html[data-theme="dark"] .barcode,
html[data-theme="dark"] .location-code,
html[data-theme="dark"] .error-code-help { background: #181715; border-color: #49443e; color: #efb173; }
html[data-theme="dark"] .auto-target { background: #222426; border-color: #3b3d40; color: #f39a49; }
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .data-empty,
html[data-theme="dark"] .flow-empty { background: #171819; border-color: #3b3d40; color: var(--muted); }

html[data-theme="dark"] .status,
html[data-theme="dark"] .data-status,
html[data-theme="dark"] .flow-pill { border-color: #3b3d40; }

html[data-theme="dark"] .scanner-field,
html[data-theme="dark"] .scanner-step,
html[data-theme="dark"] .scanner-help,
html[data-theme="dark"] .scanner-history { background: #222426; border-color: var(--line); }
html[data-theme="dark"] .scanner-select-wrap > span { background: #2b2d30; }

html[data-theme="dark"] .calendar-view-switch { background: #171819; border-color: var(--line); }
html[data-theme="dark"] .calendar-view-switch a { color: #a9acb1; }
html[data-theme="dark"] .calendar-view-switch a:hover { color: #fff; }
html[data-theme="dark"] .calendar-view-switch a.active { background: #f39a49; color: #fff; }
html[data-theme="dark"] .calendar-day { background: #222426; }
html[data-theme="dark"] .calendar-day.outside { background: #171819; color: #a9acb1; }
html[data-theme="dark"] .calendar-order { color: #f2f2f0; }
html[data-theme="dark"] .calendar-order.planned { background: #1d3856; }
html[data-theme="dark"] .calendar-order.partial { background: #4b3518; }
html[data-theme="dark"] .calendar-order.completed { background: #173e31; }
html[data-theme="dark"] .calendar-order.overdue { background: #4b2521; }
html[data-theme="dark"] .calendar-order.cancelled { background: #30302f; color: #a8a39d; }

html[data-theme="dark"] dialog.audit-window::backdrop { background: #171819c9; }
html[data-theme="dark"] .audit-window {
  border-color: #a9acb1;
  background: linear-gradient(145deg, #222426, #171819);
  color: #f39a49;
  box-shadow: 0 28px 90px #000c, 0 0 34px #f39a4926;
}
html[data-theme="dark"] .audit-window-head {
  border-color: #3b3d40;
  background: linear-gradient(115deg, #222426, #222426);
}
html[data-theme="dark"] .audit-eyebrow,
html[data-theme="dark"] .audit-title-block p,
html[data-theme="dark"] .audit-window-page,
html[data-theme="dark"] .audit-event-topline time,
html[data-theme="dark"] .audit-event-meta small { color: #a9acb1; }
html[data-theme="dark"] .audit-window-status { border-color: #3b3d40; background: #222426; }
html[data-theme="dark"] .audit-chain-valid { color: #83e2be; }
html[data-theme="dark"] .audit-chain-invalid { color: #ff9cb6; }
html[data-theme="dark"] .audit-chain-valid i { background: #173a32; }
html[data-theme="dark"] .audit-chain-invalid i { background: #422330; }
html[data-theme="dark"] .audit-event {
  border-color: #3b3d40;
  background: linear-gradient(145deg, #222426, #222426);
  box-shadow: 0 6px 18px #17181945, inset 0 1px #f2f2f008;
}
html[data-theme="dark"] .audit-event-sequence {
  border-color: #f39a495c;
  background: linear-gradient(145deg, #2b2d30, #2b2d30);
  color: #f39a49;
}
html[data-theme="dark"] .audit-event-type,
html[data-theme="dark"] .audit-event-sequence-label,
html[data-theme="dark"] .audit-event-meta { color: #f2f2f0; }
html[data-theme="dark"] .audit-event h2 { color: #f2f2f0; }
html[data-theme="dark"] .audit-location-flow {
  border-color: #3b3d40;
  background: #222426;
  color: #f39a49;
}
html[data-theme="dark"] .audit-location-flow span,
html[data-theme="dark"] .audit-technical-details small { color: #a9acb1; }
html[data-theme="dark"] .audit-technical-details { color: #f2f2f0; }
html[data-theme="dark"] .audit-hash code,
html[data-theme="dark"] .audit-payload pre {
  border-color: #3b3d40;
  background: #171819;
  color: #f39a49;
}
html[data-theme="dark"] .audit-payload summary { color: #f39a49; }
html[data-theme="dark"] .audit-control {
  border-color: #3b3d40;
  background: #222426;
  color: #f2f2f0;
}
html[data-theme="dark"] .audit-control:hover,
html[data-theme="dark"] .audit-control:focus-visible {
  border-color: #f39a49;
  background: #2b2d30;
  color: #fff;
  box-shadow: 0 0 0 3px #f39a4920, 0 0 18px #f39a4920;
}
html[data-theme="dark"] .audit-control.audit-close {
  border-color: #f39a49;
  background: linear-gradient(105deg, #f39a49, #f39a49 58%, #f39a49);
  color: #fff;
}
html[data-theme="dark"] .audit-control.is-disabled { border-color: #3b3d40; background: #222426; color: #a9acb1; }
html[data-theme="dark"] .audit-empty { color: #a9acb1; }

html[data-theme="dark"] .pallet-action-grid button { border-color: #3b3d40; background: #222426; color: var(--ink); }
html[data-theme="dark"] .pallet-action-grid button:hover { border-color: #f39a49; background: #2b2d30; }
html[data-theme="dark"] .pallet-action-grid button span { background: #2b2d30; color: #f39a49; }

@media (max-width: 960px) {
  .topbar-theme-toggle strong { display: none; }
  .topbar-theme-toggle { padding: 5px; }
}


/* Terminalpalette: identische Grundfarben im Hauptsystem, nur im Dunkelmodus. */
html[data-theme="dark"] {
  --navy: #171819; --paper: #171819; --surface: #222426;
  --surface-raised: #2b2d30; --ink: #f2f2f0; --muted: #a9acb1;
  --line: #3b3d40; --blue: #f39a49; --cyan: #f39a49;
  --accent-cyan: #f39a49; --accent-pink: #f39a49; --accent-violet: #f39a49;
  --accent-soft: #382a21;
  background: #171819;
}
html[data-theme="dark"] body { background: radial-gradient(ellipse at 95% 15%,#ee8b3010,transparent 45%),var(--paper); }
html[data-theme="dark"] .app-content { background: transparent; }
html[data-theme="dark"] .topbar { background: var(--surface); border-color: var(--line); }
html[data-theme="dark"] :is(.flow-hero,.data-hero,.export-hero,.inventory-head,.integration-head,.diagnostic-summary,.storage-head,.audit-window-head) {
  background: linear-gradient(140deg,var(--surface),var(--surface-raised)); border-color: var(--line);
}
html[data-theme="dark"] :is(.primary,button.primary,.flow-primary,.audit-control.audit-close,.calendar-view-switch a.active) {
  background: var(--blue); border-color: var(--blue); color: #171819; box-shadow: none;
}
html[data-theme="dark"] :is(.primary,.flow-primary,.audit-control.audit-close):hover { background: #ffb36b; color: #171819; }
html[data-theme="dark"] :is(.primary,.flow-primary) :is(strong,small,span) { color: inherit; }
html[data-theme="dark"] :is(.auto-target,.scanner-select-wrap > span,.pallet-action-grid button span,.audit-event-sequence,.inventory-group-icon) {
  background: var(--accent-soft); color: var(--blue); border-color: #f39a4959;
}
html[data-theme="dark"] .qb-brand img { filter: drop-shadow(0 0 8px #f39a4926); }
html[data-theme="dark"] .qb-brand:hover img { filter: drop-shadow(0 0 7px #f39a4999) drop-shadow(0 0 18px #f39a4944); }
html[data-theme="dark"] .qb-brand:hover b { color: var(--ink); text-shadow: 0 0 12px #f39a4955; }
html[data-theme="dark"] :is(.inventory-group,.license-card) { background: var(--surface); border-color: var(--line); }
html[data-theme="dark"] .inventory-group summary:hover { background: var(--surface-raised); }
html[data-theme="dark"] .inventory-group[open] summary { border-color: var(--line); }
html[data-theme="dark"] .inventory-group small { color: var(--muted); }
html[data-theme="dark"] .touch-keyboard { background: var(--paper); border-color: var(--line); }
html[data-theme="dark"] :is(.touch-key,.touch-keyboard-head button) { background: var(--surface-raised); border-color: var(--line); color: var(--ink); }
html[data-theme="dark"] .touch-key:hover { background: var(--accent-soft); border-color: var(--blue); }
html[data-theme="dark"] .touch-key.accent { background: var(--surface-raised); }
html[data-theme="dark"] :is(.touch-key.primary,.touch-key.active) { background: var(--blue); border-color: var(--blue); color: var(--paper); }

@media print {
  .theme-toggle { display: none !important; }
  html[data-theme="dark"],
  html[data-theme="dark"] body,
  html[data-theme="dark"] .app-content,
  html[data-theme="dark"] .panel,
  html[data-theme="dark"] .form-card,
  html[data-theme="dark"] table,
  html[data-theme="dark"] th,
  html[data-theme="dark"] td {
    color-scheme: light;
    background: #fff !important;
    color: #111 !important;
    box-shadow: none !important;
  }
}
