/* ==========================================================================
   AuftragsManager Pro — Main Stylesheet
   ==========================================================================
   Table of Contents:
   1.  CSS Custom Properties (Design Tokens)
   2.  Reset & Base
   3.  App Header & Logo
   4.  Tabs & Tab Content
   5.  Content Area & Toolbar
   6.  Buttons
   7.  Tables
   8.  Table Inputs
   9.  Calculated Fields
   10. Combobox Component
   11. Pause Mode Component
   12. Date Wrapper & Day Labels
   13. Holiday Items
   14. Summary Grid & Cards
   15. Invoice Layout & Sidebar
   16. Form Groups & Dividers
   17. Invoice Paper (Print Preview)
   18. Overlay & Modal
   19. Password Component
   20. Encryption Badge
   21. Options Grid & Cards
   22. Status Bar
   23. Info Grid
   24. Toast Notifications
   25. Logo Upload
   26. Search Combobox
   27. Column Config Items
   28. Payment & Due Badges
   29. Chart Components
   30. Filter Toolbar & Groups
   31. Utility Classes
   32. Editor & Preview Layout
   33. Tab Switcher (Overlay Tabs)
   34. Responsive Breakpoints
   35. Scrollbar Styling
   ========================================================================== */


/* ==========================================================================
   1. CSS Custom Properties (Design Tokens)
   ========================================================================== */

:root {
  /* Backgrounds */
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --surface3: #2e3344;

  /* Borders */
  --border: #353a4a;
  --border-light: #454b5e;

  /* Text */
  --text: #e8eaf0;
  --text-dim: #9498a8;
  --text-muted: #6b7084;

  /* Accent */
  --accent: #4f8cff;
  --accent-hover: #6da0ff;
  --accent-dim: rgba(79, 140, 255, 0.12);

  /* Semantic Colors */
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);

  /* Radii */
  --radius: 8px;
  --radius-lg: 12px;

  /* Shadows & Transitions */
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --tr: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ==========================================================================
   2. Reset & Base
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ==========================================================================
   3. App Header & Logo
   ========================================================================== */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.app-header.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
  border: none;
  padding: 0;
}
.header-toggle {
  /* Absolute so it does not participate in the flex flow and cannot
     overlap or shrink the nav tabs. Sticky containers act as a
     containing block for absolute children. */
  position: absolute;
  bottom: -1px;     /* sits on the bottom border of the header */
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  font-size: 10px;
  padding: 2px 10px;
  color: var(--text-dim);
  z-index: 101;
  line-height: 1.4;
}
.header-toggle:hover { background: var(--bg-hover); }
.header-show {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
}
.header-show:hover { background: var(--bg-hover); }

.app-logo {
  font-weight: 700;
  font-size: 17px;
  color: var(--accent);
  white-space: nowrap;
}

.app-logo span {
  color: var(--text-dim);
  font-weight: 400;
}


/* ==========================================================================
   4. Tabs & Tab Content
   ========================================================================== */

.tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
}

.tab {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: 0;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  transition: var(--tr);
  white-space: nowrap;
  position: relative;
  font-family: inherit;
}

.tab:hover {
  color: var(--text);
  background: var(--surface2);
}

.tab.active {
  color: var(--accent);
  background: var(--surface2);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.tab-content {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Tabs with natural-height content (no table to fill) scroll internally */
#tab-generator.active,
#tab-optionen.active {
  overflow-y: auto;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ==========================================================================
   5. Content Area & Toolbar
   ========================================================================== */

.content {
  padding: 16px 20px 3px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}


/* ==========================================================================
   6. Buttons
   ========================================================================== */

.btn {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--tr);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface3);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: transparent;
}

.btn-success {
  background: var(--green-dim);
  color: var(--green);
  border-color: transparent;
}

/* Invoice action button group */
.inv-action-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.inv-action-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding-left: 12px;
  padding-right: 12px;
  text-align: left;
  box-sizing: border-box;
}

.inv-save-btn {
  background: var(--green-dim);
  color: #166534; /* WCAG AA dark green on light-green bg */
  border: 1px solid rgba(22, 101, 52, 0.2);
}

.inv-save-btn:hover {
  background: rgba(74, 222, 128, 0.2);
  color: #14532d;
}

.btn-purple {
  background: var(--purple-dim);
  color: var(--purple);
  border-color: transparent;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}


/* ==========================================================================
   7. Tables
   ========================================================================== */

.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  /* max-height removed; parent flex layout handles height */
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

