:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --paper: #ffffff;
  --ink: #10131a;
  --muted: #667085;
  --line: #d7dce5;
  --line-dark: #b8c0cf;
  --navy: #071a33;
  --navy-2: #0d2a4f;
  --gold: #b58a38;
  --gold-soft: #efe3c8;
  --danger: #9f1d1d;
  --shadow: 0 18px 42px rgba(7, 26, 51, 0.12);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(rgba(7, 26, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7, 26, 51, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, #f4f2ec, #faf9f5);
  background-size: 32px 32px, 32px 32px, auto;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  background: transparent;
}

button,
input {
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 18px;
  padding: 26px 28px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(181, 138, 56, 0.16), transparent 35%),
    linear-gradient(135deg, var(--navy), var(--navy-2));
  border: 1px solid rgba(181, 138, 56, 0.42);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand {
  margin-bottom: 8px;
  color: #d8bd82;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Cambria, Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
}

.status-block {
  min-width: 240px;
  padding: 10px 12px;
  border: 1px solid rgba(216, 189, 130, 0.5);
  border-radius: 3px;
  color: #f3e6c7;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 18px;
  align-items: stretch;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.form-card,
.summary-card,
.result-card {
  padding: 24px;
}

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

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

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

.field span {
  color: #202938;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  min-height: 56px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 3px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(181, 138, 56, 0.16);
}

#amount {
  min-height: 80px;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: -0.045em;
}

input[type="date"] {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  min-height: 50px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform .12s, box-shadow .12s, background .12s, border-color .12s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(7, 26, 51, 0.14);
}

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

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

.btn-secondary {
  color: #fff;
  background: #866221;
  border-color: #866221;
}

.btn-light {
  color: var(--navy);
  background: #fff;
  border-color: var(--line-dark);
}

.summary-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background:
    linear-gradient(180deg, #ffffff, #f9f7f1);
}

.summary-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.total {
  margin: 16px 0 18px;
  padding: 18px 0;
  border-top: 2px solid var(--navy);
  border-bottom: 1px solid var(--line);
  color: var(--navy);
  font-family: Cambria, Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 45px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}

.metric span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.progress-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 800;
}

.progress-head span {
  color: var(--navy);
}

.progress-head strong {
  color: #866221;
  font-family: Cambria, Georgia, "Times New Roman", serif;
  font-size: 24px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 2px;
  background: #f4f1e8;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--navy), #866221);
  transition: width .22s ease;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.step i {
  width: 14px;
  height: 14px;
  display: inline-block;
  border: 2px solid var(--line-dark);
  background: #fff;
}

.step.active {
  color: var(--navy);
  border-color: #d5c090;
  background: #fbf8ef;
}

.step.done i {
  border-color: var(--gold);
  background: var(--gold);
}

.alert {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #e0a5a5;
  border-radius: 3px;
  color: var(--danger);
  background: #fff7f7;
  font-weight: 700;
}

.result-card {
  margin-top: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--navy);
}

.section-head h2 {
  color: var(--navy);
  font-family: Cambria, Georgia, "Times New Roman", serif;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.mini-chart {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  min-height: 88px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.chart-item {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 28px;
}

.chart-bar {
  width: 22px;
  min-height: 8px;
  border: 1px solid var(--navy);
  background: linear-gradient(180deg, var(--navy), #866221);
}

.chart-item span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 3px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: #fff;
  background: var(--navy);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  color: #252b36;
  font-size: 14px;
}

tbody tr:nth-child(even) td {
  background: #faf9f5;
}

.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.strong {
  color: var(--navy);
  font-weight: 900;
}

.year-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 28px;
  border: 1px solid #d5c090;
  border-radius: 2px;
  color: var(--navy);
  background: #fbf8ef;
  font-weight: 900;
}

.formula-cell {
  min-width: 260px;
  color: #3d4758;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .topbar,
  .layout,
  .section-head {
    display: block;
  }

  .status-block {
    width: 100%;
    margin-top: 18px;
    text-align: left;
  }

  .summary-card {
    margin-top: 18px;
  }

  .section-head h2 {
    margin-bottom: 12px;
  }

  .mini-chart {
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .form-card,
  .summary-card,
  .result-card,
  .progress-panel {
    padding: 18px;
  }

  .calc-form,
  .actions,
  .metric-grid,
  .progress-steps {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 34px;
  }

  #amount {
    min-height: 70px;
    font-size: 38px;
  }
}
