:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --success: #4ade80;
  --border: #334155;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  background: radial-gradient(circle at top, #1e293b, var(--bg));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 24px;
}

@media (min-width: 1100px) {
  .container {
    max-width: none;
    padding: 48px 32px;
  }
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.results-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.breakdown-section {
  margin-top: 32px;
}

.breakdown-section > summary {
  cursor: pointer;
  list-style: none;
  margin: 0 0 12px;
  font-size: 1.15rem;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}

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

.breakdown-section > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 120ms ease;
}

.breakdown-section[open] > summary::before {
  transform: rotate(90deg);
}

@media (min-width: 1100px) {
  .workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
    align-items: start;
    gap: 24px;
  }
  .results-aside {
    position: sticky;
    top: 24px;
  }
}

header {
  text-align: center;
  margin-bottom: 32px;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 700;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.calc-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

input, select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.input-with-prefix, .input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-prefix input { padding-left: 28px; width: 100%; }
.input-with-suffix input { padding-right: 32px; width: 100%; }

.prefix, .suffix {
  position: absolute;
  color: var(--muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.prefix { left: 12px; }
.suffix { right: 12px; }

.btn-primary {
  background: var(--accent-strong);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease;
}

.btn-primary:hover { background: var(--accent); }
.btn-primary:active { transform: translateY(1px); }

.field-full { grid-column: 1 / -1; }

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

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

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

.btn-icon {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn-icon:hover {
  color: #f87171;
  border-color: #f87171;
}

.lumpsums-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lumpsum-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  align-items: center;
}

.pension-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  align-items: center;
}

.contribution-row,
.withdrawal-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  gap: 8px;
  align-items: center;
}

.lumpsum-row input,
.pension-row input,
.contribution-row input,
.withdrawal-row input { width: 100%; }

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

.hint-inline {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.75rem;
}

.results {
  margin-top: 32px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow);
}

.result-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.result-card:nth-child(2) .result-value { color: var(--text); }
.result-card:nth-child(3) .result-value { color: var(--accent); }

h2 {
  margin: 32px 0 12px;
  font-size: 1.15rem;
  color: var(--muted);
  font-weight: 600;
}

.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

.chart-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  height: 520px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 32px 0 12px;
}

.chart-header h2 {
  margin: 0;
}

.chart-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.chart-toggle button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.chart-toggle button:hover { color: var(--text); }

.chart-toggle button.active {
  background: var(--accent-strong);
  color: white;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th:first-child, td:first-child {
  text-align: left;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}

tbody tr:last-child td { border-bottom: none; }

@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
}
