/*
 * KCDD.de - Design-Engineered Single-Screen Workbench (ui-skills Baseline)
 * Monochrome Zinc Architecture + Single Electric Indigo Accent + Semantic AI Review Tokens
 */

:root {
  /* Zinc Monochrome Scale (Tailwind v4 / Linear / Airtable Inspired) */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;
  --bg-inspector: #09090b;
  --bg-inspector-bar: #18181b;

  /* Typography Ink Scale */
  --ink-primary: #09090b;
  --ink-secondary: #3f3f46;
  --ink-muted: #71717a;
  --ink-faint: #a1a1aa;

  /* Crisp 1px Borders */
  --border-subtle: #e4e4e7;
  --border-default: #d4d4d8;
  --border-strong: #a1a1aa;

  /* Single Primary Accent: Electric Indigo */
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;
  --accent-ink: #3730a3;

  /* Semantic Status Tokens (Strictly Scoped) */
  --ai-bg: #fffbeb;
  --ai-bg-active: #fef3c7;
  --ai-border: #f59e0b;
  --ai-ink: #b45309;

  --verified-bg: #ecfdf5;
  --verified-border: #10b981;
  --verified-ink: #047857;

  --danger-bg: #fff1f2;
  --danger-border: #fecdd3;
  --danger-ink: #be123c;

  /* Spacing & Radius Scale */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Fixed Z-Index Scale (ui-skills Layout Rule) */
  --z-sticky-cell: 10;
  --z-sticky-head: 20;
  --z-sticky-corner: 30;
  --z-header: 40;
  --z-modal: 50;
}

[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-surface: #151f32;
  --bg-subtle: #1e293b;
  --bg-muted: #334155;
  --bg-inspector: #080d1a;
  --bg-inspector-bar: #0f172a;

  --ink-primary: #f1f5f9;
  --ink-secondary: #cbd5e1;
  --ink-muted: #94a3b8;
  --ink-faint: #64748b;

  --border-subtle: #1e293b;
  --border-default: #334155;
  --border-strong: #475569;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.18);
  --accent-border: #4f46e5;
  --accent-ink: #c7d2fe;

  --ai-bg: rgba(245, 158, 11, 0.14);
  --ai-bg-active: rgba(245, 158, 11, 0.24);
  --ai-border: #d97706;
  --ai-ink: #fbbf24;

  --verified-bg: rgba(16, 185, 129, 0.14);
  --verified-border: #059669;
  --verified-ink: #34d399;

  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-border: #b91c1c;
  --danger-ink: #f87171;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--ink-primary);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
optgroup,
select,
textarea {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: inherit;
  line-height: inherit;
}

/* Typography Rules (ui-skills: text-balance for headings, text-pretty for body, tabular-nums for data) */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  color: var(--ink-primary);
  text-wrap: balance;
  font-family: 'Space Grotesk', 'Plus Jakarta Sans', sans-serif;
}

.brand-title,
.sidebar-brand-title,
.step-indicator,
.kpi-chip,
.badge,
.wizard-title,
.matrix-col-header,
.tally-cell,
.matrix-player-name {
  font-family: 'Space Grotesk', 'Plus Jakarta Sans', sans-serif;
}

p {
  margin: 0;
  color: var(--ink-secondary);
  text-wrap: pretty;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-family: 'Space Grotesk', 'Plus Jakarta Sans', sans-serif;
}

/* KPI Summary Card Tokens */
.kpi-card-success {
  background: var(--verified-bg);
  border: 1px solid var(--verified-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.kpi-card-success .kpi-label {
  font-size: 10.5px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--verified-ink);
  letter-spacing: 0.04em;
  display: block;
}
.kpi-card-success .kpi-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--verified-ink);
  margin-top: 2px;
}
.kpi-card-success .kpi-meta {
  font-size: 10.5px;
  color: var(--verified-ink);
  opacity: 0.85;
  display: block;
}

.kpi-card-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.kpi-card-danger .kpi-label {
  font-size: 10.5px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--danger-ink);
  letter-spacing: 0.04em;
  display: block;
}
.kpi-card-danger .kpi-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--danger-ink);
  margin-top: 2px;
}
.kpi-card-danger .kpi-meta {
  font-size: 10.5px;
  color: var(--danger-ink);
  opacity: 0.85;
  display: block;
}

