@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0b0d12;
  --bg-soft: #0f1218;
  --panel: #151923;
  --panel2: #1c212d;
  --panel3: #232937;
  --border: #262c3a;
  --text: #eef0f4;
  --muted: #8891a3;
  --muted2: #5f6879;
  --accent: #22c55e;
  --accent-soft: rgba(34,197,94,.14);
  --accent2: #6d6ff7;
  --accent2-soft: rgba(109,111,247,.16);
  --selection-bg: rgba(245,166,35,.45);
  --danger: #f0475a;
  --danger-soft: rgba(240,71,90,.14);
  --warn: #f5a623;
  --warn-soft: rgba(245,166,35,.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.45);
  --shadow-sm: 0 4px 14px -6px rgba(0,0,0,.35);
}

[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-soft: #eceef3;
  --panel: #ffffff;
  --panel2: #f7f8fb;
  --panel3: #eef0f5;
  --border: #e3e6ee;
  --text: #1a1d29;
  --muted: #6b7280;
  --muted2: #9aa1b0;
  --accent-soft: rgba(22,163,74,.1);
  --accent2-soft: rgba(99,102,241,.1);
  --selection-bg: rgba(217,119,6,.35);
  --danger-soft: rgba(220,38,58,.1);
  --warn-soft: rgba(217,119,6,.1);
  --shadow: 0 10px 30px -14px rgba(30,35,60,.18);
  --shadow-sm: 0 4px 14px -8px rgba(30,35,60,.15);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .25s ease, color .25s ease;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--selection-bg); }
