:root {
  --page-bg: #f3f3ef;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #5f5f5f;
  --line: #111111;
  --line-soft: #c9c9c1;
  --positive: #111111;
  --negative: #6d6d6d;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Courier New", monospace;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.calc-page-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.calc-page-header,
.calc-card {
  border: 1px solid var(--line);
  background: var(--surface);
}

.calc-page-header {
  display: grid;
  gap: 18px;
  padding: 18px 22px;
}

.calc-header-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.nav-link {
  min-height: 38px;
  width: fit-content;
  padding: 0 12px;
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-link:hover,
.btn:hover {
  background: #111111;
  color: #ffffff;
}

.btn.primary {
  background: #111111;
  color: #ffffff;
}

.btn.ghost {
  background: var(--page-bg);
}

.calc-page-header h1 {
  margin: 6px 0 8px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 500;
  line-height: 1;
}

.calc-page-header p {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
}

.calc-main {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
}

.calc-card {
  min-width: 0;
  padding: 20px;
}

.calc-card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.calc-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.field span,
.stat .label {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.field input:focus {
  outline: 2px solid #111111;
  outline-offset: 0;
}

.field-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.field-meta[data-type="error"] {
  color: var(--ink);
}

.field-meta[data-type="success"] {
  color: var(--ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
}

.btn {
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 500;
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mini-btn:hover {
  background: #111111;
  color: #ffffff;
}

.mini-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

.stat {
  padding: 14px;
  border: 1px dashed var(--line-soft);
  background: var(--page-bg);
}

.stat .label {
  display: block;
}

.stat .value {
  margin-top: 4px;
  font-size: 1.3rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.profit {
  color: var(--positive);
}

.loss {
  color: var(--negative);
}

.status-message {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-message[data-type="error"] {
  color: var(--ink);
}

@media (max-width: 860px) {
  .calc-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .calc-page-shell {
    width: min(100% - 20px, 980px);
    padding-top: 16px;
  }

  .calc-page-header,
  .calc-card {
    padding: 16px;
  }

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

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }
}