.kpi-card-neutral {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.kpi-card-neutral .kpi-label {
  font-size: 10.5px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-secondary);
  letter-spacing: 0.04em;
  display: block;
}
.kpi-card-neutral .kpi-value {
  font-size: 19px;
  font-weight: 800;
  margin-top: 2px;
}
.kpi-card-neutral .kpi-meta {
  font-size: 10.5px;
  color: var(--ink-muted);
  display: block;
}

/* Single-Screen Desktop Lock (ui-skills: use dvh, never h-screen) */
@media (min-width: 1024px) {
  body.kcdd-single-screen {
    min-height: 100dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
}

/* Keyboard Focus Ring (ui-skills / fixing-accessibility) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Top Application Bar (Flat Monochrome Surface, 44px) */
.kcdd-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  flex-shrink: 0;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.kcdd-header-inner {
  height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kcdd-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink-primary);
  padding-right: 8px;
  border-right: 1px solid var(--border-subtle);
}

.kcdd-brand img {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.kcdd-brand-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-primary);
}

.kcdd-brand-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Segmented Navigation Tabs */
.kcdd-nav {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  padding: 2px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.kcdd-nav-link {
  color: var(--ink-secondary);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}

@media (hover: hover) and (pointer: fine) {
  .kcdd-nav-link:hover {
    color: var(--ink-primary);
  }
}

.kcdd-nav-link.active {
  background: var(--bg-surface);
  color: var(--accent-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(9, 9, 11, 0.06);
}

.nav-badge {
  background: var(--ai-border);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* Header KPI Metric Pills */
.kcdd-header-kpis {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.kpi-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.kpi-chip strong {
  color: var(--ink-primary);
  font-weight: 600;
}

.kpi-chip.kpi-primary strong {
  color: var(--accent-primary);
}

/* Role & Status Badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
}

.role-kassenwart,
.role-admin {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-border);
}

/* Main Workspace Container */
.kcdd-main {
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body:not(.kcdd-single-screen) .kcdd-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* Secondary Command Bar (38px Flat Toolbar) */
.workbench-command-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.workbench-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 2px;
}

/* Segmented Control (Split View Switcher & Filter Pills) */
.segmented-control {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.segment-btn {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}

.segment-btn.active {
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(9, 9, 11, 0.06);
}

/* Pill Toggle Button (Replaces ugly browser checkboxes in toolbar) */
.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--ink-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.pill-toggle input {
  margin: 0;
  accent-color: var(--accent-primary);
}

/* Review Status Pill (PC Verification State) */
.review-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}

.review-status-pill.status-ki_pruefen {
  background: var(--ai-bg);
  color: var(--ai-ink);
  border-color: var(--ai-border);
}

.review-status-pill.status-foto_geladen {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-border);
}

.review-status-pill.status-abgenommen {
  background: var(--verified-bg);
  color: var(--verified-ink);
  border-color: var(--verified-border);
}

.review-status-pill.status-offen {
  background: var(--bg-subtle);
  color: var(--ink-muted);
}

/* Termin Datepicker Dropdown */
.termin-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.termin-datepicker-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 284px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 12px;
  z-index: 1000;
  font-family: inherit;
  user-select: none;
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 10px;
}

.dp-nav-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.1s ease;
}

.dp-nav-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-border);
}

.dp-selects {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dp-selects select {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--ink-primary);
  cursor: pointer;
}

.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
  margin-bottom: 6px;
}

.dp-weekday {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  padding: 2px 0;
}

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.dp-day {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: all 0.12s ease;
}

.dp-day-disabled {
  color: var(--ink-faint);
  opacity: 0.22;
  cursor: default;
  pointer-events: none;
}

.dp-day-bowling {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  border: 1px solid var(--accent-border);
  cursor: pointer;
}

.dp-day-bowling:hover {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  transform: scale(1.08);
  z-index: 2;
  box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
}

.dp-day-selected {
  background: var(--accent-primary) !important;
  color: #ffffff !important;
  font-weight: 800;
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 3.5px var(--accent-primary);
}

.dp-day-bowling::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: currentColor;
}

.dp-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-muted);
}

/* Split-Screen Container (100dvh Content Area) */
.workbench-split {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0;
}

.workbench-split.layout-side {
  flex-direction: row;
}

.workbench-split.layout-top {
  flex-direction: column;
  overflow: visible;
}

.workbench-split.layout-matrix-only {
  flex-direction: column;
  overflow: visible;
}

