/* TFE Prospectos – panel (scoped under #tfe-crm) */
#tfe-crm {
  --tc-bg: #f6f7f5;
  --tc-card: #ffffff;
  --tc-ink: #16201a;
  --tc-muted: #66706a;
  --tc-line: #e2e6e1;
  --tc-green: #1f7a3a;
  --tc-green-ink: #ffffff;
  --tc-green-soft: #e6f2e9;
  --tc-alta: #1f7a3a;
  --tc-media: #b7791f;
  --tc-baja: #8a948e;
  --tc-danger: #b42318;
  --tc-radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--tc-ink);
  background: var(--tc-bg);
  border-radius: 14px;
  padding: 20px;
  max-width: 1280px;
  margin: 0 auto;
  box-sizing: border-box;
}
#tfe-crm *, #tfe-crm *::before, #tfe-crm *::after { box-sizing: border-box; }
#tfe-crm.tfe-crm-admin { margin: 16px 0 0; max-width: none; }
#tfe-crm h2, #tfe-crm h3 { margin: 0; color: var(--tc-ink); font-weight: 700; letter-spacing: -0.01em; }
#tfe-crm h2 { font-size: 24px; }
#tfe-crm h3 { font-size: 18px; margin-bottom: 14px; }
#tfe-crm a { color: var(--tc-green); text-decoration: none; word-break: break-word; }
#tfe-crm a:hover { text-decoration: underline; }
#tfe-crm .tc-brand { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tc-green); }
#tfe-crm .tc-muted { color: var(--tc-muted); }
#tfe-crm .tc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Buttons & inputs */
#tfe-crm .tc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--tc-line); background: var(--tc-card); color: var(--tc-ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
#tfe-crm .tc-btn:hover { border-color: #c7cec8; background: #fafbfa; text-decoration: none; }
#tfe-crm .tc-btn:disabled { opacity: .6; cursor: default; }
#tfe-crm .tc-primary { background: var(--tc-green); border-color: var(--tc-green); color: var(--tc-green-ink); }
#tfe-crm .tc-primary:hover { background: #18652f; border-color: #18652f; }
#tfe-crm .tc-ghost { background: transparent; }
#tfe-crm .tc-danger { color: var(--tc-danger); border-color: #f1c4bf; }
#tfe-crm .tc-sm { height: 30px; padding: 0 10px; font-size: 13px; }
#tfe-crm .tc-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--tc-ink); cursor: pointer; text-align: left; }
#tfe-crm .tc-link:hover { color: var(--tc-green); text-decoration: underline; }
#tfe-crm input, #tfe-crm select, #tfe-crm textarea {
  font: inherit; color: var(--tc-ink); background: var(--tc-card);
  border: 1px solid var(--tc-line); border-radius: 8px; padding: 0 10px; height: 38px;
  width: 100%; max-width: none; margin: 0; box-shadow: none;
}
#tfe-crm textarea { height: auto; padding: 8px 10px; resize: vertical; }
#tfe-crm input:focus, #tfe-crm select:focus, #tfe-crm textarea:focus, #tfe-crm .tc-btn:focus-visible, #tfe-crm .tc-link:focus-visible {
  outline: 2px solid var(--tc-green); outline-offset: 1px; border-color: var(--tc-green);
}
#tfe-crm .tc-card { background: var(--tc-card); border: 1px solid var(--tc-line); border-radius: var(--tc-radius); padding: 20px; }
#tfe-crm .tc-err { color: var(--tc-danger); min-height: 1.2em; margin: 8px 0 0; }
#tfe-crm .tc-loading, #tfe-crm .tc-empty { padding: 40px; text-align: center; color: var(--tc-muted); }

/* Login */
#tfe-crm .tc-login { display: flex; justify-content: center; padding: 48px 0; }
#tfe-crm .tc-login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; padding: 28px; }
#tfe-crm .tc-login-card h2 { font-size: 22px; margin-bottom: 6px; }
#tfe-crm .tc-login-card label { font-weight: 600; font-size: 13px; }
#tfe-crm .tc-login-card .tc-btn { height: 40px; margin-top: 4px; }

