/**
 * Investment-Simulation - Styles
 */

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Brand Colors - Aligned with PDF Design */
  --brand-primary: #0f172a;           /* Dark navy/ink - primary text & accents */
  --brand-accent: #f8f5f0;            /* Beige/cream - headers & highlights */
  --brand-accent-dark: #e8e5e0;       /* Darker beige for hover */
  --brand-beige: #B39B75;             /* Darker beige for interactive elements */
  --brand-beige-hover: #9a8463;       /* Even darker beige for hover */

  /* Semantic Colors */
  --background: #fafafa;              /* Very light grey background */
  --surface: #ffffff;                 /* White surface */
  --text-primary: #0f172a;            /* Dark navy for headings */
  --text-secondary: #475569;          /* Medium grey for body */
  --text-light: #94a3b8;              /* Light grey for hints */
  --border-color: #e2e8f0;            /* Light border */
  --success-color: #10b981;           /* Green for positive values */

  /* Legacy aliases for compatibility */
  --primary-color: var(--brand-beige);
  --secondary-color: var(--brand-beige-hover);

  /* Spacing & Effects */
  --radius: 8px;
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--background);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
  position: relative;
  background: linear-gradient(135deg, var(--brand-accent) 0%, #ffffff 100%);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Partner Logo */
.partner-logo {
  max-height: 100px;
  max-width: 400px;
  margin: 0 auto 1.5rem;
  margin-left: calc(50% + 5%); /* Shift 5% to the right */
  transform: translateX(-50%);
  display: block;
  object-fit: contain;
  /* Invert white logo for light background */
  filter: invert(1) brightness(0.2);
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
}

/* Main */
main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Form */
.simulation-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

/* Input Section */
.input-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.input-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--brand-primary);
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  margin: -1.5rem -1.5rem 1.5rem -1.5rem;
  background: linear-gradient(90deg, var(--brand-accent) 0%, transparent 100%);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid var(--brand-accent-dark);
}

/* Input Group */
.input-group {
  margin-bottom: 1.25rem;
}

.input-group:last-child {
  margin-bottom: 0;
}

.input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.input-group input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Calculated Value Display */
.calculated-display {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  background-color: #f0f9ff;
  border: 2px solid var(--primary-color);
  border-radius: var(--radius);
  color: var(--primary-color);
  text-align: left;
}

/* Finance Costs Display */
.finance-costs-display {
  width: 100%;
  padding: 0.75rem;
  background-color: #f0f9ff;
  border: 2px solid var(--primary-color);
  border-radius: var(--radius);
}

.finance-cost-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 95, 141, 0.2);
}

.finance-cost-item:last-child {
  border-bottom: none;
}

.cost-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.cost-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
}

.input-group input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.input-group input:hover {
  border-color: var(--primary-color);
}

/* Checkbox Label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
  margin: 0;
}

/* Input Hints */
.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-style: italic;
}

/* Results Section */
.results-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
}

.results-section h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-color);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.result-item {
  background: var(--background);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.result-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.result-item.highlight {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid var(--primary-color);
}

.result-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.result-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.result-value.positive {
  color: #10b981;
}

.result-value.negative {
  color: #ef4444;
}

.result-value.neutral {
  color: var(--text-primary);
}

.result-description {
  display: none; /* Hidden in production for cleaner UI */
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Yearly Data Section */
.yearly-data-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
}

.yearly-data-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.yearly-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.yearly-data-table thead {
  background: var(--primary-color);
  color: white;
}

.yearly-data-table th {
  padding: 0.75rem 0.5rem;
  text-align: right;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.yearly-data-table th:first-child {
  text-align: center;
}

.yearly-data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
}

.yearly-data-table tbody tr:hover {
  background-color: var(--background);
}

.yearly-data-table tbody tr.separator-row {
  background-color: var(--background);
}

.yearly-data-table tbody tr.separator-row:hover {
  background-color: var(--background);
}

.yearly-data-table td {
  padding: 0.75rem 0.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.yearly-data-table td:first-child {
  text-align: center;
  font-weight: 600;
  color: var(--primary-color);
}

.yearly-data-table td.positive {
  color: #10b981;
  font-weight: 600;
}

.yearly-data-table td.negative {
  color: #ef4444;
  font-weight: 600;
}

/* PDF Export Container */
/* PDF Export Section */
.pdf-export-section {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin: 2rem 0;
  position: relative;
  overflow: hidden;
}

.pdf-export-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-primary);
  margin: 0 0 1.5rem 0;
  position: relative;
  z-index: 1;
}

