:root {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #1f2a2c;
  --muted: #617176;
  --accent: #0b6e4f;
  --line: #d9e2dd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, #f4dfbf, var(--bg) 45%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  display: block;
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.nav-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding-left: 10px;
}

.nav-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.nav a {
  text-decoration: none;
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 6px;
}

.nav a:hover {
  background: #eef5f1;
}

.container {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.section-head h1 {
  margin: 0;
}

.section-head {
  margin-bottom: 12px;
}

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.card h3,
.panel h2 {
  margin-top: 0;
}

.split {
  display: grid;
  gap: 12px;
}

.split.two {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.toolbar.wrap {
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

label[hidden] {
  display: none !important;
}

input,
select,
button,
.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}

button,
.button {
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: #b9ccc1;
}

.btn-primary {
  background: #0b6e4f;
  color: #ffffff;
  border-color: #0b6e4f;
}

.btn-primary:hover {
  background: #0a6146;
  border-color: #0a6146;
}

.btn-secondary {
  background: #edf4f0;
  border-color: #c3d6cb;
  color: #1f2a2c;
}

.btn-secondary:hover {
  background: #e2eee8;
  border-color: #afc8bb;
}

.btn-danger {
  background: #a92525;
  border-color: #a92525;
  color: #ffffff;
}

.btn-danger:hover {
  background: #8f1f1f;
  border-color: #8f1f1f;
}

a.button {
  text-decoration: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #dce6e1;
  border-radius: 10px;
  background: #fff;
}

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

th {
  background: #f8fbf9;
}

.load-id-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.load-reason-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #9ab2a5;
  color: #45695b;
  font-size: 11px;
  line-height: 1;
  cursor: help;
  user-select: none;
}

.load-reason-info:hover {
  border-color: #6f9180;
  color: #2f5345;
}

.list {
  margin: 0;
  padding-left: 18px;
}

.kv {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 6px 10px;
  margin: 0;
}

.kv dt {
  font-weight: 600;
}

.kv dd {
  margin: 0;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #0b6e4f;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: #0a6146;
}

.entities-modal-list {
  list-style: disc;
  padding: 8px 0 4px 24px;
  margin: 0;
  line-height: 1.8;
}

.pager {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.pager .page-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pager .page-buttons button {
  min-width: 34px;
  padding: 6px 8px;
}

.pager .page-buttons button.is-active {
  background: #0b6e4f;
  color: #ffffff;
  border-color: #0b6e4f;
}

.pager .pager-ellipsis {
  padding: 0 4px;
  user-select: none;
}

.badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  margin-right: 4px;
  white-space: nowrap;
}

.badge.good {
  background: #e6f5ee;
  color: #1b6b4a;
  border-color: #b9e3cf;
}

.badge.warn {
  background: #fff4de;
  color: #8a5b05;
  border-color: #f0d59d;
}

.badge.danger {
  background: #ffe9e9;
  color: #8f2727;
  border-color: #f0b7b7;
}

.badge.muted {
  background: #eef2ef;
  color: #4e5b60;
}

.badge-success {
  background: #e6f5ee;
  color: #1b6b4a;
  border-color: #b9e3cf;
}

.badge-warning {
  background: #fff4de;
  color: #8a5b05;
  border-color: #f0d59d;
}

.badge-danger {
  background: #ffe9e9;
  color: #8f2727;
  border-color: #f0b7b7;
}

.row-focus {
  outline: 2px solid #8ec8b0;
  outline-offset: -2px;
  background: #f4fbf7;
}

button[data-assign],
button[data-escalate] {
  padding: 4px 8px;
  font-size: 12px;
  margin-right: 4px;
}

dialog {
  width: min(1000px, 92vw);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(19, 34, 28, 0.45);
}

.load-readiness-detail-modal-body {
  width: min(980px, 90vw);
  max-width: none;
  box-sizing: border-box;
}

.load-readiness-detail-modal-body .table-wrap,
.load-readiness-detail-modal-body table {
  width: 100%;
}

.lr-action-menu {
  position: relative;
  display: inline-block;
}

.lr-action-toggle {
  min-width: 2rem;
  padding: 4px 8px;
  line-height: 1;
}

.lr-action-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  min-width: 160px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(19, 34, 28, 0.16);
  padding: 6px;
}

