/* --- Reset & base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --color-bg: #0f1419;
  --color-surface: #1a2332;
  --color-surface-alt: #243044;
  --color-border: #2d3d52;
  --color-text: #e6edf3;
  --color-text-muted: #8b9cb3;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;
  --color-success: #22c55e;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", monospace;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.5;
  padding: 2rem 1rem;
}

/* --- Layout --- */
.calculator {
  max-width: 900px;
  margin: 0 auto;
}

.calculator-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.calculator-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.calculator-grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 700px) {
  .calculator-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* --- Panels --- */
.inputs-panel,
.results-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.inputs-panel h2,
.results-panel h2 {
  margin: 0 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Form fields --- */
.field {
  margin-bottom: 1.25rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}

.field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: var(--font-mono);
  color: var(--color-text);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  transition: border-color 0.15s ease;
}

.field input:hover {
  border-color: var(--color-text-muted);
}

.field input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.field input::placeholder {
  color: var(--color-text-muted);
}

.field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* --- Optional section --- */
.optional-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.optional-section summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-accent);
  list-style: none;
}

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

.optional-section summary::before {
  content: "▶ ";
  font-size: 0.7rem;
  margin-right: 0.25rem;
}

.optional-section[open] summary::before {
  content: "▼ ";
}

.optional-section .field {
  margin-top: 1rem;
}

/* --- Results --- */
.result-summary {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.result-row:last-child {
  margin-bottom: 0;
}

.result-row--primary {
  margin-bottom: 1rem;
}

.result-row--primary .result-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-success);
  font-family: var(--font-mono);
}

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

.result-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  text-align: right;
}

.result-breakdown .result-value {
  font-size: 0.95rem;
}

.result-totals .result-row {
  margin-bottom: 0.6rem;
}

.result-totals .result-value {
  font-weight: 600;
}

/* Hide optional breakdown rows when zero */
.result-row[data-hidden="true"] {
  display: none;
}
