/* Wingman CRM — application styles. Cascading, not atomic. Bootstrap 5 underneath. */

:root {
  --app-bg: #f5f5f3;
  --app-surface: #ffffff;
  --app-hover: #f0f0ed;
  --app-border: #e6e6e2;
  --app-border-strong: #d4d4cf;
  --app-text: #1a1a1a;
  --app-text-2: #4a4a47;
  --app-muted: #696962;                    /* 5.1:1 on the page, 4.8:1 on a hovered row */
  --app-accent: #2e5fd1;
  --app-accent-dark: #244aa6;
  --app-accent-soft: #e8eefc;
  --app-danger: #a12b1f;
  --app-danger-soft: #fbe4e1;
  --app-radius: 8px;
  --topbar-h: 52px;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 60px;

  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-border-color: var(--app-border);
  --bs-link-color: var(--app-accent);
  --bs-link-hover-color: var(--app-accent-dark);
  --bs-link-color-rgb: 46, 95, 209;        /* Bootstrap 5.3 colours <a> from the -rgb pair */
  --bs-link-hover-color-rgb: 36, 74, 166;
  --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html {
  font-size: 14px;
}
body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  letter-spacing: -0.01em;
}

/* Links: no underline until hover/focus/active, progressively darker */
a {
  text-decoration: none;
}
a:hover,
a:focus-visible {
  text-decoration: underline;
}
a:active {
  color: #1b3a86;
}
/* Links inside grey text are told apart by weight as well as colour (WCAG 1.4.1) */
.crumbs a,
.page-subtitle a,
.form-text a,
.text-muted a {
  font-weight: 500;
}
.text-danger {
  color: var(--app-danger) !important;
}

/* ---- Top bar ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-h);
  padding: 0 1rem;
  background: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
}
.brand {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--app-text);
}
.brand:hover,
.brand:focus-visible {
  color: var(--app-text);
  text-decoration: none;
}
.user-menu {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--app-text);
  font-weight: 500;
}
.user-menu:hover,
.user-menu:focus-visible {
  background: var(--app-hover);
}
.user-menu .bi-chevron-down {
  font-size: 0.7rem;
  color: var(--app-muted);
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--app-text);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---- Shell: sidebar + content ---------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
  transition: grid-template-columns 0.15s ease;
}
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.6rem 1.5rem;
  background: var(--app-surface);
  border-right: 1px solid var(--app-border);
}
.nav-label {
  margin: 0.9rem 0.6rem 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  color: var(--app-text-2);
  font-weight: 500;
  white-space: nowrap;
}
.nav-item .bi {
  width: 1.1rem;
  font-size: 1rem;
  text-align: center;
  flex: 0 0 auto;
}
.nav-item span:not(.count) {
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item .count {
  margin-left: auto;
}
.nav-item:hover,
.nav-item:focus-visible {
  background: var(--app-hover);
  color: var(--app-text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--app-text);
  color: #fff;
}
.nav-item.active .count {
  color: rgba(255, 255, 255, 0.7);
}
html.sidebar-collapsed .shell {
  grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr);
}
html.sidebar-collapsed .sidebar {
  padding-inline: 0.5rem;
}
html.sidebar-collapsed .nav-label,
html.sidebar-collapsed .nav-item span {
  display: none;
}
html.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 0;
}
@media (max-width: 991.98px) {
  .shell {
    grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr);
  }
  .nav-label,
  .nav-item span {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding-inline: 0;
  }
  .user-name {
    display: none;
  }
}

.content {
  min-width: 0;
}
.container-app {
  max-width: 1400px;
  margin-inline: auto;
  padding: 1.5rem 2rem 3rem;
}
@media (max-width: 575.98px) {
  .container-app {
    padding: 1rem 0.75rem 2rem;
  }
}
.form-page {
  max-width: 860px;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;              /* Save and Cancel always sit below the last card */
}
.narrow {
  max-width: 560px;
}

/* ---- Page header ------------------------------------------------------ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.2;
}
.page-title .bi {
  color: var(--app-muted);
  font-size: 1.2rem;
  vertical-align: -0.1em;
}
.page-subtitle {
  margin: 0.25rem 0 0;
  color: var(--app-muted);
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}
@media (max-width: 767.98px) {
  .page-header {
    flex-wrap: wrap;             /* actions drop below the title rather than squeezing it */
  }
}
.crumbs {
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--app-muted);
}

/* ---- In-page navigation (long detail pages) --------------------------- */

.page-nav {
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0;
  background: var(--app-bg);
  overflow-x: auto;              /* one row always, so the anchor offset below stays right */
  scrollbar-width: thin;
}
.page-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-surface);
  color: var(--app-text-2);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}