thead th {
  background: var(--surface2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

/* Column resize handle */
thead th .col-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  z-index: 2;
}
thead th .col-resize:hover,
thead th .col-resize.active {
  background: var(--accent, #4a7c59);
  opacity: 0.5;
}

/* Sort indicator */
thead th .sort-indicator {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  opacity: 0.6;
  vertical-align: middle;
  font-weight: 400;
}
thead th:hover .sort-indicator {
  opacity: 1;
}
thead th .sort-indicator.active {
  opacity: 1;
  color: var(--accent, #4a7c59);
  font-weight: 700;
}

/* Needed for resize handles */
table.resizing {
  cursor: col-resize !important;
  user-select: none;
}
table.resizing * {
  cursor: col-resize !important;
}

/* Sticky first column */
thead th:first-child,
tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 11;
  min-width: 40px;
}

thead th:first-child {
  z-index: 12;
  background: var(--surface2);
}

tbody td:first-child {
  background: var(--surface);
}

tr:hover td:first-child {
  background: var(--surface2);
}

tbody td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover td {
  background: var(--surface2);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Flagged rows (zur Überprüfung) */
tr.row-flagged td {
  background: #fff0f0 !important;
  border-bottom-color: #f5c6c6;
}
tr.row-flagged:hover td {
  background: #ffe0e0 !important;
}
tr.row-flagged td:first-child {
  background: #fff0f0 !important;
  border-left: 3px solid #d32f2f;
}

/* Cleared rows (geprüft & freigegeben) */
tr.row-cleared td {
  background: #f0fff0 !important;
  border-bottom-color: #c6f5c6;
}
tr.row-cleared:hover td {
  background: #e0ffe0 !important;
}
tr.row-cleared td:first-child {
  background: #f0fff0 !important;
  border-left: 3px solid #4caf50;
}

/* Neue Einsaetze (frisch angelegt, noch nicht bearbeitet) hervorheben */
tr.row-new td {
  background: #fff7d6 !important;
  border-bottom-color: #f0d98a;
}
tr.row-new:hover td {
  background: #fff0b8 !important;
}
tr.row-new td:first-child {
  background: #fff7d6 !important;
  border-left: 4px solid #f0a500;
}

/* Flag button */
.btn-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  margin-left: 4px;
  opacity: 0.3;
  vertical-align: middle;
  border-radius: 3px;
}
.btn-flag:hover {
  opacity: 0.7;
  background: #ffebee;
}
.btn-flag.active {
  opacity: 1;
  color: #d32f2f;
}

/* Active filter highlight */
.filter-group select.filter-active {
  border-color: #e6a817;
  background-color: #fef9e7;
  box-shadow: 0 0 0 2px rgba(230, 168, 23, 0.25);
}

/* Export status icons (Einsätze tab) */
.export-icon {
  display: inline-block;
  font-size: 13px;
  margin-left: 4px;
  cursor: default;
  vertical-align: middle;
}

/* Export toggle buttons (Leistungsorte tab) */
.export-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-left: 6px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  vertical-align: middle;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.export-toggle:hover { opacity: 0.7; }
.export-toggle.active-ln {
  opacity: 1;
  background: #e8f5e9;
  border-color: #4caf50;
}
.export-toggle.active-inv {
  opacity: 1;
  background: #e3f2fd;
  border-color: #1976d2;
}

/* Leistungsorte row export status */
tr.ort-ln-exported td { background: #f0fff0 !important; }
tr.ort-ln-exported td:first-child { border-left: 3px solid #4caf50; }
tr.ort-inv-exported td { background: #f0f4ff !important; }
tr.ort-inv-exported td:first-child { border-left: 3px solid #1976d2; }
tr.ort-both-exported td { background: #edfaed !important; }
tr.ort-both-exported td:first-child { border-left: 3px solid #2e7d32; }

/* Magic Fill Button (column header) */
.btn-col-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 16px;
  margin-left: 4px;
  padding: 0 3px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-dim, #999);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.btn-col-filter:hover {
  background: var(--accent-dim, #dbeafe);
  color: var(--accent, #1e40af);
}
.btn-col-filter.active {
  background: var(--accent-dim, #dbeafe);
  color: var(--accent, #1e40af);
  font-weight: 700;
}

.btn-magic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 3px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: var(--tr);
}

.btn-magic:hover {
  background: var(--accent);
  color: #fff;
}


/* ==========================================================================
   8. Table Inputs
   ========================================================================== */

table input[type="text"],
table input[type="number"],
table input[type="date"],
table input[type="time"],
table select {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 6px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 11px;
  width: 100%;
  min-width: 70px;
  transition: var(--tr);
}

table input:focus,
table select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

table input[type="date"] {
  min-width: 110px;
}

table input[type="time"] {
  min-width: 80px;
}

table input[type="number"] {
  min-width: 60px;
}


/* ==========================================================================
   9. Calculated Fields
   ========================================================================== */

.calc-field {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--green);
  font-weight: 500;
  white-space: nowrap;
}

.calc-field.cur::before {
  content: '\20AC\00A0';
  color: var(--text-muted);
}

.calc-field.overridden {
  color: #f5a623;
  cursor: pointer;
}

.calc-field.overridden::after {
  content: '\00A0\270E';
  font-size: 9px;
  opacity: 0.7;
}

.calc-override-input {
  width: 72px;
  text-align: right;
  border: 1px solid #f5a623;
  border-radius: 3px;
  padding: 1px 4px;
  background: var(--bg2, #1e1e2e);
  color: var(--text, #cdd6f4);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  outline: none;
}


/* ==========================================================================
   10. Combobox Component
   ========================================================================== */

.combobox-wrapper {
  position: relative;
  min-width: 110px;
}

.combobox-dropdown {
  position: fixed;
  background: var(--surface3);
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 150px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
  box-shadow: var(--shadow);
  min-width: 140px;
}

.combobox-dropdown.show {
  display: block;
}

.combobox-option {
  padding: 5px 8px;
  cursor: pointer;
  font-size: 11px;
  transition: var(--tr);
}

.combobox-option:hover {
  background: var(--accent-dim);
  color: var(--accent);
}


/* ==========================================================================
   11. Pause Mode Component
   ========================================================================== */

.pause-mode-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 130px;
}

.pause-mode-wrapper select {
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 4px;
  font-size: 0.72rem;
  flex: 1;
  cursor: pointer;
}

.pause-mode-wrapper input {
  width: 48px;
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 4px;
  font-size: 0.72rem;
  text-align: center;
}


/* ==========================================================================
   12. Date Wrapper & Day Labels
   ========================================================================== */

.date-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 115px;
  max-width: 125px;
  width: fit-content;
}

.date-wrapper input[type="date"] {
  width: 100%;
  font-size: 11px;
  padding: 2px 4px;
}

.date-day-label {
  font-size: 9px;
  font-weight: 600;
  /* Kein letter-spacing: die 0.3px liessen den Abstand nach dem Komma
     ("Mi, 17.06.2026") breiter wirken als ein normales Leerzeichen. */
  text-align: center;
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
}

.date-day-label.date-weekend {
  color: var(--orange);
  background: var(--orange-dim);
}

.date-day-label.date-holiday {
  color: var(--red);
  background: var(--red-dim);
}

.date-day-label.date-normal {
  color: var(--text-muted);
}


/* ==========================================================================
   13. Holiday Items
   ========================================================================== */

.holiday-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.holiday-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.holiday-item .holiday-date-label {
  font-size: 11px;
  color: var(--text);
  min-width: 110px;
  white-space: nowrap;
}

.holiday-item .holiday-name-edit {
  flex: 1;
  font-size: 11px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 3px 6px;
  font-family: inherit;
  transition: var(--tr);
}

.holiday-item .holiday-name-edit:hover {
  border-color: var(--border);
  background: var(--surface3);
}

.holiday-item .holiday-name-edit:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface3);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.holiday-add-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.holiday-add-row .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

.holiday-add-row .holiday-date-input {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 11px;
  width: 130px;
}

.holiday-add-row .holiday-name-input {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 11px;
}

.holiday-add-row .holiday-date-input:focus,
.holiday-add-row .holiday-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}


/* Profile / Mandanten */
.profile-list {
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--tr);
}

.profile-item.active {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.profile-name {
  font-size: 12px;
  color: var(--text);
  flex: 1;
  font-weight: 500;
}

.profile-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
}

.profile-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.profile-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.profile-name-input {
  flex: 1;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 11px;
}

.profile-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* BAU Kalkulator */
.bau-calc { margin-top: 6px; }
.bau-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.bau-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.bau-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  max-width: 160px;
}
.bau-currency { font-size: 11px; color: var(--text-muted); }
.bau-input-wrap input {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 11px;
  text-align: right;
}
.bau-input-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.bau-results {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.bau-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 0;
}
.bau-result-row.bau-highlight {
  color: var(--text);
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding-top: 5px;
}
.bau-value { font-family: 'JetBrains Mono', monospace; font-size: 11px; }
.bau-bar-wrap {
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.bau-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
  width: 0;
}

/* Custom Invoice Positions. Inputs intentionally inherit the global input
   styling so the additional positions look identical to the Quick-Pos box at
   the top. Only the focus highlight is kept here. */
.custom-pos-list { display: flex; flex-direction: column; gap: 8px; }
.custom-pos-row input:focus,
.custom-pos-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.profile-indicator {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

/* ==========================================================================
   14. Summary Grid & Cards
   ========================================================================== */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

/* Place summary cards and USt panel side by side to save vertical space.
   Summary cards keep their natural width; USt panel fills the remaining
   horizontal space to the right of the OFFEN card. */
/* ===== Toolbar stats bar (Rechnungen / Gesamt / Bezahlt / Offen) ===== */
.toolbar .toolbar-summary {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.toolbar .toolbar-summary:empty {
  display: none;
}
.toolbar .toolbar-summary .stat-pill {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  line-height: 1;
  white-space: nowrap;
}
.toolbar .toolbar-summary .stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  margin-bottom: 4px;
  line-height: 1;
}
.toolbar .toolbar-summary .stat-value {
  font-size: 15px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent, currentColor);
  line-height: 1;
}
.toolbar .toolbar-summary .stat-pill.is-zero .stat-value {
  color: var(--text-muted, #9ca3af);
  font-weight: 600;
}

/* USt-Panel inline in toolbar row. Cards visually match the left stat-pills:
   label above value, vertical stack, same padding and font sizes. */
.toolbar .ust-panel-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
}
.toolbar .ust-panel-inline:empty {
  display: none;
}
.toolbar .ust-panel-inline .ust-panel-header { display: none; }
.toolbar .ust-panel-inline .ust-panel-grid {
  display: inline-flex;
  flex-wrap: nowrap;
  grid-template-columns: none;
  gap: 8px;
  margin: 0;
}
.toolbar .ust-panel-inline .ust-card {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  line-height: 1;
  white-space: nowrap;
}
.toolbar .ust-panel-inline .ust-card .ust-label {
  font-size: 9px;
  font-weight: 600;
  margin: 0 0 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted, #6b7280);
  line-height: 1;
}
.toolbar .ust-panel-inline .ust-card .ust-value {
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
}
.toolbar .ust-panel-inline .ust-card .ust-sub { display: none; }

.inv-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: stretch;
  margin-bottom: 10px;
}
/* Summary cards as a single-row inline flex pill row (no wrapping into 2 rows). */
.inv-summary-row > .summary-grid {
  flex: 0 1 auto;
  margin-bottom: 0;
  display: inline-flex;
  flex-wrap: nowrap;
  grid-template-columns: none;
  gap: 4px;
  min-width: 0;
  width: auto;
}
.inv-summary-row > .summary-grid .summary-card {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.inv-summary-row > .summary-grid .summary-card .summary-label {
  font-size: 9px;
  margin: 0;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.inv-summary-row > .summary-grid .summary-card .summary-value {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
/* Compact USt panel: do NOT stretch to fill the row. Width hugs content so
   the panel sits beside summary cards (or toolbar) without wasting space. */
.inv-summary-row > .ust-panel {
  flex: 0 1 auto;
  margin-bottom: 0;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.inv-summary-row > .ust-panel:empty {
  display: none;
}
.inv-summary-row > .ust-panel .ust-panel-header {
  display: none; /* title is implicit; values are self-explanatory */
}
.inv-summary-row > .ust-panel .ust-panel-grid {
  display: inline-flex;
  flex-wrap: wrap;
  grid-template-columns: none;
  gap: 4px;
  margin: 0;
}
.inv-summary-row > .ust-panel .ust-card {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.inv-summary-row > .ust-panel .ust-card .ust-label {
  font-size: 9px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.inv-summary-row > .ust-panel .ust-card .ust-value {
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
}
.inv-summary-row > .ust-panel .ust-card .ust-sub {
  display: none;
}
@media (max-width: 900px) {
  .inv-summary-row > .summary-grid,
  .inv-summary-row > .ust-panel {
    flex: 1 1 100%;
  }
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
}

.summary-card .summary-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.summary-card .summary-value {
  font-size: 20px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.summary-card .summary-value.color-accent {
  color: var(--accent);
}

.summary-card .summary-value.color-green {
  color: var(--green);
}

.summary-card .summary-value.color-orange {
  color: var(--orange);
}

.summary-card .summary-value.color-danger {
  color: var(--danger, #ef5350);
}

.ust-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 16px;
}

.ust-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ust-panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}

.ust-panel-hint {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}

.ust-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.ust-card {
  background: var(--surface2, rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.ust-card .ust-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.ust-card .ust-value {
  font-size: 18px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.ust-card .ust-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

.ust-card.primary {
  border-color: var(--accent, #4a9eff);
  background: rgba(74, 158, 255, 0.08);
}

.ust-card.primary .ust-value {
  color: var(--accent, #4a9eff);
}


/* ==========================================================================
   15. Invoice Layout & Sidebar
   ========================================================================== */

.invoice-layout {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 0;
  flex: 1;
}

.invoice-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  width: 400px;
  min-width: 260px;
  max-width: 680px;
  flex-shrink: 0;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Drag handle between sidebar and preview */
.inv-layout-resizer {
  width: 14px;
  flex-shrink: 0;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  position: relative;
  z-index: 1;
}
.inv-layout-resizer:hover .inv-layout-resizer-handle,
.inv-layout-resizer.dragging .inv-layout-resizer-handle {
  background: var(--accent, #3b82f6);
  height: 64px;
  opacity: 1;
}
.inv-layout-resizer-handle {
  width: 3px;
  height: 40px;
  background: var(--border, #d0d0d0);
  border-radius: 4px;
  transition: background 0.15s, height 0.15s, opacity 0.15s;
  opacity: 0.6;
  pointer-events: none;
}

.invoice-preview-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  overflow: auto;
  max-height: calc(100vh - 140px);
}

@media (max-width: 900px) {
  .invoice-layout {
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   16. Form Groups & Dividers
   ========================================================================== */

.form-group {
  margin-bottom: 12px;
}

/* Label + Button inline row (e.g. Rechnungsnr. + Auto) */
.label-btn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
}

.label-inline-btn {
  font-size: 10px;
  padding: 2px 8px;
  height: auto;
  flex-shrink: 0;
}

/* Leistungsdatum/-zeitraum */
.period-group {
  margin-bottom: 24px;
}

.period-single {
  margin-top: 8px;
}

.period-single input[type="date"] {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  transition: var(--tr);
}

.period-single input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.period-range {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

.period-range input[type="date"] {
  flex: 1;
  min-width: 0;
  width: 0;
  box-sizing: border-box;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  transition: var(--tr);
}

.period-range input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.period-separator {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  padding: 0 4px;
  user-select: none;
}

.form-group label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  transition: var(--tr);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.form-group textarea {
  resize: vertical;
  min-height: 50px;
}

.form-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* §13b Reverse Charge */
.rc-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  user-select: none;
  background: var(--surface2);
  transition: border-color .15s, background .15s;
}

.rc-toggle-row:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.rc-toggle-row.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.rc-icon { font-size: 14px; flex-shrink: 0; }

.rc-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.rc-hint {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(74,137,255,.3);
}

.rc-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background .2s;
}

.rc-toggle-row.active .rc-switch { background: var(--accent); }

.rc-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.rc-toggle-row.active .rc-knob { left: 18px; }

.rc-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 11px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
}

.rc-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.rc-hint-text {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.4;
}

/* RC Customizer */
.rc-customizer {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.rc-customizer-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  background: var(--surface2);
  user-select: none;
  transition: background .15s;
}

.rc-customizer-title:hover { background: var(--surface3, rgba(255,255,255,.06)); color: var(--text); }

.rc-customizer-arrow { margin-left: auto; font-size: 10px; transition: transform .2s; }
.rc-customizer.open .rc-customizer-arrow { transform: rotate(180deg); }

.rc-customizer-body {
  display: none;
  padding: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-direction: column;
  gap: 8px;
}

.rc-customizer.open .rc-customizer-body { display: flex; }

.rc-cust-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.rc-cust-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.rc-cust-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.rc-color-swatch {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  height: 28px !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px !important;
  flex-shrink: 0 !important;
  appearance: none;
  -webkit-appearance: none;
  background: none;
  overflow: hidden;
}

.rc-color-swatch::-webkit-color-swatch-wrapper { padding: 0; border-radius: 2px; }
.rc-color-swatch::-webkit-color-swatch { border: none; border-radius: 2px; }

.rc-hex-input {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 8px;
  box-sizing: border-box;
  height: 28px;
}

.rc-cust-select {
  width: 100%;
  font-size: 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 4px 6px;
  cursor: pointer;
}

.rc-align-group {
  display: flex;
  gap: 3px;
  width: 100%;
}

.rc-align-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}

.rc-align-btn:hover { border-color: var(--accent); color: var(--accent); }
.rc-align-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.rc-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.rc-slider-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.rc-slider-val {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
  min-width: 28px;
  text-align: right;
  flex-shrink: 0;
}

.rc-reset-btn {
  align-self: flex-start;
  font-size: 10px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}

.rc-reset-btn:hover { border-color: var(--danger); color: var(--danger); }

/* VIES VAT Validation */
.vies-check-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 11px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
}
.vies-check-btn:hover { border-color: var(--accent); color: var(--accent); }
.vies-check-btn.loading { opacity: .6; pointer-events: none; }
.vies-result {
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.5;
  border: 1px solid;
}
.vies-result.valid { background: rgba(54,211,153,.1); border-color: rgba(54,211,153,.4); color: #1a7a52; }
.vies-result.invalid { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.4); color: #b91c1c; }
.vies-result.warning { background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.4); color: #92400e; }
.vies-stamp { font-size: 9px; opacity: .65; margin-top: 3px; font-family: 'JetBrains Mono', monospace; display: block; }


/* ==========================================================================
   17. Invoice Paper (Print Preview)
   ========================================================================== */

.invoice-paper {
  background: #fff;
  color: #1a1a2e;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.5;
  margin: 0 auto;
  position: relative;
  width: 210mm;
  min-height: 297mm;
  padding: 20mm;
  box-sizing: border-box;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

/* Fold marks */
.invoice-paper .falz-top,
.invoice-paper .falz-mid,
.invoice-paper .falz-bot {
  position: absolute;
  left: 0;
  width: 6mm;
  border-top: 1px solid #ccc;
  display: none;
}

.invoice-paper .falz-top {
  top: 105mm;
}

.invoice-paper .falz-mid {
  top: 148.5mm;
}

.invoice-paper .falz-bot {
  top: 210mm;
}

.invoice-paper.show-falz .falz-top,
.invoice-paper.show-falz .falz-mid,
.invoice-paper.show-falz .falz-bot {
  display: block;
}

/* Invoice paper table overrides */
.invoice-paper table {
  color: #1a1a2e;
}

/* Body cells default to dark-on-white; inline `style="color:..."` from
   buildPositionRow() can override (no !important). */
.invoice-paper th,
.invoice-paper td {
  color: #1a1a2e;
  background: #fff;
}

/* Header cells: NO !important so the active color profile (set inline
   by buildInvoiceTable via getInvoiceColors()) wins.
   Override the global `thead th` uppercase/letter-spacing so preview text
   reads "Pos. Beschreibung Menge EP Betrag" — same as the PDF. */
.invoice-paper thead th {
  background: #f5f5f5;
  color: #1a1a2e;
  border-bottom: 2px solid #1a1a2e;
  text-transform: none;
  letter-spacing: normal;
  font-size: inherit;
  position: static;
}

.invoice-paper tbody tr:hover td {
  background: #fff !important;
}

.invoice-paper .calc-field,
.invoice-paper .calc-field.cur {
  color: #1a1a2e !important;
}

.invoice-paper .calc-field.cur::before {
  color: #1a1a2e !important;
}


/* ==========================================================================
   18. Overlay & Modal
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}

.overlay.show {
  display: flex;
}
#colOv.show { z-index: 600; }

.overlay-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 92%;
  max-width: 480px;
  animation: fadeIn 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.overlay-box h3 {
  font-size: 16px;
  margin-bottom: 5px;
}

.overlay-box .sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

.overlay-box .acts {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}


/* ==========================================================================
   19. Password Component
   ========================================================================== */

.overlay-box .password-wrapper {
  position: relative;
  margin-bottom: 10px;
}

.overlay-box .password-wrapper input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 40px 10px 12px;
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  letter-spacing: 1px;
}

.overlay-box .password-wrapper input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.overlay-box .password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
}

.password-bar-track {
  height: 3px;
  border-radius: 2px;
  background: var(--surface3);
  margin-bottom: 4px;
  overflow: hidden;
}

.password-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
  width: 0;
}

.password-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 12px;
  min-height: 14px;
}


/* ==========================================================================
   20. Encryption Badge
   ========================================================================== */

.encryption-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-dim);
  padding: 3px 8px;
  border-radius: 16px;
  margin-bottom: 12px;
}


/* ==========================================================================
   21. Options Grid & Cards
   ========================================================================== */

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.option-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.option-card h4 {
  font-size: 13px;
  margin-bottom: 3px;
}

.option-card .desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.5;
}

.option-card .br {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* -- Surcharge grid -------------------------------------------------------- */

.zs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.zs-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}

.zs-item select {
  width: 100%;
  text-overflow: ellipsis;
}

.zs-item .form-group { margin-bottom: 8px; }
.zs-item .form-group:last-child { margin-bottom: 0; }

.zs-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  margin-bottom: 10px;
}

.zs-pct-wrap {
  position: relative;
}

.zs-pct-wrap input {
  width: 100%;
  padding-right: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  color: var(--text);
}

.zs-pct-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.zs-pct-unit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.zs-hint {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .zs-grid { grid-template-columns: 1fr; }
}

.monospace-input {
  font-family: 'JetBrains Mono', monospace;
}

.invoice-number-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 8px 0;
}

.preview-label-small {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.preview-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

.placeholder-help {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.8;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: var(--radius);
}

.placeholder-help code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--accent);
}


/* ==========================================================================
   22. Status Bar
   ========================================================================== */

.status-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.status-text {
  font-size: 11px;
  color: var(--text-dim);
}

.status-text strong {
  color: var(--text);
}


/* ==========================================================================
   23. Info Grid
   ========================================================================== */

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}

.info-grid .info-key {
  color: var(--text-dim);
}

.info-grid .info-value {
  color: var(--text);
  text-align: right;
}


/* ==========================================================================
   24. Toast Notifications
   ========================================================================== */

.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 12px;
  z-index: 600;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow);
  max-width: 360px;
}

.toast.success {
  border-left: 3px solid var(--green);
}

.toast.error {
  border-left: 3px solid var(--red);
}

@keyframes slideIn {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}


/* ==========================================================================
   25. Logo Upload
   ========================================================================== */

.logo-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--tr);
  color: var(--text-dim);
  font-size: 11px;
}

