* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, "Microsoft YaHei", sans-serif; background: #f5f7fb; color: #1f2937; }
a { color: #1f5fbf; text-decoration: none; }
input, select, textarea, button { font: inherit; }
.shell { min-height: 100vh; display: flex; }
.sidebar { width: 220px; background: #172033; color: #fff; padding: 24px 18px; }
.brand { font-size: 22px; font-weight: 700; margin-bottom: 24px; }
.userbox { padding: 12px; background: rgba(255,255,255,.08); border-radius: 8px; margin-bottom: 22px; }
.userbox span { display: block; color: #b8c2d6; font-size: 13px; margin-top: 5px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar a { color: #dbe6ff; padding: 10px 12px; border-radius: 6px; }
.sidebar a:hover { background: rgba(255,255,255,.1); }
.main { flex: 1; padding: 28px; overflow-x: auto; }
.login-main { width: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: #fff; padding: 34px; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 10px 28px rgba(20, 32, 52, .08); }
.install-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.install-card { width: min(760px, 100%); background: #fff; padding: 30px; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 10px 28px rgba(20, 32, 52, .08); }
h1 { margin: 0 0 8px; font-size: 26px; }
h2 { margin: 0 0 16px; font-size: 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.actions { display: flex; gap: 10px; }
.button, button { border: 1px solid #cbd5e1; background: #fff; color: #1f2937; padding: 9px 14px; border-radius: 6px; cursor: pointer; }
.primary, button.primary { background: #1f5fbf; border-color: #1f5fbf; color: #fff; }
.link { border: 0; padding: 0; background: transparent; color: #1f5fbf; }
.danger { color: #c2410c; }
.alert { padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; background: #e8f2ff; color: #184a88; }
.alert.danger { background: #fff0ed; color: #9a3412; }
.panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 18px; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; overflow-y: visible; padding: 0; }
.table-fixed-scroll { position: fixed; left: 220px; right: 0; bottom: 0; z-index: 50; height: 18px; overflow-x: auto; overflow-y: hidden; background: #f8fafc; border-top: 1px solid #d8dee8; }
.table-fixed-scroll-spacer { height: 1px; }
.ledger-table { min-width: 1840px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.ledger-table th, .ledger-table td { border: 0; color: #111827; text-align: center; vertical-align: top; line-height: 1.55; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.ledger-table th { background: #f8fafc; font-weight: 700; border-bottom: 1px solid #b8c2d2; border-right: 1px solid #cbd5e1; }
.ledger-table td { border-bottom: 1px solid #d6dde8; border-right: 1px solid #d6dde8; }
.ledger-table th:last-child, .ledger-table td:last-child { border-right: 0; }
.ledger-table tbody tr:hover { background: #f8fbff; }
.ledger-table td:nth-child(9), .ledger-table td:nth-child(11), .ledger-table td:nth-child(12) { text-align: left; }
.ledger-table th:nth-child(1) { width: 48px; }
.ledger-table th:nth-child(2) { width: 56px; }
.ledger-table th:nth-child(3) { width: 150px; }
.ledger-table th:nth-child(4), .ledger-table th:nth-child(5), .ledger-table th:nth-child(6), .ledger-table th:nth-child(10) { width: 120px; }
.ledger-table th:nth-child(7), .ledger-table th:nth-child(8) { width: 150px; }
.ledger-table th:nth-child(9) { width: 310px; }
.ledger-table th:nth-child(11) { width: 420px; }
.ledger-table th:nth-child(12) { width: 180px; }
.ledger-table th:nth-child(13) { width: 160px; }
.ledger-table th:nth-child(14) { width: 150px; }
.ledger-table td:nth-child(9), .ledger-table td:nth-child(11), .ledger-table td:nth-child(12) { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.select-cell { text-align: center; vertical-align: middle; }
.select-cell input { width: 16px; height: 16px; }
.case-closed td { color: #15803d; background: #f0fdf4; }
.case-closed a { color: #15803d; }
.closed-text { color: #15803d; }
.closed-badge { display: inline-flex; margin-left: 6px; padding: 2px 7px; border-radius: 999px; background: #dcfce7; color: #15803d; font-size: 12px; font-weight: 700; white-space: nowrap; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics div { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 18px; }
.metrics strong { display: block; font-size: 30px; }
.metrics span { color: #64748b; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px; margin-bottom: 18px; }
.filters input, .filters select, .form input, .form select, .form textarea, .login-card input { width: 100%; border: 1px solid #cbd5e1; border-radius: 6px; padding: 9px 10px; background: #fff; }
.filters input, .filters select { width: auto; min-width: 150px; }
.form { display: grid; gap: 14px; max-width: 760px; }
.form label, .login-card label { display: grid; gap: 7px; color: #475569; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #eef2f7; padding: 12px 10px; text-align: left; vertical-align: top; }
th { color: #475569; font-size: 13px; background: #f8fafc; }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; background: #eef2ff; color: #334155; font-size: 12px; }
.tag.ok { background: #dcfce7; color: #166534; }
.tag.warn { background: #fef3c7; color: #92400e; }
.muted { color: #64748b; max-width: 360px; }
.row-actions { display: flex; gap: 12px; align-items: center; }
.row-actions form { margin: 0; }
.table-actions { display: flex; align-items: center; justify-content: center; gap: 10px; white-space: nowrap; }
.table-actions form { margin: 0; }
.hint { color: #64748b; font-size: 13px; align-self: center; }
.detail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.ledger-detail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ledger-detail div { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px; }
.detail span { display: block; color: #64748b; font-size: 13px; margin-bottom: 4px; }
.timeline { border-left: 3px solid #dbeafe; padding: 0 0 16px 14px; margin-left: 4px; }
.timeline .time { color: #64748b; font-size: 13px; margin-bottom: 6px; }
.timeline p { margin: 0 0 8px; white-space: normal; line-height: 1.6; }
.meta { display: flex; gap: 10px; align-items: center; color: #64748b; font-size: 13px; }
@media (max-width: 840px) {
    .shell { display: block; }
    .sidebar { width: auto; }
    .table-fixed-scroll { left: 0; }
    .metrics, .grid-two, .detail { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; flex-direction: column; }
}
