/* ===== CSS 变量 ===== */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-card: #ffffff;
  --bg-hover: #f5f5f7;
  --bg-overlay: rgba(0,0,0,0.04);
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #aeaeb2;
  --color-primary: #0071e3;
  --color-primary-hover: #0058b9;
  --color-primary-light: rgba(0,113,227,0.08);
  --color-income: #ff3b30;
  --color-expense: #34c759;
  --color-profit: #5856d6;
  --color-warn: #ff9500;
  --color-danger: #ff3b30;
  --color-success: #34c759;
  --color-info: #0071e3;
  --border-color: #d2d2d7;
  --border-light: #e8e8ed;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 236px;
  --topbar-height: 56px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  --transition: 200ms ease;
}

/* ===== 深色模式 ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1c;
    --bg-secondary: #2c2c2e;
    --bg-card: #2c2c2e;
    --bg-hover: #3a3a3c;
    --bg-overlay: rgba(255,255,255,0.06);
    --text-primary: #f5f5f7;
    --text-secondary: #aeaeb2;
    --text-tertiary: #636366;
    --color-primary: #0a84ff;
    --color-primary-hover: #409cff;
    --color-primary-light: rgba(10,132,255,0.15);
    --color-income: #ff453a;
    --color-expense: #30d158;
    --color-profit: #5e5ce6;
    --color-warn: #ff9f0a;
    --border-color: #38383a;
    --border-light: #48484a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  }
}

/* 手动深色模式 */
[data-theme="dark"] {
  --bg-primary: #1a1a1c;
  --bg-secondary: #2c2c2e;
  --bg-card: #2c2c2e;
  --bg-hover: #3a3a3c;
  --bg-overlay: rgba(255,255,255,0.06);
  --text-primary: #f5f5f7;
  --text-secondary: #aeaeb2;
  --text-tertiary: #636366;
  --color-primary: #0a84ff;
  --color-primary-hover: #409cff;
  --color-primary-light: rgba(10,132,255,0.15);
  --color-income: #ff453a;
  --color-expense: #30d158;
  --color-profit: #5e5ce6;
  --color-warn: #ff9f0a;
  --border-color: #38383a;
  --border-light: #48484a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; width: 100%; height: 100%; overflow-x: hidden; }
body {
  font-family: var(--font-family);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 布局 ===== */
#app { display: flex; flex-direction: column; width: 100% !important; max-width: none !important; min-height: 100vh; }
#app-root { display: flex; width: 100% !important; max-width: none !important; min-width: 0; flex: 1; }

/* ---- 侧边栏 ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px; height: var(--topbar-height);
  font-size: 16px; font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-logo span:first-child { font-size: 22px; }
.sidebar-nav { flex: 1; padding: 10px 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 18px;
  color: var(--text-secondary);
  font-size: 13.5px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}
.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidebar-nav a.active {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  background: var(--color-primary-light);
  font-weight: 600;
}
.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.sidebar-nav .group-label {
  padding: 16px 18px 6px;
  font-size: 11px; font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ---- 主区域 ---- */
.main-area { flex: 1 0 0 !important; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; width: 100% !important; max-width: none !important; }

/* ---- 顶栏 ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-search {
  width: 260px; padding: 7px 14px;
  border: 1px solid var(--border-color); border-radius: 20px;
  background: var(--bg-secondary); color: var(--text-primary);
  outline: none; transition: all var(--transition);
  font-size: 13px;
}
.topbar-search:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.topbar-search::placeholder { color: var(--text-tertiary); }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 17px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.topbar-btn:active { transform: scale(0.92); }

/* 汉堡菜单按钮（仅移动端显示） */
.hamburger-btn {
  display: none;
  width: 36px; height: 36px; border-radius: 50%;
  align-items: center; justify-content: center;
  color: var(--text-primary); font-size: 20px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--bg-hover); }
.hamburger-btn:active { transform: scale(0.92); }

/* 侧边栏遮罩（仅移动端） */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition);
}
.sidebar-backdrop.visible { opacity: 1; }

