:root{
  --bg:#f4f6fa; --card:#fff; --ink:#0f172a; --ink-2:#475569; --ink-3:#94a3b8;
  --line:#e5e9f0; --brand:#1e3a8a; --accent:#2563eb; --ok:#16a34a; --warn:#f59e0b; --bad:#dc2626;
  --side:#0b1220; --side-2:#131c2e; --radius:10px;
  --shadow:0 1px 2px rgba(15,23,42,.04), 0 8px 24px -12px rgba(15,23,42,.18);
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:"Microsoft YaHei","PingFang SC","Hiragino Sans GB","Segoe UI",system-ui,sans-serif;
  background:var(--bg); color:var(--ink); font-size:14px; -webkit-font-smoothing:antialiased;
}
.hidden{display:none !important}
button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}
button{cursor:pointer;border:none;background:none}
a{color:var(--accent);text-decoration:none}

/* ---------------- boot ---------------- */
.boot{position:fixed;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;background:#fff;z-index:99;color:var(--ink-2)}
.boot-spin{width:34px;height:34px;border-radius:50%;border:3px solid #e2e8f0;border-top-color:var(--accent);animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------------- auth ---------------- */
.auth{min-height:100vh;display:grid;grid-template-columns:1.05fr .95fr}
.auth-left{background:
  radial-gradient(1000px 600px at 10% 0%,#1d4ed8 0%,transparent 55%),
  radial-gradient(800px 500px at 90% 100%,#0ea5e9 0%,transparent 50%),
  linear-gradient(160deg,#0b1220,#101c33 70%,#0b1220);
  color:#e2e8f0;padding:56px 60px;display:flex;flex-direction:column;justify-content:space-between;position:relative;overflow:hidden}
.auth-left:before{content:"";position:absolute;width:520px;height:520px;border:1px solid rgba(255,255,255,.08);border-radius:50%;right:-160px;top:-120px}
.auth-left:after{content:"";position:absolute;width:320px;height:320px;border:1px solid rgba(255,255,255,.06);border-radius:50%;right:-60px;top:-20px}
.auth-logo{display:flex;align-items:center;gap:12px;font-weight:700;letter-spacing:.5px}
.auth-logo i{width:38px;height:38px;border-radius:9px;background:linear-gradient(135deg,#3b82f6,#0ea5e9);display:grid;place-items:center;font-style:normal;color:#fff;font-weight:800}
.auth-left h1{font-size:34px;line-height:1.35;margin:28px 0 14px;font-weight:800;letter-spacing:.5px}
.auth-left p.lead{color:#94a3b8;line-height:1.9;max-width:460px}
.auth-quote{margin-top:34px;border-left:3px solid #38bdf8;padding-left:16px;color:#cbd5e1;line-height:1.9;font-size:13px}
.auth-stats{display:flex;gap:36px;margin-top:34px}
.auth-stats div span{display:block;font-size:12px;color:#7f8ea3;margin-top:4px}
.auth-stats div strong{font-size:22px;letter-spacing:.5px}
.auth-right{display:flex;align-items:center;justify-content:center;padding:40px;background:#fff}
.auth-box{width:100%;max-width:380px}
.auth-box h2{font-size:22px;margin-bottom:6px}
.auth-box .sub{color:var(--ink-3);margin-bottom:26px;font-size:13px}
.field{margin-bottom:16px}
.field label{display:block;font-size:12.5px;color:var(--ink-2);margin-bottom:6px;font-weight:600}
.field input,.field select,.field textarea{width:100%;padding:11px 12px;border:1px solid var(--line);border-radius:8px;background:#fbfcfe;transition:.15s}
.field input:focus,.field select:focus,.field textarea:focus{outline:none;border-color:#93c5fd;background:#fff;box-shadow:0 0 0 3px rgba(37,99,235,.12)}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 16px;border-radius:8px;font-weight:600;transition:.15s;white-space:nowrap}
.btn-primary{background:var(--accent);color:#fff}
.btn-primary:hover{background:#1d4ed8}
.btn-primary:disabled{background:#93b4f5;cursor:not-allowed}
.btn-ghost{background:#f1f5f9;color:var(--ink-2)}
.btn-ghost:hover{background:#e6ecf4}
.btn-danger{background:#fee2e2;color:#b91c1c}
.btn-sm{padding:6px 10px;font-size:12.5px;border-radius:6px}
.btn-block{width:100%}
.msg{font-size:12.5px;padding:9px 11px;border-radius:7px;margin-bottom:14px;line-height:1.6}
.msg.err{background:#fef2f2;color:#b91c1c;border:1px solid #fecaca}
.msg.ok{background:#f0fdf4;color:#15803d;border:1px solid #bbf7d0}
.auth-foot{margin-top:18px;font-size:12px;color:var(--ink-3);text-align:center;line-height:1.8}
.link-btn{color:var(--accent);font-size:12.5px;font-weight:600}

/* ---------------- shell ---------------- */
.shell{display:grid;grid-template-columns:238px 1fr;min-height:100vh}
.sidebar{background:linear-gradient(180deg,var(--side),#0d1526);color:#cbd5e1;display:flex;flex-direction:column;position:sticky;top:0;height:100vh}
.brand{display:flex;align-items:center;gap:11px;padding:20px 18px;border-bottom:1px solid rgba(255,255,255,.06)}
.brand-mark{width:34px;height:34px;border-radius:9px;background:linear-gradient(135deg,#3b82f6,#0ea5e9);display:grid;place-items:center;font-weight:800;color:#fff;font-size:16px;flex:none}
.brand-text strong{display:block;font-size:13.5px;color:#fff;letter-spacing:.4px}
.brand-text span{font-size:11.5px;color:#64748b}
nav{padding:12px 10px;overflow-y:auto;flex:1}
.nav-group{margin-bottom:14px}
.nav-group>p{font-size:10.5px;letter-spacing:1.4px;color:#475569;padding:6px 10px;font-weight:700}
.nav-item{display:flex;align-items:center;gap:9px;padding:9px 11px;border-radius:8px;color:#94a3b8;font-size:13px;margin-bottom:2px;transition:.15s;width:100%;text-align:left}
.nav-item:hover{background:rgba(255,255,255,.05);color:#e2e8f0}
.nav-item.active{background:linear-gradient(90deg,rgba(37,99,235,.28),rgba(37,99,235,.06));color:#fff;box-shadow:inset 2px 0 0 #3b82f6}
.nav-item .ico{width:16px;text-align:center;opacity:.9}
.nav-item .badge{margin-left:auto;font-size:10px;background:rgba(148,163,184,.18);padding:1px 6px;border-radius:20px;color:#cbd5e1}
.side-close{display:none;position:absolute;right:10px;top:12px;width:28px;height:28px;border-radius:7px;color:#94a3b8;background:rgba(255,255,255,.06);z-index:2}
.backdrop{display:none;position:fixed;inset:0;background:rgba(15,23,42,.5);z-index:55}
.backdrop.show{display:block}
.sidebar-foot{padding:14px 18px;border-top:1px solid rgba(255,255,255,.06);font-size:11.5px;color:#64748b;line-height:1.7}
.sidebar-foot .unit-name{color:#94a3b8}
.main{display:flex;flex-direction:column;min-width:0}
.topbar{height:60px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:18px;padding:0 22px;position:sticky;top:0;z-index:20}
.icon-btn{width:32px;height:32px;border-radius:7px;display:none;place-items:center;color:var(--ink-2);background:#f1f5f9}
.period{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--ink-3)}
.period select{padding:6px 10px;border:1px solid var(--line);border-radius:7px;background:#fbfcfe;font-weight:600;color:var(--ink)}
.filters{display:flex;align-items:center;gap:6px;padding-left:14px;border-left:1px solid var(--line)}
.filters .f-label{font-size:11.5px;color:var(--ink-3);margin-left:6px;white-space:nowrap}
.filters select{padding:6px 9px;border:1px solid var(--line);border-radius:7px;background:#fbfcfe;color:var(--ink);font-size:12.5px;max-width:150px}
.filters select:disabled{background:#f1f5f9;color:#94a3b8;cursor:not-allowed}
.scope-chip{font-size:11.5px;padding:3px 9px;border-radius:20px;background:#eff6ff;color:#1d4ed8;font-weight:600;white-space:nowrap}
.badge-warn{display:inline-block;font-size:10.5px;padding:1.5px 7px;border-radius:5px;background:#fef3c7;color:#b45309;font-weight:600}
.top-right{margin-left:auto;display:flex;align-items:center;gap:12px}
.pill{font-size:11.5px;padding:4px 10px;border-radius:20px;background:#f1f5f9;color:var(--ink-2);font-weight:600}
.pill.open{background:#eff6ff;color:#1d4ed8}
.pill.locked{background:#fef2f2;color:#b91c1c}
.pill.submitted{background:#f0fdf4;color:#15803d}
.user-chip{display:flex;align-items:center;gap:9px;padding:5px 10px 5px 5px;border-radius:24px;background:#f8fafc;border:1px solid var(--line);cursor:pointer}
.avatar{width:27px;height:27px;border-radius:50%;display:grid;place-items:center;color:#fff;font-size:12px;font-weight:700;flex:none}
.user-chip b{font-size:12.5px;font-weight:600}
.user-chip small{display:block;font-size:10.5px;color:var(--ink-3)}

.content{padding:22px;overflow-x:auto;flex:1}

/* ---------------- common ---------------- */
.page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:18px;flex-wrap:wrap}
.page-head h2{font-size:19px;letter-spacing:.3px}
.page-head p{color:var(--ink-3);font-size:12.5px;margin-top:5px}
.head-actions{display:flex;gap:8px;flex-wrap:wrap}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.card-head{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--line)}
.card-head h3{font-size:13.5px;letter-spacing:.3px}
.card-head .sub{font-size:11.5px;color:var(--ink-3);font-weight:400;margin-left:6px}
.card-body{padding:16px}
.grid{display:grid;gap:14px}
.g6{grid-template-columns:repeat(6,1fr)}
.g4{grid-template-columns:repeat(4,1fr)}
.g3{grid-template-columns:repeat(3,1fr)}
.g2{grid-template-columns:repeat(2,1fr)}
.g21{grid-template-columns:2fr 1fr}
.g12{grid-template-columns:1fr 2fr}
.num{font-variant-numeric:tabular-nums;font-feature-settings:"tnum"}

.kpi{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:14px 15px;box-shadow:var(--shadow);position:relative;overflow:hidden}
.kpi:before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--accent)}
.kpi.g:before{background:var(--ok)} .kpi.w:before{background:var(--warn)} .kpi.b:before{background:var(--bad)}
.kpi .k-label{font-size:12px;color:var(--ink-3);display:flex;justify-content:space-between;align-items:center}
.kpi .k-val{font-size:23px;font-weight:700;letter-spacing:-.4px;margin:7px 0 3px;font-variant-numeric:tabular-nums}
.kpi .k-sub{font-size:11.5px;color:var(--ink-3)}
.kpi .k-sub b{color:var(--ink-2)}
.up{color:var(--ok);font-weight:600} .down{color:var(--bad);font-weight:600}

table.tbl{width:100%;border-collapse:separate;border-spacing:0;font-size:12.5px}
table.tbl th{background:#f8fafc;color:var(--ink-2);font-weight:600;text-align:right;padding:9px 10px;border-bottom:1px solid var(--line);white-space:nowrap;font-size:11.5px}
table.tbl th:first-child,table.tbl td:first-child{text-align:left}
table.tbl td{padding:8px 10px;border-bottom:1px solid #f1f5f9;text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
table.tbl td.txt{text-align:left}
table.tbl tbody tr:hover{background:#fafcff}
table.tbl th.sticky,table.tbl td.sticky{position:sticky;background:#fff;z-index:2}
table.tbl th.sticky{background:#f8fafc;z-index:3}
table.tbl tr.group-sep td{border-top:1px solid #dbe3ee}
.muted{color:var(--ink-3)}
.tag{display:inline-block;font-size:10.5px;padding:1.5px 7px;border-radius:5px;background:#f1f5f9;color:var(--ink-2);font-weight:600}
.tag.ledger{background:#ecfdf5;color:#047857}
.tag.manual{background:#eff6ff;color:#1d4ed8}
.tag.empty{background:#f8fafc;color:#94a3b8}
.empty-state{padding:40px;text-align:center;color:var(--ink-3);font-size:13px}
.spinner{width:18px;height:18px;border:2px solid #e2e8f0;border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite;display:inline-block}

/* ---------------- statement ---------------- */
.stmt-wrap{overflow:auto;max-height:calc(100vh - 210px);border-radius:var(--radius);background:#fff;border:1px solid var(--line)}
table.stmt{border-collapse:separate;border-spacing:0;font-size:11.6px;min-width:1080px;width:100%}
table.stmt thead th{position:sticky;top:0;background:#0f172a;color:#fff;font-weight:600;font-size:10.6px;padding:8px 5px;text-align:right;z-index:5;white-space:nowrap;border-right:1px solid rgba(255,255,255,.06)}
table.stmt thead th:first-child,table.stmt thead th:nth-child(2),table.stmt thead th:nth-child(3){text-align:left}
table.stmt td{padding:5px;border-bottom:1px solid #f1f5f9;text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums;background:#fff}
table.stmt td.t{text-align:left}
table.stmt td.c{text-align:center}
table.stmt tr:hover td{background:#f8fbff}
table.stmt td.st1,table.stmt th.st1{position:sticky;left:0;z-index:3;background:#fff}
table.stmt td.st2,table.stmt th.st2{position:sticky;left:42px;z-index:3;background:#fff}
table.stmt td.st3,table.stmt th.st3{position:sticky;left:150px;z-index:3;background:#fff;box-shadow:2px 0 0 #eef2f7;text-align:left}
table.stmt thead th.st1,table.stmt thead th.st2,table.stmt thead th.st3{background:#0f172a;z-index:6}
table.stmt tr.hl td{background:#fffbeb;font-weight:700}
table.stmt tr.hl:hover td{background:#fff7e0}
table.stmt tr.neg td.pos{color:var(--bad)}
table.stmt td .grp{writing-mode:vertical-rl;text-orientation:upright;letter-spacing:2px;font-size:10.5px;font-weight:700;color:#64748b;text-align:center;margin:0 auto}
table.stmt td input.cell-in{width:88px;padding:4px 6px;border:1px solid #cbd5e1;border-radius:5px;text-align:right;background:#fff;font-size:12px;font-variant-numeric:tabular-nums}
table.stmt td input.cell-in:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 2px rgba(37,99,235,.15)}
table.stmt td input.cell-in.dirty{background:#fffbeb;border-color:var(--warn)}
.share-bar{display:inline-block;height:4px;border-radius:3px;background:#93c5fd;vertical-align:middle;margin-right:4px}
.save-bar{background:#0f172a;color:#fff;padding:10px 16px;display:flex;align-items:center;gap:14px;border-radius:0 0 var(--radius) var(--radius);font-size:12.5px;margin-top:-6px}
.save-bar .grow{flex:1;color:#94a3b8}

/* ---------------- ledger ---------------- */
.ledger-sum{display:flex;gap:26px;padding:12px 16px;background:linear-gradient(90deg,#f8fbff,#fff);border-bottom:1px solid var(--line);align-items:center}
.ledger-sum div span{font-size:11.5px;color:var(--ink-3);display:block}
.ledger-sum div b{font-size:18px;font-variant-numeric:tabular-nums}
.ledger-table{overflow:auto;max-height:calc(100vh - 300px)}
.ledger-table table{width:100%;border-collapse:collapse;font-size:12.5px}
.ledger-table th{position:sticky;top:0;background:#f8fafc;text-align:left;padding:9px 10px;border-bottom:1px solid var(--line);font-weight:600;color:var(--ink-2);font-size:11.5px;white-space:nowrap}
.ledger-table td{padding:8px 10px;border-bottom:1px solid #f1f5f9;white-space:nowrap}
.ledger-table td.n{text-align:right;font-variant-numeric:tabular-nums}
.ledger-table tr:hover td{background:#fafcff}
.row-actions{display:flex;gap:6px;opacity:.35;transition:.15s}
tr:hover .row-actions{opacity:1}

/* ---------------- modal ---------------- */
.modal{position:fixed;inset:0;background:rgba(15,23,42,.45);display:flex;align-items:center;justify-content:center;z-index:80;padding:20px;backdrop-filter:blur(2px)}
.modal-box{background:#fff;border-radius:12px;width:100%;max-width:560px;max-height:88vh;overflow:auto;box-shadow:0 24px 60px -12px rgba(15,23,42,.4)}
.modal-box.wide{max-width:860px}
.modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 18px;border-bottom:1px solid var(--line)}
.modal-head h3{font-size:15px}
.modal-body{padding:18px}
.modal-foot{display:flex;justify-content:flex-end;gap:8px;padding:14px 18px;border-top:1px solid var(--line);background:#fbfcfe}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px 14px}
.form-grid .full{grid-column:1/-1}

.toast{position:fixed;left:50%;bottom:34px;transform:translateX(-50%);background:#0f172a;color:#fff;padding:11px 20px;border-radius:9px;font-size:13px;z-index:120;box-shadow:0 12px 30px -8px rgba(0,0,0,.4)}
.toast.err{background:#b91c1c} .toast.ok{background:#166534}

/* ---------------- charts ---------------- */
.chart{width:100%;height:auto;display:block;overflow:visible}
.legend{display:flex;gap:16px;flex-wrap:wrap;font-size:11.5px;color:var(--ink-2);margin-top:8px}
.legend i{width:9px;height:9px;border-radius:3px;display:inline-block;margin-right:5px}
.donut-wrap{display:flex;align-items:center;gap:18px;flex-wrap:wrap}
.donut-legend{flex:1;min-width:170px}
.donut-legend div{display:flex;justify-content:space-between;font-size:12px;padding:4px 0;border-bottom:1px dashed #f1f5f9}
.donut-legend div span:first-child{color:var(--ink-2)}
.donut-legend div b{font-variant-numeric:tabular-nums}

/* ---------------- analysis ---------------- */
.finding{display:flex;gap:12px;padding:13px 15px;border:1px solid var(--line);border-radius:9px;background:#fff;margin-bottom:10px}
.finding .dot{width:8px;height:8px;border-radius:50%;margin-top:6px;flex:none}
.finding h4{font-size:13px;margin-bottom:4px}
.finding p{font-size:12.5px;color:var(--ink-2);line-height:1.75}
.lvl-good .dot{background:var(--ok)} .lvl-warn .dot{background:var(--warn)} .lvl-bad .dot{background:var(--bad)} .lvl-info .dot{background:#3b82f6}
.action-list{counter-reset:a;list-style:none}
.action-list li{position:relative;padding:9px 0 9px 30px;border-bottom:1px dashed #eef2f7;font-size:12.8px;line-height:1.7;color:var(--ink-2)}
.action-list li:before{counter-increment:a;content:counter(a);position:absolute;left:0;top:9px;width:20px;height:20px;border-radius:6px;background:#eff6ff;color:#1d4ed8;font-size:11px;font-weight:700;display:grid;place-items:center}

/* ---------------- misc ---------------- */
.kv{display:flex;justify-content:space-between;padding:7px 0;border-bottom:1px dashed #f1f5f9;font-size:12.5px}
.kv span{color:var(--ink-2)} .kv b{font-variant-numeric:tabular-nums}
.progress{height:5px;border-radius:4px;background:#eef2f7;overflow:hidden}
.progress i{display:block;height:100%;background:var(--accent);border-radius:4px}
.tips{font-size:12px;color:var(--ink-3);line-height:1.8;background:#f8fafc;border:1px dashed #e2e8f0;border-radius:8px;padding:10px 12px}
.role-badge{font-size:10.5px;padding:2px 7px;border-radius:5px;color:#fff;font-weight:600}
.copy-box{font-family:Consolas,monospace;background:#0f172a;color:#7dd3fc;padding:10px 12px;border-radius:7px;font-size:13px;letter-spacing:1px}

@media (max-width:1280px){
  .g6{grid-template-columns:repeat(3,1fr)}
  .g4{grid-template-columns:repeat(2,1fr)}
}
@media (max-width:980px){
  .shell{grid-template-columns:1fr}
  .sidebar{position:fixed;left:0;top:0;bottom:0;width:250px;z-index:60;transform:translateX(-100%);transition:.22s;box-shadow:0 0 40px rgba(0,0,0,.3)}
  .sidebar.open{transform:none}
  .side-close{display:grid;place-items:center}
  .icon-btn{display:grid}
  .auth{grid-template-columns:1fr}
  .auth-left{display:none}
  .g6,.g4,.g3,.g2,.g21,.g12{grid-template-columns:1fr}
  .content{padding:14px}
  .form-grid{grid-template-columns:1fr}
  .topbar{flex-wrap:wrap;padding:8px 10px;gap:6px;height:auto;row-gap:6px}
  .period{gap:6px;white-space:nowrap;font-size:11.5px;order:1}
  .period label{display:none}
  .period select{padding:5px 6px;font-size:11.5px;max-width:78px}
  .top-right{order:2;margin-left:auto;gap:6px}
  .filters{order:3;flex:1 0 100%;border-left:none;padding-left:0;gap:6px;max-width:none;overflow:visible;min-width:0}
  .filters .f-label{display:inline}
  .filters select{flex:1 1 0;min-width:0;max-width:none;font-size:12px;padding:5px 8px}
  .top-right{gap:8px}
  #periodStatus{display:none}
  .user-chip{padding:0;border:none;background:none}
  .user-chip>span:not(.avatar){display:none}
  .icon-btn.menu-toggle{flex:none;font-size:15px;line-height:1}
  .page-head{margin-bottom:14px}
  .page-head h2{font-size:17px}
  .page-head p{font-size:12px;line-height:1.7}
  .kpi .k-val{font-size:20px}
  .stmt-wrap{max-height:calc(100vh - 260px)}
  .save-bar{position:sticky;bottom:0;flex-wrap:wrap;font-size:12px}
  .tips{font-size:11.5px;line-height:1.85}
}
