:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17202a;
  --muted: #5d6b7a;
  --line: #dde3ea;
  --accent: #1f6feb;
  --accent-soft: #e7f0fe;
  --interest: #f0883e;
  --error: #c62828;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --card: #182028;
    --text: #e6edf3;
    --muted: #9aa7b4;
    --line: #2b3640;
    --accent: #58a6ff;
    --accent-soft: #1b2b40;
    --interest: #f0883e;
    --error: #ff7b72;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

.top { padding: 32px 0 8px; }
h1 { margin: 0 0 8px; font-size: 1.9rem; line-height: 1.2; }
h2 { margin: 0 0 16px; font-size: 1.15rem; }
.lead { margin: 0; color: var(--muted); max-width: 62ch; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 24px;
  align-items: start;
}
.wide { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h2 { margin: 0; }

.field { display: block; margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.field > span, .field > label, .field > legend, .label {
  display: block; margin-bottom: 6px; padding: 0; font-size: .9rem; color: var(--muted);
}
input[type="number"], select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.inline { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 8px; }

.radio { display: block; padding: 6px 0; cursor: pointer; }
.radio small { color: var(--muted); margin-left: 4px; }
.radio input { margin-right: 6px; accent-color: var(--accent); }

.hint { margin: 0 0 10px; font-size: .85rem; color: var(--muted); }
.error { margin: 0; color: var(--error); }

.extra-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) minmax(0, 1.2fr) 36px;
  gap: 6px;
  margin-bottom: 8px;
}
@media (max-width: 420px) {
  .extra-row { grid-template-columns: 1fr 1fr; }
  .extra-row .extra-mode { grid-column: 1; }
}

button { font: inherit; cursor: pointer; }
.btn-ghost {
  padding: 8px 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: 8px;
}
.btn-icon {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { padding: 12px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.stat.main { grid-column: 1 / -1; background: var(--accent-soft); border-color: transparent; }
.stat-label { display: block; font-size: .85rem; color: var(--muted); }
.stat strong { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.main strong { font-size: 1.8rem; }
.stat small { color: var(--muted); }
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
}

.bar { height: 12px; margin: 20px 0 8px; background: var(--interest); border-radius: 6px; overflow: hidden; }
.bar-principal { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: .9rem; color: var(--muted); }
.legend b { color: var(--text); font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; }
.dot-principal { background: var(--accent); }
.dot-interest { background: var(--interest); }

.table-scroll { overflow: auto; max-height: 520px; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .92rem; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }

.prose p { margin: 0 0 12px; max-width: 75ch; }
.prose p:last-child { margin-bottom: 0; }
code { padding: 1px 5px; background: var(--bg); border-radius: 4px; font-size: .92em; }

.foot { padding-bottom: 32px; color: var(--muted); font-size: .85rem; }
.foot p { margin: 0; }
