:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #fff;
  --line: #e4e4e7;
  --soft-line: #f1f1f3;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --black: #18181b;
  --violet: #7c3aed;
  --sky: #0284c7;
  --green: #059669;
  --red: #e11d48;
  --amber: #b45309;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
  padding: 0 22px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 300px; }
.brand img { width: 204px; height: auto; display: block; }
.brand-copy { border-left: 1px solid var(--line); padding-left: 13px; line-height: 1.15; }
.brand-copy strong { display: block; color: #71717a; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.brand-copy span { display: block; color: #a1a1aa; font-size: 12px; margin-top: 2px; }
.mainnav { display: flex; align-items: center; gap: 4px; }
.navlink, .tiny-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #52525b;
  font-weight: 500;
  padding: 8px 11px;
}
.navlink.active { background: #18181b; color: white; }
.navlink:hover, .tiny-btn:hover, .icon-btn:hover { background: #f4f4f5; color: #18181b; }
.top-actions { display: flex; align-items: center; gap: 8px; min-width: 300px; justify-content: flex-end; }
.tiny-btn { border: 1px solid #d4d4d8; background: white; padding: 7px 10px; font-size: 12px; }
.admin-btn { background: #f4f4f5; border-color: transparent; font-size: 14px; }
.app-layout { display: flex; min-height: calc(100vh - 57px); }
.sidebar {
  position: sticky;
  top: 57px;
  width: 287px;
  height: calc(100vh - 57px);
  flex: 0 0 287px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: white;
}
.sidebar-head { padding: 17px 16px; border-bottom: 1px solid #f4f4f5; }
.eyebrow { color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.sidebar-count { margin-top: 7px; color: #3f3f46; }
.summary-nav { padding: 12px 0; }
.summary-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 0;
  background: transparent;
  color: #3f3f46;
  text-align: left;
  padding: 7px 16px;
  font-size: 12px;
}
.summary-btn:hover, .summary-btn.active { background: #f4f4f5; }
.summary-btn.level-0 { font-size: 14px; font-weight: 700; }
.summary-btn.level-1 { padding-left: 29px; }
.summary-btn.level-2 { padding-left: 43px; }
.summary-code { color: #71717a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-right: 5px; }
.status-dot {
  width: 12px; height: 12px; flex: 0 0 12px; margin-top: 3px;
  border: 1px solid #d4d4d8; border-radius: 999px; display: inline-grid; place-items: center;
}
.status-dot.a_valider { border-color: #8b5cf6; box-shadow: inset 0 0 0 3px #fff; background: #8b5cf6; }
.status-dot.en_production { border-color: #0284c7; background: #e0f2fe; }
.status-dot.valide { border-color: #34d399; background: #d1fae5; }
.status-dot.valide::after { content: "✓"; color: #059669; font-size: 10px; line-height: 1; }

.status-dot.produced { border-color: #8b5cf6; box-shadow: inset 0 0 0 3px #fff; background: #8b5cf6; }
.status-dot.running { border-color: #0284c7; background: #e0f2fe; }
.status-dot.escalated { border-color: #f59e0b; background: #fffbeb; }
.status-dot.audit_ko { border-color: #e11d48; background: #fff1f2; }
.status-dot.validated { border-color: #34d399; background: #d1fae5; }
.status-dot.validated::after { content: "✓"; color: #059669; font-size: 10px; line-height: 1; }

.content {
  flex: 1;
  min-width: 0;
  padding: 0;
}
.report {
  max-width: 770px;
  margin-left: 64px;
  padding: 28px 0 80px;
}
.block {
  scroll-margin-top: 76px;
  margin: 0 0 34px;
  padding: 0;
  border: 0;
  background: transparent;
}
.block.clickable { cursor: pointer; }
.block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.block-status { color: var(--violet); font-size: 18px; line-height: 1; }
.block-code { color: #71717a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.block h2 { margin: 0; font-size: 20px; line-height: 1.25; font-weight: 700; letter-spacing: 0; }
.meta-row { display: flex; align-items: center; gap: 7px; margin: 0 0 12px; color: #a1a1aa; font-size: 12px; }
.pill { display: inline-flex; align-items: center; border: 1px solid #d4d4d8; border-radius: 6px; background: white; color: #3f3f46; padding: 3px 8px; font-size: 12px; font-weight: 500; }
.report-text { font-size: 16px; line-height: 1.65; color: #27272a; margin: 18px 0 0; white-space: pre-line; }
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-size: 14px;
}
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid #f1f1f3; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table th { text-align: left; color: #71717a; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; background: #fafafa; }
.data-table td:nth-child(n+2), .data-table th:nth-child(n+2) { text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pos { color: #00875a; font-weight: 600; }
.neg { color: #e11d48; font-weight: 600; }

.drawer-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
}
.drawer-backdrop { position: absolute; inset: 0; background: rgba(24,24,27,.34); border: 0; }
.drawer {
  position: relative;
  width: min(720px, 100vw);
  height: 100vh;
  background: white;
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 70px rgba(24,24,27,.24);
  display: flex;
  flex-direction: column;
}
.drawer-header { padding: 18px 20px 0; border-bottom: 1px solid var(--line); background: white; }
.drawer-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.drawer-kicker { display: flex; align-items: center; gap: 9px; color: #71717a; font-size: 12px; }
.drawer-dot { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 999px; color: #7c3aed; border: 1px solid #8b5cf6; font-size: 11px; }
.state-badge { color: #7c3aed; font-weight: 700; }
.drawer h2 { margin: 10px 0 0; font-size: 20px; line-height: 1.25; }
.drawer-sub { display: flex; gap: 14px; margin-top: 12px; color: #71717a; font-size: 12px; }
.close-btn { border: 0; background: transparent; color: #71717a; font-size: 25px; line-height: 1; width: 32px; height: 32px; border-radius: 8px; }
.close-btn:hover { background: #f4f4f5; color: #18181b; }
.tabs { display: flex; gap: 20px; margin-top: 16px; }
.tab { display: inline-flex; align-items: center; gap: 7px; border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 11px 0; color: #52525b; font-size: 13px; font-weight: 500; }
.tab.active { color: #18181b; border-bottom-color: #18181b; font-weight: 700; }
.header-chain {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0 12px;
  color: #52525b;
  font-size: 12px;
  font-weight: 700;
}
.header-chain div {
  flex: 1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #f1f5f9;
}
.header-chain i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, #10b981);
  transition: width .45s ease;
}
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.drawer-section { margin-bottom: 22px; }
.section-title { color: #71717a; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 10px; }
.notice { border: 1px solid #a7f3d0; background: #ecfdf5; color: #047857; border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.info-card { border: 1px solid var(--line); background: #fafafa; border-radius: 8px; padding: 14px; color: #52525b; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.flow-list { display: grid; gap: 8px; }
.flow-item { display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: white; }
.flow-num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: #18181b; color: white; font-weight: 800; font-size: 12px; flex: 0 0 24px; }
.chain-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  padding: 13px 14px;
  margin: 0 0 16px;
}
.chain-card.compact {
  color: #52525b;
}
.chain-card.compact strong {
  display: block;
  color: #3f3f46;
  font-size: 13px;
  margin-bottom: 3px;
}
.chain-card.compact a {
  color: #52525b;
  font-size: 12px;
  text-decoration: underline;
}
.chain-card.running {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border-color: #cbd5e1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.chain-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.chain-head strong {
  font-size: 14px;
}
.chain-head p {
  margin: 3px 0 0;
  color: #64748b;
  font-size: 12px;
}
.chain-head span {
  align-self: flex-start;
  border-radius: 999px;
  background: #18181b;
  color: white;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}
.agent-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  position: relative;
}
.agent-step {
  position: relative;
  min-height: 98px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: white;
  padding: 12px;
  transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease, background .25s ease;
}
.agent-step strong {
  display: block;
  margin-top: 8px;
  font-size: 13px;
}
.agent-step div div {
  color: #71717a;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 3px;
}
.agent-step small {
  display: inline-block;
  margin-top: 8px;
  color: #71717a;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.agent-node {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #f4f4f5;
  color: #71717a;
  font-size: 12px;
  font-weight: 800;
}
.agent-step.running {
  border-color: #7c3aed;
  background: #fbfaff;
  box-shadow: 0 0 0 3px rgba(124,58,237,.12), 0 14px 28px rgba(124,58,237,.12);
  transform: translateY(-2px);
}
.agent-step.running .agent-node {
  background: #7c3aed;
  color: white;
  animation: pulse-agent 1s ease-in-out infinite;
}
.agent-step.done {
  border-color: #a7f3d0;
  background: #f0fdf4;
}
.agent-step.done .agent-node {
  background: #10b981;
  color: white;
}
.agent-step.queued {
  opacity: .72;
}
@keyframes pulse-agent {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,58,237,.35); }
  50% { box-shadow: 0 0 0 7px rgba(124,58,237,0); }
}
.source-card, .audit-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: white; margin-bottom: 10px; }
.excerpt { background: #f8fafc; border: 1px solid #eef2f7; border-radius: 6px; padding: 10px; color: #52525b; font-size: 12px; line-height: 1.5; margin-top: 10px; }
.edit-area { width: 100%; min-height: 220px; resize: vertical; border: 1px solid #d4d4d8; border-radius: 8px; padding: 12px; line-height: 1.55; }
.drawer-footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line); background: white; }
.btn { border: 1px solid transparent; border-radius: 7px; padding: 9px 13px; font-weight: 700; font-size: 13px; background: #f4f4f5; color: #52525b; }
.btn.primary { background: #009b72; color: white; }
.btn.dark { background: #18181b; color: white; }
.btn.outline { border-color: #d4d4d8; background: white; color: #3f3f46; }
.btn.danger { background: #fff1f2; color: #be123c; }
.footer-actions { display: flex; gap: 8px; align-items: center; }

.page { padding: 28px 32px 80px; }
.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.page h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.page p.lead { margin: 6px 0 0; color: #71717a; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: 10px; background: white; padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.clickable-card { cursor: pointer; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.clickable-card:hover { border-color: #a1a1aa; box-shadow: 0 8px 22px rgba(24,24,27,.08); transform: translateY(-1px); }
.card h3 { margin: 0; font-size: 16px; }
.card p { color: #52525b; line-height: 1.5; }
.admin-layout { display: flex; min-height: calc(100vh - 57px); }
.admin-side { width: 244px; flex: 0 0 244px; border-right: 1px solid var(--line); background: white; padding: 18px 12px; }
.admin-side button { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 8px; padding: 10px 12px; color: #52525b; font-weight: 600; }
.admin-side button.active, .admin-side button:hover { background: #f4f4f5; color: #18181b; }
.timeline { border-left: 2px solid #e4e4e7; margin-left: 8px; padding-left: 18px; display: grid; gap: 12px; }
.timeline-item { position: relative; background: white; border: 1px solid var(--line); border-radius: 9px; padding: 13px; }
.timeline-item::before { content: ""; position: absolute; left: -25px; top: 18px; width: 10px; height: 10px; border-radius: 999px; background: #8b5cf6; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 1200; background: #18181b; color: white; padding: 10px 14px; border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,.24); }

.audit-page {
  padding: 0 32px 80px;
}
.audit-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin: 0 -32px;
  padding: 26px 32px 24px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.audit-hero h1 {
  margin: 12px 0 6px;
  font-size: 24px;
  line-height: 1.15;
}
.audit-hero p {
  margin: 0;
  color: #52525b;
  line-height: 1.45;
}
.audit-hero .btn {
  margin-top: 22px;
}
.audit-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 32px 0 28px;
}
.audit-kpi {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: white;
  padding: 13px 16px;
}
.audit-kpi strong {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f4f4f5;
  font-size: 15px;
}
.audit-kpi.ok strong { background: #d1fae5; color: #059669; }
.audit-kpi.ko strong { background: #ffe4e6; color: #e11d48; }
.audit-kpi.na strong { background: #f4f4f5; color: #18181b; }
.audit-kpi span { color: #52525b; font-size: 12px; }
.audit-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #d4d4d8;
  margin-bottom: 24px;
}
.audit-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #52525b;
  padding: 11px 16px 10px;
  font-weight: 500;
}
.audit-tab.active {
  border-bottom-color: #18181b;
  color: #18181b;
}
.ko-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #fecdd3;
  border-radius: 6px;
  background: #fff1f2;
  color: #e11d48;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 700;
}
.audit-table-card {
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: white;
  overflow: hidden;
  box-shadow: 0 1px 5px rgba(24,24,27,.08);
}
.audit-table {
  width: 100%;
  border-collapse: collapse;
}
.audit-table th,
.audit-table td {
  padding: 14px 20px;
  border-bottom: 1px solid #f1f1f3;
  text-align: left;
  vertical-align: top;
}
.audit-table th {
  color: #71717a;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.audit-table tr:last-child td { border-bottom: 0; }
.audit-table tbody tr { cursor: pointer; }
.audit-table tbody tr:hover td { background: #fafafa; }
.audit-table tbody tr.ko td { background: #fffafa; }
.audit-table tbody tr.ko:hover td { background: #fff1f2; }
.audit-badge {
  display: inline-flex;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}
.audit-badge.ko { border: 1px solid #fecdd3; background: #fff1f2; color: #e11d48; }
.audit-badge.ok { border: 1px solid #bbf7d0; background: #f0fdf4; color: #059669; }
.audit-badge.na { background: #f4f4f5; color: #52525b; }
.chevron {
  width: 28px;
  color: #a1a1aa;
  font-size: 24px;
  text-align: right !important;
}
.audit-note {
  margin-top: 22px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: white;
  padding: 14px 16px;
  color: #3f3f46;
  font-size: 13px;
}
.field-label {
  display: block;
  margin: 12px 0 6px;
  color: #71717a;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.person-select {
  width: 100%;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: white;
  padding: 10px 12px;
  color: #27272a;
  margin-bottom: 14px;
}

.plan-page { padding: 30px 42px 80px; }
.plan-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--line);
}
.crumb { color: #71717a; font-size: 13px; margin-bottom: 10px; }
.plan-hero h1 { margin: 0; font-size: 34px; line-height: 1.08; }
.plan-hero p { max-width: 760px; color: #52525b; font-size: 16px; line-height: 1.55; }
.plan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0; }
.plan-card { border: 1px solid var(--line); border-radius: 10px; background: white; padding: 18px; }
.plan-card strong { display: block; font-size: 28px; }
.plan-card span { color: #71717a; }
.plan-columns { display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(360px, .85fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 10px; background: white; overflow: hidden; }
.panel h2 { margin: 0; padding: 18px 20px; border-bottom: 1px solid #f1f1f3; font-size: 19px; }
.stack { display: grid; gap: 18px; }
.plan-tree { max-height: 630px; overflow: auto; padding: 10px 0; }
.tree-row { display: grid; grid-template-columns: 88px 1fr 160px; gap: 10px; align-items: center; padding: 9px 18px; border-bottom: 1px solid #fafafa; }
.tree-row.level-1 { padding-left: 34px; }
.tree-row.level-2 { padding-left: 50px; }
.tree-row span { color: #71717a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tree-row em { color: #a1a1aa; font-style: normal; font-size: 12px; }
.conflict, .proposal { margin: 14px; border-radius: 9px; padding: 13px; border: 1px solid #e4e4e7; }
.conflict.high { border-color: #fecdd3; background: #fff1f2; color: #9f1239; }
.conflict.medium { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.proposal.acceptable { border-color: #bbf7d0; background: #f0fdf4; }
.proposal.not_acceptable { border-color: #fecdd3; background: #fff1f2; }
.proposal span { display: inline-flex; margin-bottom: 7px; font-size: 12px; font-weight: 800; text-transform: uppercase; color: #71717a; }

.empty-block {
  border: 1px dashed #d4d4d8;
  border-radius: 9px;
  background: white;
  padding: 18px;
  color: #52525b;
}
.empty-block.small { padding: 12px; font-size: 13px; }
.empty-drawer {
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: linear-gradient(180deg, #eff6ff 0%, #fff 100%);
  padding: 22px;
  margin-bottom: 16px;
}
.empty-drawer h3 { margin: 0 0 8px; font-size: 20px; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 14px; }
.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.audit-ko {
  border: 2px solid #fda4af;
  background: linear-gradient(180deg, #fff1f2 0%, #fff 100%);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.audit-ko-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; color: #9f1239; font-size: 18px; }
.audit-ko article { margin-top: 12px; border: 1px solid #fecdd3; border-radius: 8px; background: white; padding: 13px; }
.audit-ko article span { color: #be123c; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.section-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ghost-link { border: 0; background: transparent; color: #52525b; text-decoration: underline; font-size: 13px; }
.produced-text {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: 9px;
  padding: 16px;
  color: #27272a;
  font-size: 16px;
  line-height: 1.65;
}
.preline { white-space: pre-line; line-height: 1.6; margin-top: 14px; }
.source-cell { cursor: help; }
.source-cell:hover { background: #f0f9ff; }
.cell-input { width: 100%; border: 1px solid #d4d4d8; border-radius: 6px; padding: 6px; text-align: right; }
.cite {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bae6fd;
  border-radius: 5px;
  background: #e0f2fe;
  color: #0369a1;
  padding: 1px 7px;
  margin: 0 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  font-size: 12px;
}
.cite.figure, .cite-1 { background: #e0f2fe; border-color: #bae6fd; color: #0369a1; }
.cite.kb, .cite-2, .cite-4 { background: #dcfce7; border-color: #bbf7d0; color: #047857; }
.cite.contributor, .cite-3 { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.citation-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  color: #71717a;
  font-size: 13px;
}
.legend-chip {
  width: 18px;
  height: 14px;
  border-radius: 5px;
  border: 1px solid;
  display: inline-flex;
  flex: 0 0 auto;
}
.legend-chip.figure { background: #e0f2fe; border-color: #bae6fd; }
.legend-chip.contributor { background: #fef3c7; border-color: #fde68a; }
.legend-chip.kb { background: #dcfce7; border-color: #bbf7d0; }
.citation-legend em {
  margin-left: auto;
  font-style: normal;
  color: #71717a;
}
.citation-row { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #f1f1f3; background: white; padding: 10px 0; }
.manual-edited {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px 14px;
}
.manual-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid #facc15;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  padding: 3px 9px;
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 800;
}
.manual-chip.inline { margin-right: 8px; vertical-align: middle; }
.manual-cell { background: #fffbeb; box-shadow: inset 3px 0 0 #facc15; }
.source-popover {
  position: fixed;
  z-index: 1500;
  width: 380px;
  max-width: calc(100vw - 24px);
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: white;
  padding: 14px;
  box-shadow: 0 18px 48px rgba(24,24,27,.18);
}
.source-popover > div { display: flex; justify-content: space-between; color: #71717a; font-size: 12px; }
.source-popover h4 { margin: 12px 0 4px; }
.source-popover p { margin: 0 0 10px; color: #71717a; }
.source-popover blockquote { margin: 0; border-left: 3px solid #e4e4e7; padding-left: 12px; color: #52525b; font-style: italic; line-height: 1.5; }
.chat-panel { border: 1px solid var(--line); border-radius: 10px; background: white; padding: 16px; margin-bottom: 16px; }
.chat-panel h3 { margin: 0 0 12px; }
.chat-messages { display: grid; gap: 10px; }
.chat-msg { max-width: 86%; border-radius: 12px; padding: 10px 12px; background: #f4f4f5; }
.chat-msg.human { justify-self: end; background: #e0f2fe; }
.chat-msg p { margin: 5px 0 0; line-height: 1.45; }
.pending-reply {
  margin: 14px 0;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  background: #f0fdf4;
  padding: 12px;
}
.pending-reply p { margin: 6px 0 12px; line-height: 1.45; }

.admin-layout { background: #fafafa; }
.admin-side {
  width: 326px;
  flex-basis: 326px;
  padding: 24px 16px;
}
.admin-side img { width: 232px; display: block; margin: 14px 0 2px; }
.admin-side > span { color: #71717a; display: block; margin-bottom: 28px; }
.admin-side .back-report { color: #71717a; font-weight: 700; display: inline-flex; margin-bottom: 8px; }
.admin-side button { display: flex; align-items: center; gap: 11px; font-size: 16px; padding: 13px 16px; }
.reset-admin { position: sticky; top: calc(100vh - 86px); margin-top: 80px; justify-content: center; border: 1px solid #d4d4d8 !important; background: white !important; }
.admin-main { flex: 1; min-width: 0; }
.admin-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 24px 40px 28px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.admin-head h1 { margin: 0; font-size: 30px; }
.admin-head p { margin: 8px 0 0; color: #71717a; font-size: 17px; }
.rich-agent-card { align-items: flex-start; }
.agent-deps {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f1f3;
}
.agent-deps strong {
  display: block;
  margin-bottom: 6px;
  color: #52525b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.agent-deps p {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}
.admin-card-grid { display: grid; grid-template-columns: repeat(2, minmax(300px, 1fr)); gap: 20px; padding: 40px; }
.admin-card {
  display: grid;
  grid-template-columns: 52px 1fr 20px;
  gap: 16px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 24px;
  box-shadow: 0 1px 5px rgba(24,24,27,.08);
  cursor: pointer;
}
.admin-card:hover { border-color: #a1a1aa; box-shadow: 0 10px 30px rgba(24,24,27,.10); }
.admin-card h2 { margin: 0; font-size: 21px; }
.admin-card p { color: #52525b; line-height: 1.45; font-size: 16px; }
.icon-tile { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 9px; background: linear-gradient(135deg, #0ea5e9, #7c3aed); color: white; font-size: 24px; }
.bot-tile { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 9px; background: #18181b; color: white; font-size: 22px; }
.metric-row { display: flex; flex-wrap: wrap; gap: 12px; color: #71717a; font-size: 13px; margin: 12px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span, .mini-pill, .kb-pill, .ok-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  background: #f4f4f5;
  color: #52525b;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}
.kb-pill { background: #ecfeff; color: #0e7490; border: 1px solid #bae6fd; }
.ok-pill { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 40px; }
.admin-stats article { border: 1px solid var(--line); border-radius: 12px; background: white; padding: 20px; }
.admin-stats strong { display: block; font-size: 30px; }
.admin-stats span { color: #71717a; }
.admin-table { margin: 40px; border: 1px solid var(--line); border-radius: 12px; background: white; overflow: hidden; }
.admin-table h2 { padding: 18px 24px; margin: 0; border-bottom: 1px solid var(--line); }
.admin-table table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 16px 24px; border-bottom: 1px solid #f1f1f3; text-align: left; vertical-align: top; }
.admin-table th { color: #71717a; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.admin-table tr { cursor: pointer; }
.admin-table tr:hover td { background: #fafafa; }
.admin-table em { display: block; color: #71717a; font-style: normal; margin-top: 4px; }
.team-panel { margin: 40px; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 24px; }
.team-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.team-grid article { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 14px; }
.team-grid article > span { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; background: #27272a; color: white; font-weight: 800; }
.team-grid p { margin: 3px 0 0; color: #71717a; }
.detail-layout { padding: 40px; }
.login-page { display: grid; place-items: center; min-height: calc(100vh - 57px); background: white; }
.login-card { width: min(390px, 100%); display: grid; gap: 10px; padding: 28px; }
.login-card img { width: 210px; margin: 0 auto; }
.login-card input { border: 1px solid #d4d4d8; border-radius: 8px; padding: 10px; }

@media (max-width: 900px) {
  .brand { min-width: auto; }
  .brand-copy { display: none; }
  .top-actions { min-width: auto; }
  .sidebar { display: none; }
  .report { margin: 0; padding: 22px 16px 70px; max-width: none; }
  .mainnav { gap: 2px; }
  .navlink { padding: 8px; }
  .info-grid { grid-template-columns: 1fr; }
  .plan-grid, .plan-columns, .admin-card-grid, .admin-stats, .team-grid { grid-template-columns: 1fr; }
  .admin-side { display: none; }
  .admin-head, .admin-card-grid, .admin-stats, .admin-table, .team-panel, .detail-layout { margin: 0; padding: 18px; }
}

/* Plan review, matched to the reset validation screen */
.plan-review-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 44px 0 72px;
}
.plan-review-hero {
  padding: 0 0 6px;
}
.plan-review-hero h1 {
  margin: 0 0 14px;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
  color: #09090b;
}
.plan-review-hero p {
  max-width: 820px;
  margin: 0;
  color: #3f3f46;
  font-size: 15px;
  line-height: 1.65;
}
.plan-review-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.plan-review-stat {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: #fff;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(24,24,27,.03);
}
.plan-review-stat > span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #f4f4f5;
  color: #52525b;
  font-weight: 900;
}
.plan-review-stat.green > span {
  background: #d1fae5;
  color: #059669;
}
.plan-review-stat.amber > span {
  background: #fef3c7;
  color: #d97706;
}
.plan-review-stat small {
  display: block;
  color: #71717a;
  font-size: 12px;
  line-height: 1.2;
}
.plan-review-stat strong {
  display: block;
  margin-top: 2px;
  color: #09090b;
  font-size: 18px;
  line-height: 1.1;
}
.plan-warning {
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 10px;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  background: #fffbeb;
  padding: 17px 20px;
  margin: 0 0 20px;
  box-shadow: 0 8px 18px rgba(217,119,6,.06);
}
.plan-warning::before {
  content: "!";
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 1px solid #f97316;
  border-radius: 999px;
  color: #ea580c;
  font-size: 12px;
  font-weight: 900;
}
.plan-warning strong {
  color: #18181b;
  font-size: 15px;
}
.plan-warning p {
  grid-column: 2;
  margin: 5px 0 0;
  color: #3f3f46;
  font-size: 13px;
}
.plan-structure-card {
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(24,24,27,.08);
}
.plan-structure-card header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid #f1f1f3;
}
.plan-structure-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.2;
}
.plan-structure-card p {
  margin: 0;
  color: #71717a;
  font-size: 13px;
}
.plan-structure-list {
  background: #fff;
}
.plan-chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 14px 20px;
  border-top: 1px solid #f4f4f5;
  background: #fcfcfd;
}
.plan-chapter-row:first-child {
  border-top: 0;
}
.plan-chapter-row strong {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: #09090b;
  font-size: 15px;
}
.plan-chapter-row strong span {
  color: #71717a;
  font-weight: 800;
}
.plan-chapter-row em {
  color: #52525b;
  font-size: 12px;
  font-style: normal;
}
.plan-sub-row {
  display: grid;
  grid-template-columns: 56px minmax(260px, 1fr) 88px auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-top: 1px solid #f1f1f3;
  background: #fff;
}
.plan-sub-row.has-modification {
  background: #fffdf7;
}
.plan-sub-row > strong {
  min-width: 0;
  color: #09090b;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-code,
.plan-page-ref {
  color: #8a8fa3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}
.plan-page-ref {
  text-align: right;
}
.plan-type-pill,
.plan-reprise-pill,
.plan-decision-chip {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  min-height: 24px;
  border: 1px solid #d4d4d8;
  border-radius: 7px;
  background: #fff;
  color: #27272a;
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}
.plan-reprise-pill {
  background: #f8fafc;
  color: #52525b;
}
.plan-reprise-pill.modified {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}
.plan-modification-box {
  grid-column: 2 / -1;
  margin: 2px 0 7px;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  background: #fffcf2;
  padding: 12px;
}
.plan-modification-box > div:first-child {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.plan-modification-box > div:first-child span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 1px solid #f97316;
  border-radius: 999px;
  color: #ea580c;
  font-size: 11px;
  font-weight: 900;
}
.plan-modification-box p {
  margin: 0;
  color: #27272a;
  font-size: 12px;
  line-height: 1.45;
}
.plan-mod-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
  padding-left: 26px;
}
.plan-mod-actions .btn {
  min-height: 28px;
  padding: 5px 10px;
  font-size: 12px;
}
.plan-decision-chip {
  justify-self: auto;
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #047857;
  font-weight: 800;
}
.plan-decision-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 24px 0 12px;
  border-radius: 10px;
  background: #18181b;
  color: white;
  padding: 17px 20px;
  box-shadow: 0 18px 38px rgba(24,24,27,.22);
}
.plan-decision-bar strong {
  display: block;
  font-size: 15px;
}
.plan-decision-bar p {
  margin: 5px 0 0;
  color: #fafafa;
  font-size: 12px;
}
.plan-decision-bar .btn {
  min-width: 162px;
}
.btn[disabled] {
  opacity: .48;
  cursor: not-allowed;
}
.plan-footnote {
  margin: 0;
  color: #71717a;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1080px) {
  .plan-review-page {
    max-width: none;
    margin: 0 18px;
  }
}

@media (max-width: 760px) {
  .plan-review-page {
    padding-top: 24px;
  }
  .plan-review-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .plan-sub-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .plan-page-ref,
  .plan-type-pill,
  .plan-reprise-pill {
    justify-self: start;
  }
  .plan-modification-box {
    grid-column: 1 / -1;
  }
  .plan-mod-actions {
    padding-left: 0;
  }
  .plan-decision-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .plan-decision-bar .btn {
    width: 100%;
  }
}
