/* ==========================================================================
   JD CAPITAL CRM — components.css
   Cards, KPIs, tablas, formularios, badges, tabs, modales, timeline, toasts.
   ========================================================================== */

/* ------------------------------------------------------------- CARDS ----- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 13.5px; font-weight: 600; }
.card-head .card-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.card-head .card-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 18px; }
.card-body.tight { padding: 12px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 11px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg); font-size: 12px; color: var(--muted); }

/* --------------------------------------------------------------- KPI ----- */
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 17px; box-shadow: var(--sh-1); position: relative; overflow: hidden;
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 23px; font-weight: 600; letter-spacing: -.02em; margin-top: 7px; line-height: 1.15; }
.kpi-value.sm { font-size: 19px; }
.kpi-meta { margin-top: 7px; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi-spark { position: absolute; right: 0; bottom: 0; opacity: .5; pointer-events: none; }
.kpi.accent { border-left: 3px solid var(--accent); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.flat { color: var(--muted); }
.delta svg { width: 11px; height: 11px; }

/* ------------------------------------------------------------ BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background .13s, border-color .13s, box-shadow .13s, opacity .13s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.btn.primary:hover { background: var(--navy-600); border-color: var(--navy-600); }
.btn.gold { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.gold:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--neg); border-color: #E9C4BF; background: #fff; }
.btn.danger:hover { background: var(--neg-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.sm svg { width: 13px; height: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn.icon.sm { width: 28px; }
.btn.block { width: 100%; }
.btn.lg { height: 40px; font-size: 14px; padding: 0 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.segmented { display: inline-flex; background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; gap: 2px; }
.segmented button {
  border: none; background: transparent; cursor: pointer; padding: 4px 11px;
  border-radius: var(--r-sm); font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: var(--sh-1); }

/* -------------------------------------------------------------- FORMS ---- */
.field { margin-bottom: 14px; }
.field > label, .lbl {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 5px; letter-spacing: .01em;
}
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field .err { font-size: 11.5px; color: var(--neg); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: #fff; font-size: 13.5px; transition: border-color .13s, box-shadow .13s;
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7A8C' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(30,55,82,.09);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.input.is-error, .select.is-error { border-color: var(--neg); }
.input.sm, .select.sm { height: 30px; font-size: 12.5px; padding: 0 9px; }
.select.sm { padding-right: 26px; }

.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13px; padding: 3px 0; }
.check input { width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--navy-700); cursor: pointer; flex: 0 0 auto; }
.check span { line-height: 1.45; }
.check.disabled { opacity: .55; cursor: not-allowed; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line-strong); border-radius: 20px; transition: .16s; cursor: pointer; }
.switch .track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .16s; box-shadow: var(--sh-1); }
.switch input:checked + .track { background: var(--pos); }
.switch input:checked + .track::before { transform: translateX(16px); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters .input, .filters .select { width: auto; min-width: 132px; }
.filters .search-wrap { position: relative; }
.filters .search-wrap .input { padding-left: 31px; min-width: 230px; }
.filters .search-wrap svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }

