/* CSA embed — Phase 1 styling aligned with r2s1 (Streamlit) dashboard */

html.csa-widget-page,
html.csa-widget-page body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

html.csa-in-iframe body {
  overflow-x: hidden;
  overflow-y: auto;
}

.csa-embed-jump {
  display: none;
}

html.csa-in-iframe .csa-embed-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  position: relative;
  z-index: 5;
  background: #eef3fb;
  border: 1px solid #2a5298;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
}

html.csa-in-iframe .csa-embed-jump a {
  color: #1a3366;
  font-weight: 600;
  text-decoration: none;
}

html.csa-in-iframe .csa-embed-jump a:hover {
  text-decoration: underline;
}

html.csa-in-iframe .csa-embed-page {
  max-width: 1200px;
  width: 100%;
}

html.csa-in-iframe .csa-chart-filter-row,
html.csa-in-iframe .csa-metrics-row,
html.csa-in-iframe .csa-search-panel,
html.csa-in-iframe .csa-table-section {
  width: 100%;
  max-width: 100%;
  contain: layout style;
}

.csa-chart-fallback {
  font-size: 0.85rem;
  color: #8b1a1a;
  padding: 0.5rem;
  background: #fff5f5;
  border: 1px solid #f0b4b4;
  border-radius: 6px;
}

.csa-embed-page {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: rgb(49, 51, 63);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 0.75rem 1.5rem;
  background: #fff;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.csa-hidden {
  display: none !important;
}

.csa-embed-status {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
}

.csa-embed-status.is-error {
  display: block !important;
  background: #fff5f5;
  border-color: #f0b4b4;
  color: #8b1a1a;
}

.csa-embed-status.is-ok {
  display: block !important;
  background: #f0fff4;
  border-color: #9be9a8;
  color: #116329;
}

/* Header */
.csa-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.csa-header-left {
  flex: 2 1 280px;
}

.csa-brand-updated {
  font-size: 1.5rem;
  font-weight: 600;
  text-decoration: underline;
  color: rgb(49, 51, 63);
  margin: 0;
  line-height: 1.4;
}

.header-contact {
  text-align: right;
  font-size: 0.9rem;
  color: #444;
  flex: 1 1 180px;
}

.header-contact p {
  margin: 0 0 4px 0;
}

.header-contact a {
  color: #1a3366;
  text-decoration: none;
}

.header-contact a:hover {
  text-decoration: underline;
}

.header-build {
  font-size: 0.75rem;
  color: #888;
  margin-top: 6px !important;
}

/* Metrics row — Streamlit st.metric style */
.csa-metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1.25rem;
}

.csa-metric-card {
  background: #fff;
  border: 1px solid rgba(49, 51, 63, 0.1);
  border-radius: 0.5rem;
  padding: 0.65rem 0.85rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.csa-metric-value {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: rgb(49, 51, 63);
}

.csa-metric-label {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.15rem;
}

.csa-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: rgb(49, 51, 63);
  margin: 0 0 0.65rem 0;
}

/* Chart + category filter */
.csa-chart-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .csa-chart-filter-row {
    grid-template-columns: 1fr;
  }
}

.csa-chart-wrap {
  position: relative;
  height: 320px;
  min-height: 320px;
  max-height: 320px;
  width: 100%;
  contain: strict;
}

.csa-chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.csa-caption {
  font-size: 0.8rem;
  color: #666;
  margin: 0.35rem 0 0;
}

.csa-category-radios {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
}

.csa-category-radios label {
  font-size: 0.88rem;
  cursor: pointer;
  line-height: 1.35;
}

.csa-category-radios input {
  margin-right: 0.4rem;
}

.csa-category-codes {
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: #555;
}

.csa-category-codes ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.csa-category-codes li {
  margin-bottom: 0.2rem;
}

/* Search panel — r2s1 bordered box */
.csa-search-panel {
  border: 4px solid #0d1f3d;
  border-radius: 6px;
  padding: 0.5rem 0.75rem 0.65rem;
  background: #fafbfd;
  margin: 0.75rem 0 1rem;
}

.search-heading {
  font-weight: 700;
  margin: 0 0 0.35rem 0;
  line-height: 1.05;
  color: #1a3366;
  font-size: 1rem;
}

