/* 合同审查系统 —— 内部页面样式 */

:root {
    --cr-bg: #f5f6f8;
    --cr-surface: #ffffff;
    --cr-border: #e3e6ec;
    --cr-text: #1f2430;
    --cr-muted: #6b7280;
    --cr-primary: #1a5fb4;
    --cr-primary-dark: #16509a;
    --cr-high: #d92d20;
    --cr-high-bg: #fef3f2;
    --cr-mid: #d97706;
    --cr-mid-bg: #fffaeb;
    --cr-low: #2563eb;
    --cr-low-bg: #eff6ff;
    --cr-ok: #059669;
    --cr-added: #059669;
    --cr-added-bg: #ecfdf5;
    --cr-removed: #d92d20;
    --cr-removed-bg: #fef3f2;
    --cr-modified: #d97706;
    --cr-modified-bg: #fffaeb;
}

body {
    background: var(--cr-bg);
    color: var(--cr-text);
}

.cr-shell {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 20px 40px;
}

/* ── Topbar ─────────────────────────────────────────── */
.cr-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 0 16px;
    border-bottom: 1px solid var(--cr-border);
    margin-bottom: 20px;
}

.cr-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--cr-muted);
}

.cr-breadcrumb a { color: var(--cr-muted); text-decoration: none; }
.cr-breadcrumb a:hover { color: var(--cr-primary); }
.cr-breadcrumb strong { color: var(--cr-text); }
.cr-breadcrumb .sep { color: #c3c8d2; }

.cr-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.cr-tabs { display: flex; gap: 4px; }

.cr-tab {
    border: 1px solid transparent;
    background: transparent;
    color: var(--cr-muted);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.cr-tab:hover { background: #eceef3; color: var(--cr-text); }
.cr-tab.is-active {
    background: var(--cr-primary);
    border-color: var(--cr-primary);
    color: #fff;
}

.cr-user { font-size: 13px; color: var(--cr-muted); }

/* ── Buttons ────────────────────────────────────────── */
.cr-btn {
    border: 1px solid var(--cr-border);
    background: var(--cr-surface);
    color: var(--cr-text);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .15s, border-color .15s;
}
.cr-btn:hover:not(:disabled) { border-color: #c9cedb; background: #f8f9fb; }
.cr-btn:disabled { opacity: .55; cursor: not-allowed; }

.cr-btn-primary {
    background: var(--cr-primary);
    border-color: var(--cr-primary);
    color: #fff;
}
.cr-btn-primary:hover:not(:disabled) {
    background: var(--cr-primary-dark);
    border-color: var(--cr-primary-dark);
}

.cr-btn-ghost { border-color: transparent; background: transparent; color: var(--cr-muted); }
.cr-btn-ghost:hover:not(:disabled) { background: #eceef3; }

.cr-btn-danger { color: var(--cr-high); border-color: #f4c3bf; }
.cr-btn-danger:hover:not(:disabled) { background: var(--cr-high-bg); }

.cr-btn-sm { padding: 4px 10px; font-size: 13px; }

/* ── Layout blocks ──────────────────────────────────── */
.cr-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.cr-input, .cr-select, .cr-textarea {
    /* 必须是 border-box：否则 width:100% 再加左右内边距和边框会撑出容器，
       弹窗底部会出现一条横向滚动条 */
    box-sizing: border-box;
    border: 1px solid var(--cr-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--cr-text);
    background: var(--cr-surface);
    outline: none;
}
.cr-input:focus, .cr-select:focus, .cr-textarea:focus { border-color: var(--cr-primary); }
.cr-textarea { width: 100%; min-height: 72px; resize: vertical; }
.cr-input-grow { flex: 1; min-width: 180px; }

.cr-card {
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 16px;
}

.cr-placeholder, .cr-empty {
    text-align: center;
    color: var(--cr-muted);
    padding: 48px 20px;
    font-size: 14px;
}

.cr-error {
    background: var(--cr-high-bg);
    border: 1px solid #f4c3bf;
    color: var(--cr-high);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 14px;
}

/* ── Table ──────────────────────────────────────────── */
.cr-table-wrap {
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    border-radius: 12px;
    overflow-x: auto;
}

.cr-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cr-table th, .cr-table td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--cr-border);
    vertical-align: middle;
}
.cr-table th {
    background: #fafbfc;
    font-weight: 600;
    color: var(--cr-muted);
    font-size: 13px;
    white-space: nowrap;
}
.cr-table tbody tr:last-child td { border-bottom: none; }
.cr-table tbody tr:hover { background: #fafbfc; }
.cr-table .cr-row-link { color: var(--cr-primary); cursor: pointer; font-weight: 500; }
.cr-table .cr-row-link:hover { text-decoration: underline; }
.cr-nowrap { white-space: nowrap; }

/* ── Badges ─────────────────────────────────────────── */
.cr-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.cr-badge-high { background: var(--cr-high-bg); color: var(--cr-high); }
.cr-badge-mid  { background: var(--cr-mid-bg);  color: var(--cr-mid); }
.cr-badge-low  { background: var(--cr-low-bg);  color: var(--cr-low); }
.cr-badge-type { background: #eef2f7; color: #475569; }
.cr-badge-rule { background: #f1f5f9; color: #475569; }
.cr-badge-llm  { background: #f5f3ff; color: #7c3aed; }
.cr-badge-off  { background: #f1f5f9; color: #94a3b8; }
.cr-badge-added    { background: var(--cr-added-bg);    color: var(--cr-added); }
.cr-badge-removed  { background: var(--cr-removed-bg);  color: var(--cr-removed); }
.cr-badge-modified { background: var(--cr-modified-bg); color: var(--cr-modified); }

/* ── Findings ───────────────────────────────────────── */
.cr-summary {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.cr-stat {
    flex: 1;
    min-width: 110px;
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    border-radius: 12px;
    padding: 14px 16px;
}
.cr-stat .n { font-size: 26px; font-weight: 600; line-height: 1.2; }
.cr-stat .l { font-size: 13px; color: var(--cr-muted); margin-top: 2px; }
.cr-stat.high .n { color: var(--cr-high); }
.cr-stat.mid .n  { color: var(--cr-mid); }
.cr-stat.low .n  { color: var(--cr-low); }

.cr-finding {
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    border-left: 4px solid var(--cr-border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 12px;
}
.cr-finding.sev-high { border-left-color: var(--cr-high); }
.cr-finding.sev-mid  { border-left-color: var(--cr-mid); }
.cr-finding.sev-low  { border-left-color: var(--cr-low); }
.cr-finding.is-accepted { opacity: .62; }

.cr-finding-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.cr-finding-head .ref { font-weight: 600; font-size: 14px; }

.cr-finding-quote {
    background: #fafbfc;
    border-left: 3px solid #dfe3ea;
    padding: 9px 12px;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.cr-finding-quote.is-unverified {
    background: var(--cr-mid-bg);
    border-left-color: #f59e0b;
}

.cr-quote-warn {
    margin-top: 7px;
    font-size: 12px;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cr-finding-row { font-size: 14px; line-height: 1.65; margin-bottom: 6px; }
.cr-finding-row .k { color: var(--cr-muted); margin-right: 6px; }
.cr-finding-basis { font-size: 13px; color: var(--cr-muted); }

/* ── 示范文本对照差异卡片 ─────────────────────────────── */
.cr-diff {
    background: var(--cr-surface);
    border: 1px solid var(--cr-border);
    border-left: 4px solid var(--cr-border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 12px;
}
.cr-diff-added    { border-left-color: var(--cr-added); }
.cr-diff-removed  { border-left-color: var(--cr-removed); }
.cr-diff-modified { border-left-color: var(--cr-modified); }

.cr-diff-quotes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
.cr-diff-quote {
    background: #fafbfc;
    border-left: 3px solid #dfe3ea;
    padding: 9px 12px;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #4b5563;
    white-space: pre-wrap;
    word-break: break-word;
}
.cr-diff-quote .k {
    font-size: 11px;
    font-weight: 700;
    color: var(--cr-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 4px;
}
@media (max-width: 640px) {
    .cr-diff-quotes { grid-template-columns: 1fr; }
}

.cr-finding-actions {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--cr-border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Detail header ──────────────────────────────────── */
.cr-detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.cr-detail-head h2 { margin: 0 0 6px; font-size: 20px; }
.cr-detail-meta { font-size: 13px; color: var(--cr-muted); display: flex; gap: 14px; flex-wrap: wrap; }

.cr-section-title {
    font-size: 15px;
    font-weight: 600;
    margin: 22px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Progress ───────────────────────────────────────── */
.cr-progress {
    background: var(--cr-low-bg);
    border: 1px solid #c3dafe;
    color: #1e40af;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

/* ── Modal ──────────────────────────────────────────── */
.cr-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.cr-modal {
    background: var(--cr-surface);
    border-radius: 14px;
    width: 100%;
    max-width: 620px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 48px rgba(15, 23, 42, .22);
}

.cr-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cr-border);
}
.cr-modal-header h3 { margin: 0; font-size: 16px; }

.cr-modal-close {
    border: none;
    background: transparent;
    font-size: 18px;
    color: var(--cr-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.cr-modal-close:hover { background: #f1f3f7; color: var(--cr-text); }

.cr-modal-body { padding: 20px; overflow-y: auto; }
.cr-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--cr-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.cr-field { margin-bottom: 14px; }
.cr-field label {
    display: block;
    font-size: 13px;
    color: var(--cr-muted);
    margin-bottom: 5px;
}
.cr-field .cr-input, .cr-field .cr-select { width: 100%; }
.cr-field-hint { font-size: 12px; color: var(--cr-muted); margin-top: 4px; }
.cr-field-row { display: flex; gap: 12px; }
.cr-field-row > * { flex: 1; }

/* ── Disclaimer ─────────────────────────────────────── */
.cr-disclaimer {
    margin-top: 28px;
    padding: 12px 16px;
    background: #fffaeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    font-size: 13px;
    color: #92400e;
    line-height: 1.7;
}

/* 打印时只留审查结果，用浏览器"打印为 PDF"即可得到审查报告 */
@media print {
    .site-nav, .site-mobile-nav, .cr-topbar, .cr-toolbar,
    .cr-finding-actions, .cr-modal-overlay, .cr-btn { display: none !important; }
    body { background: #fff; }
    .cr-shell { max-width: none; padding: 0; }
    .cr-finding, .cr-diff { break-inside: avoid; page-break-inside: avoid; }
}

@media (max-width: 768px) {
    .cr-topbar { flex-direction: column; align-items: stretch; }
    .cr-topbar-right { justify-content: space-between; }
    .cr-tabs { flex: 1; }
    .cr-tab { flex: 1; justify-content: center; }
    .cr-field-row { flex-direction: column; }
}