.logo-upload:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.logo-upload img {
  max-height: 50px;
  object-fit: contain;
}


/* ==========================================================================
   26. Search Combobox
   ========================================================================== */

.search-combobox {
  position: relative;
}

.search-combobox-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface3);
  border: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 120px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}

.search-combobox-dropdown.show {
  display: block;
}


/* ==========================================================================
   27. Column Config Items
   ========================================================================== */

.col-cfg-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  background: var(--surface2);
  cursor: grab;
}

.col-cfg-item:active {
  cursor: grabbing;
  background: var(--surface3);
}

.col-cfg-item .drag {
  color: var(--text-muted);
  font-size: 14px;
}

.col-cfg-item input[type="text"] {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  width: 100%;
}

.col-cfg-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.col-move-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
  padding: 1px 5px;
  color: var(--text-dim);
  line-height: 1;
  flex-shrink: 0;
}
.col-move-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}


/* ==========================================================================
   28. Payment & Due Badges
   ========================================================================== */

.pay-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  display: inline-block;
}

.pay-paid {
  background: var(--green-dim);
  color: var(--green);
}

.pay-unpaid {
  background: var(--red-dim);
  color: var(--red);
}

.pay-partial {
  background: var(--orange-dim);
  color: var(--orange);
}

.pay-cancelled {
  background: var(--red-dim);
  color: var(--red);
}

