:root {
  --bg: #f5f5f5; --surface: #fff; --border: #ddd;
  --risk-high: #e74c3c; --risk-medium: #f39c12; --risk-low: #27ae60;
  --primary: #4A90D9; --primary-dark: #357ABD;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: var(--bg); color: #222; line-height: 1.5; }
#app { max-width: 1000px; margin: 0 auto; padding: 1rem; }
header { margin-bottom: 1.5rem; }
h1 { font-size: 1.4rem; color: var(--primary); }
h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }
section { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
input[type="file"] { display: block; margin-bottom: 0.5rem; }
button { background: var(--primary); color: #fff; border: none; padding: 0.4rem 1rem; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:hover:not(:disabled) { background: var(--primary-dark); }
#etalon-status { margin-top: 0.5rem; font-size: 0.9rem; }
.contract-row { display: flex; align-items: center; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.contract-row:last-child { border-bottom: none; }
.contract-row:hover { background: #f0f4ff; }
.risk-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; font-weight: 600; color: #fff; }
.risk-high { background: var(--risk-high); }
.risk-medium { background: var(--risk-medium); }
.risk-low { background: var(--risk-low); }
.deviation { padding: 0.3rem 0; }
.deviation .type { font-weight: 600; }
.chat-input-row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.chat-input-row input { flex: 1; padding: 0.4rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.9rem; }
#chat-messages { max-height: 300px; overflow-y: auto; margin-bottom: 0.5rem; }
.msg { margin: 0.3rem 0; padding: 0.4rem 0.6rem; border-radius: 6px; font-size: 0.9rem; }
.msg-user { background: #e3f2fd; text-align: right; }
.msg-assistant { background: #f5f5f5; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.msg-assistant p { margin: 0.3rem 0; }
.msg-assistant ul, .msg-assistant ol { margin: 0.3rem 0 0.3rem 1.2rem; padding: 0; }
.msg-assistant li { margin: 0.15rem 0; }
.msg-assistant h1, .msg-assistant h2, .msg-assistant h3, .msg-assistant h4, .msg-assistant h5, .msg-assistant h6 { margin: 0.5rem 0 0.2rem; font-size: 0.95rem; }
.msg-assistant h1 { font-size: 1.1rem; }
.msg-assistant h2 { font-size: 1.05rem; }
.msg-assistant strong { font-weight: 700; }
.msg-assistant em { font-style: italic; }
.msg-assistant .code-block { background: #1e1e1e; color: #d4d4d4; padding: 0.6rem; border-radius: 4px; overflow-x: auto; font-size: 0.82rem; margin: 0.4rem 0; }
.msg-assistant .code-inline { background: #e8e8e8; padding: 1px 4px; border-radius: 3px; font-size: 0.85rem; font-family: monospace; }

.compare-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 0.8rem 0; }
.compare-col { background: #fafafa; border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem; font-size: 0.9rem; }
.compare-col.full-width { grid-column: 1 / -1; }
.compare-col .col-label { font-size: 0.75rem; text-transform: uppercase; opacity: 0.6; margin-bottom: 0.3rem; }
.diff-del { background: #fde2e2; color: #c0392b; text-decoration: line-through; padding: 0 2px; border-radius: 2px; }
.diff-ins { background: #e2f7e9; color: #1e7e34; padding: 0 2px; border-radius: 2px; }
.risk-card { grid-column: 1 / -1; padding: 0.6rem 0.8rem; background: #fafafa; border-left: 3px solid var(--risk-high); border-radius: 4px; font-size: 0.85rem; }
.risk-card.risk-medium { border-left-color: var(--risk-medium); }
.risk-card.risk-low { border-left-color: var(--risk-low); }
.risk-card .risk-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; color: #fff; background: var(--risk-high); }
.risk-card.risk-medium .risk-chip { background: var(--risk-medium); }
.risk-card.risk-low .risk-chip { background: var(--risk-low); }
.risk-card .risk-explanation { margin-top: 0.4rem; }
.risk-card .quote-warning { color: #b45309; font-size: 0.8rem; margin-left: 0.4rem; }
.risk-card details { margin-top: 0.4rem; font-size: 0.8rem; }
.risk-card details summary { cursor: pointer; color: var(--primary); }
.risk-card details .law-excerpt { margin-top: 0.3rem; padding: 0.4rem 0.6rem; background: #fff; border-radius: 4px; font-style: italic; color: #555; }