.page-nav a:hover,
.page-nav a:focus-visible {
  border-color: var(--app-text);
  color: var(--app-text);
  text-decoration: none;
}
.page-nav .count {
  color: var(--app-muted);
  font-variant-numeric: tabular-nums;
}
section[id] {
  scroll-margin-top: calc(var(--topbar-h) + 4.5rem);   /* clears the top bar and the sticky pill row */
}

/* ---- Buttons ---------------------------------------------------------- */

.btn {
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}
.btn-link {
  text-decoration: none;
}
.btn-link:hover,
.btn-link:focus-visible {
  text-decoration: underline;
}
.btn-primary {
  --bs-btn-bg: var(--app-accent);
  --bs-btn-border-color: var(--app-accent);
  --bs-btn-hover-bg: var(--app-accent-dark);
  --bs-btn-hover-border-color: var(--app-accent-dark);
  --bs-btn-active-bg: #1b3a86;
  --bs-btn-active-border-color: #1b3a86;
}
.btn-dark {
  --bs-btn-bg: var(--app-text);
  --bs-btn-border-color: var(--app-text);
  --bs-btn-hover-bg: #000;
  --bs-btn-hover-border-color: #000;
}
.btn-success {
  --bs-btn-bg: #2a7a4b;
  --bs-btn-border-color: #2a7a4b;
  --bs-btn-hover-bg: #22633d;
  --bs-btn-hover-border-color: #22633d;
}
/* Outline text at 4.5:1 or better on the page (Bootstrap's own greys and greens fall short) */
.btn-outline-secondary {
  --bs-btn-color: #5c636a;
  --bs-btn-border-color: #5c636a;
  --bs-btn-hover-bg: #5c636a;
  --bs-btn-hover-border-color: #5c636a;
  --bs-btn-active-bg: #5c636a;
  --bs-btn-active-border-color: #5c636a;
}
.btn-outline-success {
  --bs-btn-color: #146c43;
  --bs-btn-border-color: #146c43;
  --bs-btn-hover-bg: #146c43;
  --bs-btn-hover-border-color: #146c43;
  --bs-btn-active-bg: #146c43;
  --bs-btn-active-border-color: #146c43;
}

/* Ghost icon button: invisible chrome, button-like only on hover / focus / active */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--app-muted);
  font-size: 1rem;
  line-height: 1;
}
.btn-icon:hover,
.btn-icon:focus-visible {
  background: var(--app-hover);
  color: var(--app-text);
  text-decoration: none;
}
.btn-icon:active {
  background: var(--app-border);
}
.btn-icon.danger:hover,
.btn-icon.danger:focus-visible {
  background: var(--app-danger-soft);
  color: var(--app-danger);
}
.btn-icon.lg {
  width: 38px;
  height: 38px;
  font-size: 1.15rem;
}
.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.15rem;
  opacity: 0;
  transition: opacity 0.1s;
}
tr:hover .row-actions,
tr:focus-within .row-actions {
  opacity: 1;
}
@media (hover: none) {
  .row-actions {
    opacity: 1;                  /* touch screens have no hover */
  }
}

/* ---- Cards ------------------------------------------------------------ */

.card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: none;
  background: var(--app-surface);
}
.card-header {
  padding: 0.7rem 1rem;
  background: transparent;
  border-bottom: 1px solid var(--app-border);
  font-weight: 600;
}
.card-header .h6 {
  font-size: 0.95rem;
  font-weight: 600;
}
.card-header h2 .bi {
  color: var(--app-muted);
}
.card-header.d-flex {
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---- Tables ----------------------------------------------------------- */

.table {
  --bs-table-hover-bg: var(--app-hover);
  margin-bottom: 0;
  font-size: 0.9rem;
}
.table > :not(caption) > * > * {
  padding: 0.65rem 1rem;
  border-bottom-color: var(--app-border);
}
.table > thead th {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--app-muted);
  white-space: nowrap;
}
.table-list td {
  vertical-align: middle;
}
.table-list a.row-link {
  color: var(--app-text);
  font-weight: 500;
}
tr[data-href] {
  cursor: pointer;
}
tr[data-href]:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: -2px;
}
/* A table scrolls sideways inside its card; the page itself never does */
.table-responsive {
  position: relative;            /* keeps visually hidden headers inside the scroll box, not widening the page */
}
.card > .table-responsive {
  border-radius: var(--app-radius);
}
.card > .table-responsive > .table tr:last-child td {
  border-bottom: 0;
}
.table-fixed {
  table-layout: fixed;           /* stacked tables keep the same column widths card to card */
}
/* Below these widths a table scrolls inside its card rather than squeezing its columns */
.table-list {
  min-width: 36rem;
}
.table-wide {
  min-width: 50rem;
}
.table-steps {
  min-width: 40rem;
}
.step-table {
  min-width: 34rem;
}
.step-table th:nth-child(1) { width: 5rem; }
.step-table th:nth-child(3) { width: 10rem; }
.step-table th:nth-child(4) { width: 6rem; }
.step-table th:nth-child(5) { width: 5rem; }
th .sort {
  color: inherit;
}
th .sort .bi {
  opacity: 0;
  transition: opacity 0.1s;
}
th:hover .sort .bi,
th .sort.active .bi {
  opacity: 1;
}
th .sort:hover,
th .sort:focus-visible {
  color: var(--app-text);
  text-decoration: none;
}
th .sort.active {
  color: var(--app-text);
}
.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- List toolbar: search, quick toggles, Filters panel, chips -------- */