/* ---- 内容区 ---- */
.content { flex: 1 !important; padding: 24px; width: 100% !important; max-width: none !important; min-width: 0; box-sizing: border-box; }

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ===== 指标卡 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-md);
  padding: 20px; border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm); transition: all var(--transition);
  cursor: pointer; position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat-card .stat-change { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.stat-card .stat-change.up { color: var(--color-income); }
.stat-card .stat-change.down { color: var(--color-expense); }
.stat-card .stat-icon { position: absolute; top: 16px; right: 16px; font-size: 28px; opacity: 0.15; }

/* ===== 表格 ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 100%; }
.data-table th {
  text-align: left; padding: 12px 16px;
  font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap; background: var(--bg-secondary);
  position: sticky; top: 0;
  z-index: 1;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover td { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .text-muted { color: var(--text-secondary); }
.data-table .text-income { color: var(--color-income); font-weight: 600; }
.data-table .text-expense { color: var(--color-expense); font-weight: 600; }

/* 表格操作列按钮组 */
.cell-actions { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-color);
  background: var(--bg-card); color: var(--text-primary);
  transition: all var(--transition); white-space: nowrap;
  min-height: 36px;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-tertiary); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn-danger { color: var(--color-danger); border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; min-height: 30px; }
.btn-text { border: none; background: none; color: var(--color-primary); padding: 5px 10px; min-height: auto; border-radius: var(--radius-sm); }
.btn-text:hover { background: var(--bg-overlay); }
.btn-text.danger { color: var(--color-danger); }

/* ===== 表单 ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-label .req { color: var(--color-danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 13px;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text-primary);
  outline: none; transition: all var(--transition);
  font-size: 14px;
  min-height: 42px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-error { color: var(--color-danger); font-size: 12px; margin-top: 4px; }

/* ===== 徽章 ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-blue { background: rgba(0,113,227,0.1); color: var(--color-primary); }
.badge-red { background: rgba(255,59,48,0.1); color: var(--color-income); }
.badge-green { background: rgba(52,199,89,0.1); color: var(--color-expense); }
.badge-orange { background: rgba(255,149,0,0.1); color: var(--color-warn); }
.badge-purple { background: rgba(88,86,214,0.1); color: var(--color-profit); }
.badge-gray { background: var(--bg-overlay); color: var(--text-secondary); }

/* ===== 搜索/工具栏 ===== */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}
.toolbar .toolbar-left {
  display: flex; align-items: center; gap: 10px;
  flex: 1; flex-wrap: wrap;
}
.toolbar .toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.toolbar input, .toolbar select {
  padding: 7px 12px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card);
  color: var(--text-primary); font-size: 13px; outline: none;
  min-height: 38px;
  transition: border-color var(--transition);
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }

/* Tab 切换组（发票页等） */
.tab-group { display: flex; gap: 4px; }
.tab-btn {
  padding: 6px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  background: transparent; color: var(--text-secondary);
  transition: all var(--transition); cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover { background: var(--bg-hover); }
.tab-btn.active {
  background: var(--color-primary); color: #fff;
  border-color: var(--color-primary);
}

/* ===== 分页 ===== */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-top: 1px solid var(--border-light);
  flex-wrap: wrap; gap: 8px;
}
.pagination-info { font-size: 12.5px; color: var(--text-secondary); }
.pagination-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.pagination-btns button {
  padding: 6px 12px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card);
  color: var(--text-primary); font-size: 12.5px;
  min-width: 36px; min-height: 34px;
  transition: all var(--transition);
}
.pagination-btns button:disabled { opacity: 0.35; cursor: not-allowed; }
.pagination-btns button:not(:disabled):hover { background: var(--bg-hover); border-color: var(--text-tertiary); }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  padding: 16px;
}
.modal {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%;
  max-width: 600px; max-height: 90vh;
  display: flex; flex-direction: column;
  animation: modalIn 200ms ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 18px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 68px; right: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 380px;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: toastIn 200ms ease;
}
.toast-success { background: var(--color-success); color: #fff; }
.toast-error { background: var(--color-danger); color: #fff; }
.toast-warn { background: var(--color-warn); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== 进度条 ===== */
.progress-bar { width: 100%; height: 6px; background: var(--bg-overlay); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--color-primary); border-radius: 3px; transition: width 300ms ease; }

/* ===== 空状态 (旧版，向后兼容) ===== */
.empty-state-legacy { text-align: center; padding: 56px 20px; color: var(--text-secondary); }
.empty-state-legacy .icon { font-size: 44px; opacity: 0.25; margin-bottom: 10px; }
.empty-state-legacy div:last-child { font-size: 14px; }

/* ===== 加载 ===== */
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; color: var(--text-secondary); gap: 10px; }
.loading-spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border-color); border-top-color: var(--color-primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
.loading-text { font-size: 13px; color: var(--text-secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 骨架屏 ===== */
.skeleton { background: var(--bg-overlay); border-radius: 6px; position: relative; overflow: hidden; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--bg-hover), transparent);
  animation: skeletonShimmer 1.5s ease infinite;
}
@keyframes skeletonShimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.skeleton-text { height: 14px; margin-bottom: 10px; border-radius: 4px; }
.skeleton-text.w60 { width: 60%; }
.skeleton-text.w40 { width: 40%; }
.skeleton-text.w80 { width: 80%; }
.skeleton-title { height: 22px; width: 50%; margin-bottom: 16px; }
.skeleton-card { height: 100px; border-radius: var(--radius-md); }
.skeleton-row { display: flex; gap: 16px; margin-bottom: 14px; }
.skeleton-row .skeleton { flex: 1; }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-secondary); }
.empty-state .empty-icon { font-size: 52px; opacity: 0.2; margin-bottom: 14px; line-height: 1; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.empty-state .empty-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 18px; line-height: 1.6; }
.empty-state .empty-action { display: inline-flex; gap: 8px; }

