body { overflow-x: hidden; max-width: 100vw; }
:root {
  --primary: #2389dc;
  --primary-light: #edf7ff;
  --background: #f7f9fc;
  --muted: #7c8594;

  --green: #63b879;
  --green-light: #edfaf2;

  --orange: #efaa43;
  --orange-light: #fff8ea;

  --purple: #9b7bea;
  --purple-light: #f4f0ff;

  --red: #e56a6f;
  --red-light: #fff1f1;
}

/* networth overrides */
.calculator {
  margin-top: 70px;
  gap: 25px;
}

@media (min-width: 1001px) {
  .calculator {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr) !important;
  }
}

.input-column { gap: 14px; }

.currency-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #7c8594;
  position: relative;
  max-width: 100%;
}

.currency-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  min-width: 0;
  border: 1px solid #e0e4ea;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #21262f;
  background: #fff;
  cursor: pointer;
  white-space: normal;
  text-align: left;
  outline: none;
}

.currency-btn svg { flex-shrink: 0; }

.currency-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: #fff;
  border: 1px solid #e0e4ea;
  border-radius: 9px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  z-index: 999;
  width: max-content;
  min-width: min(280px, calc(100vw - 30px));
  max-width: calc(100vw - 30px);
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}

.currency-dropdown.open { display: block; }

.currency-option {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #21262f;
  cursor: pointer;
}

