:root {
  --bg: #f7efe5;
  --paper: rgba(255, 251, 246, 0.94);
  --ink: #17313a;
  --muted: #61766f;
  --line: rgba(23, 49, 58, 0.12);
  --accent: #0f8a7a;
  --accent-soft: rgba(15, 138, 122, 0.09);
  --accent-strong: #147b91;
  --danger: #bf5c47;
  --danger-soft: rgba(191, 92, 71, 0.08);
  --shadow: 0 18px 45px rgba(30, 39, 46, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(244, 162, 97, 0.24), transparent 24%),
    radial-gradient(circle at top right, rgba(15, 138, 122, 0.18), transparent 22%),
    linear-gradient(180deg, #fcf7f0 0%, #efe4d8 100%);
  font-family: "Segoe UI Variable", "Hiragino Sans", "Yu Gothic", sans-serif;
}

body {
  min-height: 100vh;
}

.page-shell {
  width: min(1420px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 14px;
}

.topbar-title h1,
.step-head h2 {
  font-family: Georgia, "Yu Mincho", "Hiragino Mincho ProN", serif;
  letter-spacing: 0.01em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.76rem;
}

.topbar-title h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.3vw, 2.4rem);
  line-height: 1.05;
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.landing-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 45px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.8);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.landing-link:focus {
  outline: 2px solid rgba(15, 138, 122, 0.22);
  outline-offset: 1px;
  border-color: var(--accent);
}

.toolbar-field span,
.step-card label,
.advanced-card label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
}

.toolbar-field {
  min-width: 220px;
}

.workspace {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  align-items: stretch;
  min-width: 0;
}

.panel {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 18px;
  min-width: 0;
}

.inputs-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-content: start;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.results-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.step-card,
.advanced-card,
.profit-spotlight,
.formula-card,
.metric-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.76);
  min-width: 0;
}

.step-card,
.profit-spotlight,
.advanced-card {
  padding: 16px;
}

.advanced-card {
  grid-column: 1 / -1;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.step-head h2 {
  margin: 0;
  font-size: 1.55rem;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid--price {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid--cost {
  grid-template-columns: 1fr;
  margin-top: 14px;
}

.field-grid--advanced {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.advanced-card summary {
  cursor: pointer;
  list-style: none;
  font-weight: 800;
}

.advanced-card summary::-webkit-details-marker {
  display: none;
}

input,
select,
button {
  width: 100%;
  margin-top: 6px;
  border: 1px solid rgba(23, 49, 58, 0.16);
  border-radius: var(--radius-md);
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(15, 138, 122, 0.22);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[readonly] {
  background: rgba(239, 246, 245, 0.95);
  color: var(--muted);
}

button {
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(15, 138, 122, 0.18);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 100%;
  padding-top: 22px;
  color: var(--ink);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.profit-spotlight {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 12px;
  background:
    linear-gradient(140deg, rgba(15, 138, 122, 0.08), rgba(255, 255, 255, 0.9)),
    rgba(255, 255, 255, 0.8);
}

.profit-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.metric-caption,
.formula-label,
.metric-tile span,
.profit-side span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.profit-main strong {
  margin-top: 10px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
}

.profit-side {
  display: grid;
  gap: 10px;
}

.profit-side article {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
}

.profit-side strong {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
}

.formula-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.formula-card {
  padding: 14px;
  min-height: 132px;
}

.formula-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.7rem;
  line-height: 1.05;
}

.formula-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.formula-card--income {
  background: rgba(15, 138, 122, 0.06);
}

.formula-card--cost {
  background: rgba(191, 92, 71, 0.06);
}

.formula-card--result {
  background: rgba(23, 49, 58, 0.05);
}

.formula-sign {
  font-size: 2rem;
  font-weight: 800;
  color: var(--muted);
}

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

.metric-tile {
  padding: 14px;
}

.metric-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 1.28rem;
}

@media (min-width: 1041px) {
  html,
  body {
    overflow: hidden;
  }

  .page-shell {
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
  }

  .workspace {
    min-height: 0;
  }
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1040px) {
  .topbar,
  .workspace,
  .profit-spotlight,
  .formula-flow {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

  .toolbar-field {
    min-width: 0;
  }

  .formula-sign {
    justify-self: center;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 16px, 1420px);
  }

  .panel,
  .step-card,
  .advanced-card,
  .profit-spotlight,
  .formula-card,
  .metric-tile {
    border-radius: 18px;
  }

  .field-grid--price,
  .field-grid--cost,
  .field-grid--advanced,
  .quick-metrics {
    grid-template-columns: 1fr;
  }
}