/* ===== 网格工具 ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.text-income { color: var(--color-income); font-weight: 600; }
.text-expense { color: var(--color-expense); font-weight: 600; }
.text-profit { color: var(--color-profit); font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }

/* ================================================================
   响应式 —— 平板（≤1024px）
   ================================================================ */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .content { padding: 20px; }
  .topbar-search { width: 200px; }
  .data-table th, .data-table td { padding: 10px 12px; }
}

/* ================================================================
   响应式 —— 手机（≤768px）
   ================================================================ */
@media (max-width: 768px) {

  /* 侧边栏：滑出 + 遮罩 */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-backdrop {
    display: block;
  }

  /* 主区域无左边距 */
  .main-area { margin-left: 0; }

  /* 显示汉堡按钮，隐藏搜索框 */
  .hamburger-btn { display: flex; }
  .topbar-search { display: none; }

  /* 顶栏紧凑 */
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-title { font-size: 15px; }

  /* 内容区内边距 */
  .content { padding: 14px; }

  /* 网格单列 */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 22px; }

  /* 工具栏垂直堆叠 */
  .toolbar {
    flex-direction: column; align-items: stretch;
    padding: 12px; gap: 10px;
  }
  .toolbar .toolbar-left { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar .toolbar-right { justify-content: stretch; }
  .toolbar .toolbar-right .btn { flex: 1; }
  .toolbar input, .toolbar select { width: 100%; min-height: 42px; font-size: 15px; }

  /* 表格 → 卡片视图 */
  .table-wrapper { overflow-x: visible; }
  .data-table thead { display: none; }
  .data-table,
  .data-table tbody,
  .data-table tr {
    display: block;
    width: 100%;
  }
  .data-table tr {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
  }
  .data-table tr:hover { box-shadow: var(--shadow-md); }
  .data-table tr:hover td { background: transparent !important; }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 5px 0 !important;
    border: none !important;
    font-size: 13.5px;
    line-height: 1.6;
  }
  /* 移动端卡片：字段标签（通过 data-label 属性） */
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    min-width: 72px;
    flex-shrink: 0;
    margin-right: 8px;
    text-align-last: justify;
  }
  /* 操作列不显示标签 */
  .data-table td:last-child::before { content: none; }
  /* 操作列特殊处理：靠右显示 */
  .data-table td:last-child {
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 10px !important;
    border-top: 1px dashed var(--border-light) !important;
  }
  .cell-actions { gap: 8px; }
  .cell-actions .btn-text { padding: 8px 14px; font-size: 13px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }

  /* 分页简化 */
  .pagination { padding: 12px 14px; flex-direction: column; align-items: center; gap: 10px; }
  .pagination-btns button { min-height: 38px; padding: 8px 14px; }

  /* 弹窗全屏 */
  .modal { max-width: 100%; max-height: 100vh; border-radius: var(--radius-md) var(--radius-md) 0 0; margin: auto; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  /* 表单行堆叠 */
  .form-row { flex-direction: column; gap: 0; }

  /* Toast 全宽 */
  .toast-container { right: 12px; left: 12px; max-width: none; }

  /* 空状态 */
  .empty-state { padding: 40px 16px; }
}

/* ================================================================
   超小屏（≤480px）
   ================================================================ */
@media (max-width: 480px) {
  :root { --sidebar-width: 280px; } /* 移动端侧边栏更宽 */
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-title { font-size: 14px; }
  .hamburger-btn { width: 34px; height: 34px; font-size: 19px; }
  .content { padding: 10px; }
  .toolbar { padding: 10px; }
  .data-table tr { padding: 12px 14px; }
  .btn { padding: 8px 14px; font-size: 13px; }
}

