:root {
  --bg: #080d16;
  --surface: #0f1726;
  --surface-2: #131e31;
  --surface-3: #18253c;
  --line: #223149;
  --line-soft: #1a2539;
  --text: #e9effa;
  --muted: #8ea2c2;
  --accent: #3ddc97;
  --accent-soft: rgba(61, 220, 151, 0.12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --warn: #ffb454;
  --info: #6aa8ff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(61, 220, 151, 0.09), transparent 60%),
    radial-gradient(700px 400px at -10% 10%, rgba(106, 168, 255, 0.07), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- layout ---------- */

.app {
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px calc(84px + env(safe-area-inset-bottom));
}

.page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.kicker {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.topbar-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-only {
  display: inline-grid;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(10, 16, 27, 0.92);
  border-top: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 10px;
  text-decoration: none;
}

.tab:hover {
  text-decoration: none;
  color: var(--text);
}

.tab.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.tab svg {
  width: 22px;
  height: 22px;
}

/* ---------- sidebar (desktop) ---------- */

@media (min-width: 900px) {
  .app {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 22px 14px;
    border-right: 1px solid var(--line-soft);
    background: rgba(9, 14, 24, 0.6);
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 22px;
    color: var(--text);
    font-weight: 700;
    font-size: 18px;
  }

  .brand:hover {
    text-decoration: none;
  }

  .brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: var(--accent);
    color: #04110b;
    font-weight: 800;
    font-size: 18px;
  }

  .side-nav,
  .side-foot {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .side-foot {
    margin-top: auto;
    gap: 2px;
  }

  .side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 11px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 550;
    text-decoration: none;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
  }

  .side-link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
  }

  .side-link.active {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .side-link svg {
    width: 19px;
    height: 19px;
  }

  .tabbar {
    display: none;
  }

  .mobile-only {
    display: none;
  }

  .main {
    padding: 28px 32px 48px;
  }
}

/* ---------- cards ---------- */

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.grid-2 {
  display: grid;
  gap: 16px;
}

@media (min-width: 720px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- hero / metrics ---------- */

.hero {
  display: grid;
  gap: 16px;
  border-color: rgba(61, 220, 151, 0.22);
  background:
    radial-gradient(420px 200px at 100% 0%, rgba(61, 220, 151, 0.14), transparent 70%),
    linear-gradient(180deg, #101c2c 0%, #0e1725 100%);
}

@media (min-width: 640px) {
  .hero {
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: end;
  }
}

.label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.hero-value {
  font-size: clamp(32px, 8vw, 44px);
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.hero-value.neg {
  color: var(--danger);
}

.hero-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.hero-side {
  display: grid;
  gap: 8px;
}

.mini {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(8, 13, 22, 0.45);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--muted);
}

.mini strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.metric-value {
  font-size: 28px;
  font-weight: 720;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric {
  margin-bottom: 12px;
}

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
  color: var(--muted);
}

.stat-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.strip-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line-soft);
}

.strip-item span {
  color: var(--muted);
  font-size: 12px;
}

.strip-item strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ---------- progress ---------- */

.progress {
  height: 9px;
  border-radius: 99px;
  background: #0a1220;
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.progress.small {
  height: 6px;
}

.progress.large {
  height: 12px;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2bb87c, var(--accent));
  min-width: 2px;
}

/* ---------- lists ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}

.list-item:first-child {
  border-top: 0;
  padding-top: 4px;
}

.list-item-stack {
  display: block;
}

.item-title {
  font-weight: 600;
  font-size: 14px;
}

.item-sub {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
}

.item-sub.danger {
  color: var(--danger);
}

.item-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.item-right {
  text-align: right;
}

.spread {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.row-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.inline-flex {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

/* ---------- forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 600px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > span {
  color: var(--muted);
  font-size: 12.5px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #0a1220;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(61, 220, 151, 0.6);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.12);
}

input::placeholder {
  color: #5c6f8d;
}

.input-compact {
  width: 96px;
  padding: 7px 9px;
  font-size: 13px;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}

.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #04110b;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(255, 107, 107, 0.35);
  color: #ffb3b3;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

/* ---------- banners / badges ---------- */

.banner {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 16px;
  font-size: 13.5px;
}

.page > .banner {
  margin-bottom: 0;
}

.banner.ok {
  border-color: rgba(61, 220, 151, 0.35);
  background: var(--accent-soft);
  color: #b9ffdd;
}

.banner.err {
  border-color: rgba(255, 107, 107, 0.35);
  background: var(--danger-soft);
  color: #ffc4c4;
}

.banner.info {
  border-color: rgba(106, 168, 255, 0.3);
  background: rgba(106, 168, 255, 0.1);
  color: #cfe1ff;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

.badge.ok {
  border-color: rgba(61, 220, 151, 0.4);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- details / month switch ---------- */

details > summary {
  cursor: pointer;
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

.form-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-card > summary::after {
  content: "+";
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.form-card[open] > summary::after {
  content: "−";
}

.form-card[open] > summary {
  margin-bottom: 14px;
}

.summary-title {
  font-weight: 650;
}

.summary-hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-left: auto;
  margin-right: 4px;
}

.subdetails {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.subdetails > summary {
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.month-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
}

.month-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--surface-3);
  text-decoration: none;
}

/* ---------- misc ---------- */

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.accent {
  color: var(--accent);
}

.danger {
  color: var(--danger);
}

.neg {
  color: var(--danger);
}

.link {
  font-size: 13px;
  font-weight: 600;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 0 6px;
  color: var(--muted);
  font-size: 13.5px;
}

.is-muted {
  opacity: 0.55;
}

.goal-card .progress {
  margin-bottom: 10px;
}

/* ---------- auth ---------- */

.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth {
  width: 100%;
  max-width: 380px;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  font-weight: 700;
  font-size: 20px;
}

.auth-brand .brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: #04110b;
  font-weight: 800;
}

.auth-card h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.auth-card .muted {
  margin-bottom: 16px;
  font-size: 13.5px;
}

.auth-card .banner {
  margin-top: 8px;
}

.auth-note {
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- chat ---------- */

.chat-card {
  padding-bottom: 14px;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.chat-msg {
  display: flex;
}

.chat-msg.user {
  justify-content: flex-end;
}

.chat-msg.assistant {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-msg.user .chat-bubble {
  background: var(--accent-soft);
  border: 1px solid rgba(61, 220, 151, 0.3);
  border-bottom-right-radius: 5px;
}

.chat-msg.assistant .chat-bubble {
  background: var(--surface-3);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 5px;
}

.chat-empty {
  padding: 8px 0 16px;
}

.chat-empty h2 {
  margin-bottom: 6px;
}

.chat-empty .muted {
  max-width: 560px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  padding: 8px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.chip:hover {
  border-color: rgba(61, 220, 151, 0.4);
  background: var(--accent-soft);
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

.chat-form textarea {
  resize: vertical;
  min-height: 70px;
}

.chat-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface-3);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------- mobile tweaks ---------- */

@media (max-width: 520px) {
  h1 {
    font-size: 22px;
  }

  .card {
    padding: 15px;
    border-radius: 16px;
  }

  .strip {
    gap: 8px;
  }

  .strip-item {
    padding: 10px 11px;
  }

  .strip-item strong {
    font-size: 15px;
  }

  .month-label {
    max-width: 104px;
  }

  .item-amount {
    font-size: 14px;
  }
}
