/* styles.css */

/* Base layout & typography */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-page: #f2f4f8;
  --bg-card: #ffffff;
  --border-subtle: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;

  /* Green, bright, fintech-y theme */
  --accent: #16a34a;          /* green-600 */
  --accent-soft: #dcfce7;     /* green-100 */
  --accent-strong: #15803d;   /* green-700 */

  --danger: #ef4444;

  --need-badge-bg: #e5e7eb;
  --need-badge-text: #374151;
  --want-badge-bg: #ecfdf5;
  --want-badge-text: #166534;

  --success-bg: #ecfdf5;
  --success-text: #166534;

  --shadow-soft: 0 22px 45px rgba(15, 23, 42, 0.12);
  --radius-card: 20px;
  --radius-pill: 999px;
  --transition-fast: 0.18s ease-out;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
}

body {
  min-height: 100vh;
}

/* App shell */
.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1rem 2.5rem;
}

@media (min-width: 640px) {
  .app-shell {
    padding: 2.4rem 1.6rem 3rem;
  }
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 1.9rem;
}

.logo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.7rem 0.25rem 0.3rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.08);
  margin-bottom: 0.6rem;
}

.logo-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #bbf7d0 0, #22c55e 40%, #15803d 100%);
}

.logo-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: #166534;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-header h1 {
  margin: 0 0 0.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.7rem;
}

.app-header .subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Main */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

@media (min-width: 640px) {
  .main-content {
    gap: 1.35rem;
  }
}

/* Card */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  padding: 1.45rem 1.15rem 1.6rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

@media (min-width: 640px) {
  .card {
    padding: 1.7rem 1.6rem 1.8rem;
  }
}

.card-header {
  margin-bottom: 0.85rem;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Step badge */
.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #16a34a;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Generic text utilities */
.field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.helper-text {
  margin-top: 0.4rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.helper-text.tiny {
  font-size: 0.78rem;
}

.error-text {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--danger);
  min-height: 1em;
}

/* Inputs */
.text-input {
  width: 100%;
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
  background-color: #f9fafb;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  background-color: #ffffff;
  transform: translateY(-0.5px);
}

.input-with-prefix {
  display: flex;
  align-items: center;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  background-color: #f9fafb;
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}

.input-with-prefix:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
  background-color: #ffffff;
  transform: translateY(-0.5px);
}

