:root {
  --primary: #622d8d;
  --primary-light: #f4eaff;
  --primary-hover: #4e2272;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --bg-color: #f8fafc;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-solid: #ffffff;
  --border: rgba(226, 232, 240, 0.8);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Dynamic Background Shapes ── */
.bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  opacity: 0.6;
  animation: float 20s infinite alternate cubic-bezier(0.45, 0.05, 0.55, 0.95);
}
.bg-shape-1 {
  width: 700px;
  height: 700px;
  background: #c084fc;
  top: -200px;
  left: -200px;
}
.bg-shape-2 {
  width: 600px;
  height: 600px;
  background: #6EE7B7;
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 60px) scale(1.05); }
  100% { transform: translate(-30px, 30px) scale(0.95); }
}

/* ── Wrapper & Layout ── */
.app-wrapper {
  max-width: 1300px;
  margin: 0 auto;
  padding: 50px 24px 80px;
}

/* ── Header ── */
.app-header {
  text-align: center;
  margin-bottom: 50px;
}

.logo-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-solid);
  padding: 8px 20px;
  border-radius: 100px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.logo-text {
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-size: 0.85rem;
}

.main-title {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
  margin-bottom: 16px;
  letter-spacing: -1.5px;
}

.main-title span {
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
  font-weight: 500;
}

/* ── Dashboard Grid ── */
.dashboard {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 32px;
  align-items: start;
}

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

/* ── Panels (Glassmorphism) ── */
.panel {
  background: var(--surface);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

.panel:hover {
  box-shadow: var(--shadow-lg);
  background: rgba(255, 255, 255, 0.9);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}

.panel-icon {
  width: 52px;
  height: 52px;
  background: var(--primary-light);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: inset 0 0 0 1px rgba(98, 45, 141, 0.1);
}
.panel-icon.highlight {
  background: var(--success-light);
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.2);
}

.panel-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

/* ── Inputs ── */
.section-label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  margin-bottom: 16px;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.input-grid.grid-4 {
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.input-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-box label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light), inset 0 2px 4px rgba(0,0,0,0.01);
}

.prefix {
  padding-left: 16px;
  color: var(--text-muted);
  font-size: 1rem;
}
.suffix {
  padding-right: 16px;
  color: var(--text-muted);
  font-weight: 700;
}

.input-wrap input {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  padding: 16px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
}

.input-box.small .input-wrap input {
  padding: 12px 14px;
  font-size: 1rem;
}

/* Remove spin buttons */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

/* ── Collapsible Groups ── */
.collapsible-group {
  margin-bottom: 16px;
}

.toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.toggle-icon {
  display: flex;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-muted);
}

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

.collapsible-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), margin 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.collapsible-panel.open {
  max-height: 500px;
  opacity: 1;
  margin-top: 16px;
}

/* ── Primary Button ── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--primary), #8839c4);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 8px 20px rgba(98, 45, 141, 0.25);
  margin-top: 32px;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 25px rgba(98, 45, 141, 0.35);
  background: linear-gradient(135deg, #7434a7, #9b41dd);
}

.btn-primary svg {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover svg {
  transform: translateX(5px);
}

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 36px;
}

.kpi-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
}

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-sm);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: var(--text-muted);
}

.kpi-card.standout::before { background: var(--primary); }
.kpi-card.success::before { background: var(--success); }

.kpi-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 10px;
  letter-spacing: -1px;
}

.kpi-card.standout .kpi-value { color: var(--primary); }
.kpi-card.success .kpi-value { color: var(--success); }

.kpi-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  font-weight: 500;
}

/* Result animation */
.result-card.pop .kpi-value {
  animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ── Comparisons Widgets ── */
.comparison-widget {
  background: var(--surface-solid);
  border-radius: var(--radius-md);
  padding: 28px;
  border: 1px solid var(--border);
  margin-bottom: 36px;
}

.comparison-widget h3 {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 24px;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.bar-container {
  margin-bottom: 20px;
}

.bar-container:last-child {
  margin-bottom: 0;
}

.bar-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #475569;
}

.bar-info .val {
  font-weight: 800;
  color: var(--text-main);
}

.progress-track {
  height: 14px;
  background: #e2e8f0;
  border-radius: 100px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.progress-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.fill-red { background: linear-gradient(90deg, #f87171, #ef4444); }
.fill-green { background: linear-gradient(90deg, #34d399, var(--success)); }

/* ── Breakdown List ── */
.breakdown-box {
  background: rgba(248, 250, 252, 0.6);
  border-radius: var(--radius-md);
  padding: 28px;
  border: 1px solid var(--border);
}

.breakdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.breakdown-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.b-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.b-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
  padding-bottom: 14px;
  border-bottom: 1px dashed #cbd5e1;
}

.b-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.b-item strong {
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.b-item.subtotal {
  font-weight: 700;
  padding-top: 10px;
  color: var(--text-main);
  border-bottom: 1px solid #cbd5e1;
}

.b-item.positive strong {
  color: var(--success);
}

.b-item.final {
  padding-top: 20px;
  font-size: 1.15rem;
}

.b-item.final strong {
  font-size: 1.35rem;
  color: var(--primary);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-wrapper {
    padding: 30px 16px 50px;
  }
  
  .main-title {
    font-size: 2.2rem;
    letter-spacing: -1px;
  }
  
  .panel {
    padding: 24px;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .input-grid.grid-4 {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 1.6rem;
  }
}
