/* =========================================================
   Kakeibo — 爽やかライトデザイン（Light-Only Refreshing UI）
   ========================================================= */

/* ---------- テーマトークン（ライト専用・爽やかなミント＆スカイパレット） ---------- */
:root {
  color-scheme: light;

  --bg:          #f3f9fa;
  --bg-soft:     #e8f4f6;
  --card:        #ffffff;
  --card-2:      #f4f9fb;
  --card-3:      #e6f1f5;
  --line:        #cfe2ea;
  --line-soft:   #e1eef3;

  --txt:         #0f2937;
  --txt-2:       #486578;
  --txt-3:       #7894a7;

  --accent:      #0d9488;
  --accent-sky:  #0ea5e9;
  --accent-ink:  #ffffff;
  --accent-soft: rgba(13, 148, 136, 0.11);
  --blue:        #0284c7;
  --blue-soft:   rgba(2, 132, 199, 0.11);
  --warn:        #d97706;
  --warn-soft:   #fef3c7;
  --danger:      #e11d48;
  --danger-soft: #ffe4e6;

  --radius:      20px;
  --radius-sm:   13px;
  --shadow:      0 16px 42px rgba(15, 55, 85, 0.11);
  --shadow-sm:   0 4px 18px rgba(15, 55, 85, 0.055);

  --sidebar-w:   252px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro JP", "Hiragino Sans",
          "Noto Sans JP", "Yu Gothic UI", "Segoe UI", system-ui, sans-serif;
}

/* ---------- リセット＆ベース ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(16, 185, 129, 0.09), transparent 70%),
    radial-gradient(900px 480px at 100% 0%, rgba(14, 165, 233, 0.10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
kbd {
  font-family: var(--font); font-size: 10px; font-weight: 700;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; color: var(--txt-2);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--txt-3); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* =========================================================
   レイアウト
   ========================================================= */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line-soft);
  padding: 24px 16px 18px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100dvh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--line-2);
  color: var(--accent); display: grid; place-items: center;
  font-weight: 800; font-size: 19px;
  padding: 3px;
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.16);
  overflow: hidden;
  flex-shrink: 0;
}
.brand-mark img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.topbar-logo {
  width: 32px; height: 32px; border-radius: 10px;
  background: #ffffff;
  border: 1px solid var(--line-2);
  padding: 2px;
  box-shadow: 0 3px 10px rgba(13, 148, 136, 0.14);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topbar-logo img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15.5px; letter-spacing: .01em; color: var(--txt); }
.brand-text span { font-size: 11px; color: var(--txt-3); font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: 12px;
  color: var(--txt-2); font-size: 13.5px; font-weight: 600;
  transition: background .15s, color .15s, box-shadow .15s;
  text-align: left; width: 100%;
}
.nav-item .ni-ico { font-size: 16px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--card-2); color: var(--txt); }
.nav-item.is-active {
  background: linear-gradient(90deg, var(--accent-soft), rgba(14, 165, 233, 0.08));
  color: var(--accent);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.22);
}

