:root {
  --ink: #071633;
  --muted: #687693;
  --line: #dde6f2;
  --panel: #ffffff;
  --panel-soft: #f6f9fd;
  --nav: #102540;
  --nav-2: #173557;
  --blue: #145bbb;
  --blue-dark: #0b428f;
  --green: #177245;
  --green-soft: #dff3e9;
  --amber: #a55b00;
  --amber-soft: #fff0cf;
  --shadow: 0 18px 50px rgba(20, 42, 72, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f3f7fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

#demoAccessControl[hidden] { display: none; }
#demoAccessCode { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
#processingStatus { font-size: 13px; overflow-wrap: anywhere; }

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 16px;
  color: white;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.brand-mark svg,
.doc-stack svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  color: rgba(255, 255, 255, 0.84);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.icon {
  width: 24px;
  text-align: center;
}

.sidebar-note {
  margin: auto 12px 4px;
  padding-top: 22px;
  color: rgba(255, 255, 255, 0.62);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cui-banner {
  padding: 9px 32px;
  color: #7a2500;
  background: #fff0cf;
  border-bottom: 1px solid #f4d89a;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 2px;
  font-size: 32px;
  line-height: 1.1;
}

.topbar p,
.matrix-header p,
.packet-card p,
.assurance-card p,
.drop-zone p,
.brief-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  color: #0f613b;
  background: var(--green-soft);
  border-radius: 8px;
  font-weight: 700;
}

.status-pill span {
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 999px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 28px 32px;
  background: #fbfdff;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-weight: 800;
  cursor: pointer;
}

.step span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: #e3ebf5;
  border-radius: 999px;
}

.step.active {
  color: var(--blue-dark);
}

.step.active span {
  color: white;
  background: var(--blue);
}

.step-line {
  width: 110px;
  height: 2px;
  background: #c9d5e5;
}

.step-panel {
  display: none;
  padding: 0 32px 32px;
}

.step-panel.active {
  display: grid;
}

.panel-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
}

.rubric-layout {
  display: none;
  padding: 0 32px 32px;
}

body[data-view="rubric"] .rubric-layout {
  display: grid;
}

.drop-zone,
.assurance-card,
.records-list,
.evidence-brief,
.matrix-card,
.packet-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 470px;
  padding: 40px;
  border-style: dashed;
  text-align: center;
}

.drop-zone.dragover {
  border-color: var(--blue);
  background: #f2f7ff;
}

.doc-stack {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  color: var(--blue);
  background: #edf4ff;
  border-radius: 8px;
}

.drop-zone h2 {
  margin: 22px 0 8px;
  font-size: 30px;
}

.drop-zone small {
  margin-top: 18px;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  color: white;
  background: var(--blue);
}

.button.primary:hover {
  background: var(--blue-dark);
}

.button.secondary {
  color: var(--blue-dark);
  background: white;
  border-color: #9eb9df;
}

.button.ghost {
  min-height: 42px;
  margin-top: 12px;
  color: #39506e;
  background: transparent;
  border-color: var(--line);
}

.assurance-card,
.packet-card {
  padding: 32px;
}

.shield {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 8px;
  font-size: 30px;
  font-weight: 900;
}

.assurance-card h3 {
  margin: 22px 0 10px;
  font-size: 24px;
}

.assurance-card ul {
  display: grid;
  gap: 22px;
  margin: 32px 0 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.assurance-card li {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 800;
}

.assurance-card li span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: white;
  background: var(--green);
  border-radius: 999px;
}

.control-stack {
  display: grid;
  gap: 14px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.control-stack h4 {
  margin: 0;
}

.control-stack label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.control-stack select,
.rubric-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.review-layout {
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
}

.records-list {
  overflow: hidden;
}

.list-header {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.list-header h2 {
  margin-bottom: 14px;
}

.list-header input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#recordList {
  max-height: 620px;
  overflow: auto;
  padding: 10px;
}

.record-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.record-row.active,
.record-row:hover {
  background: #edf4ff;
}

.record-row strong {
  display: block;
}

.record-row small {
  color: var(--muted);
}

.chip {
  align-self: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.chip.ready,
.chip.strong,
.chip.approved {
  color: #07512f;
  background: var(--green-soft);
}

.chip.review,
.chip.moderate {
  color: var(--amber);
  background: var(--amber-soft);
}

.chip.neutral {
  color: #17497e;
  background: #e7f0ff;
}

.record-row .chip {
  justify-self: end;
  max-width: 142px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 20px;
}

.evidence-brief {
  padding: 24px;
}

.brief-header,
.matrix-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.brief-header h2,
.matrix-header h2,
.packet-card h2 {
  margin-bottom: 4px;
  font-size: 30px;
}

.quality {
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 800;
}

.quality.review {
  color: var(--amber);
  background: var(--amber-soft);
}

.quality.ready {
  color: #07512f;
  background: var(--green-soft);
}

.quality.neutral {
  color: #39506e;
  background: #edf1f7;
}

#briefSections {
  display: grid;
  gap: 16px;
}

.brief-section {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  color: var(--blue);
  background: #edf4ff;
  border-radius: 8px;
  font-weight: 900;
}

.brief-section h3 {
  margin-bottom: 10px;
}

.brief-section ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: #354563;
}

.evidence-items {
  display: grid;
  gap: 10px;
}

.evidence-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.evidence-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: #263855;
  cursor: pointer;
  font-weight: 750;
  list-style: none;
}

.evidence-item summary::-webkit-details-marker {
  display: none;
}

