/* 简账企业版 · 应用外壳与通用组件 */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--primary-soft-2); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* ---------- 图标 ---------- */
.i {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

/* ---------- 工具类 ---------- */
.num { font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.row { display: flex; align-items: center; gap: var(--space-2); }
.row-3 { display: flex; align-items: center; gap: var(--space-3); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }

/* ---------- 应用框架 ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  height: 100vh;
  padding: 20px 12px 14px;
  overflow: hidden;
  color: var(--sidebar-text);
  background:
    repeating-linear-gradient(90deg, transparent 0 23px, oklch(100% 0 0 / 0.018) 23px 24px),
    var(--sidebar);
  border-right: 1px solid oklch(0% 0 0 / 0.12);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  min-height: 36px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--sidebar-text);
  color: var(--sidebar);
}
.brand-mark .i { width: 20px; height: 20px; stroke-width: 2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 14px; font-weight: 650; letter-spacing: .01em; }
.brand-sub { margin-top: 2px; font-size: 12px; color: var(--sidebar-muted); letter-spacing: .12em; }

.book-switch { position: relative; margin-top: 16px; }
.book-switch-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  color: var(--sidebar-text);
  text-align: left;
  background: var(--sidebar-2);
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius-md);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.book-switch-btn:hover { background: var(--sidebar-3); }
.book-glyph {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--sidebar);
  background: oklch(92% 0.035 82);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 650;
}
.book-switch-meta { min-width: 0; flex: 1; }
.book-switch-name {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.book-switch-type {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 12px;
  color: var(--sidebar-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.book-switch-btn > .i { width: 15px; height: 15px; color: var(--sidebar-muted); }

.book-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  display: none;
  padding: 6px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.book-menu.is-open { display: block; }
.book-menu-label { padding: 7px 8px 5px; font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.book-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.book-option:hover { background: var(--surface-2); }
.book-option.is-active { background: var(--primary-soft); color: var(--primary-strong); }
.book-option .book-glyph { width: 26px; height: 26px; font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.book-option small { display: block; color: var(--muted); font-size: 12px; }
.book-option .i { margin-left: auto; width: 14px; color: var(--primary); }

.side-nav { flex: 1; margin-top: 14px; overflow: hidden; }
.nav-group + .nav-group { margin-top: 10px; }
.nav-label {
  padding: 0 10px 4px;
  color: oklch(60% 0.018 165);
  font-size: 12px;
  font-weight: 550;
  letter-spacing: .14em;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  margin-bottom: 1px;
  color: var(--sidebar-muted);
  border-radius: 7px;
  font-size: 12px;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav-item .i { width: 17px; height: 17px; opacity: .9; }
.nav-item:hover { color: var(--sidebar-text); background: var(--sidebar-2); }
.nav-item.is-active {
  color: var(--sidebar-text);
  font-weight: 550;
  background: var(--sidebar-2);
}
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-item.is-active .i { color: oklch(78% 0.08 70); opacity: 1; }
.nav-badge {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  color: var(--sidebar);
  background: oklch(86% 0.06 80);
  font-size: 12px;
  font-weight: 650;
}
.nav-lock { margin-left: auto; color: oklch(62% 0.05 75); }
.nav-lock .i { width: 13px; height: 13px; }

.side-foot { flex: none; padding: 12px 4px 0; border-top: 1px solid var(--sidebar-line); }
.storage-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 6px;
  color: var(--sidebar-muted);
  font-size: 12px;
}
.storage-bar { height: 3px; margin: 0 6px 12px; overflow: hidden; background: var(--sidebar-3); border-radius: 3px; }
.storage-bar span { display: block; width: 48%; height: 100%; background: oklch(72% 0.075 75); border-radius: inherit; }
.side-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 7px;
  border-radius: 8px;
}
.side-user:hover { background: var(--sidebar-2); }
.side-user-meta { min-width: 0; flex: 1; }
.side-user-name { font-size: 12px; font-weight: 550; }
.side-user-role { margin-top: 1px; color: var(--sidebar-muted); font-size: 12px; }
.plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  color: oklch(86% 0.07 80);
  background: oklch(32% 0.04 70 / 0.55);
  border: 1px solid oklch(48% 0.05 75 / 0.5);
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  overflow: hidden;
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
}
.avatar-sm { width: 26px; height: 26px; font-size: 12px; }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar[data-tone="copper"] { color: oklch(45% 0.09 55); background: var(--accent-soft); }
.avatar[data-tone="blue"] { color: oklch(42% 0.09 240); background: var(--info-soft); }
.avatar[data-tone="rose"] { color: oklch(45% 0.12 20); background: var(--danger-soft); }
.avatar[data-tone="olive"] { color: oklch(43% 0.08 120); background: oklch(94% 0.03 120); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -7px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-more { color: var(--muted); background: var(--surface-2); }

/* ---------- 顶栏 ---------- */
.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--topbar-h);
  padding: 0 28px;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.crumb { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12px; color: var(--muted); }
.crumb a { display: inline-flex; align-items: center; min-height: 28px; padding: 0 2px; }
.crumb a:hover { color: var(--text); }
.crumb .sep { color: var(--line-strong); }
.crumb strong { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 550; white-space: nowrap; text-overflow: ellipsis; }
.top-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 252px;
  margin-left: 12px;
}
.top-search .i { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.top-search input {
  width: 100%;
  height: 34px;
  padding: 0 44px 0 34px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.top-search input::placeholder { color: var(--faint); }
.top-search input:focus { outline: none; background: var(--surface); border-color: var(--line-strong); }
.top-search kbd {
  position: absolute;
  right: 7px;
  padding: 1px 5px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.top-divider { width: 1px; height: 22px; margin: 0 5px; background: var(--line); }
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn .i { width: 18px; height: 18px; }
.notice-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border: 1.5px solid var(--surface);
  border-radius: 50%;
}
.top-avatar { margin-left: 3px; }
.mobile-menu, .mobile-brand { display: none; }

/* ---------- 页面容器 ---------- */
.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 32px 56px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.page-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}
.page-head h1 {
  font-size: 28px;
  font-weight: 630;
  line-height: 1.22;
  letter-spacing: -.025em;
  text-wrap: balance;
}
.page-desc { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.head-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.section-link { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; color: var(--muted); font-size: 12px; }
.section-link:hover { color: var(--primary); }
.section-link .i { width: 14px; height: 14px; }
.divider { height: 1px; background: var(--line); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.mt-6 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .i { width: 16px; height: 16px; }
.btn-primary { color: var(--primary-ink); background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-soft { color: var(--primary-strong); background: var(--primary-soft); border-color: transparent; }
.btn-soft:hover { background: var(--primary-soft-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-danger { color: var(--danger); background: transparent; border-color: color-mix(in oklch, var(--danger) 32%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 31px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-sm .i { width: 14px; height: 14px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.link-btn { padding: 0; color: var(--primary); background: none; border: 0; font-size: inherit; font-weight: 500; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.icon-link { display: inline-grid; place-items: center; width: 30px; height: 30px; color: var(--muted); border-radius: 6px; }
.icon-link:hover { color: var(--text); background: var(--surface-2); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { color: var(--text-2); font-size: 12px; font-weight: 500; }
.field-hint { color: var(--faint); font-size: 12px; line-height: 1.5; }
.input, .select, .textarea {
  width: 100%;
  height: 39px;
  padding: 0 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 12px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 13%, transparent);
}
.textarea { height: auto; min-height: 88px; padding: 9px 11px; resize: vertical; line-height: 1.65; }
.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23717a76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .i { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.input-group .input { padding-left: 34px; }
.input-group .suffix { position: absolute; right: 11px; color: var(--faint); font-size: 12px; }
.input-sm { height: 32px; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.checkbox {
  appearance: none;
  width: 24px;
  height: 24px;
  flex: none;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.checkbox:checked {
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E") center / 11px no-repeat;
  border-color: var(--primary);
}
.checkbox:indeterminate {
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E") center / 11px no-repeat;
  border-color: var(--primary);
}
.radio { accent-color: var(--primary); }
.search-input { position: relative; display: flex; align-items: center; }
.search-input .i { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--faint); }
.search-input .input { padding-left: 31px; }

/* ---------- 分段控件 / 标签页 ---------- */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.segmented button, .segmented a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}
.segmented button:hover, .segmented a:hover { color: var(--text); }
.segmented .is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  font-weight: 550;
}
.tabs { display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  font-size: 12px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); font-weight: 550; }
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}
.tab .count { color: var(--faint); font-size: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: 20px; }
.card-pad-sm { padding: 16px; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 0;
}
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 600; line-height: 1.35; }
.card-head .sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 20px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); }
.card-hover { transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card-hover:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

/* ---------- 统计卡 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  position: relative;
  min-width: 0;
  padding: 16px 17px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.kpi-label .i { width: 14px; height: 14px; }
.kpi-value { margin-top: 8px; font-size: 24px; font-weight: 620; line-height: 1.2; letter-spacing: -.035em; white-space: nowrap; }
.kpi-value .unit { margin-right: 2px; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 6px; margin-top: 7px; color: var(--faint); font-size: 12px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 550; }
.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }
.delta .i { width: 12px; height: 12px; }
.kpi-feature {
  color: oklch(95% 0.012 92);
  background:
    repeating-linear-gradient(90deg, transparent 0 23px, oklch(100% 0 0 / 0.022) 23px 24px),
    var(--sidebar);
  border-color: transparent;
}
.kpi-feature .kpi-label, .kpi-feature .kpi-foot { color: oklch(72% 0.02 165); }
.kpi-feature .kpi-value { color: oklch(98% 0 0); }
.kpi-feature .delta-up { color: oklch(79% 0.11 150); }
.kpi-feature .kpi-value .unit { color: oklch(76% 0.02 165); }

/* ---------- 徽标 / 状态 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge .i { width: 12px; height: 12px; }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: color-mix(in oklch, var(--warning) 80%, var(--text)); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-neutral { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.badge-primary { color: var(--primary-strong); background: var(--primary-soft); }
.badge-outline { color: var(--muted); background: transparent; border-color: var(--line-strong); }
.badge-accent { color: color-mix(in oklch, var(--accent) 80%, var(--text)); background: var(--accent-soft); }
.badge-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}
.chip .i { width: 12px; height: 12px; color: var(--faint); }
.chip-accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.chip-primary { color: var(--primary-strong); background: var(--primary-soft); border-color: transparent; }
.tag-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--accent); }
.type-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-radius: 8px;
}
.type-mark .i { width: 17px; height: 17px; }
.type-mark[data-tone="copper"] { color: var(--accent); background: var(--accent-soft); }
.type-mark[data-tone="blue"] { color: var(--info); background: var(--info-soft); }
.type-mark[data-tone="rose"] { color: var(--danger); background: var(--danger-soft); }
.type-mark[data-tone="neutral"] { color: var(--muted); background: var(--surface-2); }
.lock-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--faint);
  font-size: 12px;
}
.lock-note .i { width: 12px; height: 12px; }

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 550;
  text-align: left;
  white-space: nowrap;
}
.table th:first-child { padding-left: 20px; }
.table th:last-child { padding-right: 20px; }
.table td {
  height: 54px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  vertical-align: middle;
}
.table td:first-child { padding-left: 20px; }
.table td:last-child { padding-right: 20px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in oklch, var(--surface-2) 62%, transparent); }
.table .align-right { text-align: right; }
.table .align-center { text-align: center; }
.table .cell-main { color: var(--text); font-size: 12px; font-weight: 500; }
.table .cell-sub { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.table .cell-amount { font-size: 12px; font-weight: 570; white-space: nowrap; }
.table .cell-actions { white-space: nowrap; }
.table .row-link { cursor: pointer; }
.table .row-selected td { background: var(--primary-soft); }
.table-compact td { height: 46px; }
.table-compact th { height: 34px; }
.bill-date-row td {
  height: 34px;
  padding-top: 8px;
  padding-bottom: 7px;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.bill-date-row .day-total { margin-left: 10px; color: var(--faint); font-size: 12px; }
.bill-date-row .day-total b { font-weight: 550; color: var(--text-2); }
.amount-in { color: var(--success); }
.amount-out { color: var(--danger); }
.amount-in::before { content: "+"; margin-right: 1px; font-size: .86em; }
.amount-out::before { content: "−"; margin-right: 1px; font-size: .86em; }
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
}
.page-btn:hover { background: var(--surface-2); color: var(--text); }
.page-btn.is-active { color: var(--primary-strong); background: var(--primary-soft); font-weight: 600; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-size { height: 28px; padding: 0 24px 0 8px; font-size: 12px; }

/* ---------- 进度 / 开关 ---------- */
.progress { height: 6px; overflow: hidden; background: var(--surface-3); border-radius: 6px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width var(--dur-slow) var(--ease); }
.progress.is-warning > span { background: var(--warning); }
.progress.is-danger > span { background: var(--danger); }
.progress-sm { height: 4px; }
.progress-lg { height: 9px; }
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 26px;
  flex: none;
  padding: 0;
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  transition: background var(--dur) var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 1px 3px oklch(20% 0.02 165 / 0.2);
  transition: transform var(--dur) var(--ease);
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.switch-row:last-child { border-bottom: 0; padding-bottom: 0; }
.switch-row:first-child { padding-top: 0; }
.switch-copy { min-width: 0; }
.switch-title { font-size: 12px; font-weight: 500; }
.switch-desc { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---------- 弹层 / 抽屉 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal.is-open { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(15% 0.02 170 / 0.52);
  backdrop-filter: blur(2px);
  animation: fadeIn var(--dur) var(--ease);
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(540px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: panelIn var(--dur-slow) var(--ease);
}
.modal-panel-lg { width: min(760px, 100%); }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 14px;
}
.modal-head h2 { font-size: 20px; font-weight: 620; letter-spacing: -.02em; }
.modal-head p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.modal-body { padding: 8px 24px 20px; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.modal-close { margin: -4px -6px 0 0; }
.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  justify-content: flex-end;
}
.drawer.is-open { display: flex; }
.drawer-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: drawerIn var(--dur-slow) var(--ease);
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 16px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.drawer-foot { padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--line); }
.overlay { position: fixed; inset: 0; z-index: 90; display: none; background: oklch(15% 0.02 170 / 0.4); }
.overlay.is-open { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes drawerIn { from { transform: translateX(28px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 480px);
  padding: 10px 15px;
  color: oklch(96% 0.008 92);
  background: var(--sidebar);
  border: 1px solid oklch(100% 0 0 / 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 12px;
  animation: toastIn var(--dur) var(--ease);
}
.toast .i { width: 16px; height: 16px; color: oklch(80% 0.09 150); }
.toast.is-error .i { color: oklch(76% 0.13 28); }

/* ---------- 空状态 / 提示条 ---------- */
.empty { padding: 48px 24px; text-align: center; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--faint);
  background: var(--surface-2);
  border-radius: 12px;
}
.empty h3 { font-size: 14px; font-weight: 600; }
.empty p { max-width: 320px; margin: 5px auto 0; color: var(--muted); font-size: 12px; }
.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.55;
}
.notice .i { width: 15px; height: 15px; margin-top: 1px; color: var(--muted); }
.notice-warning { background: var(--warning-soft); border-color: transparent; }
.notice-warning .i { color: var(--warning); }
.notice-primary { background: var(--primary-soft); border-color: transparent; }
.notice-primary .i { color: var(--primary); }

/* ---------- 下拉菜单 ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 70;
  display: none;
  min-width: 168px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}
.menu.is-open { display: block; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 0 9px;
  color: var(--text-2);
  background: none;
  border: 0;
  border-radius: 5px;
  font-size: 12px;
  text-align: left;
}
.menu-item:hover { color: var(--text); background: var(--surface-2); }
.menu-item .i { width: 14px; height: 14px; color: var(--muted); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger .i { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  :root { --sidebar-w: 218px; }
  .content { padding: 24px 24px 48px; }
  .top-search { width: 200px; }
  .kpi-value { font-size: 24px; }
}

@media (max-width: 920px) {
  .app { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 110;
    width: 264px;
    transform: translateX(-102%);
    transition: transform var(--dur-slow) var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; }
  .topbar { height: 56px; padding: 0 14px; gap: 8px; }
  .top-search, .crumb, .top-divider, .topbar .btn-primary span { display: none; }
  .topbar .btn-primary { width: 36px; padding: 0; }
  .mobile-menu { display: inline-grid; }
  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 600;
  }
  .mobile-brand .brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--primary); color: var(--primary-ink); }
  .mobile-brand .brand-mark .i { width: 17px; height: 17px; }
  .top-actions { gap: 2px; }
  .content { padding: 18px 16px calc(88px + env(safe-area-inset-bottom)); max-width: 100%; }
  .page-head { flex-direction: column; gap: 14px; margin-bottom: 18px; }
  .page-head h1 { font-size: 24px; }
  .head-actions { width: 100%; padding-top: 0; }
  .head-actions .btn { flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .table-foot { flex-direction: column; align-items: flex-start; gap: 8px; }
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .mnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    color: var(--muted);
    font-size: 12px;
  }
  .mnav-item .i { width: 20px; height: 20px; }
  .mnav-item.is-active { color: var(--primary); font-weight: 550; }
  .mnav-add {
    width: 44px;
    height: 44px;
    margin: -14px auto 4px;
    color: var(--primary-ink);
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 4px 12px color-mix(in oklch, var(--primary) 38%, transparent);
  }
  .mnav-add .i { width: 22px; height: 22px; }
  .toast-stack { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .modal { padding: 12px; align-items: flex-end; }
  .modal-panel { width: 100%; max-height: calc(100vh - 24px); border-radius: 16px 16px 0 0; }
  .modal-foot { border-radius: 0; }
  .drawer-panel { width: 100%; }
}

@media (min-width: 921px) {
  .mobile-bottom-nav { display: none; }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 24px; }
  .page-head h1 { font-size: 24px; }
  .head-actions .btn { min-width: 0; }
  .card-pad { padding: 16px; }
  .card-head { padding: 15px 16px 0; }
  .card-body { padding: 14px 16px 16px; }
  .table-toolbar { padding: 10px 14px; }
  .table th:first-child, .table td:first-child { padding-left: 14px; }
  .table th:last-child, .table td:last-child { padding-right: 14px; }
  .modal-head { padding: 18px 18px 10px; }
  .modal-body { padding: 6px 18px 16px; }
  .modal-foot { padding: 12px 18px; }
}

@media print {
  .sidebar, .topbar, .mobile-bottom-nav, .head-actions, .no-print { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
