/* 基礎與變量 */
:root {
  --bg: #0f0f14;
  --surface: #1a1a22;
  --surface-hover: #22222e;
  --text: #e8e8ed;
  --text-muted: #8a8a9a;
  --primary: #00c896;
  --primary-hover: #00e0a8;
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
  --font: "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: 20px;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

#app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
}

/* 頁面切換 */
.page {
  animation: fadeIn 0.25s ease;
}
.page.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 登入頁 */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.login-card {
  width: 100%;
  padding: 32px 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.logo {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--primary);
}

.login-card .hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  margin-bottom: 20px;
}

/* 表單 */
.input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid #2a2a36;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--primary);
}

.input::placeholder {
  color: var(--text-muted);
}

/* 按鈕 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--bg);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover, .btn-ghost:focus {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-block {
  width: 100%;
}

.btn.small {
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* 主頁 */
#main-page .header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

#main-page .user {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#main-page .user strong {
  color: var(--text);
}

.balance-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  position: relative;
}

.balance-section .label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.balance-section .balance {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.balance-section .btn.small {
  position: absolute;
  top: 16px;
  right: 16px;
}

.actions {
  margin-bottom: 24px;
}

.actions .btn {
  padding: 16px;
}

.tips {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* 彈窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 360px;
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-content h2 {
  font-size: 1.25rem;
  margin-bottom: 20px;
}

.modal-content .label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.modal-content .input {
  margin-bottom: 12px;
}

.modal-content .msg {
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.modal-content .msg.error {
  color: var(--danger);
}

.modal-content .msg.hidden {
  display: none;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}