.currency-option:hover { background: #f4f6f9; }
.currency-option.selected { font-weight: 700; color: #2389dc; }

.section-header {
  font-size: 16px;
  color: #000000;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header .section-header-text {
  flex: 1;
  min-width: 0;
}

.section-header .section-add-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.section-header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.section-header-name {
  font-size: 15px;
  font-weight: 600;
  color: #000;
  line-height: 1.2;
}

.section-header-desc {
  font-size: 10px;
  font-weight: 450;
  color: #656769;
  line-height: 1.3;
}

.section-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 13px;
  flex-shrink: 0;
}

.hero h1 {
  font-size: clamp(38px, 5vw, 56px);
  font-weight: 500;
  margin-bottom: 18px;
  color: #000000;
}

.hero p { font-size: 20px; line-height: 1.5; }

/* Header colors */

.cash {
  border-color: #dff2ff;
}

.cash .section-header {
  background: linear-gradient(90deg, #eff8ff, #fff);
}

.invest {
  border-color: #dff2ff;
}

.invest .section-header {
  background: linear-gradient(90deg, #eff8ff, #fff);
}

.saving {
  border-color: #dff2ff;
}

.saving .section-header {
  background: linear-gradient(90deg, #eff8ff, #fff);
}

.asset {
  border-color: var(--orange-light);
}

.asset .section-header {
  background: linear-gradient(90deg, var(--orange-light), #fff);
}

.liability {
  border-color: var(--red-light);
}

.liability .section-header {
  background: linear-gradient(90deg, var(--red-light), #fff);
}

.obligation {
  border-color: var(--red-light);
}

.obligation .section-header {
  background: linear-gradient(90deg, var(--red-light), #fff);
}

.section-note {
  font-size: 10px;
  font-weight: 400;
  color: #9ba2ad;
  margin-left: 3px;
}

.input-row .money-field {
  align-self: center;
  margin-top: 0;
}

.input-label {
  color: #21262f;
  font-weight: 600;
}

.money-input { width: auto; }

.total {
  font-size: 12px;
  font-weight: 750;
  width: 110px;
  text-align: center;
  margin-top: 10px;
}

.liability-total {
  color: var(--red);
}

.asset-total {
  color: var(--primary);
}

.add-category {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 0 3px;
}

.add-category:hover {
  text-decoration: underline;
}

.input-field-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.expand-toggle {
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7c8594;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.expand-toggle.open { transform: rotate(180deg); }

.input-expand-panel {
  display: none;
  background: #f4f5f7;
  border-top: 1px solid #eaecef;
  padding: 8px 14px;
  border-radius: 10px;
}

.input-expand-panel.open { display: block; }

.expand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 12px;
  color: #4a5260;
  font-weight: 500;
}

.expand-row:first-child { border-bottom: 1px solid #e2e4e8; }

.expand-input {
  width: 80px;
  height: 28px;
  border: 1px solid #e0e2e6;
  background: #fff;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #172033;
  outline: none;
  text-align: center;
}

.compound-frequency {
  width: 160px;
  max-width: 100%;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%237c8594' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
  appearance: none;
  text-align: left;
  cursor: pointer;
}

.expand-input:focus {
  border-color: #9dd5fa;
  box-shadow: 0 0 0 2px #eaf6ff;
}

.section-add-btn {
  border: none;
  background: none;
  color: #000;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  align-self: center;
}

.custom-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 50px;
  border-bottom: 1px solid #f0f2f5;
}

.custom-name-input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 40px;
  margin: 0;
  border: none;
  outline: none;
  padding: 2px 4px;
  background: transparent;
  color: #21262f;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
  box-sizing: border-box;
  resize: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  overflow-y: auto;
}

.input-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.remove-row-btn {
  border: none;
  background: none;
  color: #c0c6cf;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}

.remove-row-btn:hover { color: #e56a6f; }

.result-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 90px;
  min-width: 0;
}

.result-panel {
  background: white;
  border: 1px solid #dff2ff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.result-title {
  font-size: 20px;
  font-weight: 600;
  color: #000000;
}

.net-worth {
  font-size: 31px;
  font-weight: 600;
  color: #62ae57;
  margin-top: 12px;
  margin-bottom: 17px;
}

.total-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.total-box-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #f0f2f5;
  border-radius: 5px;
  padding: 12px 14px;
  background: #f7f8fa;
}

.stat-label {
  color: #000000;
  font-size: 15px;
  font-weight: 450;
}

.stat-value {
  font-size: 17px;
  font-weight: 550;
  margin-top: 3px;
  color: #000000;
}

/* =========================================
     RESULT SECTION
  ========================================= */

.result-section {
  padding: 16px 0;

  border-bottom: 1px solid var(--border);
}

.result-section:last-child {
  border-bottom: 0;
}

.result-section-title {
  font-size: 18px;
  font-weight: 550;
  margin-bottom: 17px;
  color: #000000;
}

.allocation {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alloc-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-blue   { background: #2389dc; }
.dot-green  { background: #3dbf7a; }
.dot-purple { background: #9b7bea; }
.dot-orange { background: #efaa43; }

.alloc-label {
  font-size: 13px;
  font-weight: 500;
  color: #21262f;
  white-space: nowrap;
  width: 200px;
  flex-shrink: 0;
}

.alloc-bar-wrap {
  flex: 1;
  height: 18px;
  border-radius: 4px;
  background: #e8ecf0;
  overflow: hidden;
  flex-shrink: 0;
}

.alloc-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.35s;
}

.alloc-pct {
  font-weight: 700;
  font-size: 13px;
  color: #21262f;
  flex-shrink: 0;
  min-width: 40px;
  text-align: right;
  white-space: nowrap;
}

/* =========================================CHART========================================= */

.proj-toggle {
  display: flex;
  background: #f0f2f5;
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
}

.proj-toggle-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 100px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #7c8594;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}

.proj-toggle-btn.active {
  background: #2389dc;
  color: #fff;
}

.chart-summary {
  display: flex;
  align-items: center;
  background: #edf6ff;
  border-radius: 10px;
  margin-top: 12px;
  overflow: hidden;
}

.chart-summary-side {
  flex: 1;
  padding: 10px 14px;
  text-align: center;
}

.chart-summary-label {
  font-size: 11px;
  font-weight: 500;
  color: #7c8594;
  margin-bottom: 3px;
}

.chart-summary-value {
  font-size: 15px;
  font-weight: 700;
  color: #2389dc;
}

.chart-summary-today {
  color: #21262f;
}

.chart-summary-divider {
  width: 1px;
  height: 36px;
  background: #cde5f7;
  flex-shrink: 0;
}

.chart {
  height: 180px;
  width: 100%;
  position: relative;
}

.chart svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-grid {
  stroke: #f0f3f7;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-area {
  fill: url(#chartGradient);
}

.chart-line {
  fill: none;
  stroke: #2389dc;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: white;
  stroke: #2389dc;
  stroke-width: 2.5;
}

.chart-point-label {
  font-size: 9.5px;
  fill: #2389dc;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: auto;
}

.chart-y-label {
  font-size: 8px;
  fill: #b0b8c4;
  text-anchor: end;
  dominant-baseline: middle;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  color: #a1a8b2;
  font-size: 9px;
  padding: 0 2px;
}

.chart-series-toggles {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
}

.chart-series-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #9ba2ad;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.chart-series-toggles input[type=checkbox] {
  accent-color: var(--primary);
  width: 13px;
  height: 13px;
  cursor: pointer;
  margin: 0;
  padding: 0;
  vertical-align: middle;
  flex-shrink: 0;
}

.composition {
  display: flex;
  flex-direction: column;
}

.composition-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  background: #f7f8fa;
  border-bottom: 1px solid #e4e7eb;
  font-size: 13px;
  font-weight: 550;
  color: #000;
}

.composition-row:last-child {
  border-bottom: 0;
}

.composition-value {
  font-weight: 550;
  font-size: 13px;
  color: #000;
}

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

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

.hero-divider {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 5%;
}

.hero-divider .currency-bar {
  margin-bottom: 12px;
}

.hero-divider hr {
  border: none;
  height: 0.7px;
  background: linear-gradient(to right, transparent, rgba(192, 200, 212, 0.35) 50%, transparent);
  border-radius: 2px;
}

/* =========================================
     MOBILE
  ========================================= */

@media (max-width: 1000px) {
  .result-column { position: static; }
}

@media (max-width: 650px) {
  .hero-visual2 {
    width: 100%;
    max-width: 340px;
    align-self: center;
  }

  .hero-divider {
    padding: 0 15px;
  }

  .hero-divider > div {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .alloc-label {
    width: auto;
    min-width: 0;
    flex: 1;
    white-space: normal;
    font-size: 12px;
  }

  .alloc-bar-wrap {
    flex: 1;
    min-width: 40px;
  }

  .input-row {
    gap: 10px;
  }

  .input-label { font-size: 11px; }

  .custom-input-row {
    flex-wrap: wrap;
    gap: 6px;
  }
}