.btn-add-side {
  margin-top: auto;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-sky));
  color: #ffffff;
  padding: 13px 16px; border-radius: 14px;
  font-weight: 800; font-size: 14px;
  box-shadow: 0 8px 22px rgba(13, 148, 136, 0.25);
  transition: transform .12s, box-shadow .15s, filter .15s;
}
.btn-add-side:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(13, 148, 136, 0.32); filter: brightness(1.03); }
.btn-add-side .plus { font-size: 17px; }
.btn-add-side kbd { margin-left: auto; background: rgba(255,255,255,.22); color: #fff; border-color: transparent; }

.side-foot { padding: 0 4px; }
.side-tip {
  font-size: 11.5px; color: var(--txt-3); line-height: 1.55;
  border-top: 1px solid var(--line-soft); padding-top: 12px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px 12px;
  background: rgba(243, 249, 250, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(207, 226, 234, 0.5);
}
.topbar-title { font-size: 19px; font-weight: 800; letter-spacing: .01em; color: var(--txt); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 15px;
  color: var(--txt-2); background: var(--card-2); border: 1px solid var(--line-soft);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--card-3); color: var(--txt); }

.view-wrap { flex: 1; padding: 18px 28px 60px; max-width: 1040px; width: 100%; margin: 0 auto; }
.view { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; animation: fadeUp .32s cubic-bezier(.2,.7,.3,1); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabbar { display: none; }

/* =========================================================
   共通パーツ
   ========================================================= */
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { font-size: 14.5px; font-weight: 800; letter-spacing: .01em; color: var(--txt); }
.card-head .sub { font-size: 11.5px; color: var(--txt-3); font-weight: 600; }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

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

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--card-3); color: var(--txt-2);
}
.pill.good { background: #d1fae5; color: #047857; }
.pill.warn { background: var(--warn-soft); color: #b45309; }
.pill.bad  { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: #e0f2fe; color: #0369a1; }

.btn {
  padding: 9px 16px; border-radius: 12px; font-weight: 700; font-size: 13px;
  background: var(--card); color: var(--txt); border: 1px solid var(--line);
  box-shadow: 0 2px 6px rgba(15, 55, 85, 0.04);
  transition: background .15s, transform .1s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--card-2); border-color: var(--txt-3); }
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-sky));
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.22);
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 8px 20px rgba(13, 148, 136, 0.3); }
.btn.ghost { background: #ffffff; color: var(--danger); border-color: #fecdd3; }
.btn.ghost:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { padding: 6px 12px; font-size: 12px; border-radius: 10px; }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--txt-3);
  background: var(--card-2); border-radius: 16px; border: 1px dashed var(--line);
}
.empty-state .em { font-size: 34px; display: block; margin-bottom: 8px; }
.empty-state p { font-size: 13px; color: var(--txt-2); }