::-moz-selection { background: var(--selection-bg); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes spin { to { transform: rotate(360deg); } }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 10px 22px; }
.sidebar .brand .brand-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.notif-btn { position: relative; background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: flex; flex-shrink: 0; }
.notif-btn:hover { color: var(--text); background: var(--panel2); }
.notif-btn svg { width: 18px; height: 18px; }
.notif-badge { position: absolute; top: 1px; right: 1px; background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 700; border-radius: 999px; min-width: 15px; height: 15px; display: flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1; }
.notif-badge[hidden] { display: none; }
.notif-dropdown { position: fixed; width: 360px; max-width: calc(100vw - 24px); max-height: 420px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); z-index: 400; display: flex; flex-direction: column; animation: popIn .18s ease; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-head button { background: none; border: none; color: var(--accent2); font-size: 11.5px; font-weight: 600; cursor: pointer; }
.notif-head-actions { display: flex; align-items: center; gap: 12px; }
.notif-head button.danger { color: var(--danger); }
.notif-head button:disabled { opacity: .5; cursor: default; }
.notif-list { overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: flex-start; transition: opacity .15s ease; }
.notif-item.removing { opacity: .35; pointer-events: none; }
.notif-main { flex: 1; min-width: 0; }
.notif-actions { display: flex; gap: 2px; flex-shrink: 0; margin: -3px -6px 0 0; }
.notif-act { background: none; border: none; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 7px; display: flex; }
.notif-act svg { width: 14px; height: 14px; }
.notif-act:hover { color: var(--text); background: var(--panel2); }
.notif-act.del { color: var(--danger); }
.notif-act.del:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--panel2); }
.notif-item.unread { background: var(--accent2-soft); }
.notif-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { width: 15px; height: 15px; }
.notif-title { font-size: 12.5px; font-weight: 700; }
.notif-body { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 10.5px; color: var(--muted2); margin-top: 4px; }
.notif-empty { padding: 30px 14px; text-align: center; color: var(--muted); font-size: 12.5px; }
.notif-push-row { padding: 8px 14px; border-bottom: 1px solid var(--border); }
.notif-push-row button { background: none; border: none; color: var(--accent2); font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 0; }
.notif-push-row button svg { width: 14px; height: 14px; }
.notif-push-ok { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.notif-push-ok svg { width: 14px; height: 14px; }

.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; scroll-snap-type: x proximity; }
.kanban-col {
  flex-shrink: 0; width: 258px; scroll-snap-align: start;
  background: linear-gradient(180deg, color-mix(in srgb, var(--col-color) 22%, var(--panel)) 0%, var(--panel) 260px);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; max-height: calc(100vh - 150px);
}
.kanban-col-head { padding: 16px 16px 14px; display: flex; align-items: center; justify-content: space-between; }
.kanban-col-head .title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.kanban-col-head .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 4px color-mix(in srgb, var(--col-color) 25%, transparent); }
.kanban-col-head .count { font-size: 11.5px; font-weight: 700; color: var(--col-color); background: color-mix(in srgb, var(--col-color) 18%, var(--panel)); padding: 3px 10px; border-radius: 999px; }
.kanban-cards { padding: 4px 12px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.kanban-card {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--col-color);
  border-radius: var(--radius-sm); padding: 14px 15px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease; min-height: 78px;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kanban-card .name { font-weight: 700; font-size: 14px; }
.kanban-card .time { font-size: 11px; color: var(--muted2); margin-top: 3px; }
.kanban-card .tags { display: flex; gap: 5px; margin-top: 10px; flex-wrap: wrap; }
.kanban-empty { padding: 30px 14px; text-align: center; color: var(--muted2); font-size: 12.5px; }
.sidebar .brand .logo {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar .brand .logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar .brand .name { font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; }

/* Logo light/dark swap: default (dark theme) shows the "dark background" variant, [data-theme="light"] swaps to the "light background" variant */
.logo-img-dark { display: block; }
.logo-img-light { display: none; }
[data-theme="light"] .logo-img-dark { display: none; }
[data-theme="light"] .logo-img-light { display: block; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sidebar nav::-webkit-scrollbar { width: 5px; }
.sidebar nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
/* menu groups (2026-10-07): Vender / Preparar / Canales / Reportes */
.sidebar .nav-group-title { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted2, var(--muted)); padding: 12px 12px 4px; opacity: .8; }
.sidebar .nav-group-title:first-child { padding-top: 0; }
.sidebar .nav-group-sep { height: 1px; background: var(--border); margin: 10px 8px 6px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background .15s ease, color .15s ease, transform .15s ease;
  border-left: 2px solid transparent;
}
.sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.sidebar nav a:hover { color: var(--text); background: var(--panel2); }
.sidebar nav a.active { color: var(--text); background: var(--accent2-soft); border-left: 2px solid var(--accent2); }
.sidebar .bottom { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.sidebar .bottom a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: var(--muted); font-size: 13px; font-weight: 500; border-radius: var(--radius-sm); transition: background .15s ease, color .15s ease; }
.sidebar .bottom a:hover { color: var(--text); background: var(--panel2); }
.sidebar .bottom a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
/* the person's menu (2026-10-07): Seguridad, theme, Cerrar sesión */
.user-menu-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: none; border-radius: 12px; background: transparent; color: inherit; cursor: pointer; text-align: left; font-family: inherit; }
.user-menu-btn:hover { background: var(--panel2); }
.user-menu-btn .um-av { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; background: var(--panel2); border: 1px solid var(--border); color: var(--text); }
.user-menu-btn .um-txt { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.user-menu-btn .um-txt b { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-btn .um-txt small { font-size: 11px; color: var(--muted); }
.user-menu-btn .um-caret { color: var(--muted); font-size: 11px; }
.user-menu-pop { position: fixed; z-index: 1000; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.35); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.user-menu-pop .um-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text); font-size: 13px; font-weight: 500; text-decoration: none; flex-wrap: wrap; }
.user-menu-pop a.um-item:hover { background: var(--panel2); }
.user-menu-pop .um-item svg { width: 16px; height: 16px; opacity: .85; }
.user-menu-pop .um-item small { width: 100%; padding-left: 26px; margin-top: -4px; font-size: 11px; color: var(--muted); font-weight: 400; }
.user-menu-pop .um-theme { justify-content: space-between; color: var(--muted); }
.user-menu-pop .um-danger { color: var(--danger); }

.main { flex: 1; min-width: 0; padding: 26px 34px 60px; max-width: 1280px; animation: fadeInUp .35s ease; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-header p { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }

.theme-toggle {
  display: flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; cursor: pointer; width: fit-content;
}
.theme-toggle button {
  border: none; background: transparent; color: var(--muted); padding: 6px 10px; border-radius: 999px;
  font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 5px; transition: all .15s ease;
}
.theme-toggle button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.theme-toggle svg { width: 14px; height: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
/* The main dashboard stats row has 4 cards (2026-10-07): one row on a computer, 2x2 on a tablet / phone (never a lone stretched card). */
#cards { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) {
  #cards { grid-template-columns: repeat(2, 1fr); }
}
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease;
  animation: fadeInUp .4s ease backwards;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card .value { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }
.card .delta { font-size: 12px; color: var(--accent); margin-top: 4px; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin-bottom: 22px; box-shadow: var(--shadow-sm); animation: fadeInUp .45s ease backwards;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 14px; color: var(--text); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.panel h2 svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .8; }
svg { width: 1em; height: 1em; }
.panel .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; display: flex; padding: 4px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--panel2); }
.icon-btn svg { width: 18px; height: 18px; }