/* ================================================================
   登录屏（单密码门禁）
   ================================================================ */
/* ===== 登录页 ===== */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #334155 70%, #1e3a5f 100%);
  z-index: 1000;
  padding: 20px;
  overflow: hidden;
}
/* 背景装饰圆 */
.login-screen::before {
  content: ''; position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,0.15) 0%, transparent 70%);
  top: -150px; right: -100px;
  animation: loginFloat 8s ease-in-out infinite alternate;
}
.login-screen::after {
  content: ''; position: absolute;
  width: 350px; height: 350px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 70%);
  bottom: -100px; left: -80px;
  animation: loginFloat 6s ease-in-out infinite alternate-reverse;
}
@keyframes loginFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -20px) scale(1.05); }
}
/* 背景网格装饰 */
.login-bg-grid {
  position: absolute; inset: 0; opacity: 0.03;
  background-image:
    linear-gradient(rgba(255,255,255,1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,1) 1px, transparent 1px);
  background-size: 60px 60px;
}
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  box-shadow: 0 25px 80px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.1) inset;
  padding: 44px 36px 32px;
  text-align: center;
  animation: loginCardIn 500ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.login-icon-area {
  width: 72px; height: 72px;
  margin: 0 auto 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  box-shadow: 0 8px 30px rgba(59,130,246,0.3);
  animation: loginBadgePulse 3s ease-in-out infinite;
}
@keyframes loginBadgePulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(59,130,246,0.3); }
  50% { box-shadow: 0 8px 40px rgba(139,92,246,0.4); }
}
.login-sys-name {
  font-size: 24px; font-weight: 800;
  color: #1e293b; margin-bottom: 4px;
  letter-spacing: -0.3px;
}
.login-sys-sub {
  font-size: 13px; color: #64748b; margin-bottom: 28px;
  line-height: 1.5;
}
.login-field {
  text-align: left; margin-bottom: 20px;
}
.login-label {
  display: block; font-size: 13px; font-weight: 600;
  color: #475569; margin-bottom: 7px;
}
.login-pwd-wrap {
  position: relative; display: flex; align-items: center;
}
.login-input {
  width: 100%; height: 48px;
  padding: 0 48px 0 16px;
  font-size: 15px;
  color: #1e293b;
  background: #f1f5f9;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  outline: none;
  transition: all 200ms ease;
}
.login-input:focus {
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}
.login-input::placeholder { color: #94a3b8; }
.login-toggle-pwd {
  position: absolute; right: 12px;
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: #94a3b8; padding: 4px 6px;
  transition: color 150ms;
}
.login-toggle-pwd:hover { color: #475569; }
.login-err {
  color: #ef4444; font-size: 12px;
  margin-top: 6px; display: flex; align-items: center; gap: 4px;
}
.login-btn {
  width: 100%; height: 48px; border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff; font-size: 16px; font-weight: 700;
  cursor: pointer;
  transition: all 200ms ease;
  box-shadow: 0 4px 20px rgba(59,130,246,0.3);
  letter-spacing: 4px;
}
.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(59,130,246,0.4);
}
.login-btn:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.login-btn:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }
.login-hint {
  margin-top: 16px; font-size: 12px;
  color: #94a3b8; line-height: 1.5;
}
.login-footer {
  margin-top: 28px; padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px; color: #94a3b8;
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
  cursor: default;
}
.login-footer span { cursor: pointer; transition: color 150ms; }
.login-footer span:hover { color: #3b82f6; }
.login-booting {
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 0 16px; gap: 16px;
}
.login-spinner {
  width: 32px; height: 32px;
  border: 3px solid #e2e8f0; border-top-color: #3b82f6;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-booting-text {
  font-size: 14px; color: #64748b;
}

/* ---- 侧边栏底部 ---- */
.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}
.sidebar-copyright {
  font-size: 10.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-version {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 2px;
  cursor: pointer;
  transition: color var(--transition);
}
.sidebar-version:hover { color: var(--color-primary); }

/* ===== 税务中心：报税闹钟 + 申报清单 ===== */
.tax-alarm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-lg, 12px);
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 1px solid #fed7aa;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.08));
  margin-bottom: 6px;
}
.dark .tax-alarm { background: linear-gradient(135deg, #3a2a1a, #2a2018); border-color: #7c5a36; }
.tax-alarm .ta-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tax-alarm .ta-icon { font-size: 30px; line-height: 1; }
.tax-alarm .ta-title { font-size: 16px; font-weight: 700; color: #c2410c; }
.dark .tax-alarm .ta-title { color: #fdba74; }
.tax-alarm .ta-sub { font-size: 13px; color: var(--color-secondary); margin-top: 2px; }
.tax-alarm .ta-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tax-alarm.ta-urgent, .tax-alarm.ta-overdue { background: linear-gradient(135deg, #fef2f2, #fee2e2); border-color: #fecaca; }
.dark .tax-alarm.ta-urgent, .dark .tax-alarm.ta-overdue { background: linear-gradient(135deg, #3a1f1f, #2a1818); border-color: #7c3a3a; }
.tax-alarm.ta-urgent .ta-title, .tax-alarm.ta-overdue .ta-title { color: var(--color-danger); }
.tax-alarm.ta-done { background: linear-gradient(135deg, #f0fdf4, #dcfce7); border-color: #bbf7d0; }
.dark .tax-alarm.ta-done { background: linear-gradient(135deg, #1a2e1f, #182a18); border-color: #3a7a4a; }
.tax-alarm.ta-done .ta-title { color: var(--color-success); }

.filing-list { display: flex; flex-direction: column; gap: 10px; }
.filing-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md, 10px);
  overflow: hidden;
  background: var(--bg-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filing-item.open { border-color: var(--color-primary); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.fi-head { padding: 13px 16px; cursor: pointer; user-select: none; }
.fi-head:hover { background: var(--bg-hover); }
.fi-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fi-name { font-size: 15px; font-weight: 600; color: var(--color-text); }
.fi-freq {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--bg-tag, #eef2f7); color: var(--color-secondary);
}
.fi-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--color-secondary); }
.fi-arrow { margin-left: auto; color: var(--color-primary); font-weight: 600; cursor: pointer; }
.fi-body { padding: 4px 16px 16px; border-top: 1px solid var(--border-light); }
.fi-steps-title { font-size: 14px; font-weight: 600; color: var(--color-text); margin: 12px 0 8px; }
ol.steps { margin: 0; padding-left: 22px; }
ol.steps li { font-size: 13.5px; line-height: 1.9; color: var(--color-text); }
.fi-actions { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.fi-deadline { font-size: 13px; color: var(--color-secondary); }
.filing-item.done { border-color: #bbf7d0; background: linear-gradient(0deg, rgba(240,253,244,.55), var(--bg-card)); }
.dark .filing-item.done { border-color: #3a7a4a; background: linear-gradient(0deg, rgba(26,46,31,.5), var(--bg-card)); }
.filing-item.done .fi-name { color: var(--color-success); }
.fi-done {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: 4px; padding: 3px 9px; border-radius: 20px;
  background: var(--bg-tag, #eef2f7); color: var(--color-secondary);
  font-size: 12px; cursor: pointer; user-select: none;
  border: 1px solid transparent; transition: all var(--transition);
}
.fi-done:hover { border-color: var(--color-success); color: var(--color-success); }
.fi-done input { width: 14px; height: 14px; accent-color: var(--color-success); cursor: pointer; margin: 0; }
.fi-done-note {
  margin: 12px 0 4px; padding: 9px 12px; border-radius: var(--radius-sm, 8px);
  background: rgba(34,197,94,.1); color: var(--color-success);
  font-size: 13px; line-height: 1.6;
}
.dark .fi-done-note { background: rgba(34,197,94,.16); }

@media (max-width: 600px) {
  .tax-alarm { flex-direction: column; align-items: flex-start; }
  .tax-alarm .ta-right { width: 100%; justify-content: space-between; }
  .fi-meta { gap: 6px; }
}

/* ===================== 打印 / 导出 PDF ===================== */
@media print {
  /* 隐藏非内容区域 */
  .sidebar, .topbar, .toolbar, .modal-backdrop, .modal,
  button, .btn, .btn-text, .btn-sm, [data-action], .toast-container,
  .fi-actions, .ta-right, .loading { display: none !important; }

  html, body { background: #fff !important; }
  #app, .layout, .main, .content { display: block !important; padding: 0 !important; margin: 0 !important; width: 100% !important; }
  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    margin-bottom: 12px !important;
    break-inside: avoid;
    background: #fff !important;
  }
  .card-header, .card-title { color: #000 !important; }
  .data-table { width: 100% !important; border-collapse: collapse !important; }
  .data-table th, .data-table td {
    border: 1px solid #999 !important;
    padding: 4px 8px !important;
    color: #000 !important;
    font-size: 12px !important;
  }
  .data-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* 强制打印背景色（ECharts/状态色在 PDF 中可见） */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  a { color: #000 !important; text-decoration: none !important; }
  h1, h2, h3, .page-title { color: #000 !important; }
}

/* ===== 自定义确认对话框 ===== */
.xa-confirm-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 200ms ease;
}
.xa-confirm-overlay.visible { opacity: 1; }
.xa-confirm-box {
  background: var(--bg-primary); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 24px 28px;
  min-width: 340px; max-width: 480px; width: 90%;
  transform: scale(0.95); transition: transform 200ms ease;
}
.xa-confirm-overlay.visible .xa-confirm-box { transform: scale(1); }
.xa-confirm-title {
  font-size: 16px; font-weight: 700; margin-bottom: 10px;
  color: var(--text-primary);
}
.xa-confirm-msg {
  font-size: 14px; line-height: 1.6; color: var(--text-secondary);
  margin-bottom: 20px;
}
.xa-confirm-actions {
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ===== 页面过渡动画 ===== */
.page-enter-active { animation: pageIn 250ms ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== 按钮点击涟漪效果 ===== */
.btn-ripple { position: relative; overflow: hidden; }
.btn-ripple::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle, var(--bg-overlay) 10%, transparent 60%);
  transform: scale(0); opacity: 0; transition: transform 300ms ease, opacity 300ms ease;
  border-radius: inherit;
}
.btn-ripple:active::after { transform: scale(2); opacity: 1; transition: none; }

/* ===== 快速记账浮窗 ===== */
.quick-entry-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 80;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  font-size: 24px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,113,227,0.35);
  cursor: pointer; transition: all 200ms ease;
  border: none; outline: none;
}
.quick-entry-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,113,227,0.45); }
.quick-entry-fab:active { transform: scale(0.95); }

.quick-entry-panel {
  position: fixed; bottom: 90px; right: 28px; z-index: 80;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 16px 20px; min-width: 280px;
  animation: pageIn 200ms ease;
}
.quick-entry-panel .qe-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--text-primary); }
.quick-entry-panel .qe-actions { display: flex; flex-direction: column; gap: 8px; }
.quick-entry-panel .qe-actions .btn { width: 100%; justify-content: flex-start; }

/* ---- 语音识别 ---- */
.voice-overlay {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(15,23,42,0.85); display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
}
.voice-pulse {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(59,130,246,0.3); animation: voicePulse 1.5s ease-in-out infinite;
  margin-bottom: 24px;
}
@keyframes voicePulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 0.3; }
}
.voice-text { color: #fff; font-size: 20px; font-weight: 500; max-width: 80vw; text-align: center; }

/* ===== 操作日志 ===== */
.log-list { display: flex; flex-direction: column; }
.log-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border-light);
  font-size: 13px; line-height: 1.5;
}
.log-item:last-child { border-bottom: none; }
.log-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 6px; flex-shrink: 0;
}
.log-dot.create { background: var(--color-success); }
.log-dot.update { background: var(--color-primary); }
.log-dot.delete { background: var(--color-danger); }
.log-dot.login { background: var(--color-warn); }
.log-dot.system { background: var(--color-profit); }
.log-content { flex: 1; min-width: 0; }
.log-content .log-action { color: var(--text-primary); font-weight: 500; }
.log-content .log-detail { color: var(--text-secondary); margin-top: 2px; }
.log-content .log-time { color: var(--text-tertiary); font-size: 12px; margin-top: 2px; }

/* ===== 首次引导 ===== */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 200ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.onboarding-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 560px; width: 90%;
  padding: 36px 32px; text-align: center;
  animation: pageIn 300ms ease;
}
.onboarding-card .ob-step { font-size: 12px; color: var(--color-primary); font-weight: 600; margin-bottom: 8px; }
.onboarding-card .ob-title { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 10px; }
.onboarding-card .ob-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 20px; }
.onboarding-card .ob-features { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; margin-bottom: 24px; }
.onboarding-card .ob-feature { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-primary); }
.onboarding-card .ob-feature .ob-ficon { font-size: 18px; flex-shrink: 0; }
.onboarding-card .ob-actions { display: flex; justify-content: center; gap: 12px; }
.onboarding-card .ob-dots { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
.onboarding-card .ob-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-color); transition: all 200ms ease; }
.onboarding-card .ob-dot.active { background: var(--color-primary); width: 20px; border-radius: 4px; }
