:root {
  color-scheme: dark;
  --bg: #071321;
  --bg-deep: #050e18;
  --panel: #0d1b2b;
  --panel-raised: #101f31;
  --line: #263548;
  --text: #edf2f8;
  --muted: #8f9bab;
  --income: #ffb84f;
  --ok: #8fc56b;
  --assist: #69a7dd;
  --danger: #ff7a70;
  --focus: #a9d4ff;
  --radius: 6px;
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg-deep); }
body { min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; }
button, .button { border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: var(--assist); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.boot, .login-page { display: grid; min-height: 100vh; place-content: center; padding: 24px; }
.boot { color: var(--muted); text-align: center; }
.spinner { width: 26px; height: 26px; margin: 0 auto 12px; border: 3px solid var(--line); border-top-color: var(--assist); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-panel { width: min(100%, 408px); border: 1px solid var(--line); border-top: 2px solid var(--income); background: var(--panel); padding: 30px; box-shadow: 0 20px 60px #0008; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--income); color: var(--income); font-weight: 800; letter-spacing: -1px; }
.brand strong { display: block; letter-spacing: .02em; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.login-panel h1 { margin: 25px 0 6px; font-size: 24px; }
.login-panel p { color: var(--muted); }
.login-panel footer { margin-top: 22px; color: var(--muted); font-size: 12px; }

.app-shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.sidebar { z-index: 4; display: flex; flex-direction: column; width: 228px; padding: 18px 12px; border-right: 1px solid var(--line); background: var(--bg-deep); }
.sidebar .brand { padding: 2px 8px 20px; border-bottom: 1px solid var(--line); }
.nav { display: grid; gap: 3px; padding: 14px 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid transparent; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a[aria-current="page"] { border-color: var(--line); background: var(--panel-raised); color: var(--text); }
.nav-icon { width: 18px; color: var(--assist); font-weight: 700; text-align: center; }
.sidebar-bottom { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--line); }
.account-name { overflow: hidden; margin-bottom: 2px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.role { color: var(--muted); font-size: 12px; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 3; display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 26px; border-bottom: 1px solid var(--line); background: #071321ef; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 20px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }
.content { max-width: 1600px; margin: 0 auto; padding: 24px 26px 42px; }

.page-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.page-head { margin-bottom: 18px; }
.page-head h2, .section-head h3 { margin: 0; }
.page-head h2 { font-size: 18px; }
.section-head h3 { font-size: 15px; }
.page-head p, .section-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.page-grid { display: grid; gap: 16px; }
.section-gap { margin-top: 16px; }
.form-gap { margin-top: 14px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four-col { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel, .kpi { border: 1px solid var(--line); background: var(--panel); }
.panel { padding: 18px; }
.kpi { min-height: 118px; padding: 17px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { margin-top: 8px; font-size: clamp(20px, 2.2vw, 29px); font-variant-numeric: tabular-nums; font-weight: 750; }
.kpi.income .value { color: var(--income); }
.kpi.ok .value { color: var(--ok); }
.kpi.return .value { color: var(--assist); }
.kpi.risk .value { color: var(--danger); }
.kpi .detail { margin-top: 7px; color: var(--muted); font-size: 12px; }

.filters, .form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filters .form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .field-label { color: var(--muted); font-size: 12px; }
input, select { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg-deep); color: var(--text); padding: 8px 10px; }
input::placeholder { color: #677789; }
input:disabled, select:disabled { background: #091522; color: var(--muted); }
.full { grid-column: 1 / -1; }

.button, button { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; background: transparent; color: var(--text); text-decoration: none; white-space: nowrap; }
.button:hover, button:hover { border-color: var(--assist); background: #10283e; }
.button.primary { border-color: #d89739; background: #b8751a; color: #fff; }
.button.primary:hover { background: #d58a20; }
.button.danger { border-color: #914947; color: #ffd2cf; }
.button.danger:hover { background: #3a1c25; border-color: var(--danger); }
.button.ghost { border-color: transparent; color: var(--muted); }
.button.ghost:hover { border-color: var(--line); color: var(--text); }
.button.small { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.button[aria-disabled="true"] { pointer-events: none; opacity: .5; }
.menu-toggle { display: none; }

.notice { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; border: 1px solid var(--line); border-left: 3px solid var(--assist); background: var(--panel-raised); padding: 10px 12px; color: var(--text); }
.notice.error { border-left-color: var(--danger); color: #ffd6d3; }
.notice.success { border-left-color: var(--ok); color: #e1f4d6; }
.notice button { min-height: auto; padding: 0; border: 0; color: inherit; }
.loading { display: flex; min-height: 190px; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.loading .spinner { width: 18px; height: 18px; margin: 0; }
.empty { display: grid; min-height: 150px; place-content: center; gap: 5px; color: var(--muted); text-align: center; }
.empty strong { color: var(--text); font-size: 14px; }

.table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 18px; border-top: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:hover { background: #102034; }
td .row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.income-text { color: var(--income); font-weight: 700; }
.muted { color: var(--muted); }
.status { display: inline-flex; align-items: center; min-height: 23px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; color: var(--muted); font-size: 11px; }
.status.ok { border-color: #52743d; color: var(--ok); }
.status.risk { border-color: #8f4d4c; color: var(--danger); }

.chart { display: flex; min-height: 220px; align-items: end; gap: 10px; padding-top: 22px; border-bottom: 1px solid var(--line); }
.chart-item { display: grid; flex: 1 1 32px; min-width: 28px; align-items: end; gap: 6px; text-align: center; }
.chart-bar { min-height: 3px; background: linear-gradient(180deg, var(--income), #a76018); border: 1px solid #d58c30; }
.chart-bar.level-0 { height: 3px; opacity: .42; }
.chart-bar.level-1 { height: 9px; }.chart-bar.level-2 { height: 17px; }.chart-bar.level-3 { height: 26px; }.chart-bar.level-4 { height: 35px; }.chart-bar.level-5 { height: 44px; }
.chart-bar.level-6 { height: 52px; }.chart-bar.level-7 { height: 61px; }.chart-bar.level-8 { height: 70px; }.chart-bar.level-9 { height: 78px; }.chart-bar.level-10 { height: 87px; }
.chart-bar.level-11 { height: 96px; }.chart-bar.level-12 { height: 105px; }.chart-bar.level-13 { height: 113px; }.chart-bar.level-14 { height: 122px; }.chart-bar.level-15 { height: 131px; }
.chart-bar.level-16 { height: 139px; }.chart-bar.level-17 { height: 148px; }.chart-bar.level-18 { height: 157px; }.chart-bar.level-19 { height: 165px; }.chart-bar.level-20 { height: 174px; }
.chart-label, .chart-value { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.chart-value { color: var(--text); }
.rank-list { display: grid; gap: 1px; }
.rank-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(90px, .45fr); gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rank-number { color: var(--income); font-weight: 750; }
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 6px; overflow: hidden; background: var(--bg-deep); }
.bar-track .bar-fill { display: block; height: 100%; background: var(--assist); }
.bar-fill.level-0 { width: 0; }.bar-fill.level-1 { width: 5%; }.bar-fill.level-2 { width: 10%; }.bar-fill.level-3 { width: 15%; }.bar-fill.level-4 { width: 20%; }.bar-fill.level-5 { width: 25%; }
.bar-fill.level-6 { width: 30%; }.bar-fill.level-7 { width: 35%; }.bar-fill.level-8 { width: 40%; }.bar-fill.level-9 { width: 45%; }.bar-fill.level-10 { width: 50%; }
.bar-fill.level-11 { width: 55%; }.bar-fill.level-12 { width: 60%; }.bar-fill.level-13 { width: 65%; }.bar-fill.level-14 { width: 70%; }.bar-fill.level-15 { width: 75%; }
.bar-fill.level-16 { width: 80%; }.bar-fill.level-17 { width: 85%; }.bar-fill.level-18 { width: 90%; }.bar-fill.level-19 { width: 95%; }.bar-fill.level-20 { width: 100%; }
.comparison { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.comparison .metric { border: 1px solid var(--line); background: var(--bg-deep); padding: 13px; }
.comparison .metric b { display: block; margin-top: 5px; color: var(--income); font-size: 17px; }

.detail-list { display: grid; gap: 0; }
.detail-list > div { display: grid; grid-template-columns: minmax(90px, .35fr) 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); }
.detail-list dd { overflow-wrap: anywhere; margin: 0; }
.form-panel { border-top: 2px solid var(--assist); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; color: var(--muted); font-size: 12px; }
.page-actions { display: flex; gap: 8px; }

@media (max-width: 1040px) {
  .two-col, .three-col, .four-col { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(282px, 86vw); transform: translateX(-105%); transition: transform .18s ease; box-shadow: 20px 0 60px #0008; }
  .app-shell.menu-open .sidebar { transform: translateX(0); }
  .app-shell.menu-open::after { position: fixed; z-index: 3; inset: 0; background: #0008; content: ""; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .topbar h1 { font-size: 16px; }
  .topbar p { display: none; }
  .content { padding: 17px 14px 28px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head > .button { width: 100%; }
  .two-col, .three-col, .four-col, .filters, .form-grid { grid-template-columns: 1fr; }
  .filters .form-actions, .form-actions { justify-content: stretch; }
  .filters .form-actions > *, .form-actions > * { flex: 1 1 auto; }
  .comparison { grid-template-columns: 1fr; }
  .pagination { align-items: stretch; flex-direction: column; }
  .page-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .panel { padding: 14px; }
  .table-wrap { margin: 0 -14px -14px; }
  th, td { padding-left: 14px; padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
