/* ═══════════════════════════════════════════════════════════════════════════
   SolarCalc - Premium Solar Calculator UI
   Design: Solar Luxe - Dark theme with warm amber/gold accents
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Brand Color - Tech Solutions Red */
  --brand-red: #C41E3A;
  --brand-red-light: #E53E5C;
  --brand-red-glow: rgba(196, 30, 58, 0.25);
  --brand-red-subtle: rgba(196, 30, 58, 0.12);

  /* Typography */
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', 'SF Mono', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Dark Theme (Default) ──────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-deep: #0a0c10;
  --bg-base: #0f1219;
  --bg-elevated: #161b26;
  --bg-surface: #1c2333;
  --bg-hover: #252d40;

  --accent-primary: #f59e0b;
  --accent-secondary: #fbbf24;
  --accent-glow: rgba(245, 158, 11, 0.15);
  --accent-subtle: rgba(245, 158, 11, 0.08);

  --positive: #10b981;
  --positive-glow: rgba(16, 185, 129, 0.2);
  --positive-subtle: rgba(16, 185, 129, 0.1);
  --negative: #ef4444;
  --negative-glow: rgba(239, 68, 68, 0.2);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-accent: var(--brand-red-subtle);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --section-border: var(--brand-red);
  --section-border-hover: var(--brand-red-light);
}

/* ─── Light Theme ───────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-deep: #f1f5f9;
  --bg-base: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-surface: #f1f5f9;
  --bg-hover: #e2e8f0;

  --accent-primary: #d97706;
  --accent-secondary: #f59e0b;
  --accent-glow: rgba(217, 119, 6, 0.15);
  --accent-subtle: rgba(217, 119, 6, 0.08);

  --positive: #059669;
  --positive-glow: rgba(5, 150, 105, 0.15);
  --positive-subtle: rgba(5, 150, 105, 0.08);
  --negative: #dc2626;
  --negative-glow: rgba(220, 38, 38, 0.15);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-accent: var(--brand-red-subtle);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --section-border: var(--brand-red);
  --section-border-hover: var(--brand-red-light);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── App Container ─────────────────────────────────────────────────────────── */
.app {
  position: relative;
  min-height: 100vh;
  padding: var(--space-lg);
}

/* ─── Ambient Background ────────────────────────────────────────────────────── */
.ambient-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
  top: -200px;
  right: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--positive) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  animation-delay: -7s;
  opacity: 0.3;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%);
  top: 50%;
  left: 30%;
  animation-delay: -14s;
  opacity: 0.2;
}

/* Light mode: reduce orb visibility */
[data-theme="light"] .gradient-orb {
  opacity: 0.15;
}

[data-theme="light"] .orb-1 {
  background: radial-gradient(circle, var(--brand-red) 0%, transparent 70%);
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(20px, 30px) scale(1.02); }
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
}

.logo-img {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.header-tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Theme Toggle Button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--brand-red);
}

.theme-icon {
  font-size: 1.25rem;
  position: absolute;
  transition: all var(--transition-base);
}