.lr-action-dropdown .lr-action-item {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0;
}

.lr-action-dropdown .lr-action-item + .lr-action-item {
  margin-top: 4px;
}

pre {
  margin: 0;
  background: #f4f8f6;
  border: 1px solid #d9e6df;
  border-radius: 8px;
  padding: 8px;
  max-height: 350px;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: var(--accent);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.detail-head-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-head-inline h2 {
  margin-bottom: 0;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.detail-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.metric-strip {
  margin-top: 12px;
  margin-bottom: 12px;
}

.metric-strip .card p {
  font-size: 20px;
  line-height: 1.2;
}

.section-head.detail-head {
  background: linear-gradient(135deg, #ffffff, #f9f4ea);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}

.panel-lift {
  border-radius: 12px;
  border: 1px solid #cfddd6;
  box-shadow: 0 6px 18px rgba(29, 52, 42, 0.06);
  padding: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.migration-detail-page {
  display: grid;
  gap: 16px;
}

.edge-health-layout {
  align-items: start;
}

.edge-action-callout {
  border: 1px solid #d2e0d9;
  border-radius: 10px;
  background: #f5faf7;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.edge-action-callout.good {
  border-color: #9ed2b8;
  background: #e8f7ee;
  color: #164a2f;
}

.edge-action-callout.danger {
  border-color: #dca3a3;
  background: #fdeeee;
  color: #7a1d1d;
}

.migration-detail-page .panel h2 {
  margin-bottom: 10px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.panel-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.migration-detail-page .panel.is-collapsed > *:not(:first-child) {
  display: none;
}

.migration-detail-page .panel.is-collapsed .panel-head {
  margin-bottom: 0;
}

.modal-body .connector-modal-panel.is-collapsed > *:not(:first-child) {
  display: none;
}

.modal-body .connector-modal-panel.is-collapsed .panel-head {
  margin-bottom: 0;
}

#sourceConnectorsPanel .source-assignments-head {
  padding-top: 10px;
}

.view-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.migration-detail-page.is-pm-view #editProjectContextBtn {
  display: none;
}

.intake-progress-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.progress-rail {
  flex: 1;
  min-height: 8px;
  background: #dbe6df;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  min-height: 8px;
  background: linear-gradient(90deg, #0b6e4f, #2c8c68);
  transition: width 0.25s ease;
}

.step-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.step-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #c6d6ce;
  background: #f4faf7;
  color: #1f2a2c;
  font-size: 12px;
}

.step-chip.is-complete {
  background: #e5f6ed;
  border-color: #9ed2b8;
}

.mapping-card {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #d5e2dc;
  border-radius: 10px;
  background: #f9fcfa;
}

.mapping-grid-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #52656b;
  font-weight: 600;
}

.modal-body {
  padding: 16px;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.connector-modal-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.connector-modal-panel-grid {
  margin-top: 0.6rem;
}

.connector-modal-grid .connector-name-field {
  grid-column: 1 / 2;
}

.connector-modal-grid .connector-purpose-field {
  grid-column: 2 / 4;
}

.connector-modal-grid .connector-description-field,
.connector-modal-grid .connector-type-field,
.connector-modal-grid .connector-connection-fields {
  grid-column: 1 / -1;
}

.connector-modal-grid .connector-connection-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.connector-modal-grid .connector-connection-fields > .full {
  grid-column: 1 / -1;
}

.connector-field-help {
  font-size: 12px;
  color: #52656b;
}

.connector-field-error {
  font-size: 12px;
  color: #a92525;
  min-height: 14px;
}

.connector-modal-grid .connector-connection-fields input.field-invalid {
  border-color: #a92525;
  box-shadow: 0 0 0 1px rgba(169, 37, 37, 0.2);
}

.connector-modal-grid .connector-connection-fields select.field-invalid,
.connector-modal-grid .connector-connection-fields textarea.field-invalid,
#connectorHasHeaderRow.field-invalid {
  border-color: #a92525;
  box-shadow: 0 0 0 1px rgba(169, 37, 37, 0.2);
}

.connector-config-panel-head {
  align-items: center;
}

.connector-config-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.connector-inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
}

.connector-inline-checkbox input {
  margin: 0;
}

.connector-config-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 0.75rem;
}

.column-override-editor {
  display: grid;
  gap: 8px;
}

.column-override-rows {
  display: grid;
  gap: 8px;
}

.column-override-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 8px;
  align-items: center;
}

