:root {
  color-scheme: light;
  --ink: #16302f;
  --muted: #6a7a78;
  --line: #dce8e4;
  --surface: #ffffff;
  --page: #f4f8f6;
  --teal: #0f766e;
  --teal-dark: #0b5c56;
  --teal-soft: #dff3ed;
  --amber: #b45309;
  --amber-soft: #fff2d6;
  --danger: #c2413b;
  --danger-soft: #ffe4e1;
  --shadow: 0 14px 38px rgba(20, 63, 58, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 760px); margin: 0 auto; padding: 24px 16px 34px; }

.app-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.eyebrow, .section-kicker { margin: 0; color: var(--teal); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.11em; }
h1 { margin: 5px 0 0; font-size: clamp(1.18rem, 4.5vw, 1.55rem); letter-spacing: -0.03em; }
h2 { margin: 2px 0 0; font-size: 1.05rem; letter-spacing: -0.02em; }
.local-badge { flex: none; border: 1px solid #bfe1d7; border-radius: 999px; padding: 6px 10px; color: var(--teal-dark); background: #effaf6; font-size: 0.72rem; font-weight: 700; }

.hero-card { position: relative; overflow: hidden; border-radius: 24px; padding: 23px 22px 20px; color: #f4fffc; background: linear-gradient(135deg, #0f766e 0%, #124f4c 100%); box-shadow: var(--shadow); }
.hero-card::after { content: ""; position: absolute; width: 180px; height: 180px; right: -75px; top: -92px; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 50%; box-shadow: 0 0 0 22px rgba(255, 255, 255, 0.035), 0 0 0 45px rgba(255, 255, 255, 0.025); }
.hero-topline, .hero-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-topline p { margin: 0; color: #c9efdf; font-size: 0.88rem; font-weight: 700; }
.status-chip { border-radius: 999px; padding: 5px 9px; color: #e2faf0; background: rgba(255,255,255,0.14); font-size: 0.7rem; font-weight: 700; white-space: nowrap; }
.status-chip.warning { color: #fff7df; background: rgba(245, 158, 11, 0.24); }
.status-chip.danger { color: #ffe9e5; background: rgba(220, 65, 54, 0.32); }
.remaining-amount { margin: 12px 0 2px; font-size: clamp(2.35rem, 12vw, 4.1rem); font-weight: 850; letter-spacing: -0.07em; line-height: 1.05; }
.period-label { margin: 0 0 2px; color: #b9e5d6; font-size: 0.72rem; font-weight: 750; }
.hero-message { min-height: 1.5em; margin: 0 0 17px; color: #d7f5ec; font-size: 0.82rem; }
.progress-track { height: 9px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,0.18); }
.progress-bar { width: 0%; height: 100%; border-radius: inherit; background: #9ee7cb; transition: width 300ms ease; }
.progress-bar.warning { background: #f6ce7e; }
.progress-bar.danger { background: #ff9c8e; }
.hero-meta { margin-top: 13px; color: #c9efdf; font-size: 0.77rem; font-weight: 650; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.metric-card { border: 1px solid var(--line); border-radius: 17px; padding: 15px; background: var(--surface); box-shadow: 0 5px 18px rgba(20, 63, 58, 0.04); }
.metric-label { display: block; color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.metric-card strong { display: block; margin: 3px 0 2px; font-size: 1.42rem; letter-spacing: -0.04em; }
.metric-card small { display: block; color: var(--muted); font-size: 0.66rem; line-height: 1.35; }

.panel { margin-top: 12px; border: 1px solid var(--line); border-radius: 20px; padding: 19px 16px 17px; background: var(--surface); box-shadow: 0 5px 18px rgba(20, 63, 58, 0.035); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.text-button { border: 0; padding: 2px 0; color: var(--muted); background: transparent; font-size: 0.78rem; font-weight: 700; }
.text-button:hover { color: var(--danger); }
.section-total { align-self: center; color: var(--teal-dark); font-size: 0.8rem; font-weight: 800; }
.form-grid, .expense-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.expense-form-actions { display: flex; align-items: center; align-self: end; gap: 10px; }
.expense-form-actions .secondary-button { flex: 1; }
.expense-form-actions .text-button { flex: none; }
.expense-form-actions .text-button.hidden { display: none; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field > span { color: #4c625f; font-size: 0.76rem; font-weight: 750; }
input, select { width: 100%; min-height: 45px; border: 1px solid #cdded9; border-radius: 11px; padding: 10px 11px; color: var(--ink); background: #fbfdfc; outline: none; transition: border-color 150ms ease, box-shadow 150ms ease; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,0.13); }
input::placeholder { color: #a8b8b4; }
.input-with-unit { position: relative; }
.input-with-unit input { padding-right: 36px; }
.input-with-unit span { position: absolute; right: 11px; top: 50%; color: var(--muted); font-size: 0.78rem; transform: translateY(-50%); pointer-events: none; }
.primary-button, .secondary-button { min-height: 47px; border: 0; border-radius: 12px; color: #fff; font-weight: 800; transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease; }
.primary-button { background: var(--teal); box-shadow: 0 7px 15px rgba(15,118,110,0.19); }
.secondary-button { align-self: end; background: #e8f4f0; color: var(--teal-dark); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.primary-button:hover { background: var(--teal-dark); }
.secondary-button:hover { background: #d8eee7; }
.helper-text { margin: 12px 0 0; color: var(--muted); font-size: 0.71rem; }
.fixed-costs-block { margin-top: 19px; border-top: 1px solid var(--line); padding-top: 17px; }
.subsection-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.subsection-kicker { margin: 0; color: var(--teal); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; }
h3 { margin: 2px 0 0; font-size: 0.92rem; letter-spacing: -0.02em; }
.fixed-cost-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fixed-cost-form-actions { display: flex; align-items: center; gap: 12px; }
.fixed-cost-form-actions .secondary-button { flex: 1; }
.fixed-cost-form-actions .text-button { flex: none; }
.fixed-cost-form-actions .text-button.hidden { display: none; }
.fixed-cost-list { margin-top: 13px; }
.history-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid #e4eeeb; border-radius: 13px; padding: 11px 12px; background: #fbfdfc; }
.history-month { display: block; font-size: 0.82rem; font-weight: 800; }
.history-count { display: block; margin-top: 2px; color: var(--muted); font-size: 0.69rem; }
.history-amount { color: var(--teal-dark); font-size: 0.86rem; font-weight: 850; white-space: nowrap; }
.backup-description { margin: -6px 0 13px; }
.backup-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.backup-actions .outline-button { grid-column: 1 / -1; }
.outline-button { min-height: 47px; border: 1px solid #b6d6cd; border-radius: 12px; color: var(--teal-dark); background: #fff; font-weight: 800; }
.outline-button:hover { background: #eff9f5; }

.empty-state { margin-top: 15px; border-radius: 12px; padding: 13px; color: var(--muted); background: #f5f9f7; font-size: 0.77rem; }
.empty-state.hidden { display: none; }
.expense-list { display: grid; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.expense-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #edf3f1; padding: 3px 0 10px; }
.expense-item:last-child { border-bottom: 0; padding-bottom: 0; }
.expense-info { min-width: 0; }
.expense-category { display: block; font-size: 0.82rem; font-weight: 750; }
.expense-date { display: block; color: var(--muted); font-size: 0.68rem; }
.expense-right { display: flex; align-items: center; gap: 9px; }
.item-actions { display: flex; align-items: center; gap: 6px; }
.expense-amount { font-size: 0.84rem; font-weight: 800; white-space: nowrap; }
.edit-button { border: 0; border-radius: 7px; padding: 4px 7px; color: var(--teal-dark); background: #e7f4f0; font-size: 0.68rem; }
.edit-button:hover { background: #d5eee6; }
.delete-button { border: 0; border-radius: 7px; padding: 4px 7px; color: var(--muted); background: #f1f5f3; font-size: 0.68rem; }
.delete-button:hover { color: var(--danger); background: var(--danger-soft); }

.tip-card { display: flex; align-items: flex-start; gap: 11px; margin-top: 12px; border-radius: 17px; padding: 15px; color: #46645d; background: var(--teal-soft); }
.tip-icon { display: grid; flex: none; width: 21px; height: 21px; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); font-size: 0.73rem; font-weight: 850; }
.tip-card strong { display: block; margin-bottom: 2px; font-size: 0.8rem; }
.tip-card p { margin: 0; font-size: 0.74rem; line-height: 1.45; }
.app-footer { padding: 20px 4px 0; text-align: center; }
.app-footer p { margin: 0; color: var(--muted); font-size: 0.68rem; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 10; max-width: calc(100% - 32px); border-radius: 999px; padding: 10px 15px; color: #fff; background: #173c38; box-shadow: var(--shadow); font-size: 0.77rem; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity 160ms ease, transform 160ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .app-shell { padding-top: 38px; }
  .panel { padding: 21px 20px 19px; }
  .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .form-grid .field-wide { grid-column: span 2; }
  .form-grid .primary-button { grid-column: 1 / -1; }
  .expense-form { grid-template-columns: 1.1fr 1fr 1fr; align-items: end; }
  .expense-form .field-wide { grid-column: auto; }
  .expense-form-actions { grid-column: auto; }
  .fixed-cost-form { grid-template-columns: 1.45fr 1fr auto; align-items: end; }
  .fixed-cost-form .field-wide { grid-column: auto; }
  .fixed-cost-form-actions { grid-column: auto; }
  .backup-actions .outline-button { grid-column: auto; }
}
