* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
       color: #1f2328; background: #fff; height: 100vh; }
.hidden { display: none !important; }
.err { color: #d33; font-size: 13px; min-height: 18px; }

.overlay { position: fixed; inset: 0; background: #f6f7f9;
           display: flex; align-items: center; justify-content: center; z-index: 10; }
#login { flex-direction: column; }
.mascot-login { width: 200px; height: auto; margin-bottom: 14px;
                filter: drop-shadow(0 10px 24px rgba(0,0,0,.10)); }
.brand-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
                flex-shrink: 0; }
.login-box { background: #fff; padding: 32px; border-radius: 12px; width: 320px;
             box-shadow: 0 4px 24px rgba(0,0,0,.08); text-align: center; }
.login-box h2 { margin: 0 0 20px; }
.login-box input { width: 100%; padding: 10px; margin-bottom: 12px;
                   border: 1px solid #d0d7de; border-radius: 8px; font-size: 15px; }
.login-box button { width: 100%; padding: 10px; border: 0; border-radius: 8px;
                    background: #1f6feb; color: #fff; font-size: 15px; cursor: pointer; }

#app { display: flex; height: 100vh; }
#sidebar { width: 240px; border-right: 1px solid #e4e7eb; padding: 16px;
           overflow-y: auto; flex-shrink: 0; }
#new-btn { width: 100%; padding: 10px; border: 1px dashed #1f6feb; background: #fff;
           color: #1f6feb; border-radius: 8px; cursor: pointer; margin-bottom: 8px; }
#new-mrd-btn { width: 100%; padding: 10px; border: 1px dashed #d4860b; background: #fff;
               color: #b3700a; border-radius: 8px; cursor: pointer; margin-bottom: 16px; }
#projects { list-style: none; margin: 0; padding: 0; }
#projects li { display: flex; align-items: center; gap: 6px; padding: 10px; border-radius: 8px;
               cursor: pointer; font-size: 14px; margin-bottom: 4px; }