.input-with-prefix .prefix {
  padding: 0.6rem 0.55rem 0.6rem 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.input-with-prefix .text-input {
  border: none;
  background: transparent;
  padding-left: 0.2rem;
}

/* Buttons */
button {
  font-family: inherit;
}

.primary-button {
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.7rem 1.45rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: linear-gradient(135deg, #22c55e, var(--accent-strong));
  color: #ffffff;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
  box-shadow: 0 12px 26px rgba(34, 197, 94, 0.4);
}

.primary-button:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(34, 197, 94, 0.45);
}

.primary-button:active {
  transform: translateY(0);
  box-shadow: 0 7px 18px rgba(34, 197, 94, 0.3);
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.full-width {
  width: 100%;
}

/* Reset button */
.summary-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.btn-reset {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background-color: #ffffff;
  padding: 0.4rem 0.9rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.btn-reset:hover {
  background-color: #f3f4f6;
  color: var(--text-main);
  transform: translateY(-0.5px);
  box-shadow: 0 3px 6px rgba(15, 23, 42, 0.12);
}

/* Form layout */
.expense-form {
  margin-bottom: 1.1rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.form-field {
  flex: 1 1 100%;
}

.form-field-half {
  flex: 1 1 calc(50% - 0.4rem);
}

/* Pill toggle for Essential / Flexible */
.pill-toggle {
  display: inline-flex;
  background-color: #f3f4f6;
  border-radius: var(--radius-pill);
  padding: 0.12rem;
}

.pill-option {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  padding: 0.42rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.pill-option.active {
  background-color: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
}

/* Horizon toggle */
.horizon-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.horizon-toggle {
  display: inline-flex;
  background-color: #f3f4f6;
  border-radius: var(--radius-pill);
  padding: 0.12rem;
}

.horizon-option {
  border: none;
  background: transparent;
  padding: 0.42rem 0.9rem;
  font-size: 0.8rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}

.horizon-option.active {
  background-color: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
}

/* Empty state */
.empty-state {
  border-radius: 14px;
  border: 1px dashed var(--border-subtle);
  padding: 0.9rem 0.95rem;
  background-color: #f9fafb;
}

.empty-state p {
  margin: 0;
  font-size: 0.87rem;
  color: var(--text-muted);
}

/* Expenses list & cards */
.expenses-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.expense-card {
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  padding: 0.85rem 0.9rem 0.95rem;
  background-color: #ffffff;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
}

.expense-card:hover {
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.expense-card.cut {
  background-color: var(--success-bg);
  border-color: #bbf7d0;
}

.expense-top-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.expense-main {
  flex: 1 1 auto;
}

.expense-name {
  margin: 0;
  font-weight: 600;
  font-size: 0.96rem;
}

.expense-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.expense-amount {
  margin-left: auto;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.07rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-need {
  background-color: var(--need-badge-bg);
  color: var(--need-badge-text);
}

.badge-want {
  background-color: var(--want-badge-bg);
  color: var(--want-badge-text);
}

.badge-cut {
  background-color: #bbf7d0;
  color: var(--success-text);
}

/* Expense bottom section */
.expense-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.impact-lines {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.impact-lines strong {
  color: var(--text-main);
}

.impact-lines span.highlight {
  font-weight: 600;
}

/* Expense actions */
.expense-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.55rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-small {
  border-radius: 999px;
  border: none;
  padding: 0.42rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

/* CUT / KEEP buttons */
.btn-cut {
  background: #16a34a;
  color: #ecfdf5;
  box-shadow: 0 8px 16px rgba(22, 163, 74, 0.26);
}

.btn-cut:hover {
  background: #15803d;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(22, 163, 74, 0.32);
}

.btn-keep {
  background: #f97316;
  color: #fff7ed;
  box-shadow: 0 8px 16px rgba(249, 115, 22, 0.26);
}

.btn-keep:hover {
  background: #ea580c;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.32);
}

/* Remove button */
.btn-link {
  background: transparent;
  color: var(--text-muted);
  padding: 0.3rem 0;
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  box-shadow: none;
  border: none;
}

.btn-link:hover {
  color: var(--text-main);
  transform: none;
}

/* Summary card */
.summary-header-note {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.summary-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.summary-card {
  border-radius: 16px;
  padding: 0.9rem 0.95rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.main-summary {
  background: radial-gradient(circle at top left, #dcfce7 0, #f0fdf4 35%, #f9fafb 100%);
  border-color: #bbf7d0;
}

.summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
}

.summary-label.small {
  font-size: 0.75rem;
  margin-top: 0.1rem;
}

.summary-income-context {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Summary breakdown block */
.summary-breakdown {
  margin-top: 0.1rem;
  border-radius: 12px;
  background: #f9fafb;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-breakdown-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.summary-breakdown-row span:last-child {
  font-weight: 500;
  color: var(--text-main);
}

.summary-breakdown-row.total-row {
  border-top: 1px dashed var(--border-subtle);
  padding-top: 0.3rem;
  margin-top: 0.3rem;
}

.summary-breakdown-row.highlight-row {
  color: var(--accent-strong);
}

.summary-breakdown-row.highlight-row span:last-child {
  color: var(--accent-strong);
}

/* Small chip */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.chip-bright {
  background-color: #bbf7d0;
  color: #166534;
}

/* Cut impact & surplus cards */
.summary-card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.25rem;
}

.cut-impact-card {
  background: #ecfdf5;
  border-color: #bbf7d0;
}

.surplus-impact-card {
  background: #f9fafb;
  border-style: dashed;
  border-color: #d1d5db;
}

.summary-subline-strong {
  font-size: 0.85rem;
  color: var(--accent-strong);
  font-weight: 600;
  margin: 0.1rem 0 0.4rem;
}

.summary-subline {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0.1rem 0 0.4rem;
}

/* Two-column values inside summary cards */
.summary-two-col {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.summary-two-col-item {
  flex: 1 1 140px;
}

.summary-value {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.summary-value.subtle {
  color: #047857;
}

/* Cut items list inside CUT impact card */
.cut-items-wrapper {
  margin-top: 0.7rem;
}

.cut-items-label {
  margin: 0 0 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cut-items-shell {
  border-radius: 12px;
  background: #f0fdf4;
  border: 1px dashed #bbf7d0;
  overflow: hidden;
}

.cut-items-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #14532d;
  background: #dcfce7;
}

.cut-items-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 0.35rem 0.65rem;
}

.cut-items-footer {
  border-top: 1px dashed #bbf7d0;
  padding: 0.35rem 0.65rem 0.45rem;
}

.cut-items-empty {
  margin: 0.1rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cut-item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  align-items: baseline;
  padding: 0.26rem 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.4);
  gap: 0.4rem;
}

.cut-item-row:last-child {
  border-bottom: none;
}

.cut-item-main {
  display: flex;
  flex-direction: column;
}

.cut-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #166534;
}

.cut-item-amount {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cut-item-fv {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.cut-item-fv-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cut-item-fv-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: #15803d;
}

.cut-item-total-row .cut-item-name {
  font-weight: 700;
}

.cut-item-total-row .cut-item-fv-value {
  font-size: 0.92rem;
}

/* Hero combined block */
.hero-summary {
  border-radius: 18px;
  padding: 1.05rem 1.1rem 1.1rem;
  background: radial-gradient(circle at top, #bbf7d0 0, #ecfdf5 40%, #f9fafb 100%);
  border: 1px solid #16a34a;
  text-align: center;
  box-shadow: 0 16px 32px rgba(34, 197, 94, 0.25);
}

.hero-label {
  margin: 0 0 0.25rem;
  font-size: 0.88rem;
  color: #166534;
  font-weight: 600;
}

.hero-monthly {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: #166534;
}

.hero-values {
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 220px;
}

.hero-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  color: #065f46;
}

.hero-line span:last-child {
  font-weight: 700;
}

.hero-line.hero-main {
  font-size: 1.25rem;
  margin-top: 0.15rem;
}

.hero-note {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: #166534;
}

/* Footer */
.app-footer {
  margin-top: 2.2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0 0.75rem;
}

/* Responsive tweaks */
@media (min-width: 768px) {
  .card-header h2 {
    font-size: 1.12rem;
  }

  .app-header h1 {
    font-size: 1.9rem;
  }
}
