:root {
  color-scheme: light;
  --bg: #fbfaf8;
  --card: #ffffff;
  --ink: #111820;
  --muted: #69717a;
  --subtle: #8b949d;
  --line: #e9e6e1;
  --green: #1e8a3a;
  --green-soft: #eaf5eb;
  --mint: #04967d;
  --mint-soft: #e6f8f4;
  --amber: #d78618;
  --amber-soft: #fff4df;
  --red: #d33131;
  --red-soft: #fff0ee;
  --blue: #1683bf;
  --blue-soft: #e9f5fc;
  --purple: #7b5bd6;
  --purple-soft: #f1edff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 2%, rgba(30, 138, 58, 0.08), transparent 20rem),
    radial-gradient(circle at 86% 0%, rgba(123, 91, 214, 0.07), transparent 18rem),
    var(--bg);
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 22px;
}

.login-card {
  width: min(100%, 390px);
  padding: 28px 24px;
}

.login-card > span,
.connection-card > span {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  margin-bottom: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-weight: 800;
}

.login-card h1 {
  margin-bottom: 12px;
  font-size: 2.45rem;
  line-height: 1;
}

.login-card p {
  color: var(--muted);
  line-height: 1.45;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.login-form #loginStatus {
  min-height: 1.4em;
  color: var(--red);
  font-weight: 700;
}

button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.phone-app {
  position: relative;
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
}

main {
  padding: max(22px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.active { display: block; }

.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  margin-bottom: 16px;
}

.screen-head h1 {
  font-size: 2.15rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.icon-only {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--muted);
  background: var(--card);
  box-shadow: 0 8px 22px rgba(25, 25, 25, 0.04);
}

.section-label {
  display: block;
  margin: 18px 4px 9px;
  color: #2d343b;
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: 0;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.section-row .section-label {
  margin-top: 0;
}

.link-button {
  border: 0;
  color: var(--green);
  background: transparent;
  font-weight: 700;
}

.card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 10px 24px rgba(27, 25, 22, 0.045);
}

.stack-card > * + * {
  border-top: 1px solid var(--line);
}

.list-row,
.budget-list-row,
.transaction-row,
.bill-row,
.simple-row {
  display: grid;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
}

.list-row {
  grid-template-columns: 58px minmax(0, 1fr) auto;
}

.list-row.compact {
  grid-template-columns: 46px minmax(0, 1fr) auto auto;
  padding: 14px 16px;
}

.circle {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-weight: 800;
}

.emoji-circle {
  font-size: 1.55rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.circle svg {
  width: 27px;
  height: 27px;
}

.circle.neutral {
  color: #28313a;
  background: #eef0f1;
}

.circle.mint {
  color: var(--mint);
  background: var(--mint-soft);
}

.circle.red {
  color: var(--red);
  background: var(--red-soft);
}

.circle.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.circle.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.circle.purple {
  color: var(--purple);
  background: var(--purple-soft);
}

.list-row strong,
.simple-row strong {
  display: block;
  margin-bottom: 5px;
  font-size: 0.98rem;
}

.list-row b {
  display: block;
  margin-bottom: 4px;
  font-size: 1.42rem;
}

.list-row p,
.simple-row p,
.connection-card p {
  color: var(--muted);
  line-height: 1.35;
}

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

b.red { color: var(--red); }
b.amber { color: var(--amber); }

.chevron {
  color: var(--subtle);
  font-size: 2rem;
  line-height: 1;
}

.month-card,
.total-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 18px;
}

.month-card {
  position: relative;
  background:
    linear-gradient(135deg, rgba(234, 245, 235, 0.72), rgba(255, 255, 255, 0.96) 44%),
    var(--card);
}

.coach-note {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  margin-bottom: 2px;
  border-radius: 999px;
  padding: 7px 10px 7px 8px;
  color: #186836;
  background: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  font-weight: 750;
}

.coach-note span {
  font-size: 1rem;
}

.month-card p,
.total-card p {
  margin-bottom: 5px;
  color: #2d343b;
  font-weight: 700;
}

.month-card strong,
.total-card strong {
  display: block;
  font-size: 1.5rem;
}

.month-card span,
.total-card span {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.percent-block {
  align-self: end;
  text-align: right;
}

.percent-block strong {
  font-size: 1.45rem;
}

.progress-track {
  grid-column: 1 / -1;
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: #e3e3e1;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.progress-track span.amber {
  background: var(--amber);
}

.progress-track span.blue {
  background: var(--blue);
}

.progress-track span.purple {
  background: var(--purple);
}

.progress-track span.mint {
  background: var(--mint);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.segmented button {
  position: relative;
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.segmented button.active {
  color: var(--ink);
}

.segmented button.active::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: -5px;
  left: 8px;
  height: 3px;
  border-radius: 999px;
  background: var(--green);
}

.budget-list-row {
  grid-template-columns: 58px minmax(0, 1fr) auto auto;
  padding: 16px;
}

.budget-main strong {
  display: block;
  margin-bottom: 13px;
  font-size: 1.15rem;
}

.budget-numbers {
  min-width: 84px;
  text-align: right;
}

.budget-numbers b,
.budget-numbers span,
.budget-numbers small {
  display: block;
}

.budget-numbers b {
  font-size: 1.03rem;
}

.budget-numbers span {
  color: var(--muted);
}

.budget-numbers small {
  margin-top: 7px;
  color: #2d343b;
  font-size: 0.78rem;
}

.total-card {
  margin-top: 14px;
}

.total-card > div:nth-child(2) {
  text-align: right;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  gap: 12px;
  margin-bottom: 24px;
}

.search-box {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--subtle);
  background: var(--card);
  box-shadow: 0 8px 22px rgba(25, 25, 25, 0.035);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.transaction-date {
  margin-top: 24px;
}

.transaction-row {
  grid-template-columns: 52px minmax(0, 1fr) auto auto;
  padding: 16px;
}

.bill-row {
  grid-template-columns: 52px minmax(0, 1fr) auto auto;
  padding: 16px;
}

.bill-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.02rem;
}

.bill-row p {
  color: var(--muted);
}

.bill-row b {
  font-size: 1.03rem;
  white-space: nowrap;
}

.brand {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  font-size: 0.86rem;
  font-weight: 800;
}

.brand {
  font-size: 1.28rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.brand.red { background: #ec5555; }
.brand.blue { background: var(--blue); }
.brand.amber { background: var(--amber); }
.brand.purple { background: var(--purple); }
.brand.income { background: var(--green-soft); color: var(--green); font-size: 1.45rem; }

.transaction-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.02rem;
}

.transaction-row p {
  color: var(--muted);
}

.transaction-row b {
  font-size: 1.03rem;
  white-space: nowrap;
}

.chip {
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.chip.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.transaction-row:has(.brand.blue) .chip {
  color: var(--blue);
  background: var(--blue-soft);
}

.transaction-row:has(.brand.purple) .chip {
  color: var(--purple);
  background: var(--purple-soft);
}

.insight-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(241, 237, 255, 0.9), rgba(255, 255, 255, 0.96) 52%),
    var(--card);
}

.insight-card strong {
  font-size: 1.35rem;
}

.flow-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  margin-bottom: 14px;
}

.flow-card .section-label {
  margin: 0 0 8px;
}

.flow-steps {
  display: grid;
  gap: 10px;
}

.flow-step {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 0;
}

.flow-step + .flow-step {
  border-top: 1px solid var(--line);
}

.flow-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #f5f6f2;
  font-size: 1.35rem;
}

