/* ============================================================
   K-RANK — Design System v6  (WhatsApp-inspired)
   ============================================================ */

/* ── 1. TOKENS ─────────────────────────────────────────────── */
:root {
  /* vertical theme — overridden by JS via body.theme-* */
  --vAccent:      #111827;
  --vAccentDeep:  #000000;
  --vAccentLight: #f3f4f6;
  --vTint1:       rgba(17,24,39,.10);
  --vTint2:       rgba(17,24,39,.05);
  --vGlow1:       rgba(0,0,0,.0);
  --vGlow2:       rgba(0,0,0,.0);

  /* WhatsApp palette */
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --surface-2: #f7f8fa;
  --border:    #e9edef;
  --border-2:  #d1d7db;

  --text:      #111b21;
  --text-2:    #3b4a54;
  --text-muted:#54656f;
  --text-xs:   #8696a0;

  /* fixed action colors */
  --blue:    #0078d4;
  --blue-dk: #005ea2;
  --green:   #25d366;
  --green-dk:#128c7e;
  --amber:   #d97706;
  --red:     #dc2626;
  --slate:   #54656f;

  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-full: 999px;

  --sh-sm:  0 1px 3px rgba(0,0,0,.08);
  --sh-md:  0 2px 8px rgba(0,0,0,.10);
  --sh-lg:  0 6px 20px rgba(0,0,0,.12);
  --sh-xl:  0 16px 40px rgba(0,0,0,.16);
  --sh-btn: 0 2px 8px rgba(0,0,0,.15);

  --sysTop:    0px;
  --sysBottom: 0px;
}

