:root {
  --bg: #f6f7f9; --card: #fff; --line: #e3e6eb; --text: #1f2329; --muted: #646a73;
  --accent: #1f5fbf; --accent-bg: #e8f0fc;
  --p0: #e8f5e9; --p1: #eef3ff; --p2: #fff6e0; --p3: #fde8e6; --p4: #3a1414;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
.top { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 24px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.logo { color: var(--accent); font-size: 22px; }
.name { font-weight: 600; font-size: 16px; }
.sub { color: var(--muted); font-size: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 14px; white-space: nowrap; }
.who select { max-width: 230px; }
.tabs button.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); }
select, input, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; color: var(--text); }
button { font: inherit; }
main { max-width: 1180px; margin: 0 auto; padding: 16px 20px 40px; }
.tab { display: none; }
.tab.active { display: block; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--p1); color: #24407a; }
.lv-P0 { background: var(--p0); color: #1b5e20; } .lv-P1 { background: var(--p1); color: #24407a; }
.lv-P2 { background: var(--p2); color: #7a5300; } .lv-P3 { background: var(--p3); color: #8a1f12; } .lv-P4 { background: var(--p4); color: #fff; }
.muted { color: var(--muted); font-size: 12px; }
.note { background: var(--p2); border: 1px solid #f3dfa8; padding: 8px 12px; border-radius: 6px; }

.chatlog { display: flex; flex-direction: column; gap: 14px; min-height: 52vh; padding-bottom: 8px; }
.msg { display: flex; }
.msg.me { justify-content: flex-end; }
.bubble { max-width: 820px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; line-height: 1.65; white-space: pre-wrap; }
.msg.me .bubble { background: var(--accent-bg); border-color: #cddcf5; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.cites { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; font-size: 12px; color: var(--muted); white-space: normal; }
.cites div { margin: 2px 0; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.suggest button { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 4px 10px; cursor: pointer; color: var(--muted); }
.ask { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0; }
.ask textarea { flex: 1; resize: vertical; }
.ask button, .panel button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 0 18px; cursor: pointer; }
.ask button:disabled { opacity: .5; }
.askside { display: flex; flex-direction: column; gap: 6px; }
.askside button { flex: 1; min-height: 34px; }
.pub { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 4px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.card .n { font-size: 22px; font-weight: 600; }
.card .who2 { font-weight: 600; }
.card .bar { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tablewrap { overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; max-height: 64vh; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #f0f3f7; z-index: 1; white-space: nowrap; }
td.long { min-width: 260px; max-width: 420px; }
.cls { padding: 1px 6px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.cls-A { background: #e2efda; } .cls-B { background: #fff2cc; } .cls-C { background: #ddebf7; }
.cls-D { background: #f8cbad; } .cls-E { background: #ededed; } .cls-F { background: #fce4d6; }

.cal { display: grid; grid-template-columns: minmax(84px, 110px) minmax(48px, 70px) minmax(0, 1fr) minmax(64px, 160px) 52px; gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.cal > div { padding: 8px 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
@media (max-width: 640px) { main { padding: 12px 10px 30px; } .cal > div { padding: 6px; font-size: 13px; } }
.flag { font-weight: 600; } .flag-逾期, .flag-已逾期 { color: #b42318; } .flag-T-1 { color: #b42318; } .flag-T-7 { color: #b54708; } .flag-T-30 { color: #1f5fbf; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.panel .row { display: flex; gap: 12px; }
.panel .row.end { justify-content: flex-end; }
.panel label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.panel button { padding: 6px 18px; }
.draft { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.draft .acts { display: flex; gap: 8px; margin-top: 8px; }
.draft .acts button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 12px; cursor: pointer; }
.draft .acts button.ok { background: var(--accent); color: #fff; border-color: var(--accent); }

.doc { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 26px; line-height: 1.7; }
.doc table { margin: 8px 0; } .doc h1 { font-size: 20px; } .doc h2 { font-size: 17px; border-bottom: 1px solid var(--line); padding-bottom: 4px; } .doc h3 { font-size: 15px; }
.doc blockquote { color: var(--muted); border-left: 3px solid #cddcf5; margin: 0; padding-left: 10px; }
.doc code, .doc pre { background: #f3f4f6; border-radius: 4px; padding: 0 3px; }
.kv { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; }
.kv h3 { margin: 0 0 8px; font-size: 15px; }
.ok { color: #1b7a3a; } .no { color: #b42318; }

.rec { cursor: pointer; } .rec:hover { border-color: #cddcf5; }
.sec { font-size: 15px; margin: 18px 0 8px; } .sec .muted { font-weight: normal; margin-left: 6px; }
a.btn { margin-left: auto; text-decoration: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 6px; padding: 2px 10px; font-size: 12px; }
#record-view .note, #record-view > .muted { margin: 0 0 8px; }
.bubble.md { white-space: normal; } .bubble.md h1, .bubble.md h2, .bubble.md h3 { font-size: 15px; margin: 12px 0 6px; }
.bubble.md p { margin: 6px 0; } .bubble.md table { margin: 6px 0; } .bubble.md ul, .bubble.md ol { padding-left: 22px; margin: 4px 0; }