.pay-storno {
  background: #555;
  color: #ccc;
}

/* Cancelled / Storno row styles */
.row-cancelled td {
  opacity: 0.45;
  text-decoration: line-through;
}

.row-cancelled td:last-child {
  opacity: 1;
  text-decoration: none;
}

.row-storno td {
  opacity: 0.7;
  font-style: italic;
}

.row-storno td:last-child {
  opacity: 1;
  font-style: normal;
}

/* Paid row — opaque green so sticky columns blend correctly */
.row-paid td {
  background: #e8f8ee;
}
.row-paid:hover td {
  background: #d4f0dd;
}

/* ---------- Invoice list: filter / sort / sticky columns ---------- */
.inv-table-scroll {
  overflow: auto;
  position: relative;
  /* Fill the remaining vertical space of the tab content so the table
     reaches the bottom of the viewport. The fixed 70vh cap left a large
     empty area below the rows on tall screens. */
  flex: 1 1 auto;
  min-height: 0;
}
.inv-list-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
.inv-list-table th,
.inv-list-table td {
  background: #fff;
  white-space: nowrap;
}
.inv-list-table thead .inv-head-sort th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #2a2d3a;
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  user-select: none;
}
.inv-list-table thead .inv-head-sort th.inv-sort-clickable {
  cursor: pointer;
}
.inv-list-table thead .inv-head-sort th.inv-sort-clickable:hover {
  background: #3a3d4a;
}
.inv-list-table thead .inv-head-filter th {
  position: sticky;
  top: 36px;
  z-index: 3;
  background: var(--bg-hover, #f5f5f5);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.inv-sticky-l {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 1px 0 0 var(--border, #e5e7eb);
}
.inv-sticky-r {
  position: sticky;
  right: 0;
  z-index: 2;
  box-shadow: -1px 0 0 var(--border, #e5e7eb);
}
.inv-list-table thead .inv-sticky-l,
.inv-list-table thead .inv-sticky-r {
  z-index: 4;
}
.inv-list-table tbody tr:hover td {
  background: #f5f7fa;
}
.inv-list-table tbody tr.row-paid td { background: #e8f8ee; }
.inv-list-table tbody tr.row-paid:hover td { background: #d4f0dd; }
.inv-list-table tbody tr.row-cancelled td { background: #fafafa; }
.inv-list-table tbody tr.row-storno td { background: #fff8e6; }

.inv-filter-input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--border, #ddd);
  border-radius: 3px;
  font-size: 11px;
  background: #fff;
  box-sizing: border-box;
}
.inv-sort-arrow {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
}
.inv-sort-arrow.active { opacity: 1; font-size: 11px; }

.inv-col-cfg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border, #eee);
}
.inv-col-cfg-row .inv-col-cfg-label {
  flex: 1;
  font-size: 13px;
}
.inv-col-cfg-row.inv-col-cfg-fixed .inv-col-cfg-label {
  color: var(--text-dim, #888);
  font-style: italic;
}

.due-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  display: inline-block;
}

.due-ok {
  background: var(--green-dim);
  color: var(--green);
}

.due-warn {
  background: var(--orange-dim);
  color: var(--orange);
}

.due-over {
  background: var(--red-dim);
  color: var(--red);
}


/* ==========================================================================
   29. Chart Components
   ========================================================================== */

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  overflow: hidden;
  height: calc(var(--chart-base-h, 340px) * var(--chart-scale, 1));
  min-height: 160px;
  min-width: 240px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.10), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  transition: height 0.3s ease-in-out, box-shadow 0.2s, border-color 0.3s ease-in-out, opacity 0.2s;
}

.chart-wrap:hover {
  border-color: rgba(74, 137, 255, 0.35);
  box-shadow: 0 4px 16px -2px rgb(74 137 255 / 0.12), 0 2px 6px -2px rgb(0 0 0 / 0.08);
}

/* All charts use identical height — controlled exclusively via --chart-base-h and --chart-scale */

.chart-custom-body {
  height: calc(100% - 44px);
  overflow: auto;
  position: relative;
}

.chart-wrap canvas {
  width: 100% !important;
  height: calc(100% - 44px) !important;
  transition: none; /* prevent canvas blur during resize */
}

.chart-wrap .chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  margin-top: 0;
  cursor: grab;
  user-select: none;
}

.chart-wrap .chart-header:active {
  cursor: grabbing;
}

.chart-wrap .chart-header h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  text-align: left;
  letter-spacing: -0.2px;
}

