:root {
  --ink: #172033;
  --muted: #607086;
  --line: #d8dee8;
  --paper: #ffffff;
  --surface: #f4f7fb;
  --navy: #0b1f3a;
  --red: #d83b31;
  --teal: #2e9ca6;
  --green: #307d52;
  --amber: #9a641b;
  --blue: #2563a9;
  --radius: 8px;
  --shadow: 0 10px 24px rgba(11, 31, 58, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

a {
  color: #155e9f;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  min-height: 72px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  min-width: 320px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 148px;
  height: auto;
  max-height: 54px;
  object-fit: contain;
}

.brand span {
  display: grid;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav {
  display: flex;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.nav a,
.logout-form button,
.button,
button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  padding: 9px 12px;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #24364f;
  font-weight: 800;
  box-shadow: none;
}

.nav a span {
  width: 8px;
  height: 20px;
  border-radius: 999px;
  background: var(--blue);
}

.nav a.nav-database span {
  background: var(--navy);
}

.nav a.nav-review span {
  background: var(--red);
}

.nav a.nav-sync span {
  background: var(--teal);
}

.nav a.nav-config span {
  background: var(--amber);
}

.nav a.nav-run {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
  box-shadow: 0 6px 14px rgba(11, 31, 58, .16);
}

.nav a.nav-run span {
  background: #69c9d0;
}

.nav a:hover,
.button:hover,
button:hover {
  border-color: #9fb0c7;
  text-decoration: none;
}

.nav a:hover {
  background: #eef4fb;
  color: var(--navy);
  border-color: #9db3ce;
  filter: none;
  transform: translateY(-1px);
}

.nav a.nav-run:hover {
  background: #16345d;
  color: white;
  border-color: #16345d;
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.shell {
  width: min(1440px, calc(100% - 48px));
  margin: 28px auto 56px;
}

.messages {
  width: min(1440px, calc(100% - 48px));
  margin: 16px auto 0;
}

.message {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.message.success {
  border-color: #abd5bd;
  color: var(--green);
}

.message.error {
  border-color: #e8aaa5;
  color: var(--red);
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 22px;
}

.page-heading h1,
.login-panel h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  text-transform: uppercase;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
  margin: 7px 0 0;
}

.actions,
.form-actions,
.filter-actions,
.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.priority-action-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: -8px 0 20px;
}

.sam-cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--red);
  border: 1px solid #a82f28;
  color: white;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(216, 59, 49, .18);
}

.sam-cta:hover {
  color: white;
  text-decoration: none;
  background: #bd3028;
}

.primary {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.primary:hover {
  background: #16345d;
  color: white;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 112px;
  border-left: 5px solid var(--teal);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.metric:hover {
  text-decoration: none;
}

.metric.alert {
  border-left-color: var(--red);
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  font-size: 34px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 22px;
}

.two-col.wide-left {
  grid-template-columns: minmax(0, 1.7fr) minmax(340px, .7fr);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

h2 {
  margin: 0 0 12px;
  font-size: 19px;
}

.content-band,
.detail-panel,
.form-panel,
.login-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0;
  background: #f9fbfd;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

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

.strong-link {
  font-weight: 800;
  color: var(--ink);
}

/* Share-proposal panel: inline checkbox list + comfortable text areas. */
.share-proposal-form ul {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.share-proposal-form ul li label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.share-proposal-form textarea {
  width: 100%;
  max-width: 640px;
}

/* Search Database table: fit all columns on the page (no horizontal drag). */
.opportunity-table {
  table-layout: fixed;
  min-width: 0;
  width: 100%;
}
.opportunity-table th,
.opportunity-table td {
  padding: 10px 10px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Column widths (9 cols): Opportunity, Agency, Type, AI, NAICS, Response, Status, Decision, SAM */
.opportunity-table th:nth-child(1), .opportunity-table td:nth-child(1) { width: 22%; }
.opportunity-table th:nth-child(2), .opportunity-table td:nth-child(2) { width: 14%; }
.opportunity-table th:nth-child(3), .opportunity-table td:nth-child(3) { width: 9%; }
.opportunity-table th:nth-child(4), .opportunity-table td:nth-child(4) { width: 6%; }
.opportunity-table th:nth-child(5), .opportunity-table td:nth-child(5) { width: 8%; }
.opportunity-table th:nth-child(6), .opportunity-table td:nth-child(6) { width: 9%; }
.opportunity-table th:nth-child(7), .opportunity-table td:nth-child(7) { width: 12%; }
.opportunity-table th:nth-child(8), .opportunity-table td:nth-child(8) { width: 13%; }
.opportunity-table th:nth-child(9), .opportunity-table td:nth-child(9) { width: 7%; }
/* Make the inline status/decision dropdowns fill (not exceed) their column. */
.opportunity-table select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 5px 6px;
  font-size: 12px;
}
.opportunity-table .strong-link {
  font-size: 13px;
}
.opportunity-table .ai-score-cell {
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #edf2f7;
  color: #35445c;
}

.badge.approved,
.badge.success,
.badge.completed {
  background: #e6f4ec;
  color: var(--green);
}

.badge.pending,
.badge.running,
.badge.queued,
.badge.partial {
  background: #fff3dc;
  color: var(--amber);
}

.badge.rejected,
.badge.failed {
  background: #fde9e7;
  color: var(--red);
}

.keyword-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 260px;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef8f9;
  border: 1px solid #c5e3e6;
  color: #1d6870;
  font-size: 12px;
  font-weight: 800;
}

.quick-decision-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 150px;
}

.quick-decision-actions form {
  margin: 0;
}

.quick-decision-actions button {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 900;
}

.quick-approve {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.quick-approve:hover {
  background: #25643f;
  color: white;
}

.quick-deny {
  background: white;
  border-color: #d9a29d;
  color: var(--red);
}

.quick-deny:hover {
  background: #fde9e7;
  border-color: var(--red);
  color: var(--red);
}

.batch-decision-form {
  display: grid;
  gap: 14px;
}

.batch-decision-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 230px;
}

.decision-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-transform: none;
  cursor: pointer;
}

.decision-choice input {
  margin: 0;
}

.decision-choice.approve {
  border-color: #abd5bd;
  color: var(--green);
}

.decision-choice.deny {
  border-color: #d9a29d;
  color: var(--red);
}

.decision-choice:has(input:checked) {
  background: #eef4fb;
  border-color: #9db3ce;
}

.decision-choice.approve:has(input:checked) {
  background: #e7f4ed;
  border-color: var(--green);
}

.decision-choice.deny:has(input:checked) {
  background: #fde9e7;
  border-color: var(--red);
}

.batch-decision-submit {
  justify-content: flex-end;
}

.run-list {
  display: grid;
  gap: 10px;
}

.run-item {
  display: grid;
  gap: 5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--ink);
}

.run-item:hover {
  text-decoration: none;
  border-color: #9fb0c7;
}

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

.filter-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.filter-grid.compact {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.filter-actions,
.form-actions {
  align-self: end;
}

form p {
  display: grid;
  gap: 6px;
  margin: 0;
}

label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #bfc8d6;
  border-radius: var(--radius);
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: white;
}

textarea {
  resize: vertical;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.form-grid p:has(textarea),
.form-grid .form-actions {
  grid-column: 1 / -1;
}

.search-config-stack {
  display: grid;
  gap: 22px;
}

.search-builder {
  display: grid;
  gap: 14px;
}

.criteria-builder {
  max-width: 900px;
}

.criteria-table {
  min-width: 0;
}

.criteria-table th:first-child,
.criteria-table td:first-child {
  width: 120px;
}

.criteria-table th:nth-child(2),
.criteria-table td:nth-child(2) {
  width: 180px;
}

.criteria-table select,
.criteria-table input {
  min-width: 0;
}

.search-builder-actions {
  justify-content: flex-start;
}

.inline-form {
  margin: 0;
}

.existing-searches {
  display: grid;
  gap: 12px;
}

.search-list-header,
.search-card {
  display: grid;
  grid-template-columns: minmax(540px, 1fr) 150px 96px;
  gap: 16px;
  align-items: start;
}

.search-list-header {
  padding: 0 14px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.search-card-list {
  display: grid;
  gap: 12px;
}

.search-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 14px;
  box-shadow: 0 6px 16px rgba(11, 31, 58, .05);
}

.search-card.is-disabled {
  border-left-color: #9aa7b7;
  background: #f7f9fc;
}

.criteria-lines {
  display: grid;
  gap: 6px;
}

.criteria-grid {
  display: grid;
  grid-template-columns: 120px 180px minmax(220px, 1fr);
  gap: 12px;
  align-items: center;
}

.criteria-grid span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.criteria-heading {
  color: var(--muted);
}

.criterion-exclude {
  color: var(--muted);
  font-weight: 800;
}

.criterion-exclude.is-exclude {
  color: var(--red);
}

.switch-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  width: 118px;
  min-height: 36px;
  padding: 0 12px 0 42px;
  border-radius: 999px;
  border-color: #b8c2d0;
  background: #d8dee8;
  color: #44546a;
  font-size: 12px;
  font-weight: 900;
}

.switch-toggle::before {
  content: "";
  position: absolute;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(11, 31, 58, .22);
  transition: transform .16s ease;
}

.switch-toggle.is-on {
  justify-content: flex-start;
  padding: 0 42px 0 12px;
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.switch-toggle.is-on::before {
  transform: translateX(78px);
}

.switch-toggle:hover {
  border-color: #9aa7b7;
  background: #cbd3df;
  color: #2e3b4f;
}

.switch-toggle.is-on:hover {
  border-color: #25643f;
  background: #25643f;
  color: white;
}

.switch-toggle:disabled {
  opacity: .7;
  cursor: wait;
}

.danger-button {
  min-height: 36px;
  color: white;
  border-color: var(--red);
  background: var(--red);
  font-weight: 900;
}

.danger-button:hover {
  border-color: #bd3028;
  background: #bd3028;
  color: white;
}

.search-empty {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

dl {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 10px 14px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
}

.notes {
  margin: 0;
}

.decision-note-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.decision-note {
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: var(--radius);
  padding: 12px;
  background: #f9fbfd;
}

.decision-note div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.decision-note p {
  margin: 0 0 8px;
}

.decision-note small {
  color: var(--muted);
}

.link-list {
  padding-left: 18px;
  overflow-wrap: anywhere;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.console {
  background: #111827;
  color: #e5edf6;
  border-radius: var(--radius);
  padding: 14px;
  min-height: 180px;
}

.sync-status {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 3px 10px;
  align-items: center;
  border: 1px solid #bfd9dc;
  border-radius: var(--radius);
  padding: 12px;
  background: #effafb;
  color: var(--ink);
}

.sync-status.hidden {
  display: none;
}

.sync-status small {
  grid-column: 2;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 31, 58, .48);
}

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

.notification-modal {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(11, 31, 58, .28);
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin-bottom: 0;
}

.modal-close {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
}

.notification-form {
  display: grid;
  gap: 14px;
}

.notification-summary {
  margin: 0;
  color: var(--ink);
}

.notification-form p {
  margin: 0;
}

.notification-warning {
  border: 1px solid #f0d29a;
  border-radius: var(--radius);
  background: #fff8e8;
  color: var(--amber);
  padding: 10px 12px;
  font-weight: 800;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  text-transform: none;
}

.checkbox-row input {
  width: auto;
  margin-top: 2px;
}

.detail-side-stack {
  display: grid;
  gap: 18px;
}

.error-text {
  color: var(--red);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #cde8eb;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.decision-panel ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.decision-panel li label {
  color: var(--ink);
  font-size: 15px;
  text-transform: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.decision-panel input[type="radio"],
.form-panel input[type="checkbox"],
.form-grid input[type="checkbox"],
.share-proposal-form input[type="checkbox"] {
  width: auto;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(320px, .45fr);
  align-items: center;
  gap: 28px;
  min-height: 420px;
  border-top: 5px solid var(--red);
}

@media (max-width: 980px) {
  .topbar,
  .page-heading,
  .two-col,
  .detail-grid,
  .login-panel {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    position: static;
    padding: 14px;
  }

  .brand {
    min-width: 0;
  }

  .metric-grid,
  .filter-grid,
  .filter-grid.compact,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell,
  .messages {
    width: min(100% - 24px, 1440px);
  }

  .metric-grid,
  .filter-grid,
  .filter-grid.compact,
  .form-grid {
    grid-template-columns: 1fr;
  }

  dl {
    grid-template-columns: 1fr;
  }
}