/* =========================================================
   ホーム — ヒーロー（爽やかなミント＆スカイグラデーション）
   ========================================================= */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(110% 130% at 95% 0%, rgba(14, 165, 233, 0.14), transparent 58%),
    radial-gradient(110% 120% at 0% 100%, rgba(16, 185, 129, 0.14), transparent 58%),
    linear-gradient(135deg, #ffffff 0%, #f2fcf9 55%, #f0f9ff 100%);
  border: 1px solid #bce8e0;
  border-radius: 24px;
  padding: 24px 26px;
  box-shadow: 0 12px 32px rgba(13, 148, 136, 0.08);
}
.hero-top { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.hero-main { flex: 1; min-width: 230px; }
.hero-label { font-size: 12.5px; color: var(--txt-2); font-weight: 700; letter-spacing: .03em; }
.hero-amount {
  display: flex; align-items: baseline; gap: 3px; margin: 6px 0 4px;
}
.hero-amount .cur { font-size: 24px; font-weight: 700; color: var(--txt-2); }
.hero-amount .val { font-size: clamp(36px, 6.5vw, 50px); font-weight: 850; letter-spacing: -.03em; line-height: 1.08; color: var(--txt); }
.hero-amount .val.over { color: var(--danger); }
.hero-note { font-size: 13px; color: var(--txt-2); }
.hero-note b { color: var(--txt); }

.hero-ring { position: relative; width: 140px; height: 140px; flex: 0 0 auto; background: rgba(255,255,255,0.75); border-radius: 50%; padding: 4px; box-shadow: 0 4px 16px rgba(13,148,136,0.08); }
.hero-ring svg { width: 100%; height: 100%; }
.hero-ring-in {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.hero-ring-in .rv { font-size: 20px; font-weight: 800; letter-spacing: -.02em; color: var(--txt); }
.hero-ring-in .rl { font-size: 10.5px; color: var(--txt-3); font-weight: 700; }

.hero-bar { margin-top: 18px; }
.hero-bar-track {
  height: 10px; border-radius: 999px; background: #dceef2; overflow: hidden; position: relative;
}
.hero-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-sky));
  transition: width .6s cubic-bezier(.2,.8,.25,1);
}
.hero-bar-fill.warn { background: linear-gradient(90deg, #f59e0b, #ea580c); }
.hero-bar-fill.bad  { background: linear-gradient(90deg, #e11d48, #f43f5e); }
.hero-bar-marker {
  position: absolute; top: -3px; width: 2px; height: 16px;
  background: var(--txt); opacity: .75; border-radius: 2px;
}
.hero-bar-meta {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-size: 12px; color: var(--txt-2);
}
.hero-bar-meta b { color: var(--txt); }

.hero-msg {
  margin-top: 16px; padding: 12px 15px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.85); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--txt-2); display: flex; gap: 9px; align-items: flex-start;
}
.hero-msg .hm-ico { font-size: 15px; line-height: 1.35; }
.hero-msg b { color: var(--txt); }
.hero-msg.good { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.hero-msg.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.hero-msg.bad  { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.hero-msg.good b, .hero-msg.warn b, .hero-msg.bad b { color: inherit; }

/* ---------- 統計タイル ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 11.5px; color: var(--txt-2); font-weight: 700; display: flex; align-items: center; gap: 5px; }
.stat-value { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; color: var(--txt); }
.stat-sub { font-size: 11px; color: var(--txt-3); margin-top: 2px; }
.stat-value.pos { color: var(--accent); }
.stat-value.neg { color: var(--danger); }

/* ---------- クイック記録 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 9px; }
.quick-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2); border: 1px solid var(--line-soft);
  border-radius: 13px; padding: 10px 12px; text-align: left;
  transition: transform .12s, border-color .15s, background .15s;
}
.quick-card:hover { transform: translateY(-2px); border-color: var(--accent); background: #ffffff; }
.quick-card:active { transform: scale(.97); }
.quick-card .qc-ico { font-size: 19px; }
.quick-card .qc-body { min-width: 0; }
.quick-card .qc-label { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-card .qc-amt { font-size: 11.5px; color: var(--txt-2); }

/* ---------- 取引リスト ---------- */
.tx-day { margin-bottom: 10px; background: var(--card); border: 1px solid var(--line-soft); border-radius: 18px; padding: 6px 12px 10px; box-shadow: var(--shadow-sm); }
.tx-day-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 6px 8px; border-bottom: 1px solid var(--line-soft);
}
.tx-day-head .d { font-size: 12.5px; font-weight: 800; color: var(--txt); }
.tx-day-head .t { margin-left: auto; font-size: 12.5px; color: var(--accent); font-weight: 800; }

.tx-list { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.tx {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 13px;
  transition: background .13s;
  cursor: pointer; text-align: left; width: 100%;
}
.tx:hover { background: var(--card-2); }
.tx-ico {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px;
  display: grid; place-items: center; font-size: 18px;
}
.tx-body { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 700; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11.5px; color: var(--txt-3); display: flex; gap: 6px; align-items: center; }
.tx-meta .dot { opacity: .5; }
.tx-amt { font-size: 15px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; color: var(--txt); }
.tx-amt.income { color: var(--accent); }

/* ---------- カテゴリ内訳 ---------- */
.cat-list { display: flex; flex-direction: column; gap: 4px; }
.cat-row { display: flex; align-items: center; gap: 11px; padding: 8px 4px; }
.cat-row .cr-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; flex: 0 0 32px; }
.cat-row .cr-body { flex: 1; min-width: 0; }
.cat-row .cr-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.cat-row .cr-name { font-size: 13px; font-weight: 700; color: var(--txt); }
.cat-row .cr-amt { font-size: 13px; font-weight: 800; letter-spacing: -.02em; color: var(--txt); }
.cat-row .cr-track { height: 6px; border-radius: 999px; background: var(--card-3); margin-top: 5px; overflow: hidden; }
.cat-row .cr-fill { height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.25,1); }
.cat-row .cr-pct { font-size: 11px; color: var(--txt-3); margin-top: 3px; display: flex; justify-content: space-between; }

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 190px; height: 190px; flex: 0 0 auto; }
.donut-seg { animation: dash .7s cubic-bezier(.2,.8,.25,1) both; }
@keyframes dash { from { opacity: 0; } to { opacity: 1; } }
.donut-label { fill: var(--txt-3); font-size: 10px; font-weight: 700; font-family: var(--font); }
.donut-value { fill: var(--txt); font-size: 19px; font-weight: 800; font-family: var(--font); letter-spacing: -.02em; }
.donut-sub   { fill: var(--txt-3); font-size: 9.5px; font-weight: 600; font-family: var(--font); }
.donut-legend { flex: 1; min-width: 190px; }

/* ---------- チャート ---------- */
.daily-bars { width: 100%; height: 52px; display: block; }
.daily-bars .bar { fill: var(--accent); opacity: .85; }
.daily-bars .bar.weekend { fill: var(--blue); opacity: .8; }
.daily-bars .bar.today { fill: var(--warn); opacity: 1; }
.daily-bars .bar.empty { fill: var(--line); opacity: .9; }
.cum-chart { width: 100%; height: 110px; display: block; }
.ideal-line { stroke: var(--txt-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: .5; vector-effect: non-scaling-stroke; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--txt-3); margin-top: 8px; flex-wrap: wrap; }
.chart-legend i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.ring-fg { transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.25,1); }