.list-toolbar {
  position: relative;            /* the Filters panel anchors to the toolbar, not the button */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.toolbar-search {
  position: relative;
  flex: 0 1 24rem;
}
.toolbar-search .bi-search {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--app-muted);
  pointer-events: none;
}
.toolbar-search .form-control {
  padding-left: 2rem;
}
.toggle-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.8rem;
  border: 1px solid var(--app-text);
  border-radius: 999px;
  color: var(--app-text);
  font-size: 0.85rem;
  font-weight: 500;
}
.toggle-pill:hover,
.toggle-pill:focus-visible {
  background: var(--app-hover);
  text-decoration: none;
}
.toggle-pill.on {
  background: var(--app-text);
  color: #fff;
}
.filter-menu > summary {
  list-style: none;
}
.filter-menu > summary::-webkit-details-marker {
  display: none;
}
.filter-menu[open] > summary {
  background: var(--app-text);
  color: #fff;
}
.count-badge {
  display: inline-block;
  min-width: 1.25rem;
  margin-left: 0.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--app-accent);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.25rem;
  text-align: center;
}
.filter-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 20;
  width: min(48rem, 100%);
  padding: 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: 0 10px 28px rgba(26, 26, 26, 0.1);
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem 1rem;
}
.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--app-border);
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
}
.clear-all {
  margin-left: 0.25rem;
  font-size: 0.85rem;
}

/* ---- Forms ------------------------------------------------------------ */

.form-control,
.form-select {
  border-color: var(--app-border-strong);
  border-radius: 6px;
  background-color: var(--app-surface);
}
.form-control:focus,
.form-select:focus {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 3px var(--app-accent-soft);
}
.form-label {
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--app-text-2);
}
.form-text {
  font-size: 0.8rem;
}
.form-control[aria-invalid="true"],
.form-select[aria-invalid="true"] {
  border-color: var(--app-danger);
}

/* Checkboxes and radios: the outline must reach 3:1 against what sits behind it (WCAG 1.4.11).
   --app-muted is 5.5:1 on white, 5.1:1 on the page and 4.8:1 on a hovered row. */
.form-check-input {
  border: 1.5px solid var(--app-muted);
}
.form-check-input:checked,
.form-check-input:indeterminate {
  background-color: var(--app-accent);
  border-color: var(--app-accent);
}
.form-check-input:focus {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 3px var(--app-accent-soft);
}

/* ---- Pills ------------------------------------------------------------ */

