:root {
  --bg: #080808;
  --panel: #121212;
  --panel-2: #171717;
  --line: #282828;
  --line-strong: #3a3a3a;
  --text: #f7f4ef;
  --muted: #aaa39a;
  --dim: #6f6a63;
  --gold: #e5aa45;
  --gold-2: #f4cc75;
  --green: #57d18d;
  --blue: #6da7ff;
  --red: #ff7770;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(229, 170, 69, 0.16), transparent 28rem),
    linear-gradient(135deg, #080808 0%, #111 46%, #09110e 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 14px clamp(16px, 4vw, 44px);
  background: rgba(8, 8, 8, 0.82);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.brand span {
  overflow-wrap: anywhere;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ghost-button,
.primary-button,
.danger-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 8px;
  color: var(--text);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
}

.primary-button {
  color: #111;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  font-weight: 760;
}

.danger-button {
  align-self: end;
  border: 1px solid rgba(255, 119, 112, 0.46);
  color: #ffd0cd;
  background: rgba(255, 119, 112, 0.1);
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 48px);
}

.calculator-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: clamp(18px, 4vw, 36px);
  align-items: end;
  padding: 28px 0 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-2);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.04;
  letter-spacing: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(36px, 6vw, 72px);
}

h2 {
  font-size: clamp(22px, 3vw, 32px);
}

.target-panel,
.panel,
.summary-card,
.progress-section {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(18, 18, 18, 0.78);
  box-shadow: var(--shadow);
}

.target-panel {
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 8px;
}

.target-panel label,
.select-label,
.field label,
.monthly-cell label,
.toggle-row {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.money-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0b0b0b;
}

.money-input input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 25px;
  font-weight: 800;
}

.money-input span {
  color: var(--dim);
  font-size: 12px;
  font-weight: 760;
}

.range-input {
  width: 100%;
  accent-color: var(--gold);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.summary-card {
  display: grid;
  gap: 8px;
  min-height: 124px;
  padding: 18px;
  border-radius: 8px;
}

.summary-card span {
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  align-self: end;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.progress-section {
  margin: 14px 0;
  padding: 18px;
  border-radius: 8px;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #252525;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green));
  transition: width 0.25s ease;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 14px;
  align-items: stretch;
}

.panel {
  border-radius: 8px;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.select-label {
  display: grid;
  gap: 7px;
}

select,
.field input,
.field select,
.monthly-cell input {
  min-height: 40px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #0d0d0d;
  outline: 0;
}

select {
  padding: 0 12px;
}

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

.requirements-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.requirements-table th,
.requirements-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.requirements-table th:first-child,
.requirements-table td:first-child {
  text-align: left;
}

.requirements-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.requirements-table td {
  color: var(--text);
  font-size: 14px;
}

.source-name {
  display: grid;
  gap: 4px;
}

.source-name span {
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--green);
  font-weight: 760;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: 420px;
}

.assumptions-panel {
  margin-top: 14px;
}

.source-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
}

.source-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}

.source-card summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 74px;
  padding: 16px;
  cursor: pointer;
  list-style: none;
}

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

.source-title {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.source-title strong {
  overflow-wrap: anywhere;
}

.source-title span,
.source-metric span {
  color: var(--muted);
  font-size: 12px;
}

.source-metric {
  display: grid;
  gap: 4px;
  text-align: right;
}

.source-metric strong {
  font-size: 18px;
}

.source-body {
  display: grid;
  gap: 16px;
  padding: 0 16px 16px;
}

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

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

.field input,
.field select,
.monthly-cell input,
.lead-form input {
  padding: 0 10px;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.monthly-fill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 8, 8, 0.42);
}

.monthly-fill .ghost-button {
  min-width: 230px;
}

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.monthly-cell {
  display: grid;
  gap: 5px;
}

.monthly-cell label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-panel {
  margin-top: 14px;
}

.lead-copy {
  max-width: 960px;
  margin: -4px 0 24px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.lead-form {
  display: grid;
  gap: 18px;
}

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

.lead-fields label {
  display: grid;
  gap: 8px;
}

.lead-fields label:last-child {
  grid-column: 1 / -1;
}

.lead-fields span,
.consent-row {
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.lead-form input[type="text"],
.lead-form input[type="email"],
.lead-form input[type="tel"] {
  min-height: 58px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 17px;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 880px;
  line-height: 1.5;
}

.consent-row input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: 0 0 auto;
  accent-color: var(--gold);
}

.lead-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.lead-status.success {
  color: var(--green);
}

.lead-status.error {
  color: var(--red);
}

.lead-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.lead-modal.is-visible {
  display: flex;
}

.lead-modal-card {
  width: min(860px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: clamp(26px, 5vw, 46px);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 0%, rgba(229, 170, 69, 0.18), transparent 22rem),
    #121212;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.lead-modal-card h2 {
  margin-bottom: 14px;
  font-size: clamp(30px, 4vw, 44px);
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 1120px) {
  .workspace-grid,
  .calculator-hero {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .source-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .page-shell {
    padding: 18px 14px 32px;
  }

  h1 {
    font-size: 36px;
  }

  .summary-grid,
  .lead-fields,
  .source-cards,
  .field-grid,
  .monthly-fill,
  .monthly-grid {
    grid-template-columns: 1fr;
  }

  .monthly-fill .ghost-button {
    width: 100%;
    min-width: 0;
  }

  .panel-heading {
    flex-direction: column;
  }

  .select-label {
    width: 100%;
  }

  .chart-panel canvas {
    height: 320px;
  }

  .lead-modal {
    align-items: flex-end;
    padding: 12px;
  }

  .lead-modal-card {
    max-height: calc(100vh - 24px);
  }
}