.workbench-split.layout-matrix-only .workbench-photo-pane,
.workbench-split.layout-matrix-only .workbench-splitter-bar {
  display: none !important;
}

.workbench-split.layout-matrix-only .workbench-matrix-pane {
  width: 100%;
  flex: 1;
}

/* Left / Top Pane: Darkroom Bogen Inspector */
.workbench-photo-pane {
  background: var(--bg-inspector);
  color: #f4f4f5;
  border: 1px solid #27272a;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.workbench-split.layout-side .workbench-photo-pane {
  width: 36%;
  min-width: 320px;
  max-width: 600px;
  flex-shrink: 0;
}

.workbench-split.layout-top .workbench-photo-pane {
  height: 38vh;
  min-height: 140px;
  max-height: 85vh;
  flex-shrink: 0;
  overflow: hidden;
}

/* Dedicated Horizontal Splitter Bar */
.workbench-splitter-bar {
  height: 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: row-resize;
  user-select: none;
  touch-action: none;
  position: relative;
  z-index: 10;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
  margin: 4px 0;
  border-radius: var(--radius-sm);
}

.workbench-splitter-bar:hover,
.workbench-splitter-bar.is-dragging {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.splitter-handle-pill {
  width: 52px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-default);
  transition: all 0.15s ease;
}

.workbench-splitter-bar:hover .splitter-handle-pill,
.workbench-splitter-bar.is-dragging .splitter-handle-pill {
  background: var(--accent-primary);
  width: 72px;
  height: 5px;
}

.photo-pane-toolbar {
  padding: 5px 8px;
  background: var(--bg-inspector-bar);
  border-bottom: 1px solid #27272a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
}

.photo-pane-canvas-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: #09090b;
}

.photo-pane-canvas-wrap img,
.photo-pane-canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-sm);
  touch-action: none;
}

.photo-pane-canvas-wrap.is-scroll-mode img,
.photo-pane-canvas-wrap.is-scroll-mode canvas {
  max-height: none;
  width: 100%;
  height: auto;
}

.photo-pane-canvas-wrap canvas.corner-mode {
  cursor: crosshair;
}

/* Pending Guest Recognition Banner */
.pending-guest-banner {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  animation: fadeIn 150ms ease-out;
}

.pending-guest-banner strong {
  color: var(--ai-ink);
  font-weight: 600;
}

/* Right / Bottom Pane: Data Grid Surface (Airtable / Linear Grid Style) */
.workbench-matrix-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.matrix-form-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
}

.matrix-scroll-wrapper {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

/* Modern High-Density Data Grid */
.matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.matrix-table th,
.matrix-table td {
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 2px;
  text-align: center;
  vertical-align: middle;
  height: 23px;
}

/* Clean Compact SaaS Data Grid Table Header (Linear / Airtable Style) */
.matrix-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  color: var(--ink-secondary);
  z-index: var(--z-sticky-head);
  font-weight: 600;
  font-size: 11px;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  height: 38px;
  vertical-align: middle;
  padding: 2px 4px;
}

.matrix-table thead tr.price-subhead th {
  top: 38px;
  height: 20px;
  background: var(--bg-subtle);
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 0 2px;
  z-index: var(--z-sticky-head);
  border-bottom: 1px solid var(--border-default);
}

.matrix-col-rotate {
  height: 38px !important;
  min-width: 36px;
  max-width: 44px;
  vertical-align: middle !important;
  padding: 2px 1px !important;
  position: static;
  overflow: hidden;
  text-align: center;
}

.matrix-col-rotate > span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-secondary);
  line-height: 1.12;
  letter-spacing: -0.2px;
  text-align: center;
  word-break: break-word;
  white-space: normal;
}

/* Thick Block Dividers between Penalty Groups */
.matrix-table th.col-block-divider,
.matrix-table td.col-block-divider {
  border-right: 2.5px solid #475569 !important;
}

/* Status Cycle Pill Button (3 States: Anw. / Abg. / Unabg.) */
.status-cycle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  line-height: 1.15;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
  min-width: 42px;
}

.status-cycle-btn:active {
  transform: scale(0.94);
}

.status-cycle-btn.status-anwesend {
  background: var(--verified-bg);
  color: var(--verified-ink);
  border-color: var(--verified-border);
}

