/* Paleta Conecta Digital */
:root {
  --navy: #0F2A4A;      /* azul marino: encabezado y texto fuerte */
  --teal: #14B8A6;      /* turquesa: color principal / acciones */
  --teal-dark: #0D9488;
  --coral: #F97362;     /* coral: acentos y alertas */
  --bg: #F3F6FA;
  --surface: #FFFFFF;
  --line: #DDE4EE;
  --text: #1E293B;
  --muted: #64748B;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--teal-dark); }
.muted { color: var(--muted); }
h1 { font-size: 20px; margin: 0; color: var(--navy); }
h3 { margin: 0 0 12px; color: var(--navy); font-size: 15px; }
h4 { margin: 0; color: var(--navy); font-size: 13px; }

/* Encabezado */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  align-items: center;
  min-height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 10px 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--coral));
  font-weight: 800; letter-spacing: -1px; font-size: 16px;
}
.brand-name { font-size: 20px; font-weight: 300; }
.brand-name strong { font-weight: 800; color: var(--teal); }
.brand-sub { font-size: 12px; opacity: .7; border-left: 1px solid rgba(255,255,255,.3); padding-left: 10px; }

.nav { display: flex; gap: 2px; flex-wrap: wrap; align-self: stretch; }
.nav a {
  color: rgba(255,255,255,.75); text-decoration: none; padding: 0 12px; font-weight: 600;
  display: flex; align-items: center; border-bottom: 3px solid transparent;
}
.nav a:hover { color: #fff; }
.nav a[hidden] { display: none; }
.nav a.active { color: #fff; border-bottom-color: var(--teal); }

/* Barra de cada vista */
.view-bar {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
  padding: 14px 20px 4px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input, .toolbar select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; min-width: 0; background: #fff;
}
#search { width: 320px; max-width: 100%; }

.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 8px 14px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.danger { background: #fff; border-color: var(--coral); color: var(--coral); }
.link { background: none; border: 0; padding: 0; color: var(--teal-dark); font: inherit; font-weight: 600; cursor: pointer; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { color: var(--coral); background: #FEE9E6; }

/* Resumen */
.summary { display: flex; gap: 24px; padding: 8px 20px 12px; color: var(--muted); flex-wrap: wrap; }
.summary b { color: var(--navy); font-size: 16px; }

/* Tablero */
.board {
  display: flex; gap: 12px; padding: 0 20px 20px;
  overflow-x: auto; align-items: flex-start;
  min-height: calc(100vh - 170px);
}
.column {
  flex: 0 0 270px; background: #E9EEF5; border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 190px);
}
.column-head {
  padding: 10px 12px; border-top: 4px solid var(--stage-color, var(--teal));
  border-radius: var(--radius) var(--radius) 0 0; background: var(--surface);
}
.column-head .name { font-weight: 700; display: flex; justify-content: space-between; }
.column-head .count {
  background: var(--bg); color: var(--muted); border-radius: 999px; padding: 0 8px; font-size: 12px;
}
.column-head .total { color: var(--navy); font-weight: 600; margin-top: 2px; }
.column-body { padding: 8px; overflow-y: auto; flex: 1; min-height: 80px; }
.column.drag-over .column-body { background: rgba(20,184,166,.12); outline: 2px dashed var(--teal); outline-offset: -4px; border-radius: 0 0 var(--radius) var(--radius); }
.add-inline { margin: 0 8px 8px; background: transparent; border: 1px dashed #B8C4D4; color: var(--muted); }

.card {
  background: var(--surface); border-radius: 8px; padding: 10px; margin-bottom: 8px;
  border: 1px solid var(--line); cursor: grab; box-shadow: 0 1px 2px rgba(15,42,74,.06);
  user-select: none; touch-action: none;
}
.card:hover { border-color: var(--teal); }
.card.dragging { opacity: .4; }
.card.ghost { position: fixed; pointer-events: none; z-index: 1000; transform: rotate(2deg); box-shadow: 0 10px 24px rgba(15,42,74,.25); }
.card .title { font-weight: 700; color: var(--navy); margin-bottom: 4px; word-break: break-word; }
.card .amount { color: var(--teal-dark); font-weight: 700; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.card .wa { color: var(--teal-dark); text-decoration: none; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 6px; }
.owner {
  display: inline-block; font-size: 11px; background: #FEE9E6; color: #B4473A;
  border-radius: 999px; padding: 1px 8px;
}
.badges { display: flex; gap: 8px; font-size: 11px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; font-size: 12px; padding: 12px 0; }

/* Páginas y paneles */
.page { padding: 16px 20px 32px; max-width: 1280px; margin: 0 auto; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel-sub { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Ficha de negociación */
.detail-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 12px; }
.detail-title h1 { font-size: 24px; word-break: break-word; }
.big-amount { font-size: 20px; font-weight: 700; color: var(--teal-dark); }

.stage-bar { display: flex; gap: 3px; margin-bottom: 16px; overflow-x: auto; }
.stage-bar button {
  flex: 1 0 auto; min-width: 90px; border: 0; padding: 9px 14px; font: inherit; font-weight: 600; font-size: 12px;
  background: #E2E8F0; color: var(--muted); cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
}
.stage-bar button:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
.stage-bar button.done { background: var(--c); color: #fff; opacity: .55; }
.stage-bar button.current { opacity: 1; }
.stage-bar button:hover { filter: brightness(.95); }
.stage-bar .stage-gear { flex: 0 0 auto; min-width: 0; clip-path: none; border-radius: 0 8px 8px 0; background: #fff; border: 1px solid var(--line); }

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

.table-wrap { overflow-x: auto; }
.products { width: 100%; border-collapse: collapse; }
.products th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
.products td { padding: 6px; border-bottom: 1px solid var(--line); }
.products .num { text-align: right; white-space: nowrap; }
.products td input { width: 90px; text-align: right; font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.products tfoot td { font-weight: 700; color: var(--navy); border-bottom: 0; }
.prod-form { display: grid; grid-template-columns: 1fr 80px 110px auto; gap: 8px; margin-top: 12px; }
.prod-form input { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-width: 0; }

.composer textarea { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 10px; resize: vertical; }
.composer .actions { margin-top: 8px; }
.timeline { list-style: none; margin: 16px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-item { display: flex; gap: 10px; margin-bottom: 14px; position: relative; }
.tl-icon { flex: 0 0 32px; height: 32px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); display: grid; place-items: center; font-size: 14px; }
.tl-body { flex: 1; min-width: 0; padding-top: 5px; }
.tl-comment .comment { background: #F0FDFA; border: 1px solid #CCFBF1; border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; }
.tl-meta { color: var(--muted); font-size: 12px; margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.tl-meta .link { font-size: 12px; color: var(--muted); font-weight: 400; }
.changes { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.changes b { color: var(--text); font-weight: 600; }

/* Formularios */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(15,42,74,.3); }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15,42,74,.45); }
dialog form { padding: 20px; }
dialog h2 { margin: 0 0 14px; color: var(--navy); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12px; color: var(--muted); min-width: 0; }
.grid label small { font-weight: 400; }
.grid .full { grid-column: 1 / -1; }
.grid input, .grid select, .grid textarea, .stage-list input, .stage-list select {
  font: inherit; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; min-width: 0; background: #fff;
}
.grid input:disabled { background: var(--bg); color: var(--muted); }
.grid input:focus, .grid select:focus, .grid textarea:focus { outline: 2px solid var(--teal); border-color: transparent; }
.actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.spacer { flex: 1; }
.hint { color: var(--muted); margin-top: -6px; }

.stage-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.stage-list li { display: flex; gap: 6px; align-items: center; }
.stage-list input[type=text] { flex: 1; }
.stage-list input[type=color] { width: 40px; height: 36px; padding: 2px; flex: 0 0 auto; }
.stage-list button { padding: 6px 9px; }

/* Listas y tablas */
.page-pad { padding: 4px 20px 24px; }
.list-count { margin: 4px 0 8px; font-size: 12px; }
.panel.flush { padding: 0; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: #F8FAFC; white-space: nowrap; user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--navy); }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; white-space: nowrap; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #F0FDFA; }
table.data a { text-decoration: none; }
.empty-row { text-align: center; padding: 24px !important; }
.small { font-size: 12px; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.chip {
  display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, white);
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }

.links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: -4px 0 14px; }
.links a { text-decoration: none; font-weight: 600; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head h3 { margin: 0; }
.related { list-style: none; margin: 0; padding: 0; }
.related li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.related li:last-child { border-bottom: 0; }
.related a { text-decoration: none; }

/* Actividades */
.acts { list-style: none; margin: 0; padding: 0; }
.act { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: 0; }
.act-check { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--teal); flex: 0 0 auto; cursor: pointer; }
.act-body { flex: 1; min-width: 0; }
.act-open { color: var(--text); font-weight: 600; text-decoration: none; }
.act-open:hover { color: var(--teal-dark); }
.act.done .act-open { text-decoration: line-through; color: var(--muted); }
.act.overdue { background: linear-gradient(90deg, #FEF2F0, transparent 60%); }
.overdue-label { color: #C2410C; }
.badges .pending { color: var(--teal-dark); font-weight: 600; }
.badges .pending.overdue { color: #C2410C; }
details summary { cursor: pointer; margin-top: 10px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 12px; }
.tabs button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.tabs button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.tabs .count { background: rgba(100,116,139,.15); border-radius: 999px; padding: 0 7px; font-size: 12px; margin-left: 2px; }
.tabs .count.alert { background: var(--coral); color: #fff; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head { background: #F8FAFC; padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.cal-day { background: #fff; min-height: 104px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:hover { background: #F0FDFA; }
.cal-day.other { background: #F8FAFC; }
.cal-day.other .cal-num { color: #B8C4D4; }
.cal-num { font-size: 12px; font-weight: 700; color: var(--navy); }
.cal-day.today .cal-num { background: var(--teal); color: #fff; border-radius: 999px; width: 22px; height: 22px; display: grid; place-items: center; }
.cal-item {
  border: 0; text-align: left; font: inherit; font-size: 11px; padding: 2px 6px; border-radius: 4px; cursor: pointer;
  background: #E0F2FE; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-item.done { background: #F1F5F9; color: var(--muted); text-decoration: line-through; }
.cal-item.overdue { background: #FEE9E6; color: #B4473A; }
.cal-title { min-width: 140px; text-align: center; color: var(--navy); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bell { position: relative; text-decoration: none; font-size: 18px; padding: 6px; opacity: .7; }
.bell.has { opacity: 1; }
.bell-count {
  position: absolute; top: 0; right: -4px; background: var(--coral); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 0 5px; line-height: 16px;
}
.bell-count:empty { display: none; }

#alerts { position: fixed; right: 16px; bottom: 16px; z-index: 1500; display: flex; flex-direction: column; gap: 8px; width: min(320px, calc(100vw - 32px)); }
.alert { background: #fff; border-left: 4px solid var(--coral); border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(15,42,74,.25); }
.alert > div:first-child { display: flex; justify-content: space-between; align-items: center; }

@media (max-width: 640px) {
  .cal-day { min-height: 70px; padding: 3px; }
  .cal-item { font-size: 10px; padding: 1px 3px; }
}

/* Sesión, encabezado y avisos */
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-name { display: flex; flex-direction: column; line-height: 1.15; font-weight: 600; text-align: right; }
.user-name small { font-weight: 400; opacity: .7; font-size: 11px; }
.user-chip .logout { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.banner {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 20px;
  background: #FFF7ED; border-bottom: 1px solid #FED7AA; color: #7C2D12;
}
.banner[hidden] { display: none; }
.title-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pipeline-select { font: inherit; font-weight: 600; color: var(--navy); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #fff; }
.pipeline-pick { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; margin-left: auto; }
.pipeline-pick select { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: #fff; }
label.inline { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }

body.login-mode .topbar, body.login-mode #view, body.login-mode .banner { display: none; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--navy), #13406B); }
.login-card {
  background: #fff; border-radius: 16px; padding: 28px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 30px 60px rgba(0,0,0,.3);
}
.login-card h2 { margin: 4px 0; color: var(--navy); }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login-card input { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.login-card .btn { padding: 10px; }
.login-brand { color: var(--navy); padding: 0; }
.login-error { color: #B4473A; min-height: 1em; margin: 0; font-size: 13px; }

/* Reportes */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile span { color: var(--muted); font-size: 12px; font-weight: 600; }
.tile b { font-size: 26px; color: var(--navy); font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 4px 6px; border-radius: 6px; position: relative; }
.bar-row:hover, .bar-row:focus { background: #F0FDFA; outline: none; }
.bar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: #EEF2F7; border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--teal-dark); border-radius: 0 4px 4px 0; }
.bar-value { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 70px; text-align: right; }
.bar-row[data-tip]:hover::after, .bar-row[data-tip]:focus::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); z-index: 10;
  background: var(--navy); color: #fff; font-size: 12px; padding: 6px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none;
}
.bar-cell { min-width: 220px; }
.bar-cell .bar-row { grid-template-columns: 1fr auto; padding: 0; }
.bar-cell .bar-label { display: none; }

.toast.error { background: #B4473A; }

/* Centro de contacto */
.nav-count {
  background: var(--coral); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
  padding: 0 6px; line-height: 16px; margin-left: 5px;
}
.nav-count:empty { display: none; }
.inbox {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 12px; padding: 0 20px 20px;
  height: calc(100vh - 128px); min-height: 480px;
}
.inbox > .panel { margin: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.inbox-filters { padding: 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.inbox-filters input, .inbox-filters select { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; min-width: 0; background: #fff; }
.inbox-selects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv:hover { background: #F8FAFC; }
.conv.on { background: #F0FDFA; box-shadow: inset 3px 0 0 var(--teal); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 6px; }
.conv-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--navy); }
.conv.unread .conv-top b, .conv.unread .conv-text { font-weight: 700; color: var(--text); }
.conv-text { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 2px 0 4px; }
.conv-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.unread-badge { margin-left: auto; background: var(--coral); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.ch-badge {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 800; color: #fff; background: var(--c); letter-spacing: -.3px;
}
.status-dot { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-dot.s-abierta { color: var(--teal-dark); }
.status-dot.s-en_espera { color: #B45309; }
.status-dot.s-cerrada { color: var(--muted); }

.chat-empty { margin: auto; text-align: center; padding: 24px; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-head select { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; background: #fff; }
.chat-who { display: flex; flex-direction: column; min-width: 0; }
.chat-who b { color: var(--navy); }
.back-mobile { display: none; text-decoration: none; font-size: 18px; }
.chat-crm { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 14px; background: #F8FAFC; border-bottom: 1px solid var(--line); }
.chat-crm a { text-decoration: none; font-weight: 600; font-size: 13px; }
.chat-crm .status-dot { margin-left: auto; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.msg { max-width: min(560px, 80%); padding: 8px 12px; border-radius: 14px; }
.msg.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: #CCFBF1; border-bottom-right-radius: 4px; }
.msg.system { align-self: center; background: none; font-size: 12px; color: var(--muted); padding: 2px; text-align: center; }
.msg-text { white-space: pre-wrap; word-break: break-word; }
.msg-meta { font-size: 11px; color: var(--muted); margin-top: 3px; }
.delivery-fail { color: #B4473A; font-weight: 600; }
.chat-compose { border-top: 1px solid var(--line); padding: 10px 14px; background: #fff; position: relative; }
.compose-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.compose-row textarea { flex: 1; font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; resize: vertical; min-height: 44px; }
.compose-note { margin: 6px 0 0; }
.qr-wrap { position: relative; }
.qr-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20; width: min(420px, 80vw); max-height: 300px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(15,42,74,.2); padding: 4px;
}
.qr-menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; font: inherit; cursor: pointer; }
.qr-menu button span { color: var(--muted); font-size: 12px; }
.qr-menu button:hover { background: #F0FDFA; }
.qr-menu .qr-edit { color: var(--teal-dark); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0; }

.timeline.compact { margin-top: 4px; }
.ch-icon { background: var(--c); color: #fff; border-color: var(--c); font-size: 9px; font-weight: 800; }

/* Conectar canales */
.channels { max-width: 900px; }
.channels h1 { margin-bottom: 6px; }
.channel-card h3 { display: flex; align-items: center; gap: 8px; }
.channel-card h4 { margin: 16px 0 4px; }
.pill { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: #F1F5F9; color: var(--muted); }
.pill.ok { background: #CCFBF1; color: var(--teal-dark); }
.switch { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--navy); cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--teal); }
.switch-cell { display: flex; align-items: flex-end; padding-bottom: 8px; }
.copy-box { display: flex; gap: 8px; align-items: center; background: #0F2A4A; border-radius: 8px; padding: 8px 8px 8px 12px; margin: 8px 0 12px; }
.copy-box code { color: #E2E8F0; font-size: 12px; overflow-x: auto; white-space: nowrap; flex: 1; }
.copy-box .btn { flex: 0 0 auto; }
code.wrap { word-break: break-all; }
.steps { margin: 4px 0 8px; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.banner-inline { background: #FFF7ED; border: 1px solid #FED7AA; color: #7C2D12; border-radius: 10px; padding: 10px 14px; margin: 12px 0 16px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 16px 0; }

@media (max-width: 860px) {
  .inbox { grid-template-columns: 1fr; height: auto; padding: 0 16px 16px; }
  .inbox .inbox-chat { display: none; height: calc(100vh - 140px); }
  .inbox.has-chat .inbox-list { display: none; }
  .inbox.has-chat .inbox-chat { display: flex; }
  .inbox .inbox-list { max-height: calc(100vh - 140px); }
  .back-mobile { display: inline; }
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000;
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: 0 8px 20px rgba(15,42,74,.3);
}

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar, .view-bar, .summary, .page { padding-left: 16px; padding-right: 16px; }
  .board { padding: 0 16px 16px; }
  .grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  #search { width: 100%; }
  .toolbar { width: 100%; }
  .prod-form { grid-template-columns: 1fr 1fr; }
  .prod-form input[name=name] { grid-column: 1 / -1; }
}

/* Grupo de casillas en formularios */
.grid .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-weight: 600; font-size: 12px; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--teal); }
.grid .field small { color: var(--muted); font-size: 12px; }

/* Reservas: agenda */
.agenda-title { text-transform: capitalize; }
#agDate { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; }
.agenda { overflow-x: auto; }
.ag-head, .ag-body { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(140px, 1fr)); min-width: calc(56px + var(--cols) * 140px); }
.ag-head { position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 1px solid var(--line); }
.ag-colhead { padding: 10px 8px; font-weight: 700; color: var(--navy); text-align: center; border-left: 1px solid var(--line); border-top: 3px solid var(--rc); text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-colhead.today { background: #F0FDFA; }
.ag-gutter { border-right: 1px solid var(--line); }
.ag-time { height: var(--row-h); font-size: 11px; color: var(--muted); text-align: right; padding: 0 6px; transform: translateY(-7px); }
.ag-col { position: relative; border-left: 1px solid var(--line); }
.ag-slot { height: var(--row-h); border-top: 1px dashed #EEF2F7; cursor: pointer; }
.ag-slot.hour { border-top: 1px solid var(--line); }
.ag-slot:hover { background: #F0FDFA; }
.ag-slot.off { background: repeating-linear-gradient(135deg, #F8FAFC, #F8FAFC 6px, #EEF2F7 6px, #EEF2F7 8px); }
.ag-block {
  position: absolute; left: 3px; right: 3px; z-index: 2; border-radius: 6px; padding: 3px 6px; overflow: hidden; cursor: grab;
  background: color-mix(in srgb, var(--rc) 16%, white); border-left: 4px solid var(--sc); font-size: 12px; line-height: 1.25;
  display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(15,42,74,.12); user-select: none; touch-action: none;
}
.ag-block b { color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-block span { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-block .ag-status { color: var(--sc); font-weight: 600; font-size: 11px; }
.ag-block.s-cancelada { opacity: .55; text-decoration: line-through; }
.ag-block.s-llego { background: color-mix(in srgb, #14B8A6 22%, white); }
.ag-block.busy { background: repeating-linear-gradient(135deg, #E2E8F0, #E2E8F0 6px, #F1F5F9 6px, #F1F5F9 12px); border-left-color: #94A3B8; color: var(--muted); cursor: default; justify-content: center; }
.ag-block.dragging { opacity: .35; }
.ag-ghost { position: fixed; z-index: 1000; pointer-events: none; transform: rotate(1deg); box-shadow: 0 10px 24px rgba(15,42,74,.3); }
.ag-preview { position: absolute; left: 3px; right: 3px; z-index: 1; border: 2px dashed var(--teal); border-radius: 6px; background: rgba(20,184,166,.1); font-size: 11px; font-weight: 700; color: var(--teal-dark); padding: 2px 6px; pointer-events: none; }
.status-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.booking-crm { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.booking-crm a { font-weight: 600; text-decoration: none; }
.booking-crm select { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.form-error { color: #B4473A; margin: 10px 0 0; min-height: 1em; }
.empty-state { text-align: center; padding: 32px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; }
.cal-item.booking { background: #EDE9FE; color: #4C1D95; }

/* Editor de embudos y túneles */
.funnels-page { max-width: 1400px; }
.funnels-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 6px; }
.funnels { position: relative; display: flex; flex-direction: column; gap: 22px; margin-top: 14px; }
.tunnel-layer { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 4; overflow: visible; }
.tunnel-path { fill: none; stroke: #64748B; stroke-width: 2; stroke-dasharray: 6 5; }
.tunnel-temp { fill: none; stroke: var(--teal); stroke-width: 2; stroke-dasharray: 4 4; }
.tunnel-label { pointer-events: all; cursor: pointer; }
.tunnel-label rect { fill: #fff; stroke: #64748B; stroke-width: 1.5; }
.tunnel-label text { font-size: 10px; font-weight: 800; fill: #0F2A4A; letter-spacing: .5px; }
.tunnel-label:hover rect { fill: #FEE9E6; stroke: var(--coral); }
.funnel { margin: 0; position: relative; }
.funnel.dragging { opacity: .5; }
.funnel.drop-before { box-shadow: 0 -4px 0 var(--teal); }
.funnel.drop-after { box-shadow: 0 4px 0 var(--teal); }
.funnel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 14px; }
.funnel-head h3 { margin: 0; cursor: text; }
.handle { cursor: grab; color: var(--muted); font-size: 18px; padding: 0 4px; touch-action: none; user-select: none; }
.muted-link { color: var(--muted); }
.funnel-groups { display: flex; flex-wrap: wrap; gap: 16px 22px; align-items: flex-start; }
.stage-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stage-group.g-open { flex: 1 1 520px; }
.group-title { font-size: 11px; font-weight: 800; letter-spacing: .8px; color: var(--muted); border-bottom: 2px solid var(--line); padding-bottom: 4px; }
.g-won .group-title { color: var(--teal-dark); border-color: #99F6E4; }
.g-lost .group-title { color: #B4473A; border-color: #FECACA; }
.g-icon { font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 16px 4px; }
.stage-chip { position: relative; display: flex; flex-direction: column; align-items: center; touch-action: none; user-select: none; cursor: grab; }
.chip-body {
  display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 22px 6px 16px;
  background: var(--c); color: var(--t); font-weight: 700; font-size: 13px;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 10px 50%);
}
.chips .stage-chip:first-child .chip-body { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 6px 0 0 6px; }
.stage-chip.dragging { opacity: .4; }
.stage-chip.drop-before::before, .stage-chip.drop-after::before { content: ""; position: absolute; top: -4px; bottom: 14px; width: 3px; background: #0F2A4A; border-radius: 2px; }
.stage-chip.drop-before::before { left: -4px; }
.stage-chip.drop-after::before { right: -4px; }
.stage-chip.tunnel-target .chip-body { outline: 3px dashed #0F2A4A; outline-offset: -3px; }
.swatch { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--t); background: var(--c); cursor: pointer; padding: 0; flex: 0 0 auto; }
.chip-name { cursor: text; white-space: nowrap; }
.chip-count { background: rgba(255,255,255,.3); color: var(--t); border-radius: 999px; font-size: 11px; padding: 0 6px; }
.chip-btn { background: rgba(255,255,255,.25); color: var(--t); border: 0; border-radius: 50%; width: 20px; height: 20px; line-height: 18px; padding: 0; cursor: pointer; font-weight: 800; font-size: 12px; }
.chip-btn:hover { background: rgba(255,255,255,.5); }
.inline-input { font: inherit; font-weight: 600; color: #1E293B; border: 1px solid var(--teal); border-radius: 6px; padding: 2px 6px; width: 150px; }
.funnel-head .inline-input { font-size: 15px; width: 220px; }
.connector {
  width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; border: 2px solid var(--c); background: #fff; cursor: crosshair;
  box-shadow: 0 0 0 3px #fff;
}
.connector:hover, .funnels.linking .connector { background: var(--c); }
.connector-demo { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--teal); background: #fff; vertical-align: middle; }
.add-pipeline { width: 100%; margin-top: 18px; padding: 14px; border: 2px dashed #B8C4D4; border-radius: var(--radius); background: transparent; color: var(--muted); font: inherit; font-weight: 800; letter-spacing: .6px; cursor: pointer; }
.add-pipeline:hover { border-color: var(--teal); color: var(--teal-dark); }
.tunnel-list { list-style: none; margin: 4px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.rule-stage { margin-bottom: 12px; }
.rules { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rules li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.rules li span { flex: 1; }
.rules li.off span { color: var(--muted); text-decoration: line-through; }
#ruleParams { padding: 0; }
