:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #f0f4f2;
  --border: #d9e0dc;
  --text: #18211f;
  --muted: #66736e;
  --accent: #1f7a58;
  --accent-dark: #155d43;
  --blue: #235b8f;
  --amber: #a86705;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

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

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 650;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 88, 0.14);
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

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

.select-column {
  width: 42px;
  min-width: 42px;
  text-align: center;
}

.select-column input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 12;
  overflow: visible;
  background: #eef3f1;
  color: #42504b;
  font-size: 12px;
  font-weight: 800;
}

.inline-column-filter {
  position: relative;
  min-width: 105px;
}

.inline-column-filter.active .column-filter-details summary {
  color: var(--accent-dark);
}

.column-filter-details {
  position: relative;
}

.column-filter-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  border-radius: 5px;
  color: inherit;
  cursor: pointer;
  font-size: inherit;
  font-weight: 800;
  list-style: none;
}

.column-filter-details summary::-webkit-details-marker {
  display: none;
}

.column-filter-details summary::after {
  content: "▾";
  font-size: 10px;
}

.column-filter-details[open] summary::after {
  content: "▴";
}

.column-filter-details[open] {
  z-index: 30;
}

.column-filter-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 7px);
  z-index: 31;
  width: 260px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  padding: 8px;
  box-shadow: var(--shadow);
}

.column-filter-search {
  min-height: 32px;
  border-radius: 5px;
  padding: 5px 7px;
  font-size: 12px;
}