.proj-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-badge { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; flex-shrink: 0; }
.type-prd { background: #eaf2ff; color: #1f6feb; }
.type-mrd { background: #fff3e0; color: #b3700a; }
#projects li:hover { background: #f0f3f6; }
#projects li.active { background: #ddeeff; }
#projects li .badge { font-size: 11px; color: #57606a; flex-shrink: 0; }

#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#header { padding: 14px 20px; border-bottom: 1px solid #e4e7eb; font-weight: 600;
          display: flex; align-items: center; gap: 12px; }
#title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dl-btn { padding: 6px 14px; border: 0; border-radius: 8px; background: #1f883d; color: #fff;
          cursor: pointer; font-size: 13px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
#dl-btn:hover { background: #1a7332; }
.lang-select { padding: 4px 8px; border: 1px solid #d0d7de; border-radius: 8px; background: #fff;
               color: #1f2328; font-size: 13px; cursor: pointer; flex-shrink: 0; }
.phase { font-weight: 400; font-size: 13px; color: #1f6feb; background: #eef4ff;
         padding: 2px 10px; border-radius: 12px; white-space: nowrap; }
.phase:empty { display: none; }
.cost { font-weight: 400; font-size: 13px; color: #9a6700; background: #fff8e6;
        padding: 2px 10px; border-radius: 12px; white-space: nowrap; cursor: default; }
.cost:empty { display: none; }
#chat { flex: 1; overflow-y: auto; padding: 20px; }
.msg { max-width: 760px; margin: 0 auto 16px; }
.msg .bubble { padding: 12px 16px; border-radius: 12px; white-space: pre-wrap;
               word-break: break-word; line-height: 1.6; }
.msg.user .bubble { background: #1f6feb; color: #fff; margin-left: auto; max-width: 70%; width: fit-content; }
.msg.assistant .bubble { background: #f0f3f6; }
.msg.assistant .bubble.thinking { color: #57606a; font-style: italic;
  animation: prd-pulse 1.4s ease-in-out infinite; }
@keyframes prd-pulse { 0%, 100% { opacity: .45; } 50% { opacity: .9; } }
.msg.error .bubble { background: #fff0f0; color: #b91c1c; }

/* 气泡工具条：复制按钮，hover 浮现，触屏设备常显淡 */
.msg-tools { margin-top: 4px; height: 18px; line-height: 18px; opacity: 0; transition: opacity .12s; }
.msg.user .msg-tools { text-align: right; }
.msg:hover .msg-tools { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: .55; } }
.copy-msg { border: 0; background: none; color: #8b949e; font-size: 12px; line-height: 1;
            cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.copy-msg:hover { background: #f0f3f6; color: #1f2328; }
.copy-msg.copied { color: #1f883d; }
.options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.options button { padding: 8px 14px; border: 1px solid #1f6feb; background: #fff;
                  color: #1f6feb; border-radius: 18px; cursor: pointer; font-size: 14px; }
.options button .desc { color: #57606a; font-size: 12px; margin-left: 4px; }
.options button.readonly { border-color: #d0d7de; color: #8c959f; background: #f6f8fa; cursor: default; }
.options button.readonly .desc { color: #8c959f; }
.done-actions { margin-top: 12px; }
.done-actions button { padding: 8px 16px; border: 0; border-radius: 8px;
                       background: #1f883d; color: #fff; cursor: pointer; }

#composer { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid #e4e7eb; }
#input { flex: 1; resize: none; height: 56px; padding: 10px; border: 1px solid #d0d7de;
         border-radius: 8px; font-size: 15px; font-family: inherit; }
#send-btn { padding: 0 24px; border: 0; border-radius: 8px; background: #1f6feb;
            color: #fff; cursor: pointer; }
#send-btn:disabled, #input:disabled { opacity: .5; cursor: not-allowed; }

/* 回到底部悬浮按钮：上滑读历史时出现，点击回到最新 */
#scroll-bottom { position: absolute; right: 28px; bottom: 104px; z-index: 5;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid #d0d7de;
  background: #fff; color: #1f2328; cursor: pointer; font-size: 18px; line-height: 1;
  box-shadow: 0 2px 10px rgba(0,0,0,.14); display: flex; align-items: center; justify-content: center; }
#scroll-bottom:hover { background: #f0f3f6; }

#prd-panel { width: 460px; border-left: 1px solid #e4e7eb; display: flex;
             flex-direction: column; flex-shrink: 0; }
#prd-panel header { display: flex; align-items: center; gap: 12px; padding: 14px 20px;
                    border-bottom: 1px solid #e4e7eb; }
#prd-panel header span { font-weight: 600; flex: 1; }
#prd-panel header a { color: #1f6feb; font-size: 14px; text-decoration: none; }
#close-prd { border: 0; background: none; font-size: 20px; cursor: pointer; color: #57606a; }
#prd-body { overflow-y: auto; padding: 20px; }
.markdown h1, .markdown h2 { border-bottom: 1px solid #eaecef; padding-bottom: .3em; }
.markdown table { border-collapse: collapse; }
.markdown td, .markdown th { border: 1px solid #d0d7de; padding: 6px 12px; }
.markdown code { background: #f0f3f6; padding: 2px 5px; border-radius: 4px; }
.markdown pre { background: #f0f3f6; padding: 12px; border-radius: 8px; overflow-x: auto; }

/* 附件上传 */
#attach-btn { padding: 0 12px; border: 1px solid #d0d7de; background: #fff; border-radius: 8px;
              cursor: pointer; font-size: 18px; flex-shrink: 0; }
#attach-btn:disabled { opacity: .5; cursor: not-allowed; }
#attachments { max-width: 760px; margin: 0 auto; padding: 8px 20px 0;
               display: flex; flex-wrap: wrap; gap: 8px; }
#attachments:empty { display: none; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; background: #f0f3f6;
            border: 1px solid #d0d7de; border-radius: 8px; padding: 4px 8px;
            font-size: 13px; max-width: 220px; }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; display: block; }
.att-del { border: 0; background: none; cursor: pointer; color: #57606a; font-size: 13px; padding: 0 2px; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg.user .msg-attachments .att-thumb { width: 64px; height: 64px; }
.att-file { background: rgba(255,255,255,.25); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
#upload-hint { max-width: 760px; margin: 4px auto 0; padding: 0 20px 10px;
               font-size: 12px; color: #8b949e; line-height: 1.5; }
#upload-hint strong { color: #57606a; font-weight: 600; }

/* 完成态：勾选下载卡片 */
.done-card { margin-top: 12px; background: #f6f8fa; border: 1px solid #e4e7eb;
             border-radius: 10px; padding: 14px 16px; }
.done-title { font-weight: 600; margin-bottom: 8px; }
.done-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.done-file { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.done-actions { display: flex; gap: 8px; margin-top: 4px; }
.done-actions button { padding: 8px 16px; border: 1px solid #1f883d; border-radius: 8px;
                       background: #fff; color: #1f883d; cursor: pointer; font-size: 14px; }
.done-actions button.primary { background: #1f883d; color: #fff; border-color: #1f883d; }

/* 重连自愈：末条没等到回复时的一键重试卡片 */
.retry-card { margin-top: 12px; background: #fff8e6; border: 1px solid #f0d58c;
              border-radius: 10px; padding: 12px 14px; }
.retry-card > div { color: #8a6d1a; font-size: 14px; margin-bottom: 10px; }
.retry-btn { padding: 7px 14px; border: 1px solid #d4a72c; background: #fff; color: #9a6700;
             border-radius: 8px; cursor: pointer; font-size: 14px; }
.retry-btn:hover { background: #fff3d6; }

/* ============ 管理后台 ============ */
#admin-header { display: flex; align-items: center; gap: 16px; padding: 14px 24px;
                border-bottom: 1px solid #e4e7eb; }
#admin-header .admin-title { font-weight: 600; font-size: 16px; }
#admin-header .overview { color: #57606a; font-size: 14px; }
#admin-main { padding: 24px; max-width: 1100px; margin: 0 auto; }
.admin-card { background: #fff; border: 1px solid #e4e7eb; border-radius: 12px;
              padding: 20px; margin-bottom: 20px; }
.admin-card h3 { margin: 0 0 16px; font-size: 15px; }

.add-user-form { display: flex; gap: 10px; flex-wrap: wrap; }
.add-user-form input { flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid #d0d7de;
                       border-radius: 8px; font-size: 14px; }
.add-user-form button { padding: 9px 18px; border: 0; border-radius: 8px;
                        background: #1f6feb; color: #fff; cursor: pointer; font-size: 14px; }
.token-box { margin-top: 14px; padding: 12px 14px; background: #fff8e6; border: 1px solid #f0d58c;
             border-radius: 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.token-box .token-tip { color: #8a6d1a; font-size: 13px; }
.token-val { background: #fff; border: 1px solid #e4d08a; border-radius: 6px; padding: 4px 10px;
             font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
             word-break: break-all; }
.copy-btn { padding: 5px 12px; border: 1px solid #1f6feb; background: #fff; color: #1f6feb;
            border-radius: 6px; cursor: pointer; font-size: 13px; }

.table-wrap { overflow-x: auto; }
#users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
#users-table th, #users-table td { padding: 10px 12px; border-bottom: 1px solid #eaecef;
                                   text-align: left; white-space: nowrap; }
#users-table th { color: #57606a; font-weight: 600; font-size: 13px; }
#users-table tbody tr:hover { background: #f6f8fa; }
.token-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
              background: #f0f3f6; border-radius: 6px; padding: 3px 8px; cursor: pointer;
              max-width: 180px; overflow: hidden; text-overflow: ellipsis; display: inline-block;
              vertical-align: middle; }
.token-cell:hover { background: #e3e9ef; }
.cost-cell { color: #9a6700; font-weight: 600; white-space: nowrap; }
.status-badge { font-size: 12px; padding: 2px 10px; border-radius: 12px; }
.status-active { background: #dafbe1; color: #1a7f37; }
.status-disabled { background: #ffebe9; color: #cf222e; }
.op-cell { display: flex; gap: 6px; }
.op-btn { padding: 5px 10px; border: 1px solid #d0d7de; background: #fff; border-radius: 6px;
          cursor: pointer; font-size: 13px; color: #1f2328; }
.op-btn:hover { background: #f0f3f6; }
.op-danger { color: #cf222e; border-color: #f3c2c2; }
.op-danger:hover { background: #ffebe9; }

/* 抽屉：看某用户的项目 + 对话 */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-mask { position: absolute; inset: 0; background: rgba(0,0,0,.32); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(880px, 92vw);
                background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.12);
                display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px;
               border-bottom: 1px solid #e4e7eb; }
.drawer-title { font-weight: 600; flex: 1; }
.drawer-close { border: 0; background: none; font-size: 22px; cursor: pointer; color: #57606a; }
.drawer-body { flex: 1; display: flex; min-height: 0; }
.drawer-col { display: flex; flex-direction: column; min-height: 0; padding: 16px; }
.drawer-col h4 { margin: 0 0 12px; font-size: 14px; color: #57606a; }
.drawer-col:first-child { width: 260px; border-right: 1px solid #e4e7eb; flex-shrink: 0; }
.drawer-msgs-col { flex: 1; min-width: 0; }
.drawer-projects { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.drawer-proj { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
               margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-proj:hover { background: #f0f3f6; }
.drawer-proj.active { background: #ddeeff; }
.drawer-proj .badge { font-size: 11px; color: #57606a; }
.drawer-messages { overflow-y: auto; flex: 1; }
.drawer-messages .msg { max-width: 100%; margin: 0 0 14px; }
.drawer-empty { color: #8b949e; font-size: 13px; padding: 4px 2px; }

/* ---- Legal Master 追加样式 ---- */
.risk-badge { display: inline-block; border-radius: 6px; padding: 3px 10px; font-size: 12px;
  margin-bottom: 6px; font-weight: 600; }
.risk-badge.l0 { background: #e6f7e9; color: #1a7f37; }
.risk-badge.l1 { background: #fff4e0; color: #b45309; }
.risk-badge.l2 { background: #fdecec; color: #c0392b; }
.msg.reviewer .bubble { background: #e6f7e9; border: 1px solid #b7e3c0; color: #14532d;
  font-size: 13px; }
#new-matter-form { display: flex; flex-direction: column; gap: 6px; padding: 8px; }
#new-matter-form input, #new-matter-form select { padding: 6px 8px; border-radius: 6px;
  border: 1px solid #d0d4dc; font-size: 13px; width: 100%; box-sizing: border-box; }
.review-link { display: block; margin: 10px 8px; padding: 8px 10px; border-radius: 8px;
  background: #fff4e0; color: #b45309; text-decoration: none; font-size: 13px; text-align: center; }
.review-link:hover { background: #ffe9c4; }
.review-list { max-width: 860px; margin: 20px auto; padding: 0 16px; }
.review-item { background: #fff; border: 1px solid #e3e6ec; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px; }
.review-item h3 { margin: 0 0 6px; font-size: 15px; }
.ri-meta { color: #667; font-size: 12px; margin: 0 0 8px; }
.ri-last { background: #f7f8fa; border-radius: 8px; padding: 10px; font-size: 12px;
  white-space: pre-wrap; max-height: 280px; overflow: auto; }
.ri-note { width: 100%; box-sizing: border-box; min-height: 56px; margin-top: 8px;
  border: 1px solid #d0d4dc; border-radius: 8px; padding: 8px; font-size: 13px; }
.ri-actions { margin-top: 8px; display: flex; gap: 10px; }
.ri-actions button { padding: 7px 14px; border-radius: 8px; border: none; cursor: pointer; font-size: 13px; }
.btn-approve { background: #1a7f37; color: #fff; }
.btn-revise { background: #fff4e0; color: #b45309; border: 1px solid #f0c478 !important; }
.topbar { display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid #e3e6ec; background: #fff; }
.topbar h1 { font-size: 17px; margin: 0; }
.btn-link { font-size: 13px; color: #4466dd; text-decoration: none; }

#nm-title.input-err { border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192,57,43,.18); animation: lm-shake .3s; }
@keyframes lm-shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