.pill {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.pill-neutral { background: #ecece9; color: #3f3f3d; }
.pill-muted   { background: transparent; color: var(--app-muted); border: 1px solid var(--app-border); }
.pill-info    { background: var(--app-accent-soft); color: var(--app-accent); }
.pill-success { background: #e3f2e9; color: #1d6a3e; }
.pill-warning { background: #fbf1dc; color: #865706; }
.pill-danger  { background: var(--app-danger-soft); color: #972a1e; }

/* ---- Detail pages ----------------------------------------------------- */

.kv {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  row-gap: 0.5rem;
  column-gap: 1rem;
}
.kv dt {
  color: var(--app-muted);
  font-weight: 500;
}
.kv-names {
  grid-template-columns: max-content 1fr;   /* variable names are never broken */
}
.kv-names dt {
  white-space: nowrap;
}
.kv dd {
  margin: 0;
  overflow-wrap: break-word;     /* long emails and links wrap at their <wbr> points (the breakable filter) */
}
.notes {
  white-space: pre-line;
  font-size: 0.9rem;
}
.activity-feed .list-group-item {
  padding: 0.65rem 1rem;
}
.list-group {
  --bs-list-group-bg: var(--app-surface);    /* white like the card, not the page grey */
}
.list-group-item {
  border-color: var(--app-border);
}
.empty {
  color: var(--app-muted);                    /* every "No … yet" reads the same, left-aligned */
}
.count {
  font-size: 0.75rem;
  color: var(--app-muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Pipeline --------------------------------------------------------- */

.progress {
  height: 3px;
  border-radius: 999px;
  background: var(--app-border);
}
.progress-bar {
  background: var(--app-accent);
}
.phase-progress {
  border-radius: 0;
}
.progress-cell .progress {
  margin-bottom: 0.25rem;
  min-width: 6rem;
}
.table-steps td {
  vertical-align: middle;
  padding: 0.45rem 1rem;
}
.table-steps .step-name {
  width: 42%;
}
.table-steps .step-date {
  width: 11rem;
}
.table-steps .step-note input {
  min-width: 10rem;
}
.step-row.status-dne .step-name {
  color: var(--app-muted);
}
.step-row.status-na .step-name {
  color: var(--app-muted);
  font-style: italic;
}
.step-row form {
  margin: 0;
}
.step-row .btn-group .btn {
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
}

/* ---- Dashboard -------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 0.9rem 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  color: var(--app-text);
}
a.stat:hover,
a.stat:focus-visible {
  text-decoration: none;
  border-color: var(--app-border-strong);
  background: var(--app-hover);
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-muted);
}
.follow-up.done .small > a,
.follow-up.done .follow-up-summary {
  text-decoration: line-through;
}
.row-error {
  margin: 0.25rem 0 0;
  color: var(--app-danger);
  font-weight: 500;
}
.bar-list li {
  display: grid;
  grid-template-columns: 7rem 1fr 2rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
  font-size: 0.88rem;
}
.bar-label {
  color: var(--app-text);
}
.bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--app-border);
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: var(--app-accent);
  border-radius: 999px;
}
.bar-value {
  text-align: right;
  color: var(--app-muted);
  font-variant-numeric: tabular-nums;
}

/* ---- Picker ----------------------------------------------------------- */

.picker {
  position: relative;
}
.picker-results {
  position: absolute;
  z-index: 1040;
  width: 100%;
  max-height: 18rem;
  overflow: auto;
  background: var(--app-surface);
}
.picker-results:empty {
  display: none;
}

/* ---- Messages, login -------------------------------------------------- */

.alert {
  border-radius: var(--app-radius);
}
.alert-success { --bs-alert-bg: #e3f2e9; --bs-alert-color: #1d6a3e; --bs-alert-border-color: #cde6d6; }
.alert-info    { --bs-alert-bg: var(--app-accent-soft); --bs-alert-color: var(--app-accent-dark); --bs-alert-border-color: #d3defa; }
.alert-warning { --bs-alert-bg: #fbf1dc; --bs-alert-color: #6e4805; --bs-alert-border-color: #f1dfb6; }
.alert-danger  { --bs-alert-bg: var(--app-danger-soft); --bs-alert-color: #7f2117; --bs-alert-border-color: #f2cbc5; }

/* Pagination: ghost page buttons, the current page dark, as the rest of the app */
.pagination {
  --bs-pagination-color: var(--app-text-2);
  --bs-pagination-bg: transparent;
  --bs-pagination-border-color: transparent;
  --bs-pagination-border-radius: 6px;
  --bs-pagination-hover-color: var(--app-text);
  --bs-pagination-hover-bg: var(--app-hover);
  --bs-pagination-hover-border-color: transparent;
  --bs-pagination-focus-color: var(--app-text);
  --bs-pagination-focus-bg: var(--app-hover);
  --bs-pagination-focus-box-shadow: 0 0 0 3px var(--app-accent-soft);
  --bs-pagination-active-color: #fff;
  --bs-pagination-active-bg: var(--app-text);
  --bs-pagination-active-border-color: var(--app-text);
  --bs-pagination-disabled-color: var(--app-muted);
  --bs-pagination-disabled-bg: transparent;
  --bs-pagination-disabled-border-color: transparent;
  gap: 0.15rem;
}
.pagination .page-link {
  margin-left: 0;
  border-radius: var(--bs-pagination-border-radius);
  font-variant-numeric: tabular-nums;
}
.pagination .page-link:hover {
  text-decoration: none;
}
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-brand {
  font-weight: 600;
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
}

/* ---- Tags, chips, bulk bar ------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.3rem 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--app-accent-soft);
  color: var(--app-accent);
  font-size: 0.8rem;
  font-weight: 500;
}
.chip form {
  display: inline;
  margin: 0;
}
.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: inherit;
  width: 1.2rem;
  height: 1.2rem;
  line-height: 1;
  border-radius: 50%;
  padding: 0;
  text-decoration: none;
}
.chip-remove:hover,
.chip-remove:focus-visible {
  background: rgba(46, 95, 209, 0.15);
}
.check-col {
  width: 2.2rem;
  padding-right: 0 !important;
}
.bulk-bar {
  display: flex;
  flex-direction: row;           /* .card would stack the controls in a column */
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--app-accent-soft);
  border-color: var(--app-accent-soft);
}
.bulk-bar .form-control,
.bulk-bar .form-select {
  width: auto;
}
.bulk-count {
  margin-right: auto;
  font-size: 0.9rem;
}

/* ---- Facts ------------------------------------------------------------ */

.finding {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.finding-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--app-muted);
}
.finding-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.15rem;
}
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 16rem;
  white-space: nowrap;
}
.link-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;       /* a long link ends in "…", never cut mid-word */
}

/* ---- Duplicates ------------------------------------------------------- */

.dup-evidence {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.dup-table {
  min-width: 36rem;
}
.dup-table th[scope="row"] {
  width: 9rem;
  color: var(--app-muted);
  font-weight: 500;
}
.dup-table td {
  width: calc(50% - 4.5rem);
}
.dup-table tr.differs td {
  background: #fdf6e3;                     /* fields that differ between the two records */
}
.dup-table tfoot td {
  border-bottom: 0;
}

/* ---- Outreach --------------------------------------------------------- */

.chip-group-label {
  margin: 0.6rem 0 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-muted);
}
.variable-chips .chips {
  gap: 0.4rem;
}
.var-chip {
  border: 0;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}
.var-chip:hover,
.var-chip:focus-visible {
  background: var(--app-accent);
  color: #fff;
}
.email-preview,
.email-body {
  font-size: 0.92rem;
  line-height: 1.55;
}
.email-body {
  white-space: pre-wrap;         /* only the email's own text keeps its line breaks */
}
textarea[data-editor] {
  line-height: 1.55;
  min-height: 12rem;
  resize: vertical;
}
.copied {
  color: #1d6a3e !important;
}
.send-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}
.follow-up-days {
  width: 9rem;
}
.skip {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}
.skip .form-control {
  width: 12rem;
}
@media (max-width: 575.98px) {
  .skip {
    flex: 1 1 100%;              /* reason, Skip and discard share one full row under Mark as sent */
    min-width: 0;
    margin-left: 0;
  }
  .skip .form-control {
    flex: 1;
    width: auto;
    min-width: 0;
  }
}
.template-pick {
  display: flex;
  flex: 0 1 22rem;               /* when the card header wraps, the select takes the whole line */
  align-items: center;
  gap: 0.5rem;
}
.template-pick .form-select {
  flex: 1;
  min-width: 0;
}
@media (max-width: 575.98px) {
  .template-pick {
    flex: 1 1 100%;
    flex-wrap: wrap;
  }
  .template-pick .form-select {
    flex-basis: 100%;            /* its own full line, so the choice reads in full */
  }
}
/* Tabs are pills, as all in-page navigation: outline-dark, dark when active */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.8rem;
  border: 1px solid var(--app-text);
  border-radius: 999px;
  color: var(--app-text);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}
.tabs a:hover,
.tabs a:focus-visible {
  background: var(--app-hover);
  text-decoration: none;
}
.tabs a.active {
  background: var(--app-text);
  color: #fff;
}
.tabs a.active .count {
  color: rgba(255, 255, 255, 0.75);
}

/* ---- Import ----------------------------------------------------------- */

.mapping-table td {
  vertical-align: middle;
}
.mapping-table .form-select {
  min-width: 11rem;
}

/* ---- Parties from pasted emails --------------------------------------- */

.party-rows .form-select,
.party-rows .form-control {
  min-width: 8rem;
}
@media (max-width: 1199.98px) {
  /* One block per address, so nothing scrolls and the firm picker is never clipped */
  .party-rows {
    --bs-table-bg: transparent;  /* blocks sit on the card, without the table's banding */
    min-width: 0;
  }
  .party-rows thead {
    display: none;
  }
  .party-rows,
  .party-rows tbody,
  .party-rows tr,
  .party-rows td {
    display: block;
  }
  .party-rows tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--app-border);
  }
  .party-rows td {
    padding: 0.3rem 1rem;
    border: 0;
  }
}
.sample {
  font-size: 0.8rem;
  color: var(--app-muted);
}
