:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #18202f;
  --muted: #667085;
  --line: #e5e7ef;
  --primary: #3157d5;
  --primary-dark: #2542a4;
  --danger: #c93434;
  --success: #16875a;
  --warning: #b87300;
  --shadow: 0 16px 45px rgba(31, 41, 55, .08);
  --radius: 22px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #e9eefc, transparent 32rem), var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
  backdrop-filter: blur(18px);
  background: rgba(255,255,255,.83);
  border-bottom: 1px solid rgba(229,231,239,.9);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 850; font-size: 20px; }
.brand-mark {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 12px; background: #101828; color: white; font-size: 24px;
}
.topnav { display: flex; align-items: center; gap: 16px; color: #344054; font-size: 14px; }
.user-pill { padding: 8px 12px; border-radius: 999px; background: #eef2ff; color: #273a89; }
.page { max-width: 1480px; margin: 0 auto; padding: 26px; }
.card { background: rgba(255,255,255,.94); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
.hero { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: stretch; margin: 10px 0 24px; }
.hero > div:first-child, .hero-card { padding: 34px; border-radius: 30px; }
.hero > div:first-child { background: linear-gradient(135deg, #172033, #30437d); color: white; box-shadow: var(--shadow); }
.eyebrow { color: #bcd0ff; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; }
.hero h1 { margin: 10px 0 12px; font-size: 42px; line-height: 1.05; max-width: 880px; }
.hero p { color: #dce6ff; font-size: 18px; max-width: 760px; }
.hero-card { background: #fff; display: flex; flex-direction: column; justify-content: center; gap: 12px; border: 1px solid var(--line); }
.hero-card b { font-size: 24px; }
.hero-card span { color: var(--muted); line-height: 1.5; }
.toolbar { padding: 16px; display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 22px; }
.filters { display: flex; gap: 12px; flex: 1; }
input, textarea, select {
  width: 100%; padding: 13px 14px; border: 1px solid #d0d5dd; border-radius: 14px; background: #fff; color: var(--text); font: inherit;
}
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 8px; font-weight: 700; color: #344054; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: 14px; border: 1px solid #ccd2e2;
  background: #fff; color: #263043; cursor: pointer; font-weight: 800; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); color: white; }
.btn.small { padding: 8px 11px; border-radius: 11px; font-size: 13px; }
.btn.tiny { padding: 6px 8px; border-radius: 9px; font-size: 12px; }
.btn.success { border-color: #bdebd9; color: var(--success); }
.btn.danger { border-color: #f4c7c7; color: var(--danger); }
.doc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.doc-card { padding: 22px; display: flex; flex-direction: column; gap: 10px; min-height: 260px; }
.doc-card h2 { margin: 4px 0; font-size: 20px; line-height: 1.25; }
.doc-card p { color: var(--muted); line-height: 1.55; flex: 1; }
.doc-meta, .doc-foot, .stats-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; color: var(--muted); font-size: 13px; }
.stats-row span { padding: 9px 10px; background: #f8f9fc; border-radius: 12px; }
.status { padding: 5px 9px; border-radius: 999px; font-weight: 850; font-size: 12px; }
.status.draft { background: #f2f4f7; color: #475467; }
.status.discussion { background: #eaf0ff; color: #2846b8; }
.status.expertise { background: #fff4df; color: #a15c00; }
.status.revision { background: #f1e9ff; color: #6b30ba; }
.status.completed { background: #e4f8ee; color: #087447; }
.status.archived { background: #eee; color: #555; }
.auth-card, .wide-card { max-width: 860px; margin: 26px auto; padding: 28px; }
.auth-card { max-width: 460px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.two-cols { display: grid; grid-template-columns: 1fr 240px; gap: 16px; }
.three-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.alert { padding: 13px 15px; border-radius: 14px; background: #fff7e6; border: 1px solid #ffd99b; color: #7a4a00; }
.alert.error { background: #fff0f0; border-color: #ffc7c7; color: #9b1c1c; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 28px; }
.doc-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) 420px; gap: 18px; align-items: start; }
.doc-toc, .comment-panel { position: sticky; top: 82px; max-height: calc(100vh - 102px); overflow: auto; padding: 18px; }
.doc-toc h3, .comment-panel h3 { margin: 0 0 14px; }
.toc-list { display: flex; flex-direction: column; gap: 6px; }
.toc-list a { display: flex; justify-content: space-between; gap: 8px; padding: 10px; border-radius: 12px; color: #344054; font-size: 13px; }
.toc-list a:hover { background: #f1f4ff; }
.toc-list b { background: #edf2ff; color: var(--primary); padding: 1px 7px; border-radius: 999px; }
.toc-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.doc-main { padding: 28px; }
.doc-titlebar h1 { margin: 12px 0 8px; font-size: 32px; line-height: 1.15; }
.doc-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0 24px; }
.doc-summary div { background: #f8f9fc; border: 1px solid #eef0f5; border-radius: 16px; padding: 14px; }
.doc-summary b { display: block; font-size: 26px; }
.doc-summary span { color: var(--muted); font-size: 13px; }
.document-text { display: flex; flex-direction: column; gap: 10px; }
.doc-block { position: relative; padding: 16px 78px 16px 18px; border: 1px solid transparent; border-radius: 18px; line-height: 1.7; }
.doc-block:hover { border-color: #dbe3ff; background: #fbfcff; }
.doc-block p { margin: 0; white-space: pre-wrap; }
.section-block { background: #f8f9fc; font-weight: 850; }
.block-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; align-items: center; }
.icon-btn { border: 0; background: #f1f4f9; color: #344054; border-radius: 11px; padding: 7px 9px; cursor: pointer; font-weight: 800; }
.icon-btn:hover { background: #e8edff; color: var(--primary); }
.mini-badge { font-size: 12px; padding: 5px 7px; background: #eff4ff; color: #2846b8; border-radius: 999px; font-weight: 850; }
.mini-badge.danger { background: #fff1f1; color: var(--danger); }
.selection-toolbar {
  position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translateX(-50%);
  padding: 10px; background: rgba(16,24,40,.9); border-radius: 18px; box-shadow: var(--shadow);
}
.comment-panel { transition: transform .2s ease; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 12px; }
.panel-head span { color: var(--muted); font-size: 13px; }
.new-comment { padding: 14px; background: #f8f9fc; border-radius: 18px; margin-bottom: 14px; }
.new-comment h4 { margin: 0 0 10px; }
.selected-preview, .quote { border-left: 4px solid var(--primary); background: #eef3ff; padding: 10px 12px; border-radius: 12px; margin: 10px 0; color: #263043; }
.suggestion-fields { display: none; }
.panel-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip { border: 1px solid #d0d5dd; background: white; border-radius: 999px; padding: 7px 10px; cursor: pointer; font-weight: 800; font-size: 12px; color: #344054; }
.chip.active, .chip:hover { border-color: var(--primary); color: var(--primary); background: #eef3ff; }
.comments-list { display: flex; flex-direction: column; gap: 12px; }
.comment-card { border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: #fff; }
.comment-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.type { padding: 5px 8px; border-radius: 999px; font-size: 12px; font-weight: 900; background: #f2f4f7; color: #475467; }
.type.question { background: #eaf0ff; color: #3157d5; }
.type.suggestion { background: #e6f7ef; color: #087447; }
.type.legal_risk, .type.corruption_risk, .type.contradiction { background: #fff0f0; color: #b42318; }
.type.finance { background: #fff7e6; color: #a15c00; }
.type.technical { background: #f2f4f7; color: #475467; }
.type.support { background: #ecfdf3; color: #067647; }
.comment-status { color: var(--muted); font-size: 12px; }
.comment-meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.comment-body { line-height: 1.5; }
.suggestion-box { margin-top: 12px; border: 1px solid #cfe8da; background: #f6fffa; border-radius: 16px; padding: 12px; }
.suggestion-title { color: var(--success); font-weight: 900; margin-bottom: 8px; }
.diff-row { margin: 10px 0; }
.diff-row span { display: inline-block; font-size: 12px; font-weight: 900; color: #8a3b3b; margin-bottom: 4px; }
.diff-row.good span { color: var(--success); }
pre { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0; padding: 10px; border-radius: 12px; background: #fff; border: 1px solid #e4e7ec; }
.reason { margin-top: 10px; color: #344054; }
.vote-row, .status-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.reply { margin-top: 10px; padding: 10px; background: #f8f9fc; border-radius: 14px; }
.reply-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.footer { max-width: 1480px; margin: 0 auto; padding: 22px 26px 40px; color: var(--muted); font-size: 13px; }
@media (max-width: 1180px) {
  .doc-shell { grid-template-columns: 1fr; }
  .doc-toc, .comment-panel { position: static; max-height: none; }
  .comment-panel { display: none; }
  .comment-panel.open { display: block; }
  .hero { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .page { padding: 14px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topnav { flex-wrap: wrap; }
  .hero h1 { font-size: 31px; }
  .toolbar, .filters { flex-direction: column; align-items: stretch; }
  .doc-grid, .two-cols, .three-cols, .doc-summary { grid-template-columns: 1fr; }
  .doc-main { padding: 18px; }
  .doc-block { padding-right: 16px; }
  .block-actions { position: static; margin-bottom: 8px; }
}
