:root {
  --bg: #f6f1e9;
  --bg-deep: #eee8df;
  --surface: #fffaf4;
  --surface-soft: #f1f4ee;
  --ink: #102a38;
  --ink-strong: #081c28;
  --muted: #6f7d82;
  --line: rgba(15, 76, 78, 0.14);
  --teal: #056b6c;
  --teal-dark: #004f53;
  --mint: #dceae2;
  --mint-2: #b9dcd0;
  --positive: #258b76;
  --negative: #b96a55;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family: "Avenir Next", "Nunito Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }

body {
  background:
    radial-gradient(circle at 80% -10%, rgba(157, 207, 192, 0.24), transparent 36%),
    radial-gradient(circle at -10% 30%, rgba(255, 255, 255, 0.78), transparent 34%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid rgba(5, 107, 108, 0.45); outline-offset: 2px; }
.bottom-nav button:focus-visible { outline-offset: -3px; border-radius: 13px; }

.app-shell { width: min(100%, 560px); min-height: 100vh; margin: 0 auto; position: relative; }

.topbar {
  height: 74px;
  padding: max(14px, env(safe-area-inset-top)) 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: var(--teal-dark);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-mark { width: 32px; height: 23px; display: inline-flex; position: relative; }
.brand-mark i {
  position: absolute;
  width: 18px;
  height: 23px;
  border: 7px solid var(--teal);
  border-bottom: 0;
  border-radius: 12px 12px 3px 3px;
}
.brand-mark i:first-child { left: 0; }
.brand-mark i:last-child { right: 0; }

.avatar, .profile-avatar {
  border: 1px solid rgba(5, 107, 108, 0.12);
  background: var(--mint);
  color: var(--teal-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.avatar { width: 38px; height: 38px; border-radius: 14px; }

main { padding: 2px 16px calc(104px + var(--safe-bottom)); }
.screen { display: none; animation: fade-in 180ms ease; }
.screen.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.intro { padding: 15px 4px 21px; }
.eyebrow { margin: 0 0 6px; color: var(--teal); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; color: var(--ink-strong); font-size: clamp(29px, 8vw, 40px); line-height: 1.08; letter-spacing: -0.038em; font-weight: 650; }
h2 { margin: 0; color: var(--ink-strong); font-size: 19px; letter-spacing: -0.018em; }

.period-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 250, 244, 0.68);
}
.period-tabs button {
  border: 0;
  min-height: 40px;
  padding: 7px 5px;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.period-tabs button.active { background: var(--teal); color: white; }
.period-tabs.compact { margin: 18px 0; }

.period-nav { height: 48px; display: flex; align-items: center; justify-content: center; gap: 16px; font-size: 13px; color: var(--muted); }
.icon-button { width: 30px; height: 30px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.35); color: var(--teal); font-size: 21px; line-height: 1; }
.icon-button:disabled { opacity: .28; }

.hero-card {
  min-height: 174px;
  padding: 24px;
  border-radius: 27px;
  background: linear-gradient(145deg, var(--teal-dark), #087879);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}
.hero-card::after { content: ""; position: absolute; width: 150px; height: 150px; border: 28px solid rgba(255,255,255,.055); border-radius: 50%; right: -57px; bottom: -80px; }
.card-label { margin: 0 0 9px; font-size: 13px; color: var(--muted); }
.hero-card .card-label { color: rgba(255,255,255,.72); }
.hero-amount { display: block; font-size: clamp(37px, 11vw, 52px); letter-spacing: -0.045em; line-height: 1; font-weight: 650; }
.trend { margin: 13px 0 0; display: inline-flex; padding: 5px 8px; border-radius: 9px; font-size: 12px; background: rgba(255,255,255,.11); }
.trend.positive { color: #c8f4e4; }.trend.negative { color: #ffd2c4; }.trend.neutral { color: rgba(255,255,255,.75); }
.round-chat-button { width: 46px; height: 46px; border: 0; border-radius: 16px; background: rgba(255,255,255,.92); color: var(--teal); display: grid; place-items: center; z-index: 1; }
.round-chat-button svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.metric-card, .content-card, .profile-stats article {
  border: 1px solid var(--line);
  background: rgba(255,250,244,.75);
}
.metric-card { min-height: 122px; padding: 16px; border-radius: 21px; }
.metric-card p { margin: 14px 0 4px; color: var(--muted); font-size: 12px; }
.metric-card strong { font-size: 16px; line-height: 1.2; color: var(--ink-strong); }
.metric-icon { width: 30px; height: 30px; border-radius: 11px; background: var(--mint); color: var(--teal); display: grid; place-items: center; font-size: 17px; font-weight: 700; }
.metric-icon-dot::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 5px rgba(5,107,108,.12); }

.content-card { border-radius: 24px; padding: 19px; margin-top: 10px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 19px; }
.section-heading .eyebrow { margin-bottom: 4px; }
.text-button { border: 0; background: transparent; color: var(--teal); font-size: 13px; padding: 5px 0; }

.chart-layout { display: grid; grid-template-columns: 132px 1fr; align-items: center; gap: 17px; }
.donut { width: 132px; aspect-ratio: 1; border-radius: 50%; position: relative; background: conic-gradient(var(--mint) 0 100%); }
.donut::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: var(--surface); }
.donut > div { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut strong { font-size: 14px; color: var(--ink-strong); }
.donut span { color: var(--muted); font-size: 10px; margin-top: 2px; }
.donut.large { width: min(60vw, 225px); margin: 22px auto 4px; }
.donut.large::after { inset: 34px; background: var(--surface-soft); }
.donut.large strong { font-size: 23px; }
.legend { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.legend-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 7px; align-items: center; font-size: 11px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.legend-amount { color: var(--ink); font-weight: 650; }

.operation-list, .history-list { display: flex; flex-direction: column; }
.operation-row { min-height: 59px; display: grid; grid-template-columns: 40px minmax(0,1fr) auto; gap: 11px; align-items: center; border-top: 1px solid rgba(15,76,78,.09); }
.operation-row:first-child { border-top: 0; }
.operation-icon { width: 38px; height: 38px; border-radius: 13px; background: var(--mint); color: var(--teal); display: grid; place-items: center; font-size: 16px; font-weight: 700; }
.operation-main { min-width: 0; }
.operation-main strong, .operation-main span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.operation-main strong { color: var(--ink-strong); font-size: 13px; }
.operation-main span, .operation-value span { color: var(--muted); font-size: 10px; margin-top: 3px; }
.operation-value { text-align: right; }
.operation-value strong { color: var(--ink-strong); font-size: 13px; }
.operation-value strong.income { color: var(--positive); }

.chat-cta { width: 100%; min-height: 58px; margin-top: 12px; padding: 0 19px; border: 0; border-radius: 19px; background: var(--teal); color: white; display: flex; align-items: center; justify-content: space-between; font-weight: 650; }

.screen-title { padding: 23px 4px 4px; }
.screen-title h1 { font-size: 35px; }
.screen-title > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.category-total-card { text-align: center; background: var(--surface-soft); }
.category-total-card > strong { color: var(--ink-strong); font-size: 31px; }
.category-details { display: flex; flex-direction: column; gap: 9px; margin-top: 11px; }
.category-row { border: 1px solid var(--line); border-radius: 18px; background: rgba(255,250,244,.68); padding: 15px 16px; }
.category-row-head { display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center; }
.category-row-head strong { font-size: 14px; }.category-row-head span:last-child { font-weight: 650; font-size: 14px; }
.category-row-meta { margin: 7px 0 9px 19px; color: var(--muted); font-size: 11px; }
.progress { height: 5px; border-radius: 5px; background: var(--bg-deep); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; }

.history-summary { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; padding: 3px 4px 11px; }
.history-summary strong { color: var(--ink); }
.history-group { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 22px; padding: 4px 16px; background: rgba(255,250,244,.7); }
.history-date { padding: 13px 0 8px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.empty-state { padding: 34px 15px; text-align: center; color: var(--muted); font-size: 14px; }

.profile-title { display: flex; align-items: center; gap: 15px; }
.profile-avatar { width: 64px; height: 64px; border-radius: 23px; font-size: 23px; flex: 0 0 auto; }
.profile-title h1 { font-size: 29px; }
.profile-title > div:last-child > p:last-child { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.subscription-card { margin-top: 22px; padding: 23px; border-radius: 27px; background: linear-gradient(145deg, var(--teal-dark), #087879); color: white; overflow: hidden; position: relative; }
.subscription-card::after { content: ""; position: absolute; width: 150px; height: 150px; border: 26px solid rgba(255,255,255,.05); border-radius: 50%; right: -62px; bottom: -72px; }
.subscription-topline { display: flex; align-items: center; justify-content: space-between; color: rgba(255,255,255,.7); font-size: 11px; }
.plus-badge { border-radius: 8px; background: rgba(255,255,255,.15); padding: 5px 8px; color: white; font-weight: 750; letter-spacing: .06em; }
.subscription-card h2 { margin-top: 25px; color: white; font-size: 26px; }
.subscription-card p { max-width: 310px; margin: 8px 0 20px; color: rgba(255,255,255,.75); font-size: 13px; line-height: 1.45; }
.light-button { position: relative; z-index: 1; border: 0; min-height: 43px; padding: 0 15px; border-radius: 14px; background: white; color: var(--teal-dark); font-weight: 650; font-size: 12px; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.profile-stats article { padding: 16px; border-radius: 19px; display: flex; flex-direction: column; gap: 5px; }
.profile-stats span { color: var(--muted); font-size: 11px; }.profile-stats strong { color: var(--ink-strong); font-size: 18px; }
.profile-info { padding: 7px 17px; }
.info-row { min-height: 55px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-top: 1px solid rgba(15,76,78,.09); font-size: 13px; }
.info-row:first-child { border-top: 0; }.info-row span { color: var(--muted); }.info-row strong { text-align: right; }
.privacy-note { margin: 15px 13px 0; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.5; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 560px);
  height: calc(76px + var(--safe-bottom));
  padding: 8px 10px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: rgba(250, 247, 241, .94);
  backdrop-filter: blur(18px);
}
.bottom-nav button { border: 0; background: transparent; color: #879194; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10px; font-weight: 650; }
.bottom-nav button.active { color: var(--teal); }
.bottom-nav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.loading-layer { position: fixed; z-index: 50; inset: 0; background: var(--bg); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 19px; color: var(--muted); font-size: 13px; }
.loading-layer.active { display: flex; }
.loader-logo { width: 70px; height: 70px; border-radius: 25px; display: grid; place-items: center; background: var(--mint); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.06); opacity: .72; } }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(91px + var(--safe-bottom)); transform: translate(-50%, 18px); width: min(calc(100% - 32px), 500px); padding: 13px 16px; border-radius: 15px; background: var(--ink-strong); color: white; text-align: center; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.active { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border: 1px solid var(--line); border-radius: 34px; overflow: hidden; background: rgba(246,241,233,.88); }
  .bottom-nav { bottom: 24px; border-radius: 0 0 34px 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
