/* ============ Reset & Base ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: #333;
  background: #f5f6fa;
  height: 100%;
  overscroll-behavior: none;
}

input, button {
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border: none;
  background: none;
}

button { cursor: pointer; }

/* ============ Login Page ============ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.login-container {
  width: 90%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-header .logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: #333;
}

.login-header p {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
}

.login-tabs {
  display: none;
}

/* Auth Form */
.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
  font-weight: 500;
}

.input-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-size: 15px;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: #667eea;
}

.input-hint {
  display: block;
  font-size: 11px;
  color: #bbb;
  margin-top: 4px;
}

/* Switch Link */
.switch-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: #999;
}

.switch-link a {
  color: #667eea;
  font-weight: 600;
  text-decoration: none;
}

.switch-link a:active {
  opacity: 0.7;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 8px;
  transition: opacity 0.2s;
}

.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: #f0f0f5;
  color: #667eea;
  border-radius: 10px;
  font-weight: 600;
  margin-top: 12px;
}

.btn-danger {
  width: 100%;
  padding: 12px;
  background: #fff0f0;
  color: #e74c3c;
  border-radius: 10px;
  font-weight: 600;
  margin-top: 24px;
}

.error-msg {
  color: #e74c3c;
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
}

/* ============ App Page ============ */
.app-page {
  padding-top: 0;
  padding-bottom: 80px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left, .header-right {
  flex: 0 0 auto;
}

.header-center {
  flex: 1;
  text-align: center;
}

.month-display {
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.month-summary {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.summary-label {
  font-size: 11px;
  opacity: 0.8;
}

.summary-amount {
  font-size: 15px;
  font-weight: 700;
}

.summary-amount.expense { color: #ffd6d6; }
.summary-amount.income { color: #d6ffd6; }

.icon-btn {
  font-size: 20px;
  color: #fff;
  padding: 4px 8px;
  border-radius: 8px;
}

.icon-btn:active { background: rgba(255,255,255,0.2); }

/* Bill List */
.bill-list {
  padding: 12px;
}

.loading, .empty, .error {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 14px;
}

.bill-day-group {
  background: #fff;
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.bill-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #f5f5f5;
}

.bill-date {
  font-size: 13px;
  color: #666;
  font-weight: 500;
}

.bill-day-summary {
  font-size: 12px;
  color: #999;
}

.bill-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid #f8f8f8;
  position: relative;
}

.bill-item:last-child {
  border-bottom: none;
}

.bill-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: #f5f6fa;
  border-radius: 10px;
  margin-right: 12px;
}

.bill-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.bill-category {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.bill-note {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

.bill-amount {
  font-size: 15px;
  font-weight: 700;
}

.bill-amount.expense { color: #e74c3c; }
.bill-amount.income { color: #27ae60; }

.bill-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff0f0;
  color: #e74c3c;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
}

.bill-item:hover .bill-delete,
.bill-item:active .bill-delete {
  display: flex;
}

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(102,126,234,0.4);
  z-index: 50;
  transition: transform 0.2s;
}

.fab:active { transform: scale(0.92); }

/* ============ Modal ============ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 500px;
  border-radius: 20px 20px 0 0;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.close-btn {
  font-size: 18px;
  color: #999;
  padding: 4px 8px;
}

.modal-body {
  padding: 20px;
}

/* Type Switch */
.type-switch {
  display: flex;
  background: #f0f0f5;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}

.type-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  color: #999;
  font-weight: 500;
  transition: all 0.2s;
}

.type-btn.active {
  background: #fff;
  color: #333;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.category-item.selected {
  border-color: #667eea;
  background: #f0f0ff;
}

.category-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.category-name {
  font-size: 12px;
  color: #666;
}

/* Amount Input */
.amount-input {
  display: flex;
  align-items: center;
  padding: 16px;
  background: #f5f6fa;
  border-radius: 12px;
  margin-bottom: 12px;
}

.amount-input .currency {
  font-size: 24px;
  font-weight: 700;
  color: #667eea;
  margin-right: 8px;
}

.amount-input input {
  flex: 1;
  font-size: 28px;
  font-weight: 700;
  color: #333;
}

.date-input, .note-input {
  margin-bottom: 12px;
}

.date-input input, .note-input input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-size: 14px;
}

.date-input input:focus, .note-input input:focus {
  border-color: #667eea;
}

/* ============ User Panel ============ */
.user-info {
  display: flex;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 16px;
}

.user-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin-right: 14px;
}

.user-details {
  flex: 1;
}

.user-name {
  font-size: 17px;
  font-weight: 600;
}

.user-account {
  font-size: 13px;
  color: #999;
  margin-top: 2px;
}

.identifier-section {
  margin-bottom: 20px;
}

.section-label {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}

.identifier-display {
  padding: 16px;
  background: #f5f6fa;
  border-radius: 12px;
  text-align: center;
  margin-bottom: 8px;
}

.identifier-placeholder {
  color: #ccc;
  font-size: 15px;
}

.identifier-id {
  font-size: 20px;
  font-weight: 700;
  color: #667eea;
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
}

.identifier-tip {
  font-size: 12px;
  color: #bbb;
  margin-top: 8px;
  text-align: center;
}

/* ============ Month Picker ============ */
.year-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.year-switch span {
  font-size: 18px;
  font-weight: 600;
}

.year-switch .icon-btn {
  color: #667eea;
  font-size: 22px;
}

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

.month-item {
  padding: 14px;
  border-radius: 12px;
  background: #f5f6fa;
  color: #333;
  font-weight: 500;
  font-size: 15px;
  transition: all 0.15s;
}

.month-item.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