/* ------------------------------------------------------------- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
  letter-spacing: .015em; white-space: nowrap; line-height: 1.6;
  background: var(--surface-3); color: var(--ink-2); border: 1px solid transparent;
}
.badge.pos  { background: var(--pos-soft);  color: var(--pos); }
.badge.neg  { background: var(--neg-soft);  color: var(--neg); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.gold { background: var(--accent-soft); color: var(--accent); }
.badge.outline { background: #fff; border-color: var(--line-strong); color: var(--ink-2); font-weight: 500; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: var(--r-sm); font-size: 11.5px; background: var(--surface-3);
  color: var(--ink-2); border: 1px solid var(--line);
}
.tag button { border: none; background: none; cursor: pointer; color: var(--muted-2); padding: 0; display: flex; }
.tag button:hover { color: var(--neg); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  background: var(--navy-700); color: #fff;
}
.avatar.sm { width: 24px; height: 24px; font-size: 9.5px; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; }
.avatar.c1{background:#1E3752}.avatar.c2{background:#A8823C}.avatar.c3{background:#2A7F76}
.avatar.c4{background:#7A5C8E}.avatar.c5{background:#B2683C}.avatar.c6{background:#4A6E93}

/* ------------------------------------------------------------- TABLES ---- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
table.tbl th.sortable { cursor: pointer; user-select: none; }
table.tbl th.sortable:hover { color: var(--ink); }
table.tbl th .sort-ind { display: inline-block; width: 9px; margin-left: 3px; color: var(--accent); }
table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tr.group-row td { background: var(--surface-3); font-weight: 600; font-size: 12px; }
table.tbl tfoot td { padding: 10px 12px; border-top: 2px solid var(--line-strong); font-weight: 600; background: var(--surface-2); }
table.tbl.compact th { padding: 7px 10px; }
table.tbl.compact td { padding: 7px 10px; font-size: 12.5px; }
table.tbl .cell-main { font-weight: 500; }
table.tbl .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-cell .bar { flex: 1 1 auto; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; min-width: 40px; }
.bar-cell .bar > i { display: block; height: 100%; background: var(--navy-600); border-radius: 3px; }
.bar-cell .bar.gold > i { background: var(--accent); }
.bar-cell .v { font-variant-numeric: tabular-nums; font-size: 12px; min-width: 44px; text-align: right; }

.empty-state { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 12px; }
.empty-state h4 { font-size: 14px; color: var(--ink-2); margin-bottom: 5px; }
.empty-state p { font-size: 13px; max-width: 420px; margin: 0 auto; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 11px 16px; font-size: 12.5px; color: var(--muted); }

/* --------------------------------------------------------------- TABS ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: none; background: none; cursor: pointer; padding: 10px 15px;
  font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button .badge-count { margin-left: 6px; font-size: 10.5px; color: var(--muted-2); }

/* ----------------------------------------------------------- DEF LIST ---- */
.dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 0; font-size: 13px; }
.dl > dt { color: var(--muted); padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.dl > dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--line); text-align: right; font-weight: 500; }
.dl > dt:last-of-type, .dl > dd:last-of-type { border-bottom: none; }

