:root {
  --text: #1b1b1b;
  --muted: #4d4d4d;
  --border: #d0d0d0;
  --panel: #f7f7f7;
  --blue: #003087;
  --blue-hover: #002766;
  --error: #b00020;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Tahoma, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #ffffff;
  line-height: 1.5;
}

a {
  color: var(--blue);
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.site-logo {
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.nav-links,
.footer-links {
  list-style: none;
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
}

.nav-links a,
.footer-links a {
  text-decoration: underline;
}

.hero {
  padding: 2rem 0 1rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

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

.calculator-section {
  padding: 0.5rem 0 1.8rem;
}

.calculator-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 1.1rem;
}

.mode-fieldset {
  border: 1px solid var(--border);
  margin: 0 0 1rem;
  padding: 0.7rem 0.8rem;
}

.mode-fieldset legend {
  font-weight: 700;
  padding: 0 0.3rem;
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.mode-options label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.9rem;
}

.field-group {
  display: flex;
  flex-direction: column;
}

.field-group label {
  margin-bottom: 0.35rem;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid #8f8f8f;
  background: #ffffff;
  color: var(--text);
  padding: 0.62rem;
}

.field-help {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.is-hidden {
  display: none;
}

.calculate-button {
  margin-top: 1rem;
  width: 100%;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 1rem;
  cursor: pointer;
}

.calculate-button:hover {
  background: var(--blue-hover);
}

.form-error {
  min-height: 1.2em;
  margin: 0.7rem 0 0;
  color: var(--error);
  font-size: 0.93rem;
}

.result-box,
.scenario-section,
.disclaimer-box {
  margin-top: 1rem;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 1rem;
}

.result-box h2,
.scenario-section h2 {
  margin-top: 0;
}

.main-result {
  border: 1px solid var(--border);
  background: #f5f5f5;
  padding: 0.85rem;
  margin-bottom: 0.9rem;
}

.result-label {
  margin: 0 0 0.22rem;
  color: #2b2b2b;
  font-weight: 600;
}

.result-value {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

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

.result-item {
  border: 1px solid var(--border);
  background: #fafafa;
  padding: 0.72rem;
}

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

.copy-button {
  margin-top: 0.6rem;
  border: 1px solid #6f6f6f;
  background: #ffffff;
  color: var(--text);
  padding: 0.34rem 0.7rem;
  cursor: pointer;
  font-size: 0.88rem;
}

.copy-button:hover {
  background: #efefef;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border: 1px solid var(--border);
  padding: 0.58rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f3f3f3;
}

.disclaimer-box {
  background: #f5f5f5;
}

.disclaimer-box p {
  margin: 0;
  font-size: 0.95rem;
}

.content-section {
  border-top: 1px solid #ececec;
  padding: 1.3rem 0;
}

.content-section h2 {
  margin-top: 0;
}

.formula-block {
  border: 1px solid var(--border);
  background: #f9f9f9;
  padding: 0.78rem;
}

.formula-block p:last-child {
  margin-bottom: 0;
}

details {
  border: 1px solid var(--border);
  background: #fbfbfb;
  padding: 0.75rem;
  margin-bottom: 0.65rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: #fafafa;
  padding: 1.3rem 0 2rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.footer-inner p {
  margin: 0;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (max-width: 780px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .mode-options,
  .footer-links,
  .nav-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

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

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