:root {
    --brand: #235fa5;
    --brand-2: #2a5a8a;
    --bg: #f4f6fa;
    --line: #e2e8f0;
    --text: #1f2937;
    --muted: #6b7280;
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 208px;
    flex: 0 0 208px;
    background: #16324f;
    color: #cfe0f2;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--brand); color: #fff;
    display: grid; place-items: center;
    font-weight: 700; letter-spacing: .5px;
}
.brand-text { font-weight: 600; font-size: 15px; color: #fff; }

.sidebar nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-group {
    margin: 14px 8px 4px; font-size: 11px; letter-spacing: .1em;
    color: #7fa3c6; text-transform: uppercase;
}
.nav-item {
    display: block; padding: 9px 12px; border-radius: 8px;
    color: #cfe0f2; text-decoration: none; font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 52px; background: #fff; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: flex-end;
    padding: 0 20px;
}
.who { color: var(--muted); }
.badge {
    font-style: normal; background: #e0edff; color: var(--brand);
    border-radius: 999px; padding: 2px 8px; font-size: 12px; margin-left: 6px;
}
.content { padding: 20px 24px 40px; }

h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- 卡片 ---------- */
.cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}
.card {
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 14px 16px;
}
.card-k { color: var(--muted); font-size: 13px; }
.card-v { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--brand-2); }
.card-v.warn { color: var(--warn); }
.card-v small { font-size: 13px; font-weight: 400; margin-left: 2px; }

/* ---------- 表格 ---------- */
.grid {
    width: 100%; border-collapse: collapse; background: #fff;
    border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.grid th, .grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.grid th { background: #f8fafc; font-weight: 600; color: #475569; white-space: nowrap; }
.grid tbody tr:hover { background: #f8fbff; }
.grid td.ops { white-space: nowrap; }

/* ---------- 状态徽标 ---------- */
.st { padding: 2px 9px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.st-PENDING     { background: #e0edff; color: #1d4ed8; }
.st-IN_PROGRESS { background: #fff2dd; color: #b45309; }
.st-COMPLETED   { background: #dcfce7; color: #15803d; }
.st-ABANDONED   { background: #f1f5f9; color: #64748b; }

/* ---------- 控件 ---------- */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 14px; margin-bottom: 14px;
}
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.toolbar input, .toolbar select {
    padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 14px; min-width: 130px; background: #fff; color: var(--text);
}
.btn {
    padding: 7px 14px; border: 1px solid var(--line); background: #fff;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-xs {
    padding: 3px 9px; font-size: 12px; border: 1px solid var(--line);
    background: #fff; border-radius: 5px; cursor: pointer; margin-right: 4px;
}
.btn-xs:hover { border-color: var(--brand); color: var(--brand); }
.btn-xs.danger { color: var(--danger); border-color: #fecaca; }
.btn-xs.danger:hover { background: #fef2f2; }
.btn-xs[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary {
    width: 100%; padding: 10px; border: 0; border-radius: 8px;
    background: var(--brand); color: #fff; font-size: 15px; cursor: pointer;
}
.btn-primary:hover { background: #1b4d88; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }

/* ---------- 提示 ---------- */
.alert-ok, .alert-error {
    padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; white-space: pre-wrap;
}
.alert-ok { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.deny { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; }

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center;
    background: linear-gradient(135deg, #16324f 0%, #235fa5 100%);
}
.login-card {
    width: 340px; background: #fff; border-radius: 14px;
    padding: 30px 28px 26px; box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.login-logo {
    width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 12px;
    background: var(--brand); color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: 18px;
}
.login-card h1 { text-align: center; font-size: 19px; margin: 0 0 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 12px; margin: 0 0 20px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 14px;
}
.field input:focus { outline: none; border-color: var(--brand); }
.login-error {
    background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
    padding: 8px 11px; border-radius: 8px; margin-bottom: 14px; font-size: 13px;
}

/* ---------- 页头 / 录入页 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.page-head h1 { margin: 0; }

.sheet-head {
    display: flex; flex-wrap: wrap; gap: 22px;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 16px; margin-bottom: 14px;
}
.sheet-head .k { color: var(--muted); margin-right: 6px; font-size: 13px; }

table.grid.entry td { padding: 6px 10px; }
.cell-input {
    width: 100%; padding: 6px 8px; border: 1px solid var(--line);
    border-radius: 6px; font-size: 14px;
}
.cell-input:focus { outline: none; border-color: var(--brand); }

.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }

.summary-bar {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 16px; margin-top: 14px; color: var(--muted);
}
.summary-bar .conclusion b { color: var(--brand-2); }

.actions { display: flex; gap: 12px; margin-top: 14px; }
.btn-primary.inline { width: auto; padding: 9px 22px; }
.hint { font-size: 12.5px; line-height: 1.7; margin-top: 12px; }

a.btn-xs { display: inline-block; text-decoration: none; color: var(--text); }
a.btn-xs:hover { border-color: var(--brand); color: var(--brand); }
a.btn { display: inline-block; text-decoration: none; color: var(--text); }

/* ---------- 台账结论徽标 ---------- */
.st-PASS      { background: #dcfce7; color: #15803d; }
.st-FAIL      { background: #fee2e2; color: #b91c1c; }
.st-MARGINAL  { background: #fff2dd; color: #b45309; }
.st-PENDING   { background: #fef9c3; color: #854d0e; }
.st-REVERSED  { background: #f1f5f9; color: #64748b; text-decoration: line-through; }

/* ---------- 复选框标签 ---------- */
.toolbar label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.toolbar input[type="checkbox"] { min-width: auto; }

/* ---------- 表单网格（录入页抬头） ---------- */
.form-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px 16px; background: #fff; border: 1px solid var(--line);
    border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select {
    padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 14px; background: #fff; color: var(--text); width: 100%;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--brand); }
.form-grid input[readonly] { background: #f8fafc; color: var(--brand-2); font-weight: 600; }

label.block { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label.block textarea {
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 14px; font-family: inherit; resize: vertical;
}

/* ---------- 明细面板 / 页签 ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
    padding: 7px 16px; border: 1px solid var(--line); background: #fff;
    border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--text);
}
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 18px; }
.kv div { font-size: 14px; }
.kv .k { color: var(--muted); margin-right: 6px; font-size: 13px; }



