:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #dbe4ef;
  --blue: #2563eb;
  --green: #047857;
  --orange: #b45309;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.import-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.import-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: 28px;
}

.import-head p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
}

.import-panel,
.notice,
.toolbar,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import-panel {
  padding: 14px;
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  padding: 16px;
  border: 1px dashed #9db3d0;
  border-radius: 8px;
  background: #f8fbff;
  cursor: pointer;
}

.drop-zone strong,
.drop-zone small {
  display: block;
}

.drop-zone small {
  margin-top: 3px;
  color: var(--muted);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.import-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.summary-grid div {
  min-width: 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-grid strong {
  display: block;
  font-size: 24px;
}

.summary-grid span {
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.toolbar-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 190px) minmax(140px, 150px) minmax(140px, 150px);
  gap: 10px;
  min-width: 0;
}

.toolbar-primary {
  display: flex;
  justify-content: flex-end;
}

.toolbar-more {
  grid-column: 1 / -1;
  position: relative;
  min-width: 0;
}

.toolbar-more summary {
  display: none;
  list-style: none;
}

.toolbar-more summary::-webkit-details-marker {
  display: none;
}

.toolbar-more-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.toolbar input,
.toolbar select,
.toolbar button,
.toolbar-more summary {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.toolbar input,
.toolbar select {
  padding: 0 12px;
}

.toolbar button,
.toolbar-more summary {
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  user-select: none;
}

.toolbar-primary button,
.toolbar-more summary {
  white-space: nowrap;
}

.toolbar button.is-active {
  border-color: #d6ad4b;
  background: #fff7db;
  color: #7a4f00;
}

.toolbar button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.notice {
  padding: 12px 14px;
  color: #1f3a5f;
  background: #eef6ff;
  margin-bottom: 12px;
  line-height: 1.45;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
  color: #334155;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}

.source-pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #e0ecff;
  color: #1d4ed8;
}

.source-pill.instagram {
  background: #ffe4ef;
  color: #be185d;
}

.source-pill.phone {
  background: #dcfce7;
  color: #166534;
}

.source-pill.facebook.is-later {
  background: #dcfce7;
  color: #166534;
}

.dup-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 800;
}

.dup-badge.is-blocked {
  background: #fee2e2;
  color: #991b1b;
}

.dup-badge.is-warning {
  background: #fef3c7;
  color: #92400e;
}

.decision-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  font-weight: 800;
}

.decision-badge.rejected {
  background: #f1f5f9;
  color: #475569;
}

.decision-badge.imported {
  background: #dcfce7;
  color: #166534;
}

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

.row-actions button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.row-actions button:hover:not(:disabled) {
  border-color: var(--blue);
  color: var(--blue);
}

.row-actions button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.handled-note {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 7px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 800;
}

.copy-name-btn {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-left: 8px;
  padding: 0 9px;
  border: 1px solid #b8d4c9;
  border-radius: 999px;
  background: #f0fdf7;
  color: #07583f;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.copy-name-btn:hover {
  border-color: var(--green);
  background: #dcfce7;
}

.inline-details-btn {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-left: 8px;
  padding: 0 9px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.inline-details-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.import-history {
  margin-bottom: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import-history:empty {
  display: none;
}

.import-history-accordion {
  border: 1px solid #e3ebf5;
  border-radius: 8px;
  overflow: hidden;
}

.import-history-accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 16px;
}

.import-history-accordion summary::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #334155;
  font-weight: 900;
}

.import-history-accordion[open] summary::after {
  content: "-";
}

.history-items {
  display: grid;
  gap: 0;
  padding: 0;
}

.history-item {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-top: 1px solid #edf2f7;
}

.history-date {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.history-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.profile-link {
  color: var(--blue);
  word-break: break-all;
}

.inline-profile {
  display: inline-flex;
  margin: 0 8px 0 0;
  font-size: 12px;
  font-weight: 800;
}

.import-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.review-note {
  width: 100%;
  min-width: 220px;
  resize: vertical;
  border: 1px solid #d7e0eb;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
}

.review-note.has-note {
  border-color: #dc2626;
}

.review-note:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}

.import-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .38);
}

.import-modal.is-open {
  display: flex;
}

.import-modal-panel {
  width: min(100%, 460px);
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .24);
  padding: 18px;
}

.import-modal-panel h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.modal-contact-name {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 800;
}

.import-modal-panel label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 800;
  color: #334155;
}

.import-modal-panel input,
.import-modal-panel textarea {
  width: 100%;
  border: 1px solid #d7e0eb;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
}

.import-modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.import-modal-actions button {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  padding: 0 12px;
  font-weight: 800;
  cursor: pointer;
}

.import-modal-actions button[data-modal-action="save"] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

@media (max-width: 820px) {
  .import-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 14px;
  }

  .import-head {
    display: block;
  }

  .back-link {
    margin-bottom: 12px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    grid-template-columns: 1fr auto;
    align-items: stretch;
  }

  .toolbar-filters {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar-primary {
    justify-content: stretch;
  }

  .toolbar-primary button {
    width: 100%;
  }

  .toolbar-more {
    grid-column: auto;
    justify-self: end;
  }

  .toolbar-more summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
  }

  .toolbar-more-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 8;
    display: none;
    width: min(320px, calc(100vw - 36px));
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 35px rgba(15, 23, 42, .18);
  }

  .toolbar-more[open] .toolbar-more-menu {
    display: grid;
    gap: 8px;
  }

  .toolbar-more-menu button {
    width: 100%;
  }

  .history-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .copy-name-btn {
    margin-left: 0;
    margin-top: 6px;
    width: fit-content;
  }
}

@media (max-width: 560px) {
  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar-filters {
    grid-template-columns: 1fr;
  }

  .toolbar-more {
    justify-self: stretch;
  }

  .toolbar-more summary {
    width: 100%;
  }

  .toolbar-more-menu {
    left: 0;
    right: auto;
    width: 100%;
  }
}