.icon-refresh { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; cursor: pointer; color: var(--muted); display: flex; }
.icon-refresh:hover { color: var(--text); }
.icon-refresh svg { width: 15px; height: 15px; }

/* Shared date-range filter bar (Anuncios, Dashboard): a quick preset row plus two exact-date
   inputs so any page can filter its own stats "from one date to another". */
.filters-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.filters-bar select { width: auto; min-width: 170px; }
.filters-bar .spacer { flex: 1; }
.date-range-inputs { display: flex; align-items: center; gap: 6px; }
.date-range-inputs input[type=date] { width: auto; padding: 8px 10px; font-size: 12.5px; }
.range-quick { display: flex; gap: 6px; }
.range-quick button { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text); }
.range-quick button.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--panel2); }
tbody tr:last-child td { border-bottom: none; }

.btn {
  background: var(--accent2); color: white; border: none; border-radius: 9px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: transform .12s ease, opacity .15s ease, box-shadow .15s ease;
  box-shadow: 0 4px 14px -6px rgba(109,111,247,.5);
}
.btn:hover { transform: translateY(-1px); opacity: .95; }
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; }
.btn.secondary { background: var(--panel2); border: 1px solid var(--border); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--danger); box-shadow: 0 4px 14px -6px rgba(240,71,90,.5); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); box-shadow: none; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

input, textarea, select {
  width: 100%; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13.5px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px var(--accent2-soft); }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; margin-top: 14px; font-weight: 500; }
