/* css/style.css */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
  font-size: 16px;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.top-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.hero-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 28px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.app-icon {
  font-size: 48px;
}

.hero-card h1 {
  margin: 12px 0;
  font-size: 32px;
}

.hero-card p {
  color: var(--muted);
  line-height: 1.7;
}

.primary-btn,
.secondary-btn,
.icon-btn,
.month-btn,
.setting-item {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
}

.primary-btn {
  background: var(--primary);
  color: white;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn {
  background: #eef2ff;
  color: var(--primary);
}

.full {
  width: 100%;
}

.message {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.wallet-page {
  max-width: 520px;
  height: 100dvh;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wallet-header {
  flex-shrink: 0;
  margin: -16px -16px 16px;
  padding: 16px;
  background: rgba(244, 246, 248, 0.9);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.label,
.summary-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.wallet-id-btn {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text);
  font-weight: 800;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: white;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.wallet-page main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#contentArea {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.month-card,
.summary-card,
.expense-section,
.error-box {
  background: var(--card);
  border-radius: 24px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

.month-card {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  align-items: center;
}

.month-card input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.month-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 24px;
  line-height: 1;
}

.summary-card {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.summary-value {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
}

.expense-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.section-title-row {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title-row h2 {
  margin: 0;
  font-size: 20px;
}

.count-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 12px;
}

.expense-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 12px;
  display: grid;
  gap: 10px;
  padding-bottom: 120px;
}

.expense-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  background: #fff;
}

.expense-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.expense-amount {
  font-weight: 900;
  font-size: 20px;
  white-space: nowrap;
}

.expense-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.expense-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.small-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  background: #f3f4f6;
  color: var(--text);
}

.danger-btn {
  background: #fee2e2;
  color: var(--danger);
}

.empty-text {
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
}

.error-box {
  border: 1px solid #fecaca;
  color: var(--danger);
}

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 34px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.45);
}

.bottom-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  width: 100%;
  max-width: 520px;
  transform: translateX(-50%);
  background: white;
  border-radius: 28px 28px 0 0;
  padding: 12px 20px 24px;
  box-shadow: var(--shadow);
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(100%);
  }
  to {
    transform: translateX(-50%) translateY(0);
  }
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 16px;
  border-radius: 999px;
  background: #d1d5db;
}

.bottom-sheet h2 {
  margin: 0 0 16px;
}

.bottom-sheet form,
.setting-list {
  display: grid;
  gap: 14px;
}

label,
.setting-input {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

label input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 12px;
  color: var(--text);
  background: white;
}

input[type="date"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  padding-right: 8px;
}

.setting-item {
  width: 100%;
  background: #f9fafb;
  color: var(--text);
  text-align: left;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 60;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
}

@media (min-width: 640px) {
  .summary-card {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-card .full {
    grid-column: 1 / -1;
  }
}