:root {
  --bg: #f5efe3;
  --bg-deep: #eadfc9;
  --surface: rgba(255, 253, 248, 0.9);
  --surface-strong: #fffaf2;
  --line: rgba(41, 58, 47, 0.12);
  --ink: #1f2a24;
  --muted: #5f6c61;
  --accent: #1f6b55;
  --accent-soft: #d6eadf;
  --warn: #9c4b2f;
  --good: #0e6b45;
  --bad: #8b2f38;
  --shadow: 0 18px 40px rgba(65, 51, 24, 0.12);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --control-width: 102px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 34%),
    radial-gradient(circle at top right, rgba(214, 234, 223, 0.9), transparent 28%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.32), transparent 80%);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

.page-shell {
  width: min(1160px, calc(100vw - 16px));
  margin: 16px auto 28px;
  position: relative;
  z-index: 1;
}

.hero,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero {
  width: fit-content;
  max-width: 100%;
  justify-self: start;
  padding: 22px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  animation: rise-in 360ms ease-out both;
}

.eyebrow,
.section-tag {
  font-size: 0.77rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.hero-copy {
  display: grid;
  gap: 12px;
}

.hero-copy h1 {
  font-size: clamp(2.5rem, 6vw, 4.4rem);
  line-height: 0.95;
  max-width: 100%;
}

.hero-text {
  color: var(--muted);
  max-width: 46rem;
  font-size: 1.02rem;
  line-height: 1.6;
}

.hero-metrics {
  display: grid;
  width: 100%;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-content: stretch;
  justify-items: stretch;
  align-items: stretch;
}

.metric-card,
.summary-card,
.field-group {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(41, 58, 47, 0.09);
  border-radius: var(--radius-md);
}

.metric-card {
  width: 100%;
  min-width: 0;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.metric-label,
.summary-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.metric-value,
.summary-value {
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  line-height: 1.05;
  min-width: 0;
  white-space: nowrap;
}

.metric-detail,
.summary-detail {
  color: var(--muted);
  line-height: 1.45;
}

.workspace {
  margin-top: 16px;
  display: grid;
  gap: 10px;
  grid-template-columns: max-content max-content;
  justify-content: start;
  align-items: start;
}

.panel {
  padding: 16px;
  animation: rise-in 420ms ease-out both;
}

.inputs-panel {
  width: fit-content;
  max-width: 100%;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2 {
  font-size: 1.65rem;
  margin-top: 2px;
}

.ghost-button {
  border: 1px solid rgba(31, 107, 85, 0.24);
  background: rgba(214, 234, 223, 0.7);
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease;
}

.ghost-button:hover {
  background: rgba(214, 234, 223, 0.96);
  border-color: rgba(31, 107, 85, 0.44);
  transform: translateY(-1px);
}

.field-groups {
  display: grid;
  row-gap: 6px;
  column-gap: 26px;
  grid-template-columns: repeat(2, max-content);
  justify-content: start;
}

.field-group {
  padding: 8px;
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
  width: auto;
  justify-self: stretch;
}

.field-group h3 {
  font-size: 1.05rem;
}

.field {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  width: fit-content;
}

.field span:first-child {
  flex: 0 0 54px;
  font-weight: 700;
  font-size: 0.76rem;
  line-height: 1.2;
}

.field .input-shell {
  flex: 0 0 var(--control-width);
  width: var(--control-width);
  min-width: var(--control-width);
  max-width: var(--control-width);
}

.input-shell {
  min-height: 40px;
  display: flex;
  align-items: center;
  background: var(--surface-strong);
  border: 1px solid rgba(31, 42, 36, 0.12);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-width: 0;
}

.input-shell input {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.8rem;
  padding: 0 5px;
  min-height: 40px;
  text-align: left;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.input-shell input[type="date"] {
  padding-right: 4px;
}

.date-shell {
  position: relative;
  cursor: pointer;
}

.date-display {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 0 22px 0 5px;
  font-size: 0.8rem;
  color: var(--ink);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.date-shell::after {
  content: "";
  position: absolute;
  right: 8px;
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  color: var(--muted);
  pointer-events: none;
  box-sizing: border-box;
  background:
    linear-gradient(currentColor, currentColor) 2px 4px / 8px 1.5px no-repeat,
    linear-gradient(currentColor, currentColor) 3px 0 / 1.5px 3px no-repeat,
    linear-gradient(currentColor, currentColor) 7px 0 / 1.5px 3px no-repeat;
}

.date-picker-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.affix {
  color: var(--muted);
  font-weight: 700;
  padding: 0 5px;
  white-space: nowrap;
}

.with-prefix input {
  padding-left: 5px;
}

.with-suffix input {
  padding-right: 1px;
}

.fine-print {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.results-panel {
  display: grid;
  gap: 16px;
  align-content: start;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}

.results-panel > .panel-header,
.results-panel > .summary-grid {
  display: none !important;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.summary-card {
  padding: 14px;
  display: grid;
  gap: 6px;
}

.breakdown-panel {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(41, 58, 47, 0.09);
  border-radius: var(--radius-md);
  padding: 10px;
  width: fit-content;
  max-width: 100%;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.table-header h3 {
  font-size: 1.25rem;
}

.table-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.table-chip.warn {
  background: rgba(156, 75, 47, 0.14);
  color: var(--warn);
}

.deal-table {
  width: auto;
  border-collapse: collapse;
}

.deal-table tr + tr {
  border-top: 1px solid rgba(41, 58, 47, 0.08);
}

.deal-table td {
  padding: 10px 4px;
}

.deal-table td:first-child {
  color: var(--muted);
  font-weight: 600;
  padding-right: 24px;
  white-space: nowrap;
}

.deal-table td:last-child {
  text-align: right;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.deal-table tr.subtotal td {
  padding-top: 14px;
  color: var(--ink);
}

.deal-table tr.total td {
  font-size: 1.08rem;
  color: var(--ink);
}

.deal-table tr.total td.value-positive {
  color: var(--good);
}

.deal-table tr.total td.value-negative {
  color: var(--bad);
}

.value-positive {
  color: var(--good);
}

.value-negative {
  color: var(--bad);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .hero-copy h1 {
    font-size: clamp(2.4rem, 13vw, 4rem);
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    margin-top: 8px;
  }

  .hero {
    width: 100%;
  }

  .hero,
  .panel {
    padding: 14px;
  }

  .hero-copy h1 {
    font-size: clamp(1.75rem, 8.8vw, 2.35rem);
    line-height: 0.98;
  }

  .hero-metrics {
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-card {
    padding: 8px 7px;
    gap: 3px;
  }

  .metric-label,
  .metric-detail {
    font-size: 0.68rem;
    line-height: 1.25;
  }

  .metric-value {
    font-size: clamp(0.86rem, 3.6vw, 1.08rem);
  }

  .inputs-panel {
    --control-width: 94px;
  }

  .panel-header {
    flex-direction: column;
    align-items: start;
  }

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

  .field-groups {
    grid-template-columns: repeat(2, max-content);
    row-gap: 4px;
    column-gap: 12px;
  }

  .field-group {
    padding: 6px;
    gap: 5px;
  }

  .field-group h3 {
    font-size: 0.98rem;
  }

  .field span:first-child {
    flex-basis: 46px;
    font-size: 0.72rem;
  }

  .input-shell input,
  .date-display {
    font-size: 0.76rem;
  }

  .table-header {
    flex-direction: column;
    align-items: start;
  }
}