label:first-child { margin-top: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.on { background: var(--accent-soft); color: var(--accent); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.stage { background: var(--accent2-soft); color: var(--accent2); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.green { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.red { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.dot.gray { background: var(--muted2); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }

.chip { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; background: var(--panel3); color: var(--muted); margin: 2px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--panel3); border-radius: 999px; cursor: pointer; transition: background .2s ease; }
.switch .track:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track:before { transform: translateX(18px); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; opacity: .4; margin-bottom: 10px; }

.spinner { width: 16px; height: 16px; border: 2px solid var(--panel3); border-top-color: var(--accent2); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }

.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 16px; box-shadow: var(--shadow); font-size: 13.5px; display: flex; align-items: center; gap: 8px;
  animation: popIn .25s ease;
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--danger); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,7,12,.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 500;
  padding: 5vh 20px; overflow-y: auto; animation: fadeIn .18s ease;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 640px; box-shadow: var(--shadow); animation: popIn .22s cubic-bezier(.2,.9,.3,1.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--muted); background: none; border: none; font-size: 18px; padding: 4px; }
.modal-body { padding: 20px 22px; max-height: 65vh; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.section-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 20px 0 6px; }
.section-title:first-child { margin-top: 0; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(circle at 30% 20%, var(--accent2-soft), transparent 55%), var(--bg); }
.login-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 32px; width: 340px; box-shadow: var(--shadow); animation: popIn .3s ease; }
.login-logo { width: 190px; margin: 0 auto 18px; }
.login-logo img { width: 100%; height: auto; }
.login-box p { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; display: flex; align-items: center; gap: 6px; }

/* The whole chat page is locked to the viewport (no page/body-level scroll at all) so only
   the conversation list and the open thread's own messages scroll - the header, contact name
   and composer never move. See body.inbox-page below for the rest of this fill-height chain. */
html.inbox-page, body.inbox-page { height: 100%; overflow: hidden; }
body.inbox-page { display: flex; flex-direction: column; }
body.inbox-page .layout { flex: 1; min-height: 0; }
.inbox-main { max-width: none; padding: 20px 24px; display: flex; flex-direction: column; overflow: hidden; }
.inbox-page-header { flex-shrink: 0; }
.inbox-layout { display: flex; flex: 1; min-height: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); background: var(--panel); }
.conv-list { width: 320px; border-right: 1px solid var(--border); overflow-y: auto; background: var(--panel); flex-shrink: 0; }
.unassigned-toggle { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 600; cursor: pointer; border-bottom: 1px solid var(--border); }
.unassigned-toggle svg { width: 14px; height: 14px; }
.unassigned-list { border-bottom: 2px solid var(--border); max-height: 280px; overflow-y: auto; }
.unassigned-item { padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel2); }
.unassigned-item .preview { color: var(--muted); font-size: 12px; margin: 3px 0 8px; }
.assign-row { display: flex; gap: 6px; }
.assign-row select { font-size: 12px; padding: 6px 8px; }
.conv-list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.conv-list-head input { margin-bottom: 8px; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; background: var(--panel2); color: var(--muted); cursor: pointer; border: 1px solid transparent; transition: all .15s ease; }
.filter-chip.active { background: var(--accent2-soft); color: var(--accent2); border-color: var(--accent2); }
.conv-item { padding: 13px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s ease; position: relative; }
.conv-item:hover { background: var(--panel2); }
.conv-item.active { background: var(--accent2-soft); }
.conv-item.active:before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent2); }
.conv-item .conv-row { display: flex; gap: 10px; align-items: flex-start; }
.conv-item .conv-item-body { min-width: 0; flex: 1; }
.conv-item .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-item .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .time { font-size: 11px; color: var(--muted2); flex-shrink: 0; }
.conv-item .preview { color: var(--muted); font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .tags { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.conv-item .tags:not(:has(*)) { display: none; }
.conv-item .conv-sub { font-size: 11px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .conv-sub:empty { display: none; }
/* PENDIENTES row (Kanban, owner 2026-10-07): what needs a person right now; each card opens its chats */
.pending-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.pending-card { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; color: var(--text); font-family: inherit; cursor: default; min-width: 0; }
.pending-card.on { border-color: var(--warn); background: linear-gradient(0deg, var(--warn-soft), var(--warn-soft)), var(--panel); cursor: pointer; transition: transform .15s; }
.pending-card.on:hover { transform: translateY(-2px); }
.pending-card:disabled { opacity: .55; }
.pending-card .pc-ic { font-size: 22px; flex-shrink: 0; }
.pending-card .pc-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pending-card .pc-txt b { font-size: 20px; line-height: 1.1; }
.pending-card .pc-txt span { font-size: 12.5px; font-weight: 600; }
.pending-card .pc-txt small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending-card .pc-go { font-size: 12px; font-weight: 700; color: var(--warn); flex-shrink: 0; }
.pending-ok { font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.pending-list a { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.pending-list a:last-child { border-bottom: none; }
.pending-list .avatar { width: 32px; height: 32px; font-size: 11.5px; flex-shrink: 0; }
.pending-list .info { flex: 1; min-width: 0; }
.pending-list .name { font-size: 13px; font-weight: 600; }
.pending-list .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending-list .time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
@media (max-width: 1100px) { .pending-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .pending-row { gap: 10px; } .pending-card { padding: 10px 12px; gap: 9px; } .pending-card .pc-txt b { font-size: 17px; } .pending-card .pc-go { display: none; } }
/* small text buttons for secondary / dangerous actions, kept away from the main button (2026-10-07) */
.card-more { display: flex; gap: 14px; flex-wrap: wrap; }
.link-btn { background: none; border: none; padding: 4px 0; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-family: inherit; }
.link-btn svg { width: 13px; height: 13px; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.link-btn.danger-link:hover { color: var(--danger); }   /* no label to show (2026-10-07: "IA activa" is not shown any more, only the exceptions) */
/* Small colored dot identifying which WhatsApp number a conversation came in on - color is
   set per-number in Numeros, shown here without a text label to keep the list uncluttered. */
.num-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: middle; flex-shrink: 0; }

.thread { flex: 1; display: flex; flex-direction: column; background: var(--bg-soft); min-width: 0; position: relative; }
.thread-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--panel); }
.thread-header .who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--accent2), var(--accent)); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 14px; flex-shrink: 0; }
.thread-header .meta { display: flex; align-items: center; gap: 6px; }
.ai-toggle-wrap { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.thread-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.date-sep { text-align: center; color: var(--muted2); font-size: 11px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.msg-row { display: flex; margin-bottom: 4px; animation: fadeInUp .2s ease; }
.msg-row.out { justify-content: flex-end; }
.msg { max-width: 62%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.4; box-shadow: var(--shadow-sm); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; }
.msg.in { background: var(--panel); border-bottom-left-radius: 4px; }
.msg.out { background: var(--accent2); color: #fff; border-bottom-right-radius: 4px; }
.msg .mtime { display: block; font-size: 10px; opacity: .6; margin-top: 4px; text-align: right; }
.msg .src-tag { display: flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; opacity: .9; margin-bottom: 4px; }
.msg .src-tag svg { width: 10px; height: 10px; }
.msg.out .src-tag.bot { color: #d7ffe6; }
.msg.out .src-tag.followup { color: #ffe9b3; }
.msg.out .src-tag.mobile { color: #cdeaff; }
.msg.out .src-tag.web { color: #e3d9ff; }   /* "web", not "panel": .panel is the big card style of the whole app */
.msg .media-tag { display: flex; align-items: center; gap: 6px; font-style: italic; opacity: .85; }
.msg .voice-transcript { margin-top: 4px; }
.msg .btn-msg-tag { display: flex; align-items: center; gap: 6px; }
.thread-input { padding: 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: var(--panel); align-items: flex-end; }
.thread-input input { flex: 1; }
.thread-input textarea { flex: 1; resize: none; max-height: 120px; line-height: 1.35; overflow-y: auto; }
.thread-empty { margin: auto; text-align: center; color: var(--muted); }
.thread-empty svg { width: 44px; height: 44px; opacity: .35; margin-bottom: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* Wrap any table that can get wide (many columns, or long content) in this so it scrolls on
   its own on a narrow screen instead of forcing the whole page wider than the viewport. */
.table-scroll { overflow-x: auto; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.product-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); transition: transform .16s ease, box-shadow .16s ease;
  animation: fadeInUp .35s ease backwards; cursor: pointer;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent2); }
.product-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.product-card .icon { width: 38px; height: 38px; border-radius: 10px; background: var(--accent2-soft); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.product-card h3 { margin: 12px 0 4px; font-size: 15px; }
.product-card .method { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.add-card {
  border: 2px dashed var(--border); border-radius: var(--radius); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: var(--muted); cursor: pointer; min-height: 160px;
  transition: all .15s ease;
}
.add-card:hover { border-color: var(--accent2); color: var(--accent2); background: var(--accent2-soft); }
.add-card svg { width: 26px; height: 26px; }

.integration-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 18px; animation: fadeInUp .35s ease backwards; }
.integration-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.integration-head .left { display: flex; align-items: center; gap: 14px; }
.integration-logo { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; font-size: 15px; }
.integration-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.integration-body { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.key-input-wrap { position: relative; }
.key-input-wrap button { position: absolute; right: 6px; top: 6px; background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px 8px; font-size: 11px; }

.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.back-to-list-btn { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: 4px; margin-right: 6px; flex-shrink: 0; }
.back-to-list-btn svg { width: 20px; height: 20px; }

@media (max-width: 860px) {
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px;
    height: 56px; box-sizing: border-box;
    background: var(--panel); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-topbar .mt-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
  .mobile-topbar .hamburger-btn { background: none; border: none; color: var(--text); cursor: pointer; padding: 4px; display: flex; flex-shrink: 0; }
  .mobile-topbar .hamburger-btn svg { width: 22px; height: 22px; }
  .mobile-topbar .mt-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-topbar .notif-btn { flex-shrink: 0; }

  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; z-index: 55;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .main { padding: 18px; }
  .integration-body, .form-grid { grid-template-columns: 1fr; }
  /* phone (2026-10-07): numbers 2 per row and smaller, so the money is seen without scrolling a long column of big cards */
  #cards, .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
  .card { padding: 13px 14px; }
  .card .label { font-size: 10.5px; letter-spacing: .04em; }
  .card .label svg { display: none; }
  .card .value { font-size: 21px; margin-top: 6px; overflow-wrap: anywhere; }
  .card .delta { font-size: 11px; }
  /* the quick date buttons slide sideways in one row instead of being cut */
  .range-quick { flex-wrap: nowrap; overflow-x: auto; width: 100%; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .range-quick::-webkit-scrollbar { display: none; }
  .range-quick button { flex-shrink: 0; white-space: nowrap; }
  .filters-bar .date-range-inputs { width: 100%; }
  /* the filters wrap 2 per row instead of being squeezed into a bare arrow */
  .filters-bar select { flex: 1 1 150px; min-width: 0; }
  .filters-bar .spacer { display: none; }

  /* Chats: use the full device screen instead of sitting inside a bordered, padded card -
     drop the page's own header (the mobile topbar above already shows "Chats") and the
     boxed-card look, and show either the conversation list or the open thread, never both. */
  .inbox-main { padding: 0; }
  .inbox-page-header { display: none; }
  .inbox-layout {
    position: relative;
    border: none; border-radius: 0; box-shadow: none;
  }
  .conv-list { width: 100%; }
  .thread { position: absolute; inset: 0; z-index: 2; }
  .inbox-layout:not(.show-thread) .thread { display: none; }
  .inbox-layout.show-thread .conv-list { display: none; }
  .inbox-layout.show-thread .back-to-list-btn { display: inline-flex; }

  /* Keep the back button, avatar/name and the action icons (automation, AI switch, more) all
     on the SAME row, actions flush to the right - same arrangement as desktop. The phone
     number and tags can still wrap onto extra lines below the name (there just isn't room for
     them next to 3 icons + a switch on a phone screen without squeezing the name unreadably),
     so align everything to the TOP of the row instead of centering against that taller block -
     otherwise the back arrow and icons drift toward the middle of a 3-4 line name column. */
  .thread-header { flex-wrap: nowrap; justify-content: flex-start; align-items: flex-start; }
  .back-to-list-btn { margin-top: 8px; }
  .thread-header .who { min-width: 0; flex: 1 1 auto; }
  .thread-header .who .avatar + div { min-width: 0; flex: 1; }
  .thread-header .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-actions { flex-shrink: 0; gap: 6px; margin-top: 8px; }
  /* Already reachable via the "..." menu's "Atribuir a" entry - hiding the standalone icon
     here frees up room so the name doesn't get squeezed to a couple of letters. */
  #escalate-btn { display: none; }
}

/* ---------- Shared filter panel (Chats + Contactos): trigger button, floating panel, segmented control, dropdowns and active-filter pills ---------- */
.filters-btn .fcount { background: var(--accent2); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; line-height: 16px; }
.filters-btn.has-filters { border-color: var(--accent2); }
.fp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.fp-head strong { font-size: 13px; }
.fp-clear { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 4px 10px; font-size: 11.5px; cursor: pointer; font-family: inherit; }
.fp-clear:hover { color: var(--danger); border-color: var(--danger); }
.seg { display: flex; gap: 2px; padding: 2px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; }
.seg-btn { flex: 1; padding: 6px 4px; font-size: 12px; border: none; background: none; color: var(--muted); border-radius: 7px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent2-soft); color: var(--accent2); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent2); }
.seg-btn .n { opacity: .7; font-size: 10.5px; margin-left: 4px; }
.fp-select { padding: 8px 10px; font-size: 12.5px; text-overflow: ellipsis; cursor: pointer; }
.fp-select.active { border-color: var(--accent2); background: var(--accent2-soft); color: var(--accent2); font-weight: 600; }
.fp-select option { background: var(--panel); color: var(--text); font-weight: 400; }
.fp-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fp-grid2 > div { min-width: 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.active-filters[hidden] { display: none; }
.af-pill { display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 10px; border-radius: 999px; font-size: 11.5px; background: var(--accent2-soft); color: var(--accent2); border: 1px solid var(--accent2); max-width: 100%; }
.af-pill button { background: none; border: none; color: inherit; cursor: pointer; padding: 0 6px; font-size: 14px; line-height: 1; border-radius: 50%; }
.af-pill button:hover { background: var(--accent2); color: #fff; }
.af-clear { background: none; border: none; color: var(--muted); font-size: 11.5px; text-decoration: underline; cursor: pointer; padding: 3px 4px; font-family: inherit; }
.af-clear:hover { color: var(--danger); }
.filters-btn { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel2); font-size: 12.5px; color: var(--text); cursor: pointer; }
.filters-btn svg { width: 13px; height: 13px; }
/* The panel lives inside the sticky search bar and floats over the chat list (absolute, right
   under the bar) instead of sitting at the top of the scrolling list - so it opens in view no
   matter how far down the list is scrolled, and never shifts or scrolls the chats underneath. */
.filters-panel { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 3; padding: 12px 14px; background: var(--panel); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); max-height: min(70vh, 540px); overflow-y: auto; }
.filters-panel.open { display: block; }
.fp-actions { display: flex; align-items: center; gap: 8px; }
.fp-close { background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 6px; }
.fp-close:hover { color: var(--text); background: var(--panel2); }
.filters-panel .group { margin-bottom: 8px; }
.filters-panel .label { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; margin-bottom: 5px; }