.evidence-item summary::before {
  content: "+";
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--blue-dark);
  background: #edf4ff;
  border-radius: 999px;
  font-weight: 900;
}

.evidence-item[open] summary::before {
  content: "-";
}

.evidence-detail {
  padding: 0 14px 14px 48px;
  color: #4c5d78;
}

.evidence-detail p {
  margin-bottom: 10px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-meta span {
  padding: 5px 9px;
  color: #39506e;
  background: #edf1f7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.source {
  display: inline-block;
  margin-left: 8px;
  padding: 5px 9px;
  color: #39506e;
  background: #edf1f7;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.brief-actions {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding: 28px;
  background: rgba(9, 24, 45, 0.46);
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
  display: none;
}

.editor-modal {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(880px, 100%);
  max-height: calc(100dvh - 56px);
  animation: editor-drop 180ms ease-out;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(9, 24, 45, 0.26);
}

.editor-header,
.editor-toolbar,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.editor-header h2 {
  font-size: 22px;
}

.editor-header p {
  margin-top: 3px;
  color: var(--muted);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #253956;
  background: #f6f9fd;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.editor-toolbar {
  background: #f8fbff;
}

.editor-toolbar label {
  display: grid;
  gap: 6px;
  min-width: 280px;
  color: #3e506c;
  font-size: 13px;
  font-weight: 800;
}

.editor-toolbar select,
.editor-field input,
.editor-field textarea,
.editor-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #10213d;
  background: #fff;
  font: inherit;
}

.editor-toolbar select {
  padding: 11px 12px;
}

.editor-list {
  display: grid;
  gap: 14px;
  padding: 18px 22px;
  overflow: auto;
  overscroll-behavior: contain;
  align-content: start;
  min-height: 160px;
}

.editor-row {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.finding-heading { display: flex; align-items: center; gap: 12px; padding: 16px 0; cursor: pointer; list-style: none; }
.finding-heading::-webkit-details-marker { display: none; }
.finding-number { flex: 0 0 30px; color: #536881; font-size: 12px; font-weight: 700; }
.finding-title { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; line-height: 1.5; }
.finding-chevron { color: #536881; }
.editor-row[open] .finding-chevron { transform: rotate(180deg); }
.finding-fields { display: grid; gap: 16px; padding: 4px 0 22px 42px; }
.editor-row-header strong { font-size: 12px; color: var(--muted); }
.delete-evidence { color: #a12b35; }
.editor-modal :focus-visible { outline: 3px solid #6299e1; outline-offset: 3px; }
.editor-modal button:disabled { opacity: .45; cursor: default; }
#editorSaveState { margin-right: auto; color: var(--muted); font-size: 13px; }
#editorDiscardPrompt:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; width: 100%; color: #8a3430; }
@keyframes editor-drop { from { opacity: 0; transform: translateY(-18px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .editor-modal { animation: none; } }
@media (max-width: 720px) {
  .modal-backdrop { padding: 12px; }
  .editor-modal { max-height: calc(100dvh - 24px); }
  .finding-fields { padding-left: 0; }
  .editor-toolbar label { min-width: 0; width: 100%; }
  #editorSaveState { width: 100%; }
  .editor-actions { flex-wrap: wrap; }
}

.editor-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-row-header strong {
  color: #10213d;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 12px;
}

.editor-field {
  display: grid;
  gap: 6px;
  color: #3e506c;
  font-size: 13px;
  font-weight: 800;
}

.editor-field input,
.editor-field select {
  padding: 10px 12px;
  font-weight: 400;
}

.editor-field textarea {
  font-weight: 400;
  min-height: 86px;
  padding: 11px 12px;
  resize: vertical;
}

.editor-field.full {
  grid-column: 1 / -1;
}

.editor-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: #f8fbff;
}

.export-layout {
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
}

.matrix-card {
  padding: 24px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

th,
td {
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: #173557;
  background: #f2f6fb;
}

tr:last-child td {
  border-bottom: 0;
}

.packet-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.packet-card label {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 800;
}

.full {
  width: 100%;
}

.info-box {
  padding: 16px;
  color: #586985;
  background: var(--panel-soft);
  border-radius: 8px;
}

.audit-preview {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.audit-preview h3 {
  margin-bottom: 0;
  font-size: 18px;
}

#auditLog {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.audit-row {
  display: grid;
  gap: 3px;
  padding: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.audit-row span,
.audit-row small,
.mini-muted {
  color: var(--muted);
  font-size: 12px;
}

.rubric-input {
  max-width: 130px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(120px);
  max-width: 360px;
  padding: 16px 18px;
  color: white;
  background: #173557;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .panel-grid,
  .review-layout,
  .export-layout {
    grid-template-columns: 1fr;
  }

  .stepper {
    justify-content: flex-start;
    overflow-x: auto;
  }
}

@media (max-width: 720px) {
  .topbar,
  .brief-header,
  .matrix-header,
  .editor-header,
  .editor-toolbar,
  .editor-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .step-line {
    width: 40px;
  }

  .step-panel {
    padding: 0 16px 24px;
  }

  h1 {
    font-size: 26px;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .editor-header,
  .editor-actions {
    flex-direction: row;
    align-items: center;
    padding: 14px 16px;
    gap: 10px;
  }

  .editor-header > div { min-width: 0; }
  .editor-header p { overflow-wrap: anywhere; font-size: 13px; }
  .editor-header .icon-button { flex-shrink: 0; }
  .editor-actions > button { flex: 1; }
}