/* Exposé Upload */
.expose-upload-container {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: #f9fafb;
  border-radius: var(--radius);
  border: 2px dashed var(--border-color);
}

.expose-upload-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.upload-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.file-input-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.expose-file-input {
  display: none;
}

.btn-file-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brand-primary);
  background: white;
  border: 2px solid var(--brand-primary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-file-upload:hover {
  background: var(--brand-primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-file-upload svg {
  width: 18px;
  height: 18px;
}

.file-name-display {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
  min-width: 200px;
}

.file-name-display:empty::before {
  content: 'Keine Datei ausgewählt';
  color: var(--text-secondary);
  font-weight: normal;
}

.btn-remove-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: #fee2e2;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-remove-file:hover {
  background: #fecaca;
  transform: scale(1.1);
}

.btn-remove-file svg {
  width: 16px;
  height: 16px;
  stroke: #dc2626;
}

.pdf-export-container {
  display: flex;
  justify-content: center;
  margin: 0;
}

.btn-export-pdf {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

.btn-export-pdf:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-export-pdf:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-export-pdf svg {
  width: 20px;
  height: 20px;
}

/* Charts Section */
.charts-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
}

.charts-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-color);
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
}

.chart-container {
  background: var(--background);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.chart-container.full-width {
  grid-column: 1 / -1;
}

.chart-container h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-align: center;
}

.chart-container canvas {
  max-height: 400px;
}

/* ApexCharts Premium Styling */
.charts-grid-apex {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
  margin-top: 2rem;
}

.chart-container-apex {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border-color);
  min-height: 550px;
}

.chart-container-apex h3 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2rem;
  text-align: left;
  letter-spacing: -0.025em;
}

.chart-container-apex > div {
  min-height: 480px;
}

/* Responsive für ApexCharts */
@media (max-width: 768px) {
  .charts-grid-apex {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .chart-container-apex {
    padding: 1.5rem;
    min-height: 400px;
  }

  .chart-container-apex h3 {
    font-size: 1.25rem;
  }

  .chart-container-apex > div {
    min-height: 350px;
  }
}

/* Debug Section */
.debug-section {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  margin-top: 1rem;
}

.debug-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.debug-section h2::before {
  content: '🔍';
  font-size: 1.25rem;
}

.debug-output {
  background: #1e293b;
  color: #10b981;
  padding: 1rem;
  border-radius: var(--radius);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid #334155;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .simulation-form {
    grid-template-columns: 1fr;
  }

  .input-section {
    padding: 1rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .result-value {
    font-size: 1.5rem;
  }

  .yearly-data-table {
    font-size: 0.75rem;
  }

  .yearly-data-table th,
  .yearly-data-table td {
    padding: 0.5rem 0.25rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .chart-container {
    padding: 1rem;
  }
}

/* KPI Tooltip */
.kpi-label-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.kpi-info-icon {
  display: none !important; /* Hidden for cleaner UI */
}

.kpi-info-icon:hover {
  background: var(--secondary-color);
  transform: scale(1.1);
}

.kpi-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  max-width: 90vw;
  padding: 1rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-primary);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

/* Tooltip-Pfeil */
.kpi-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: white;
}

.kpi-tooltip::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top-color: var(--border-color);
  margin-top: 1px;
}