.status-cycle-btn.status-abgemeldet {
  background: var(--bg-muted);
  color: var(--ink-secondary);
  border-color: var(--border-default);
}

.status-cycle-btn.status-unabgemeldet {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-color: var(--danger-border);
}

.status-badge-static {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}

.status-badge-static.status-anwesend {
  background: var(--verified-bg);
  color: var(--verified-ink);
}

.status-badge-static.status-abgemeldet {
  background: #e2e8f0;
  color: #334155;
}

.status-badge-static.status-unabgemeldet {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

/* Sticky Player Column */
.matrix-sticky-col {
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: var(--z-sticky-cell);
  text-align: left !important;
  min-width: 118px;
  max-width: 130px;
  padding: 0 8px !important;
  border-right: 1px solid var(--border-default) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-table thead th.matrix-sticky-col {
  background: var(--bg-subtle);
  z-index: var(--z-sticky-corner);
}

/* Alternating Row Striping (Zebra) */
.matrix-table tbody tr:nth-child(even) td {
  background-color: var(--bg-subtle);
  color: var(--ink-primary);
}

.matrix-table tbody tr:nth-child(odd) td {
  background-color: var(--bg-surface);
  color: var(--ink-primary);
}

.matrix-table tbody tr:nth-child(even) td.matrix-sticky-col {
  background-color: var(--bg-subtle);
  color: var(--ink-primary);
}

.matrix-table tbody tr:nth-child(odd) td.matrix-sticky-col {
  background-color: var(--bg-surface);
  color: var(--ink-primary);
}

.matrix-table tbody tr:hover td,
.matrix-table tbody tr:hover td.matrix-sticky-col {
  background-color: var(--bg-muted) !important;
}

/* Subtle Row Hover & Active Row Crosshair */
.matrix-table tbody tr.matrix-row-active td {
  background-color: var(--accent-soft) !important;
}

.matrix-table tbody tr.matrix-row-active td.matrix-sticky-col {
  background-color: var(--accent-soft) !important;
  color: var(--accent-ink) !important;
  box-shadow: inset 3px 0 0 0 var(--accent-primary);
}

/* Guest Bowler Remove Pill Button */
.guest-remove-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--danger-ink);
  border: 1px solid var(--border-subtle);
  font-size: 9px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  margin-left: 4px;
  padding: 0;
  transition: all 120ms ease-out;
  vertical-align: middle;
}

.guest-remove-pill:hover {
  background: var(--danger-ink);
  color: #ffffff;
  border-color: var(--danger-ink);
  transform: scale(1.1);
}

/* Absent Bowlers (Abgemeldet & Unabgemeldet): Distinct Muted Appearance */
.matrix-table tbody tr.matrix-row-absent td {
  background-color: var(--bg-subtle) !important;
  color: var(--ink-muted) !important;
  opacity: 0.85;
}

.matrix-table tbody tr.matrix-row-absent td.matrix-sticky-col {
  background-color: var(--bg-muted) !important;
  color: var(--ink-muted) !important;
  box-shadow: inset 3px 0 0 0 var(--ink-faint);
  opacity: 1;
}

.matrix-table tbody tr.matrix-row-absent.status-is-unabgemeldet td.matrix-sticky-col {
  box-shadow: inset 3px 0 0 0 #ef4444;
}

.matrix-table tbody tr.matrix-row-absent td.matrix-sticky-col strong {
  font-weight: 600;
  color: var(--ink-primary);
}

.matrix-table tbody tr.matrix-row-absent .player-row-index {
  color: var(--ink-faint);
}

.matrix-table tbody tr.matrix-row-absent .tally-btn {
  opacity: 0.2;
}

.matrix-table tbody tr.matrix-row-absent .tally-input {
  color: var(--ink-muted);
}

.matrix-table tbody tr.matrix-row-absent:hover td {
  background-color: var(--bg-muted) !important;
}

.matrix-table tbody tr.matrix-row-absent:hover td.matrix-sticky-col {
  background-color: var(--bg-muted) !important;
}

.matrix-table tbody tr.matrix-row-absent:hover .tally-btn {
  opacity: 0.8;
}

/* Active Non-Zero Cells in Absent Rows remain highlighted */
.matrix-table tbody tr.matrix-row-absent td.tally-cell.cell-has-val {
  background-color: var(--accent-soft) !important;
  color: var(--ink-primary);
}

