/* BetterLawer — premium light theme (white, formal, high-end) */
:root {
  --bg: #f6f7f9;            /* app canvas */
  --panel: #ffffff;          /* cards */
  --panel-2: #f4f6f9;        /* inset areas */
  --line: #e4e8ef;           /* hairline borders */
  --line-2: #eef1f5;         /* row dividers */
  --text: #1b2a41;           /* ink navy */
  --muted: #66738b;
  --faint: #98a3b6;
  --gold: #b08d3e;           /* restrained house gold */
  --gold-2: #8a6d2f;
  --gold-bg: #faf6ec;
  --blue: #2456a6;
  --red: #c2453e;
  --red-bg: #fdf3f2;
  --amber: #b8741a;
  --amber-bg: #fdf8ef;
  --green: #23795b;
  --green-bg: #f0f8f4;
  --navy: #1f3a5f;
  --serif: "Songti SC", "STSong", Georgia, "Times New Roman", serif;
  --sans: -apple-system, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  --shadow: 0 1px 2px rgba(27, 42, 65, .04), 0 4px 14px rgba(27, 42, 65, .05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- sidebar ---------- */
.sidebar { width: 236px; flex: none; background: #ffffff; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 14px 16px; overflow-y: auto; }
.brand { display: flex; gap: 11px; align-items: center; padding: 2px 8px 18px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--navy); color: #e9cd92; font: 700 21px var(--serif); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.brand-name { font: 700 17px var(--serif); letter-spacing: .04em; color: var(--text); }
.brand-sub { color: var(--faint); font-size: 11px; letter-spacing: .02em; }
.matter-box { margin: 2px 0 14px; padding: 0 4px; }
.side-label { display: block; color: var(--faint); font-size: 10px; letter-spacing: .16em; margin: 0 2px 6px; font-weight: 600; }
.matter-box select { width: 100%; }
nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left; background: none; border: none; color: var(--text); padding: 8px 11px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.nav-item em { font-style: normal; color: var(--faint); font-size: 10px; margin-left: auto; letter-spacing: .05em; }
.nav-item .ico { color: var(--gold); width: 16px; font-size: 12px; }
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--navy); color: #ffffff; }
.nav-item.active .ico { color: #e9cd92; }
.nav-item.active em { color: rgba(255, 255, 255, .55); }
.side-footer { margin-top: auto; border-top: 1px solid var(--line-2); padding-top: 12px; }
.engine-badge { font-size: 11px; border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; color: var(--muted); text-align: center; background: var(--panel-2); }
.engine-badge.llm { color: var(--green); border-color: #bfe0d2; background: var(--green-bg); }
.side-note { color: var(--faint); font-size: 10.5px; text-align: center; margin-top: 10px; line-height: 1.7; }

/* ---------- main ---------- */
.main { flex: 1; overflow-y: auto; padding: 30px 36px 70px; }
@media (max-width: 760px) { .main { padding: 20px 16px 60px; } .sidebar { width: 200px; } }
.view { display: none; max-width: 1180px; margin: 0 auto; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; gap: 14px; flex-wrap: wrap; }
h1 { font: 700 25px var(--serif); letter-spacing: .02em; color: var(--text); }
h2 { font: 600 13.5px var(--sans); color: var(--gold-2); letter-spacing: .06em; margin-bottom: 12px; text-transform: uppercase; }
h2::before { content: "§"; color: var(--gold); margin-right: 7px; font-family: var(--serif); }
.muted { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.input-row { align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */
select, input, textarea { background: #ffffff; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; font-family: var(--sans); font-size: 13px; outline: none; transition: border-color .15s; }
select:focus, input:focus, textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(31, 58, 95, .08); }
textarea { width: 100%; resize: vertical; }
.wide { width: 100%; margin-bottom: 10px; }
.inline-select { width: auto; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 11px; margin: 6px 0 10px; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn { border: 1px solid var(--line); background: #ffffff; color: var(--text); border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 13px; transition: all .15s; }
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn.primary { background: var(--navy); color: #ffffff; font-weight: 600; border: 1px solid var(--navy); }
.btn.primary:hover:not(:disabled) { background: #2a4a75; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: wait; }
.btn.primary:disabled { background: var(--navy); color: #fff; }

/* keyboard navigation visibility */
.nav-item:focus-visible, .btn:focus-visible, .qa-card:focus-visible,
.chip.kind-chip:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px;
}

/* thin scrollbars to match the light theme */
.main::-webkit-scrollbar, .chat-log::-webkit-scrollbar, .sidebar::-webkit-scrollbar,
.notif-panel::-webkit-scrollbar, .modal-card pre::-webkit-scrollbar { width: 8px; height: 8px; }
.main::-webkit-scrollbar-thumb, .chat-log::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb,
.notif-panel::-webkit-scrollbar-thumb, .modal-card pre::-webkit-scrollbar-thumb { background: #d4dae4; border-radius: 8px; }
.main::-webkit-scrollbar-thumb:hover, .chat-log::-webkit-scrollbar-thumb:hover { background: #bfc7d4; }
.main::-webkit-scrollbar-track, .chat-log::-webkit-scrollbar-track { background: transparent; }

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

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 980px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 15px 17px; box-shadow: var(--shadow); }
.stat .num { font: 700 26px var(--serif); color: var(--navy); }
.stat .lab { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.alert .num { color: var(--red); }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list-item:last-child { border-bottom: none; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 800px) { .quick-actions { grid-template-columns: 1fr; } }
.qa-card { text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; cursor: pointer; color: var(--text); transition: all .15s; }
.qa-card:hover { border-color: var(--gold); background: var(--gold-bg); }
.qa-card b { display: block; margin-bottom: 3px; }
.qa-card span { color: var(--muted); font-size: 12px; }

/* ---------- tags / severity ---------- */
.tag { display: inline-block; border-radius: 20px; padding: 1px 9px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); background: var(--panel-2); }
.tag.high { color: var(--red); border-color: #f0cfcb; background: var(--red-bg); }
.tag.medium { color: var(--amber); border-color: #ecd9b8; background: var(--amber-bg); }
.tag.low { color: var(--blue); border-color: #ccdcf3; background: #f2f6fd; }
.tag.ok { color: var(--green); border-color: #c3e2d3; background: var(--green-bg); }
.tag.gold { color: var(--gold-2); border-color: #e4d4ae; background: var(--gold-bg); }
.score-hero { display: flex; align-items: center; gap: 22px; margin-bottom: 6px; }
.score-ring { --p: 0; width: 94px; height: 94px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; background: conic-gradient(var(--ring, var(--red)) calc(var(--p)*1%), #e8ecf2 0); }
.score-ring::before { content: attr(data-grade); width: 72px; height: 72px; border-radius: 50%; background: #ffffff; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font: 700 30px var(--serif); color: var(--text); }
.posture { font-size: 13.5px; }
.meta-line { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- findings ---------- */
.finding { border: 1px solid var(--line); border-left-width: 3px; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #ffffff; }
.finding.high { border-left-color: var(--red); background: #fffdfc; }
.finding.medium { border-left-color: var(--amber); }
.finding.low { border-left-color: var(--blue); }
.finding .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.finding blockquote { border-left: 2px solid var(--line); padding: 4px 10px; margin: 6px 0; color: #4a5872; font-size: 12.5px; font-style: italic; background: var(--panel-2); border-radius: 0 6px 6px 0; }
.finding .fix { font-size: 12.5px; color: #2c4a3c; }
.finding .fix b { color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { border: 1px solid #e4d4ae; color: var(--gold-2); background: var(--gold-bg); border-radius: 20px; padding: 3px 12px; font-size: 12.5px; }
.chip.kind-chip { background: #ffffff; color: var(--muted); border-color: var(--line); cursor: pointer; }
.chip.kind-chip.active { color: var(--gold-2); border-color: var(--gold); background: var(--gold-bg); }
.diff-snippet { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: #4a5872; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; margin: 6px 0; word-break: break-all; }
details summary { cursor: pointer; font-size: 11.5px; }
.arg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .arg-grid { grid-template-columns: 1fr; } }
.arg-col { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.arg-col h3 { font-size: 13px; margin-bottom: 8px; }
.arg-col.claimant h3 { color: var(--blue); }
.arg-col.respondent h3 { color: var(--amber); }
.arg-col li { margin-left: 16px; margin-bottom: 6px; font-size: 12.5px; }
.tl-item { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.tl-item:last-child { border-bottom: none; }
.tl-date { color: var(--gold-2); font: 600 12px var(--serif); flex: none; width: 130px; }
.report-section { margin-top: 14px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mini th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 11.5px; letter-spacing: .04em; }
table.mini td { padding: 8px; border-bottom: 1px solid var(--line-2); }
table.mini tbody tr:hover td, table.mini tr:hover td { background: #fafbfd; }
.disclaimer { color: var(--faint); font-size: 11px; margin-top: 10px; }

/* ---------- chat ---------- */
.chat-panel { display: flex; flex-direction: column; height: calc(100vh - 160px); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg-bubble { max-width: 78%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; white-space: pre-wrap; }
.msg.user .msg-bubble { background: var(--navy); color: #ffffff; }
.msg.assistant .msg-bubble { background: #ffffff; }
.citations { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.cite { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.cite:hover { border-color: var(--gold); }
.cite b { color: var(--gold-2); }
.chat-input-row { display: flex; gap: 10px; padding-top: 12px; }
.chat-input-row input { flex: 1; }
.engine-note { font-size: 11px; color: var(--faint); margin-top: 6px; }

/* ---------- tables / misc ---------- */
.doc-table { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line-2); }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; cursor: pointer; }
.row .name:hover { color: var(--gold-2); }
.row .sub { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.empty-note { color: var(--muted); font-size: 13px; padding: 8px 0; }
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px); background: #ffffff; border: 1px solid var(--gold); color: var(--text); border-radius: 10px; padding: 10px 20px; font-size: 13px; transition: transform .25s ease; z-index: 50; box-shadow: 0 8px 30px rgba(27, 42, 65, .14); max-width: min(560px, 90vw); }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.modal { position: fixed; inset: 0; background: rgba(27, 42, 65, .38); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal.hidden { display: none; }
.modal-card { width: min(860px, 92vw); max-height: 84vh; background: #ffffff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; box-shadow: 0 18px 60px rgba(27, 42, 65, .2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-card pre { overflow: auto; white-space: pre-wrap; font-size: 12.5px; color: #3c4a63; font-family: var(--sans); }
.loading { color: var(--gold-2); font-size: 13px; padding: 8px 0; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--gold); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; margin-right: 8px; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- settings ---------- */
.editions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { .editions { grid-template-columns: 1fr; } }
.edition { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--panel-2); }
.edition.current { border-color: var(--gold); background: var(--gold-bg); }
.edition b { font: 700 15px var(--serif); }
.edition .price { color: var(--gold-2); font-size: 12.5px; margin: 2px 0 8px; }
.edition ul { list-style: none; }
.edition li { font-size: 12px; color: var(--muted); padding: 2px 0; }
.edition li::before { content: "✓"; color: var(--green); margin-right: 6px; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .set-grid { grid-template-columns: 1fr; } }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.rule-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 2px; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.rule-row:last-child { border-bottom: none; }
.rule-row .grow { flex: 1; min-width: 0; }
.danger { color: var(--red); border-color: #f0cfcb; }
.danger:hover { background: var(--red-bg); border-color: var(--red); }

/* ---------- auth ---------- */
.hidden { display: none !important; }
#view-login { display: none; }
#view-login.active { display: flex; align-items: center; justify-content: center; height: 100%; }
.login-card { width: min(400px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px 32px; box-shadow: 0 12px 50px rgba(27, 42, 65, .1); }
.user-box { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--panel-2); font-size: 12.5px; }

/* ---------- notifications (站内通知) ---------- */
.notif-wrap { position: relative; margin-bottom: 10px; }
.notif-wrap .btn { width: 100%; }
.notif-badge { display: inline-block; min-width: 16px; text-align: center; background: var(--red); color: #fff; border-radius: 9px; font-size: 10px; line-height: 15px; padding: 0 4px; margin-left: 2px; }
.notif-panel { position: absolute; bottom: 38px; left: 0; right: 0; max-height: 400px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(27, 42, 65, .16); padding: 10px; z-index: 40; }
.notif-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 2px 8px; border-bottom: 1px solid var(--line-2); }
.notif-head b { white-space: nowrap; flex: none; }
.notif-item { padding: 8px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--panel-2); }
.notif-item.unread { background: var(--gold-bg); }
.notif-item.unread:hover { background: #f5eeda; }
.notif-item.unread .notif-title b::after { content: "●"; color: var(--gold); font-size: 9px; margin-left: 6px; vertical-align: 2px; }
.notif-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.notif-item .sub { margin-top: 3px; }

/* ---------- matter tools / streaming ---------- */
.matter-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.matter-actions .btn { padding: 3px 4px; font-size: 11px; text-align: center; }
.blink { animation: blink 1s steps(2, start) infinite; color: var(--gold); }
@keyframes blink { to { visibility: hidden; } }
.answer-text { white-space: pre-wrap; }

/* ---------- 材料汇编 (bundles) ---------- */
.bd-title { font-weight: 600; }
.bd-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 62%; }
.bd-docs { max-height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; margin-bottom: 12px; }
.bd-doc { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.bd-doc:last-child { border-bottom: none; }
.bd-doc label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 240px; cursor: pointer; }
.bd-move { display: flex; gap: 4px; }
.bd-move .btn { padding: 1px 8px; }
.bd-opts { display: flex; gap: 22px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; }
.bd-opts label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.bd-bar { height: 6px; border-radius: 4px; background: var(--panel-2); margin-top: 6px; max-width: 360px; overflow: hidden; }
.bd-bar i { display: block; height: 100%; background: var(--gold); transition: width .3s; }
