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

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --success: #15803d;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(16, 24, 40, 0.12);
  --radius-lg: 24px;
  --radius-md: 14px;
}

body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, #e0e7ff 0, transparent 28%),
    radial-gradient(circle at bottom right, #dbeafe 0, transparent 32%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.calculator-card {
  width: min(100%, 700px);
  background: var(--card);
  border: 1px solid rgba(228, 231, 236, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px;
}

.heading {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.heading h1 {
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  line-height: 1.15;
  margin-bottom: 12px;
}

.heading p {
  max-width: 560px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.65;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.step {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  background: #fafafa;
}

.step.active {
  border-color: #c7d2fe;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.step-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 0.78rem;
}

.total-panel {
  text-align: center;
  padding: 24px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #111827, #312e81);
  color: #fff;
  border-radius: 18px;
}

.total-label,
.total-panel small {
  display: block;
}

.total-label {
  opacity: 0.76;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.total-panel strong {
  display: block;
  font-size: clamp(2.4rem, 8vw, 4rem);
  line-height: 1;
  margin-bottom: 10px;
  word-break: break-word;
}

.total-panel small {
  opacity: 0.72;
}

.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}

.input-group input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  outline: none;
  transition: 0.2s ease;
  background: #fff;
  color: var(--text);
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.input-group input:disabled {
  background: #f2f4f7;
  cursor: not-allowed;
}

.helper-text {
  margin-top: 7px;
  font-size: 0.82rem;
  color: var(--muted);
}

.error-message {
  min-height: 20px;
  margin-top: 6px;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 700;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  border: 0;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-weight: 800;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #f2f4f7;
  color: #344054;
  border: 1px solid var(--line);
}

.btn-secondary:hover:not(:disabled) {
  background: #eaecf0;
}

.history-section {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

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

.history-header h2 {
  font-size: 1rem;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
}

.history-empty {
  color: var(--muted);
  text-align: center;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.history-list {
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
}

.history-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.history-item strong {
  word-break: break-word;
}

.final-result {
  margin-top: 24px;
  text-align: center;
  padding: 28px 20px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 18px;
}

.final-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--success);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 900;
}

.final-result p {
  color: #166534;
  font-weight: 800;
  margin-bottom: 8px;
}

.final-result strong {
  display: block;
  font-size: clamp(2.3rem, 8vw, 3.7rem);
  line-height: 1.05;
  margin-bottom: 6px;
  color: #14532d;
  word-break: break-word;
}

.final-caption {
  display: block;
  color: #4d7c0f;
  margin-bottom: 18px;
}

@media (max-width: 640px) {
  .calculator-card {
    padding: 22px 16px;
    border-radius: 18px;
  }

  .workflow {
    grid-template-columns: 1fr;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .page-shell {
    padding: 16px 12px;
  }
}