.chart-wrap .chart-header .drag-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  color: var(--text-dim);
}

.chart-wrap:hover .chart-header .drag-hint {
  opacity: 0.35;
}

.chart-wrap.chart-dragging {
  opacity: 0.4;
  border: 2px dashed var(--accent);
  z-index: 1;
}

.chart-wrap.chart-drag-over {
  box-shadow: 0 0 0 2px var(--accent);
  border-color: var(--accent);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(var(--chart-cols, 3), 1fr);
  gap: var(--chart-gutter, 24px);
  overflow-x: auto;
}

/* Layout Controller Panel */
.layout-ctrl-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  overflow: hidden;
  animation: fadeIn .15s ease;
}

.layout-ctrl-inner {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 16px;
  flex-wrap: wrap;
}

.layout-ctrl-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.layout-ctrl-divider {
  padding-left: 20px;
  margin-left: 16px;
  border-left: 1px solid var(--border);
}

.layout-ctrl-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.layout-cols-picker,
.layout-legend-toggle {
  display: flex;
  gap: 3px;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 2px;
}

.layout-col-btn {
  padding: 3px 10px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  border-radius: calc(var(--radius) - 1px);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.layout-col-btn.active {
  background: var(--accent);
  color: #fff;
}

.layout-col-btn:hover:not(.active) {
  background: var(--surface3, rgba(255,255,255,.08));
  color: var(--text);
}

.layout-scale-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layout-scale-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  min-width: 36px;
  text-align: right;
}