.flow-step strong {
  display: block;
  margin-bottom: 3px;
}

.flow-step p {
  color: var(--muted);
  line-height: 1.35;
}

.connection-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.connection-card span,
.simple-row > span {
  width: max-content;
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.78rem;
  font-weight: 750;
}

.simple-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

.secondary-button {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  background: var(--card);
  font-weight: 800;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--card);
}

dialog {
  width: min(calc(100% - 28px), 390px);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--card);
  box-shadow: 0 30px 80px rgba(20, 20, 20, 0.22);
}

dialog::backdrop {
  background: rgba(17, 24, 32, 0.34);
  backdrop-filter: blur(8px);
}

.modal-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head .icon-only {
  width: 38px;
  height: 38px;
  font-size: 1.4rem;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 430px);
  min-height: calc(76px + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.tabbar button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  border: 0;
  color: #606a72;
  background: transparent;
  font-size: 0.68rem;
  font-weight: 650;
}

.tabbar button.active {
  color: var(--green);
}

.tabbar svg {
  width: 24px;
  height: 24px;
}

@media (min-width: 900px) {
  body {
    background: #f3f1ee;
  }

  .phone-app {
    min-height: 900px;
    margin: 26px auto;
    border: 1px solid #dedbd6;
    border-radius: 34px;
    box-shadow: 0 28px 80px rgba(30, 30, 30, 0.12);
  }

  .tabbar {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 34px 34px;
  }
}

@media (max-width: 390px) {
  main {
    padding-right: 14px;
    padding-left: 14px;
  }

  .transaction-row {
    grid-template-columns: 48px minmax(0, 1fr) auto;
  }

  .transaction-row .chip {
    grid-column: 2;
    justify-self: start;
  }

  .transaction-row b {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
}
