:root {
  --ink: #13213a;
  --ink-soft: #526079;
  --ink-faint: #8590a4;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #e8edf4;
  --navy: #142542;
  --navy-2: #1d3458;
  --teal: #159b91;
  --teal-dark: #08736e;
  --aqua: #e7fbf8;
  --purple: #715ce6;
  --purple-soft: #f1efff;
  --yellow: #f7b844;
  --yellow-soft: #fff6dd;
  --red: #d85d6f;
  --red-soft: #fff0f2;
  --shadow: 0 20px 50px rgba(16, 35, 66, .08);
  --shadow-sm: 0 8px 24px rgba(16, 35, 66, .06);
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 0%, rgba(21, 155, 145, .13), transparent 26rem),
    radial-gradient(circle at 100% 13%, rgba(113, 92, 230, .10), transparent 25rem),
    #f4f7fb;
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1440px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 2rem 0 1.5rem;
}

.brand-lockup { display: flex; align-items: center; gap: .8rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--teal), var(--purple));
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: -.06em;
  box-shadow: 0 10px 22px rgba(21, 155, 145, .23);
}

.eyebrow, .section-kicker {
  margin: 0;
  color: var(--teal-dark);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topbar h1, h2, h3, h4, p { margin-top: 0; }
.topbar h1 { margin-bottom: 0; font: 700 1.18rem/1.2 "Space Grotesk", sans-serif; letter-spacing: -.03em; }

.save-status {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--ink-soft);
  font-size: .86rem;
  font-weight: 600;
}
.status-dot, .live-pill span {
  width: .5rem;
  height: .5rem;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 .25rem rgba(21, 155, 145, .12);
}

.page-content { width: min(1440px, calc(100% - 3rem)); margin: 0 auto; padding-bottom: 3rem; }

.panel {
  border: 1px solid rgba(232, 237, 244, .95);
  border-radius: 24px;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-sm);
}

.identity-panel {
  display: grid;
  grid-template-columns: minmax(220px, .75fr) minmax(600px, 1.55fr);
  align-items: center;
  gap: 2rem;
  padding: 1.5rem 1.65rem;
  background: linear-gradient(110deg, rgba(255, 255, 255, .92), rgba(241, 251, 250, .95));
}
.identity-copy h2 { margin: .28rem 0 .3rem; font: 600 1.35rem/1.2 "Space Grotesk", sans-serif; letter-spacing: -.04em; }
.identity-copy p:last-child { margin: 0; color: var(--ink-soft); font-size: .91rem; }
.identity-controls { display: grid; grid-template-columns: minmax(100px, .45fr) auto minmax(170px, .8fr) minmax(160px, .8fr); align-items: end; gap: .7rem; }