.profile-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.profile-loading[hidden] {
  display: none !important;
}

.profile-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #c7d8cf;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.modal-grid .full {
  grid-column: 1 / -1;
}

.modal-grid textarea {
  width: 100%;
  min-height: 130px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.project-context-entities-wrap {
  position: relative;
}

.project-context-entities-trigger {
  cursor: pointer;
}

.project-context-entities-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  padding: 8px;
}

.project-context-entities-dropdown[hidden] {
  display: none !important;
}

.project-context-entities-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.project-context-entities-actions button {
  flex: 1 1 auto;
}

.project-context-entities-options {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #dbe6e0;
  border-radius: 6px;
  background: #fff;
}

.project-context-entity-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #eef3f0;
}

.project-context-entity-option:last-child {
  border-bottom: 0;
}

.project-context-entity-option input {
  margin: 0;
}

#profileDetailModal .panel {
  margin-top: 8px;
}

#profileDetailModal h4 {
  margin-top: 0;
}

@media (max-width: 720px) {
  .connector-modal-grid {
    grid-template-columns: 1fr;
  }

  .connector-modal-grid .connector-name-field,
  .connector-modal-grid .connector-purpose-field,
  .connector-modal-grid .connector-description-field,
  .connector-modal-grid .connector-type-field,
  .connector-modal-grid .connector-connection-fields {
    grid-column: 1 / -1;
  }

  .connector-modal-grid .connector-connection-fields {
    grid-template-columns: 1fr;
  }

  .connector-config-fields {
    grid-template-columns: 1fr;
  }

  .column-override-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .detail-head,
  .detail-head-inline {
    flex-direction: column;
    align-items: stretch;
  }

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

  .migration-detail-page .table-wrap table {
    min-width: 680px;
  }

  .migration-detail-page th,
  .migration-detail-page td {
    padding: 7px 6px;
    font-size: 12px;
  }

  .migration-detail-page .panel-actions {
    width: 100%;
  }

  .migration-detail-page .panel-actions button,
  .migration-detail-page .panel-actions .button {
    flex: 1 1 140px;
    text-align: center;
  }

  .migration-detail-page .step-chip {
    font-size: 11px;
    padding: 5px 8px;
  }
}

/* ── Migration Progress Checklist ─────────────────────────────── */
.project-checklist {
  margin-bottom: 4px;
}

.checklist-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.checklist-header h2 {
  margin: 0;
}

.checklist-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checklist-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  font-size: 13px;
  background: #fff;
  cursor: default;
  white-space: nowrap;
}

.checklist-item:hover .checklist-tooltip {
  display: block;
}

.checklist-item.ci-complete {
  background: #eef8f2;
  border-color: #a3d4b8;
  color: #0b6e4f;
}

.checklist-item.ci-in_progress {
  background: #fff8ec;
  border-color: #f4c97b;
  color: #7a5100;
}

.checklist-item.ci-not_started {
  background: #f5f5f5;
  border-color: #d0d5d3;
  color: #617176;
}

.checklist-icon {
  font-size: 13px;
  line-height: 1;
}

.checklist-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 30;
  pointer-events: none;
}

/* ── Mapping Setup Disclosure ─────────────────────────────────── */
.mapping-setup-wrap {
  position: relative;
  display: inline-block;
}

.mapping-setup-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  min-width: 210px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.mapping-setup-dropdown[hidden] {
  display: none !important;
}

.mapping-setup-dropdown button {
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

/* ── Project Manager View ─────────────────────────────────────── */
.pm-scorecards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.pm-scorecard {
  border: 1px solid #d6e2dc;
  border-radius: 10px;
  padding: 10px;
  background: #f8fbf9;
}

.pm-scorecard h3 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #4e6167;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pm-scorecard p {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  color: #1f2a2c;
}

.pm-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid #c8d7d0;
}

.pm-pill-good {
  background: #e8f6ee;
  color: #19653f;
  border-color: #9fd3b8;
}

.pm-pill-warn {
  background: #fff7e9;
  color: #7c5500;
  border-color: #efcb86;
}

.pm-pill-danger {
  background: #fdeeee;
  color: #8b2727;
  border-color: #dbacac;
}

