:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --card: rgba(255, 255, 255, 0.94);
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #0f172a;
  --accent-soft: #eef2ff;
  --positive: #136c4a;
  --negative: #b42318;
  --shadow: 0 14px 34px rgba(16, 24, 40, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Yu Gothic UI", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(118, 134, 255, .14), transparent 33%),
    var(--bg);
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(94px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 4px 12px;
}
.topbar h1 { margin: 1px 0 0; font-size: 25px; letter-spacing: -.04em; }
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}
.icon-button, .nav-button, .close-button {
  border: 0;
  background: rgba(255,255,255,.78);
  box-shadow: 0 4px 16px rgba(16,24,40,.06);
  cursor: pointer;
}
.icon-button {
  width: 43px; height: 43px; border-radius: 50%;
  font-size: 24px; line-height: 1;
}
.summary-card, .calendar-card, .recent-card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.75);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}
.summary-card {
  padding: 21px;
  background: linear-gradient(135deg, #111827, #27364f);
  color: #fff;
}
.summary-main { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.summary-main span { opacity: .72; font-size: 13px; }
.summary-main strong { font-size: clamp(29px, 9vw, 43px); letter-spacing: -.055em; }
.summary-breakdown {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-top: 20px;
}
.summary-breakdown div {
  padding: 11px 9px; border-radius: 14px;
  background: rgba(255,255,255,.085);
}
.summary-breakdown span { display: block; opacity: .65; font-size: 11px; }
.summary-breakdown strong { display: block; margin-top: 5px; font-size: 15px; }

.calendar-card { margin-top: 14px; padding: 15px 10px 12px; }
.calendar-toolbar {
  display: grid; grid-template-columns: 46px 1fr 46px;
  align-items: center; padding: 0 4px 13px;
}
.nav-button {
  width: 38px; height: 38px; border-radius: 13px;
  font-size: 28px; background: #f8fafc;
}
.nav-button:last-child { justify-self: end; }
.month-title {
  border: 0; background: transparent; cursor: pointer;
  font-weight: 800; font-size: 19px;
}
.month-title small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 600; }

.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row {
  color: var(--muted); font-size: 11px; font-weight: 700; text-align: center;
  border-bottom: 1px solid var(--line); padding-bottom: 7px;
}
.sunday { color: #d92d20; }
.saturday { color: #175cd3; }

.day-cell {
  position: relative; min-height: 69px; padding: 7px 3px 5px;
  border: 0; border-right: 1px solid #f0f1f3; border-bottom: 1px solid #f0f1f3;
  background: transparent; text-align: center; cursor: pointer;
}
.day-cell:nth-child(7n) { border-right: 0; }
.day-cell.outside { opacity: .28; }
.day-cell.today::before {
  content: ""; position: absolute; inset: 4px;
  border: 1.5px solid #64748b; border-radius: 13px; pointer-events: none;
}
.day-number { display: block; font-size: 12px; font-weight: 700; }
.day-amount {
  display: block; min-height: 28px; margin-top: 6px;
  color: var(--ink); font-size: 11px; font-weight: 800;
  letter-spacing: -.04em; line-height: 1.2; overflow-wrap: anywhere;
}
.day-amount.zero { color: #d0d5dd; font-weight: 500; }
.day-cell.has-spending { background: linear-gradient(180deg, transparent, rgba(99,102,241,.055)); }
.day-count { display: block; color: var(--muted); font-size: 8px; margin-top: 2px; }

.recent-card { margin-top: 14px; padding: 18px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.section-heading h2 { margin: 2px 0 0; font-size: 18px; }
.text-button { border: 0; background: transparent; color: #475467; font-weight: 700; cursor: pointer; }

.transaction-list { min-height: 58px; }
.transaction-row {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 11px; align-items: center; padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.transaction-row:last-child { border-bottom: 0; }
.tx-date {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 14px; background: #f2f4f7;
  color: #475467; font-size: 11px; font-weight: 800; text-align: center;
}
.tx-main { min-width: 0; }
.tx-main strong {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px;
}
.tx-main span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.tx-amount { font-size: 14px; font-weight: 800; white-space: nowrap; }
.tx-amount.refund { color: var(--positive); }

.empty-state {
  padding: 26px 12px; text-align: center; color: var(--muted);
  font-size: 13px; line-height: 1.65;
}

.bottom-actions {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  background: rgba(243,245,248,.86); backdrop-filter: blur(18px);
  border-top: 1px solid rgba(208,213,221,.72);
}
.primary-action {
  width: min(100%, 720px); min-height: 54px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 17px; background: var(--accent); color: #fff;
  font-weight: 800; cursor: pointer; box-shadow: 0 8px 24px rgba(15,23,42,.20);
}
.action-icon { font-size: 22px; line-height: 1; }

.sheet-dialog {
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: transparent;
}
.sheet-dialog::backdrop { background: rgba(15, 23, 42, .38); backdrop-filter: blur(3px); }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 760px); max-height: 84vh; overflow: auto;
  padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0; background: #fff;
  box-shadow: 0 -24px 60px rgba(16,24,40,.22);
}
.full-sheet { min-height: 76vh; }
.menu-sheet { max-height: 88vh; }
.sheet-handle { width: 44px; height: 5px; margin: 3px auto 14px; border-radius: 5px; background: #d0d5dd; }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-header h2 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.04em; }
.close-button {
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 23px; background: #f2f4f7;
}
.detail-breakdown {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 16px 0 7px;
}
.detail-breakdown div { padding: 12px; border-radius: 15px; background: #f8fafc; }
.detail-breakdown span { display: block; color: var(--muted); font-size: 11px; }
.detail-breakdown strong { display: block; margin-top: 4px; font-size: 16px; }
.detail-list { padding-bottom: 18px; }

.filter-row { display: grid; grid-template-columns: 120px 1fr; gap: 8px; margin: 16px 0 8px; }
.filter-row select, .filter-row input, .settings-group input {
  width: 100%; min-height: 44px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 13px; background: #fff;
}

.settings-group {
  display: grid; gap: 10px; padding: 17px 0; border-bottom: 1px solid var(--line);
}
.settings-group:last-child { border-bottom: 0; }
.settings-group label { color: #344054; font-size: 13px; font-weight: 700; }
.settings-group label input { margin-top: 6px; font-weight: 400; }
.settings-group h3 { margin: 0; font-size: 15px; }
.settings-group p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.secondary-button, .danger-button {
  min-height: 46px; padding: 10px 14px; border-radius: 14px;
  font-weight: 800; cursor: pointer;
}
.secondary-button { border: 1px solid #d0d5dd; background: #fff; }
.file-label { display: grid; place-items: center; color: var(--ink) !important; font-size: 14px !important; }
.danger-button { border: 1px solid #fecdca; background: #fef3f2; color: var(--negative); }
.danger-zone { padding-bottom: 3px; }

.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 24px); width: max-content; max-width: calc(100% - 32px);
  padding: 11px 16px; border-radius: 13px; background: #101828; color: #fff;
  font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none;
  transition: .24s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) {
  .app-shell { padding-left: 20px; padding-right: 20px; }
  .day-cell { min-height: 86px; padding-top: 10px; }
  .day-number { font-size: 13px; }
  .day-amount { font-size: 13px; }
}