/* ---------- リスト行 ---------- */
.rec-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 13px; border-radius: 14px; width: 100%; text-align: left;
  border-bottom: 1px solid var(--line-soft);
  transition: background .13s;
}
.rec-row:last-child { border-bottom: 0; }
.rec-row:hover { background: var(--card-2); }
.rec-ico { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; }
.rec-body { flex: 1; min-width: 0; }
.rec-name { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; color: var(--txt); }
.rec-meta { font-size: 11.5px; color: var(--txt-3); }
.rec-amt { text-align: right; }
.rec-amt .a { font-size: 14px; font-weight: 800; letter-spacing: -.02em; }
.rec-amt .y { font-size: 10.5px; color: var(--txt-3); }
.rec-row.paid .rec-ico { opacity: .55; }
.rec-row.inactive { opacity: .5; }

/* ---------- 履歴フィルタ ---------- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.search-input {
  flex: 1; min-width: 160px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 13px; font-size: 13px; outline: none;
  box-shadow: 0 2px 6px rgba(15, 55, 85, 0.03);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select-mini {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 12px; font-size: 12.5px; font-weight: 600; outline: none; cursor: pointer;
  box-shadow: 0 2px 6px rgba(15, 55, 85, 0.03);
}

.period-nav {
  display: flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px;
  box-shadow: 0 2px 6px rgba(15, 55, 85, 0.03);
}
.period-nav button { width: 30px; height: 30px; border-radius: 9px; color: var(--txt-2); display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.period-nav button:hover:not(:disabled) { background: var(--card-3); color: var(--accent); }
.period-nav button:disabled { opacity: .3; cursor: default; }
.period-nav .pl { font-size: 13.5px; font-weight: 800; padding: 0 10px; min-width: 96px; text-align: center; color: var(--txt); }

/* =========================================================
   設定
   ========================================================= */
.set-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 4px; border-bottom: 1px solid var(--line-soft);
}
.set-row:last-child { border-bottom: 0; }
.set-row .sr-body { flex: 1; min-width: 200px; }
.set-row .sr-title { font-size: 14px; font-weight: 700; color: var(--txt); }
.set-row .sr-desc { font-size: 12px; color: var(--txt-2); margin-top: 2px; }
.set-row .sr-ctrl { flex: 0 0 auto; }
.num-input {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; width: 140px; text-align: right;
  font-size: 14px; font-weight: 700; outline: none; font-variant-numeric: tabular-nums;
  transition: border-color .15s, background .15s;
}
.num-input:focus { border-color: var(--accent); background: #ffffff; }

/* =========================================================
   支出入力シート（モーダル）— 明るく清潔なカード設計
   ========================================================= */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 45, 70, 0.32);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}
.sheet-backdrop[hidden] { display: none; }
[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  width: 100%; max-width: 440px; max-height: calc(100dvh - 40px);
  background: #ffffff; border: 1px solid var(--line);
  border-radius: 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  animation: sheetIn .26s cubic-bezier(.2,.8,.25,1);
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(18px) scale(.98) } to { opacity: 1; transform: none } }
.sheet-grab { display: none; }

.sheet-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 18px 10px;
  background: linear-gradient(180deg, #f2fbf9 0%, #ffffff 100%);
  border-bottom: 1px solid var(--line-soft);
}
.sheet-head strong { font-size: 15px; font-weight: 800; color: var(--txt); }
.sheet-head .icon-btn { margin-left: auto; }

.amount-display {
  display: flex; align-items: baseline; justify-content: center; gap: 4px;
  padding: 12px 16px 2px;
}
.amount-display .cur { font-size: 22px; font-weight: 700; color: var(--accent); }
.amount-display .amount {
  font-size: 44px; font-weight: 850; letter-spacing: -.035em;
  font-variant-numeric: tabular-nums; line-height: 1.1; color: var(--txt);
}
.amount-hint { text-align: center; font-size: 11.5px; color: var(--txt-2); min-height: 18px; font-weight: 600; }