.player-row-index {
  display: inline-block;
  width: 18px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Tally Cell: Zero Clutter When Empty, Crisp Pill When Filled */
.tally-cell {
  min-width: 34px;
  max-width: 42px;
  padding: 0 !important;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.tally-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 25px;
  position: relative;
  padding: 0;
}

.tally-btn {
  flex: 1 1 0;
  width: auto;
  height: 25px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: opacity 100ms ease-out, background 100ms ease-out, transform 100ms ease-out;
  touch-action: manipulation;
}

.tally-cell:hover .tally-btn,
.tally-cell.cell-has-val .tally-btn,
.tally-cell:focus-within .tally-btn {
  opacity: 0.85;
}

.tally-btn:hover {
  opacity: 1 !important;
}

.tally-btn.plus:hover {
  color: #4338ca;
  background: #e0e7ff;
}

.tally-btn.minus:hover {
  color: #dc2626;
  background: #fee2e2;
}

.tally-btn:active {
  transform: scale(0.92);
}

.tally-input {
  flex: 0 0 17px;
  width: 17px;
  height: 21px;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font-weight: 700;
  font-size: 12px;
  padding: 0;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.tally-input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
  color: var(--ink-primary);
  outline: none;
}

.tally-input::-webkit-outer-spin-button,
.tally-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Active Non-Zero Cell (Single Accent Discipline: Indigo Tint) */
.tally-cell.cell-has-val {
  background-color: var(--accent-soft) !important;
}

.tally-input.has-val {
  color: var(--accent-ink);
  font-weight: 700;
}

/* AI-Recognized Cell State (Amber Review Highlight) */
.tally-cell.ai-filled-cell {
  background-color: var(--ai-bg) !important;
  box-shadow: inset 0 0 0 1px var(--ai-border);
}

.tally-cell.ai-filled-cell .tally-input.has-val {
  color: var(--ai-ink);
}

.tally-cell.ai-verified-cell {
  background-color: var(--verified-bg) !important;
  box-shadow: inset 0 0 0 1px var(--verified-border);
}

.tally-cell.ai-verified-cell .tally-input.has-val {
  color: var(--verified-ink);
}

.ai-cell-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ai-border);
  pointer-events: none;
}

/* Compact Inline Inputs & Selects inside Grid */
.player-status-select {
  height: 20px;
  padding: 0 4px !important;
  font-size: 11px !important;
  border-radius: 3px !important;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-weight: 500;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .player-status-select:hover {
    border-color: var(--border-default);
    background: var(--bg-subtle);
  }
}

.matrix-sum-cell {
  padding: 0 6px !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.compact-cell-input {
  height: 20px;
  padding: 0 4px !important;
  font-size: 11px !important;
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

/* Bottom Inspector Status Bar */
.workbench-footer-bar {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-subtle);
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-secondary);
  flex-shrink: 0;
}

.ai-cell-inspector-readout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Buttons (ui-skills: <=150ms compositor feedback, crisp 1px borders) */
.btn {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 120ms ease-out, opacity 120ms ease-out;
}

.btn:active {
  transform: scale(0.97);
}

.btn svg,
.kcdd-nav-link svg,
.segment-btn svg,
.review-status-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background: var(--accent-primary-hover);
  }
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-color: var(--border-default);
}

@media (hover: hover) and (pointer: fine) {
  .btn-secondary:hover {
    background: var(--bg-subtle);
    color: var(--ink-primary);
  }
}

.btn-dark {
  background: #27272a;
  color: #f4f4f5;
  border-color: #3f3f46;
}

.btn-amber {
  background: var(--ai-bg-active);
  color: var(--ai-ink);
  border-color: var(--ai-border);
  font-weight: 600;
}

.btn-success {
  background: var(--verified-border);
  color: #ffffff;
  font-weight: 600;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}

/* Cards, Forms & Modals */
.kcdd-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.form-control {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-surface);
  color: var(--ink-primary);
}

.form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-secondary);
}