.column-filter-tools {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.column-filter-tools button {
  flex: 1;
  min-height: 30px;
  padding: 0 6px;
  font-size: 11px;
}

.column-filter-options {
  display: grid;
  gap: 2px;
  max-height: 230px;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px;
}

.column-filter-option {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  border-radius: 5px;
  padding: 4px 6px;
  color: #2c3835;
  font-size: 12px;
  font-weight: 650;
}

.column-filter-option:hover {
  background: #f3faf7;
}

.column-filter-option input {
  width: 15px;
  min-height: 15px;
  accent-color: var(--accent);
}

.column-filter-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

td {
  color: #26312e;
}

tbody tr {
  background: #ffffff;
}

tbody tr:hover {
  background: #f3faf7;
}

tbody tr.selected {
  background: #e8f5ef;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(31, 122, 88, 0.1), rgba(35, 91, 143, 0.08)),
    var(--bg);
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel,
.panel,
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.login-panel {
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-block.compact {
  margin-bottom: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 850;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.2;
}

.stack {
  display: grid;
  gap: 14px;
}

.primary-action {
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--accent-dark);
}

.secondary-action {
  background: #edf6f2;
  border-color: #b9d9cc;
  color: var(--accent-dark);
}

.secondary-action:hover {
  background: #dff0e9;
}

.ghost-action {
  background: #ffffff;
  border-color: var(--border);
  color: #2c3835;
}

.ghost-action:hover {
  background: var(--surface-soft);
}

.danger-action {
  min-height: 30px;
  border-color: #f0b8b2;
  background: #fff1f0;
  color: var(--danger);
  font-size: 12px;
}

.danger-action:hover {
  background: #ffe3e0;
}

.form-error,
.inline-status {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.form-error:not(:empty),
.error {
  color: var(--danger);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email {
  color: var(--muted);
  font-weight: 700;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  width: min(1500px, calc(100vw - 32px));
  margin: 18px auto 28px;
}

.workbench,
.side-column {
  display: grid;
  align-content: start;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.stat {
  min-height: 78px;
  padding: 14px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
}

.panel {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfc;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.selection-count {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.control-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  padding: 14px;
}

.control-grid.filters {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  border-bottom: 1px solid var(--border);
}

.check-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding-top: 18px;
  color: #43514c;
}

.check-control input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.naf-picker-label {
  grid-column: span 2;
  position: relative;
  z-index: 3;
}

.naf-picker-details {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
}

.naf-picker-details[open] {
  z-index: 10;
}

.naf-picker-details summary {
  min-height: 34px;
  padding: 8px 10px;
  color: #43514c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.naf-option-list {
  position: absolute;
  left: -1px;
  top: calc(100% - 1px);
  z-index: 11;
  display: grid;
  gap: 2px;
  width: min(620px, calc(100vw - 72px));
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 7px 7px;
  background: #ffffff;
  padding: 6px;
  box-shadow: var(--shadow);
}

.naf-option {
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 8px;
  min-height: 30px;
  border-radius: 5px;
  padding: 5px 6px;
  color: #2c3835;
  font-size: 12px;
  font-weight: 650;
}

.naf-option:hover {
  background: #f3faf7;
}

.naf-option input {
  width: 15px;
  min-height: 15px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.naf-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.table-wrap {
  position: relative;
  min-height: 360px;
  max-height: 560px;
  overflow: auto;
}

.enrichment-preview {
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.search-preview {
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.search-preview-table {
  min-width: 1120px;
}

.preview-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.preview-table {
  min-width: 980px;
}

.preview-table td {
  font-size: 13px;
}

.preview-table a {
  color: var(--blue);
  font-weight: 750;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 180px;
}

.preview-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 11px;
}

.merge-prospect {
  min-height: 30px;
  padding: 0 8px;
  font-size: 11px;
  white-space: nowrap;
}

.company-cell {
  display: grid;
  gap: 2px;
  min-width: 220px;
}

.company-cell strong {
  color: var(--text);
}

.company-cell span {
  color: var(--muted);
  font-size: 12px;
}

.score-pill,
.status-pill,
.priority-pill,
.legal-pill,
.contact-pill,
.sms-pill,
.confidence-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.score-pill {
  background: #ecf7f2;
  color: var(--accent-dark);
}

.score-pill.warn {
  background: #fff2d8;
  color: var(--amber);
}

.status-pill {
  background: #eef2f6;
  color: var(--blue);
}

.status-pill.due {
  background: #fff2d8;
  color: var(--amber);
}

.priority-pill {
  background: #f1f4f3;
  color: #42504b;
}

.priority-pill.haute {
  background: #fff1f0;
  color: var(--danger);
}

.priority-pill.moyenne {
  background: #fff2d8;
  color: var(--amber);
}

.priority-pill.basse {
  background: #ecf7f2;
  color: var(--accent-dark);
}

.legal-pill {
  background: #f1f4f3;
  color: #42504b;
}

.contact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.contact-pill {
  background: #f1f4f3;
  color: #42504b;
}

.table-link {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.confidence-pill {
  background: #eef2f6;
  color: var(--blue);
}

.sms-pill {
  background: #f1f4f3;
  color: #42504b;
}

.sms-pill.sent {
  background: #ecf7f2;
  color: var(--accent-dark);
}

.sms-pill.stop,
.sms-pill.failed {
  background: #fff1f0;
  color: var(--danger);
}

.side-column {
  position: sticky;
  top: 90px;
}

.detail-panel,
.sms-panel {
  min-width: 0;
}

.detail-panel select {
  max-width: 150px;
}

.detail-empty {
  padding: 18px 14px;
  color: var(--muted);
  font-weight: 700;
}

.detail-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.detail-title {
  display: grid;
  gap: 4px;
}

.detail-title h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.detail-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.kv {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px;
  background: #fcfdfd;
}

.kv span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.kv strong,
.kv a {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
}

.kv a {
  color: var(--blue);
  font-weight: 750;
}

.contact-kv {
  display: grid;
  gap: 5px;
}

.contact-kv em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.crm-form,
.activity-form {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--border);
}

.crm-form[hidden],
.activity-form[hidden] {
  display: none;
}

.compact-grid {
  grid-template-columns: 1fr 1fr;
  padding: 0;
}

.check-control.no-top {
  padding-top: 0;
}

.notes-field {
  padding: 0;
}

.form-actions,
.panel-subheading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-subheading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.activity-list {
  display: grid;
  gap: 8px;
}

.activity-item,
.activity-empty {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px;
  background: #fcfdfd;
}

.activity-item div {
  display: grid;
  gap: 2px;
}

.activity-item strong {
  color: var(--text);
  font-size: 13px;
}

.activity-item span,
.activity-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.activity-item p {
  margin: 7px 0 0;
  color: #2c3835;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sms-panel form {
  padding: 14px;
}

.sms-subsection {
  display: grid;
  gap: 8px;
  padding: 0 14px 12px;
}

.sms-subsection h3 {
  margin: 0;
  color: #43514c;
  font-size: 13px;
}

.sms-recipient-list,
.sms-stop-list {
  display: grid;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  padding: 8px;
}

.sms-stop-list {
  margin: 0 14px 12px;
}

.sms-recipient-row,
.sms-stop-row {
  display: grid;
  gap: 2px;
  border-radius: 5px;
  background: #f7faf9;
  padding: 7px 8px;
  color: #2c3835;
  font-size: 12px;
}

.sms-recipient-row strong,
.sms-stop-row strong {
  overflow-wrap: anywhere;
}

.sms-recipient-row span,
.sms-stop-row span {
  color: var(--muted);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.sms-recipient-row.blocked {
  background: #fff4f2;
}

.sms-panel .inline-status,
.panel > .inline-status {
  padding: 0 14px 14px;
}

@media (max-width: 1180px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .side-column {
    position: static;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 860px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .stats-grid,
  .control-grid,
  .control-grid.filters,
  .compact-grid,
  .side-column,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .check-control {
    padding-top: 0;
  }
}
