:root {
  --bg: #080a09;
  --bg-2: #0e1312;
  --card: #141b1a;
  --card-2: #1a2321;
  --line: rgba(196, 214, 208, 0.09);
  --text: #e8eeec;
  --muted: #8b9a95;
  --green: #4aa887;
  --green-dim: rgba(74, 168, 135, 0.16);
  --gold: #c4a36a;
  --expense: #d58b82;
  --income: #6fbfa8;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: #080a09;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(1200px 500px at 50% -80px, rgba(63, 110, 92, 0.22), transparent 60%),
    var(--bg);
}

button, input {
  font: inherit;
  color: inherit;
  color-scheme: dark;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 20px calc(108px + var(--safe-bottom));
}

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

.ghost, .month {
  background: none;
  border: 0;
  padding: 8px 12px;
}

.ghost {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 22px;
  line-height: 1;
}

.month {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px 22px 18px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(74, 168, 135, 0.12), transparent 42%),
    var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--green), transparent);
  opacity: 0.7;
}

.hero-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.16em;
}

.hero-balance {
  margin: 8px 0 18px;
  font-size: 36px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.hero-flow {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 12px;
  align-items: center;
}

.hero-flow span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.hero-flow strong {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hero-flow .divider { height: 28px; background: var(--line); }
.hero-flow div:first-child strong { color: var(--income); }
.hero-flow div:last-child strong { color: var(--expense); }

.views {
  display: flex;
  gap: 8px;
  margin: 22px 0 14px;
}

.view-tab {
  flex: 1;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.view-tab.active {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
}

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

.day-label {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.tx {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}

.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--green-dim);
  font-size: 18px;
}

.tx-body { flex: 1; min-width: 0; }
.tx-body b { display: block; font-weight: 600; }
.tx-body span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.tx-amt.expense { color: var(--expense); }
.tx-amt.income { color: var(--income); }

.empty {
  margin-top: 48px;
  text-align: center;
  color: var(--muted);
}

.empty p { margin: 8px 0 0; font-size: 13px; }

.bar-row { margin: 0 0 14px; }
.bar-row header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #0c1110;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2d6c58, var(--green));
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(22px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, #5bb392, #2f7a61);
  color: #f4fffb;
  font-size: 30px;
  box-shadow: 0 12px 28px rgba(47, 122, 97, 0.35);
  z-index: 20;
}

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 18px calc(16px + var(--safe-bottom));
  background: #101615;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  transform: translateY(110%);
  transition: transform 0.28s ease;
  z-index: 31;
}

.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: #2a3532;
  margin: 4px auto 14px;
}

.sheet-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.sheet-tab {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
}

.sheet-tab.active {
  background: var(--green-dim);
  color: var(--green);
  border-color: transparent;
}

.amount-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 0 12px;
}

.yen { color: var(--gold); font-size: 22px; }
.amount {
  font-size: 40px;
  font-weight: 650;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.cats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.cat {
  border: 0;
  background: var(--card);
  border-radius: 14px;
  padding: 8px 0;
  color: var(--muted);
}

.cat small { display: block; font-size: 11px; margin-top: 2px; }
.cat.active {
  background: var(--green-dim);
  color: var(--text);
}

.meta {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.meta label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.meta input {
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0 10px;
  font-size: 16px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.keypad button {
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--card-2);
  font-size: 20px;
}

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

.save {
  width: 100%;
  margin-top: 10px;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #5bb392, #2f7a61);
  font-weight: 650;
}

.install {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(92px + var(--safe-bottom));
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 18px;
  background: #171f1d;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 25;
}

.install img { border-radius: 10px; }
.install p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.install button {
  border: 0;
  background: none;
  font-size: 22px;
  color: var(--muted);
}

[hidden] { display: none !important; }