/* Mobile Handset Upload View (?tab=upload) */
.mobile-upload-shell {
  max-width: 520px;
  width: 100%;
  margin: 12px auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.camera-dropzone {
  border: 1.5px dashed var(--accent-border);
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  display: block;
  margin: 12px 0;
}

.camera-dropzone strong {
  display: block;
  font-size: 13px;
  color: var(--accent-ink);
  margin-bottom: 4px;
}

/* Tables & Badges */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.kcdd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

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

.kcdd-table thead th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-secondary);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.badge-success { background: #16a34a; color: #ffffff; border: 1px solid #15803d; font-weight: 700; }
.badge-warning { background: var(--ai-bg); color: var(--ai-ink); border: 1px solid var(--ai-border); }
.badge-danger  { background: #dc2626; color: #ffffff; border: 1px solid #b91c1c; font-weight: 700; }
.badge-neutral { background: var(--bg-subtle); color: var(--ink-secondary); border: 1px solid var(--border-default); }
.badge-info    { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-border); }

[data-theme="dark"] .badge-danger {
  background: #dc2626 !important;
  color: #ffffff !important;
  border-color: #f87171 !important;
}

[data-theme="dark"] .badge-success {
  background: #059669 !important;
  color: #ffffff !important;
  border-color: #34d399 !important;
}

.salden-player-row.salden-row-debtor {
  background-color: rgba(254, 242, 242, 0.45);
}

[data-theme="dark"] .salden-player-row.salden-row-debtor {
  background-color: rgba(239, 68, 68, 0.08) !important;
}

.alert {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.alert-success { background: var(--verified-bg); color: var(--verified-ink); border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger-border); }

.lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.55);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: 16px;
  max-height: 100dvh;
  overflow-y: auto;
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }

/* Reduced Motion Compliance (ui-skills / fixing-motion-performance) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Mobile & Tablet Viewport Adjustments */
@media (max-width: 1023px) {
  .kcdd-header-inner {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
  }
  .workbench-split.layout-side {
    flex-direction: column;
  }
  .workbench-split.layout-side .workbench-photo-pane {
    width: 100%;
    max-width: 100%;
    height: 250px;
  }
  .tally-btn {
    opacity: 1;
    width: 20px;
    height: 28px;
    background: var(--bg-subtle);
  }
  .tally-cell {
    min-width: 56px;
  }
  .matrix-table th,
  .matrix-table td {
    height: 32px;
  }
}



/* ========================================================
   5-STUFEN UPLOAD-WIZARD STYLES (?tab=upload)
   ======================================================== */
.upload-wizard-container {
  max-width: 840px;
  width: 100%;
  margin: 16px auto;
  padding: 0 12px;
}

/* Stepper Bar */
.wizard-stepper-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.wizard-stepper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  flex: 1;
}

.step-indicator {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 2px solid var(--border-color);
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13.5px;
  transition: all 0.25s ease;
  flex-shrink: 0;
}

.step-check {
  display: none;
}

.wizard-step.active .step-indicator {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.20);
}

.wizard-step.completed .step-indicator {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
}

.wizard-step.completed .step-circle {
  display: none;
}

.wizard-step.completed .step-check {
  display: inline-block;
}

.step-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.step-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  line-height: 1;
  margin-bottom: 2px;
}

.step-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  line-height: 1.2;
  white-space: nowrap;
}

.wizard-step.active .step-name {
  color: var(--ink-primary);
  font-weight: 700;
}

.wizard-step.completed .step-name {
  color: #059669;
}

.wizard-step-divider {
  flex: 1;
  height: 2px;
  background: var(--border-color);
  min-width: 14px;
  margin-top: 17px;
  transition: background 0.3s ease;
}

/* Callout Guidance */
.crop-guidance-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: #fffbeb;
  border: 1px solid #fef08a;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 12.5px;
  color: #78350f;
  line-height: 1.45;
}

.crop-guidance-callout .callout-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.wizard-step.completed + .wizard-step-divider {
  background: #059669;
}

@media (max-width: 680px) {
  .wizard-stepper-wrap {
    padding: 12px 6px;
  }
  .wizard-step {
    flex: 1;
    min-width: 0;
  }
  .wizard-step .step-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: 4px;
  }
  .wizard-step .step-label {
    display: none;
  }
  .wizard-step .step-name {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-align: center;
    white-space: normal;
    word-break: normal;
    display: block;
    width: 100%;
  }
  .wizard-step.active .step-name {
    font-weight: 700;
    color: #4f46e5;
  }
}

/* Card Container */
.wizard-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.wizard-card-header {
  margin-bottom: 24px;
}

.wizard-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4f46e5;
  background: rgba(79, 70, 229, 0.10);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.wizard-title {
  font-size: 18px;
  margin: 0 0 6px;
  color: var(--ink-primary);
  font-weight: 700;
}