/* vertical themes */
body.theme-all       { --vAccent:#111827; --vAccentDeep:#000;    --vAccentLight:#f3f4f6; --vTint1:rgba(17,24,39,.10);  --vTint2:rgba(17,24,39,.05); }
body.theme-reformas  { --vAccent:#b45309; --vAccentDeep:#92400e; --vAccentLight:#fef3c7; --vTint1:rgba(180,83,9,.12);  --vTint2:rgba(180,83,9,.06); }
body.theme-tapiceria { --vAccent:#6d28d9; --vAccentDeep:#4c1d95; --vAccentLight:#ede9fe; --vTint1:rgba(109,40,217,.12); --vTint2:rgba(109,40,217,.06); }
body.theme-pergolas  { --vAccent:#128c7e; --vAccentDeep:#075e54; --vAccentLight:#dcfce7; --vTint1:rgba(18,140,126,.12); --vTint2:rgba(18,140,126,.06); }

/* ── 2. RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  margin: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
main { flex: 1 0 auto; }

/* ── 3. LAYOUT ─────────────────────────────────────────────── */
main {
  width: 100%;
  margin: 0;
  padding: 16px 20px 28px;
  display: grid;
  gap: 12px;
}
@media (min-width: 1200px) { main { padding: 20px 28px 32px; gap: 14px; } }

/* ── 4. TYPOGRAPHY ─────────────────────────────────────────── */
.muted  { color: var(--text-muted); font-size: 14px; }
.small  { font-size: 12px; }
.row    { display: grid; gap: 10px; }
.hr     { height: 1px; background: var(--border); margin: 10px 0; }

/* ── 5. HEADER ─────────────────────────────────────────────── */
header {
  background: var(--vAccentDeep);
  color: #fff;
  padding: calc(16px + env(safe-area-inset-top,0px) + var(--sysTop)) 20px 16px;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}

body.noSession header { box-shadow: none; }

.brand      { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img  { height: 48px; width: auto; border-radius: 8px; object-fit: contain; display: block; }
.brandText  { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brandTitle { font-weight: 700; font-size: 20px; line-height: 1.1; white-space: nowrap; letter-spacing: -.01em; }
.brandSub   { color: rgba(255,255,255,.6); font-size: 12px; }
.brandEmail { color: rgba(255,255,255,.7); font-size: 11px; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: none; }

.headerRight  { margin-left: auto; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.hdrTopLine   { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.hdrStatusLine{ color: rgba(255,255,255,.5); font-size: 11px; }

.pill {
  display: inline-block; padding: 3px 10px;
  border-radius: var(--r-full);
  background: rgba(255,255,255,.15);
  font-size: 12px; color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.2);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logoutBtn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: var(--r-full);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  color: rgba(255,255,255,.9);
  cursor: pointer; font-weight: 600; font-size: 12px;
  width: auto !important; white-space: nowrap; transition: background .1s;
}
.logoutBtn:hover { background: rgba(255,255,255,.2); }
.logoutTxt { display: inline; }
.logoutX   { display: none; font-size: 14px; }
.notifBtn  { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: var(--r-sm); color: #fff; font-size: 14px; padding: 4px 8px; cursor: pointer; width: auto !important; }
.notifBtn:hover { background: rgba(255,255,255,.2); }

@media (min-width: 900px)  { header { min-height: 80px; padding: 18px 24px; } .brand img { height: 54px; } .brandTitle { font-size: 22px; } }
@media (max-width: 720px)  {
  header { padding: calc(12px + env(safe-area-inset-top,0px) + var(--sysTop)) 14px 12px; min-height: 60px; }
  .brand img { height: 40px; }
  .brandTitle { font-size: 17px; }
  .hdrStatusLine { display: none; }
  #hdrWho { display: none !important; }
  #hdrWhoInline { display: block !important; }
  #hdrRole { display: inline-block !important; }
  #brandRole { display: none; }
}

/* ── 6. TOP VERTICAL BAR ───────────────────────────────────── */
.topVerticalBar {
  background: var(--vAccentDeep);
  border-bottom: 3px solid var(--vAccent);
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topVerticalInner {
  width: 100%; max-width: 1400px; margin: 0 auto;
  padding: 10px 18px 12px;
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px;
}
.vTopBtn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px 8px;
  border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.7);
  font-weight: 600; font-size: 13px; cursor: pointer; user-select: none;
  transition: all .12s;
}
.vTopBtn svg  { width: 16px; height: 16px; flex: 0 0 auto; }
.vTopBtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vTopBtn:hover  { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.vTopBtn.isActive {
  background: var(--vAccent);
  border-color: var(--vAccent);
  color: #fff; font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
}
.vTopBtn:active { transform: scale(.98); }

@media (max-width: 900px)  { .topVerticalInner { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 340px)  { .topVerticalInner { grid-template-columns: 1fr; } }

/* ── 7. CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--sh-sm);
}
.card + .card { margin-top: 12px; }

/* ── 8. INPUTS ─────────────────────────────────────────────── */
input, select, textarea {
  width: 100%; padding: 10px 13px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  font-size: 14px; font-family: inherit;
  color: var(--text); background: var(--surface-2);
  box-sizing: border-box;
  transition: border-color .12s, box-shadow .12s;
  appearance: auto;
}
input:focus, select:focus, textarea:focus {
  outline: none; background: var(--surface);
  border-color: var(--vAccent);
  box-shadow: 0 0 0 3px var(--vTint1);
}
input::placeholder { color: var(--text-xs); }
textarea { min-height: 82px; resize: vertical; }
select, option { color: var(--text); }

.cellInp { padding: 6px 9px; border-radius: 8px; font-size: 13px; background: var(--surface-2); }
select.cellInp { min-width: 108px; }

/* ── 9. BUTTONS ─────────────────────────────────────────────── */
main button {
  width: 100%; padding: 12px;
  border-radius: var(--r-md); border: none;
  font-size: 14px; font-family: inherit; font-weight: 700;
  cursor: pointer; box-sizing: border-box;
  transition: filter .12s, opacity .12s;
}
button { background: var(--text); color: #fff; border: none; font-weight: 700; cursor: pointer; }
button:hover  { opacity: .88; }
button:active { transform: scale(.98); }

button.secondary {
  background: var(--surface-2); color: var(--text-2);
  border: 1.5px solid var(--border-2); box-shadow: var(--sh-sm);
}
button.secondary:hover { background: #eceff2; }
button.small { padding: 7px 12px; font-size: 12px; border-radius: var(--r-sm); }

.dangerBtn         { background: var(--red) !important; color: #fff !important; border: none !important; }
.dangerBtn:hover   { opacity: .9; }

.btnPrimary, .btnMain, button.primary {
  background: var(--blue) !important; color: #fff !important;
  border: none !important; box-shadow: var(--sh-btn) !important;
}
.btnPrimary:hover, .btnMain:hover, button.primary:hover { opacity: .9; }

.btnGhost { background: var(--vTint2) !important; color: var(--vAccentDeep) !important; border: 1.5px solid var(--vTint1) !important; box-shadow: none !important; }
.btnGhost:hover { background: var(--vTint1) !important; }

.btn { display: inline-flex; align-items: center; gap: 6px; width: auto !important; padding: 8px 16px; border-radius: var(--r-md); font-size: 13px; font-weight: 600; cursor: pointer; }

#btnToggleCreateLead { background: var(--blue) !important; color: #fff !important; border: none !important; box-shadow: var(--sh-btn) !important; }
#btnToggleCreateLead.is-open { background: #8696a0 !important; color: #fff !important; box-shadow: none !important; }

.btnWhatsApp { background: var(--green) !important; color: #fff !important; border: none !important; }

/* force auto width */
.actionsCell button, .actionsCell a,
.bulkBar button, .bulkBar .secondary,
.topActions button, .topActions a,
#exportJobsWrap button,
.logoutBtn, .notifBtn, .btn, .btnMini, [data-act] { width: auto !important; }

/* micro buttons */
.btnMini {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 10px; height: 32px; border-radius: var(--r-sm);
  border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text);
  text-decoration: none; font-weight: 600; font-size: 12px;
  cursor: pointer; white-space: nowrap; box-shadow: var(--sh-sm);
  width: auto !important;
}
.btnMini:hover { background: #eceff2; }
.btnMini.iconOnly {
  padding: 0 !important;
  width: 32px !important;
  height: 30px !important;
  justify-content: center;
  border: none !important;
  box-shadow: 0 2px 5px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.12);
}
.btnMini.iconOnly:hover {
  opacity: 1;
  box-shadow: 0 3px 8px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.15);
}
.btnMini.iconOnly:active {
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transform: translateY(1px);
}
.btnMini.iconOnly svg { width: 16px; height: 16px; fill: currentColor; }
.btnMini.btnCall { background: var(--blue);  color: #fff; }
.btnMini.btnWa   { background: var(--green); color: #fff; }
.btnMini.btnMail { background: var(--slate); color: #fff; }
.btnCall { background: var(--blue); color: #fff; }
.btnWa   { background: var(--green); color: #fff; }

.photoLink { display: inline-flex; align-items: center; gap: 4px; padding: 0 9px; height: 32px; border-radius: 7px; background: var(--slate); color: #fff; text-decoration: none; font-weight: 700; font-size: 12px; white-space: nowrap; position: relative; width: auto !important; }
.photoBadge { position: absolute; top: -5px; right: -5px; display: inline-flex; align-items: center; justify-content: center; background: #ef4444; color: #fff; font-size: 9px; font-weight: 700; min-width: 15px; height: 15px; border-radius: 8px; padding: 0 3px; border: 1.5px solid #fff; pointer-events: none; }
.photoLink:hover { opacity: .88; }
.btnMini.addPhotosBtn { padding: 5px 8px; }

.btn-link      { background: none; border: none; padding: 0; cursor: pointer; font-size: 13px; color: inherit; text-decoration: underline; opacity: .6; }
.btn-link:hover{ opacity: 1; }
.btn-secondary { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 13px; font-weight: 600; cursor: pointer; }
.btn-secondary:hover { background: #eceff2; }
.btn-toggle    { padding: 5px 12px; border-radius: var(--r-full); }
.btnDanger     { background: #fff; border: 1.5px solid var(--red); color: var(--red); border-radius: var(--r-sm); padding: 7px 13px; font-weight: 600; cursor: pointer; }
.btnDanger:hover { background: #fff5f5; }

/* ── 10. BADGES ─────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: var(--r-full); background: #e9edef; font-size: 12px; font-weight: 600; color: var(--text-2); }

.stBadge {
  display: inline-flex; align-items: center;
  padding: 4px 11px; border-radius: var(--r-full);
  font-weight: 700; font-size: 12px; border: 1px solid transparent;
  white-space: nowrap;
}
.st-assigned        { background: #e8f4fd; color: #0c5fa5; border-color: #acd4f0; }
.st-pending         { background: #f5f3ff; color: #6b21a8; border-color: #c4b5fd; }
.st-picked_up       { background: #fff0e6; color: #c2410c; border-color: #fb923c; }
.st-delivered       { background: #fefce8; color: #854d0e; border-color: #fde047; }
.st-commission_paid { background: #f0fdf4; color: #166534; border-color: #86efac; }
.st-cancelled       { background: #fff0f0; color: #9b1c1c; border-color: #fca5a5; }
select.stSel option[value="assigned"]        { color: #0c5fa5; background: #e8f4fd; }
select.stSel option[value="pending"]         { color: #6b21a8; background: #f5f3ff; }
select.stSel option[value="picked_up"]       { color: #c2410c; background: #fff0e6; }
select.stSel option[value="delivered"]       { color: #854d0e; background: #fefce8; }
select.stSel option[value="commission_paid"] { color: #166534; background: #f0fdf4; }
select.stSel option[value="cancelled"]       { color: #9b1c1c; background: #fff0f0; }

select.ctSel, select.pCtSel { min-width: 58px; }
input.cvInp, input.pCvInp   { max-width: 78px; }

.roleTag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; background: #e8f4fd; border: 1px solid #acd4f0; color: #0c5fa5; }
.roleTag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }

.status-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; border: 1px solid rgba(0,0,0,.10); }
.status-pill.active   { background: #111b21; color: #fff; }
.status-pill.inactive { background: #e9edef; color: var(--text-2); }

/* ── 11. GRIDS ──────────────────────────────────────────────── */
.grid2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 700px)  { .grid2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 860px)  { .grid3 { grid-template-columns: 1fr 1fr 1fr; } }
@media (min-width: 1100px) { .grid4 { grid-template-columns: 1fr 1fr 1fr 1fr; } }

/* ── 12. SECTION ACCORDIONS ─────────────────────────────────── */
details.acc {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
details.acc + details.acc { margin-top: 10px; }

details.acc > summary {
  list-style: none; cursor: pointer;
  padding: 14px 18px;
  font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  color: var(--text);
  background: var(--surface);
  border-left: 4px solid var(--vAccent);
  user-select: none; transition: background .1s;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "▾"; font-size: 12px; opacity: .5; }
details.acc[open] > summary::after { content: "▴"; }
details.acc[open] > summary { background: var(--surface-2); border-bottom: 1px solid var(--border); }
details.acc > summary:hover { background: #f7f8fa; }
details.acc .accBody { padding: 16px 18px; }

@media (max-width: 720px) {
  details.acc { border-radius: 12px; }
  details.acc > summary { padding: 12px 14px 12px 12px; font-size: 13px; border-left-width: 3px; }
  details.acc .accBody { padding: 12px 14px; }
}

/* ── 13. KPI CARDS ──────────────────────────────────────────── */
#dash .grid3 { display: grid !important; grid-template-columns: repeat(3,1fr) !important; gap: 12px !important; }
@media (max-width: 720px) { #dash .grid3 { grid-template-columns: 1fr !important; } }

#dash .grid3 > .card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  padding: 20px 18px 16px !important;
  box-shadow: var(--sh-sm) !important;
  border-left: 4px solid var(--vAccent) !important;
  position: relative;
}
#dash .grid3 > .card::before { display: none !important; }
#dash .grid3 > .card .muted:first-child {
  font-size: 11px !important; font-weight: 700 !important;
  text-transform: uppercase !important; letter-spacing: .07em !important;
  color: var(--text-xs) !important; margin-bottom: 8px !important;
}
#dash .grid3 > .card #kpiJobs,
#dash .grid3 > .card #kpiBilled,
#dash .grid3 > .card #kpiComm {
  font-size: 32px !important; font-weight: 700 !important;
  color: var(--text) !important; line-height: 1 !important;
  letter-spacing: -.02em !important; margin-bottom: 6px !important;
}
#dash .grid3 > .card .muted.small { font-size: 12px !important; color: var(--text-xs) !important; }

/* ── 14. CHARTS ─────────────────────────────────────────────── */
canvas { width: 100%; height: 240px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }

/* ── 15. TABLE (DESKTOP) ────────────────────────────────────── */
.tableWrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface);
}
table { width: 100%; min-width: 1380px; border-collapse: collapse; background: var(--surface); }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; vertical-align: top; white-space: nowrap; }
th { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); position: sticky; top: 0; z-index: 2; border-bottom: 2px solid var(--border-2); }
td.wrap, th.wrap { white-space: normal; }
.right { text-align: right; }

tbody tr { transition: background .1s; }
tbody tr:hover { background: #f5f6f6; }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--vAccent); }
tbody tr:last-child td { border-bottom: none; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #eceff2; color: var(--text-2); }
.sortMark { font-size: 11px; color: #8696a0; margin-left: 4px; }

.chkCell  { width: 40px; }
td.chkCell, th.chkCell { text-align: center; vertical-align: middle; }
.chk { width: 16px; height: 16px; }
.colVal     { width: 68px; }
.colImporte { width: 120px; }
.colTipo    { width: 50px; }
.cellSelectSmall { min-width: 0; width: 100%; box-sizing: border-box; }
input.aDateInp[type="date"] { min-width: 110px; width: 100%; box-sizing: border-box; padding: 2px 4px; }
.colComm    { width: 78px; }
.colPhotos  { width: 1%; white-space: nowrap; }
.colActions { width: 1%; white-space: nowrap; }
.colProvider  { max-width: 200px; }
.colProvincia { width: 70px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.colChat { width: 44px; text-align: center; }
.btnMini.btnChat { background: #111827; color: #fff; position: relative; }
.btnMini.btnChat:hover { background: #1f2937; }

.chatBadge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 8px;
  padding: 0 3px;
  border: 1.5px solid #fff;
  pointer-events: none;
}
.cellSmall    { max-width: 130px; }

@media (min-width: 980px) {
  #adminPanel .tableWrap table { table-layout: fixed; }
  #adminPanel .tableWrap table thead th:nth-child(3),
  #adminPanel .tableWrap table tbody td:nth-child(3) { width:145px; max-width:145px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  #adminPanel .tableWrap table thead th:nth-child(4),
  #adminPanel .tableWrap table tbody td:nth-child(4) { width:220px; max-width:220px; white-space:normal; word-break:break-word; }
}

@media (min-width: 721px) {
  #jobsPanel .tableWrap table { table-layout: fixed !important; width: 100% !important; min-width: 1500px !important; }
  #jobsPanel th { overflow: hidden !important; white-space: normal !important; word-break: break-word !important; }
  #jobsPanel td { overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; }
  #jobsPanel th:nth-child(1),  #jobsPanel td:nth-child(1)  { width: 32px !important; }
  #jobsPanel th:nth-child(2),  #jobsPanel td:nth-child(2)  { width: 130px !important; overflow: visible !important; }
  #jobsPanel th:nth-child(3),  #jobsPanel td:nth-child(3)  { width: 110px !important; white-space: normal !important; word-break: break-word !important; }
  #jobsPanel th:nth-child(4),  #jobsPanel td:nth-child(4)  { width: 80px !important; }
  #jobsPanel th:nth-child(5),  #jobsPanel td:nth-child(5)  { width: 75px !important; overflow: visible !important; }
  #jobsPanel th:nth-child(6),  #jobsPanel td:nth-child(6)  { width: 65px !important; }
  #jobsPanel th:nth-child(7),  #jobsPanel td:nth-child(7)  { width: 60px !important; }
  #jobsPanel th:nth-child(8),  #jobsPanel td:nth-child(8)  { width: 95px !important; overflow: visible !important; }
  #jobsPanel th:nth-child(9),  #jobsPanel td:nth-child(9)  { width: 145px !important; white-space: normal !important; word-break: break-word !important; }
  #jobsPanel th:nth-child(10), #jobsPanel td:nth-child(10) { width: 110px !important; }
  #jobsPanel th:nth-child(11), #jobsPanel td:nth-child(11) { width: 85px !important; }
  #jobsPanel th:nth-child(12), #jobsPanel td:nth-child(12) { width: 58px !important; }
  #jobsPanel th:nth-child(13), #jobsPanel td:nth-child(13) { width: 85px !important; }
  #jobsPanel th:nth-child(14), #jobsPanel td:nth-child(14) { width: 70px !important; }
  #jobsPanel th:nth-child(15), #jobsPanel td:nth-child(15) { width: 36px !important; }
  #jobsPanel th:nth-child(16), #jobsPanel td:nth-child(16) { width: 85px !important; overflow: visible !important; }
  #jobsPanel th:nth-child(17), #jobsPanel td:nth-child(17) { width: 150px !important; overflow: visible !important; }
}

@media (max-width: 1099px) {
  #providerPanel .tableWrap thead { display: none; }
}
@media (min-width: 1100px) {
  #providerPanel .tableWrap { overflow-x: hidden !important; }
  #providerPanel .tableWrap table { table-layout: fixed; width: 100% !important; min-width: unset !important; }
  #providerPanel th, #providerPanel td { text-align: left; overflow: hidden; }
  #providerPanel th:nth-child(1),  #providerPanel td:nth-child(1)  { width: 11%; }
  #providerPanel th:nth-child(2),  #providerPanel td:nth-child(2)  { width: 9%; }
  #providerPanel th:nth-child(3),  #providerPanel td:nth-child(3)  { width: 9%; overflow: visible; }
  #providerPanel td:nth-child(3) .row { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 4px; }
  #providerPanel th:nth-child(4),  #providerPanel td:nth-child(4)  { width: 7%; }
  #providerPanel th:nth-child(5),  #providerPanel td:nth-child(5)  { width: 5%; }
  #providerPanel th:nth-child(6),  #providerPanel td:nth-child(6)  { width: 7%; }
  #providerPanel th:nth-child(7),  #providerPanel td:nth-child(7)  { width: 25%; white-space: normal; }
  #providerPanel th:nth-child(8),  #providerPanel td:nth-child(8)  { width: 8%; }
  #providerPanel th:nth-child(9),  #providerPanel td:nth-child(9)  { width: 6%; }
  #providerPanel th:nth-child(10), #providerPanel td:nth-child(10) { width: 6%; }
  #providerPanel th:nth-child(11), #providerPanel td:nth-child(11) { width: 6%; }
  #providerPanel th:nth-child(12), #providerPanel td:nth-child(12) { width: 5%; }
  #providerPanel th:nth-child(13), #providerPanel td:nth-child(13) { width: 3%; }
  #providerPanel th:nth-child(14), #providerPanel td:nth-child(14) { width: 5%; overflow: visible; }
  #providerPanel td:nth-child(14) .photoLink { width: auto; }
  #providerPanel th:nth-child(15), #providerPanel td:nth-child(15) { width: 7%; }
  #providerPanel td input, #providerPanel td select { width: 100%; min-width: 0; box-sizing: border-box; }
  #providerPanel button.pSaveRowBtn { padding: 0 8px; width: auto; height: 32px; }
  #providerPanel td:nth-child(7) textarea { width: 100%; min-width: 0; box-sizing: border-box; min-height: unset; height: auto; resize: vertical; overflow: auto; }
}
.pNotesTa { min-width: 220px; width: 100%; min-height: 44px; resize: vertical; }

.actionsCell { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }
.actionsCell button, .actionsCell a { padding: 6px 9px; font-size: 12px; border-radius: 7px; line-height: 1.1; white-space: nowrap; }
.actionsCell .dangerBtn { padding: 6px 9px; }
.contactActions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.bulkBar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulkBar .muted { margin-left: auto; }

/* ── 16. MOBILE ACCORDION (≤720px) ─────────────────────────── */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  main {
    padding: 10px 10px 18px !important;
    display: flex; flex-direction: column; align-items: center;
  }
  main { padding-bottom: calc(18px + env(safe-area-inset-bottom,0px) + var(--sysBottom)) !important; }
  main > * { width: 100% !important; max-width: 680px !important; margin-left: auto !important; margin-right: auto !important; }
  #dash.card { background: transparent; border: none; box-shadow: none; padding: 0; }

  .tableWrap { border: 0; border-radius: 0; overflow: visible; }
  table { min-width: 0 !important; width: 100%; }
  thead { display: none; }
  tbody, tr, td { display: block; width: 100%; }

  tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 8px 0; overflow: hidden;
    box-shadow: var(--sh-sm);
  }
  tbody td.cardCell { padding: 0; border: 0; }
  tbody td.cardCell::before { content: none !important; }

  .accHeader {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 13px; cursor: pointer; user-select: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    border-left: 3px solid var(--vAccent);
  }
  /* Status colors for provider cards — colored border on whole card */
  #jobsProvTbody tr.st-pending,
  #jobsAdminTbody tr.st-pending         { border-color:#6b21a8; }
  #jobsProvTbody tr.st-assigned,
  #jobsAdminTbody tr.st-assigned        { border-color:#1e3a8a; }
  #jobsProvTbody tr.st-picked_up,
  #jobsAdminTbody tr.st-picked_up       { border-color:#c2410c; }
  #jobsProvTbody tr.st-delivered,
  #jobsAdminTbody tr.st-delivered       { border-color:#854d0e; }
  #jobsProvTbody tr.st-commission_paid,
  #jobsAdminTbody tr.st-commission_paid { border-color:#166534; }
  #jobsProvTbody tr.st-cancelled,
  #jobsAdminTbody tr.st-cancelled       { border-color:#b42318; }

  .accHeader.st-pending         { background:#f5f3ff; border-left-color:#6b21a8; }
  .accHeader.st-assigned        { background:#eff6ff; border-left-color:#1e3a8a; }
  .accHeader.st-picked_up       { background:#fff7ed; border-left-color:#c2410c; }
  .accHeader.st-delivered       { background:#fefce8; border-left-color:#854d0e; }
  .accHeader.st-commission_paid { background:#f0fdf4; border-left-color:#166534; }
  .accHeader.st-cancelled       { background:#fef2f2; border-left-color:#b42318; }

  .accHeader .left { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
  .accTitle { font-weight: 700; font-size: 14px; line-height: 1.2; color: var(--text); white-space: normal; overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
  .accSub   { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: var(--text-muted); font-size: 12px; min-width: 0; }
  .accHeader .right { display: flex; align-items: center; gap: 6px; }
  .accChevron {
    width: 30px; height: 30px; min-width: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface-2); font-weight: 700; color: var(--text-muted);
    transition: transform .15s, background .12s, color .12s; flex: 0 0 auto;
  }
  .accDetails { display: none; padding: 12px 13px; background: var(--surface-2); }
  tr.isOpen .accDetails { display: block; }
  tr.isOpen .accChevron { transform: rotate(180deg); background: var(--vAccent); color: #fff; border-color: var(--vAccent); }
  tr.isOpen .accHeader  { border-left-color: var(--vAccent); background: var(--vTint2); }

  .accGrid  { display: grid; gap: 10px; }
  .accRow   { border-bottom: 1px solid var(--border); padding-bottom: 9px; }
  .accRow:last-child { border-bottom: 0; padding-bottom: 0; }
  .accLabel { font-size: 10px; font-weight: 700; color: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
  .accVal   { font-size: 14px; color: var(--text); overflow-wrap: anywhere; word-break: break-word; white-space: normal; max-width: 100%; }
  .accVal * { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .accActions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; padding-top: 7px; }
  .accActions button, .accActions a { width: auto !important; }
  .accChk { width: 16px; height: 16px; border-radius: 4px; }
  .accGrid, .accRow, .accVal, .accSub, .accTitle, .accHeader .left { min-width: 0; }
}

/* ── 17. MODAL ──────────────────────────────────────────────── */
.modalBackdrop {
  position: fixed; inset: 0;
  background: rgba(17,27,33,.55);
  display: none; align-items: center; justify-content: center;
  padding: 16px; z-index: 9999; backdrop-filter: blur(2px);
}
.modal { width: min(980px,100%); background: var(--surface); border-radius: var(--r-xl); padding: 20px; box-shadow: var(--sh-xl); border: 1px solid var(--border); max-height: 90vh; overflow-y: auto; overflow-x: hidden; }
.modalHeader { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modalHeader h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modalClose { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 13px; cursor: pointer; font-weight: 600; font-size: 13px; width: auto !important; }
.modalClose:hover { background: #eceff2; }

/* ── 18. GALLERY ─────────────────────────────────────────────── */
.galleryGrid { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
@media (min-width: 640px) { .galleryGrid { grid-template-columns: repeat(3,1fr); } }
@media (min-width: 900px) { .galleryGrid { grid-template-columns: repeat(4,1fr); } }
.thumb { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); cursor: pointer; transition: box-shadow .12s; }
.thumb:hover { box-shadow: var(--sh-md); }
.thumb img { width: 100%; height: 136px; object-fit: cover; display: block; }
.thumb .cap { padding: 7px 9px; font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; gap: 7px; align-items: center; }
.thumb .cap a { color: var(--blue); text-decoration: underline; }

/* ── 19. USERS ──────────────────────────────────────────────── */
.usersGroupTitle { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 9px 13px; border-radius: var(--r-md); background: var(--surface-2); border-left: 3px solid var(--vAccent); font-weight: 700; color: var(--text-2); font-size: 13px; }
.userCardCompact { padding: 10px !important; }
.userCardCompact .grid4 { gap: 10px !important; }

/* ── 20. TOP ACTIONS ─────────────────────────────────────────── */
.topActions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#adminPanel .topActions { margin: 6px 0 10px; }

/* ── 21. PROV STAT CARDS ─────────────────────────────────────── */
.provStatCard {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.provStatSummary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.provStatSummary::-webkit-details-marker { display: none; }
.provStatSummary::after { content: "⌄"; font-size: 14px; color: var(--text-muted); transition: transform .15s; }
.provStatCard[open] > .provStatSummary::after { transform: rotate(180deg); }
.provStatName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provStatBadge {
  font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 8px; white-space: nowrap; flex-shrink: 0;
}
.provStatBody { padding: 4px 14px 10px; border-top: 1px solid var(--border); background: var(--surface-2); }
.provStatRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.provStatRow:last-child { border-bottom: none; }
.provStatRow span { color: var(--text-muted); }
.provStatRow strong { color: var(--text); font-weight: 600; }

/* ── 23. FOOTER ─────────────────────────────────────────────── */
.appFooter {
  background: var(--vAccentDeep);
  color: #fff;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom,0px) + var(--sysBottom));
  border-top: 2px solid var(--vAccent);
}
.appFooterInner { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.footerLogo { display: inline-flex; align-items: center; gap: 8px; }
.footerLogo img { height: 42px; width: auto; display: block; border-radius: 7px; object-fit: contain; }
.footerStatus { display: flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-full); border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); font-size: 12px; white-space: nowrap; }
.footerStatusDot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.3); }
.footerStatusDot.is-ok   { background: #25d366; }
.footerStatusDot.is-bad  { background: #ef4444; }
.footerStatusDot.is-warn { background: #f59e0b; }
.footerNote { font-size: 12px; opacity: .55; white-space: nowrap; }
@media (max-width: 640px) { .appFooterInner { flex-direction: column; align-items: center; } .footerNote { display: none; } .footerLogo img { height: 36px; } }

/* ── 22. LOGIN PAGE ─────────────────────────────────────────── */
html.noSession, body.noSession { height: 100%; overflow: hidden !important; }
body.noSession {
  background: #000 !important; color: #fff;
  position: fixed; inset: 0; width: 100%; overscroll-behavior: none;
}
body.noSession .topVerticalBar, body.noSession .appFooter { display: none !important; }
body.noSession header { box-shadow: none; border-bottom: none !important; }
body.noSession main {
  padding: 0 !important; background: #000 !important;
  height: calc(100dvh - var(--hdrH,60px)); overflow: hidden !important;
  display: flex !important; flex-direction: column !important;
  align-items: center !important; justify-content: center !important;
}
body.noSession #loginCard {
  background: transparent !important; border: none !important; box-shadow: none !important;
  margin: 0 !important; width: min(340px,calc(100% - 40px)) !important;
  padding: 0 !important; display: flex !important; flex-direction: column !important;
  align-items: center !important; transform: translateY(-8px); padding-bottom: 14px !important;
}
body.noSession #loginMark {
  width: min(86vw,480px); max-width: 480px; height: auto;
  display: block; margin: 0 0 8px; opacity: .96;
  animation: markFloat 5s ease-in-out infinite;
}
@keyframes markFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
body.noSession #loginCard .grid2 { width:100%!important; display:flex!important; flex-direction:column!important; gap:12px!important; }
body.noSession #loginCard input,
body.noSession #loginBtn { width:100%!important; max-width:100%; border-radius:12px!important; }
body.noSession #loginCard input { background:rgba(255,255,255,.08)!important; border:1.5px solid rgba(255,255,255,.5)!important; color:#fff!important; height:50px; padding:0 14px; }
body.noSession #loginCard input::placeholder { color:rgba(255,255,255,.6)!important; opacity:1!important; }
body.noSession #loginCard input:focus { border-color:rgba(255,255,255,.85)!important; box-shadow:0 0 0 3px rgba(255,255,255,.10)!important; }
body.noSession #loginBtn { height:50px; background:rgba(255,255,255,.08)!important; border:1.5px solid rgba(255,255,255,.55)!important; color:#fff!important; font-weight:700; margin-top:2px; box-shadow:none!important; }
body.noSession #loginBtn:active { transform:scale(.99); }
body.noSession #status { margin-top:6px; color:rgba(255,255,255,.5)!important; font-size:12px; text-align:center; }
body.noSession #forgotBtn { color:rgba(255,255,255,.6); width:100%; text-align:center; margin-top:4px; }
@media (max-height:680px) {
  body.noSession #loginMark { width:min(78vw,380px); }
  body.noSession #loginCard input, body.noSession #loginBtn { height:46px; }
}

/* ── 23. VERTICAL CHIPS ─────────────────────────────────────── */
.vChips  { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vChip   { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: var(--r-full); border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); cursor: pointer; user-select: none; font-size: 12px; transition: all .1s; }
.vChip:hover   { border-color: var(--vAccent); background: var(--vTint2); }
.vChip.isActive{ background: var(--vTint1); border-color: var(--vAccent); font-weight: 700; }
.vChip svg     { width: 14px; height: 14px; }
.vChipsBar     { margin: 6px 0 10px; }
.vChipsBar .vChips { display: flex; flex-wrap: wrap; gap: 7px; }

/* ── 24. MISC ───────────────────────────────────────────────── */
.container   { max-width: 1400px; margin: 0 auto; padding: 16px; }
.sectionGrid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 980px) { .sectionGrid { grid-template-columns: 400px 1fr; } }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--r-full); font-weight: 600; font-size: 12px; border: 1px solid transparent; }
.chip.new  { background: #e8f4fd; color: #0c5fa5; border-color: #acd4f0; }
.chip.sent { background: #fff4e6; color: #974a00; border-color: #ffc078; }
.chip.done { background: #e6faf2; color: #0a6640; border-color: #5cc8a0; }
.waIcon { display: inline-flex; align-items: center; }


/* ══════════════════════════════════════════════════════════════
   COLOR + TRAMA POR VERTICAL  (añadido encima de la base limpia)
   ══════════════════════════════════════════════════════════════ */

/* ── Fondo general: trama de puntos tintada con el color del vertical ── */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle, var(--vTint1) 1.2px, transparent 1.2px),
    linear-gradient(160deg, var(--vTint2) 0%, transparent 55%),
    linear-gradient(340deg, var(--vTint2) 0%, transparent 45%);
  background-size: 20px 20px, 100% 100%, 100% 100%;
  background-attachment: fixed;
}
/* Login: sin trama */
body.noSession { background: #000 !important; background-image: none !important; }

/* ── Cabeceras de sección (summary) con gradiente del color ── */
details.acc > summary {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--vAccent) 10%, #fff) 0%,
    #fff 55%) !important;
}
details.acc[open] > summary {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--vAccent) 14%, #fff) 0%,
    color-mix(in srgb, var(--vAccent) 5%, #fff) 100%) !important;
}
details.acc > summary:hover {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--vAccent) 16%, #fff) 0%,
    color-mix(in srgb, var(--vAccent) 6%, #fff) 100%) !important;
}

/* ── KPI cards: fondo tintado suave ── */
#dash .grid3 > .card {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--vAccent) 6%, #fff) 0%,
    #fff 60%) !important;
}

/* ── Cabecera de tabla tintada ── */
th {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--vAccent) 8%, #f7f8fa) 0%,
    color-mix(in srgb, var(--vAccent) 4%, #f0f2f5) 100%) !important;
}

/* ── Filas hover con tinte del vertical ── */
tbody tr:hover {
  background: color-mix(in srgb, var(--vAccent) 5%, #f7f8fa) !important;
}

/* ── Accordion body con tinte muy suave ── */
details.acc .accBody {
  background: color-mix(in srgb, var(--vAccent) 3%, #fff);
}

/* ── Inputs con tinte de foco más marcado ── */
input:focus, select:focus, textarea:focus {
  background: color-mix(in srgb, var(--vAccent) 4%, #fff) !important;
}

/* ── Mobile: cabecera de tarjeta tintada al abrirse ── */
@media (max-width: 720px) {
  tr.isOpen .accHeader {
    background: linear-gradient(90deg,
      color-mix(in srgb, var(--vAccent) 12%, #fff) 0%,
      color-mix(in srgb, var(--vAccent) 4%, #fff) 100%) !important;
  }
  .accDetails {
    background: color-mix(in srgb, var(--vAccent) 3%, #f7f8fa) !important;
  }
}

/* ── Botón de exportar/importar con tinte ── */
#exportJobsWrap button.secondary {
  background: color-mix(in srgb, var(--vAccent) 6%, #fff) !important;
  border-color: color-mix(in srgb, var(--vAccent) 20%, #dde2ec) !important;
}


/* ══════════════════════════════════════════════════════════════
   TIPOGRAFÍA UNIFICADA — Inter + escala consistente
   ══════════════════════════════════════════════════════════════ */

/* Fuente base en todo */
*, input, select, textarea, button {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ── Escala de tamaños ── */
/* 11px — etiquetas uppercase (PROVEEDOR, FECHA…) */
th,
.accLabel,
.muted.small, .small {
  font-size: 11px;
  letter-spacing: .04em;
}

/* 12px — badges, pills, notas secundarias */
.stBadge, .badge, .chip, .pill,
.roleTag, .status-pill,
.btnMini, .photoLink,
.hdrStatusLine, .brandSub, .brandEmail,
.footerNote, .footerStatus,
.accSub, .sortMark {
  font-size: 12px;
  letter-spacing: 0;
}

/* 13px — botones de acción, inputs compactos, etiquetas tabla */
.btn, .btnMini, .cellInp,
button.small, .modalClose,
.btn-secondary, .btn-toggle,
.usersGroupTitle,
.accChevron,
#exportJobsWrap button {
  font-size: 13px;
}

/* 14px — texto base de tabla, inputs, cuerpo */
td, input, select, textarea,
.muted, .accVal, .accTitle {
  font-size: 14px;
}

/* 15px — botones principales */
main button, .btnPrimary, .btnMain, button.primary,
#btnToggleCreateLead, .dangerBtn, .btnWhatsApp {
  font-size: 14px;
}

/* 16px — títulos de sección (summary) */
details.acc > summary { font-size: 15px; }

/* 18px — título de marca */
.brandTitle { font-size: 20px; }
@media (min-width: 900px) { .brandTitle { font-size: 22px; } }
@media (max-width: 720px)  { .brandTitle { font-size: 18px; } }

/* 32–36px — KPI numbers */
#kpiJobs, #kpiBilled, #kpiComm {
  font-size: 34px !important;
  letter-spacing: -.03em !important;
}

/* ── Pesos ── */
/* 400 — texto normal */
td, .muted, .accVal, .accSub,
.hdrStatusLine, .footerNote { font-weight: 400; }

/* 500 — etiquetas, labels */
.accLabel, th,
.muted.small, .small,
.footerStatus, .brandSub { font-weight: 500; }

/* 600 — botones secundarios, pills, badges, inputs de estado */
.btn, .btnMini, .badge, .chip,
.stBadge, .pill, .roleTag, .status-pill,
button.secondary, .btn-secondary,
.modalClose, .photoLink,
.cellInp, .logoutBtn { font-weight: 600; }

/* 700 — botones primarios, títulos de sección, accTitle */
main button, .btnPrimary, .dangerBtn,
.btnWhatsApp, #btnToggleCreateLead,
details.acc > summary, .accTitle,
.brandTitle, .usersGroupTitle,
.modalHeader h3 { font-weight: 700; }

/* Los números KPI sí van en 700 (no 900) */
#kpiJobs, #kpiBilled, #kpiComm { font-weight: 700 !important; }

/* Etiquetas uppercase: solo 600, no negrita total */
th { font-weight: 600 !important; }

/* Eliminar pesos excesivos heredados */
b, strong { font-weight: 600; }

/* ── JOB THREAD (conversación por trabajo) ─────────────────── */
.accRowThread { flex-direction: column; }
.accRowThread .accLabel { margin-bottom: 6px; }
.accRowThread .accVal   { width: 100%; }

.jobThread {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f0f2f5;
  border-radius: 12px;
  padding: 10px 10px 6px;
  max-height: 280px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.jMsg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  gap: 2px;
}
.jMsg.admin, .jMsg.superadmin { align-self: flex-end; align-items: flex-end; }
.jMsg.provider                { align-self: flex-start; align-items: flex-start; }

.jMsgBubble {
  padding: 7px 11px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.jMsg.admin .jMsgBubble,
.jMsg.superadmin .jMsgBubble {
  background: var(--vAccent, #111827);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.jMsg.provider .jMsgBubble {
  background: #fff;
  color: #111b21;
  border: 1px solid #e9edef;
  border-bottom-left-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.jMsg.jMsgLegacy .jMsgBubble { opacity: .6; font-style: italic; }

.jMsgMeta {
  font-size: 10.5px;
  color: #8696a0;
  padding: 0 3px;
}

.jMsgActions {
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .15s;
  margin-bottom: 2px;
}
.jMsg:hover .jMsgActions { opacity: 1; }
/* En móvil siempre visibles */
@media (max-width: 720px) { .jMsgActions { opacity: 1; } }

.jMsgAct {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1;
  opacity: .6;
}
.jMsgAct:hover { opacity: 1; background: rgba(0,0,0,.06); }

.jMsgEditTa {
  width: 100%;
  min-height: 56px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #111827;
  font-size: 13px;
  padding: 5px 8px;
  resize: vertical;
  font-family: inherit;
}

/* ── Auditoría ── */
.auditEntry {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.auditEntry:last-child { border-bottom: none; }
.auditMeta { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.auditChanges { display: flex; flex-direction: column; gap: 3px; }
.auditChange {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; flex-wrap: wrap;
}
.auditField { font-weight: 600; color: #374151; min-width: 100px; }
.auditOld { color: #ef4444; text-decoration: line-through; }
.auditArrow { color: #9ca3af; }
.auditNew { color: #16a34a; font-weight: 600; }

/* ── Dashboard proveedor ── */
.provDashRow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.provDashLabel { font-size: 13px; color: #6b7280; min-width: 120px; }
.provDashPills { display: flex; gap: 6px; flex-wrap: wrap; }
.statusBreakPill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.commProgress {
  flex: 1; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; min-width: 100px;
}
.commProgressBar { height: 100%; background: #22c55e; border-radius: 4px; transition: width .4s ease; }

/* ── Paginación ── */
.paginationBar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 4px;
}
.paginationInfo { font-size: 13px; color: #6b7280; }

/* ── Flash fila nueva (realtime) ── */
@keyframes rowFlashAnim {
  0%   { background: #d1fae5; }
  70%  { background: #d1fae5; }
  100% { background: transparent; }
}
tr.rowFlash { animation: rowFlashAnim 2s ease-out forwards; }

.jThreadEmpty, .jThreadLoading {
  text-align: center;
  color: #8696a0;
  font-size: 12px;
  padding: 10px 0;
}

/* Chat modal: anclado abajo, solo scrollea el thread */
#chatBackdrop {
  align-items: flex-end !important;
  padding: 0 !important;
}
#chatBackdrop .modal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 85vh;
  padding: 16px;
}
#chatThread {
  overflow-y: auto;
  overflow-x: hidden;
}

.jThreadInput {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e9edef;
}
.jThreadInput textarea {
  flex: 1;
  min-height: 34px;
  max-height: 100px;
  resize: none;
  border: 1px solid #e9edef;
  border-radius: 18px;
  padding: 7px 13px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: #fff;
  line-height: 1.4;
}
.jThreadInput textarea:focus { border-color: var(--vAccent, #111827); }
.jThreadSend {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  border-radius: 50% !important;
  border: none !important;
  background: var(--vAccent, #111827) !important;
  color: #fff !important;
  font-size: 15px !important;
  cursor: pointer;
  flex-shrink: 0;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  transition: opacity .15s;
}
.jThreadSend:hover  { opacity: .82; }
.jThreadSend:disabled { opacity: .35; }
.jThreadSend.micActive {
  background: #ef4444 !important;
  animation: micPulse .8s ease-in-out infinite alternate;
}
@keyframes micPulse {
  from { box-shadow: 0 0 0 0 rgba(239,68,68,.5); }
  to   { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* ── Filter panel (chips UI) ── */
#filtersPanel {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  margin-top: 10px;
  padding: 12px 10px;
  box-sizing: border-box;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
details.acc + #filtersPanel { margin-top: 10px; }
#filtersPanel + details.acc { margin-top: 10px; }

#filterPillsRow {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--surface);
}

#adminActiveChips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 14px 8px;
}
#adminActiveChips:empty { display: none; }

.filterToggleBtn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--border-2);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background .12s, border-color .12s, color .12s;
}
.filterToggleBtn.active {
  background: var(--vAccent);
  border-color: var(--vAccent);
  color: #fff;
}
.filterToggleBtn.active::first-letter { content: "▴"; }

.filterChip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--vAccent);
  color: #fff;
  border-radius: 20px;
  padding: 4px 8px 4px 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chipClose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.28);
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  padding: 0;
  flex: 0 0 auto;
  transition: background .1s;
}
.chipClose:hover { background: rgba(255,255,255,0.48); }

.filterSearchInline {
  flex: 1;
  min-width: 80px;
}

.btnIcon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 20px;
  border: 1.5px solid var(--border-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}

#adminFiltersDropdown,
#provFiltersDropdown {
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

#provFilterUI {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0 4px;
}

.fpRow {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

/* override main button { width:100% } */
.fpRow button, .fp, .fpClear {
  width: auto !important;
  flex: 0 0 auto !important;
}

.fp {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.fp.active {
  background: var(--vAccent);
  border-color: var(--vAccent);
  color: #fff;
}

/* Select con icono */
.fpSelectWrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
/* Flecha común para todos los selectWrap */
.fpSelectWrap::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
  z-index: 1;
}

.fpSelIcon {
  position: absolute;
  left: 9px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
  z-index: 1;
}
.fpIconSel {
  width: 100%;
  padding: 5px 22px 5px 28px;
  border-radius: 20px;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--border-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background .12s, color .12s, border-color .12s;
}
.fpIconSel.st-assigned      { background:#dbeafe; color:#1e3a8a; border-color:#1e3a8a44; }
.fpIconSel.st-picked_up     { background:#ffedd5; color:#c2410c; border-color:#c2410c44; }
.fpIconSel.st-delivered     { background:#fef9c3; color:#854d0e; border-color:#854d0e44; }
.fpIconSel.st-commission_paid { background:#dcfce7; color:#166534; border-color:#16653444; }
.fpIconSel.st-cancelled     { background:#fee2e2; color:#b42318; border-color:#b4231844; }
.fpIconSel.st-pending       { background:#f5f3ff; color:#6b21a8; border-color:#6b21a844; }

/* Select de estado con color dinámico */
.fpStatusSel {
  padding: 5px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--border-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  max-width: 140px;
  transition: background .12s, color .12s, border-color .12s;
}
.fpStatusSel.st-assigned      { background:#dbeafe; color:#1e3a8a; border-color:#1e3a8a44; }
.fpStatusSel.st-picked_up     { background:#ffedd5; color:#c2410c; border-color:#c2410c44; }
.fpStatusSel.st-delivered     { background:#fef9c3; color:#854d0e; border-color:#854d0e44; }
.fpStatusSel.st-commission_paid { background:#dcfce7; color:#166534; border-color:#16653444; }
.fpStatusSel.st-cancelled     { background:#fee2e2; color:#b42318; border-color:#b4231844; }

.fpSearch {
  flex: 1 !important;
  min-width: 80px;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  border: 1.5px solid var(--border-2);
  background: var(--surface-2);
}
.fpSearch:focus {
  outline: none;
  border-color: var(--vAccent);
  background: var(--surface);
}

.fpClear {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  border-radius: 50% !important;
  border: 1.5px solid var(--border-2) !important;
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  font-size: 11px !important;
  line-height: 1 !important;
  padding: 0 !important;
  flex: 0 0 22px !important;
  box-sizing: border-box !important;
  cursor: pointer !important;
}
.fpClear:hover { background: var(--border) !important; }

/* Status multi-select dropdown */
#adminStatusMultiWrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
#provStatusMultiWrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
#provStatusMultiWrap::after { display: none; }
.fpMultiBtn {
  width: 100% !important;
  text-align: left !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  padding: 5px 22px 5px 28px !important;
}
.fpMultiBtn::after { display: none; }
.fpMultiDrop {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  padding: 6px;
  overflow: hidden;
}
.fpMultiDrop.open { display: block; }
.fpMultiOpt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  user-select: none;
}
.fpMultiOpt:hover { background: var(--surface-2); }
.fpMultiOpt.active { background: var(--surface-2); }
.fpMultiOpt.active::after { content: "✓"; margin-left: auto; font-size: 13px; }
.fpMultiDot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

#filtersSummarySection {
  padding: 14px 18px;
  display: grid;
  gap: 10px;
}

/* ── Admin filter bar compact (desktop only) ── */
#adminFiltersBar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
#adminFiltersBar select,
#adminFiltersBar input[type="date"] {
  flex: 0 0 auto;
  min-width: 0;
  width: auto;
}
@media (min-width: 720px) {
  #adminFiltersBar {
    flex-wrap: nowrap;
  }
  #adminFiltersBar select {
    max-width: 160px;
  }
  #adminFiltersBar input[type="date"] {
    width: 138px;
  }
}

/* ── TOAST ─────────────────────────────────────────────── */
#toastMsg {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #25D366;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 28px;
  border-radius: 24px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  white-space: nowrap;
}
#toastMsg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

