:root {
  --primary: #0f172a;
  --secondary: #1e3a8a;
  --accent: #1677ff;
  --accent-dark: #0958d9;
  --accent-soft: #e8f2ff;
  --background: #f8fafc;
  --card: #ffffff;
  --foreground: #020617;
  --muted: #e8ecf1;
  --muted-foreground: #475569;
  --border: #e2e8f0;
  --success: #15803d;
  --warning: #a16207;
  --danger: #dc2626;
  --ring: #1677ff;
  --sidebar: 260px;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html { background: var(--background); }
body {
  margin: 0;
  color: var(--foreground);
  background:
    radial-gradient(circle at 85% 0%, rgba(30, 58, 138, .06), transparent 28rem),
    var(--background);
  font: 16px/1.5 "Microsoft YaHei", "PingFang SC", "Source Sans 3", sans-serif;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select, input, textarea, a { outline-color: var(--ring); }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(15, 23, 42, .24);
  outline-offset: 2px;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}
.app-shell > .sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
  display: flex; flex-direction: column; gap: 24px; height: auto; padding: 24px 16px;
  background: var(--primary); color: #cbd5e1; border-radius: 0; box-shadow: none;
  overflow: visible; transition: width 180ms ease, padding 180ms ease;
}
.app-shell > .sidebar > .brand { display: flex; align-items: center; gap: 12px; color: white; text-decoration: none; padding: 4px 56px 20px 8px; border-bottom: 1px solid rgba(255,255,255,.12); }
.app-shell > .sidebar > .brand strong { display: block; font-size: 17px; letter-spacing: .02em; }
.app-shell > .sidebar > .brand small { display: block; margin-top: 2px; color: #94a3b8; font-size: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto;
  color: #7dd3fc; border: 1px solid rgba(96,165,250,.5); border-radius: 10px;
  background: rgba(22,119,255,.16);
}
.brand-mark.large { width: 56px; height: 56px; }
.brand-mark.large svg { width: 30px; height: 30px; }
.sidebar-collapse {
  position: absolute; top: 33px; right: 16px; z-index: 2; display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0; border: 1px solid rgba(148,163,184,.34);
  border-radius: 8px; background: rgba(255,255,255,.06); color: #cbd5e1; cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}
.sidebar-collapse:hover { background: rgba(255,255,255,.12); color: white; }
.sidebar-collapse svg { width: 16px; height: 16px; }
html.nav-min .app-shell { grid-template-columns: 64px minmax(0, 1fr); }
html.nav-min .app-shell > .sidebar { width: 64px; padding: 24px 8px; }
html.nav-min .app-shell > .sidebar > .brand { visibility: hidden; }
html.nav-min .sidebar-collapse { right: 17px; transform: rotate(180deg); }
html.nav-min .sidebar nav { padding-right: 0; }
html.nav-min .nav-head {
  display: flex; justify-content: center; width: 48px; min-height: 44px;
  margin: 0 auto; padding: 0;
}
html.nav-min .nav-head > span,
html.nav-min .nav-head .chevron { display: none; }
html.nav-min .nav-sub { display: none !important; }
html.nav-min .sidebar-foot { display: none; }
.sidebar nav {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 4px; overflow-y: auto; padding-right: 2px; scrollbar-width: thin;
}
.nav-section { display: grid; flex: 0 0 auto; align-content: start; gap: 3px; }
.nav-head { align-self: start; height: 44px; }
.nav-head {
  width: 100%; min-height: 44px; display: grid; grid-template-columns: 20px 1fr 18px;
  align-items: center; gap: 10px; padding: 9px 11px; border: 0; border-radius: 9px;
  color: #cbd5e1; background: transparent; text-align: left; font-weight: 600; cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}
.nav-head:hover, .nav-head.active { color: white; background: rgba(255,255,255,.08); }
.nav-head .chevron { width: 16px; height: 16px; transition: transform 180ms ease; }
.nav-section.open .nav-head .chevron { transform: rotate(180deg); }
.nav-sub {
  display: none; grid-template-columns: 1fr; gap: 2px; margin-left: 15px; padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,.12);
}
.nav-section.open .nav-sub { display: grid; }
.sidebar nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 38px; padding: 8px 10px; border-radius: 7px; text-decoration: none;
  color: #b8c3d3; font-size: 13px; font-weight: 500;
  transition: background 180ms ease, color 180ms ease;
}
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255,255,255,.1); }
.sidebar nav a.active { background: rgba(22,119,255,.2); box-shadow: inset 3px 0 #60a5fa; }
.nav-sub .external { width: 14px; height: 14px; opacity: .58; }
.sidebar-foot {
  margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px;
  color: #94a3b8; font-size: 13px; border-top: 1px solid rgba(255,255,255,.1);
}
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: #64748b; }
.status-dot.ok { background: #4ade80; box-shadow: 0 0 0 4px rgba(74,222,128,.12); }
.workspace { grid-column: 2; min-width: 0; }
.workspace > .topbar {
  height: 116px; min-height: 116px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 12px clamp(22px, 3vw, 44px); border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.8); backdrop-filter: blur(14px);
}
.workspace > .topbar h1 { margin: 2px 0 0; font-size: clamp(24px, 2.2vw, 32px); letter-spacing: -.03em; }
.workspace > .topbar .topbar-subtitle { margin: 4px 0 0; color: var(--muted-foreground); font-size: 13px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.workspace > .topbar .user-chip { display: flex; align-items: center; gap: 10px; }
.workspace > .topbar .user-chip span:not(.avatar) { display: grid; }
.workspace > .topbar .user-chip strong { font-size: 14px; }
.workspace > .topbar .user-chip small { color: var(--muted-foreground); font-size: 11px; }
.workspace > .topbar .user-chip a { margin-left: 8px; color: var(--muted-foreground); font-size: 13px; text-decoration: none; }
.workspace > .topbar .user-chip a:hover { color: var(--foreground); }
.workspace > .topbar .avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--muted); color: var(--secondary); font-weight: 800; }
.content { max-width: 1500px; margin: 0 auto; padding: clamp(20px, 3vw, 40px); }
.mobile-menu { display: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
}
.metric-card { padding: 18px 20px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 60px; height: 60px; border-radius: 50%; right: -24px; top: -24px; background: rgba(30,58,138,.06); }
.metric-card span { color: var(--muted-foreground); font-size: 13px; }
.metric-card strong { display: block; margin: 8px 0 4px; font-size: 30px; line-height: 1; letter-spacing: -.04em; }
.metric-card small { color: #64748b; }
.metric-card.attention strong { color: var(--danger); }
.dashboard-grid, .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.settings-wide { grid-column: 1 / -1; }
.panel { padding: 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.02em; }
.amount { color: var(--accent-dark); font-size: 18px; font-weight: 700; }
.integration-list { display: grid; margin-bottom: 18px; }
.integration-list div, .detail-list div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.integration-list div:last-child, .detail-list div:last-child { border-bottom: 0; }
.integration-list span, .detail-list dt { color: var(--muted-foreground); }
.ok { color: var(--success) !important; }
.warn { color: var(--warning) !important; }
.text-link { color: var(--secondary); font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.step-list { list-style: none; display: grid; gap: 12px; padding: 0; margin: 0; }
.step-list li { display: flex; gap: 12px; }
.step-list li > span { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px; background: var(--muted); color: var(--secondary); font-weight: 800; }
.step-list div { display: grid; }
.step-list small { color: var(--muted-foreground); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { padding: 10px 12px; text-align: left; color: var(--muted-foreground); background: #f8fafc; font-size: 12px; letter-spacing: .03em; border-bottom: 1px solid var(--border); }
td { padding: 13px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
td small { display: block; margin-top: 3px; color: var(--muted-foreground); font-size: 11px; }
tbody tr:hover { background: #fbfdff; }
.row-disabled { color: #94a3b8; background: #f8fafc; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 2px 9px; border-radius: 999px; background: #eef2ff; color: var(--secondary); font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.muted { background: var(--muted); color: var(--muted-foreground); }
.badge.ok { background: #dcfce7; color: var(--success); }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.empty-state { display: grid; justify-items: start; gap: 8px; padding: 34px 20px; color: var(--muted-foreground); }
.empty-state strong { color: var(--foreground); }
.empty-state p { margin: 0 0 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-weight: 700; cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary { color: white; background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { color: var(--primary); background: white; border-color: var(--primary); }
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; }
.btn:disabled, button:disabled, select:disabled, input:disabled, textarea:disabled {
  cursor: not-allowed; opacity: .48; transform: none;
}
.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 12px 14px; border-radius: 9px; border: 1px solid var(--border); background: white; }
.flash.error { border-color: #fecaca; color: #991b1b; background: #fef2f2; }
.flash.success { border-color: #bbf7d0; color: #166534; background: #f0fdf4; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .7fr); gap: 18px; align-items: start; }
.form-main, .form-side { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label { display: grid; gap: 7px; color: #334155; font-size: 13px; font-weight: 700; }
label.span-2, fieldset.span-2 { grid-column: span 2; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: white; color: var(--foreground); transition: border-color 180ms ease, box-shadow 180ms ease;
}
textarea { min-height: 108px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(30,58,138,.12); outline: none; }
fieldset { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: 10px; }
legend { padding: 0 6px; color: #334155; font-size: 13px; font-weight: 700; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check-card { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.check-card:has(input:checked) { border-color: var(--secondary); background: #eef2ff; }
.check-card input { width: 18px; min-height: 18px; }
.check-card span { display: grid; }
.check-card small { color: var(--muted-foreground); font-weight: 400; }
.field-note { font-size: 12px; font-weight: 500; }
.danger { color: var(--danger); }
.inline-disabled { padding: 14px; border-radius: 8px; background: #f1f5f9; color: #64748b; }
.gate-list { list-style: none; display: grid; gap: 10px; padding: 0; margin: 18px 0; }
.gate-list li { display: flex; align-items: center; gap: 9px; color: var(--muted-foreground); }
.gate-list li span { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; }
.gate-list li.ok span { background: var(--success); }
.gate-list li.blocked span { background: var(--danger); }
.notice { padding: 13px; border-radius: 9px; }
.notice.warning { border: 1px solid #fde68a; background: #fffbeb; color: #854d0e; }
.notice p { margin: 4px 0 0; color: #92400e; font-size: 13px; }
.form-actions { display: grid; gap: 9px; margin-top: 16px; }
.detail-list { margin: 0; }
.detail-list dd { margin: 0; text-align: right; font-weight: 700; }
.panel-copy { max-width: 760px; margin: 7px 0 0; color: var(--muted-foreground); font-size: 13px; }
.permission-summary { color: var(--secondary); font-weight: 700; }
.permission-summary.muted { color: var(--muted-foreground); }
.user-editor summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  cursor: pointer; list-style: none;
}
.user-editor summary::-webkit-details-marker { display: none; }
.user-editor summary span:first-child { display: grid; gap: 3px; }
.user-editor summary small { color: var(--muted-foreground); font-weight: 400; }
.user-editor[open] summary { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.user-form { padding-top: 18px; display: grid; gap: 16px; }
.user-basic-grid { margin-bottom: 0; }
.permission-fieldset { padding: 16px; }
.permission-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.permission-group { padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: #fbfdff; }
.permission-group > strong { display: block; margin-bottom: 9px; color: var(--secondary); font-size: 13px; }
.permission-options { display: grid; gap: 7px; }
.permission-option {
  display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-weight: 500; color: #334155;
}
.permission-option:hover { background: var(--muted); }
.permission-option input { width: 17px; min-height: 17px; }
.compact-label { max-width: 260px; }
.form-actions.horizontal { display: flex; margin: 0; }
.user-list-table td { vertical-align: middle; }
.table-action-col { width: 120px; text-align: right; white-space: nowrap; }
.table-action-disabled { color: var(--muted-foreground); font-size: 12px; }
.btn-compact { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.app-dialog {
  width: min(960px, calc(100vw - 28px)); max-height: calc(100vh - 28px);
  padding: 0; border: 0; border-radius: 16px; background: transparent;
  color: var(--foreground); box-shadow: 0 28px 90px rgba(2,6,23,.32);
}
.app-dialog::backdrop { background: rgba(15,23,42,.52); backdrop-filter: blur(4px); }
.app-dialog .dialog-card { max-height: calc(100vh - 28px); overflow-y: auto; background: white; border-radius: 16px; }
.app-dialog .dialog-head {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between;
  gap: 18px; padding: 20px 22px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
}
.app-dialog .dialog-head h2 { margin: 4px 0; }
.app-dialog .dialog-head p:last-child { margin: 0; color: var(--muted-foreground); font-size: 13px; }
.app-dialog .dialog-close {
  display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px;
  padding: 0; border: 1px solid var(--border); border-radius: 9px;
  background: white; color: var(--muted-foreground); cursor: pointer;
}
.app-dialog .dialog-close:hover { color: var(--foreground); background: var(--muted); }
.app-dialog .dialog-form { padding: 20px 22px 22px; }
.app-dialog .dialog-actions {
  position: sticky; bottom: -22px; display: flex; justify-content: flex-end; gap: 9px;
  margin: 20px -22px -22px; padding: 14px 22px; border-top: 1px solid var(--border);
  background: rgba(255,255,255,.97);
}

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    linear-gradient(135deg, rgba(15,23,42,.96), rgba(30,58,138,.9)),
    repeating-linear-gradient(45deg, transparent 0 28px, rgba(255,255,255,.03) 28px 29px);
}
.login-card { width: min(460px, 100%); padding: 34px; border-radius: 18px; background: white; box-shadow: 0 24px 80px rgba(2,6,23,.35); }
.login-brand { display: grid; gap: 8px; margin-bottom: 26px; }
.login-brand h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.login-brand > p:last-child { margin: 0; color: var(--muted-foreground); }
.login-form { display: grid; gap: 16px; }
.login-form .btn { width: 100%; margin-top: 4px; }
.login-remember { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: -4px; }
label.login-remember-item {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted-foreground); font-size: 13px; font-weight: 500; cursor: pointer;
}
label.login-remember-item input {
  width: 15px; height: 15px; min-height: 0; margin: 0; padding: 0;
  flex: none; accent-color: var(--accent); cursor: pointer;
}
.form-error { margin: 0; color: var(--danger); font-size: 13px; }
.login-note { margin: 22px 0 0; color: #64748b; font-size: 12px; }

@media (max-width: 1024px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-layout { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .workspace > .topbar .user-chip span:not(.avatar),
  .workspace > .topbar .user-chip a { display: none; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .app-shell > .sidebar { transform: translateX(-100%); transition: transform 200ms ease; box-shadow: 20px 0 40px rgba(2,6,23,.25); }
  .app-shell > .sidebar.open { transform: translateX(0); }
  .workspace { display: block; }
  html.nav-min .app-shell { display: block; }
  html.nav-min .app-shell > .sidebar {
    width: var(--sidebar); padding: 24px 16px;
  }
  html.nav-min .app-shell > .sidebar > .brand { visibility: visible; }
  html.nav-min .nav-head {
    display: grid; width: 100%; margin: 0; padding: 9px 11px;
    grid-template-columns: 20px 1fr 18px;
  }
  html.nav-min .nav-head > span,
  html.nav-min .nav-head .chevron { display: initial; }
  html.nav-min .nav-section.open .nav-sub { display: grid; }
  html.nav-min .sidebar-foot { display: flex; }
  .sidebar-collapse { display: none; }
  .mobile-menu {
    display: grid; place-items: center; position: fixed; z-index: 30; top: 16px; left: 16px;
    width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 10px;
    background: white; color: var(--foreground); box-shadow: var(--shadow); cursor: pointer;
  }
  .workspace > .topbar { height: auto; padding-left: 74px; min-height: 82px; }
  .content { padding: 16px; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .form-grid, .check-grid { grid-template-columns: 1fr; }
  .permission-groups { grid-template-columns: 1fr; }
  .app-dialog { width: calc(100vw - 18px); }
  .app-dialog .dialog-actions { bottom: -22px; }
  label.span-2, fieldset.span-2 { grid-column: span 1; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .workspace > .topbar h1 { font-size: 22px; }
  .login-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* 资金台账 */
.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 4px 0 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.filter-bar label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted-foreground); }
.filter-bar select, .filter-bar input { min-width: 160px; }
.filter-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.chip { display: inline-flex; margin: 2px 4px 2px 0; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--secondary); font-size: 12px; font-weight: 600; }
.muted { color: var(--muted-foreground); }
.balance-positive { color: var(--success); font-weight: 700; }
.balance-negative { color: var(--danger); font-weight: 700; }
.check-line { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; }
.notice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.notice-item { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.notice-item.unread { border-color: #bfdbfe; background: #f8fbff; }
.notice-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 999px; background: #cbd5e1; }
.notice-item.unread .notice-dot { background: var(--accent); }
.notice-item strong { display: block; font-size: 14px; }
.notice-item p { margin: 4px 0; color: var(--muted-foreground); font-size: 13px; }
.notice-item small { color: #94a3b8; font-size: 12px; }