.wizard-desc {
  font-size: 13.5px;
  color: var(--ink-secondary);
  margin: 0;
  line-height: 1.45;
}

/* Step 1: Radio Option Cards Grid */
.termin-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 640px) {
  .termin-options-grid {
    grid-template-columns: 1fr;
  }
}

.termin-option-card {
  display: flex;
  gap: 12px;
  padding: 18px;
  background: var(--bg-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.termin-option-card:hover {
  border-color: #818cf8;
  background: var(--bg-card);
}

.termin-option-card.selected {
  border-color: #4f46e5;
  background: rgba(79, 70, 229, 0.04);
  box-shadow: 0 0 0 1px #4f46e5;
}

.option-radio-wrap {
  padding-top: 2px;
}

.option-radio-wrap input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #4f46e5;
  cursor: pointer;
}

.option-content {
  flex: 1;
  min-width: 0;
}

.option-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.option-icon {
  font-size: 16px;
}

.option-desc {
  font-size: 12px;
  color: var(--ink-secondary);
  margin: 0 0 8px;
  line-height: 1.4;
}

.new-date-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.new-date-hint {
  font-size: 11.5px;
  color: #4f46e5;
  font-weight: 600;
}

/* Step 2: Dropzone & Summary */
.wizard-summary-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 13px;
}

.summary-label {
  color: var(--ink-secondary);
}

.summary-value {
  color: var(--ink-primary);
}

.wizard-dropzone {
  border: 2px dashed #818cf8;
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--radius-lg);
  padding: 44px 20px;
  text-align: center;
  cursor: pointer;
  display: block;
  margin-bottom: 20px;
  transition: all 0.2s ease;
}

.wizard-dropzone:hover,
.wizard-dropzone.dragover {
  border-color: #4f46e5;
  background: rgba(99, 102, 241, 0.12);
  transform: translateY(-1px);
}

.dropzone-illu {
  color: #4f46e5;
  margin-bottom: 12px;
}

.dropzone-title {
  display: block;
  font-size: 15px;
  color: var(--ink-primary);
  margin-bottom: 6px;
}

.dropzone-subtitle {
  display: block;
  font-size: 12.5px;
  color: var(--ink-secondary);
}

.file-success-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  color: #166534;
  font-size: 13px;
  margin-bottom: 20px;
}

/* Step 3: Canvas Viewport & Toolbar */
.wizard-canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #0f172a;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 10px 14px;
  flex-wrap: wrap;
}

.toolbar-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crop-hint-badge {
  background: #d97706;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.wizard-canvas-viewport {
  background: #020617;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  max-height: 55vh;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  touch-action: none;
  user-select: none;
}

.wizard-canvas-viewport canvas {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  object-fit: contain;
  cursor: crosshair;
  touch-action: none;
}

.wizard-ai-options-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
}

/* Step 4: Pulse Spinner */
.wizard-scanner-pulse {
  position: relative;
  width: 90px;
  height: 90px;
  margin: 0 auto;
}

.scanner-spinner {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 5px solid rgba(79, 70, 229, 0.15);
  border-top-color: #4f46e5;
  animation: wizard-spin 1s linear infinite;
}

.scanner-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 34px;
}

@keyframes wizard-spin {
  to { transform: rotate(360deg); }
}

.wizard-progress-pills {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* Wizard Footer Navigation */
.wizard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 700;
}

/* ==========================================================================
   APP SHELL, SIDEBAR NAVIGATION & THEME SWITCH
   ========================================================================== */
.kcdd-app-shell {
  display: flex;
  min-height: 100dvh;
  width: 100%;
}

/* Sidebar (Desktop Sticky Left / Mobile Drawer) */
.kcdd-sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.kcdd-sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  min-height: 56px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink-primary);
}

.sidebar-brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.sidebar-brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1.1;
}

.sidebar-brand-sub {
  font-size: 10px;
  color: var(--ink-muted);
  display: block;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.sidebar-close-btn:hover {
  color: var(--ink-primary);
}

.kcdd-sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--ink-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 12.5px;
  transition: background-color 0.15s ease, color 0.15s ease;
  position: relative;
}

.sidebar-nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--ink-primary);
}

.sidebar-nav-item.active {
  background-color: var(--accent-soft);
  color: var(--accent-primary);
  font-weight: 700;
}