.search-hint {
  font-size: 0.85rem;
  color: #555;
  font-weight: 400;
}

.search-input-label {
  font-size: 0.88rem;
  margin: 0.35rem 0 0.15rem;
  color: #1a3366;
}

.csa-search-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
}

.csa-search-modes label {
  cursor: pointer;
  color: #1a3366;
}

.semantic-tip {
  cursor: help;
  color: #1a3366;
  font-size: 0.85rem;
}

.csa-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.csa-search-row input[type="text"] {
  flex: 1 1 220px;
  min-width: 180px;
  padding: 0.35rem 0.55rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.csa-search-status {
  font-size: 0.85rem;
  color: #555;
  margin: 0.35rem 0 0;
  min-height: 1.2em;
}

.csa-progress {
  margin: 0.4rem 0 0;
  height: 6px;
  border-radius: 999px;
  background: #e6eaf0;
  overflow: hidden;
}

.csa-progress-bar {
  height: 100%;
  width: 35%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1a3366, #4a7fd4, #1a3366);
  background-size: 200% 100%;
  animation: csa-progress-slide 1.1s linear infinite;
}

@keyframes csa-progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.csa-match-timing {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #555;
}

.csa-embed-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #1a3366;
  background: #1a3366;
  color: #fff;
  cursor: pointer;
  font-size: 0.82rem;
}

.csa-embed-btn.secondary {
  background: #fff;
  color: #1a3366;
}

.csa-embed-btn:hover {
  filter: brightness(1.05);
}

/* Table — Phase 2 (r2s1 job-records-table parity) */
.csa-table-section {
  margin: 1rem 0;
  min-width: 0;
  max-width: 100%;
}

.csa-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: flex-end;
  margin-bottom: 0.35rem;
}

.csa-toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.82rem;
  color: #444;
}

.csa-toolbar-field select,
.csa-toolbar-field input[type="number"] {
  padding: 0.25rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.82rem;
  min-width: 5.5rem;
}

.csa-toolbar-check {
  flex-direction: row;
  align-items: center;
  padding-bottom: 0.25rem;
}

.csa-toolbar-check input {
  margin-right: 0.3rem;
}

.csa-table-page-info {
  font-size: 0.8rem;
  color: #666;
  padding-bottom: 0.3rem;
}

.csa-scroll-hint {
  font-size: 11px;
  color: #555;
  margin: 0 0 4px 0;
}

.csa-embed-table-wrap.job-records-wrapper {
  display: block;
  overflow-x: scroll;
  overflow-y: scroll;
  max-height: 480px;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: #fff;
  cursor: grab;
}

.csa-embed-table-wrap.job-records-wrapper.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.csa-embed-table-wrap.is-scrollable-x {
  box-shadow: inset -10px 0 8px -8px rgba(42, 82, 152, 0.25);
}

.csa-embed-table-wrap.job-records-wrapper:focus {
  outline: 2px solid #2a5298;
  outline-offset: 1px;
}

.csa-embed-table.job-records-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  max-width: none;
}

