:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #64748b;
  --accent: #10b981;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --input-bg: #f1f5f9;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 16px;
  --font: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  background-color: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 16px;
}

#rvb-calculator-plugin .page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Header Section */
#rvb-calculator-plugin .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
  gap: 20px;
}

#rvb-calculator-plugin .topbar h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

#rvb-calculator-plugin .sub {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
}

/* Actions */
#rvb-calculator-plugin .actions {
  display: flex;
  gap: 12px;
}

#rvb-calculator-plugin .btn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#rvb-calculator-plugin .btn.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

#rvb-calculator-plugin .btn.secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
}

/* Layout Grid */
#rvb-calculator-plugin .grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: start;
  width: 100%;
}

#rvb-calculator-plugin .card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 32px;
  transition: padding 0.3s ease;
  min-width: 0;
  /* Prevents grid blowout */
}

/* Form Styles */
#rvb-calculator-plugin .section {
  margin-bottom: 32px;
}

#rvb-calculator-plugin .section h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

#rvb-calculator-plugin .section h2::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
}

#rvb-calculator-plugin .row {
  margin-bottom: 20px;
}

#rvb-calculator-plugin .row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#rvb-calculator-plugin .row input,
#rvb-calculator-plugin .row select {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 16px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-main);
  transition: all 0.2s ease;
}

#rvb-calculator-plugin .split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Results Card */
#rvb-calculator-plugin .results-card {
  position: sticky;
  top: 40px;
}

#rvb-calculator-plugin .results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

#rvb-calculator-plugin .pill {
  background: rgba(16, 185, 129, 0.1);
  /* Fallback */
  background: color-mix(in srgb, var(--accent), transparent 90%);
  color: var(--accent);
  padding: 8px 16px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 14px;
}

#rvb-calculator-plugin .mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

#rvb-calculator-plugin .mini-item {
  padding: 20px;
  background: var(--input-bg);
  border-radius: 16px;
  text-align: center;
}

#rvb-calculator-plugin .chart-wrap {
  margin-bottom: 32px;
  background: var(--input-bg);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  min-height: 300px;
}

#rvb-calculator-plugin .table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
  max-height: 500px;
}

#rvb-calculator-plugin table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

#rvb-calculator-plugin thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  z-index: 10;
}

#rvb-calculator-plugin tbody td {
  padding: 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 500;
}

/* Responsive Styles */
@media (max-width: 640px) {
  #rvb-calculator-plugin .grid {
    grid-template-columns: 1fr !important;
  }

  #rvb-calculator-plugin .results-card {
    position: static;
  }

  #rvb-calculator-plugin .page {
    padding: 24px 16px;
  }

  #rvb-calculator-plugin .topbar {
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 32px;
    gap: 16px;
  }

  #rvb-calculator-plugin .topbar h1 {
    font-size: 28px;
  }

  #rvb-calculator-plugin .actions {
    width: 100%;
    justify-content: center;
  }

  #rvb-calculator-plugin .btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 16px;
  }

  #rvb-calculator-plugin .card {
    padding: 24px 20px;
  }

  #rvb-calculator-plugin .mini {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  #rvb-calculator-plugin .mini-value {
    font-size: 22px;
  }

  #rvb-calculator-plugin .chart-wrap {
    min-height: 280px;
    padding: 12px;
  }

  #rvb-calculator-plugin .pill {
    width: 100%;
    text-align: center;
    margin-top: 8px;
  }

  #rvb-calculator-plugin .results-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  #rvb-calculator-plugin .split {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}