/* 纯 CSS 兼容层：不依赖 Tailwind / oklch，专供 Android WebView */

html, body {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  background: #eef7f2;
  color: #18181b;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }

a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; height: auto; vertical-align: middle; }

/* ── Auth ── */
.auth-bg {
  min-height: 100vh !important;
  min-height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 2rem 1rem !important;
  background: linear-gradient(160deg, #d1fae5 0%, #ecfdf5 40%, #f8fafc 100%) !important;
}

.auth-bg form,
form {
  display: flex !important;
  flex-direction: column !important;
  gap: 1rem !important;
  width: 100% !important;
}

label {
  display: block !important;
  width: 100% !important;
}

label > span {
  display: block !important;
  margin-bottom: 0.5rem !important;
  font-size: 0.875rem;
  color: #52525b;
  font-weight: 500;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  display: block !important;
  width: 100% !important;
  min-height: 48px !important;
  padding: 12px 16px !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 16px !important;
  background: #fff !important;
  font-size: 16px !important;
  color: #18181b !important;
}

button {
  font: inherit;
  cursor: pointer;
}

button[type="submit"],
.app-btn-primary {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  min-height: 48px !important;
  padding: 12px 20px !important;
  border: 0 !important;
  border-radius: 16px !important;
  background: linear-gradient(90deg, #059669, #14b8a6) !important;
  color: #fff !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

.glass-card {
  width: 100% !important;
  max-width: 400px !important;
  background: rgba(255, 255, 255, 0.92) !important;
  border: 1px solid rgba(255, 255, 255, 0.9) !important;
  border-radius: 24px !important;
  padding: 1.5rem !important;
  box-shadow: 0 8px 32px -8px rgba(15, 60, 40, 0.12) !important;
}

/* ── App shell ── */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: #eef7f2;
  padding-bottom: 5.5rem;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid #e4e4e7;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 16px;
  background: linear-gradient(135deg, #10b981, #0d9488);
  color: #fff;
  flex-shrink: 0;
}

.app-header-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #18181b;
}

.app-header-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: #a1a1aa;
}

.app-logout {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  width: auto !important;
  min-width: 40px;
  padding: 0 12px !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 16px !important;
  background: #fff !important;
  color: #71717a !important;
  font-size: 13px !important;
  font-weight: 500 !important;
}

.app-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

/* 桌面侧栏：小屏强制隐藏（不依赖 Tailwind hidden/md:block） */
.app-sidebar {
  display: none !important;
}

/* 底栏 */
.app-tabbar {
  position: fixed !important;
  left: 12px !important;
  right: 12px !important;
  bottom: max(8px, env(safe-area-inset-bottom, 8px)) !important;
  z-index: 40 !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: space-around !important;
  gap: 4px;
  padding: 6px 4px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 24px !important;
  box-shadow: 0 12px 40px rgba(15, 60, 40, 0.12) !important;
}

.app-tab {
  flex: 1;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2px;
  padding: 8px 4px !important;
  border-radius: 16px !important;
  color: #a1a1aa !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

.app-tab-active {
  color: #059669 !important;
  background: #ecfdf5 !important;
}

.app-fab {
  position: fixed !important;
  right: 20px !important;
  bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)) !important;
  z-index: 40 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 52px !important;
  height: 52px !important;
  border-radius: 999px !important;
  background: linear-gradient(135deg, #10b981, #0d9488) !important;
  color: #fff !important;
  box-shadow: 0 10px 25px rgba(5, 150, 105, 0.4) !important;
  text-decoration: none !important;
}

/* ── 通用页面 ── */
.app-page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #18181b;
}

.app-page-desc {
  margin: 6px 0 0;
  font-size: 0.875rem;
  color: #71717a;
}

.app-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.app-action-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px;
  width: auto !important;
  min-height: 40px !important;
  padding: 8px 14px !important;
  border-radius: 16px !important;
  border: 1px solid #e4e4e7 !important;
  background: #fff !important;
  color: #3f3f46 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

.app-action-btn-primary {
  border: 0 !important;
  background: linear-gradient(90deg, #059669, #14b8a6) !important;
  color: #fff !important;
}

/* ── Hero / 结余卡 ── */
.hero-mesh {
  border-radius: 24px !important;
  padding: 20px !important;
  margin: 16px 0 !important;
  background: linear-gradient(135deg, #059669 0%, #0d9488 45%, #0f766e 100%) !important;
  color: #fff !important;
  box-shadow: 0 20px 40px rgba(5, 150, 105, 0.28) !important;
}

.hero-mesh,
.hero-mesh * {
  color: #fff !important;
}

.hero-mesh .hero-muted,
.hero-mesh [class*="emerald-1"],
.hero-mesh [class*="emerald-2"] {
  color: rgba(209, 250, 229, 0.95) !important;
}

.hero-mesh .hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 12px;
}

.hero-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  margin-top: 16px !important;
}

.hero-grid > div {
  background: rgba(255, 255, 255, 0.12) !important;
  border-radius: 16px !important;
  padding: 10px 12px !important;
}

.hero-grid > div:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ── 统计卡片网格 ── */
.stat-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  margin: 12px 0 16px !important;
}

.stat-card {
  display: block !important;
  border-radius: 16px !important;
  padding: 14px !important;
  background: #fff !important;
  border: 1px solid #e4e4e7 !important;
  text-decoration: none !important;
  color: inherit !important;
}

.stat-card-label {
  margin: 0;
  font-size: 12px;
  color: #a1a1aa;
  font-weight: 600;
}

.stat-card-value {
  margin: 8px 0 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.stat-income .stat-card-value { color: #047857; }
.stat-expense .stat-card-value { color: #e11d48; }
.stat-balance .stat-card-value { color: #0369a1; }

/* ── 列表卡 ── */
.section-card {
  background: #fff !important;
  border: 1px solid #e4e4e7 !important;
  border-radius: 20px !important;
  padding: 12px 14px !important;
  margin-bottom: 16px !important;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

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

.section-link {
  color: #059669 !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
}

/* 大屏仍隐藏侧栏，统一用底栏，避免 WebView 宽度误判 */
@media (min-width: 900px) {
  .app-shell { padding-bottom: 24px; }
  .app-tabbar { display: none !important; }
  .app-fab { display: none !important; }
  .app-sidebar {
    display: flex !important;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 20px;
  }
  .app-sidebar a {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #71717a !important;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 500;
  }
  .app-sidebar a.app-tab-active {
    background: linear-gradient(90deg, #059669, #14b8a6) !important;
    color: #fff !important;
  }
}