/* Hover-State für Desktop */
.kpi-info-icon:hover .kpi-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Click-State für Mobile (via JS) */
.kpi-info-icon.active .kpi-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Disclaimer Box */
.disclaimer-box {
  margin: 0 0 2rem 0;
  padding: 1rem 1.5rem;
  background-color: #f9fafb;
  border-left: 4px solid var(--primary-color);
  border-radius: var(--radius);
}

.disclaimer-text {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-style: italic;
}

/* Eingesetztes Kapital Display */
.invested-capital-display {
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background-color: #f0f9ff;
  border: 2px solid var(--primary-color);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.invested-capital-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.invested-capital-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Vorsteuer-Rückerstattung Box */
.vorsteuer-box {
  margin-top: 2rem;
  padding: 1.5rem;
  background-color: #f0fdf4;
  border: 2px solid #10b981;
  border-radius: var(--radius);
}

.vorsteuer-box h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

.vorsteuer-gesamt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: #dcfce7;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.vorsteuer-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.vorsteuer-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #10b981;
}

.vorsteuer-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.vorsteuer-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background-color: white;
  border-radius: var(--radius);
  border: 1px solid #d1fae5;
}

.vorsteuer-item-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.vorsteuer-item-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #059669;
}

/* Tooltip-Inhalt */
.kpi-tooltip-title {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  font-size: 0.9375rem;
}

.kpi-tooltip-text {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.kpi-tooltip-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-secondary);
}

.kpi-tooltip-list li {
  margin-bottom: 0.5rem;
}

.kpi-tooltip-list li:last-child {
  margin-bottom: 0;
}

/* Responsive Anpassungen */
@media (max-width: 768px) {
  .kpi-tooltip {
    width: 280px;
    font-size: 0.8125rem;
    bottom: auto;
    top: calc(100% + 10px);
    left: auto;
    right: 0;
    transform: none;
  }

  .kpi-tooltip::after {
    top: auto;
    bottom: 100%;
    left: auto;
    right: 10px;
    transform: none;
    border-top-color: transparent;
    border-bottom-color: white;
  }

  .kpi-tooltip::before {
    top: auto;
    bottom: 100%;
    left: auto;
    right: 10px;
    transform: none;
    border-top-color: transparent;
    border-bottom-color: var(--border-color);
    margin-top: 0;
    margin-bottom: 1px;
  }
}

/* Jahrestabelle Toggle */
.section-header-with-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header-with-toggle h2 {
  margin: 0;
}