/* ----------------------------------------------------------- TIMELINE ---- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-dot {
  position: absolute; left: -21px; top: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2px solid var(--navy-600);
}
.tl-dot.llamada{border-color:#2A5D8F} .tl-dot.reunion{border-color:#7A5C8E}
.tl-dot.whatsapp{border-color:#0E7B58} .tl-dot.email{border-color:#4A6E93}
.tl-dot.operacion{border-color:#A8823C} .tl-dot.seguimiento{border-color:#8C9AA8}
.tl-dot.preferencia{border-color:#B2683C} .tl-dot.importante{border-color:#B23A2E; background:#B23A2E}
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.tl-date { font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tl-author { font-size: 12px; color: var(--muted); }
.tl-body { font-size: 13.2px; color: var(--ink-2); line-height: 1.6; white-space: pre-wrap; }
.tl-actions { margin-left: auto; display: flex; gap: 3px; opacity: 0; transition: opacity .12s; }
.tl-item:hover .tl-actions { opacity: 1; }

/* -------------------------------------------------------------- MODAL ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,20,32,.46);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px 40px; z-index: 90; overflow-y: auto;
  animation: fadeIn .13s ease;
}
.modal {
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--sh-3);
  width: 100%; max-width: 560px; animation: slideUp .18s cubic-bezier(.2,.8,.3,1);
}
.modal.wide { max-width: 900px; }
.modal.xwide { max-width: 1180px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15.5px; }
.modal-head .modal-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 20px; max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

/* ------------------------------------------------------------- TOASTS ---- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 120; display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.toast {
  background: var(--navy-800); color: #fff; padding: 11px 15px; border-radius: var(--r);
  box-shadow: var(--sh-3); font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
  animation: slideUp .18s ease; border-left: 3px solid var(--accent);
}
.toast.ok  { border-left-color: var(--pos); }
.toast.err { border-left-color: var(--neg); }
.toast.warn{ border-left-color: var(--warn); }
.toast svg { flex: 0 0 auto; margin-top: 1px; }

/* ------------------------------------------------------------- CHARTS ---- */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 14px; }
.chart-legend .li { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.chart-legend .li .sw { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.chart-legend .li .lv { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 2px; }
.chart-legend .li.off { opacity: .4; }

/* --------------------------------------------------------- ALLOCATION ---- */
.alloc-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.alloc-bar > i { display: block; height: 100%; }
.alloc-list { margin-top: 13px; display: flex; flex-direction: column; gap: 9px; }
.alloc-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.alloc-row .sw { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.alloc-row .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-row .pc { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 46px; text-align: right; }
.alloc-row .vl { font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; font-weight: 500; }

/* ---------------------------------------------------------- PROGRESS ----- */
.steps { display: flex; align-items: center; gap: 0; margin-bottom: 22px; }
.step { display: flex; align-items: center; gap: 9px; flex: 1 1 auto; }
.step .sn {
  width: 25px; height: 25px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 600; border: 1.5px solid var(--line-strong);
  color: var(--muted); background: #fff;
}
.step .st { font-size: 12.5px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.step .sl { flex: 1 1 auto; height: 1.5px; background: var(--line); margin: 0 12px; min-width: 16px; }
.step.done .sn { background: var(--pos); border-color: var(--pos); color: #fff; }
.step.done .st { color: var(--ink-2); }
.step.active .sn { border-color: var(--navy-700); color: var(--navy-700); background: #fff; box-shadow: 0 0 0 3px rgba(30,55,82,.1); }
.step.active .st { color: var(--ink); font-weight: 600; }

.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--r-lg);
  padding: 44px 24px; text-align: center; background: var(--surface-2);
  cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 12px; }
.dropzone h4 { font-size: 14.5px; margin-bottom: 5px; }
.dropzone p { font-size: 12.5px; color: var(--muted); margin: 0; }

.progress { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--navy-600); border-radius: 4px; transition: width .25s; }

.notice {
  padding: 11px 14px; border-radius: var(--r); font-size: 12.8px; line-height: 1.55;
  border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start;
}
.notice svg { flex: 0 0 auto; margin-top: 1px; }
.notice.info { background: var(--info-soft); border-color: #CFE0EE; color: #1D4A72; }
.notice.warn { background: var(--warn-soft); border-color: #EEDCB8; color: #7C5512; }
.notice.err  { background: var(--neg-soft);  border-color: #EFCBC6; color: #8A2C22; }
.notice.ok   { background: var(--pos-soft);  border-color: #C4E4D7; color: #0A5B41; }

.perm-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.perm-grid th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; }
.perm-grid td, .perm-grid th { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.perm-grid td.c, .perm-grid th.c { text-align: center; width: 92px; }
.perm-grid .pg-sec td { background: var(--surface-3); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* --------------------------------------------------------- CONTRASEÑAS -- */
.pwd-row { display: flex; gap: 6px; align-items: stretch; }
.pwd-row .input { flex: 1 1 auto; min-width: 0; }
.pwd-row .btn { flex: 0 0 auto; height: 36px; }

.pwd-meter { display: flex; gap: 4px; margin-top: 7px; }
.pwd-meter > i {
  flex: 1 1 0; height: 4px; border-radius: 3px; background: var(--line);
  transition: background .18s;
}
.pwd-meter.s1 > i.on { background: #B23A2E; }
.pwd-meter.s2 > i.on { background: #C87F2B; }
.pwd-meter.s3 > i.on { background: #A8823C; }
.pwd-meter.s4 > i.on { background: #0E7B58; }

.pwd-info { margin-top: 5px; font-size: 11.5px; min-height: 16px; line-height: 1.45; }
.pwd-info .err { color: var(--neg); }
.pwd-info .hint { color: var(--muted); }
.pwd-info .ok-txt { color: var(--pos); font-weight: 600; }

.cred-list { display: flex; flex-direction: column; gap: 7px; }
.cred-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2);
}
.cred-code {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .02em;
  background: #fff; border: 1px solid var(--line-strong);
  padding: 4px 9px; border-radius: var(--r-sm); user-select: all; white-space: nowrap;
}

/* --------------------------------------------------------------- SETUP -- */
.setup-card { width: 100%; max-width: 430px; }
.setup-card h1 { font-size: 21px; margin-bottom: 6px; }
.setup-card > p.sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; line-height: 1.6; }
.setup-steps { display: flex; gap: 6px; margin-bottom: 24px; }
.setup-steps > i { flex: 1 1 0; height: 3px; border-radius: 3px; background: var(--line); }
.setup-steps > i.on { background: var(--accent); }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, #E9EDF3 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: var(--line-strong); border-top-color: var(--navy-700); }
@keyframes spin { to { transform: rotate(360deg) } }
