/* 家庭消费报销系统 - 响应式样式 */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 2px 12px rgba(17, 24, 39, .06);
  --radius: 14px;
  --sidebar-w: 224px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }

.boot-screen { display: flex; align-items: center; justify-content: center; height: 100vh; color: var(--text-2); }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%);
}
.login-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 20px;
  padding: 38px 32px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
.login-logo {
  width: 58px; height: 58px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.login-logo svg { width: 30px; height: 30px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.login-sub { text-align: center; color: var(--text-2); margin: 0 0 28px; font-size: 13px; }
.login-tip { margin-top: 20px; padding: 12px 14px; background: #f8fafc; border: 1px dashed var(--border); border-radius: 10px; color: var(--text-2); font-size: 12px; line-height: 1.8; }
.login-tip b { color: var(--text); }

/* ---------- 布局 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 20;
}
.brand {
  height: 66px; display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 16px; white-space: nowrap;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.nav { padding: 14px 10px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 11px; color: var(--text-3); padding: 12px 12px 6px; letter-spacing: .05em; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; color: var(--text-2);
  cursor: pointer; margin-bottom: 3px; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f3f6ff; color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; }

.main-wrap { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 66px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 15;
}
.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px; border: 1px solid var(--border); background: #fff;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; color: var(--text-2);
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }
.dot { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; line-height: 17px; text-align: center; padding: 0 4px; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11px; color: var(--text-3); }
main#page { padding: 24px 26px 40px; flex: 1; }
.bottom-nav { display: none; }

/* ---------- 通用组件 ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-desc { color: var(--text-2); font-size: 13px; margin: 0; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-title { font-weight: 700; font-size: 15px; margin: 0 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title small { font-weight: 400; color: var(--text-3); font-size: 12px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; right: -18px; top: -18px; width: 76px; height: 76px; border-radius: 50%; background: var(--tint, var(--primary-light)); opacity: .5; }
.stat-label { color: var(--text-2); font-size: 13px; margin-bottom: 8px; position: relative; z-index: 1; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; position: relative; z-index: 1; }
.stat-value.small { font-size: 24px; }
.stat-foot { font-size: 12px; color: var(--text-3); margin-top: 8px; position: relative; z-index: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-pending { background: var(--warning-light); color: var(--warning); }
.badge-approved { background: var(--primary-light); color: var(--primary-dark); }
.badge-rejected { background: var(--danger-light); color: var(--danger); }
.badge-paid { background: var(--success-light); color: var(--success); }
.badge-off { background: #f3f4f6; color: var(--text-3); }
.badge-on { background: var(--success-light); color: var(--success); }

.field { margin-bottom: 16px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.label .req { color: var(--danger); margin-left: 3px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: #fff; outline: none; transition: border .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.textarea { min-height: 88px; resize: vertical; }
.hint { color: var(--text-3); font-size: 12px; margin-top: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--border); gap: 16px; }
.switch-row:last-child { border-bottom: 0; }
.switch-row .label { margin: 0; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d1d5db; border-radius: 24px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(20px); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 9px 14px; cursor: pointer; color: var(--text-2); font-size: 13px; white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 600; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 140px; }
.toolbar .grow { flex: 1; }

.list-item {
  display: flex; align-items: center; gap: 13px; padding: 13px 0;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: #fafbff; }
.cat-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-amount { font-weight: 700; font-size: 16px; white-space: nowrap; }

.progress { height: 9px; background: #edf0f5; border-radius: 9px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #38bdf8); border-radius: 9px; transition: width .4s; }
.progress.warning > i { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-top: 8px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; font-size: 12px; }
.bar-name { width: 72px; flex: none; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 9px; background: #f0f2f6; border-radius: 9px; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 9px; }
.bar-value { width: 78px; text-align: right; flex: none; font-weight: 600; }

.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; min-width: 480px; width: 100%; height: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-2); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: #fafbfe; }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }

.empty { text-align: center; padding: 38px 16px; color: var(--text-3); }
.empty svg { width: 44px; height: 44px; margin: 0 auto 10px; color: #cbd5e1; }
.loading { text-align: center; padding: 50px; color: var(--text-3); }

/* 分类选择 */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.cat-choice { border: 2px solid var(--border); border-radius: 12px; padding: 13px 6px; text-align: center; cursor: pointer; background: #fff; transition: all .15s; }
.cat-choice:hover { border-color: #bfdbfe; }
.cat-choice.selected { border-color: var(--primary); background: #f0f6ff; }
.cat-choice .cat-icon { margin: 0 auto 7px; width: 36px; height: 36px; font-size: 13px; }
.cat-choice .cat-name { font-size: 12px; font-weight: 600; }

/* 上传 */
.upload-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-box { border: 1px dashed #cbd5e1; border-radius: 12px; padding: 16px; text-align: center; cursor: pointer; background: #fafbfe; transition: all .15s; }
.upload-box:hover { border-color: var(--primary); background: #f4f8ff; }
.upload-box svg { width: 28px; height: 28px; color: var(--primary); margin: 0 auto 8px; }
.upload-box .u-title { font-weight: 600; font-size: 13px; }
.upload-box .u-sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.upload-box input { display: none; }
.thumb { width: 100%; height: 130px; object-fit: cover; border-radius: 9px; margin-bottom: 8px; background: #eef1f5; }
.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-pair figure { margin: 0; }
.photo-pair figcaption { font-size: 12px; color: var(--text-2); text-align: center; margin-bottom: 6px; }
.photo-pair img { width: 100%; border-radius: 10px; cursor: zoom-in; border: 1px solid var(--border); max-height: 300px; object-fit: contain; background: #f8fafc; }

.notice { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; border-radius: 10px; padding: 12px 14px; font-size: 12px; line-height: 1.8; margin-bottom: 18px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 100; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal.wide { max-width: 720px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 16px; }
.modal-close { border: 0; background: transparent; font-size: 22px; color: var(--text-3); cursor: pointer; line-height: 1; padding: 2px 6px; }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: fadein .2s; }
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
@keyframes fadein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 响应式 ---------- */
.mobile-only { display: none; }
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
  .topbar { height: 56px; padding: 0 16px; }
  .topbar-title { font-size: 15px; }
  main#page { padding: 16px 14px 84px; }
  .mobile-only { display: flex; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--border);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav .nav-item {
    flex: 1; flex-direction: column; gap: 2px; padding: 5px 2px; margin: 0;
    font-size: 10px; border-radius: 8px; background: transparent !important;
  }
  .bottom-nav .nav-item svg { width: 20px; height: 20px; }
  .bottom-nav .nav-badge { position: absolute; margin-left: 22px; margin-top: -6px; }
  .grid-3, .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid { gap: 10px; }
  .card { padding: 16px; border-radius: 12px; margin-bottom: 12px; }
  .stat-card { padding: 15px; }
  .stat-value { font-size: 22px; }
  .stat-value.small { font-size: 19px; }
  .page-title { font-size: 19px; }
  .form-row, .upload-row { grid-template-columns: 1fr; gap: 0; }
  .cat-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .cat-choice { padding: 10px 2px; }
  .modal { max-height: 94vh; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .toolbar .input, .toolbar .select { min-width: 0; flex: 1; }
  .user-chip .user-name, .user-chip .user-role { display: none; }
  .topbar-right { gap: 6px; }
}
@media (max-width: 380px) {
  .grid-3, .grid-2, .grid-4 { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 20px; }
}