/* Dark mode: show moon, hide sun */
[data-theme="dark"] .theme-icon-dark {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="dark"] .theme-icon-light {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

/* Light mode: show sun, hide moon */
[data-theme="light"] .theme-icon-light {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-icon-dark {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

/* ─── Main Grid ─────────────────────────────────────────────────────────────── */
.main-grid {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--space-xl);
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Input Panel ───────────────────────────────────────────────────────────── */
.input-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.calc-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Client Type Selector */
.client-type-selector {
  background: var(--bg-elevated);
  border: 2px solid var(--brand-red);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: 0 0 24px var(--brand-red-glow);
}

.client-type-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.client-type-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-base);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
}

.client-type-option:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.client-type-option:has(input:checked) {
  background: var(--accent-subtle);
  border-color: var(--accent-primary);
  box-shadow: 0 0 12px var(--accent-glow);
}

.client-type-option input[type="radio"] {
  display: none;
}

.client-type-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Deduction fields dimmed in aziendale mode */
.deduction-fields-hidden {
  opacity: 0.3;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

/* Stat card dimmed */
.stat-card-hidden {
  opacity: 0.3;
  transition: opacity var(--transition-base);
}

/* Input Sections (Accordion) */
.input-section {
  background: var(--bg-elevated);
  border: 2px solid var(--brand-red-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
}

.input-section:hover {
  border-color: var(--brand-red);
  box-shadow: 0 0 20px var(--brand-red-glow);
}

.input-section[open] {
  border-color: var(--brand-red);
  box-shadow: 0 0 24px var(--brand-red-glow);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
  list-style: none;
}

.section-header::-webkit-details-marker {
  display: none;
}

.section-header:hover {
  background: var(--bg-hover);
}

.section-icon {
  font-size: 1.25rem;
}

.section-title {
  flex: 1;
  font-weight: 600;
  font-size: 0.9375rem;
}

.section-chevron {
  font-size: 1.25rem;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}

.input-section[open] .section-chevron {
  transform: rotate(90deg);
}

.section-content {
  padding: 0 var(--space-md) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  animation: slideDown var(--transition-base);
}

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

/* Field Styles */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.field label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input {
  padding-right: 50px;
}

.input-with-unit .unit {
  position: absolute;
  right: 12px;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  color: var(--text-muted);
  pointer-events: none;
}

input[type="number"],
select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  outline: none;
}

input[type="number"]:hover,
select:hover {
  border-color: var(--border-default);
}

input[type="number"]:focus,
select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inline Field (Checkbox) */
.inline-field {
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
}

.inline-field label {
  text-transform: none;
  font-size: 0.875rem;
  color: var(--text-primary);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* API Status */
.api-status {
  min-height: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Results Panel ─────────────────────────────────────────────────────────── */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SOLAR ANALYTICS DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── Section 1: Comparison Cards ─────────────────────────────────────────────── */
.comparison-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.compare-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.card-header-bar {
  height: 4px;
}

.bar-red { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-green { background: linear-gradient(90deg, #10b981, #34d399); }

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
}

.card-before .card-title { color: #ef4444; }
.card-after .card-title { color: #10b981; }

.card-icon { font-size: 1rem; }

.card-body {
  padding: var(--space-lg);
}

.card-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.card-big-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: var(--space-md);
}

.card-big-value .currency {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card-before .card-big-value .currency { color: #ef4444; }
.card-after .card-big-value.green .currency { color: #10b981; }

.card-big-value .value {
  font-family: var(--font-sans);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.card-big-value.green .value { color: #10b981; }

.card-big-value .period {
  font-size: 1rem;
  color: var(--text-muted);
}

.card-big-value.green .period { color: #10b981; }

.card-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.detail-amount {
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-primary);
}

/* Card After specific styles */
.card-value-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.savings-badge {
  background: #10b981;
  color: white;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
}

.savings-bar {
  height: 8px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.savings-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #34d399 var(--fill-percent, 50%), var(--bg-surface) var(--fill-percent, 50%));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

/* Stacked bar for DOPO card */
.stacked-bar {
  display: flex;
  height: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.stacked-segment {
  height: 100%;
  transition: width 0.5s ease;
}

.segment-risparmio { background: #10b981; }
.segment-gse { background: #f59e0b; }
.segment-detrazione { background: #3b82f6; }
.segment-rata { background: #ef4444; }

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.breakdown-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.breakdown-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.green { background: #10b981; }
.dot.amber { background: #f59e0b; }
.dot.red { background: #ef4444; }
.dot.blue { background: #3b82f6; }

.breakdown-label { flex: 1; }

.breakdown-amount {
  font-family: var(--font-sans);
  font-weight: 600;
  color: #10b981;
}

.breakdown-amount.green { color: #10b981; }
.breakdown-amount.amber { color: #f59e0b; }
.breakdown-amount.red { color: #ef4444; }
.breakdown-amount.blue { color: #3b82f6; }

/* ─── Section 2: Status Bar ───────────────────────────────────────────────────── */
.status-bar-card {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-lg);
}

.status-left {
  flex-shrink: 0;
}

.status-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.status-indicator {
  font-size: 1.25rem;
  font-weight: 700;
}

.status-value {
  color: #10b981;
}

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

.status-center {
  flex: 1;
}

.status-scale {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}

.scale-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.scale-label.negative { color: #ef4444; }
.scale-label.positive { color: #10b981; }

.status-track {
  position: relative;
  height: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  display: flex;
  overflow: visible;
}

.status-track-negative {
  flex: 1;
  background: linear-gradient(90deg, #fecaca 0%, #fef3c7 100%);
  border-radius: var(--radius-full) 0 0 var(--radius-full);
}

.status-track-positive {
  flex: 1;
  background: linear-gradient(90deg, #d1fae5 0%, #10b981 100%);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.status-cursor {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  background: #10b981;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: left 0.5s ease;
}

.status-right {
  flex-shrink: 0;
  text-align: right;
}

.status-result-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.status-result-value {
  font-family: var(--font-sans);
  font-size: 1.75rem;
  font-weight: 700;
  color: #10b981;
}

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

/* ─── Section 3: Detail Charts ────────────────────────────────────────────────── */
.detail-charts {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.detail-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-lg);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xs);
}

.detail-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-sm) 0;
}

.detail-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

.breakeven-badge {
  background: #fef3c7;
  color: #b45309;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.breakeven-badge strong {
  color: #92400e;
}

/* Waterfall Chart */
.waterfall-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.waterfall-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.waterfall-label {
  width: 70px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: right;
  line-height: 1.2;
  flex-shrink: 0;
}

.waterfall-bar-container {
  flex: 1;
  height: 32px;
  position: relative;
}

.waterfall-bar {
  height: 100%;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  min-width: 80px;
  transition: width 0.5s ease;
  position: relative;
}

.waterfall-bar.bar-red { background: linear-gradient(90deg, #ef4444, #fca5a5); }
.waterfall-bar.bar-green { background: linear-gradient(90deg, #10b981, #6ee7b7); }
.waterfall-bar.bar-green-dark { background: linear-gradient(90deg, #059669, #34d399); }
.waterfall-bar.bar-orange { background: linear-gradient(90deg, #f59e0b, #fcd34d); }
.waterfall-bar.bar-blue { background: linear-gradient(90deg, #3b82f6, #93c5fd); }
.waterfall-bar.bar-black { background: linear-gradient(90deg, #1f2937, #4b5563); }

.waterfall-value {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  padding: 0 var(--space-sm);
  white-space: nowrap;
}

.waterfall-result {
  margin-top: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 2px dashed var(--border-subtle);
}

/* Investment Chart */
.investment-chart {
  height: 180px;
  margin-bottom: var(--space-lg);
}

.investment-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

.investment-summary {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--space-md);
}

.summary-card {
  padding: var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}

.summary-card.green {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

.summary-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-xs);
}

.summary-card.green .summary-label {
  color: #065f46;
}

.summary-value {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-card.green .summary-value {
  color: #047857;
}

/* Charts section is now part of detail-charts */

.chart-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.legend-item:hover {
  background: var(--bg-hover);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.legend-value {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: var(--space-xs);
}

.legend-dot.positive {
  background: var(--positive);
}

.legend-dot.negative {
  background: var(--negative);
}

/* ─── Cashflow Table Section ────────────────────────────────────────────────── */
.cashflow-table-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  user-select: none;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  list-style: none;
}

.table-toggle::-webkit-details-marker {
  display: none;
}

.table-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toggle-icon {
  font-size: 1.25rem;
  font-weight: 300;
  transition: transform var(--transition-base);
}

.cashflow-table-section[open] .toggle-icon {
  transform: rotate(45deg);
}

.table-wrapper {
  max-height: 400px;
  overflow-y: auto;
  border-top: 1px solid var(--border-subtle);
}

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

.cashflow-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.cashflow-table th {
  background: var(--bg-surface);
  padding: var(--space-sm) var(--space-md);
  text-align: right;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
}

.cashflow-table th:first-child {
  text-align: left;
}

.cashflow-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: right;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

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

.cashflow-table td:last-child {
  font-weight: 700;
}

.cashflow-table tr:hover td {
  background: var(--bg-hover);
}

.cashflow-table .positive {
  color: var(--positive);
}

.cashflow-table .negative {
  color: var(--negative);
}

/* ─── Scrollbar Styling ─────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Number Input Arrows (hidden for touch-friendly UI) ────────────────────── */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
  display: none;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ─── Animations for Value Changes ──────────────────────────────────────────── */
@keyframes valueUpdate {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.value-updated {
  animation: valueUpdate 300ms ease-out;
}

/* ─── Loading State ─────────────────────────────────────────────────────────── */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ─── PDF Preventivo Button ────────────────────────────────────────────────── */
.btn-preventivo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-light) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--brand-red-glow);
}

.btn-preventivo:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--brand-red-glow);
}

.btn-preventivo:active {
  transform: translateY(0);
}

.btn-preventivo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  pointer-events: none;
}

.btn-preventivo-icon {
  font-size: 1.25rem;
}

.btn-preventivo-text {
  letter-spacing: 0.02em;
}

/* ─── Modal Styles ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal-content {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

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

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-hover);
  border-color: var(--brand-red);
  color: var(--brand-red);
}

.modal-body {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.modal-body input[type="text"] {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: all var(--transition-fast);
  outline: none;
}

.modal-body input[type="text"]:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px var(--brand-red-glow);
}

.modal-body input[type="text"]::placeholder {
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-red-light) 100%);
  color: white;
  box-shadow: 0 2px 10px var(--brand-red-glow);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px var(--brand-red-glow);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 1rem;
}

/* ─── Manual Quote Section ─────────────────────────────────────────────────── */
.section-manual-quote .section-header {
  border-left-color: var(--accent-primary);
}

.multi-select-container {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  padding: var(--space-xs);
}

.multi-select-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 0.85rem;
}

.multi-select-item:hover {
  background: var(--bg-hover);
}

.multi-select-item.selected {
  background: var(--accent-subtle);
  border: 1px solid var(--accent-primary);
}

.multi-select-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.multi-select-item .item-label {
  flex: 1;
  color: var(--text-primary);
}

.multi-select-item .item-price {
  font-weight: 600;
  color: var(--accent-primary);
  font-family: var(--font-sans);
}

.multi-select-group {
  margin-top: var(--space-sm);
}

.multi-select-group-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-xs);
}

.selected-systems-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.summary-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.summary-total {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-primary);
  font-family: var(--font-sans);
}

.payment-type-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.title-selector {
  display: flex;
  flex-direction: row;
  gap: var(--space-sm);
}

.title-selector .radio-option {
  flex: 1;
  justify-content: center;
  padding: var(--space-xs) var(--space-sm);
}

.radio-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.radio-option:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.radio-option:has(input:checked) {
  background: var(--accent-subtle);
  border-color: var(--accent-primary);
}

.radio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.radio-label {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.btn-manual-quote {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  margin-top: var(--space-md);
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: white;
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-manual-quote:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-manual-quote:active {
  transform: translateY(0);
}

.btn-manual-quote .btn-icon {
  font-size: 1.1rem;
}

/* Modal textarea styling */
.modal-body textarea,
.section-content textarea {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.modal-body textarea:focus,
.section-content textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-body textarea::placeholder,
.section-content textarea::placeholder {
  color: var(--text-muted);
}

/* ─── Datasheet Options ──────────────────────────────────────────────────── */
.datasheet-options {
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.datasheet-options .field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  cursor: pointer;
  user-select: none;
}

.checkbox-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-red);
  cursor: pointer;
}

.checkbox-option .checkbox-label {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.checkbox-option:hover .checkbox-label {
  color: var(--accent-primary);
}

.field-hint {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
  line-height: 1.4;
}

.savings-option {
  background: var(--surface-secondary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent-primary);
}

.datasheet-preview {
  margin-top: var(--space-sm);
}

.datasheet-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.datasheet-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.datasheet-tag::before {
  content: "📄 ";
  margin-right: 4px;
}

.datasheet-none {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ─── Datasheet Dropzone ─────────────────────────────────────────────────── */
.datasheet-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--bg-base);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
  min-height: 100px;
}

.datasheet-dropzone:hover {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
}

.datasheet-dropzone.dragover {
  border-color: var(--positive);
  background: var(--positive-subtle);
  transform: scale(1.02);
}

.datasheet-dropzone.uploading {
  border-color: var(--accent-primary);
  opacity: 0.7;
  pointer-events: none;
}

.dropzone-icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

.dropzone-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-subtext {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ─── Datasheet Library ──────────────────────────────────────────────────── */
.datasheet-library {
  margin-top: var(--space-md);
}

.datasheet-category {
  margin-bottom: var(--space-md);
}

.datasheet-category-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.datasheet-category-header .category-icon {
  font-size: 1rem;
}

.datasheet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-sm);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
  font-size: 0.85rem;
  transition: background var(--transition-fast);
}

.datasheet-item:hover {
  background: var(--bg-hover);
}

.datasheet-item-name {
  flex: 1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: var(--space-sm);
}

.datasheet-item-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: var(--space-sm);
}

.datasheet-item-delete {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.datasheet-item-delete:hover {
  background: var(--negative-glow);
  color: var(--negative);
}

.datasheet-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-md);
}

/* ─── Datasheet Selector (for quote modal) ───────────────────────────────── */
.datasheet-selector {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-xs);
}

.selector-category {
  margin-bottom: var(--space-xs);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.selector-category:last-child {
  margin-bottom: 0;
}

.selector-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm);
  background: var(--bg-surface);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.selector-category-header:hover {
  background: var(--bg-hover);
}

.selector-category-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.category-icon {
  font-size: 1rem;
}

.category-name {
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.category-count {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-base);
  padding: 2px 6px;
  border-radius: 10px;
}

.category-count.has-selection {
  background: var(--accent-primary);
  color: white;
}

.category-toggle {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.category-toggle.expanded {
  transform: rotate(180deg);
}

.selector-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-xs);
  background: var(--bg-base);
  max-height: 200px;
  overflow-y: auto;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.selector-items.collapsed {
  max-height: 0;
  padding: 0 var(--space-xs);
  opacity: 0;
  overflow: hidden;
}

.selector-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.selector-item:hover {
  background: var(--bg-hover);
}

.selector-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-red);
  cursor: pointer;
}

.selector-item-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selector-empty {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-md);
}

/* ─── Catalog Management ─────────────────────────────────────────────────── */
.section-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-md) 0;
  line-height: 1.5;
}

.catalog-actions {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.btn-catalog-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
}

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

.btn-catalog-action .btn-icon {
  font-size: 1.1rem;
}

.catalog-upload-section {
  margin-top: var(--space-md);
}

.catalog-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: var(--bg-base);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
  min-height: 80px;
}

.catalog-dropzone:hover {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
}

.catalog-dropzone.dragover {
  border-color: var(--positive);
  background: var(--positive-subtle);
  transform: scale(1.02);
}

.catalog-status {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  text-align: center;
  transition: all var(--transition-base);
}

.catalog-status:empty {
  display: none;
}

.catalog-status.status-info {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
}

.catalog-status.status-success {
  background: var(--positive-subtle);
  color: var(--positive);
  border: 1px solid var(--positive);
}

.catalog-status.status-error {
  background: var(--negative-glow);
  color: var(--negative);
  border: 1px solid var(--negative);
}

/* ─── Button Open Manual Modal ───────────────────────────────────────────── */
.btn-open-manual-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-sm) 0;
  background: linear-gradient(135deg, #C41E3A, #9B1830);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 4px 12px rgba(196, 30, 58, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-open-manual-modal:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(196, 30, 58, 0.4);
}

.btn-open-manual-modal:active {
  transform: translateY(0);
}

.btn-open-manual-modal .btn-icon {
  font-size: 1.1rem;
}

/* ─── Modal Large (for Manual Quote) ─────────────────────────────────────── */
.modal-large {
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-large .modal-header {
  flex: 0 0 auto;
}

.modal-large .modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.modal-large .modal-footer {
  flex: 0 0 auto;
}

.modal-two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  max-width: 100%;
  overflow: hidden;
}

.modal-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0; /* Prevent grid blowout */
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 60vh;
}

.modal-column input,
.modal-column select,
.modal-column textarea {
  max-width: 100%;
  box-sizing: border-box;
}

.modal-column .multi-select-container {
  max-height: 300px;
  overflow-y: auto;
}

.modal-column .datasheet-selector {
  max-height: 150px;
}

/* Responsive: stack columns on smaller screens */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: stretch;
    padding: 0;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-large {
    max-width: 100%;
  }

  .modal-header {
    flex: 0 0 auto;
    padding: var(--space-md);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
  }

  .modal-header h2 {
    font-size: 1.1rem;
  }

  .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-md);
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    flex: 0 0 auto;
    padding: var(--space-md);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
  }

  .modal-two-columns {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .modal-column .multi-select-container {
    max-height: 250px;
  }

  .modal-column .datasheet-selector {
    max-height: 180px;
  }

  /* Larger touch targets */
  .modal-body input[type="text"],
  .modal-body input[type="number"],
  .modal-body select,
  .modal-body textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: var(--space-md);
    min-height: 48px;
  }

  .radio-option,
  .checkbox-option {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .btn {
    min-height: 48px;
    padding: var(--space-md) var(--space-lg);
  }

  /* Mobile layout: reorder so results appear before management sections */
  .main-grid {
    display: flex;
    flex-direction: column;
  }

  .input-panel,
  .calc-form {
    display: contents;
  }

  /* Order: Input sections first, then results, then management sections at bottom */
  details.input-section:nth-of-type(1) { order: 1; } /* Consumi Attuali */
  details.input-section:nth-of-type(2) { order: 2; } /* Impianto Fotovoltaico */
  .btn-open-manual-modal { order: 3; } /* Genera Preventivo button */
  .results-panel { order: 4; } /* Charts and results */
  details.input-section:nth-of-type(3) { order: 5; } /* Gestione Schede Tecniche */
  details.input-section:nth-of-type(4) { order: 6; } /* Gestione Listino */
  details.input-section:nth-of-type(5) { order: 7; } /* Parametri Avanzati */

  /* Mobile hero layout */
  .hero-big-number {
    margin-bottom: var(--space-sm);
  }

  .big-value {
    font-size: 2.5rem;
  }

  .big-currency {
    font-size: 1.25rem;
  }

  .hero-detail {
    font-size: 0.8rem;
    gap: var(--space-xs);
  }

  /* Mobile comparison chart */
  .compare-bar-label {
    width: 50px;
    font-size: 0.75rem;
  }

  .compare-bar-track {
    height: 40px;
  }

  .compare-bar-value {
    font-size: 0.85rem;
  }

  .savings-zone-label {
    font-size: 0.65rem;
  }

  .savings-breakdown {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
  }

  .breakdown-item {
    font-size: 0.8rem;
  }

  /* ─── Mobile Dashboard Styles ─────────────────────────────────────────────────── */

  /* Section 1: Stack comparison cards vertically */
  .comparison-cards {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .card-body {
    padding: var(--space-md);
  }

  .card-big-value .value {
    font-size: 2.25rem;
  }

  .card-big-value .currency {
    font-size: 1.25rem;
  }

  .card-value-row {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .savings-badge {
    align-self: flex-start;
    font-size: 0.85rem;
  }

  .detail-row {
    font-size: 0.8rem;
    padding: var(--space-sm);
  }

  .breakdown-row {
    font-size: 0.8rem;
  }

  /* Section 2: Stack status bar vertically */
  .status-bar-card {
    flex-direction: column;
    padding: var(--space-md);
    gap: var(--space-md);
  }

  .status-left {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .status-indicator {
    font-size: 1rem;
  }

  .status-center {
    width: 100%;
  }

  .scale-label {
    font-size: 0.55rem;
  }

  .status-right {
    width: 100%;
    text-align: center;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-subtle);
  }

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

  /* Section 3: Stack detail charts vertically */
  .detail-charts {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .detail-card {
    padding: var(--space-md);
  }

  .detail-header {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .breakeven-badge {
    align-self: flex-start;
  }

  /* Waterfall chart mobile */
  .waterfall-label {
    width: 55px;
    font-size: 0.6rem;
  }

  .waterfall-bar-container {
    height: 28px;
  }

  .waterfall-value {
    font-size: 0.7rem;
  }

  /* Investment chart mobile */
  .investment-chart {
    height: 150px;
  }

  .investment-summary {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .summary-card {
    padding: var(--space-sm) var(--space-md);
  }

  .summary-value {
    font-size: 1.1rem;
  }
}