.csa-embed-table.job-records-table th,
.csa-embed-table.job-records-table td {
  padding: 6px 8px;
  border: 1px solid #ddd;
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csa-embed-table.job-records-table thead th {
  background: #2a5298;
  color: white;
  white-space: nowrap;
  line-height: 1.2;
  font-size: 11px;
  text-align: center;
  vertical-align: middle;
  position: sticky;
  top: 0;
  z-index: 4;
  box-shadow: 0 1px 0 #1a3366;
  border-bottom: 1px solid #1a3366;
  cursor: pointer;
}

.csa-embed-table.job-records-table td {
  word-wrap: break-word;
}

.csa-embed-table.job-records-table tbody td {
  vertical-align: top;
  overflow: hidden;
}

.csa-embed-table.job-records-table .record-cell-inner {
  line-height: 1.35;
  overflow: hidden;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  line-clamp: 8;
}

.csa-embed-table.job-records-table tbody td:hover {
  background-color: #d6e8ff !important;
  box-shadow: inset 0 0 0 2px #2a5298;
  cursor: default;
}

.csa-embed-table.job-records-table tbody td.cell-hover-fulltext {
  cursor: pointer;
}

.csa-embed-table.job-records-table tbody td.cell-nowrap {
  white-space: nowrap;
}

.cell-fulltext-popover {
  position: fixed;
  z-index: 100000;
  display: none;
  box-sizing: border-box;
  width: 340px;
  height: 340px;
  overflow: auto;
  padding: 12px 14px;
  background: #fffef8;
  color: #222;
  border: 2px solid #2a5298;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
  font-size: 12px;
  line-height: 1.4;
  word-wrap: break-word;
  cursor: pointer;
  white-space: normal;
  pointer-events: auto;
}

.cell-popover-meta {
  font-size: 0.82rem;
  color: #1a3366;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

.cell-popover-meta strong {
  font-weight: 700;
}

.cell-popover-divider {
  border: none;
  border-top: 1px solid #d0d7de;
  margin: 0 0 0.55rem 0;
}

.cell-popover-body {
  font-size: 12px;
  line-height: 1.4;
}

.csa-table-empty {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #e7f3ff;
  border-radius: 6px;
  color: #1a3366;
  font-size: 0.9rem;
}

.csa-embed-table.job-records-table tbody tr.row-selected td {
  background-color: #fff3cd !important;
}

.csa-embed-table.job-records-table .bid-ref-link {
  color: #1a3366;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.csa-embed-table .hl-term {
  padding: 0 2px;
  border-radius: 3px;
  color: #fff;
}

.csa-pick-section,
.csa-cv-section {
  margin: 1.25rem 0;
  padding: 0.75rem;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #fafbfd;
}

.csa-step-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a3366;
  margin: 0 0 0.35rem;
}

.csa-step-caption {
  font-size: 0.85rem;
  color: #555;
  margin: 0 0 0.65rem;
}

.csa-pick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
}

.csa-pick-row select {
  min-width: 14rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.csa-picked-status {
  font-size: 0.88rem;
  color: #1a3366;
  margin: 0.5rem 0 0;
}

.csa-job-detail {
  margin-top: 0.65rem;
  font-size: 0.88rem;
}

.csa-job-detail-body {
  margin: 0.5rem 0;
  line-height: 1.4;
}

.csa-job-detail-body dl {
  margin: 0;
}

.csa-job-detail-body dt {
  font-weight: 700;
  color: #1a3366;
  margin-top: 0.5rem;
}

.csa-job-detail-body dd {
  margin: 0.15rem 0 0;
  white-space: pre-wrap;
}

.csa-jd-actions {
  margin: 0.5rem 0;
}

.csa-jd-actions a.csa-embed-btn {
  display: inline-block;
  text-decoration: none;
}

.csa-embed-table .jd-download-cell {
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}

.csa-embed-table .jd-download-link {
  color: #1a3366;
  font-weight: 600;
  font-size: 11px;
  text-decoration: none;
}

.csa-embed-table .jd-download-link:hover {
  text-decoration: underline;
}

.csa-jd-download-row {
  margin: 0.5rem 0 0;
}

.csa-jd-download-row a.csa-embed-btn {
  display: inline-block;
  text-decoration: none;
}

.csa-cv-consent {
  display: block;
  font-size: 0.85rem;
  margin: 0.5rem 0;
  color: #333;
}

.csa-cv-consent input {
  margin-right: 0.35rem;
}

.cv-privacy-caption {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: #808495;
  line-height: 1.5;
}

.cv-privacy-caption .csa-legal-link {
  font-size: inherit;
  font-weight: 500;
  text-decoration: underline;
}

.csa-service-compare {
  margin: 0.5rem 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  font-size: 0.82rem;
  color: #444;
  line-height: 1.45;
}

.csa-service-compare p {
  margin: 0.25rem 0;
}

.csa-service-compare p:first-child {
  margin-top: 0;
}

.csa-service-compare p:last-child {
  margin-bottom: 0;
}

.csa-cv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.65rem 0 0.35rem;
}

.csa-cv-actions .csa-embed-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.csa-cv-status {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
}

.csa-cv-status.is-error {
  background: #fff5f5;
  border-color: #f0b4b4;
  color: #8b1a1a;
}