.quick-row {
  display: flex; gap: 6px; padding: 8px 16px 6px; overflow-x: auto;
  scrollbar-width: none;
}
.quick-row::-webkit-scrollbar { display: none; }
.quick-chip {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px;
  background: #ecf8f6; border: 1px solid #bce8e0;
  font-size: 12px; font-weight: 700; color: var(--accent); white-space: nowrap;
  transition: background .15s, transform .1s;
}
.quick-chip:hover { background: #d5f3ee; }
.quick-chip:active { transform: scale(.95); }

.sheet-scroll { overflow-y: auto; padding: 10px 16px 6px; flex: 1; min-height: 0; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-label { display: block; font-size: 11.5px; font-weight: 700; color: var(--txt-2); margin-bottom: 7px; letter-spacing: .02em; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 7px; }
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px; border-radius: 13px;
  background: var(--card-2); border: 1.5px solid var(--line-soft);
  font-size: 11px; font-weight: 700; color: var(--txt-2);
  transition: background .13s, border-color .13s, color .13s, transform .1s;
}
.cat-btn .ci { font-size: 20px; line-height: 1.2; }
.cat-btn:hover { background: var(--card-3); }
.cat-btn:active { transform: scale(.95); }
.cat-btn.is-active { color: var(--txt); background: #ffffff; box-shadow: 0 3px 10px rgba(15, 55, 85, 0.06); }

.date-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 10px; background: var(--card-2);
  border: 1.5px solid var(--line-soft); font-size: 12px; font-weight: 700; color: var(--txt-2);
  transition: background .13s, border-color .13s, color .13s;
}
.chip:hover { background: var(--card-3); }
.chip.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.date-input, .text-input {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: 13.5px; outline: none;
  color-scheme: light;
  transition: border-color .15s, background .15s; width: 100%;
}
.date-input { width: auto; flex: 1; min-width: 130px; }
.text-input:focus, .date-input:focus { border-color: var(--accent); background: #ffffff; }
select.text-input { cursor: pointer; }

.link-btn {
  margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--accent);
  padding: 4px 0; transition: opacity .15s;
}
.link-btn:hover { opacity: .8; }

.keypad {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px;
  padding: 12px 16px 16px; border-top: 1px solid var(--line-soft);
  background: #f8fcfd;
}
.keypad button {
  height: 46px; border-radius: 13px; font-size: 19px; font-weight: 700;
  background: #ffffff; border: 1px solid var(--line-soft);
  box-shadow: 0 2px 4px rgba(15, 55, 85, 0.04);
  transition: background .1s, transform .08s;
  font-variant-numeric: tabular-nums; color: var(--txt);
}
.keypad button:hover { background: var(--card-2); border-color: var(--line); }
.keypad button:active { transform: scale(.95); background: var(--card-3); }
.keypad .k-fn { font-size: 15px; color: var(--txt-2); background: var(--card-2); }
.keypad .k-hidden { visibility: hidden; pointer-events: none; }
.keypad .k-ok {
  grid-column: 4; grid-row: 4;
  background: linear-gradient(135deg, var(--accent), var(--accent-sky));
  color: #ffffff; border-color: transparent; font-size: 14.5px; font-weight: 800;
  box-shadow: 0 6px 14px rgba(13, 148, 136, 0.25);
}
.keypad .k-ok:hover { filter: brightness(1.05); }

.sheet-delete {
  padding: 12px; font-size: 12.5px; font-weight: 700; color: var(--danger);
  border-top: 1px solid var(--line-soft); background: #ffffff;
}
.sheet-delete:hover { background: var(--danger-soft); }

.switch {
  appearance: none; width: 44px; height: 26px; border-radius: 999px;
  background: #cbd5e1; position: relative; cursor: pointer; transition: background .2s;
  flex: 0 0 44px;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #ffffff; box-shadow: 0 2px 4px rgba(0,0,0,0.18);
  transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #ffffff; border: 1.5px solid var(--line);
  color: var(--txt); padding: 12px 20px; border-radius: 16px;
  font-size: 13px; font-weight: 700; box-shadow: var(--shadow);
  z-index: 200; animation: toastIn .25s cubic-bezier(.2,.8,.25,1);
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px) } to { opacity: 1; transform: translate(-50%, 0) } }
.toast.ok { border-color: var(--accent); background: #f0fdfa; }
.toast.warn { border-color: var(--warn); background: #fffbeb; }
.toast.err { border-color: var(--danger); background: #fff1f2; }

/* =========================================================
   モバイル版 ホーム画面ウィジェットシミュレータ (§8)
   ========================================================= */
.widget-sim-card {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  border: 1px solid #c8e6e2;
  border-radius: var(--radius);
  padding: 15px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.widget-sim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.ios-widget-frame {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #99f6e4;
  border-radius: 22px;
  padding: 13px 15px;
  max-width: 340px;
  margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(13, 148, 136, 0.08);
}

.ios-widget-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.widget-plus-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-sky));
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(13, 148, 136, 0.24);
  transition: transform .1s, filter .15s;
}
.widget-plus-btn:hover { filter: brightness(1.06); }
.widget-plus-btn:active { transform: scale(.94); }

.widget-preset-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.widget-preset-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  padding: 7px 11px;
  text-align: left;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}

