* {
  box-sizing: border-box;
}

:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background: #eef2f7;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(59,130,246,.12), transparent 35%),
    #eef2f7;
}

.app-shell {
  width: min(920px, calc(100% - 28px));
  margin: 36px auto;
}

.card {
  background: rgba(255,255,255,.96);
  border: 1px solid #dbe3ee;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(15,23,42,.08);
  padding: 28px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  color: #2563eb;
}

h1 {
  margin: 8px 0 6px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
}

.subtitle {
  margin: 0 0 24px;
  color: #475569;
  font-size: 16px;
}

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

label span {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 7px;
  color: #334155;
}

input, select {
  width: 100%;
  min-height: 50px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 0 14px;
  background: white;
  color: #0f172a;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59,130,246,.12);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

button {
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  background: #2563eb;
  color: white;
  flex: 1;
}

.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.error {
  margin-top: 18px;
  padding: 13px 15px;
  border-radius: 12px;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.results {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid #e2e8f0;
}

.results h2 {
  margin: 0 0 16px;
  font-size: 22px;
}

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

.result-item {
  min-height: 122px;
  border-radius: 16px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.result-item span {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.result-item strong {
  margin: 5px 0 2px;
  font-size: 30px;
  letter-spacing: -.02em;
}

.result-item small {
  color: #64748b;
}

.result-item.wide {
  grid-column: 1 / -1;
}

.formula-box {
  margin-top: 16px;
  padding: 15px 16px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
}

.formula-box summary {
  cursor: pointer;
  font-weight: 800;
}

#formulaText {
  margin-top: 12px;
  line-height: 1.7;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 920px);
    margin: 16px auto;
  }

  .card {
    border-radius: 18px;
    padding: 18px;
  }

  .grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-item.wide {
    grid-column: auto;
  }

  .actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
