/* ==========================================================================
   Binance Budget — styles
   Reuses the deck's color tokens for a consistent look.
   ========================================================================== */

:root {
  --bg-1:        #fbfaf4;
  --bg-2:        #eef6ee;
  --bg-3:        #e7f1f8;
  --ink:         #1f2a2e;
  --ink-soft:    #4d5a60;
  --muted:       #7d8a90;
  --line:        #d9e2dd;
  --sage:        #8bb89a;
  --sage-deep:   #4f8a64;
  --sky:         #7fb6d6;
  --sky-deep:    #3d7fa8;
  --peach:       #f4b893;
  --peach-deep:  #e0875a;
  --gold:        #e6c875;
  --rose:        #e8a3aa;
  --lilac:       #c5b3e0;
  --shadow-sm:   0 2px 8px rgba(31,42,46,0.06);
  --shadow-md:   0 8px 28px rgba(31,42,46,0.10);
  --shadow-lg:   0 20px 60px rgba(31,42,46,0.14);
  --radius:      14px;
  --radius-sm:   10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(127,182,214,0.18), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(139,184,154,0.22), transparent 55%),
    radial-gradient(700px 500px at 50% 120%, rgba(244,184,147,0.14), transparent 60%),
    var(--bg-1);
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 0.4em 0;
}