.widget-preset-btn:hover {
  background: #ccfbf1;
  border-color: var(--accent);
}

.widget-preset-btn:active {
  transform: scale(0.98);
}

.widget-preset-btn.invalid {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff1f2;
}

.wp-top {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--txt);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wp-amt {
  font-size: 12.5px;
  color: #0f766e;
  font-weight: 800;
}

/* =========================================================
   旧Webアプリ互換用（ログインカード等）
   ========================================================= */
.auth-backdrop {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px; background: #ffffff; border: 1px solid var(--line);
  border-radius: 24px; padding: 28px 26px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-tabs { display: flex; background: var(--card-2); border-radius: 11px; padding: 3px; gap: 2px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; padding: 8px 0; border-radius: 9px; font-size: 12.5px; font-weight: 700; color: var(--txt-3); }
.auth-tabs button.is-active { background: #ffffff; color: var(--txt); box-shadow: var(--shadow-sm); }

/* =========================================================
   レスポンシブ
   ========================================================= */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .sidebar { display: none; }
  .topbar { padding: 14px 16px 10px; }
  .view-wrap { padding: 12px 14px calc(96px + env(safe-area-inset-bottom)); }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line-soft);
    box-shadow: 0 -4px 20px rgba(15, 55, 85, 0.06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 5px 0; color: var(--txt-3); transition: color .15s;
  }
  .tab span { font-size: 18px; line-height: 1.1; }
  .tab i { font-size: 10px; font-style: normal; font-weight: 700; }
  .tab.is-active { color: var(--accent); }
  .tab-add { position: relative; }
  .tab-add .fab {
    position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
    width: 52px; height: 52px; border-radius: 18px;
    background: linear-gradient(135deg, var(--accent), var(--accent-sky));
    color: #ffffff; font-size: 26px; font-weight: 400;
    display: grid; place-items: center;
    box-shadow: 0 8px 22px rgba(13, 148, 136, 0.32);
    transition: transform .13s;
  }
  .tab-add:active .fab { transform: translateX(-50%) scale(.92); }

  .sheet-backdrop { padding: 0; align-items: flex-end; }
  .sheet {
    max-width: 100%; max-height: 94dvh;
    border-radius: 26px 26px 0 0; border-bottom: 0;
    animation: sheetUp .28s cubic-bezier(.2,.8,.25,1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes sheetUp { from { transform: translateY(100%) } to { transform: none } }
  .sheet-grab {
    display: block; width: 40px; height: 4px; border-radius: 999px;
    background: var(--line); margin: 9px auto 0;
  }
  .amount-display .amount { font-size: 38px; }
  .hero { padding: 18px 16px; border-radius: 20px; }
  .hero-ring { width: 118px; height: 118px; }
  .card { padding: 16px; }
}

@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-value { font-size: 18px; }
  .keypad button { height: 42px; }
}

/* =========================================================
   カスタム平面アイコン (MoNEYYY Flat SVG Icons)
   ========================================================= */
.flat-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.16em;
  flex-shrink: 0;
  line-height: 1;
}
.flat-ico svg {
  width: 100%;
  height: 100%;
  display: block;
}
.ni-ico .flat-ico,
.tab .flat-ico {
  color: currentColor;
}
.icon-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.icon-pick-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--txt-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .14s;
}
.icon-pick-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-soft);
}
.icon-pick-btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.14);
}

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