.notice { display: flex; align-items: flex-start; gap: .7rem; margin: 1rem 0 1.55rem; padding: .8rem 1rem; border-radius: 14px; font-size: .85rem; }
.notice p { margin: 0; }
.notice-warning { color: #7e5d17; background: var(--yellow-soft); border: 1px solid #f8e6b6; }
.notice-icon { display: grid; place-items: center; flex: 0 0 auto; width: 1.25rem; height: 1.25rem; margin-top: .1rem; border-radius: 50%; color: #7e5d17; background: #f7cf73; font-size: .78rem; font-weight: 800; }

.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 0 0 1.15rem; }
.hero-row h2 { margin: .28rem 0 .25rem; font: 700 clamp(1.65rem, 3vw, 2.25rem)/1.05 "Space Grotesk", sans-serif; letter-spacing: -.06em; }
.muted { margin: 0; color: var(--ink-soft); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.7rem;
  border: 0;
  border-radius: 12px;
  padding: .65rem 1rem;
  font-size: .9rem;
  font-weight: 700;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .text-button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(21, 155, 145, .25); outline-offset: 2px; }
.button-primary { color: white; background: var(--navy); box-shadow: 0 9px 20px rgba(20, 37, 66, .17); }
.button-primary:hover { background: var(--navy-2); box-shadow: 0 12px 24px rgba(20, 37, 66, .22); }
.button-secondary { color: var(--navy); background: white; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.button-secondary:hover { background: var(--surface-soft); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.metric-card { position: relative; min-height: 8.2rem; overflow: hidden; padding: 1.15rem 1.25rem; border-radius: 20px; box-shadow: var(--shadow-sm); }
.metric-card::after { position: absolute; right: -2rem; bottom: -3rem; width: 8.5rem; height: 8.5rem; border-radius: 50%; content: ""; opacity: .14; }
.metric-income { color: white; background: linear-gradient(145deg, #148e87, #116a6a); }
.metric-plan { color: white; background: linear-gradient(145deg, #4e42b2, #322d78); }
.metric-flexible { color: var(--ink); background: linear-gradient(145deg, #e8f8f4, #d9f1ee); }
.metric-daily { color: var(--ink); background: linear-gradient(145deg, #fff7e4, #ffedbe); }
.metric-income::after { background: #a4fff4; }.metric-plan::after { background: #cbc6ff; }.metric-flexible::after { background: var(--teal); }.metric-daily::after { background: var(--yellow); }
.metric-label { display: flex; align-items: center; gap: .48rem; position: relative; z-index: 1; font-size: .82rem; font-weight: 700; opacity: .83; }
.metric-icon { display: inline-grid; place-items: center; width: 1.35rem; height: 1.35rem; border-radius: 7px; background: rgba(255,255,255,.23); font-size: .95rem; }
.metric-card strong { display: block; position: relative; z-index: 1; margin: .7rem 0 .15rem; font: 700 clamp(1.25rem, 2.2vw, 1.75rem)/1 "Space Grotesk", sans-serif; letter-spacing: -.05em; }
.metric-note { position: relative; z-index: 1; font-size: .72rem; opacity: .7; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, .85fr); gap: 1rem; align-items: start; }
.budget-panel, .composition-panel, .control-panel, .daily-panel { padding: 1.35rem; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.panel-heading h3 { margin: .3rem 0 0; font: 600 1.2rem/1.2 "Space Grotesk", sans-serif; letter-spacing: -.04em; }
.compact-heading { margin-bottom: 1rem; }
.month-chip { padding: .42rem .72rem; border-radius: 9px; color: var(--teal-dark); background: var(--aqua); font-size: .77rem; font-weight: 700; white-space: nowrap; }

.form-grid { display: grid; gap: 1rem; }
.two-columns { grid-template-columns: 1fr 1fr; margin-bottom: 1.55rem; }
.field { display: flex; flex-direction: column; gap: .38rem; min-width: 0; color: var(--ink-soft); font-size: .78rem; font-weight: 700; }
.field input, .field select {
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid #dce3ed;
  border-radius: 11px;
  padding: .62rem .75rem;
  color: var(--ink);
  background: white;
  font-size: .92rem;
  font-weight: 500;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.field input:hover, .field select:hover { border-color: #b9c7d9; }
.field small { color: var(--ink-faint); font-size: .73rem; font-weight: 500; }
.money-input, .suffix-input { display: flex; align-items: center; min-height: 2.65rem; border: 1px solid #dce3ed; border-radius: 11px; background: white; overflow: hidden; }
.money-input:focus-within, .suffix-input:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(21, 155, 145, .12); }
.money-input span, .suffix-input span { flex: 0 0 auto; padding: 0 .75rem; color: var(--ink-faint); font-size: .87rem; font-weight: 700; }
.money-input input, .suffix-input input { min-height: 2.55rem; border: 0; border-radius: 0; padding-left: .1rem; box-shadow: none; }
.money-input input:focus, .suffix-input input:focus { outline: 0; }
.compact-field span { font-size: .7rem; }
.compact-field input, .compact-field select { min-height: 2.45rem; padding: .5rem .65rem; font-size: .85rem; }

.subsection-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.subsection-heading h4, .entries-toolbar h4 { margin: 0; font-size: .95rem; }
.subsection-heading p { margin: .2rem 0 0; color: var(--ink-faint); font-size: .78rem; font-weight: 500; }
.text-button { border: 0; padding: .3rem 0; color: var(--teal-dark); background: transparent; font-size: .8rem; font-weight: 800; }
.text-button:hover { color: var(--purple); }
.danger-text { color: var(--red); }

.expense-list { display: flex; flex-direction: column; }
.expense-row { display: grid; grid-template-columns: minmax(150px, 1.25fr) minmax(120px, .8fr) minmax(125px, .75fr) minmax(72px, .38fr) 30px; align-items: center; gap: .65rem; padding: .78rem 0; border-bottom: 1px solid var(--line); }
.expense-row:last-child { border-bottom: 0; }
.expense-row .field { gap: .2rem; }
.expense-row .field > span { display: none; }
.expense-row .field input, .expense-row .field select { min-height: 2.35rem; padding: .46rem .6rem; font-size: .84rem; }
.expense-name { min-width: 0; }
.expense-name input { font-weight: 700 !important; }
.period-control { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.frequency-inline { display: flex; align-items: center; gap: .35rem; color: var(--ink-faint); font-size: .66rem; font-weight: 600; white-space: nowrap; }
.frequency-inline input { width: 3.2rem; min-height: 1.55rem !important; padding: .22rem .35rem !important; border-radius: 7px !important; font-size: .74rem !important; }
.expense-unit { align-self: end; color: var(--ink-faint); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.expense-total { align-self: end; color: var(--navy); font-size: .84rem; font-weight: 800; text-align: right; white-space: nowrap; }
.icon-button { display: grid; place-items: center; width: 1.85rem; height: 1.85rem; border: 0; border-radius: 8px; color: var(--ink-faint); background: transparent; font-size: 1.15rem; }
.icon-button:hover { color: var(--red); background: var(--red-soft); }

.calculation-strip { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding: .9rem 1rem; border-radius: 13px; background: var(--navy); color: white; }
.calculation-strip span { display: block; font-size: .84rem; font-weight: 700; }.calculation-strip small { display: block; margin-top: .18rem; color: #aebbd0; font-size: .7rem; }
.calculation-strip strong { font: 700 1.25rem/1 "Space Grotesk", sans-serif; letter-spacing: -.04em; }

.side-stack { display: flex; flex-direction: column; gap: 1rem; }
.composition-list { display: flex; flex-direction: column; gap: .9rem; }
.composition-item { display: grid; grid-template-columns: 1fr auto; gap: .25rem .7rem; align-items: center; }
.composition-item .composition-label { color: var(--ink-soft); font-size: .77rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composition-item strong { font-size: .78rem; }
.composition-bar { grid-column: 1 / -1; height: .44rem; overflow: hidden; border-radius: 999px; background: #edf1f7; }
.composition-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #72d7cb); transition: width .25s ease; }
.composition-empty { color: var(--ink-faint); font-size: .8rem; }

.live-pill { display: inline-flex; align-items: center; gap: .42rem; padding: .35rem .55rem; border-radius: 8px; color: var(--teal-dark); background: var(--aqua); font-size: .7rem; font-weight: 800; }
.control-stat { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.control-stat span { color: var(--ink-soft); font-size: .78rem; }.control-stat strong { font: 700 1rem "Space Grotesk", sans-serif; letter-spacing: -.04em; }
.daily-progress { margin-top: 1rem; }.progress-meta { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .45rem; color: var(--ink-faint); font-size: .72rem; font-weight: 600; }.progress-track { height: .55rem; overflow: hidden; border-radius: 999px; background: #edf1f7; }.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--purple)); transition: width .25s ease; }.control-tip { margin: .85rem 0 0; color: var(--ink-faint); font-size: .75rem; }

.daily-panel { margin-top: 1rem; }
.daily-heading { align-items: center; }.daily-heading > div:first-child { max-width: 680px; }.daily-heading h3 { margin-bottom: .38rem; }.daily-heading p:last-child { margin: 0; color: var(--ink-faint); font-size: .78rem; }
.remaining-badge { min-width: 170px; padding: .65rem .8rem; border-radius: 12px; color: var(--purple); background: var(--purple-soft); text-align: right; }.remaining-badge span { display: block; font-size: .68rem; font-weight: 700; }.remaining-badge strong { display: block; margin-top: .18rem; font: 700 1.15rem "Space Grotesk", sans-serif; letter-spacing: -.04em; }
.daily-entry-form { display: grid; grid-template-columns: .7fr 1.5fr .85fr auto; align-items: end; gap: .75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.field-wide { min-width: 0; }.entry-submit { min-height: 2.65rem; white-space: nowrap; }
.entries-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-top: 1.35rem; padding-bottom: .65rem; border-bottom: 1px solid var(--line); }.entries-toolbar span { color: var(--ink-faint); font-size: .76rem; }.entries-total { color: var(--navy) !important; font: 700 1rem "Space Grotesk", sans-serif; }
.entries-list { display: flex; flex-direction: column; }.entry-item { display: grid; grid-template-columns: 110px 1fr auto 30px; gap: .8rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--line); }.entry-item:last-child { border-bottom: 0; }.entry-date { color: var(--ink-faint); font-size: .76rem; font-weight: 700; }.entry-note { color: var(--ink); font-size: .83rem; font-weight: 600; }.entry-amount { color: var(--navy); font-size: .84rem; font-weight: 800; text-align: right; }.empty-state { padding: 1.35rem 0 .2rem; color: var(--ink-faint); font-size: .82rem; }

.page-footer { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.3rem; color: var(--ink-faint); font-size: .76rem; }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 10; max-width: min(360px, calc(100% - 2rem)); transform: translateY(1rem); opacity: 0; pointer-events: none; padding: .75rem 1rem; border-radius: 11px; color: white; background: var(--navy); box-shadow: var(--shadow); font-size: .82rem; font-weight: 700; transition: opacity .22s ease, transform .22s ease; }.toast.show { transform: translateY(0); opacity: 1; }.toast.error { background: var(--red); }

@media (max-width: 1050px) {
  .identity-panel { grid-template-columns: 1fr; gap: 1rem; }
  .identity-controls { grid-template-columns: minmax(100px, .55fr) auto minmax(160px, 1fr) minmax(150px, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .side-stack { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .topbar, .page-content { width: min(100% - 1.4rem, 680px); }
  .topbar { padding-top: 1.1rem; }
  .save-status { font-size: .72rem; }.save-status span:last-child { display: none; }
  .identity-controls { grid-template-columns: 1fr 1fr; }.identity-controls .button { width: 100%; }.profile-select-wrap { grid-column: 1 / 2; }.month-field { grid-column: 2 / 3; }
  .hero-row { align-items: flex-start; flex-direction: column; }.hero-row .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }.metric-card { min-height: 7.6rem; }
  .two-columns { grid-template-columns: 1fr; gap: .75rem; }
  .expense-row { grid-template-columns: minmax(120px, 1fr) minmax(100px, .75fr) minmax(110px, .7fr) 28px; }.expense-unit { grid-column: 2 / 3; grid-row: 2; margin-top: -.55rem; }.expense-total { grid-column: 3 / 4; grid-row: 2; margin-top: -.55rem; }.expense-row .icon-button { grid-column: 4; grid-row: 1 / 3; align-self: center; }
  .side-stack { grid-template-columns: 1fr; }
  .daily-heading { align-items: flex-start; flex-direction: column; }.remaining-badge { width: 100%; text-align: left; }
  .daily-entry-form { grid-template-columns: 1fr 1fr; }.field-wide { grid-column: 1 / -1; }.entry-submit { grid-column: 1 / -1; width: 100%; }
  .page-footer { flex-direction: column; gap: .45rem; }
}

@media (max-width: 480px) {
  .panel { border-radius: 18px; }.identity-panel, .budget-panel, .composition-panel, .control-panel, .daily-panel { padding: 1rem; }
  .identity-controls { grid-template-columns: 1fr; }.profile-select-wrap, .month-field { grid-column: auto; }
  .metric-grid { gap: .65rem; }.metric-card { min-height: 7rem; padding: .9rem; border-radius: 16px; }.metric-label { font-size: .7rem; }.metric-note { font-size: .65rem; }.metric-card strong { font-size: 1.15rem; }
  .subsection-heading { align-items: flex-start; flex-direction: column; gap: .35rem; }.subsection-heading .text-button { padding: 0; }
  .expense-row { grid-template-columns: minmax(110px, 1fr) minmax(90px, .8fr) 28px; }.period-control { grid-column: 1 / 3; }.expense-unit { grid-column: 1 / 2; }.expense-total { grid-column: 2 / 3; }
  .calculation-strip { align-items: flex-start; flex-direction: column; gap: .5rem; }.calculation-strip strong { font-size: 1.1rem; }
  .daily-entry-form { grid-template-columns: 1fr; }.field-wide, .entry-submit { grid-column: auto; }
  .entry-item { grid-template-columns: 1fr auto 28px; gap: .35rem .55rem; }.entry-date { grid-column: 1 / -1; }.entry-amount { grid-column: 2; grid-row: 2; }.entry-item .icon-button { grid-column: 3; grid-row: 2; }
}