.layout-slider {
  width: 110px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.layout-scale-presets {
  display: flex;
  gap: 3px;
}

.layout-preset-btn {
  padding: 2px 7px;
  font-size: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: 3px;
  cursor: pointer;
  transition: all .15s;
}

.layout-preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.layout-reset-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
}

.layout-reset-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
}

.layout-ctrl-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.layout-ctrl-toggle.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* -- Chart action buttons ------------------------------------------------- */

.chart-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.chart-act-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.chart-wrap:hover .chart-act-btn { opacity: 0.7; }
.chart-act-btn:hover { opacity: 1 !important; background: var(--surface2); color: var(--accent); }

/* -- Maximized chart ------------------------------------------------------ */

.chart-wrap.chart-maximized {
  grid-column: 1 / -1 !important;
  height: calc(480px * var(--chart-scale, 1)) !important;
  border-color: #4A89FF;
  box-shadow: 0 0 0 2px rgba(74, 137, 255, 0.45), 0 8px 24px -4px rgb(0 0 0 / 0.18);
  /* No order:-1 — chart stays in its current grid position */
}

/* Chart visibility toggle row */
.chart-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  align-items: center;
}

.chart-toggle-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  margin-right: 4px;
  white-space: nowrap;
}

.chart-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.chart-toggle-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.chart-toggle-btn:hover:not(.active) {
  border-color: var(--border-active);
  color: var(--text);
}

.chart-wrap.chart-hidden {
  display: none;
}

/* Chart Visibility Overlay items */
.chart-vis-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
  background: var(--surface2);
}

.chart-vis-item:hover { border-color: var(--accent); background: var(--accent-dim); }
.chart-vis-item.on { border-color: rgba(74,137,255,.3); }
.chart-vis-item.off { opacity: .55; }

.chart-vis-icon { font-size: 18px; flex-shrink: 0; }

.chart-vis-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.chart-vis-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background .2s;
}

.chart-vis-toggle.active { background: var(--accent); }

.chart-vis-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.chart-vis-toggle.active .chart-vis-knob { left: 18px; }


/* -- Chart Popup Overlay -------------------------------------------------- */

.chart-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(10px);
  z-index: 600;
  display: none;
  flex-direction: column;
  padding: 24px;
}

.chart-popup-overlay.show { display: flex; }

.chart-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.chart-popup-header h3 {
  font-size: 16px;
  margin: 0;
  color: #fff;
}

.chart-popup-body {
  flex: 1;
  position: relative;
  min-height: 0;
}

.chart-popup-body canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ==========================================================================
   30. Filter Toolbar & Groups
   ========================================================================== */

.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.filter-toolbar.filter-toolbar-bg {
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* --- Focus Mode --- */
.fokus-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  margin: 8px 0 4px;
}
.fokus-counter {
  font-weight: 700;
  font-size: 14px;
  min-width: 80px;
  text-align: center;
}
.fokus-nav .btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  font-weight: 600;
}
.fokus-nav .btn:hover {
  background: rgba(255,255,255,0.28);
}
#btnFokus.fokus-active {
  background: var(--accent);
  color: #fff;
}

.filter-toolbar .filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-bottom: 1px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
}

.filter-group {
  margin: 0;
  flex: 0 0 auto;
}

.filter-group label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.filter-group input,
.filter-group select,
.filter-group textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  transition: var(--tr);
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}


/* ==========================================================================
   31. Utility Classes
   ========================================================================== */

.flex-spacer {
  flex: 1;
}

.row-count-label {
  font-size: 11px;
  color: var(--text-muted);
}

.overlay-wide {
  max-width: none;
  width: 98vw;
  height: 94vh;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
}


/* ==========================================================================
   32. Editor & Preview Layout
   ========================================================================== */

.editor-layout {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.editor-sidebar {
  flex: 0 0 320px;
  max-height: calc(90vh - 120px);
  overflow-y: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.preview-panel {
  flex: 1 1 400px;
  max-height: calc(90vh - 120px);
  overflow: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}


/* ==========================================================================
   33. Tab Switcher (Overlay Tabs)
   ========================================================================== */

.tab-switcher {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-switcher button {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--tr);
  white-space: nowrap;
}

.tab-switcher button:hover {
  color: var(--text);
}

.tab-switcher button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}


/* ==========================================================================
   34. Responsive Breakpoints
   ========================================================================== */

@media (max-width: 768px) {
  .app-header {
    padding: 0 10px;
    height: 48px;
  }

  .content {
    padding: 10px;
  }

  .tab {
    padding: 5px 8px;
    font-size: 10px;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    flex: 1 1 100%;
    min-width: 0;
  }

  .invoice-layout {
    grid-template-columns: 1fr;
  }

  .editor-sidebar {
    flex: 1 1 100%;
  }
}


/* ==========================================================================
   35. Scrollbar Styling
   ========================================================================== */

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}


/* ==========================================================================
   36. Color Scheme Themes
   ========================================================================== */

/* --- Color Scheme Custom Dropdown --- */
.cs-dropdown {
  position: relative;
  width: 100%;
}
.cs-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}
.cs-selected:hover {
  border-color: var(--accent);
}
.cs-arrow {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 14px;
}
.cs-label {
  flex: 1;
  color: var(--text);
  font-size: 14px;
}
.cs-swatches {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.cs-swatches span {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(128,128,128,0.25);
}
.cs-options {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 999;
  padding: 4px 0;
}
.cs-options.open {
  display: block;
}
.cs-group-label {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  pointer-events: none;
}
.cs-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 14px;
  color: var(--text);
}
.cs-option:hover {
  background: var(--hover);
}
.cs-option.active {
  background: var(--accent);
  color: #fff;
}
.cs-option .cs-swatches span {
  width: 12px;
  height: 12px;
}

/* --- DARK THEMES --- */

