:root {
  /* Palette: Midnight Savannah */
  --bg-deep: #0f0f11;
  --bg-panel: #18181b;
  --bg-input: #232328;

  --text-primary: #edeadd;
  --text-secondary: #8c8c9a;

  /* Accents */
  --accent-ochre: #d4a373; /* Sand */
  --accent-clay: #bc6c25; /* Deep earth */
  --accent-neon: #ffba08; /* Highlight */
  --success: #606c38;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --glass-effect: rgba(24, 24, 27, 0.85);

  /* Typography */
  --font-display: "Syne", sans-serif;
  --font-body: "Manrope", sans-serif;

  --radius-lg: 24px;
  --radius-md: 12px;
}

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

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

/* --- Atmosphere --- */
.noise-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.ambient-light {
  position: fixed;
  top: -10%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(
    circle,
    rgba(212, 163, 115, 0.15) 0%,
    rgba(15, 15, 17, 0) 70%
  );
  filter: blur(80px);
  z-index: 0;
  animation: pulseLight 10s ease-in-out infinite alternate;
}

@keyframes pulseLight {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* --- Layout --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.calculator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 3rem;
}

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

/* --- Typography --- */
header {
  text-align: center;
  margin-bottom: 2rem;
}

.main-title {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  background: linear-gradient(135deg, #fff 0%, #b8b8b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.highlight {
  color: var(--accent-ochre);
  -webkit-text-fill-color: var(--accent-ochre);
}

.subtitle {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--accent-ochre);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

/* --- Panels --- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transition: transform 0.4s ease;
}

.panel:hover {
  border-color: rgba(212, 163, 115, 0.2);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.decoration-line {
  flex-grow: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-subtle), transparent);
}

/* --- Forms & Inputs --- */
.input-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

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

.field-container {
  position: relative;
  transition: all 0.3s ease;
}

.field-container:focus-within {
  transform: translateY(-2px);
}

.input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: color 0.3s;
}

input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid transparent;
  color: var(--text-primary);
  padding: 1rem 1rem 1rem 2.8rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s;
}

input:focus {
  outline: none;
  background: #2a2a30;
  border-color: var(--accent-ochre);
  box-shadow: 0 0 0 4px rgba(212, 163, 115, 0.1);
}

input:focus + .input-icon,
.field-container:focus-within .input-icon {
  color: var(--accent-ochre);
}

input::placeholder {
  color: rgba(140, 140, 154, 0.4);
}

/* --- Action Button --- */
.action-area {
  margin-top: 2.5rem;
}

.btn-calculate {
  width: 100%;
  background: var(--text-primary);
  color: var(--bg-deep);
  border: none;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.btn-calculate:hover {
  background: var(--accent-ochre);
  transform: scale(1.02);
  box-shadow: 0 10px 20px rgba(212, 163, 115, 0.2);
}

.btn-calculate:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
}

.btn-calculate.is-loading .btn-text,
.btn-calculate.is-loading .btn-icon {
  display: none;
}

/* Simple CSS loader for button */
.loader {
  display: none;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--bg-deep);
  animation: spin 1s ease-in-out infinite;
}

.btn-calculate.is-loading .loader {
  display: block;
}

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

/* --- Results & Metrics --- */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: rgba(255, 255, 255, 0.03);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background 0.3s;
}

.highlight-card {
  grid-column: span 2;
  background: linear-gradient(
    135deg,
    rgba(212, 163, 115, 0.1),
    rgba(188, 108, 37, 0.05)
  );
  border-color: rgba(212, 163, 115, 0.2);
  text-align: center;
}

.metric-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.metric-value {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.metric-value.large {
  font-size: 3.5rem;
  color: var(--accent-ochre);
  font-family: var(--font-display);
}

.metric-value.small {
  font-size: 1.1rem;
}

/* --- Chart Wrapper --- */
.chart-wrapper {
  position: relative;
  height: 250px;
  width: 100%;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* --- Animations --- */
.fade-in-up {
  opacity: 0;
  transform: translateY(30px);
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.delay-100 {
  animation-delay: 0.15s;
}

.header-animate {
  opacity: 0;
  animation: fadeIn 1s ease forwards;
}

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

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

/* --- Mobile Fixes --- */
@media (max-width: 600px) {
  .main-title {
    font-size: 2.5rem;
  }
  .input-group-grid {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 1.5rem;
  }
  .metric-value.large {
    font-size: 2.5rem;
  }
}