/* Header */
#tfe-crm .tc-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
#tfe-crm .tc-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Stats */
#tfe-crm .tc-stats { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
#tfe-crm .tc-stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--tc-card); border: 1px solid var(--tc-line); border-radius: var(--tc-radius);
  padding: 12px 14px; font: inherit; color: var(--tc-ink); text-align: left; cursor: pointer; border-left-width: 4px;
}
#tfe-crm div.tc-stat { cursor: default; border-left-color: var(--tc-ink); }
#tfe-crm .tc-stat.is-active { box-shadow: 0 0 0 2px var(--tc-green); }
#tfe-crm .tc-stat-n { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
#tfe-crm .tc-stat-l { font-size: 12px; color: var(--tc-muted); }
#tfe-crm .tc-e-porcontactar { border-left-color: #9aa39d; }
#tfe-crm .tc-e-contactado { border-left-color: #2b6cb0; }
#tfe-crm .tc-e-respondio { border-left-color: #7c3aed; }
#tfe-crm .tc-e-demoagendada { border-left-color: #b7791f; }
#tfe-crm .tc-e-cliente { border-left-color: var(--tc-green); }
#tfe-crm .tc-e-nointeresado { border-left-color: var(--tc-danger); }

/* Filters */
#tfe-crm .tc-filters { display: grid; grid-template-columns: 2fr repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
#tfe-crm .tc-count { font-size: 12px; color: var(--tc-muted); margin: 6px 2px 10px; }

/* Table */
#tfe-crm .tc-list { background: var(--tc-card); border: 1px solid var(--tc-line); border-radius: var(--tc-radius); overflow: hidden; }
#tfe-crm .tc-table { width: 100%; border-collapse: collapse; margin: 0; border: 0; }
#tfe-crm .tc-table th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--tc-muted); background: #fafbfa; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--tc-line);
}
#tfe-crm .tc-table td { padding: 12px; vertical-align: top; border: 0; border-bottom: 1px solid var(--tc-line); background: transparent; }
#tfe-crm .tc-row:hover td { background: #fbfcfb; }
#tfe-crm .tc-row.is-open td { border-bottom-color: transparent; }
#tfe-crm .tc-org { min-width: 200px; }
#tfe-crm .tc-sub { display: block; color: var(--tc-muted); font-size: 12px; margin-top: 2px; }
#tfe-crm .tc-note { display: block; font-size: 12px; margin-top: 6px; background: #fff8e1; border-radius: 6px; padding: 4px 8px; color: #6b4e00;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#tfe-crm .tc-contact { min-width: 180px; font-size: 13px; }
#tfe-crm .tc-contact > div + div { margin-top: 3px; }
#tfe-crm .tc-person { font-weight: 600; }
#tfe-crm .tc-sells { font-size: 13px; color: #3c4640; max-width: 240px; }
#tfe-crm .tc-estado { height: 32px; font-size: 13px; font-weight: 600; min-width: 140px; border-left-width: 4px; }
#tfe-crm .tc-date { display: block; font-size: 12px; color: var(--tc-muted); margin-top: 4px; }
#tfe-crm .tc-row-actions { white-space: nowrap; text-align: right; }
#tfe-crm .tc-row-actions .tc-btn + .tc-btn { margin-left: 4px; }
#tfe-crm .tc-prio { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
#tfe-crm .tc-prio-alta { background: var(--tc-green-soft); color: var(--tc-alta); }
#tfe-crm .tc-prio-media { background: #fdf3e1; color: #8a5a12; }
#tfe-crm .tc-prio-baja { background: #eef0ee; color: #59625c; }
#tfe-crm .tc-detail td { background: #fafbfa; padding: 4px 12px 16px; }
#tfe-crm .tc-detail dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; margin: 0; }
#tfe-crm .tc-detail dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tc-muted); margin: 0 0 2px; }
#tfe-crm .tc-detail dd { margin: 0; font-size: 13px; }