[data-theme="dark-charcoal"] {
  --bg: #1a1a1a;
  --surface: #242424;
  --surface2: #2e2e2e;
  --surface3: #383838;
  --border: #444;
  --border-light: #555;
  --text: #e0e0e0;
  --text-dim: #999;
  --text-muted: #666;
  --accent: #6bb5ff;
  --accent-hover: #8ac7ff;
  --accent-dim: rgba(107, 181, 255, 0.12);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark-ocean"] {
  --bg: #0a1628;
  --surface: #122040;
  --surface2: #1a2d50;
  --surface3: #233a60;
  --border: #2d4a70;
  --border-light: #3a5a85;
  --text: #d4e4f7;
  --text-dim: #8aa8c8;
  --text-muted: #5a7a9a;
  --accent: #22d3ee;
  --accent-hover: #4addf2;
  --accent-dim: rgba(34, 211, 238, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --orange: #fbbf24;
  --orange-dim: rgba(251, 191, 36, 0.12);
  --red: #fb7185;
  --red-dim: rgba(251, 113, 133, 0.12);
  --purple: #818cf8;
  --purple-dim: rgba(129, 140, 248, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark-violet"] {
  --bg: #0e0818;
  --surface: #1a1028;
  --surface2: #241a38;
  --surface3: #2e2448;
  --border: #3e3460;
  --border-light: #504678;
  --text: #e4ddf2;
  --text-dim: #a898c8;
  --text-muted: #6e5e90;
  --accent: #8b5cf6;
  --accent-hover: #a078ff;
  --accent-dim: rgba(139, 92, 246, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --orange: #fbbf24;
  --orange-dim: rgba(251, 191, 36, 0.12);
  --red: #f472b6;
  --red-dim: rgba(244, 114, 182, 0.12);
  --purple: #c084fc;
  --purple-dim: rgba(192, 132, 252, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark-crimson"] {
  --bg: #150a0a;
  --surface: #201212;
  --surface2: #2c1a1a;
  --surface3: #382222;
  --border: #4a2e2e;
  --border-light: #5c3a3a;
  --text: #f0e0e0;
  --text-dim: #c09090;
  --text-muted: #886060;
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --accent-dim: rgba(220, 38, 38, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

[data-theme="dark-slate"] {
  --bg: #111518;
  --surface: #1a2025;
  --surface2: #242c32;
  --surface3: #2e3840;
  --border: #3a4650;
  --border-light: #4a5862;
  --text: #d0dae0;
  --text-dim: #8898a5;
  --text-muted: #5a6a78;
  --accent: #94a3b8;
  --accent-hover: #b0bec5;
  --accent-dim: rgba(148, 163, 184, 0.12);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark-nord"] {
  --bg: #2e3440;
  --surface: #3b4252;
  --surface2: #434c5e;
  --surface3: #4c566a;
  --border: #5a6578;
  --border-light: #6a7588;
  --text: #eceff4;
  --text-dim: #d8dee9;
  --text-muted: #81899a;
  --accent: #88c0d0;
  --accent-hover: #a0d0e0;
  --accent-dim: rgba(136, 192, 208, 0.12);
  --green: #a3be8c;
  --green-dim: rgba(163, 190, 140, 0.12);
  --orange: #d08770;
  --orange-dim: rgba(208, 135, 112, 0.12);
  --red: #bf616a;
  --red-dim: rgba(191, 97, 106, 0.12);
  --purple: #b48ead;
  --purple-dim: rgba(180, 142, 173, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="dark-dracula"] {
  --bg: #282a36;
  --surface: #323443;
  --surface2: #3c3f50;
  --surface3: #464a5e;
  --border: #555870;
  --border-light: #656880;
  --text: #f8f8f2;
  --text-dim: #bfbfb6;
  --text-muted: #6272a4;
  --accent: #bd93f9;
  --accent-hover: #d0aafb;
  --accent-dim: rgba(189, 147, 249, 0.12);
  --green: #50fa7b;
  --green-dim: rgba(80, 250, 123, 0.12);
  --orange: #ffb86c;
  --orange-dim: rgba(255, 184, 108, 0.12);
  --red: #ff5555;
  --red-dim: rgba(255, 85, 85, 0.12);
  --purple: #ff79c6;
  --purple-dim: rgba(255, 121, 198, 0.12);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* --- LIGHT THEMES --- */

[data-theme="light-clean"] {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #f0f0f2;
  --surface3: #e5e5ea;
  --border: #d1d1d6;
  --border-light: #c7c7cc;
  --text: #1c1c1e;
  --text-dim: #636366;
  --text-muted: #aeaeb2;
  --accent: #007aff;
  --accent-hover: #0066d6;
  --accent-dim: rgba(0, 122, 255, 0.08);
  --green: #34c759;
  --green-dim: rgba(52, 199, 89, 0.08);
  --orange: #ff9500;
  --orange-dim: rgba(255, 149, 0, 0.08);
  --red: #ff3b30;
  --red-dim: rgba(255, 59, 48, 0.08);
  --purple: #af52de;
  --purple-dim: rgba(175, 82, 222, 0.08);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light-sage"] {
  --bg: #f0f4ee;
  --surface: #f8faf6;
  --surface2: #e6ece3;
  --surface3: #dae2d6;
  --border: #c0ccb8;
  --border-light: #adb8a4;
  --text: #2a3328;
  --text-dim: #556b50;
  --text-muted: #8a9e85;
  --accent: #5f8c5a;
  --accent-hover: #4e7a4a;
  --accent-dim: rgba(95, 140, 90, 0.08);
  --green: #5f8c5a;
  --green-dim: rgba(95, 140, 90, 0.08);
  --orange: #c07820;
  --orange-dim: rgba(192, 120, 32, 0.08);
  --red: #c04040;
  --red-dim: rgba(192, 64, 64, 0.08);
  --purple: #7a6898;
  --purple-dim: rgba(122, 104, 152, 0.08);
  --shadow: 0 2px 12px rgba(30, 50, 20, 0.06);
}

[data-theme="light-sky"] {
  --bg: #eef5fb;
  --surface: #f8fbff;
  --surface2: #e4eef8;
  --surface3: #d4e4f2;
  --border: #b8d0e8;
  --border-light: #a0c0dd;
  --text: #1a2a3a;
  --text-dim: #4a6a85;
  --text-muted: #8aa0b8;
  --accent: #2196f3;
  --accent-hover: #1976d2;
  --accent-dim: rgba(33, 150, 243, 0.08);
  --green: #43a047;
  --green-dim: rgba(67, 160, 71, 0.08);
  --orange: #fb8c00;
  --orange-dim: rgba(251, 140, 0, 0.08);
  --red: #e53935;
  --red-dim: rgba(229, 57, 53, 0.08);
  --purple: #7e57c2;
  --purple-dim: rgba(126, 87, 194, 0.08);
  --shadow: 0 2px 12px rgba(20, 50, 80, 0.06);
}

[data-theme="light-lavender"] {
  --bg: #f3f0f9;
  --surface: #faf8ff;
  --surface2: #ece8f5;
  --surface3: #e0daee;
  --border: #c8c0dd;
  --border-light: #b8a8d0;
  --text: #22182e;
  --text-dim: #5a4870;
  --text-muted: #9888b0;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-dim: rgba(124, 58, 237, 0.08);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.08);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.08);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.08);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.08);
  --shadow: 0 2px 12px rgba(40, 20, 60, 0.06);
}

[data-theme="light-peach"] {
  --bg: #fdf3ee;
  --surface: #fff8f4;
  --surface2: #f8ece4;
  --surface3: #f0e0d4;
  --border: #e0c8b8;
  --border-light: #d0b4a0;
  --text: #2e1e18;
  --text-dim: #7a5844;
  --text-muted: #b09080;
  --accent: #e86830;
  --accent-hover: #d05828;
  --accent-dim: rgba(232, 104, 48, 0.08);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.08);
  --orange: #e86830;
  --orange-dim: rgba(232, 104, 48, 0.08);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --purple: #9333ea;
  --purple-dim: rgba(147, 51, 234, 0.08);
  --shadow: 0 2px 12px rgba(60, 30, 10, 0.06);
}

[data-theme="light-sand"] {
  --bg: #f5f1ea;
  --surface: #fdfaf5;
  --surface2: #ede8de;
  --surface3: #e0d8cc;
  --border: #ccc4b4;
  --border-light: #bab0a0;
  --text: #2e2a22;
  --text-dim: #68604e;
  --text-muted: #a09888;
  --accent: #9a7030;
  --accent-hover: #856028;
  --accent-dim: rgba(154, 112, 48, 0.08);
  --green: #3a9a5c;
  --green-dim: rgba(58, 154, 92, 0.08);
  --orange: #cc8800;
  --orange-dim: rgba(204, 136, 0, 0.08);
  --red: #cc4444;
  --red-dim: rgba(204, 68, 68, 0.08);
  --purple: #8866aa;
  --purple-dim: rgba(136, 102, 170, 0.08);
  --shadow: 0 2px 12px rgba(40, 30, 10, 0.06);
}

[data-theme="light-mint"] {
  --bg: #eef8f4;
  --surface: #f5fcf8;
  --surface2: #e2f4ec;
  --surface3: #d2eae0;
  --border: #b0d8c4;
  --border-light: #98c8b0;
  --text: #1a302a;
  --text-dim: #3a6a58;
  --text-muted: #80a898;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-dim: rgba(16, 185, 129, 0.08);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.08);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.08);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.08);
  --purple: #8b5cf6;
  --purple-dim: rgba(139, 92, 246, 0.08);
  --shadow: 0 2px 12px rgba(10, 50, 30, 0.06);
}

[data-theme="light-rose"] {
  --bg: #fdf0f2;
  --surface: #fff6f8;
  --surface2: #f8e4e8;
  --surface3: #f0d4da;
  --border: #e0b8c0;
  --border-light: #d0a0aa;
  --text: #2e1820;
  --text-dim: #7a4858;
  --text-muted: #b08090;
  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-dim: rgba(225, 29, 72, 0.08);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.08);
  --orange: #f59e0b;
  --orange-dim: rgba(245, 158, 11, 0.08);
  --red: #e11d48;
  --red-dim: rgba(225, 29, 72, 0.08);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.08);
  --shadow: 0 2px 12px rgba(60, 10, 20, 0.06);
}

/* MA Config Overlay - fullscreen responsive */
.ma-config-box { width: calc(100vw - 40px); max-width: 1400px; max-height: calc(100vh - 40px); overflow-y: auto; }

/* MA Config Table */
.ma-cfg-tbl { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }
.ma-cfg-tbl th { padding: 6px 8px; text-align: left; font-weight: 600; background: var(--bg-hover); white-space: nowrap; border-bottom: 2px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-sec); }
.ma-cfg-tbl td { padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ma-cfg-tbl input, .ma-cfg-tbl select { padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card); color: var(--text); font-size: 13px; box-sizing: border-box; }
.ma-cfg-tbl input:disabled { opacity: 0.35; background: var(--bg-hover); }
.ma-cfg-tbl tr[data-employee]:hover { background: var(--bg-hover); }
.ma-cfg-tbl .maCfgName { width: 100%; min-width: 120px; font-weight: 600; }
.ma-cfg-tbl .maCfgPnr { width: 70px; }
.ma-cfg-tbl .maCfgStundenlohn, .ma-cfg-tbl .maCfgGehaltInput { width: 100%; min-width: 70px; }
.ma-cfg-tbl .maCfgUeber { width: 80px; }
.ma-cfg-tbl .maCfgNotiz { width: 100%; min-width: 100px; }
.ma-cfg-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 14px; padding: 4px 0; }
.ma-cfg-detail-grid label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-sec); margin-bottom: 2px; }
.ma-cfg-detail-grid input, .ma-cfg-detail-grid select { width: 100%; padding: 5px 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card); color: var(--text); font-size: 13px; box-sizing: border-box; }