.toggle-container {
  display: flex;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-label-text {
  font-weight: 600;
  color: var(--text-primary);
}

.toggle-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.toggle-option {
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

.toggle-checkbox:checked + .toggle-option {
  color: var(--primary-color);
  font-weight: 600;
}

/* Responsive Toggle */
@media (max-width: 768px) {
  .section-header-with-toggle {
    flex-direction: column;
    align-items: flex-start;
  }

  .toggle-container {
    width: 100%;
  }

  .toggle-label {
    width: 100%;
    justify-content: space-between;
  }
}

/* ============================================================================
   HISTORY MODAL
   ============================================================================ */

/* History Button */
.history-button-container {
  margin: 2rem 0;
  text-align: center;
}

.btn-open-history {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-open-history:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-open-history svg {
  flex-shrink: 0;
}

/* Modal Overlay */
.history-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  overflow-y: auto;
}

.history-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal Header */
.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.history-modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-modal:hover {
  background: var(--background);
  color: var(--text-primary);
}

/* Search Container */
.history-search-container {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
}

.history-search-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.history-search-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-search-history {
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.btn-search-history:hover {
  background: var(--secondary-color);
}

/* Results Container */
.history-results {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 60vh;
}

/* History Item */
.history-item {
  background: var(--background);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
}

.history-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.history-item:last-child {
  margin-bottom: 0;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

.history-item-date {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.history-item-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.history-item-details {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.history-item-details strong {
  color: var(--text-primary);
  font-weight: 600;
}

.history-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-history-action {
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-history-action:hover {
  background: var(--background);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.btn-history-action.btn-primary {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.btn-history-action.btn-primary:hover {
  background: var(--secondary-color);
  border-color: var(--secondary-color);
  color: white;
}

.btn-history-action.btn-secondary {
  background: var(--background);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-history-action.btn-secondary:hover {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

/* Loading & Empty States */
.history-loading,
.history-empty,
.history-error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.history-loading {
  font-size: 1rem;
}

.history-empty {
  font-size: 0.95rem;
}

.history-error {
  color: #ef4444;
  font-size: 0.95rem;
}

.history-error strong {
  display: block;
  margin-bottom: 0.5rem;
}

.history-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius);
}

/* Responsive History Modal */
@media (max-width: 768px) {
  .history-modal-content {
    max-height: 95vh;
  }

  .history-search-container {
    flex-direction: column;
  }

  .history-item-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .history-item-date {
    order: -1;
  }

  .history-item-details {
    flex-direction: column;
    gap: 0.5rem;
  }

  .history-item-actions {
    flex-direction: column;
  }

  .btn-history-action {
    width: 100%;
    justify-content: center;
  }
}

/* Collapsible Sections */
.collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  text-align: left;
  transition: all 0.2s ease;
}

.collapse-toggle:hover {
  color: var(--brand-beige);
}

.collapse-icon {
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.collapse-toggle[aria-expanded="true"] .collapse-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  overflow: hidden;
  transition: all 0.3s ease;
}

.collapsible-section h2 {
  margin-bottom: 0;
}

.collapsible-section .section-header-with-toggle {
  margin-bottom: 0;
}

.collapsible-content[style*="display: block"] {
  margin-top: 1.5rem;
}

/* Print */
@media print {
  .debug-section {
    display: none;
  }

  .kpi-info-icon {
    display: none;
  }

  .toggle-container {
    display: none;
  }

  .history-button-container,
  .history-modal {
    display: none;
  }

  .collapse-toggle {
    display: none;
  }

  .collapsible-content {
    display: block !important;
  }
}

/* ============================================================================
   LOGIN SCREEN & AUTHENTICATION
   ============================================================================ */

/* Login Screen - Full page overlay */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--brand-accent) 0%, #ffffff 50%, var(--brand-accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Login Container */
.login-container {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem;
  max-width: 420px;
  width: 90%;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Login Header */
.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  max-height: 72px; /* 20% größer als 60px */
  margin-bottom: 1.5rem;
  /* Invert white logo to black for visibility on light background */
  filter: invert(1) brightness(0);
}

.login-header h1 {
  color: var(--brand-primary);
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Login Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-input-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.login-input-group input {
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s ease;
}

.login-input-group input:focus {
  outline: none;
  border-color: var(--brand-beige);
  box-shadow: 0 0 0 3px rgba(179, 155, 117, 0.1);
}

/* Login Button */
.login-button {
  padding: 1rem;
  background: var(--brand-beige);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-button:hover {
  background: var(--brand-beige-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.login-button:active {
  transform: translateY(0);
}

/* Login Error */
.login-error {
  padding: 0.875rem;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: var(--radius);
  color: #c33;
  font-size: 0.9rem;
  text-align: center;
}

/* Logout Button in Header */
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.header-text {
  flex: 1;
  text-align: center;
  padding-left: 15%; /* Shift 15% to the right for alignment with logo */
}

.logout-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: transparent;
  border: 2px solid var(--brand-beige);
  color: var(--brand-beige);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-button:hover {
  background: var(--brand-beige);
  color: white;
  transform: translateY(-1px);
}

.logout-button svg {
  width: 18px;
  height: 18px;
}

/* Responsive */
@media (max-width: 640px) {
  .login-container {
    padding: 2rem 1.5rem;
  }

  .logout-button span {
    display: none;
  }

  .logout-button {
    padding: 0.625rem;
  }
}
