/* ============================================================
   Mythox - CRM / Emailing v1
   Founder-only contacts, tags, and CSV import.
   ============================================================ */

.crm {
  color: var(--ivory);
}

.crm * {
  box-sizing: border-box;
}

.crm-gate {
  max-width: 560px;
  margin: 42px auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), var(--surface-grad-2));
}

.crm-gate h2,
.crm-head h1 {
  margin: 0;
}

.crm-gate p,
.crm-muted {
  color: var(--muted);
}

.crm-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.crm-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.crm-actions,
.crm-row-actions,
.crm-pager,
.crm-tags-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.crm-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface), var(--surface-grad-2));
  padding: 16px;
}

.crm-card h2,
.crm-card h3 {
  margin: 0 0 12px;
}

.crm-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.crm input,
.crm select,
.crm textarea {
  width: 100%;
  min-width: 0;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ivory);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.crm textarea {
  resize: vertical;
  line-height: 1.45;
}

.crm input:focus,
.crm select:focus,
.crm textarea:focus {
  border-color: var(--gold-2);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.crm label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.crm-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.crm-table th,
.crm-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.crm-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface-2);
}

.crm-table tr:last-child td {
  border-bottom: none;
}

.crm-table tbody tr:hover {
  background: color-mix(in srgb, var(--gold) 7%, transparent);
}

.crm-contact-name {
  font-weight: 750;
  color: var(--ivory);
}

.crm-contact-sub {
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
}

.crm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.2;
}

.crm-pill.gold {
  border-color: var(--gold-line);
  color: var(--gold);
}

.crm-pager {
  justify-content: space-between;
  margin-top: 12px;
}

.crm-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.crm-form-grid .wide {
  grid-column: 1 / -1;
}

.crm-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.crm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ivory);
  font-size: 12.5px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.crm-check input {
  width: auto;
  min-width: auto;
  padding: 0;
}

.crm-tag-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.crm-tag-option {
  flex-direction: row;
  align-items: center;
  width: auto;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 650;
}

.crm-tag-option input {
  width: auto;
  min-width: auto;
  padding: 0;
}

.crm-side-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-tag-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.crm-tag-row:last-child {
  border-bottom: none;
}

.crm-tag-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-import-box {
  border: 1px dashed var(--line-2);
  border-radius: 12px;
  padding: 13px;
  background: var(--surface-2);
}

.crm-msg {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.crm-msg.err {
  color: var(--red);
}

.crm-msg.ok {
  color: var(--green);
}

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

.crm-danger {
  color: var(--red) !important;
  border-color: color-mix(in srgb, var(--red) 45%, transparent) !important;
}

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

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

@media (max-width: 640px) {
  .crm-head {
    flex-direction: column;
  }

  .crm-form-grid,
  .crm-checks {
    grid-template-columns: 1fr;
  }
}