@media (max-width: 720px) {
  .pm-scorecards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Dashboard-specific polish */
.dashboard-page {
  display: grid;
  gap: 16px;
}

.dashboard-page .section-head {
  background: linear-gradient(135deg, #ffffff, #f9f4ea);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}

.dashboard-view-toggle {
  display: flex;
  justify-content: flex-end;
}

.dashboard-view-toggle .view-toggle-buttons {
  display: flex;
  gap: 8px;
}

.dashboard-controls {
  position: sticky;
  top: 66px;
  z-index: 4;
  box-shadow: 0 8px 22px rgba(27, 47, 38, 0.08);
}

.dashboard-page .toolbar label {
  min-width: 140px;
}

.dashboard-page .toolbar input,
.dashboard-page .toolbar select {
  min-width: 170px;
}

.dashboard-page .cards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.dashboard-page .cards[hidden] {
  display: none !important;
}

.dashboard-page .card {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #ceddd5;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfc 100%);
}

.dashboard-page .card h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  color: #53656b;
}

.dashboard-page .card p {
  margin: 8px 0 0;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.05;
}

.ops-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ops-summary-headings {
  display: grid;
  grid-template-columns: 3fr 1fr;
  align-items: end;
  gap: 10px;
}

.ops-summary-headings h2 {
  margin: 0 0 10px;
}

.ops-summary-headings h2:last-child {
  text-align: left;
}

.ops-summary-card {
  border: 1px solid #ceddd5;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fbfdfc;
  min-height: 96px;
}

.ops-summary-card h3 {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #5a6b70;
}

.ops-summary-card p {
  margin: 8px 0 0;
  font-size: 24px;
  font-weight: 700;
}

.ops-summary-card.recently-accessed-card {
  display: flex;
  align-items: stretch;
}

.recently-accessed-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.recently-accessed-list li {
  line-height: 1.2;
}

.recently-accessed-list a {
  color: #0b5fa5;
  text-decoration: none;
}

.recently-accessed-list a:hover {
  text-decoration: underline;
}

.attention-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.dashboard-page .panel {
  border-radius: 12px;
  padding: 16px;
}

.dashboard-page .panel h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.dashboard-page .panel h2:not(:first-child) {
  margin-top: 18px;
}

.dashboard-page .table-wrap {
  overflow-x: auto;
  border: 1px solid #dce6e1;
  border-radius: 10px;
  background: #fff;
}

.dashboard-page table {
  min-width: 940px;
}

.dashboard-page th,
.dashboard-page td {
  padding: 10px 9px;
  font-size: 13px;
}

.dashboard-page th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-top: none;
}

.dashboard-page tbody tr:nth-child(even) {
  background: #fcfdfc;
}

.dashboard-page tbody tr:hover {
  background: #f3faf6;
}

.dashboard-page .list {
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.dashboard-page .list li {
  border: 1px solid #e3ece7;
  border-radius: 8px;
  background: #fbfdfc;
  padding: 8px 10px;
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

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

  .ops-summary-headings {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .ops-summary-headings h2:last-child {
    margin-top: 0;
  }

  .dashboard-controls {
    top: 102px;
  }

  .dashboard-page .card p {
    font-size: 23px;
  }

  .ops-summary-card p {
    font-size: 21px;
  }

  .dashboard-view-toggle {
    justify-content: stretch;
  }

  .dashboard-view-toggle .view-toggle-buttons {
    width: 100%;
  }

  .dashboard-view-toggle .view-toggle-buttons button {
    flex: 1;
  }
}

/* ── Transform Builder ──────────────────────────────────────────────── */
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.btn-sm:hover { background: #eef6f1; }
/* .btn-sm is declared after .btn-primary and resets the background, which left
   white text on a light panel. Restore the primary colours for the pairing. */
.btn-sm.btn-primary { background: #0b6e4f; border-color: #0b6e4f; color: #ffffff; }
.btn-sm.btn-primary:hover { background: #0a6146; border-color: #0a6146; }
.btn-sm.btn-danger,
.btn-secondary.btn-danger {
  background: #a92525;
  border-color: #a92525;
  color: #ffffff;
}
.btn-sm.btn-danger:hover,
.btn-secondary.btn-danger:hover {
  background: #8f1f1f;
  border-color: #8f1f1f;
}
.btn-outline { border-color: var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }

.transform-config-editor { padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.transform-config-editor label { font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.transform-config-editor input,
.transform-config-editor textarea,
.transform-config-editor select { font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; }

.lookup-editor-container { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #fafaf7; }
.lookup-grid { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.lookup-grid .lookup-row { display: flex; gap: 6px; align-items: center; }
.lookup-grid .lookup-row input { flex: 1; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 3px; }
.lookup-grid .lookup-row .remove-row { color: #c44; cursor: pointer; font-size: 16px; border: none; background: none; padding: 0 4px; }

.transform-preview { margin-top: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: #f0faf5; max-height: 180px; overflow-y: auto; }
.transform-preview table { width: 100%; font-size: 12px; }
.transform-preview th { text-align: left; font-weight: 600; padding: 2px 6px; border-bottom: 1px solid var(--line); }
.transform-preview td { padding: 2px 6px; }
.transform-preview .error { color: #c44; }

.transform-visual-editor {
  border: 1px solid #d6dbe2;
  border-radius: 6px;
  background: #f8fbff;
  padding: 8px;
}

.transform-visual-canvas {
  display: grid;
  gap: 8px;
}

.ve-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto auto auto;
  gap: 6px;
  align-items: center;
}

.ve-row .ve-when,
.ve-row .ve-then {
  font-size: 12px;
  color: #475467;
  font-weight: 600;
}

.ve-icon-btn {
  min-width: 30px;
  padding: 4px 8px;
}

.ve-pick-valid-row {
  grid-template-columns: 1fr auto auto auto;
}

.ve-pick-paired-row {
  grid-template-columns: 1fr auto 1fr auto;
}

.ve-rule-card {
  border: 1px solid #d6dbe2;
  border-radius: 6px;
  background: #ffffff;
  padding: 8px;
}

.ve-rule-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ve-rule-conditions {
  display: grid;
  gap: 6px;
}

.ve-rule-condition {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 6px;
  align-items: center;
}

.ve-rule-then-wrap {
  margin-top: 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  align-items: center;
}

.ve-concat-builder {
  display: grid;
  gap: 8px;
}

.ve-concat-tokens {
  display: grid;
  gap: 6px;
}

.ve-concat-token {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  padding: 6px;
  background: #fff;
}

.ve-token-title {
  font-size: 12px;
  color: #4a5568;
  font-weight: 600;
  min-width: 88px;
}

.ve-date-helper {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

@media (max-width: 1100px) {
  .ve-row {
    grid-template-columns: 1fr 1fr;
  }

  .ve-rule-condition {
    grid-template-columns: 1fr 1fr;
  }
}

.rule-suggestion-insights {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbf9;
  padding: 8px;
}

.rule-suggestion-insights-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rule-suggestion-insights-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rule-suggestion-list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 12px;
}

.rule-suggestion-list li {
  margin-bottom: 2px;
}

@media (max-width: 900px) {
  .rule-suggestion-insights-body {
    grid-template-columns: 1fr;
  }
}

/* ── Triage Detail — Collapsible Panels ───────────────────────── */
.triage-panel .panel-head {
  cursor: default;
}

.triage-panel.is-collapsed .panel-body {
  display: none;
}

.triage-panel .panel-body {
  margin-top: 12px;
}

.btn-collapse {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-collapse:hover {
  background: #f0f4f2;
}

/* ── Triage Detail — Field Preview ────────────────────────────── */
.field-preview-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.field-preview-text {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
  word-break: break-word;
}

.btn-field-preview {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-field-preview:hover {
  opacity: 0.75;
}

/* ── Triage Detail — Content Modal ────────────────────────────── */
.triage-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.triage-modal-overlay[hidden] {
  display: none !important;
}

.triage-modal-dialog {
  background: var(--panel);
  border-radius: 12px;
  max-width: 820px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  margin: auto 0;
}

.triage-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.triage-modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.btn-modal-close {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  line-height: 1;
}

.btn-modal-close:hover {
  background: #f0f4f2;
}

.triage-modal-dialog .modal-body {
  overflow-y: auto;
  padding: 16px 20px;
  flex: 1;
  overscroll-behavior: contain;
}

.triage-modal-pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: none;
  font-size: 13px;
  line-height: 1.6;
}