/* Lohn MA Table */
.lohn-ma-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.lohn-ma-tbl th { padding: 6px 8px; font-weight: 600; background: var(--bg-hover); border-bottom: 2px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-sec); }
.lohn-ma-tbl th:hover { background: var(--accent-dim); }
.lohn-ma-tbl td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.lohn-ma-tbl tbody tr:hover { background: var(--bg-hover); }
.lohn-ma-tbl tfoot td { padding: 8px 8px; border-top: 2px solid var(--border); background: var(--bg-hover); }

/* Active filter highlight — applied to <select> elements with a non-empty value */
.filter-active {
  background-color: #e0f2fe !important;
  border-color: #3b82f6 !important;
  color: #1e40af !important;
  font-weight: 600 !important;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}
.filter-group:has(.filter-active) > label {
  color: #1e40af;
  font-weight: 700;
}
.filter-group:has(.filter-active) > label::after {
  content: ' ●';
  color: #3b82f6;
  font-size: 9px;
}

/* Einsätze totals row — sticky at the bottom of the scroll container */
.einsaetze-totals-row td {
  position: sticky;
  bottom: 0;
  background: var(--surface2, #f5f5f5);
  border-top: 1px solid var(--border, #d0d0d0);
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  z-index: 1;
}
.einsaetze-totals-row .einsaetze-totals-cell {
  color: var(--text, #222);
  font-variant-numeric: tabular-nums;
}
.einsaetze-totals-row .einsaetze-totals-label {
  color: var(--text-dim, #888);
  font-style: italic;
}

/* Leistungsorte totals row (GESAMT) — sticky at the bottom of the scroll area */
#orteFoot td {
  position: sticky;
  bottom: 0;
  background: var(--surface2, #f5f5f5);
  border-top: 2px solid var(--border, #d0d0d0);
  font-weight: 700;
  z-index: 1;
}