.csa-cv-status.is-ok {
  background: #f0fff4;
  border-color: #9be9a8;
  color: #116329;
}

.csa-cv-status.is-busy {
  background: #eef3fb;
  border-color: #9bb8e8;
  color: #1a3366;
}

.csa-cv-status.is-warn {
  background: #fff8e6;
  border-color: #e6c200;
  color: #6b5500;
}

.csa-cv-upload-wrap.is-blocked {
  opacity: 0.72;
  cursor: not-allowed;
}

.csa-cv-upload-wrap.is-blocked input[type="file"] {
  pointer-events: none;
}

.csa-debug-panel {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: #444;
}

.csa-debug-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: #1a3366;
}

.csa-debug-log {
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.65rem;
  max-height: 12rem;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.csa-match-result {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 0.88rem;
}

.csa-match-score-bar {
  height: 8px;
  background: #eaeef2;
  border-radius: 4px;
  margin: 0.5rem 0;
  overflow: hidden;
}

.csa-match-score-fill {
  height: 100%;
  background: #2a5298;
  border-radius: 4px;
}

.csa-match-terms {
  font-size: 0.82rem;
  color: #555;
  margin: 0.25rem 0 0;
}

.csa-match-caption {
  font-size: 0.8rem;
  color: #666;
  margin: 0.65rem 0 0;
  line-height: 1.45;
}

.csa-match-disclaimer {
  font-size: 0.78rem;
  color: #808495;
  margin: 0.35rem 0 0;
  font-style: italic;
}

.csa-match-quality-warn {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
  background: #fff8e6;
  border: 1px solid #e6c200;
  color: #6b5500;
}

.csa-match-gap-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0 0.35rem;
}

.csa-match-gap-col h4 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: #1a3366;
}

.csa-match-gap-col ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: #444;
}

.csa-match-gap-col .csa-gap-empty {
  font-size: 0.8rem;
  color: #888;
  margin: 0;
}

.csa-match-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.csa-fuzzy-threshold {
  margin: 0.65rem 0 0;
  max-width: 28rem;
}

.csa-fuzzy-threshold label {
  display: block;
  font-size: 0.85rem;
  color: #1a3366;
  margin-bottom: 0.25rem;
}

.csa-fuzzy-threshold input[type="range"] {
  width: 100%;
}

.csa-fuzzy-tip {
  margin: 0.35rem 0 0;
}

.cv-upload-label {
  font-size: 0.88rem;
  color: #1a3366;
  margin: 0 0 0.5rem;
}

.csa-embed-matches {
  margin-top: 0.75rem;
  font-size: 0.88rem;
}

.csa-cv-help {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.85rem;
  color: #555;
}

.csa-cv-help summary {
  cursor: pointer;
  font-weight: 600;
  color: #1a3366;
}

.csa-footer {
  margin-top: 2rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eaeef2;
}

.footer-note {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 0.35rem;
}

.usage-stats-line {
  font-size: 0.72rem;
  color: #9ca3af;
  margin: 0 0 0.35rem;
  line-height: 1.3;
}

.footer-legal {
  margin: 0;
  font-size: 0.85rem;
}

.csa-legal-link {
  background: none;
  border: none;
  padding: 0;
  color: #1a3366;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.footer-legal-sep {
  color: #888;
  margin: 0 0.35rem;
}

.csa-legal-dialog {
  border: 2px solid #2a5298;
  border-radius: 8px;
  padding: 0;
  max-width: min(640px, 92vw);
  width: 640px;
}

.csa-legal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.csa-legal-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: #eef3fb;
  border-bottom: 1px solid #d0d7de;
}

.csa-legal-dialog-header h2 {
  margin: 0;
  font-size: 1rem;
  color: #1a3366;
}

.csa-legal-close {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: #444;
}

.csa-legal-dialog-body {
  padding: 0.85rem 1rem 1rem;
  max-height: 70vh;
  overflow-y: auto;
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #333;
}

.csa-match-download {
  margin-top: 0.5rem;
}

.csa-match-download a {
  color: #1a3366;
  font-weight: 600;
}

/* CV section (legacy) */
