:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --ink: #161a22;
  --muted: #647084;
  --line: #dce2ea;
  --line-strong: #c7d0dc;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --plum: #7c3aed;
  --amber: #b7791f;
  --red: #b42318;
  --green: #18794e;
  --blue: #2563eb;
  --shadow: 0 18px 50px rgba(22, 26, 34, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(245, 247, 250, 0.96) 260px),
    repeating-linear-gradient(90deg, rgba(22, 26, 34, 0.035) 0, rgba(22, 26, 34, 0.035) 1px, transparent 1px, transparent 72px);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon-sprite path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0 16px;
  background: rgba(245, 247, 250, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(220, 226, 234, 0.8);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(1.25rem, 1.1rem + 0.8vw, 2rem);
}

h2 {
  font-size: 1.05rem;
}

h3 {
  margin-top: 1rem;
  font-size: 0.98rem;
}

.toolbar,
.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button.primary {
  background: var(--teal);
  color: #fff;
}

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

.button.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

main {
  display: grid;
  gap: 16px;
  padding-top: 16px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 16px;
}

.output-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 0.8fr);
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.input-panel {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  min-height: 430px;
}

#rfp-input {
  width: 100%;
  min-height: 320px;
  height: 100%;
  resize: vertical;
  border: 0;
  border-radius: 0;
  padding: 16px;
  background: #fff;
  color: var(--ink);
  outline: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.91rem;
  line-height: 1.6;
}

#rfp-input:focus {
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.2);
}

.input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.summary-panel {
  display: grid;
  align-content: start;
}

.meter {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0deg, #e6ebf1 0deg);
  color: var(--ink);
  font-weight: 900;
}

.meter span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff;
  font-size: 0.92rem;
}

.summary-metrics {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  padding: 14px 16px 0;
}

.summary-metrics > div,
.status-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.metric-label,
.status-card span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.summary-metrics strong,
.status-card strong {
  display: block;
  margin-top: 2px;
  font-size: 1.3rem;
  line-height: 1.1;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 16px 16px;
}

.status-card {
  position: relative;
  overflow: hidden;
}

.status-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--status-color, var(--line-strong));
}

.matrix-panel {
  overflow: hidden;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.matrix-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
}

.matrix-table th {
  padding: 10px 10px;
  background: #f0f3f7;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.matrix-table th:nth-child(1) {
  width: 98px;
}

.matrix-table th:nth-child(2) {
  width: 33%;
}

.matrix-table th:nth-child(3) {
  width: 142px;
}

.matrix-table th:nth-child(4) {
  width: 150px;
}

.matrix-table th:nth-child(5),
.matrix-table th:nth-child(6) {
  width: 20%;
}

.matrix-table th:nth-child(7) {
  width: 130px;
}

.matrix-table td {
  vertical-align: top;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.matrix-table tr:nth-child(even) td {
  background: #fbfcfd;
}

.req-id {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef7f6;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.cell-input,
.cell-select,
.cell-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

.cell-input,
.cell-select {
  min-height: 38px;
  padding: 0 10px;
}

.cell-textarea {
  min-height: 76px;
  resize: vertical;
  padding: 9px 10px;
}

.requirement-text {
  min-height: 104px;
}

.cell-input:focus,
.cell-select:focus,
.cell-textarea:focus {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.status-select {
  font-weight: 800;
}

.status-select.status-comply {
  color: var(--green);
}

.status-select.status-partial {
  color: var(--amber);
}

.status-select.status-exception {
  color: var(--plum);
}

.status-select.status-no-bid {
  color: var(--red);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.icon-button:hover {
  background: var(--panel-soft);
  border-color: var(--line-strong);
}

.icon-button.danger {
  color: var(--red);
}

.document-output {
  padding: 16px;
}

.document-output p,
.document-output ul,
.document-output ol {
  margin: 0 0 12px;
}

.document-output ul,
.document-output ol {
  padding-left: 20px;
}

.document-output li + li {
  margin-top: 6px;
}

.document-output .empty-state {
  color: var(--muted);
}

.memo-output {
  border-top: 1px solid var(--line);
}

.score-badge {
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
}

.score-badge span {
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
}

.score-badge small {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.bid-controls {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.score-control {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
  align-items: center;
}

.score-control span {
  color: var(--muted);
  font-weight: 800;
}

.score-control strong {
  text-align: right;
  font-weight: 900;
}

.score-control input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--teal);
}

.tests-panel {
  overflow: hidden;
}

.test-summary {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--muted);
  font-weight: 900;
}

.test-summary.pass {
  background: #e8f5ef;
  color: var(--green);
}

.test-summary.fail {
  background: #fff1f0;
  color: var(--red);
}

.test-results {
  display: grid;
  gap: 8px;
  padding: 14px 16px 16px;
}

.test-row {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.test-row strong {
  font-size: 0.8rem;
}

.test-row.pass strong {
  color: var(--green);
}

.test-row.fail strong {
  color: var(--red);
}

.test-row code {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
}

.notice {
  padding: 12px 14px;
  border: 1px solid #e8d6aa;
  border-radius: var(--radius);
  background: #fff9eb;
  color: #5c430b;
  font-size: 0.9rem;
}

@media (max-width: 1100px) {
  .topbar,
  .workspace-grid,
  .output-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .toolbar {
    justify-content: start;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1540px);
    padding-top: 8px;
  }

  .brand-lockup {
    min-width: 0;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 0.85rem;
  }

  .toolbar,
  .button-row {
    width: 100%;
  }

  .button {
    flex: 1 1 auto;
    min-width: 92px;
  }

  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-metrics,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .test-row {
    grid-template-columns: 1fr;
  }
}

@media print {
  :root {
    --line: #c9c9c9;
    --shadow: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .no-print,
  .toolbar,
  .input-panel,
  .tests-panel,
  .actions-col,
  .row-actions,
  .icon-sprite {
    display: none !important;
  }

  .topbar {
    position: static;
    padding: 0 0 12px;
    border-bottom: 2px solid #000;
    background: #fff;
  }

  main {
    display: block;
  }

  .workspace-grid,
  .output-grid {
    display: block;
  }

  .panel {
    box-shadow: none;
    break-inside: avoid;
    margin: 0 0 14px;
  }

  .matrix-table {
    min-width: 0;
    table-layout: auto;
    font-size: 9pt;
  }

  .matrix-table th,
  .matrix-table td {
    padding: 6px;
  }

  .matrix-table th:nth-child(7),
  .matrix-table td:nth-child(7) {
    display: none;
  }

  .cell-input,
  .cell-select,
  .cell-textarea {
    border: 0;
    padding: 0;
    min-height: 0;
    resize: none;
    color: #000;
  }

  .notice {
    border-color: #999;
    background: #fff;
    color: #000;
  }
}