.sidebar-nav-item.active svg {
  color: var(--accent-primary);
}

.nav-badge {
  margin-left: auto;
  background: #f59e0b;
  color: #1e1b4b;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.kcdd-sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-surface);
}

/* Theme Switch Slider */
.theme-slider-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.theme-icon-indicator {
  font-size: 13px;
  user-select: none;
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
  margin: 0 4px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.theme-slider-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  border-radius: 22px;
  transition: background-color 0.25s ease;
}

[data-theme="dark"] .theme-slider-track {
  background-color: #4b5563;
}

.theme-slider-thumb {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.theme-switch input:checked + .theme-slider-track {
  background-color: var(--accent-primary);
}

.theme-switch input:checked + .theme-slider-track .theme-slider-thumb {
  transform: translateX(18px);
}

.sidebar-user-block {
  font-size: 11px;
}

/* Layout Main Content Area */
.kcdd-layout-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
}

.kcdd-topbar {
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px;
  color: var(--ink-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.hamburger-btn:hover {
  background: var(--bg-subtle);
}

.topbar-brand-mobile {
  display: none;
  align-items: center;
  gap: 6px;
}

.topbar-mobile-logo {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.topbar-mobile-name {
  font-weight: 800;
  font-size: 14px;
}

.topbar-page-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

/* Mobile & Tablet Off-Canvas Drawer (max-width: 1023px) */
@media (max-width: 1023px) {
  .hamburger-btn {
    display: inline-flex;
  }
  .topbar-brand-mobile {
    display: inline-flex;
  }
  .sidebar-close-btn {
    display: inline-flex;
  }
  .kcdd-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
    z-index: 1000;
  }
  .kcdd-sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-backdrop.is-open {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  .topbar-page-title {
    display: none;
  }
}

/* Google Pixel & Small Viewports Optimization (<= 440px) */
@media (max-width: 440px) {
  .kcdd-topbar {
    padding: 0 10px;
    height: 48px;
  }
  .kcdd-main {
    padding: 10px 8px;
  }
  .kcdd-header-kpis {
    gap: 4px;
  }
  .kpi-chip {
    padding: 3px 6px;
    font-size: 10px;
  }
}

/* Responsive Upload Wizard for Mobile (Google Pixel etc.) */
@media (max-width: 640px) {
  .upload-wizard-container {
    padding: 0 4px;
    margin: 8px auto;
  }
  .wizard-card {
    padding: 16px 12px;
  }
  .wizard-card-header {
    margin-bottom: 14px;
  }
  .wizard-stepper-wrap {
    padding: 10px 8px;
    margin-bottom: 12px;
  }
  .step-indicator {
    width: 28px;
    height: 28px;
    font-size: 11.5px;
  }
  .wizard-step-divider {
    margin-top: 13px;
    min-width: 6px;
  }
  .wizard-dropzone {
    padding: 24px 12px;
  }
  .dropzone-title {
    font-size: 13.5px;
  }
  .dropzone-subtitle {
    font-size: 11.5px;
  }
  .wizard-canvas-toolbar {
    padding: 8px 10px;
    gap: 6px;
  }
  .crop-hint-badge {
    font-size: 11px;
    padding: 3px 8px;
  }
  .wizard-canvas-viewport {
    min-height: 220px;
    max-height: 50vh;
  }
  .wizard-ai-options-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
    margin: 12px 0;
  }
  .wizard-footer {
    flex-direction: column-reverse;
    gap: 8px;
    align-items: stretch;
    margin-top: 16px;
    padding-top: 12px;
  }
  .wizard-footer .btn {
    width: 100%;
    justify-content: center;
    padding: 10px 14px;
    font-size: 13px;
  }
  .wizard-footer div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .crop-guidance-callout {
    padding: 8px 10px;
    font-size: 11.5px;
    gap: 8px;
  }
}

/* Regelbuch Drag & Drop Styles */
.regel-draggable {
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.regel-draggable.is-dragging {
  opacity: 0.35 !important;
  transform: scale(0.98);
  outline: 2px dashed var(--accent-primary);
  outline-offset: 2px;
}

.regel-cards-grid.drag-over {
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  outline: 2px dashed var(--accent-primary);
  outline-offset: 4px;
}

.regel-drag-handle {
  transition: color 0.12s ease;
}

.regel-drag-handle:hover {
  color: var(--accent-primary) !important;
}
