:root {
  --bg0: #eef3f0;
  --bg1: #f7faf8;
  --ink: #15231f;
  --muted: #6b7c76;
  --line: rgba(21, 35, 31, 0.08);
  --panel: rgba(255, 255, 255, 0.82);
  --accent: #0f766e;
  --accent-2: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --good: #15803d;
  --bad: #dc2626;
  --warn: #c2410c;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Manrope", system-ui, sans-serif;
  --display: "Sora", "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  touch-action: manipulation;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(15, 118, 110, 0.14), transparent 55%),
    radial-gradient(90% 70% at 100% 8%, rgba(20, 83, 45, 0.08), transparent 50%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 14px;
  font-size: 16px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.app {
  height: 100dvh;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-t)) 18px 4px;
}
.top-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 6px;
}
.logout-btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
}
.hero-all {
  margin: -8px 0 14px;
  opacity: 0.9;
  font-size: 0.88rem;
  font-weight: 700;
}
.chips {
  display: flex;
  gap: 8px;
  margin: 10px 0 4px;
}
.chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}
.chip.on {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: transparent;
}
#txSearch {
  margin-top: 4px;
}
.colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
}
.color-dot.on {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink);
}
.login-app .scroll { padding-top: 8px; }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}
.login-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.4;
}
.login-error { color: var(--bad); font-weight: 700; }
.brand {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}
.brand-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.month-bar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 6px;
}
.month-nav {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--line);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-2);
}
.month-label {
  min-height: 44px;
  border-radius: 14px;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--line);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 6px 16px calc(24px + var(--safe-b));
}

.hero {
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 12px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.14), transparent 42%),
    linear-gradient(145deg, #0f766e, #134e4a 68%, #14532d);
  box-shadow: 0 16px 36px rgba(15, 118, 110, 0.28);
}
.hero-kicker {
  opacity: 0.88;
  font-size: 0.86rem;
  font-weight: 600;
}
.hero > strong {
  display: block;
  margin: 8px 0 16px;
  font-family: var(--display);
  font-size: 2.15rem;
  letter-spacing: -0.04em;
}
.hero-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.hero-split div {
  background: rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 12px;
}
.hero-split small {
  display: block;
  opacity: 0.85;
  font-size: 0.74rem;
  margin-bottom: 4px;
}
.hero-split b { font-size: 1.05rem; }

.quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.quick-out, .quick-in {
  min-height: 52px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 10px 22px rgba(21, 35, 31, 0.08);
}
.quick-out {
  background: #fff;
  color: var(--bad);
  border: 1px solid rgba(220, 38, 38, 0.18);
}
.quick-in {
  background: linear-gradient(160deg, #14b8a6, var(--accent-2));
  color: #fff;
}
.quick-out:active, .quick-in:active { transform: scale(0.98); }

.panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.75);
  border-radius: 20px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 10px 24px rgba(21,35,31,0.05);
  backdrop-filter: blur(8px);
}
.panel-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}
.panel-h h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.link {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
}
.pill {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
}
.pill.over { background: rgba(220,38,38,0.12); color: var(--bad); }
.pill.under { background: rgba(21,128,61,0.12); color: var(--good); }

.forecast {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.forecast div {
  background: rgba(15, 118, 110, 0.06);
  border-radius: 14px;
  padding: 12px;
}
.forecast span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.forecast b { font-size: 0.95rem; }
.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
}

.row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}
.muted { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(21,35,31,0.08);
  overflow: hidden;
  margin-top: 8px;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.row-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.tx-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
}
.tx-row:last-child { border-bottom: 0; }
.amt-in { color: var(--good); font-weight: 800; }
.amt-out { color: var(--bad); font-weight: 800; }
.empty {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 0;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 22, 0.42);
  z-index: 40;
}
.scrim[hidden] { display: none !important; }

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(110%);
  width: min(430px, 100%);
  max-height: min(92dvh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #fbfdfc;
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(18px + var(--safe-b));
  z-index: 50;
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  pointer-events: none;
  box-shadow: 0 -12px 40px rgba(21,35,31,0.18);
}
.sheet.open { transform: translateX(-50%) translateY(0); pointer-events: auto; }
.sheet[hidden] { display: block !important; }
.handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: #d5ddd9;
  margin: 4px auto 12px;
}
.sheet-title {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.sheet-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 600;
}
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.field > span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.grow { flex: 1; }
.btn-primary, .btn-danger {
  min-height: 50px;
  border-radius: 16px;
  font-weight: 800;
  padding: 0 16px;
}
.btn-primary {
  background: linear-gradient(160deg, #14b8a6, var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.28);
}
.btn-primary:disabled { opacity: 0.55; }
.btn-danger {
  color: var(--bad);
  background: rgba(220, 38, 38, 0.1);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-b));
  transform: translateX(-50%);
  background: rgba(21, 35, 31, 0.92);
  color: #fff;
  padding: 11px 14px;
  border-radius: 14px;
  z-index: 80;
  font-size: 0.86rem;
  font-weight: 700;
  max-width: calc(100% - 32px);
}
.toast[hidden] { display: none !important; }
