/* 记账本样式：移动端优先 */
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f3f4f6; color: #111827; }
.hidden { display: none !important; }
.view { max-width: 900px; margin: 0 auto; padding: 12px; }

/* 登录 */
.auth-card { background: #fff; border-radius: 12px; padding: 28px 22px; margin: 16px auto; max-width: 400px; box-shadow: 0 2px 12px rgba(0,0,0,.08); text-align: center; }
.auth-card h1 { margin: 0 0 6px; }
.auth-card .sub { color: #6b7280; margin: 0 0 18px; font-size: 14px; }
/* 登录页品牌区：移动端紧凑展示 */
.hero-copy { text-align: center; padding: 30px 0 6px; }
.hero-copy h1 { font-size: 30px; margin: 0 0 6px; }
.hero-copy .tagline { color: #6b7280; margin: 0; font-size: 14px; }
.hero-copy .feat { display: none; }
.nav-ic { display: none; }
.dash-grid { display: grid; gap: 8px; }
.tabs-mini { display: flex; gap: 8px; margin-bottom: 14px; }
.mini-tab { flex: 1; padding: 8px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; }
.mini-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 15px; background: #fff; }
input:focus, select:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }
.hint { font-size: 12px; color: #9ca3af; }
.msg { color: #dc2626; min-height: 18px; font-size: 14px; }

/* 按钮 */
.btn { padding: 10px 16px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: #dc2626; border-color: #fecaca; }
.btn.block { width: 100%; margin-top: 8px; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

/* 顶部 + 导航 */
.topbar { display: flex; align-items: center; gap: 10px; background: #fff; padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; }
.topbar .logo { font-weight: 700; font-size: 18px; }
.topbar #whoami { margin-left: auto; color: #6b7280; font-size: 13px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.nav-btn { flex: 1 1 auto; padding: 9px 6px; border: 1px solid #d1d5db; background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; }
.nav-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.panel { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 12px; }

/* 卡片 */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.card { border-radius: 10px; padding: 14px; background: #f9fafb; border: 1px solid #e5e7eb; }
.card.green { background: #f0fdf4; border-color: #bbf7d0; }
.card.red { background: #fef2f2; border-color: #fecaca; }
.card.blue { background: #eff6ff; border-color: #bfdbfe; }
.card.big { padding: 18px; }
.card-label { font-size: 13px; color: #6b7280; margin-bottom: 4px; }
.card-value { font-size: 20px; font-weight: 700; }
.card-sub { font-size: 12px; color: #6b7280; margin-top: 4px; }

/* 表单 */
.form-grid { display: grid; gap: 10px; margin-bottom: 16px; }
.seg { display: flex; gap: 16px; align-items: center; }
.seg label { display: flex; gap: 6px; align-items: center; font-size: 15px; }
.seg input { width: auto; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 8px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filter-bar input, .filter-bar select { width: auto; flex: 1 1 120px; }

/* 流水列表 */
.tx-list { display: grid; gap: 8px; }
.tx-item { display: flex; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; }
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-weight: 600; }
.tx-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }
.tx-note { font-size: 13px; color: #374151; margin-top: 2px; word-break: break-all; }
.tx-amt { font-weight: 700; font-size: 17px; white-space: nowrap; }
.tx-amt.income { color: #16a34a; }
.tx-amt.expense { color: #dc2626; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 600; }
.badge.income { background: #dcfce7; color: #166534; }
.badge.expense { background: #fee2e2; color: #991b1b; }
.tx-actions { display: flex; gap: 4px; flex-direction: column; }
.tx-actions .btn { padding: 4px 8px; font-size: 12px; }
.empty { color: #9ca3af; text-align: center; padding: 24px; }

/* 列表项（账本/账户/分类） */
.item-list { display: grid; gap: 8px; margin-bottom: 16px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; border: 1px solid #e5e7eb; border-radius: 10px; }
.item .name { font-weight: 600; }
.item .meta { font-size: 12px; color: #6b7280; }

/* 统计条 */
.stat-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f3f4f6; }
.stat-row .name { width: 110px; }
.stat-row .bar-wrap { flex: 1; background: #f3f4f6; border-radius: 6px; height: 18px; overflow: hidden; }
.stat-row .bar { height: 100%; }
.stat-row .bar.income { background: #22c55e; }
.stat-row .bar.expense { background: #ef4444; }
.stat-row .val { width: 110px; text-align: right; font-weight: 600; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { border-bottom: 1px solid #e5e7eb; padding: 8px 6px; text-align: left; }
table.tbl th { color: #6b7280; font-weight: 600; }

dialog { border: none; border-radius: 12px; padding: 20px; width: min(92vw, 480px); box-shadow: 0 8px 30px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(0,0,0,.4); }

/* 每人汇总卡片 */
.cards.users { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.user-card { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.user-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.user-card.active { outline: 2px solid #2563eb; }
.uc-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-top: 6px; }
.uc-row span { color: #6b7280; }
.uc-row .in { color: #16a34a; }
.uc-row .out { color: #dc2626; }

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .card-value { font-size: 17px; }
  .tx-actions { flex-direction: row; }
}

/* ---------- 桌面端（≥1024px）：宽屏豪华版 ---------- */
@media (min-width: 1024px) {
  /* 登录页：全屏渐变 + 左右分栏 */
  #authView { max-width: none; margin: 0; padding: 48px 40px; min-height: 100vh; display: flex; align-items: center; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%); }
  .auth-hero { display: grid; grid-template-columns: 1fr 400px; gap: 64px; align-items: center; max-width: 1040px; margin: 0 auto; width: 100%; }
  .hero-copy { text-align: left; padding: 0; color: #fff; }
  .hero-copy h1 { font-size: 46px; margin: 0 0 14px; }
  .hero-copy .tagline { color: rgba(255,255,255,.88); font-size: 18px; margin: 0 0 30px; }
  .hero-copy .feat { display: grid; gap: 14px; list-style: none; padding: 0; margin: 0; }
  .hero-copy .feat li { display: flex; gap: 12px; align-items: center; font-size: 16px; background: rgba(255,255,255,.13); padding: 13px 18px; border-radius: 14px; backdrop-filter: blur(4px); }
  .auth-card { margin: 0; max-width: none; padding: 34px 30px; border-radius: 18px; box-shadow: 0 24px 64px rgba(0,0,0,.28); }

  /* 主界面：左侧边栏 + 右侧内容 */
  #mainView { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 0 22px; max-width: 1300px; align-items: start; }
  #mainView .topbar { grid-column: 1 / -1; border-radius: 0 0 16px 16px; padding: 16px 22px; box-shadow: 0 4px 16px rgba(37,99,235,.1); }
  #mainView .topbar .logo { font-size: 20px; }
  #mainView .nav { grid-column: 1; grid-row: 2; flex-direction: column; flex-wrap: nowrap; background: #fff; border-radius: 16px; padding: 12px; margin: 0; position: sticky; top: 18px; box-shadow: 0 4px 16px rgba(0,0,0,.05); }
  #mainView .nav-btn { text-align: left; padding: 13px 16px; border-radius: 10px; font-size: 15px; border: none; background: transparent; display: flex; align-items: center; gap: 10px; }
  #mainView .nav-btn:hover { background: #eff6ff; }
  #mainView .nav-btn.active { background: #2563eb; color: #fff; }
  .nav-ic { display: inline; font-size: 17px; }
  #mainView .panel { grid-column: 2; grid-row: 2; margin: 0; padding: 26px; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.05); min-height: 70vh; }

  /* 记账页：左表单右流水 */
  .dash-grid { grid-template-columns: 400px minmax(0, 1fr); gap: 30px; align-items: start; }
  .dash-grid h3 { margin-top: 0; }

  /* 豪华渐变统计卡 */
  .card.green { background: linear-gradient(135deg, #16a34a, #4ade80); border: none; }
  .card.red { background: linear-gradient(135deg, #dc2626, #f87171); border: none; }
  .card.blue { background: linear-gradient(135deg, #2563eb, #60a5fa); border: none; }
  .card.green .card-label, .card.green .card-value,
  .card.red .card-label, .card.red .card-value,
  .card.blue .card-label, .card.blue .card-value { color: #fff; }
  .card { border-radius: 14px; padding: 20px; box-shadow: 0 6px 18px rgba(0,0,0,.06); }
  .card-value { font-size: 26px; }

  .tx-item { transition: box-shadow .15s, transform .15s; }
  .tx-item:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-1px); }
  .item-list { grid-template-columns: 1fr 1fr; }
}