/* Modal */
#tfe-crm .tc-modal { position: fixed; inset: 0; background: rgba(15, 22, 18, .45); z-index: 100000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
#tfe-crm .tc-form { width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
#tfe-crm .tc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
#tfe-crm .tc-field { display: flex; flex-direction: column; gap: 4px; }
#tfe-crm .tc-field label { font-size: 12px; font-weight: 600; color: #3c4640; }
#tfe-crm .tc-wide { grid-column: 1 / -1; }
#tfe-crm .tc-form-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
#tfe-crm .tc-spacer { flex: 1; }
body.tc-noscroll { overflow: hidden; }

/* Toast */
#tfe-crm .tc-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--tc-ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 100001;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px);
}
#tfe-crm .tc-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
#tfe-crm .tc-toast.is-bad { background: var(--tc-danger); }

/* Admin settings box */
.tfe-crm-settings { margin-top: 16px; background: #fff; border: 1px solid #dcdcde; border-radius: 8px; padding: 10px 16px; }
.tfe-crm-settings summary { font-weight: 600; cursor: pointer; }
.tfe-crm-settings input[type=password] { margin: 0 8px; }

/* Responsive */
@media (max-width: 1080px) {
  #tfe-crm .tc-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #tfe-crm .tc-filters { grid-template-columns: 1fr 1fr; }
  #tfe-crm .tc-filters [data-f="q"] { grid-column: 1 / -1; }
  #tfe-crm .tc-sells { display: none; }
  #tfe-crm .tc-table th:nth-child(4) { display: none; }
}
@media (max-width: 760px) {
  #tfe-crm { padding: 12px; border-radius: 0; }
  #tfe-crm h2 { font-size: 20px; }
  #tfe-crm .tc-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #tfe-crm .tc-stat { padding: 8px 10px; }
  #tfe-crm .tc-stat-n { font-size: 20px; }
  #tfe-crm .tc-list { background: transparent; border: 0; }
  #tfe-crm .tc-table, #tfe-crm .tc-table tbody { display: block; }
  #tfe-crm .tc-table thead { display: none; }
  #tfe-crm .tc-row { display: grid; grid-template-columns: 1fr auto; background: var(--tc-card); border: 1px solid var(--tc-line); border-radius: var(--tc-radius); margin-bottom: 10px; padding: 12px; gap: 8px; }
  #tfe-crm .tc-row.is-open { border-radius: var(--tc-radius) var(--tc-radius) 0 0; margin-bottom: 0; border-bottom: 0; }
  #tfe-crm .tc-row td { display: block; padding: 0; border: 0; background: transparent !important; }
  #tfe-crm .tc-row td:nth-child(1) { grid-column: 2; grid-row: 1; }
  #tfe-crm .tc-row td.tc-org { grid-column: 1; grid-row: 1; min-width: 0; }
  #tfe-crm .tc-row td.tc-contact, #tfe-crm .tc-row td:nth-child(5), #tfe-crm .tc-row .tc-row-actions { grid-column: 1 / -1; min-width: 0; }
  #tfe-crm .tc-row .tc-row-actions { text-align: left; display: flex; gap: 6px; }
  #tfe-crm .tc-row .tc-row-actions .tc-btn { flex: 1; margin: 0; }
  #tfe-crm .tc-estado { width: 100%; }
  #tfe-crm .tc-detail { display: block; background: #fafbfa; border: 1px solid var(--tc-line); border-top: 0; border-radius: 0 0 var(--tc-radius) var(--tc-radius); margin-bottom: 10px; }
  #tfe-crm .tc-detail td { display: block; padding: 12px; border: 0; }
  #tfe-crm .tc-grid { grid-template-columns: 1fr; }
  #tfe-crm .tc-modal { padding: 0; }
  #tfe-crm .tc-form { border-radius: 0; min-height: 100%; }
  #tfe-crm .tc-head { align-items: flex-start; }
  #tfe-crm .tc-actions { width: 100%; }
  #tfe-crm .tc-actions .tc-btn { flex: 1; }
}
