:root {
  --theme-main: #2563EB;
  --theme-light: #EFF6FF;
  --theme-dark: #1E40AF;

  --gray-selected: #6B7280;
  --warn-red: #DC2626;
  --warn-yellow: #D97706;
  --success-green: #22C55E;

  --card-bg: #FFFFFF;
  --text-main: #111827;
  --text-sub: #6B7280;
  --border: rgba(0, 0, 0, 0.08);

  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-input: 8px;
}

[data-user="yuichi"] {
  --theme-main: #2563EB;
  --theme-light: #EFF6FF;
  --theme-dark: #1E40AF;
}

[data-user="izumi"] {
  --theme-main: #EC4899;
  --theme-light: #FDF2F8;
  --theme-dark: #BE185D;
}

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

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--theme-light);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background 0.25s;
}

/* ===== User Tabs ===== */
.user-tabs {
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--card-bg);
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.user-tab {
  flex: 1;
  padding: 14px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: var(--text-sub);
  transition: color 0.2s, border-color 0.2s;
}

.user-tab.active {
  color: var(--theme-main);
  border-bottom-color: var(--theme-main);
  font-weight: 700;
}

/* ===== Layout ===== */
.main-content {
  width: 100%;
  max-width: 480px;
  flex: 1;
  overflow: hidden;
  padding-bottom: 70px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-scroll {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 16px;
  border: 0.5px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* ===== Usage Badge ===== */
.usage-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  background: var(--theme-light);
  color: var(--theme-main);
  border: 0.5px solid var(--theme-main);
  align-self: flex-start;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.usage-badge.warn-yellow {
  background: #FFFBEB;
  color: var(--warn-yellow);
  border-color: var(--warn-yellow);
}

.usage-badge.warn-red {
  background: #FEF2F2;
  color: var(--warn-red);
  border-color: var(--warn-red);
}

/* ===== Garden ===== */
.garden-container {
  width: 100%;
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 0.5px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

#garden-svg {
  width: 100%;
  display: block;
}

/* ===== Balance Card ===== */
.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.balance-label {
  font-size: 14px;
  color: var(--text-sub);
}

.balance-value {
  font-size: 16px;
  font-weight: 500;
}

.divider {
  height: 0.5px;
  background: var(--border);
  margin: 6px 0;
}

.remaining-row {
  align-items: flex-start;
  padding-top: 8px;
}

.remaining-amount {
  font-size: 30px;
  font-weight: 700;
  color: var(--theme-main);
  text-align: right;
  transition: color 0.2s;
}

.remaining-amount.warn-yellow { color: var(--warn-yellow); }
.remaining-amount.warn-red    { color: var(--warn-red); }

.remaining-pct {
  font-size: 13px;
  color: var(--text-sub);
  text-align: right;
  margin-top: 2px;
}

/* ===== Section Header ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
}

.link-btn {
  background: none;
  border: none;
  color: var(--theme-main);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

/* ===== Expense List ===== */
.expense-list {
  display: flex;
  flex-direction: column;
}

.expense-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 0.5px solid var(--border);
}

.expense-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.expense-item:first-child {
  padding-top: 0;
}

.expense-date {
  font-size: 13px;
  color: var(--text-sub);
  min-width: 34px;
  flex-shrink: 0;
}

.expense-memo {
  flex: 1;
  font-size: 14px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.expense-amount {
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  flex-shrink: 0;
}

.tag {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

[data-user="yuichi"] .tag-cash   { background: #EFF6FF; color: #1E40AF; }
[data-user="yuichi"] .tag-credit { background: #DBEAFE; color: #1D4ED8; }
[data-user="izumi"]  .tag-cash   { background: #FDF2F8; color: #BE185D; }
[data-user="izumi"]  .tag-credit { background: #FCE7F3; color: #9D174D; }

.empty-msg {
  text-align: center;
  color: var(--text-sub);
  font-size: 14px;
  padding: 20px 0;
}

/* ===== Form ===== */
.form-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 18px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: 7px;
}

.form-input {
  width: 100%;
  padding: 11px 12px;
  border: 0.5px solid #D1D5DB;
  border-radius: var(--radius-input);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  background: #FAFAFA;
  color: var(--text-main);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--theme-main);
  background: #fff;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.amount-input-wrap {
  display: flex;
  align-items: center;
  border: 0.5px solid #D1D5DB;
  border-radius: var(--radius-input);
  background: #FAFAFA;
  transition: border-color 0.2s, background 0.2s;
}

.amount-input-wrap:focus-within {
  border-color: var(--theme-main);
  background: #fff;
}

.amount-prefix {
  padding: 0 4px 0 12px;
  font-size: 16px;
  color: var(--text-sub);
  flex-shrink: 0;
}

.amount-input {
  border: none;
  background: transparent;
  padding: 11px 12px 11px 4px;
  flex: 1;
  min-width: 0;
}

.amount-input:focus {
  border: none;
  background: transparent;
}

/* ===== Payment Toggle ===== */
.pay-toggle {
  display: flex;
  gap: 10px;
}

.pay-btn {
  flex: 1;
  padding: 11px;
  border: 0.5px solid #D1D5DB;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: #fff;
  color: var(--text-sub);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pay-btn.selected {
  background: var(--gray-selected);
  color: #fff;
  border-color: var(--gray-selected);
}

/* ===== Buttons ===== */
.btn {
  cursor: pointer;
  font-family: inherit;
  border-radius: var(--radius-btn);
  font-weight: 500;
  transition: transform 0.1s, opacity 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

.submit-btn {
  width: 100%;
  padding: 14px;
  background: var(--theme-main);
  color: #fff;
  border: none;
  font-size: 16px;
  transition: background 0.2s, transform 0.1s;
}

.outline-btn {
  width: 100%;
  padding: 12px;
  background: #fff;
  color: var(--theme-main);
  border: 0.5px solid var(--theme-main);
  font-size: 14px;
}

.saved-msg {
  text-align: center;
  color: var(--success-green);
  font-size: 14px;
  margin-top: 12px;
  font-weight: 500;
}

.hidden {
  display: none !important;
}

/* ===== History ===== */
.history-header {
  margin-bottom: 12px;
}

.month-select {
  width: 100%;
  padding: 11px 12px;
  border: 0.5px solid #D1D5DB;
  border-radius: var(--radius-input);
  font-size: 15px;
  font-family: inherit;
  background: #FAFAFA;
  color: var(--text-main);
  outline: none;
  margin-bottom: 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.history-summary {
  font-size: 14px;
  color: var(--text-sub);
}

.history-summary strong {
  color: var(--text-main);
  font-weight: 700;
}

.delete-btn {
  background: none;
  border: 0.5px solid #E5E7EB;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--warn-red);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.15s;
}

.delete-btn:active {
  background: #FEF2F2;
  transform: scale(0.97);
}

/* ===== Bottom Navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--card-bg);
  border-top: 0.5px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.nav-btn {
  flex: 1;
  padding: 10px 4px 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-sub);
  transition: color 0.15s;
}

.nav-btn.active {
  color: var(--theme-main);
}

.nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-plus {
  font-size: 22px;
  font-weight: 300;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-card);
  padding: 22px 20px 20px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal-body {
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 22px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 12px;
  font-size: 14px;
  border: none;
}

.modal-btn-cancel {
  background: #F3F4F6;
  color: var(--text-main);
}

.modal-btn-ok {
  background: var(--theme-main);
  color: #fff;
  transition: background 0.2s;
}

/* ===== Responsive ===== */
@media (min-width: 480px) {
  body {
    background: #E5E7EB;
    padding: 20px 0;
  }

  .user-tabs {
    border-radius: 16px 16px 0 0;
    overflow: hidden;
  }

  .bottom-nav {
    border-radius: 0 0 16px 16px;
    overflow: hidden;
  }

  .main-content {
    border-left: 0.5px solid var(--border);
    border-right: 0.5px solid var(--border);
  }
}