a { color: var(--sage-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top nav (shared site header injected by /js/site-header.js) ---- */
.site-nav { max-width: 1240px; }

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

/* ==========================================================================
   HUB PAGE
   ========================================================================== */
.hub-header {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5em;
  margin: 1rem 0 0.5rem;
}
.hub-header h1 { font-size: 2.2rem; margin: 0; }
.hub-header .lede { color: var(--ink-soft); font-size: 1rem; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1em;
  margin-top: 1.5rem;
}

.tile {
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2em 1.3em;
  display: flex; flex-direction: column; gap: 0.5em;
  box-shadow: var(--shadow-sm);
  text-decoration: none; color: var(--ink);
  transition: transform 0.18s ease, box-shadow 0.22s ease, border-color 0.18s ease;
  position: relative;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--sage);
  text-decoration: none;
}
.tile.tile-new {
  background: linear-gradient(135deg, var(--sage-deep), #3f7050);
  color: #fff;
  border-color: var(--sage-deep);
}
.tile.tile-new:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(79,138,100,0.35); }
.tile-title {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.1rem; margin: 0;
}
.tile.tile-new .tile-title { color: #fff; }
.tile-meta { font-size: 0.78rem; color: var(--muted); }
.tile.tile-new .tile-meta { color: rgba(255,255,255,0.85); }
.tile-takehome {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.4rem;
  color: var(--sage-deep); margin-top: 0.3em;
}
.tile-cta {
  align-self: flex-end;
  font-size: 0.85rem; font-weight: 600; color: var(--sage-deep);
  margin-top: auto;
}
.tile.tile-new .tile-cta { color: #fff; }
.tile-remove {
  position: absolute; top: 8px; right: 10px;
  background: transparent; border: none; cursor: pointer;
  font-size: 0.85rem; color: var(--muted);
  padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.tile-remove:hover { background: rgba(31,42,46,0.06); color: var(--ink); }

.paste-code {
  margin-top: 2rem;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1em 1.2em;
  display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap;
}
.paste-code label { font-size: 0.85rem; color: var(--ink-soft); }
.paste-code input {
  font-family: 'Inter', sans-serif; font-size: 0.95rem;
  padding: 0.5em 0.7em; border-radius: 8px; border: 1.5px solid var(--line);
  width: 140px; letter-spacing: 0.08em;
}
.paste-code input:focus { outline: none; border-color: var(--sage-deep); box-shadow: 0 0 0 3px rgba(139,184,154,0.22); }
.privacy-note {
  margin-top: 1.5rem; font-size: 0.78rem; color: var(--muted);
  background: var(--bg-2); border-radius: 8px; padding: 0.7em 1em;
  border-left: 3px solid var(--sage);
}

/* ==========================================================================
   EDITOR PAGE
   ========================================================================== */
.editor-header {
  display: flex; align-items: center; flex-wrap: wrap; gap: 1em;
  padding: 0.5rem 0 1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}
.editor-header .title-block { flex: 1 1 auto; min-width: 200px; }
.editor-header .title-input {
  font-family: 'Fraunces', serif;
  font-size: 1.6rem; font-weight: 600;
  background: transparent; border: 1px dashed transparent;
  padding: 0.15em 0.3em; margin: -0.15em -0.3em;
  width: 100%; max-width: 600px;
  border-radius: 6px;
  color: var(--ink);
}
.editor-header .title-input:hover, .editor-header .title-input:focus {
  border-color: var(--sage); outline: none; background: #fff;
}
.editor-meta {
  font-size: 0.8rem; color: var(--muted);
  display: flex; gap: 0.7em; align-items: center; flex-wrap: wrap;
}
.editor-meta code {
  background: var(--bg-2); padding: 0.15em 0.45em; border-radius: 5px;
  letter-spacing: 0.06em; color: var(--sage-deep); font-weight: 600;
}
.save-status {
  font-weight: 500; color: var(--muted);
  display: inline-flex; align-items: center; gap: 0.35em;
}
.save-status.saving { color: var(--sky-deep); }
.save-status.saved  { color: var(--sage-deep); }
.save-status.error  { color: var(--peach-deep); }
.editor-actions { display: flex; gap: 0.5em; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.55em 1em;
  border-radius: 999px;
  font-weight: 600; font-size: 0.85rem;
  text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--line);
  background: rgba(255,255,255,0.85);
  color: var(--ink);
  transition: transform 0.15s ease, background 0.18s, color 0.18s, border-color 0.18s;
}
.btn:hover { transform: translateY(-1px); background: #fff; text-decoration: none; }
.btn-primary { background: var(--sage-deep); color: #fff; border-color: var(--sage-deep); }
.btn-primary:hover { background: #3f7050; color: #fff; }
.btn-ghost   { background: transparent; }

/* ---- Card grid: 2-col default, with a special row for growth+suggestions ---- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1em;
}
.card-grid .full { grid-column: 1 / -1; }
.card-grid .growth-card     { grid-column: 1 / span 1; }
.card-grid .suggestions-card { grid-column: 2 / span 1; }
@media (max-width: 880px) { .card-grid { grid-template-columns: 1fr; }
  .card-grid .growth-card,
  .card-grid .suggestions-card { grid-column: auto; }
}

.suggestions-card { max-height: 520px; overflow-y: auto; }
.suggestions-card::-webkit-scrollbar { width: 6px; }
.suggestions-card::-webkit-scrollbar-thumb { background: var(--sage); border-radius: 3px; }

.card {
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1em 1.25em;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  font-size: 1.05rem; margin: 0 0 0.6em 0;
  display: flex; align-items: center; gap: 0.4em;
}
.card-sub { font-size: 0.78rem; color: var(--muted); margin-top: -0.4em; margin-bottom: 0.7em; }

/* ---- Collapsible cards (chevron in top-right, summary inline) ---- */
.card.collapsible > .card-header {
  display: flex;
  align-items: center;
  gap: 0.55em;
  cursor: pointer;
  user-select: none;
  margin: 0 0 0.6em 0;
  padding: 0;
  font-size: 1.05rem;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  color: var(--ink);
}
.card.collapsible > .card-header .card-title-text {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}
.card.collapsible > .card-header .card-summary {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card.collapsible.is-collapsed > .card-header .card-summary { opacity: 1; }
.card.collapsible > .card-header .card-chevron {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 24px; height: 24px;
  margin-left: 0.2em;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  transition: transform 0.18s ease, color 0.18s ease;
  border-radius: 6px;
}
.card.collapsible:hover > .card-header .card-chevron { color: var(--sage-deep); }
.card.collapsible.is-collapsed > .card-header .card-chevron { transform: rotate(-90deg); }
.card.collapsible.is-collapsed { padding-bottom: 1.1em; }
.card.collapsible.is-collapsed > .card-header { margin-bottom: 0; }
.card.collapsible.is-collapsed > *:not(.card-header) { display: none !important; }

.card .field { display: flex; flex-direction: column; margin-bottom: 0.6em; }
.card .field label {
  font-size: 0.7rem; font-weight: 600; color: var(--ink-soft);
  letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.25em;
}
.card .field input,
.card .field select {
  font: inherit; font-size: 0.95rem; font-weight: 500;
  padding: 0.5em 0.7em;
  border: 1.5px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink);
  width: 100%;
}
.card .field input:focus,
.card .field select:focus {
  outline: none; border-color: var(--sage-deep); box-shadow: 0 0 0 3px rgba(139,184,154,0.22);
}

.income-period {
  display: inline-flex; gap: 0.3em; margin-bottom: 0.5em;
  background: var(--bg-2); padding: 3px; border-radius: 999px;
}
.income-period label {
  cursor: pointer;
  font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
  padding: 0.3em 0.85em; border-radius: 999px;
}
.income-period input[type="radio"] { display: none; }
.income-period input[type="radio"]:checked + span {
  background: var(--sage-deep); color: #fff;
  padding: 0.3em 0.85em; border-radius: 999px;
}

.takehome-readout {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem; color: var(--sage-deep);
  margin-top: 0.6em; padding-top: 0.6em;
  border-top: 1px solid var(--line);
}
.takehome-readout .label {
  font-family: 'Inter', sans-serif; font-size: 0.7rem; font-weight: 600;
  color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase;
  display: block; margin-bottom: 0.2em;
}
.takehome-tax-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem; font-weight: 500; color: var(--peach-deep);
  margin-top: 0.35em;
}
.takehome-tax-line span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- Line items list ---- */
.line-items { display: flex; flex-direction: column; gap: 0.4em; }
.line-item {
  display: grid;
  grid-template-columns: 1fr 95px 56px auto;
  gap: 0.4em;
  align-items: center;
}
.line-item .li-label {
  font: inherit; font-size: 0.92rem;
  padding: 0.4em 0.55em;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--ink);
  min-width: 0;
}
.line-item .li-label:hover, .line-item .li-label:focus {
  border-color: var(--line); background: #fff; outline: none;
}
.line-item .li-amount {
  font: inherit; font-size: 0.92rem; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 600;
  padding: 0.4em 0.5em;
  border: 1.5px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); width: 100%;
  min-width: 0;
}
.line-item .li-amount:focus {
  outline: none; border-color: var(--sage-deep); box-shadow: 0 0 0 2px rgba(139,184,154,0.22);
}
.line-item .li-period {
  font: inherit; font-size: 0.7rem; font-weight: 600; color: var(--ink-soft);
  padding: 0.4em 0.3em;
  border: 1.5px solid var(--line); border-radius: 6px;
  background: #fff;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: none;
  text-align: center;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.line-item .li-period:hover { border-color: var(--sage); }
.line-item .li-period:focus { outline: none; border-color: var(--sage-deep); box-shadow: 0 0 0 2px rgba(139,184,154,0.22); }
.line-item .li-remove {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); padding: 0.3em 0.5em; font-size: 1rem; border-radius: 6px;
  visibility: hidden;
}
.line-item:hover .li-remove { visibility: visible; }
.line-item .li-remove:hover { color: var(--peach-deep); background: rgba(244,184,147,0.15); }
.line-item.is-default .li-remove { display: none; }
.line-item.is-key .li-label { font-weight: 500; }

.bucket-total {
  font-family: 'Fraunces', serif; font-weight: 600;
  font-size: 1rem; color: var(--ink);
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 0.7em; padding-top: 0.6em; border-top: 1px solid var(--line);
}
.bucket-total .lbl { font-family: 'Inter', sans-serif; font-size: 0.78rem; color: var(--muted); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.bucket-total .val { color: var(--sage-deep); font-variant-numeric: tabular-nums; }

.add-line {
  font: inherit; font-size: 0.85rem; color: var(--sage-deep);
  background: transparent; border: 1px dashed var(--sage); cursor: pointer;
  border-radius: 6px; padding: 0.4em 0.8em; margin-top: 0.5em;
  align-self: flex-start;
}
.add-line:hover { background: rgba(139,184,154,0.12); }

/* ---- Bottom line card ---- */
.bottom-line table {
  width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums;
}
.bottom-line th, .bottom-line td {
  padding: 0.45em 0.6em; font-size: 0.92rem;
}
.bottom-line th {
  text-align: right; font-weight: 600; font-size: 0.7rem;
  color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.bottom-line th:first-child { text-align: left; }
.bottom-line td.lbl { color: var(--ink-soft); }
.bottom-line td.num { text-align: right; }
.bottom-line tr.takehome-row td {
  font-weight: 700; padding-top: 0.7em; padding-bottom: 0.7em;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.bottom-line tr.takehome-row td.lbl { color: var(--ink); }
.bottom-line tr.takehome-row td.num { color: var(--ink); }

.bottom-line tr.leftover-row td {
  font-weight: 700; padding-top: 0.7em; border-top: 1px solid var(--line);
}
.bottom-line tr.leftover-row td.lbl { color: var(--sage-deep); }
.bottom-line tr.leftover-row td.num { color: var(--sage-deep); font-size: 1.05rem; }
.bottom-line .effective-rate {
  margin-top: 0.7em; font-size: 0.78rem; color: var(--muted); text-align: right;
}

/* ---- Score / 50-30-20 card ---- */
.score-bars { display: flex; flex-direction: column; gap: 0.5em; margin-top: 0.5em; }
.score-bar {
  display: grid; grid-template-columns: 70px 1fr 50px;
  gap: 0.6em; align-items: center; font-size: 0.85rem;
}
.score-bar .lbl { color: var(--ink-soft); font-weight: 500; }
.score-bar .pct { text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.score-bar .bar-track {
  height: 12px; background: var(--bg-2); border-radius: 999px; overflow: hidden;
  position: relative;
}
.score-bar .bar-fill {
  height: 100%; transition: width 0.4s ease;
  border-radius: 999px;
}
.score-bar.needs .bar-fill { background: var(--sage-deep); }
.score-bar.wants .bar-fill { background: var(--sky-deep); }
.score-bar.save  .bar-fill { background: var(--peach-deep); }
.score-bar .target-marker {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: rgba(31,42,46,0.45);
}

.score-summary {
  font-size: 0.85rem; color: var(--ink-soft);
  margin-top: 0.6em;
}

/* ---- Growth card ---- */
.growth-card .rate-input {
  display: flex; align-items: center; gap: 0.5em; margin-bottom: 0.6em;
}
.growth-card .rate-input label { font-size: 0.78rem; color: var(--muted); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.growth-card .rate-input input {
  font: inherit; font-size: 0.95rem; font-weight: 600;
  padding: 0.4em 0.55em; border-radius: 6px;
  border: 1.5px solid var(--line); background: #fff; width: 70px; text-align: right;
}
.growth-card .rate-input input:focus { outline: none; border-color: var(--sage-deep); box-shadow: 0 0 0 3px rgba(139,184,154,0.22); }
.growth-card .rate-input .pct-suffix { color: var(--muted); }
.growth-card .horizon-list {
  display: flex; flex-direction: column; gap: 0.3em; font-size: 0.92rem;
}
.growth-card .horizon-list div {
  display: flex; justify-content: space-between; font-variant-numeric: tabular-nums;
}
.growth-card .horizon-list .yrs { color: var(--ink-soft); }
.growth-card .horizon-list .val { color: var(--sage-deep); font-weight: 600; font-family: 'Fraunces', serif; font-size: 1rem; }
.growth-card .rate-warning {
  margin-top: 0.5em; font-size: 0.78rem; color: var(--peach-deep);
  background: rgba(244,184,147,0.15); padding: 0.55em 0.75em;
  border-radius: 6px; border-left: 3px solid var(--peach);
}
.growth-card { display: flex; flex-direction: column; }
.growth-card canvas { width: 100% !important; height: 260px !important; margin-top: 0.8em; flex: 1 1 auto; }

/* ---- Suggestions card ---- */
.suggestions { display: flex; flex-direction: column; gap: 0.5em; }
.suggestion {
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--line); border-left: 3px solid var(--sage);
  border-radius: 6px; padding: 0.7em 0.85em;
  font-size: 0.88rem;
}
.suggestion.warn     { border-left-color: var(--gold); background: rgba(230,200,117,0.10); }
.suggestion.critical { border-left-color: var(--peach-deep); background: rgba(244,184,147,0.13); }
.suggestion .s-title { font-weight: 600; color: var(--ink); margin-bottom: 0.15em; }
.suggestion .s-detail { color: var(--ink-soft); font-size: 0.85rem; }
.suggestion .s-link { font-size: 0.78rem; color: var(--sage-deep); display: inline-block; margin-top: 0.3em; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 0.7em 1.1em; border-radius: 999px;
  background: var(--ink); color: #fff;
  font-size: 0.85rem; font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error  { background: var(--peach-deep); }

/* ---- Disclaimer footer ---- */
.disclaimer {
  margin-top: 2.5rem;
  font-size: 0.75rem; color: var(--muted);
  text-align: center;
  padding: 0.8em 1em;
}

/* ---- 404 ---- */
.error-page {
  max-width: 520px; margin: 6rem auto 4rem; padding: 0 1.5rem; text-align: center;
}
.error-page h1 { font-size: 2rem; margin-bottom: 0.5em; }
.error-page p { color: var(--ink-soft); }
.error-page .btn-row { display: flex; justify-content: center; gap: 0.6em; margin-top: 1.5em; flex-wrap: wrap; }
