/* ============================================================
   CRM E-mpact / Pressence — UI con theming por marca
   ============================================================ */
:root {
  color-scheme: light;

  /* === Default (Todas) - estilo neutral === */
  --sidebar:        #0f1322;
  --sidebar-2:      #1a2038;
  --sidebar-hover:  #232a48;
  --sidebar-text:   #b4bcd0;
  --sidebar-muted:  #6c7693;

  --primary:        #5d3df5;
  --primary-2:      #4a2fd9;
  --primary-soft:   #efeaff;
  --primary-rgb:    93,61,245;
  --accent:         #f5a623;

  --bg:             #f6f8fa;
  --card:           #ffffff;
  --border:         #e3e8ee;
  --border-2:       #eef2f6;
  --text:           #0f1322;
  --text-2:         #4f566b;
  --muted:          #8792a2;
  --gray-soft:      #f1f3f7;

  --green:          #3fb37f;
  --green-soft:     #e3f5ec;
  --yellow:         #f5a623;
  --yellow-soft:    #fff5e1;
  --red:            #e25950;
  --red-soft:       #fce6e4;
  --blue:           #3997ff;
  --blue-soft:      #e1efff;
  --purple:         #8a64f8;
  --purple-soft:    #ede5ff;

  --font-head:      "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:      "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-sm:      0 1px 2px rgba(15,19,34,0.06);
  --shadow-md:      0 4px 12px rgba(15,19,34,0.08);
  --shadow-lg:      0 12px 28px rgba(15,19,34,0.10);
}

/* === E-mpact theme — exact colors from e-mpact.es: black #0D0D0D + lime #E5F975 === */
[data-theme="e-mpact"] {
  --sidebar:        #0D0D0D;
  --sidebar-2:      #121212;
  --sidebar-hover:  #1c1c1c;
  --sidebar-text:   #e8e8e8;
  --sidebar-muted:  #828282;

  --primary:        #E5F975;
  --primary-2:      #d4ec4f;
  --primary-soft:   #f7fde0;
  --primary-rgb:    229,249,117;
  --accent:         #0D0D0D;

  --bg:             #f3f3f3;
  --card:           #ffffff;
  --text:           #0D0D0D;
  --text-2:         #404040;
  --muted:          #828282;
  --border:         #e1e1e1;
  --border-2:       #ededed;
  --font-head:      "Manrope", "Inter", sans-serif;
  --font-body:      "Inter", sans-serif;
}
[data-theme="e-mpact"] body { letter-spacing: -0.01em; }
[data-theme="e-mpact"] h1, [data-theme="e-mpact"] h2, [data-theme="e-mpact"] h3 { font-weight: 800; letter-spacing: -0.025em; }
[data-theme="e-mpact"] .btn-primary {
  background: #0D0D0D; color: #E5F975;
  border-radius: 6px; text-transform: uppercase; letter-spacing: 0.04em; font-size: 12px;
  box-shadow: 0 2px 5px rgba(13,13,13,0.25);
}
[data-theme="e-mpact"] .btn-primary:hover { background: #E5F975; color: #0D0D0D; }
[data-theme="e-mpact"] .topbar-brand-tag { background: #0D0D0D; color: #E5F975; border-radius: 4px; font-weight: 700; }
[data-theme="e-mpact"] .kpi-card, [data-theme="e-mpact"] .chart-card, [data-theme="e-mpact"] .table-card { border-radius: 10px; }
[data-theme="e-mpact"] .kpi-value { font-weight: 800; color: #0D0D0D; }
[data-theme="e-mpact"] .sidebar-logo img { filter: none; max-width: 60px; max-height: 60px; }
[data-theme="e-mpact"] .sidebar { border-right: 3px solid #E5F975; }
[data-theme="e-mpact"] .nav-item.active {
  background: #E5F975; color: #0D0D0D;
  box-shadow: 0 4px 12px rgba(229,249,117,0.3);
}
[data-theme="e-mpact"] .kanban-col-head { border-top-color: #E5F975 !important; }
[data-theme="e-mpact"] .progress > div { background: #0D0D0D; }
[data-theme="e-mpact"] .stage-pill.active { background: #0D0D0D; border-color: #0D0D0D; color: #E5F975; }
[data-theme="e-mpact"] .kpi-label .icon-circle { background: #E5F975 !important; color: #0D0D0D !important; }
[data-theme="e-mpact"] .ct-tab.active { background: #0D0D0D; color: #E5F975; box-shadow: 0 2px 6px rgba(13,13,13,0.3); }
/* En E-mpact, texto lime sobre lime-soft NO se lee: forzar texto negro en backgrounds primary-soft */
[data-theme="e-mpact"] .topbar-brand-tag { background: #0D0D0D; color: #E5F975; }
[data-theme="e-mpact"] .chip-pendiente,
[data-theme="e-mpact"] .chip-pagada { color: #0D0D0D; font-weight: 700; }
[data-theme="e-mpact"] [style*="background:var(--primary-soft)"][style*="color:var(--primary)"] { color: #0D0D0D !important; }
[data-theme="e-mpact"] .auto-toggle.on { background: #E5F975; color: #0D0D0D; box-shadow: 0 2px 6px rgba(229,249,117,0.5); }

/* === Pressence theme — black #000 + lavender #9EAFEF + deep navy #132C6D === */
[data-theme="pressence"] {
  --sidebar:        #000000;
  --sidebar-2:      #0a0a0a;
  --sidebar-hover:  #1a1a1a;
  --sidebar-text:   #d4d4d4;
  --sidebar-muted:  #7a7a7a;

  --primary:        #132C6D;
  --primary-2:      #0a1c4c;
  --primary-soft:   #e3e8f5;
  --primary-rgb:    19,44,109;
  --accent:         #9EAFEF;

  --bg:             #f8f8fa;
  --card:           #ffffff;
  --text:           #0a0a0a;
  --text-2:         #404040;
  --muted:          #8a8a8a;
  --border:         #e5e5e8;
  --border-2:       #efeff2;
  --font-head:      "Cormorant Garamond", "Playfair Display", Georgia, serif;
  --font-body:      "Inter", sans-serif;
}
[data-theme="pressence"] h1, [data-theme="pressence"] h2, [data-theme="pressence"] h3 {
  font-family: var(--font-head); font-weight: 500; letter-spacing: 0;
}
[data-theme="pressence"] .page-header h2 { font-size: 32px; font-weight: 500; }
[data-theme="pressence"] .kpi-value { font-family: var(--font-head); font-weight: 500; font-size: 30px; letter-spacing: -0.01em; }
[data-theme="pressence"] .topbar-title { font-family: var(--font-head); font-weight: 500; }
[data-theme="pressence"] .btn-primary {
  background: #132C6D; color: white; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; font-weight: 600;
}
[data-theme="pressence"] .btn-primary:hover { background: #9EAFEF; color: #132C6D; }
[data-theme="pressence"] .topbar-brand-tag {
  background: #132C6D; color: white; border-radius: 4px; letter-spacing: 0.1em;
}
[data-theme="pressence"] .kpi-card, [data-theme="pressence"] .chart-card, [data-theme="pressence"] .table-card { border-radius: 4px; }
[data-theme="pressence"] .sidebar-logo img { filter: brightness(0) invert(1); max-width: 56px; max-height: 38px; }
[data-theme="pressence"] .nav-item.active { background: #9EAFEF; color: #132C6D; box-shadow: 0 4px 12px rgba(158,175,239,0.4); }
[data-theme="pressence"] .sidebar { border-right: 2px solid #9EAFEF; }
[data-theme="pressence"] .kpi-label .icon-circle { background: #e3e8f5 !important; color: #132C6D !important; }
[data-theme="pressence"] .progress > div { background: #132C6D; }
[data-theme="pressence"] .ct-tab.active { background: #132C6D; color: white; }
[data-theme="pressence"] .stage-pill.active { background: #132C6D; border-color: #132C6D; color: white; }

/* === DARK MODE === */
[data-mode="dark"] {
  --sidebar:        #0a0a0a;
  --sidebar-2:      #141414;
  --sidebar-hover:  #1f1f1f;
  --sidebar-text:   #d4d4d4;
  --sidebar-muted:  #7a7a7a;

  --bg:             #0d0f14;
  --card:           #15181f;
  --border:         #262a35;
  --border-2:       #1c2029;
  --text:           #f1f5f9;
  --text-2:         #b4bcd0;
  --muted:          #6b7280;
  --gray-soft:      #1c2029;

  --primary-soft:   rgba(93,61,245,0.18);
  --green-soft:     rgba(63,179,127,0.15);
  --yellow-soft:    rgba(245,166,35,0.15);
  --red-soft:       rgba(226,89,80,0.15);
  --blue-soft:      rgba(57,151,255,0.15);
  --purple-soft:    rgba(138,100,248,0.18);
}
[data-mode="dark"][data-theme="e-mpact"] {
  --bg:             #0a0a0a;
  --card:           #15151a;
  --border:         #2a2a32;
  --border-2:       #1f1f25;
  --primary-soft:   rgba(229,249,117,0.18);
}
[data-mode="dark"][data-theme="pressence"] {
  --bg:             #0a0c14;
  --card:           #14171f;
  --border:         #2a2f3d;
  --border-2:       #1d2230;
  --primary-soft:   rgba(158,175,239,0.18);
}
[data-mode="dark"] body { color-scheme: dark; }
[data-mode="dark"] thead th { background: #1a1d26; color: var(--muted); }
[data-mode="dark"] tbody tr:hover td { background: #1c2029; }
[data-mode="dark"] .table-toolbar { background: #1a1d26; }
[data-mode="dark"] .topbar-search input { background: #1a1d26; }
[data-mode="dark"] .topbar-search input:focus { background: #1f2330; }
[data-mode="dark"] .btn-secondary { background: #1c2029; color: var(--text); border-color: var(--border); }
[data-mode="dark"] .btn-secondary:hover { background: #262a35; }
[data-mode="dark"] .form-row input, [data-mode="dark"] .form-row select, [data-mode="dark"] .form-row textarea,
[data-mode="dark"] .pipeline-toolbar input, [data-mode="dark"] .pipeline-toolbar select,
[data-mode="dark"] .table-toolbar input, [data-mode="dark"] .table-toolbar select {
  background: #1a1d26; color: var(--text); border-color: var(--border);
}
[data-mode="dark"] .modal { background: #15181f; }
[data-mode="dark"] .kanban-col { background: #15181f; }
[data-mode="dark"] .kanban-col-head { background: transparent; }
[data-mode="dark"] .kcard { background: #1c2029; border-color: var(--border); }
[data-mode="dark"] .kcard:hover { background: #1f2330; }
[data-mode="dark"] .inv-folder-head, [data-mode="dark"] .inv-folder-totals { background: #1a1d26; }
[data-mode="dark"] .inv-folder-head:hover { background: #1f2330; }
/* Invoice doc ALWAYS uses light theme (printable document) */
[data-mode="dark"] .invoice-doc { background: white !important; color: #1a1a1a !important; }
[data-mode="dark"] .invoice-doc table.lines th { background: #1a1a1a !important; color: white !important; }
[data-mode="dark"] .invoice-doc .head .num,
[data-mode="dark"] .invoice-doc .head .num-label,
[data-mode="dark"] .invoice-doc .head .issuer .name,
[data-mode="dark"] .invoice-doc .party .pname,
[data-mode="dark"] .invoice-doc .party h5,
[data-mode="dark"] .invoice-doc table.lines td,
[data-mode="dark"] .invoice-doc .totals-block td,
[data-mode="dark"] .invoice-doc .totals-block td.value,
[data-mode="dark"] .invoice-doc .footer-note h5,
[data-mode="dark"] .invoice-doc .dates strong { color: #1a1a1a !important; }
[data-mode="dark"] .invoice-doc .head .issuer .line,
[data-mode="dark"] .invoice-doc .party .pline,
[data-mode="dark"] .invoice-doc .dates,
[data-mode="dark"] .invoice-doc .totals-block td.label,
[data-mode="dark"] .invoice-doc .footer-note { color: #555 !important; }
[data-mode="dark"] .invoice-doc .totals-block tr.total td,
[data-mode="dark"] .invoice-doc .totals-block tr.total td.value { color: white !important; background: #1a1a1a !important; }
[data-mode="dark"] .invoice-doc .totals-block tr.due td,
[data-mode="dark"] .invoice-doc .totals-block tr.due td.label,
[data-mode="dark"] .invoice-doc .totals-block tr.due td.value { color: #c1372f !important; background: #fff5f5 !important; font-weight: 700 !important; }
[data-mode="dark"] .invoice-doc .recurrente-badge { background: #1a1a1a !important; color: white !important; }
[data-mode="dark"] .modal-close { background: #1c2029; color: var(--text-2); }
[data-mode="dark"] .modal-close:hover { background: #262a35; color: var(--text); }
[data-mode="dark"] .stage-pill { background: #1c2029; border-color: var(--border); color: var(--text-2); }
[data-mode="dark"] .empresa-pill.active { background: var(--card); color: var(--text); }
[data-mode="dark"] .ct-tab { color: var(--text); }
[data-mode="dark"] .ct-tab:not(.active):hover { background: #1c2029; color: var(--text); }
[data-mode="dark"] .contract-tabs { background: var(--card); }
[data-mode="dark"] .kpi-card:hover { border-color: #3a3f4f; }
[data-mode="dark"] .cobros-grid { background: var(--card); border-color: var(--border); }
[data-mode="dark"] .cobros-grid > div { background: transparent; border-color: var(--border-2); }
[data-mode="dark"] .cobros-grid .ch { background: #15181f; border-bottom-color: var(--border); }
[data-mode="dark"] .cobros-grid .total-cell { background: #15181f; }
[data-mode="dark"] .cobros-grid .cobro.c-no { color: #2a2f3e; }
[data-mode="dark"] .cobros-grid .cobro.c-nofact { background: #15181f; }
[data-mode="dark"] .cobros-grid .cobro.c-cobrado { background: linear-gradient(135deg, rgba(63,179,127,.18), rgba(63,179,127,.08)); color: #5dd0a2; box-shadow: inset 0 0 0 1px rgba(63,179,127,.25); }
[data-mode="dark"] .cobros-grid .cobro.c-pendiente { background: linear-gradient(135deg, rgba(245,166,35,.18), rgba(245,166,35,.08)); color: #f5c569; box-shadow: inset 0 0 0 1px rgba(245,166,35,.25); }
[data-mode="dark"] .cobros-grid .cobro.c-parcial { background: linear-gradient(90deg, rgba(63,179,127,.18) 50%, rgba(245,166,35,.18) 50%); color: #f5c569; box-shadow: inset 0 0 0 1px rgba(245,166,35,.25); }
[data-mode="dark"] .margen-bar-wrap { background: rgba(255,255,255,.08); }
[data-mode="dark"] .oneshot-card { background: #15181f; }
[data-mode="dark"] .oneshot-head { background: linear-gradient(to bottom, #1a1d26, #15181f); }
[data-mode="dark"] .oneshot-hito.h-empty { background: #1c2029; border-color: var(--border); }
[data-mode="dark"] .oneshot-hito.h-nofact { background: #1a1d26; }
[data-mode="dark"] .inbox-list { background: #15181f; }
[data-mode="dark"] .inbox-list-head { background: #1a1d26; }
[data-mode="dark"] .inbox-msg.unread { background: #15181f; }
[data-mode="dark"] .inbox-msg:hover { background: #1c2029; }
[data-mode="dark"] .inbox-msg.active { background: var(--primary-soft); }
[data-mode="dark"] .inbox-detail { background: #15181f; }
[data-mode="dark"] .inbox-detail-head, [data-mode="dark"] .inbox-detail-actions { background: transparent; }
[data-mode="dark"] .progress { background: #2a2a32; }
[data-mode="dark"] .auto-toggle { background: #2a2a32; }
[data-mode="dark"] .toast { background: white; color: #0d0f14; }
[data-mode="dark"] .chip-borrador, [data-mode="dark"] .chip-empty { background: #1c2029; color: var(--text-2); border: 1px solid var(--border); }

/* Dark mode — fixes adicionales para legibilidad */
[data-mode="dark"] .chart-card, [data-mode="dark"] .kpi-card, [data-mode="dark"] .table-card,
[data-mode="dark"] .channel-card, [data-mode="dark"] .pipeline-toolbar {
  background: var(--card);
}
[data-mode="dark"] .pipeline-toolbar input, [data-mode="dark"] .pipeline-toolbar select {
  background: #1a1d26; color: var(--text); border-color: var(--border);
}
[data-mode="dark"] .pipeline-toolbar .stat .val { color: var(--text); }
[data-mode="dark"] .inbox-msg .from, [data-mode="dark"] .inbox-msg .subject { color: var(--text); }
[data-mode="dark"] .inbox-msg .preview, [data-mode="dark"] .inbox-msg .date { color: var(--text-2); }
[data-mode="dark"] .inbox-detail-body { color: var(--text); }
[data-mode="dark"] .kpi-value, [data-mode="dark"] .channel-roi-val, [data-mode="dark"] .channel-name,
[data-mode="dark"] .topbar-title, [data-mode="dark"] .page-header h2 { color: var(--text); }
[data-mode="dark"] .topbar { background: var(--card); }
/* (Invoice doc dark-mode overrides moved above — always uses light theme) */
[data-mode="dark"] .invoice-row.active { background: rgba(var(--primary-rgb),0.22); }
[data-mode="dark"] .invoice-row { background: transparent; }
[data-mode="dark"] .invoice-row:hover { background: #1c2029; }
[data-mode="dark"] .invoice-row .num { color: var(--text); }
[data-mode="dark"] .invoice-row .who, [data-mode="dark"] .invoice-row .amt { color: var(--text); }
[data-mode="dark"] .invoice-sidebar-head { background: #1a1d26; border-color: var(--border-2); }
[data-mode="dark"] .invoice-preview, [data-mode="dark"] .invoice-sidebar { background: var(--card); }
[data-mode="dark"] .invoice-preview .actions { background: #1a1d26; }
[data-mode="dark"] .modal h3 { color: var(--text); }
[data-mode="dark"] .form-row label { color: var(--text-2); }
[data-mode="dark"] tbody td, [data-mode="dark"] tbody td.bold { color: var(--text); }
[data-mode="dark"] tbody td.muted { color: var(--text-2); }
[data-mode="dark"] .table-footer { background: #1a1d26; border-color: var(--border); }
[data-mode="dark"] .channel-stats .cs-val { color: var(--text); }
[data-mode="dark"] .kanban-col-head { border-color: var(--border-2); }
[data-mode="dark"] .empresa-pill { background: var(--sidebar-2); }
[data-mode="dark"] .pipeline-toolbar .stat { border-color: var(--border); }
[data-mode="dark"] datalist option { background: var(--card); color: var(--text); }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  color-scheme: light; background: var(--bg);
  transition: background .25s ease, color .25s ease;
}
body {
  font-family: var(--font-body);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}
h1, h2, h3, h4 { font-family: var(--font-head); }
[data-theme="pressence"] h2 { font-weight: 600; letter-spacing: 0; }

/* ===================== Layout ===================== */
.app { display: flex; min-height: 100vh; padding: 14px; gap: 14px; }

/* ===================== Sidebar — flotante con bordes redondos ===================== */
.sidebar {
  width: 78px;
  background: var(--sidebar);
  display: flex; flex-direction: column;
  position: sticky; top: 14px; height: calc(100vh - 28px);
  flex-shrink: 0;
  transition: background .25s ease;
  border-radius: 22px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-hover); border-radius: 2px; }
.sidebar-logo {
  display: flex; align-items: center; justify-content: center;
  height: 64px; border-bottom: 1px solid var(--sidebar-2);
  padding: 14px;
}
.sidebar-logo img {
  max-width: 50px; max-height: 50px;
  transition: filter .25s ease;
}
[data-theme="pressence"] .sidebar-logo img { filter: brightness(0) invert(1); }
.sidebar-logo .logo-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), rgba(255,255,255,0.3));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 18px;
}

.sidebar-nav { padding: 14px 8px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 11px 4px; border-radius: 14px;
  cursor: pointer; color: var(--sidebar-text);
  transition: all .15s ease; gap: 4px;
  font-size: 10px; font-weight: 500;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active {
  background: var(--primary); color: white;
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}
.nav-item svg { width: 22px; height: 22px; }

.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid var(--sidebar-2);
  display: flex; flex-direction: column; gap: 6px;
}
.empresa-pill {
  font-size: 9px; padding: 6px 4px; border-radius: 8px;
  background: var(--sidebar-2); color: var(--sidebar-text);
  text-align: center; cursor: pointer; font-weight: 700;
  border: 1px solid transparent; transition: all .15s ease;
  letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.empresa-pill:hover { background: var(--sidebar-hover); color: white; }
.empresa-pill.active {
  background: white; color: var(--text);
  border-color: rgba(255,255,255,0.15);
}

/* ===================== Main ===================== */
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.06);
  overflow: hidden;
}

/* Top bar */
.topbar {
  height: 64px; background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 10;
}
.topbar-title {
  font-size: 19px; font-weight: 700; color: var(--text);
  font-family: var(--font-head); letter-spacing: -0.01em;
}
.topbar-search {
  flex: 1; max-width: 460px; position: relative;
}
.topbar-search input {
  width: 100%; padding: 10px 14px 10px 38px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); font-size: 13px; color: var(--text);
  outline: none; transition: all .15s ease; font-family: inherit;
}
.topbar-search input:focus {
  background: white; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb),0.12);
}
.topbar-search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted);
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-brand-tag {
  font-size: 11px; padding: 5px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Page content */
.page { padding: 24px 28px 40px; flex: 1; overflow-x: hidden; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 22px; gap: 18px;
}
.page-header h2 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-header .sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }

.section { display: none; animation: fade .2s ease; }
.section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ===================== Buttons ===================== */
.btn {
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 13px; cursor: pointer;
  transition: all .15s ease; display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary); color: white;
  box-shadow: 0 2px 5px rgba(var(--primary-rgb),0.25);
}
.btn-primary:hover {
  background: var(--primary-2);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb),0.35);
}
.btn-secondary { background: white; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--muted); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { filter: brightness(0.95); }
.btn-danger  { background: var(--red);  color: white; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--gray-soft); }
.btn svg { width: 14px; height: 14px; }

/* ===================== KPI Cards ===================== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 22px;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px 20px;
  transition: all .15s ease; box-shadow: var(--shadow-sm);
}
.kpi-card:hover { box-shadow: var(--shadow-md); border-color: #d4dae3; }
.kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); font-weight: 600; margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.kpi-label .icon-circle {
  width: 26px; height: 26px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
}
.kpi-label .icon-circle svg { width: 13px; height: 13px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.15; letter-spacing: -0.02em; font-family: var(--font-head); }
.kpi-meta { font-size: 12px; color: var(--text-2); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-meta .up   { color: var(--green); font-weight: 600; }
.kpi-meta .down { color: var(--red);   font-weight: 600; }
.progress { height: 6px; background: var(--gray-soft); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* ===================== Charts ===================== */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart-grid.equal { grid-template-columns: 1fr 1fr; }
.chart-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  margin: 0 0 16px; font-size: 14px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-head);
}
.chart-card h3 .meta { color: var(--muted); font-weight: 500; font-size: 11px; }
.chart-wrap { position: relative; height: 280px; }

/* ===================== Pipeline / Kanban ===================== */
.pipeline-toolbar {
  display: flex; align-items: center; gap: 10px;
  background: white; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.pipeline-toolbar .stat {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-2); padding: 4px 14px;
  border-right: 1px solid var(--border);
}
.pipeline-toolbar .stat:last-of-type { border-right: none; }
.pipeline-toolbar .stat .label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.pipeline-toolbar .stat .val   { color: var(--text); font-weight: 700; font-size: 15px; font-family: var(--font-head); }
.pipeline-toolbar .spacer { flex: 1; }
.pipeline-toolbar select, .pipeline-toolbar input {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; background: white; color: var(--text); font-family: inherit;
}
.pipeline-toolbar input { min-width: 240px; }
.pipeline-toolbar input:focus, .pipeline-toolbar select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.12);
}

.kanban {
  display: flex; gap: 12px; overflow-x: auto;
  padding-bottom: 12px; align-items: flex-start; min-height: 60vh;
}
.kanban-col {
  flex: 0 0 290px; width: 290px; min-width: 290px; max-width: 290px;
  background: var(--card);
  border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 280px); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kanban-col-head { padding: 14px 14px 12px; border-bottom: 1px solid var(--border-2); }
.kanban-col-head .title-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.kanban-col-head .title {
  font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.kanban-col-head .count {
  background: var(--gray-soft); padding: 2px 9px; border-radius: 999px;
  font-size: 11px; color: var(--text-2); font-weight: 600;
}
.kanban-col-head .subtitle { color: var(--muted); font-size: 12px; font-weight: 500; }
.kanban-cards { overflow-y: auto; flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.kanban-cards.empty-col { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; min-height: 80px; }

.kcard {
  background: white; border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 13px 11px; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
  position: relative; overflow: hidden;
  width: 100%; box-sizing: border-box; min-width: 0;
  /* Altura consistente: todas las cards activas miden lo mismo, layout uniforme */
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kcard .cliente { font-size: 14px !important; font-weight: 700; }
.kcard .lead-id { font-size: 11px; }
.kcard .bottom-row { margin-top: auto; }
.kcard:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kcard.kcard-kb-focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary), var(--shadow-md); }
.kcard::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--border);
  border-radius: 11px 0 0 11px;
}
.kcard:hover::before { background: var(--primary); }
.kcard.kcard-warn::before { background: var(--yellow); }
.kcard.kcard-urgent::before { background: var(--red); }
.kcard.kcard-snoozed { opacity: 0.55; }

/* ===== Columnas colapsables ===== */
.kanban-col.collapsed {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  cursor: pointer;
}
.kanban-col.collapsed .kanban-cards { display: none; }
.kanban-col.collapsed .kanban-col-head {
  padding: 12px 6px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}
.kanban-col.collapsed .kanban-col-head .title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kanban-col.collapsed .kanban-col-head .title-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.kanban-col.collapsed .kanban-col-head .subtitle { display: none; }
.kanban-col.collapsed .col-drag-handle { display: none; }
.kanban-col.collapsed .col-collapse-btn { transform: rotate(180deg); }

.col-collapse-btn {
  background: transparent;
  border: 1px solid var(--border-2);
  width: 22px; height: 22px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background .12s, color .12s;
  padding: 0;
  flex-shrink: 0;
}
.col-collapse-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.kanban-col.collapsed .col-collapse-btn { margin: 0; }

/* Bulk-select checkbox: en bulk mode solo visible al hover (o si ya está marcado) */
.kcard-bulk {
  position: absolute; top: 6px; left: 6px; z-index: 4;
  opacity: 0;
  transition: opacity .12s ease;
}
.kcard-bulk input[type="checkbox"] {
  width: 14px; height: 14px; cursor: pointer;
  accent-color: var(--primary);
}
.kcard:hover .kcard-bulk,
.kcard-bulk.is-checked { opacity: 1; }
/* Si la card tiene la check marcada, ocultar el lead-id detrás del checkbox para que no choque */
.kcard.is-bulk-checked .lead-id { opacity: 0.35; }

/* Iconos discretos en la card (bottom-right) — solo visibles al hover */
.kcard-icons {
  position: absolute; bottom: 6px; right: 7px;
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity .12s ease;
  z-index: 3;
}
.kcard:hover .kcard-icons { opacity: 1; }
.kcard-icon-btn {
  background: transparent; border: none; cursor: pointer;
  width: 24px; height: 24px;
  padding: 0; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: background .12s ease, color .12s ease;
  line-height: 0;
}
.kcard-icon-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text);
}
:root.dark .kcard-icon-btn:hover { background: rgba(255,255,255,0.08); }
.kcard-icon-btn svg { display: block; }

.kcard .top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; padding-left: 6px; }
.kcard .lead-id { font-size: 10px; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; }
.kcard .cliente { font-weight: 700; font-size: 14px; padding-left: 6px; color: var(--text); line-height: 1.25; }
.kcard .servicio { font-size: 12px; color: var(--text-2); padding-left: 6px; margin-top: 2px; }
.kcard .bottom-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-left: 6px; }
.kcard .resp { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-2); font-weight: 500; }
.kcard .resp .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.kcard .valor { font-weight: 700; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.kcard .valor.zero { color: var(--muted); font-weight: 500; }

/* ===================== Badges ===================== */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
}
.b-won, .b-cobrado, .b-ingreso, .b-activo { background: var(--green-soft); color: #137047; }
.b-lost, .b-gasto                          { background: var(--red-soft);   color: #97271f; }
.b-neg                                     { background: var(--yellow-soft);color: #875c0c; }
.b-prop                                    { background: var(--blue-soft);  color: #135ea8; }
.b-reu                                     { background: var(--purple-soft);color: #5a2cb8; }
.b-lead, .b-pausa                          { background: var(--gray-soft);  color: var(--text-2); }
.b-pendiente                               { background: var(--yellow-soft);color: #875c0c; }
.b-llc                                     { background: #e0f2fe; color: #075985; }
.b-sl                                      { background: #fef3c7; color: #92400e; }

/* ===================== Tables ===================== */
.table-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.table-toolbar {
  display: flex; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border-2); align-items: center; flex-wrap: wrap;
  background: #fafbfc;
}
.table-toolbar input, .table-toolbar select {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; background: white; font-family: inherit; color: var(--text);
}
.table-toolbar input:focus, .table-toolbar select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.12);
}
.table-toolbar input { min-width: 220px; }
.table-toolbar .spacer { flex: 1; }

.table-scroll { overflow: auto; max-height: calc(100vh - 320px); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #fafbfc; text-align: left;
  padding: 11px 16px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
tbody td {
  padding: 12px 16px; font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--border-2); white-space: nowrap;
}
tbody tr { transition: background .1s ease; }
tbody tr:hover td { background: #fafbfc; }
tbody tr.clickable { cursor: pointer; }
tbody td.right { text-align: right; font-variant-numeric: tabular-nums; }
tbody td.muted { color: var(--text-2); }
tbody td.bold { font-weight: 600; }
tbody td .num-pos { color: var(--green); font-weight: 600; }
tbody td .num-neg { color: var(--red); font-weight: 600; }

.table-footer {
  padding: 12px 16px; background: #fafbfc; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-2);
}
.table-footer .totals { display: flex; gap: 24px; }
.table-footer .totals .t { display: flex; flex-direction: column; }
.table-footer .totals .label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.table-footer .totals .val { font-weight: 700; color: var(--text); font-size: 15px; font-family: var(--font-head); }

/* ===================== Modal ===================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,7,14,0.94);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; backdrop-filter: blur(12px);
}
[data-mode="dark"] .modal-overlay { background: rgba(2,4,10,0.96); }
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 22px; padding: 26px;
  width: 720px; max-width: 100%; max-height: 92vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal.wide { width: 920px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { margin: 0; font-size: 19px; font-weight: 700; font-family: var(--font-head); }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--gray-soft); color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); font-weight: 600;
}
.form-row input, .form-row select, .form-row textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; font-family: inherit;
  background: white; color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.12);
}
.form-row textarea { min-height: 60px; resize: vertical; }
.form-row.full { grid-column: 1 / -1; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-2);
}

.stage-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.stage-pill {
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: white; cursor: pointer; font-size: 12px; font-weight: 600;
  color: var(--text-2); transition: all .15s ease;
}
.stage-pill:hover { border-color: var(--primary); color: var(--primary); }
.stage-pill.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ===================== Toast ===================== */
.toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 1000;
  background: var(--text); color: white; padding: 12px 18px;
  border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); transition: all .25s ease;
  /* No bloquear clicks debajo del toast */
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===================== Empty ===================== */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted); font-size: 13px;
}

/* ===================== Invoice (Factura) ===================== */
.invoice-list {
  display: grid; grid-template-columns: 320px 1fr; gap: 16px;
}
.invoice-sidebar {
  background: white; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow-sm); max-height: calc(100vh - 200px);
  display: flex; flex-direction: column;
}
.invoice-sidebar-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border-2);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.invoice-sidebar-list { flex: 1; overflow-y: auto; }
.invoice-row {
  padding: 12px 16px; border-bottom: 1px solid var(--border-2);
  cursor: pointer; transition: background .12s;
}
.invoice-row:hover { background: var(--gray-soft); }
.invoice-row.active { background: var(--primary-soft); }
.invoice-row .num { font-weight: 700; color: var(--text); font-size: 13px; }
.invoice-row .who { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.invoice-row .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.invoice-row .amt { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }

.invoice-preview {
  background: white; border: 1px solid var(--border); border-radius: 12px;
  padding: 0; box-shadow: var(--shadow-sm); overflow: hidden;
}
.invoice-preview .actions {
  padding: 12px 18px; border-bottom: 1px solid var(--border-2);
  background: #fafbfc; display: flex; gap: 8px; justify-content: flex-end; align-items: center;
}
.invoice-doc {
  padding: 50px 56px; min-height: 700px;
  font-family: var(--font-body);
  background: white;
  color: #1a1a1a;
  border-radius: 14px;
  box-shadow: 0 6px 32px rgba(0,0,0,0.06);
}
.invoice-doc .head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 2px solid #1a1a1a;
}
.invoice-doc .head .num-label { color: #6b6b6b; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.invoice-doc .head .num { font-size: 32px; font-weight: 800; letter-spacing: -.02em; font-family: var(--font-head); color: #1a1a1a; }
.invoice-doc .head .issuer { text-align: right; }
.invoice-doc .head .issuer .name { font-weight: 800; font-size: 15px; margin-bottom: 6px; color: #1a1a1a; }
.invoice-doc .head .issuer .line { font-size: 11.5px; color: #555; line-height: 1.6; }
.invoice-doc .parties { display: flex; justify-content: space-between; margin-bottom: 32px; gap: 36px; }
.invoice-doc .party h5 { margin: 0 0 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #6b6b6b; font-weight: 800; }
.invoice-doc .party .pname { font-weight: 700; font-size: 15px; margin-bottom: 4px; color: #1a1a1a; }
.invoice-doc .party .pline { font-size: 12px; color: #555; line-height: 1.6; }
.invoice-doc .dates { font-size: 12px; color: #555; line-height: 1.8; }
.invoice-doc .dates strong { color: #1a1a1a; }
.invoice-doc table.lines { width: 100%; border-collapse: collapse; margin: 24px 0 0; border-radius: 10px; overflow: hidden; border: 1px solid #e5e5e5; }
.invoice-doc table.lines th {
  background: #1a1a1a; padding: 14px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: white; font-weight: 800; text-align: left;
}
.invoice-doc table.lines td {
  padding: 14px; border-bottom: 1px solid #f0f0f0; font-size: 13px; color: #1a1a1a;
}
.invoice-doc table.lines tbody tr:last-child td { border-bottom: none; }
.invoice-doc table.lines td.right { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-doc .totals-block { display: flex; justify-content: flex-end; margin-top: 18px; }
.invoice-doc .totals-block table { width: 360px; background: #fafafa; border-radius: 10px; overflow: hidden; border: 1px solid #e5e5e5; }
.invoice-doc .totals-block td { padding: 12px 16px; font-size: 13px; color: #1a1a1a; }
.invoice-doc .totals-block td.label { color: #555; font-weight: 500; }
.invoice-doc .totals-block td.value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: #1a1a1a; }
.invoice-doc .totals-block tr.total td {
  border-top: 2px solid #1a1a1a;
  background: #1a1a1a;
  color: white;
  font-size: 17px; font-weight: 800; padding: 16px;
}
.invoice-doc .totals-block tr.total td.value { color: white; }
.invoice-doc .totals-block tr.due td { color: #c1372f; font-weight: 700; padding-top: 12px; background: #fff5f5; }
.invoice-doc .footer-note { margin-top: 28px; padding-top: 18px; border-top: 1px solid #e5e5e5; font-size: 11.5px; color: #555; line-height: 1.6; }
.invoice-doc .footer-note h5 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #1a1a1a; font-weight: 700; }

/* Recurrente badge */
.invoice-doc .recurrente-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #1a1a1a; color: white;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 10px; border-radius: 999px; margin-top: 6px;
}
.invoice-doc .footer-note {
  margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border-2);
  font-size: 12px; color: var(--text-2); line-height: 1.6;
}
.invoice-doc .footer-note h5 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text); font-weight: 700; }

/* Channel ROI cards */
.channels-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px;
}
.channel-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 16px 18px; box-shadow: var(--shadow-sm); transition: all .15s ease;
}
.channel-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.channel-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.channel-name { font-weight: 700; font-size: 15px; color: var(--text); }
.channel-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.channel-roi { text-align: right; }
.channel-roi-val { font-size: 22px; font-weight: 800; font-family: var(--font-head); letter-spacing: -0.02em; }
.channel-roi-lbl {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.channel-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--border-2);
}
.channel-stats .cs { display: flex; flex-direction: column; gap: 2px; }
.channel-stats .cs-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.channel-stats .cs-val { font-size: 13px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* Carpetas de clientes en Facturas */
.inv-folder { border-bottom: 1px solid var(--border-2); }
.inv-folder-head {
  padding: 12px 14px 4px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  background: #fafbfc;
}
.inv-folder-head:hover { background: var(--gray-soft); }
.inv-folder-head .caret { width: 14px; height: 14px; color: var(--muted); transition: transform .15s ease; }
.inv-folder-head .caret.open { transform: rotate(90deg); }
.inv-folder-head .inv-folder-name { flex: 1; font-weight: 700; font-size: 13px; color: var(--text); }
.inv-folder-head .inv-folder-count {
  background: var(--primary-soft); color: var(--primary); padding: 1px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
}
.inv-folder-totals {
  padding: 0 14px 10px 36px; font-size: 11px; color: var(--muted);
  display: flex; gap: 10px; background: #fafbfc;
}
.inv-folder-totals b { color: var(--text); }

/* Status chips */
.chip {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.chip-pagada    { background: var(--green-soft); color:#137047; }
.chip-enviada   { background: var(--blue-soft); color:#135ea8; }
.chip-pendiente { background: var(--yellow-soft); color:#875c0c; }
.chip-borrador  { background: var(--gray-soft); color: var(--text-2); }
.chip-vencida   { background: var(--red-soft); color: #97271f; }

/* Print */
@media print {
  body * { visibility: hidden; }
  .invoice-doc, .invoice-doc * { visibility: visible; }
  .invoice-doc { position: absolute; left: 0; top: 0; width: 100%; padding: 30px; }
  .invoice-preview .actions { display: none; }
}

/* ===================== Scrollbars ===================== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdd4dc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===================== Misc ===================== */
.flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.text-right { text-align: right; }

/* ===================== Inbox ===================== */
.inbox-layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 14px;
  height: calc(100vh - 220px);
  border-radius: 20px;
}
.inbox-list {
  background: white; border: 1px solid var(--border); border-radius: 18px;
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm);
}
.inbox-list-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border-2);
  display: flex; gap: 8px; align-items: center; background: #fafbfc;
}
.inbox-list-head input {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; outline: none; font-family: inherit;
}
.inbox-list-scroll { overflow-y: auto; flex: 1; }
.inbox-msg {
  padding: 14px 18px; border-bottom: 1px solid var(--border-2);
  cursor: pointer; transition: background .12s ease;
  position: relative;
}
.inbox-msg:hover { background: #f5f7ff; }
.inbox-msg.active { background: #efeaff; border-left: 3px solid var(--primary); }
.inbox-msg.unread { background: white; }
.inbox-msg.unread::before {
  content: ''; position: absolute; left: 6px; top: 22px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
}
.inbox-msg .row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.inbox-msg .from { font-weight: 700; font-size: 13px; color: var(--text); }
.inbox-msg.unread .from { font-weight: 800; }
.inbox-msg .date { font-size: 11px; color: var(--muted); }
.inbox-msg .subject { font-size: 13px; color: var(--text); font-weight: 500; margin-bottom: 3px; }
.inbox-msg.unread .subject { font-weight: 700; }
.inbox-msg .preview { font-size: 12px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.inbox-msg .tag {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 600; margin-top: 6px;
  background: var(--green-soft); color: #137047;
}
.inbox-msg .tag.archived { background: var(--gray-soft); color: var(--text-2); }

.inbox-detail {
  background: white; border: 1px solid var(--border); border-radius: 18px;
  display: flex; flex-direction: column; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.inbox-detail-head {
  padding: 18px 24px; border-bottom: 1px solid var(--border-2);
}
.inbox-detail-head h3 { margin: 0; font-size: 16px; font-weight: 700; font-family: var(--font-head); line-height: 1.3; }
.inbox-detail-head .meta { font-size: 12px; color: var(--text-2); margin-top: 6px; display: flex; gap: 14px; }
.inbox-detail-head .meta b { color: var(--text); font-weight: 600; }
.inbox-detail-actions {
  padding: 12px 24px; background: #fafbfc; border-bottom: 1px solid var(--border-2);
  display: flex; gap: 8px;
}
.inbox-detail-body {
  flex: 1; padding: 24px; overflow-y: auto; line-height: 1.7;
  white-space: pre-wrap; color: var(--text); font-size: 14px;
}
.inbox-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; padding: 40px;
}

/* Contract tabs */
.contract-tabs {
  display: flex; gap: 6px; margin-bottom: 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow-sm); width: fit-content;
}
.ct-tab {
  padding: 6px 14px; border-radius: 20px; border: 1.5px solid transparent; background: transparent;
  font-weight: 600; font-size: 12px; cursor: pointer; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 8px; transition: all .15s;
  font-family: inherit;
}
.ct-tab:not(.active):hover { background: var(--primary-soft); border-color: var(--primary-soft); color: var(--text); }
.ct-tab.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 6px rgba(var(--primary-rgb),0.3); }
.ct-tab .count {
  background: rgba(0,0,0,0.08); padding: 1px 7px; border-radius: 999px; font-size: 11px;
}
.ct-tab.active .count { background: rgba(255,255,255,0.25); }

/* Cobros legend */
.cobro-legend {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 5px; margin: 0 2px; font-weight: 700;
  font-size: 12px;
}
.cobro-legend.c-no       { background: white; color: var(--muted); border: 1px solid var(--border); }
.cobro-legend.c-nofact   { background: #f8fafc; color: var(--text-2); border: 1px solid var(--border); }
.cobro-legend.c-pendiente{ background: var(--yellow-soft); color: #875c0c; }
.cobro-legend.c-cobrado  { background: var(--green-soft); color: #137047; }

.chip-empty { background: white; color: var(--muted); border: 1px solid var(--border); }

/* Auto-facturación toggle */
.auto-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer;
  background: var(--gray-soft); color: #cbd5e1; font-size: 12px;
  transition: all .15s ease;
}
.auto-toggle:hover { transform: scale(1.1); }
.auto-toggle.on {
  background: var(--yellow); color: white; box-shadow: 0 2px 6px rgba(245,166,35,0.4);
}

/* One Shots */
.oneshots-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px;
}
.oneshot-card {
  background: white; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.oneshot-head {
  padding: 14px 16px; display: flex; justify-content: space-between;
  align-items: flex-start; border-bottom: 1px solid var(--border-2);
  background: linear-gradient(to bottom, #fafbfc, white);
}
.oneshot-title { font-weight: 700; font-size: 14px; color: var(--text); }
.oneshot-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.oneshot-hitos { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.oneshot-subproject-head {
  font-size: 11px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 10px; background: var(--bg); border-radius: 6px;
  margin-top: 4px; cursor: pointer;
}
.oneshot-subproject-head:first-child { margin-top: 0; }
.oneshot-subproject-head:hover { background: var(--primary-soft); color: var(--primary); }
.oneshot-card-multi { position: relative; }
.oneshot-card-multi::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; background: var(--primary); border-radius: 0 2px 2px 0; }
.oneshot-hito {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  transition: all .12s ease; border: 1px solid transparent; font-size: 12px;
}
.oneshot-hito:hover { transform: translateX(2px); }
.oneshot-hito.h-empty    { background: white; border-color: var(--border); }
.oneshot-hito.h-nofact   { background: #f8fafc; border-color: var(--border); }
.oneshot-hito.h-pendiente{ background: var(--yellow-soft); border-color: #f6c976; }
.oneshot-hito.h-cobrado  { background: var(--green-soft); border-color: #95d9b5; }
.oneshot-hito .h-name { font-weight: 600; color: var(--text); }
.oneshot-hito .h-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.oneshot-hito .h-status {
  font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: rgba(0,0,0,0.08); color: var(--text-2);
}
.oneshot-hito.h-pendiente .h-status { background: rgba(245,166,35,0.2); color: #875c0c; }
.oneshot-hito.h-cobrado .h-status { background: rgba(63,179,127,0.2); color: #137047; }

/* ===================== Contratos · grid mensual de cobros (UX premium) ===================== */
.cobros-grid {
  display: grid; grid-template-columns: 220px repeat(12, 1fr) 130px;
  gap: 0;
  background: var(--card);
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.cobros-grid > div {
  background: transparent;
  padding: 12px 10px;
  font-size: 12px;
  border-right: 1px solid var(--border-2);
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.cobros-grid > div:nth-child(14n) { border-right: none; }  /* última col sin borde */
.cobros-grid .ch {
  background: var(--bg);
  font-weight: 700; color: var(--text-2);
  text-transform: uppercase; font-size: 10px; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.cobros-grid .cliente-cell {
  justify-content: flex-start;
  font-weight: 700; color: var(--text);
}
.cobros-grid .cobro {
  cursor: pointer; font-weight: 700; font-size: 11px;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  min-height: 38px;
}
.cobros-grid .cobro:hover {
  transform: scale(1.08);
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.cobros-grid .cobro.c-cobrado {
  background: linear-gradient(135deg, var(--green-soft), #d6f4e3);
  color: #137047;
  box-shadow: inset 0 0 0 1px rgba(19,112,71,.18);
}
.cobros-grid .cobro.c-pendiente {
  background: linear-gradient(135deg, var(--yellow-soft), #fdf0c9);
  color: #875c0c;
  box-shadow: inset 0 0 0 1px rgba(135,92,12,.18);
}
.cobros-grid .cobro.c-nofact {
  background: var(--bg); color: var(--text-2);
}
.cobros-grid .cobro.c-no {
  color: var(--border);
  font-size: 14px;
}
.cobros-grid .cobro.c-parcial {
  background: linear-gradient(90deg, var(--green-soft) 50%, var(--yellow-soft) 50%);
  color: #875c0c; font-size: 10px; font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(135,92,12,.2);
}
.cobro-legend.c-parcial {
  background: linear-gradient(90deg, var(--green-soft) 50%, var(--yellow-soft) 50%);
  color: #875c0c;
}
.cobros-grid .cobro.c-na {
  color: transparent;
  background: repeating-linear-gradient(45deg, transparent, transparent 5px, var(--border-2) 5px, var(--border-2) 6px);
  cursor: not-allowed; pointer-events: none;
}
[data-mode="dark"] .cobros-grid .cobro.c-na {
  background: repeating-linear-gradient(45deg, transparent, transparent 5px, #1f232c 5px, #1f232c 6px);
}
.cobros-grid .total-cell {
  font-weight: 800; justify-content: flex-end;
  background: var(--bg); color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

/* ===== Margen barrita en Rentabilidad (más premium, animada, glow) ===== */
.margen-bar-wrap {
  position: relative;
  height: 6px;
  background: var(--border-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.margen-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .6s cubic-bezier(.34, 1.56, .64, 1);
  position: relative;
  box-shadow: 0 0 0 1px rgba(255,255,255,.05) inset;
}
.margen-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.4), transparent);
  background-size: 200% 100%;
  background-position: -100% 0;
  animation: margenShimmer 2.5s ease-in-out infinite;
  border-radius: 999px;
}
@keyframes margenShimmer {
  0%   { background-position: -100% 0; }
  50%  { background-position: 100% 0; }
  100% { background-position: 100% 0; }
}
.margen-bar-fill.green  { background: linear-gradient(90deg, #34d399, #059669); }
.margen-bar-fill.yellow { background: linear-gradient(90deg, #fde68a, #f59e0b); }
.margen-bar-fill.red    { background: linear-gradient(90deg, #fca5a5, #dc2626); }

/* ===================== DASHBOARD TABS ===================== */
.dashboard-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; padding: 4px; background: var(--bg); border-radius: 12px; width: fit-content; }
.dashboard-tabs .ct-tab { padding: 8px 16px; font-size: 13px; }

/* ===================== DASHBOARD MI DÍA ===================== */
.dashboard-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dashboard-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; min-height: 280px;
}
.dashboard-panel .panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border-2);
}
.dashboard-panel .panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.dashboard-panel .panel-meta { font-size: 11px; color: var(--text-2); font-weight: 500; }

.todo-add { display: flex; gap: 8px; margin-bottom: 12px; }
.todo-add input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--bg); color: var(--text); }
.todo-add select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; background: var(--bg); color: var(--text); }
.todo-list { display: flex; flex-direction: column; gap: 4px; max-height: 380px; overflow-y: auto; }
.todo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  transition: background .15s ease;
}
.todo-item:hover { background: var(--bg); }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--text-2); opacity: 0.6; }
.todo-prio { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.todo-prio.prio-baja  { background: var(--text-2); }
.todo-prio.prio-media { background: #f59e0b; }
.todo-prio.prio-alta  { background: var(--red); }
.todo-text { flex: 1; font-size: 13px; line-height: 1.4; }
.todo-del {
  background: none; border: none; color: var(--text-2);
  font-size: 18px; cursor: pointer; padding: 2px 8px;
  opacity: 0; transition: opacity .15s ease;
}
.todo-item:hover .todo-del { opacity: 1; }
.todo-del:hover { color: var(--red); }

.project-list { display: flex; flex-direction: column; gap: 10px; max-height: 480px; overflow-y: auto; }
.project-card {
  background: var(--bg); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 14px; position: relative;
}
.project-card.overdue { border-color: var(--red); background: #fff5f5; }
.project-card .proj-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 10px; }
.project-card .proj-title { font-weight: 700; font-size: 13px; }
.project-card .proj-status { font-size: 10px; padding: 3px 8px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.project-card .proj-meta { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.project-card .proj-meta-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.project-card .proj-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; color: var(--text-2);
  background: var(--card); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 999px;
}
.project-card .proj-type {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700;
  background: var(--primary-soft); color: var(--primary);
  padding: 3px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.project-card.urgent { border-color: #e25950; background: #fff5f5; }
.project-card .proj-notes { font-size: 11px; color: var(--text-2); margin-top: 8px; padding: 8px; background: var(--card); border-radius: 6px; font-style: italic; }
.project-card .proj-actions { display: flex; gap: 6px; margin-top: 8px; }
.project-card .proj-edit, .project-card .proj-del {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  font-size: 11px; padding: 4px 10px; cursor: pointer; color: var(--text-2);
}
.project-card .proj-edit:hover { border-color: var(--primary); color: var(--primary); }
.project-card .proj-del:hover { border-color: var(--red); color: var(--red); }

@media (max-width: 900px) {
  .dashboard-2col { grid-template-columns: 1fr; }
  .todo-add { flex-direction: column; }
  .todo-add select { width: 100%; }
}

/* ===================== HISTORIAL MODAL ===================== */
.hist-list { max-height: 60vh; overflow-y: auto; margin: 0 -20px; padding: 0 20px; }
.hist-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  cursor: pointer; transition: background .15s ease;
  border: 1px solid transparent;
}
.hist-row:hover { background: var(--bg); border-color: var(--border); }
.hist-row .hist-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.hist-row.hist-past .hist-icon    { background: var(--gray-soft); color: var(--text-2); }
.hist-row.hist-future .hist-icon  { background: var(--blue-soft, #dbeafe); color: var(--blue, #3b82f6); }
.hist-row.hist-current { background: var(--primary-soft); border-color: var(--primary); cursor: default; }
.hist-row.hist-current .hist-icon { background: var(--primary); color: white; }
.hist-row.hist-current:hover { background: var(--primary-soft); }
.hist-body { flex: 1; min-width: 0; }
.hist-body .hist-label { font-weight: 600; font-size: 13px; line-height: 1.3; }
.hist-body .hist-meta  { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.hist-go {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 12px; font-size: 11px; font-weight: 600;
  color: var(--text-2); cursor: pointer; flex-shrink: 0;
}
.hist-row:hover .hist-go { border-color: var(--primary); color: var(--primary); }

/* Global search */
.gs-result { transition: background .1s ease; border: 1px solid transparent; }
.gs-result.active { background: var(--primary-soft); border-color: var(--primary); }
.gs-result:hover { background: var(--bg); }

/* ===================== SETTINGS ===================== */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 0; box-shadow: var(--shadow-sm); overflow: hidden;
}
.settings-card > summary {
  list-style: none; cursor: pointer; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 14px; transition: background .15s ease;
}
.settings-card > summary::-webkit-details-marker { display: none; }
.settings-card > summary::after {
  content: '▾'; color: var(--text-2); font-size: 14px; margin-left: 10px;
  transition: transform .2s ease;
}
.settings-card[open] > summary::after { transform: rotate(180deg); }
.settings-card > summary:hover { background: var(--bg); }
.settings-card .sec-meta { font-size: 11px; color: var(--text-2); font-weight: 500; margin-left: auto; margin-right: 12px; }
.settings-body { padding: 4px 18px 18px; border-top: 1px solid var(--border-2); }
.set-row {
  display: grid; grid-template-columns: 220px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border-2);
}
.set-row:last-child { border-bottom: none; }
.set-row.full { grid-template-columns: 1fr; }
.set-row > label { font-size: 12px; font-weight: 600; color: var(--text); }
.set-row > input, .set-row > select, .set-row > textarea {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--bg); color: var(--text); font-family: inherit;
  width: 100%;
}
.set-row > textarea { font-family: inherit; resize: vertical; }
.set-help { font-size: 11px; color: var(--text-2); }
.set-row { position: relative; }

/* ===================== iOS-like polish ===================== */
.btn { border-radius: 10px; font-weight: 600; transition: all .15s cubic-bezier(.4,0,.2,1); }
.btn-primary { border-radius: 10px; }
.btn:active { transform: scale(0.97); }
.modal-content, .modal { border-radius: 20px; box-shadow: 0 12px 48px rgba(0,0,0,0.15); }
.kpi-card { border-radius: 16px; transition: transform .15s ease; }
.kpi-card:hover { transform: translateY(-2px); }
.table-card { border-radius: 16px; }
.chart-card { border-radius: 14px; }
.settings-card { border-radius: 16px; }
input, select, textarea { border-radius: 10px; transition: border-color .15s ease, box-shadow .15s ease; }
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3px var(--primary-soft); border-color: var(--primary); outline: none; }

/* Inbox visto + section dividers */
.inbox-section-divider {
  padding: 8px 16px; background: var(--bg); font-size: 11px; font-weight: 700;
  color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
  border-top: 1px solid var(--border-2); border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 8px;
}
.inbox-msg.visto { opacity: 0.55; }
.inbox-msg.visto .subject { font-weight: 500; }

/* Quick visto button on hover */
.inbox-msg-actions { display: none; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); gap: 4px; }
.inbox-msg:hover .inbox-msg-actions { display: flex; }
.inbox-quick-visto { background: var(--primary-soft); border: none; color: var(--primary); border-radius: 8px; width: 28px; height: 28px; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.inbox-quick-visto:hover { background: var(--primary); color: white; }

.ai-action-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; text-align: left;
  transition: all .15s ease;
}
.ai-action-btn:hover { border-color: #8a64f8; background: #f0ecff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(138,100,248,0.15); }
.spin { display: inline-block; animation: spin 1.5s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Sticky headers en tablas largas */
.table-scroll table thead { position: sticky; top: 0; z-index: 5; background: var(--card); box-shadow: 0 2px 0 var(--border); }
.table-scroll table thead th { background: var(--bg); }
[data-mode="dark"] .table-scroll table thead th { background: var(--card); }

/* Avatar de cliente con color único */
.cli-avatar {
  letter-spacing: 0;
  border: 1px solid rgba(0,0,0,0.06);
  transition: transform .15s ease;
}
.cli-avatar:hover { transform: scale(1.08); }
.saved-flash {
  position: absolute; right: -8px; top: -6px;
  font-size: 10px; font-weight: 700; color: var(--green);
  background: var(--green-soft); padding: 2px 8px; border-radius: 999px;
  opacity: 0; transition: opacity .3s ease; pointer-events: none;
}
.integ-card {
  background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px;
  padding: 12px; margin-bottom: 8px;
}
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
  .set-row { grid-template-columns: 1fr; }
}

/* ===================== CALENDARIO (sin uso, mantenido por si reactiva) ===================== */
.cal-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-month-label { font-weight: 700; font-size: 18px; min-width: 180px; text-align: center; }
.cal-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-2); flex-wrap: wrap; }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cal-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.cal-grid { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; box-shadow: var(--shadow-sm); }
.cal-headers { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-h { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; padding: 6px 0; }
.cal-body { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { min-height: 80px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; cursor: pointer; transition: all .15s ease; }
.cal-cell:hover.cal-has-events { border-color: var(--primary); background: var(--primary-soft); }
.cal-cell.cal-empty { background: transparent; border: none; cursor: default; }
.cal-cell.cal-today { background: var(--primary-soft); border-color: var(--primary); }
.cal-day-num { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cal-cell.cal-today .cal-day-num { color: var(--primary); font-weight: 700; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; }
.cal-more { font-size: 9px; color: var(--text-2); font-weight: 600; }
.cal-sidebar { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; max-height: calc(100vh - 220px); overflow-y: auto; box-shadow: var(--shadow-sm); position: sticky; top: 80px; }
.cal-up-list { display: flex; flex-direction: column; gap: 8px; }
.cal-up-row { background: var(--bg); border-radius: 8px; padding: 8px 10px; cursor: pointer; transition: background .15s ease; }
.cal-up-row:hover { background: var(--primary-soft); }
.cal-up-date { font-size: 10px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.cal-up-title { font-size: 12px; font-weight: 600; margin-top: 2px; line-height: 1.3; }
.cal-up-title.cal-done { text-decoration: line-through; opacity: .6; }
.cal-up-sub { font-size: 10px; color: var(--text-2); margin-top: 2px; }
@media (max-width: 900px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-sidebar { position: static; max-height: none; }
  .cal-cell { min-height: 60px; }
}

/* ===================== MOBILE RESPONSIVE ===================== */
.mobile-menu-btn {
  display: none;
  background: none; border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; cursor: pointer;
  color: var(--text); align-items: center; justify-content: center;
}
.mobile-menu-btn svg { width: 22px; height: 22px; }
.mobile-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 99;
}
.mobile-overlay.active { display: block; }

@media (max-width: 900px) {
  .app { padding: 0; gap: 0; flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 240px; height: 100vh;
    border-radius: 0; z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 24px rgba(0,0,0,0.3);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-nav { padding: 18px 12px; }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; font-size: 14px; }
  .nav-item svg { width: 20px; height: 20px; }
  .sidebar-logo { height: 72px; padding: 16px; }
  .sidebar-logo img { max-width: 50px; max-height: 50px; }
  .empresa-pill { font-size: 11px; padding: 10px 8px; }
  .main { border-radius: 0; box-shadow: none; width: 100%; overflow: visible !important; }
  .app { min-height: 100vh; height: auto !important; padding: 0 !important; }
  .page { overflow-x: hidden !important; overflow-y: visible !important; }
  .topbar {
    height: 56px; padding: 0 12px; gap: 8px;
    flex-wrap: nowrap;
    /* Scroll horizontal por si no caben todos los botones */
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar-title { font-size: 16px; }
  .topbar-brand-tag { display: none; }
  .topbar-search { display: none; }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  .topbar-actions .btn { padding: 6px 10px; font-size: 11px; flex-shrink: 0; }
  .topbar-actions .btn span, .topbar-actions label span { display: none; }
  .topbar-actions .btn svg, .topbar-actions label svg { margin: 0; }
  /* Compactar Export/Import en mobile (apenas se usan ahí) */
  .topbar-actions #btn-export, .topbar-actions label[for="file-import"] { display: none; }
  #user-chip span { display: none; }
  .mobile-menu-btn { display: inline-flex; }
  .page { padding: 14px 12px 60px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
  .page-header h2 { font-size: 20px; }
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .kpi-grid > * { padding: 12px !important; }
  table { font-size: 12px; }
  .table-wrap, .scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table th, table td { white-space: nowrap; padding: 8px 10px !important; }
  .form-grid, .form-row { grid-template-columns: 1fr !important; flex-direction: column !important; }
  input, select, textarea { font-size: 16px !important; }
  .modal { max-width: 96vw !important; max-height: 92vh !important; }
  .modal-content { padding: 16px !important; }
  .cobros-grid { font-size: 10px; }
  .pipeline-grid, .pipeline-board { overflow-x: auto; }
  .chart-container { max-width: 100%; overflow-x: auto; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .topbar-actions .btn { padding: 5px 8px; }
  .topbar-title { font-size: 14px; }
  .page { padding: 12px 8px 60px; }
}

/* ===== Vista móvil del pipeline (≤ 768px) =====
   Kanban con scroll horizontal swipe + cards full-height (sin inner scroll) */
@media (max-width: 768px) {
  /* Forzar el container kanban a ser el scroll horizontal principal */
  .kanban {
    gap: 10px;
    padding: 4px 4px 12px;
    /* Snap por columna: el scroll horizontal se queda alineado */
    scroll-snap-type: x mandatory;
    scroll-padding-left: 4px;
    -webkit-overflow-scrolling: touch;
    overflow-x: auto !important;
    overflow-y: visible !important;
    overscroll-behavior-x: contain;
    /* Mejor swipe en touch — sólo permite scroll horizontal */
    touch-action: pan-x pan-y;
  }
  .kanban-col {
    flex: 0 0 82vw;
    width: 82vw;
    min-width: 82vw;
    max-width: 82vw;
    /* Sin max-height: la columna crece con sus cards, scroll de página vertical */
    max-height: none !important;
    scroll-snap-align: start;
    overflow: visible !important;
  }
  /* Sin inner scroll: las cards apiladas, scroll de página vertical normal */
  .kanban-cards {
    overflow-y: visible !important;
    flex: 1 1 auto;
    padding: 10px 10px 12px;
  }
  .kanban-col.collapsed {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
  }
  .kanban-col-head {
    padding: 10px 12px 8px;
  }
  .kanban-col-head .title { font-size: 13px; }
  .kanban-cards { padding: 8px; gap: 6px; }
  /* Cards más compactas */
  .kcard {
    min-height: 110px;
    padding: 8px 9px 7px;
  }
  .kcard .top-row { font-size: 10px; }
  /* Toolbar del pipeline en columna en móvil */
  .pipeline-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .pipeline-toolbar .stat { flex: 1; min-width: 90px; }
  .pipeline-toolbar input,
  .pipeline-toolbar select { width: 100%; }
  /* Stats agrupadas en grid 2x */
  .pipeline-toolbar > .stat:nth-child(-n+5) {
    display: inline-flex;
  }
  .pipeline-toolbar .spacer { display: none; }
  /* Avatar más pequeño en card móvil */
  .kcard .top-row .lead-id { font-size: 10px; }
  /* Esconder bottom-row en móvil (info menos esencial) salvo el valor */
  .kcard .bottom-row .resp { display: none; }
  .kcard .bottom-row .valor { margin-left: auto; }
  /* Hover icons siempre visibles en móvil (no hay hover) */
  .kcard-icons { opacity: 1 !important; }
}

/* ============================================================
   CONFETTI — animación de celebración Won
   ============================================================ */
@keyframes confettiFall {
  0%   { transform: translate3d(0, -20px, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--driftX, 0), 105vh, 0) rotate(var(--rot, 360deg)); opacity: 0.3; }
}

/* ============================================================
   DRAG-TO-SNOOZE — zona para snoozear arrastrando tarjeta
   ============================================================ */
.snooze-dropzone {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  background: var(--card);
  border: 2px dashed var(--yellow);
  color: var(--text);
  padding: 14px 28px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 13px;
  z-index: 9000;
  box-shadow: var(--shadow-md);
  transition: transform .25s cubic-bezier(.4,.2,.2,1);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.snooze-dropzone.show { transform: translateX(-50%) translateY(0); pointer-events: auto; }
.snooze-dropzone.over { background: var(--yellow-soft); border-style: solid; transform: translateX(-50%) translateY(0) scale(1.05); }

/* ============================================================
   HEATMAP — actividad estilo GitHub
   ============================================================ */
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  padding: 4px 0;
  overflow-x: auto;
}
.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--border-2);
  transition: transform .12s;
}
.heatmap-cell:hover { transform: scale(1.3); }
.heatmap-cell.h1 { background: #c6e7d4; }
.heatmap-cell.h2 { background: #7fc9a3; }
.heatmap-cell.h3 { background: #3fb37f; }
.heatmap-cell.h4 { background: #2a8a5e; }
:root.dark .heatmap-cell { background: var(--border); }
:root.dark .heatmap-cell.h1 { background: #1f4d35; }
:root.dark .heatmap-cell.h2 { background: #2a7a52; }
:root.dark .heatmap-cell.h3 { background: #3fb37f; }
:root.dark .heatmap-cell.h4 { background: #5fd99a; }

/* ============================================================
   COMMAND PALETTE — búsqueda global Cmd/Ctrl + K
   ============================================================ */
.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: cmdkFade .15s ease;
}
@keyframes cmdkFade { from { opacity: 0 } to { opacity: 1 } }
.cmdk-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 22px 60px rgba(0,0,0,.35);
  width: 92vw; max-width: 640px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmdkPop .18s cubic-bezier(.2,.8,.4,1);
}
@keyframes cmdkPop { from { transform: translateY(-8px); opacity:0 } to { transform: translateY(0); opacity:1 } }
.cmdk-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cmdk-input {
  flex: 1; border: none; background: transparent;
  font-size: 15px; color: var(--text); outline: none;
  font-family: inherit;
}
.cmdk-kbd, .cmdk-footer kbd {
  background: var(--border);
  color: var(--text-2);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  font-family: monospace;
}
.cmdk-results { flex: 1; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .08s;
  font-size: 13px;
}
.cmdk-item.sel { background: var(--primary-soft); }
.cmdk-icon { font-size: 16px; width: 22px; text-align: center; }
.cmdk-label { flex: 1; color: var(--text); font-weight: 600; }
.cmdk-hint { color: var(--text-2); font-size: 11px; font-weight: 500; }
.cmdk-empty { padding: 24px; text-align: center; color: var(--text-2); font-size: 13px; }
.cmdk-footer {
  display: flex; gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--text-2);
}

/* ============================================================
   DASHBOARD — quick action buttons + insight cards
   ============================================================ */
.insight-card { transition: transform .12s ease, box-shadow .12s ease; }
.insight-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.qa-btn { transition: transform .1s ease; }
.qa-btn:hover { transform: translateY(-1px); }

/* ============================================================
   MOBILE V2 — Bottom nav + safe areas + polish
   ============================================================ */
.mobile-bottom-nav { display: none; }

@media (max-width: 900px) {
  /* Safe area insets para iPhone notch + home indicator */
  body { padding-top: env(safe-area-inset-top); padding-bottom: 0; }

  /* === BOTTOM NAV === */
  .mobile-bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 90;
    background: var(--card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    gap: 2px;
  }
  .mobile-bottom-nav .mbn-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    background: transparent; border: none;
    padding: 6px 4px; min-height: 52px;
    cursor: pointer;
    border-radius: 10px;
    color: var(--text-2); font-size: 10px; font-weight: 600;
    transition: background .12s ease, color .12s ease;
    font-family: inherit;
  }
  .mobile-bottom-nav .mbn-item svg { width: 22px; height: 22px; }
  .mobile-bottom-nav .mbn-item:active { background: var(--bg); transform: scale(.95); }
  .mobile-bottom-nav .mbn-item.active {
    color: var(--primary);
    background: var(--primary-soft);
  }

  /* Espacio para que el bottom nav no tape contenido */
  .page { padding-bottom: 90px !important; }

  /* Sidebar entera escondida por defecto en mobile (se abre con "Más") */
  .sidebar { box-shadow: 0 0 32px rgba(0,0,0,0.5) !important; }

  /* Topbar más compacta y limpia */
  .topbar {
    height: 52px;
    padding: 0 10px calc(0px + env(safe-area-inset-top, 0)) 10px;
    padding-top: env(safe-area-inset-top);
    height: calc(52px + env(safe-area-inset-top, 0px));
    position: sticky; top: 0; z-index: 50;
    background: var(--card);
    border-bottom: 1px solid var(--border);
  }

  /* Esconder filtros año/entidad en topbar mobile — accesibles vía Ajustes/filtros internos */
  .topbar #global-year-filter, .topbar #global-entidad-filter { display: none; }

  /* Botones topbar: solo iconos, más grandes para dedos */
  .topbar-actions .btn,
  .topbar-actions label {
    min-width: 40px; min-height: 40px;
    padding: 0 !important;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .topbar-actions .btn svg { width: 18px; height: 18px; }

  /* === TAP TARGETS GLOBALES === */
  button, .btn, .nav-item, [role="button"] { min-height: 40px; }

  /* === KPIs más cómodos === */
  .kpi-card h3, .kpi-card .kpi-title { font-size: 11px !important; }
  .kpi-card .kpi-value, .kpi-card strong { font-size: 18px !important; }

  /* === MODALES full-screen feel === */
  .modal-overlay.open .modal-box,
  .modal-overlay.show .modal-box,
  #modal-box {
    max-width: 100vw !important;
    width: 100% !important;
    max-height: 100vh !important;
    height: auto;
    border-radius: 16px 16px 0 0 !important;
    margin: auto auto 0 auto !important;
    align-self: flex-end;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)) !important;
  }
  .modal-overlay { align-items: flex-end !important; }
  .modal-header h3 { font-size: 17px; }

  /* === TABLAS: scroll horizontal con sombra hint === */
  .table-scroll, .table-wrap, .scroll-x {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .table-scroll::after, .table-wrap::after {
    content: ''; position: sticky; right: 0; top: 0; bottom: 0;
    width: 16px; pointer-events: none;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.06));
  }
  table { min-width: max-content; }

  /* === FORMS — inputs grandes (16px evita zoom iOS) === */
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="number"], input[type="date"], input[type="password"],
  textarea, select {
    font-size: 16px !important;
    padding: 10px 12px !important;
    min-height: 44px;
  }

  /* === PIPELINE / KANBAN — full width sin padding lateral === */
  .pipeline-board, .kanban {
    margin: 0 -12px;
    padding: 0 12px 16px;
  }

  /* === CHIPS, badges más legibles === */
  .chip { font-size: 11px; padding: 3px 9px; }

  /* === ESCONDER columnas marcadas como hide-mobile === */
  .hide-mobile { display: none !important; }
  th.hide-mobile, td.hide-mobile { display: none !important; }

  /* === CARDS de cliente: hacerlas tap-friendly === */
  .cli-card, .cliente-row { padding: 14px !important; }

  /* === Inbox layout vertical en mobile === */
  .inbox-layout { grid-template-columns: 1fr !important; display: flex !important; flex-direction: column; }
  .inbox-detail { display: none; }
  .inbox-layout.show-detail .inbox-list { display: none; }
  .inbox-layout.show-detail .inbox-detail { display: block; }

  /* === Floating Action Button hueco para acciones primarias === */
  .fab-mobile {
    position: fixed; right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: 56px; height: 56px;
    border-radius: 50%; background: var(--primary);
    color: white; border: none;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 80; cursor: pointer; font-size: 24px;
  }
  .fab-mobile:active { transform: scale(.93); }

  /* === Settings/lista de Cards más espaciado === */
  .settings-card > summary { padding: 16px; font-size: 15px; }
  .settings-body { padding: 6px 14px 14px; }

  /* === Notification toast no encima del bottom nav === */
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)) !important; }
}

/* === DARK MODE bottom nav === */
[data-mode="dark"] .mobile-bottom-nav {
  background: var(--card);
  border-top-color: var(--border);
}

/* === Mobile add buttons + filtros toolbar === */
@media (max-width: 900px) {
  .page-header { width: 100%; }
  .page-header .btn-primary {
    width: 100%;
    margin-top: 8px;
    padding: 14px 16px !important;
    font-size: 14px !important;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(93, 61, 245, 0.25);
  }
  .page-header .btn-primary svg { width: 18px; height: 18px; }

  /* Toolbar de tablas (Contabilidad, etc.) — filtros legibles, 2 col en mobile */
  .table-toolbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 12px !important;
  }
  .table-toolbar > input,
  .table-toolbar > select {
    flex: 1 1 calc(50% - 4px) !important;
    min-width: 0 !important;
    font-size: 14px !important;
  }
  .table-toolbar > .spacer { display: none; }
  .table-toolbar > .btn { flex: 1 1 100%; justify-content: center; }

  /* Page header column stack en mobile */
  .page-header { flex-direction: column; align-items: stretch !important; gap: 8px !important; }

  /* Empty states del CRM con un CTA grande para crear el primero */
  .empty {
    padding: 28px 18px !important;
    text-align: center !important;
    color: var(--text-2);
    font-size: 14px;
  }

  /* Pipeline cards más legibles */
  .kanban-card { padding: 10px !important; font-size: 12px; }
  .kanban-card-title { font-size: 13px !important; }

  /* Cobros: tabla muy ancha → permitir scroll horizontal */
  .cobros-grid { display: block !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Settings full width */
  .settings-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .set-row { grid-template-columns: 1fr !important; gap: 6px !important; }

  /* Notif drawer fits screen */
  .notif-drawer { width: 100% !important; }

  /* Login modal */
  #login-overlay > div { max-width: 92vw !important; padding: 24px 18px !important; }
}

/* Pipeline cards más grandes en mobile */
@media (max-width: 900px) {
  .kcard {
    min-height: 0 !important;       /* deja que crezca a contenido */
    padding: 14px 14px 12px !important;
    border-radius: 14px;
    overflow: visible !important;   /* nada se corta */
  }
  .kcard .cliente { font-size: 15px !important; }
  .kcard .servicio { font-size: 11.5px; }

  /* En mobile, los iconos viven dentro del flow normal (no absolute)
     para que no tapen el responsable / valor del bottom-row */
  .kcard-icons {
    position: static !important;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-2);
    justify-content: flex-end;
    gap: 6px;
    opacity: 1 !important;
  }
  .kcard-icon-btn { width: 32px !important; height: 32px !important; }
  .kcard-icon-btn svg { width: 16px !important; height: 16px !important; }
  /* bottom-row ya no necesita padding-right reservado para los iconos */
  .kcard .bottom-row {
    padding-right: 0 !important;
    margin-top: 8px;
    padding-top: 6px;
  }
}

/* === Chip de URL del lead — limpio, sin underline raro === */
.kcard .lead-web {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--primary);
  margin: 3px 0 4px 6px;
  font-weight: 600;
  text-decoration: none !important;
  background: var(--primary-soft);
  padding: 3px 9px 3px 8px;
  border-radius: 999px;
  max-width: calc(100% - 12px);
  width: fit-content;
  line-height: 1.35;
  border: 1px solid transparent;
  transition: border-color .15s ease, background .15s ease;
}
.kcard .lead-web .lw-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none !important;
  min-width: 0;
}
.kcard .lead-web svg { flex-shrink: 0; opacity: 0.85; }
.kcard .lead-web:hover {
  border-color: var(--primary);
  text-decoration: none !important;
}
.kcard .lead-web:hover .lw-text,
.kcard .lead-web:focus .lw-text { text-decoration: none !important; }
[data-mode="dark"] .kcard .lead-web {
  background: rgba(93,61,245,0.18);
  color: #b3a3ff;
}
[data-mode="dark"] .kcard .lead-web:hover {
  border-color: #b3a3ff;
  background: rgba(93,61,245,0.28);
}
@media (max-width: 900px) {
  .kcard .lead-web { font-size: 12px; padding: 4px 11px; }
}

/* ============================================================
   MOBILE V3 — fixes adicionales de usabilidad
   ============================================================ */
@media (max-width: 900px) {
  /* Scroll suave en todas las superficies táctiles */
  * { -webkit-overflow-scrolling: touch; }

  /* Modal scrolleable de verdad — overflow-y auto y altura limitada */
  .modal-overlay.open,
  .modal-overlay.show {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #modal-box, .modal-content {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    max-height: 90vh !important;
  }

  /* Botones del modal sticky abajo (Guardar/Cancelar) */
  .modal-actions, .modal-footer {
    position: sticky; bottom: 0;
    background: var(--card);
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--border-2);
    z-index: 2;
  }

  /* Dropdowns/selects abiertos a tamaño completo */
  select { background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px !important; appearance: none; -webkit-appearance: none; }

  /* Botón de cerrar modales más grande en touch */
  .modal-close { width: 40px !important; height: 40px !important; }
  .modal-close svg { width: 20px; height: 20px; }

  /* Inputs date/datetime más cómodos */
  input[type="date"], input[type="datetime-local"] { min-height: 44px; }

  /* Botones de stage en pipeline mobile — alineación */
  .kanban-col-head .title { font-size: 13px; }
  .kanban-col-head .count { font-size: 11px; padding: 3px 10px; }

  /* Cuando una card está activa (al tap), pequeño feedback visual */
  .kcard:active { transform: scale(.98); border-color: var(--primary); }

  /* Permitir scroll vertical de página + horizontal de kanban */
  body { overflow-x: hidden; }

  /* Tablas detail row — la barra de scroll horizontal es delgada */
  .table-scroll::-webkit-scrollbar { height: 4px; }
  .table-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  /* Dashboard insight cards 1 columna */
  .insight-grid { grid-template-columns: 1fr !important; }

  /* Quick actions del dashboard 2 columnas en lugar de 4 */
  .qa-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .qa-btn { padding: 12px !important; font-size: 12px !important; }

  /* Cobros grid — primera columna sticky para que la referencia del cliente no se pierda al scrollear horizontal */
  .cobros-grid table { min-width: 720px; }
  .cobros-grid table th:first-child,
  .cobros-grid table td:first-child {
    position: sticky; left: 0;
    background: var(--card);
    z-index: 2;
    box-shadow: 2px 0 4px rgba(0,0,0,0.04);
  }

  /* Modal — labels y form rows más cómodos */
  .form-row label, .modal label { font-size: 13px; }
  .modal h3 { font-size: 16px !important; line-height: 1.3; }

  /* Notificaciones drawer ancho completo */
  #notif-drawer, .notif-drawer { width: 100vw !important; max-width: 100vw !important; right: 0 !important; }

  /* Sidebar mobile-open — ocupa 85vw máximo, no demasiado estrecha */
  .sidebar.mobile-open { width: 280px; max-width: 85vw; }

  /* Login overlay full screen mobile */
  #login-overlay { padding: 16px; }
  #login-overlay > div { width: 100%; }

  /* Equipo / Settings tabs scroll horizontal */
  .tab-bar, [class*="tabs"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
  }
  .tab-bar::-webkit-scrollbar, [class*="tabs"]::-webkit-scrollbar { display: none; }
}

/* En pantallas muy pequeñas, kanban col ocupa 88vw */
@media (max-width: 480px) {
  .kanban-col { flex: 0 0 88vw !important; width: 88vw !important; min-width: 88vw !important; max-width: 88vw !important; }
}

/* Visual hint: pequeña sombra a la derecha del kanban cuando hay más columnas */
.kanban {
  background: linear-gradient(to right, transparent calc(100% - 24px), rgba(0,0,0,0.04));
  background-attachment: local;
}

/* ============================================================
   TABLET / SMALL LAPTOP (901–1280px) — entre mobile y desktop full
   ============================================================ */
@media (min-width: 901px) and (max-width: 1280px) {
  /* Sidebar más compacta para dejar más espacio al contenido */
  .sidebar { width: 78px !important; padding: 12px 6px !important; }
  .sidebar-logo { padding: 10px !important; height: 56px !important; }
  .sidebar-logo img { max-width: 40px; max-height: 40px; }
  .nav-item {
    flex-direction: column !important;
    gap: 3px !important;
    padding: 8px 4px !important;
    font-size: 10px !important;
    text-align: center !important;
  }
  .nav-item svg { width: 18px; height: 18px; }
  .empresa-pill { font-size: 9px !important; padding: 5px 6px !important; }

  /* Topbar: oculta textos largos de botones, conserva iconos */
  .topbar { gap: 8px !important; padding: 0 14px !important; }
  .topbar-actions .btn span { display: none; }
  .topbar-search { max-width: 280px !important; }
  .topbar-search input { padding-right: 36px; }

  /* Kanban: columnas más estrechas para que entren todas */
  .kanban-col {
    flex: 0 0 240px !important;
    width: 240px !important;
    min-width: 240px !important;
    max-width: 240px !important;
  }
  .kcard { padding: 10px 10px 8px !important; }

  /* KPIs más compactos */
  .kpi-card .kpi-value { font-size: 18px !important; }

  /* Page padding reducido */
  .page { padding: 18px 18px 32px !important; }

  /* Tablas: menos padding horizontal */
  table th, table td { padding: 8px 10px !important; }

  /* Settings + ajustes en 1 columna si está apretado */
  .settings-grid { gap: 12px !important; }
}

/* IPad portrait (≈768–900) — algunos ajustes extra */
@media (min-width: 768px) and (max-width: 900px) {
  /* Kanban cols un pelín más anchas que mobile pero compactas */
  .kanban-col {
    flex: 0 0 320px !important;
    width: 320px !important;
    min-width: 320px !important;
    max-width: 320px !important;
  }
  /* Modal tipo bottom-sheet también en iPad */
  #modal-box { max-width: 92vw !important; }
}

/* ============================================================
   RESPONSIVE V4 — pase comprensivo
   Breakpoints:
   - ≤480px:    phone pequeño
   - ≤768px:    phone (bottom nav)
   - 769–1024:  tablet (iPad portrait)
   - 1025–1280: small laptop
   - >1280:     desktop full
   ============================================================ */

/* === MOBILE BOTTOM NAV: solo ≤768 (no en iPad) === */
@media (min-width: 769px) {
  .mobile-bottom-nav { display: none !important; }
  .mobile-menu-btn { display: none !important; }
  .fab-mobile { display: none !important; }
  body { padding-bottom: 0 !important; }
  .page { padding-bottom: 32px !important; }
}

/* === TABLET (769–1024): iPad portrait con sidebar compacta === */
@media (min-width: 769px) and (max-width: 1024px) {
  .app { padding: 10px !important; gap: 10px !important; }
  .sidebar {
    width: 76px !important; min-width: 76px !important;
    padding: 14px 6px !important;
    transform: none !important;
    position: relative !important;
    box-shadow: none !important;
  }
  .sidebar-logo { padding: 10px !important; height: 60px !important; }
  .sidebar-logo img { max-width: 44px; max-height: 44px; }
  .nav-item {
    flex-direction: column !important;
    gap: 4px !important;
    padding: 9px 4px !important;
    font-size: 10px !important;
    text-align: center !important;
    line-height: 1.2;
  }
  .nav-item svg { width: 19px; height: 19px; }
  .nav-item span { font-size: 9.5px; letter-spacing: 0.01em; }
  .empresa-pill { font-size: 9.5px !important; padding: 6px 6px !important; }
  .sidebar-footer { gap: 4px !important; }

  /* Topbar: oculta textos de botones, conserva iconos */
  .topbar { gap: 8px !important; padding: 0 16px !important; height: 56px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions label span { display: none; }
  .topbar-actions .btn,
  .topbar-actions label {
    padding: 7px 9px !important;
    min-width: 38px;
  }
  .topbar-search { max-width: 320px !important; }
  .topbar-title { font-size: 16px; }

  /* Kanban: cols 260px */
  .kanban-col {
    flex: 0 0 260px !important;
    width: 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
  }
  .kcard { padding: 11px 11px 9px !important; }

  /* Page padding */
  .page { padding: 20px 22px 32px !important; }

  /* KPI compactos */
  .kpi-card .kpi-value { font-size: 19px !important; }
  .kpi-card h3, .kpi-card .kpi-title { font-size: 11.5px !important; }

  /* Tablas */
  table th, table td { padding: 8px 10px !important; font-size: 12.5px; }

  /* Modales: max ancho razonable */
  #modal-box { max-width: 700px !important; }

  /* Form rows: 2 columnas en lugar de 3 */
  .form-grid { grid-template-columns: 1fr 1fr !important; }

  /* Dashboard widgets: 2 columnas */
  .dashboard-2col { grid-template-columns: 1fr 1fr !important; }

  /* Settings grid: 2 columnas */
  .settings-grid { grid-template-columns: 1fr 1fr !important; }
}

/* === SMALL LAPTOP (1025–1280): sidebar compacta pero más ancha === */
@media (min-width: 1025px) and (max-width: 1280px) {
  .sidebar { width: 92px !important; min-width: 92px !important; padding: 14px 8px !important; }
  .nav-item {
    flex-direction: column !important;
    gap: 4px !important;
    padding: 10px 4px !important;
    font-size: 11px !important;
    text-align: center !important;
  }
  .nav-item svg { width: 20px; height: 20px; }

  /* Topbar: mostrar texto en botones críticos solo */
  .topbar-actions .btn span:not(.always-show) { display: none; }

  /* Kanban cols 250px */
  .kanban-col {
    flex: 0 0 250px !important;
    width: 250px !important;
    min-width: 250px !important;
    max-width: 250px !important;
  }
}

/* === MOBILE ≤768: refinos finales sobre lo ya hecho === */
@media (max-width: 768px) {
  /* Sidebar drawer ancho razonable */
  .sidebar.mobile-open {
    width: 280px !important; max-width: 82vw !important;
    padding-top: calc(16px + env(safe-area-inset-top)) !important;
  }
  .sidebar .nav-item {
    flex-direction: row !important;
    justify-content: flex-start !important;
    padding: 14px 16px !important;
    font-size: 14px !important;
  }
  .sidebar .nav-item svg { width: 22px; height: 22px; }

  /* Dashboard widgets 1 columna */
  .dashboard-2col { grid-template-columns: 1fr !important; }
  .insight-grid { grid-template-columns: 1fr !important; }

  /* KPIs 2 columnas, valor grande */
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .kpi-card { padding: 12px !important; min-height: 80px; }
  .kpi-card .kpi-value { font-size: 20px !important; line-height: 1.1; }
  .kpi-card .kpi-title, .kpi-card h3 {
    font-size: 10.5px !important;
    margin-bottom: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-2);
  }

  /* Topbar: hide year+entidad filters, more breathing room */
  .topbar { height: 56px !important; padding: 0 12px !important; }
  .topbar-title { font-size: 17px !important; font-weight: 700; }

  /* FAB más visible con label rotativo */
  .fab-mobile { width: 58px !important; height: 58px !important; }

  /* Bottom nav labels más pequeños para no apretarse */
  .mobile-bottom-nav .mbn-item span { font-size: 9.5px; }

  /* Cards uniformes con sombra suave para destacarse */
  .kcard {
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border-color: var(--border-2);
  }
  .kcard:active { background: var(--bg); }

  /* Formularios en modales: labels arriba, inputs full ancho */
  .modal label, .modal .form-row label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
  }
  .modal input, .modal select, .modal textarea {
    width: 100% !important;
    box-sizing: border-box;
  }

  /* Botones de acción del modal: stack full width */
  .modal-actions button, .modal-actions .btn {
    flex: 1;
    min-height: 44px;
    font-size: 14px;
    font-weight: 700;
  }

  /* Páginas con padding lateral pequeño */
  .page { padding: 14px 12px 90px !important; }
  .page-header h2 { font-size: 22px !important; line-height: 1.2; }
  .page-header .sub { font-size: 12px; }

  /* Tabla -> card view alternativo para clientes (cuando .table-card-mobile añadida) */
  /* (Se aplica solo si se añade la clase) */

  /* Switch / pills tab bar: scroll horizontal sin barra */
  [class*="tab"], .tabs, .ct-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    padding-bottom: 2px;
  }

  /* Notification badges en bottom nav */
  .mobile-bottom-nav .mbn-item { position: relative; }
  .mobile-bottom-nav .mbn-item .mbn-badge {
    position: absolute;
    top: 4px; right: calc(50% - 22px);
    background: var(--red); color: white;
    font-size: 9px; font-weight: 800;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
  }

  /* Pipeline: stage funnel más pequeño */
  .pipeline-funnel { padding: 10px !important; }
  .pipeline-funnel .stage-bar { height: 28px !important; }

  /* Inbox: detail full-screen overlay-style */
  .inbox-msg { padding: 12px !important; min-height: 64px; }
  .inbox-msg .subject { font-size: 13px; font-weight: 600; }
  .inbox-msg .from { font-size: 11.5px; }

  /* Charts contained */
  canvas { max-width: 100%; height: auto !important; }

  /* Filter pills más fáciles de tocar */
  .filter-pill, .chip-filter {
    padding: 8px 14px !important;
    font-size: 12px !important;
    min-height: 36px;
  }
}

/* === MOBILE TINY ≤480px === */
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .topbar-title { font-size: 15px !important; }
  .page-header h2 { font-size: 19px !important; }
  .modal h3 { font-size: 16px !important; }
  .mobile-bottom-nav .mbn-item span { font-size: 9px; }
}

/* === SCROLL HINT ARROW EN KANBAN MOBILE === */
@media (max-width: 768px) {
  .kanban {
    position: relative;
  }
  .kanban::after {
    content: '';
    position: sticky;
    right: 0; top: 50%;
    width: 3px; height: 40px;
    background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.1), transparent);
    pointer-events: none;
  }
}

/* === LANDSCAPE PHONE: ajusta el bottom nav que sino ocupa demasiado === */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .mobile-bottom-nav {
    padding: 3px 4px calc(3px + env(safe-area-inset-bottom));
  }
  .mobile-bottom-nav .mbn-item {
    min-height: 42px;
    padding: 4px;
  }
  .mobile-bottom-nav .mbn-item svg { width: 18px; height: 18px; }
  .mobile-bottom-nav .mbn-item span { font-size: 9px; }
  .page { padding-bottom: 70px !important; }
}

/* === ACCESIBILIDAD: focus visible mejorado === */
button:focus-visible, a:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* === Notch / safe-area en topbar ya aplicado en V2 === */

/* === Dark mode tablet/laptop polish === */
[data-mode="dark"] .nav-item:hover {
  background: rgba(255,255,255,0.04);
}

/* === FAB se oculta cuando hay modal abierto === */
body:has(.modal-overlay.open) .fab-mobile,
body:has(.modal-overlay.show) .fab-mobile {
  display: none !important;
}

/* === Hide bottom nav cuando teclado mobile está abierto (heurística) === */
@media (max-width: 768px) {
  .modal-overlay.open + body, .modal-overlay.show + body {
    overflow: hidden;
  }
}

/* === Iconos del bottom nav: mejor contraste cuando activa === */
.mobile-bottom-nav .mbn-item.active svg {
  stroke-width: 2.3;
}

/* === Topbar sticky con blur backdrop en mobile (más premium) === */
@media (max-width: 768px) {
  .topbar {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: color-mix(in srgb, var(--card) 88%, transparent);
  }
}

/* === Form inputs touch-friendly en general === */
@media (max-width: 1024px) {
  input[type="text"], input[type="email"], input[type="tel"],
  input[type="number"], input[type="date"], input[type="password"], input[type="search"],
  textarea, select {
    min-height: 42px;
  }
}

/* === Botones grandes y sólidos === */
@media (max-width: 768px) {
  .btn-primary {
    background: var(--primary) !important;
    color: white !important;
    font-weight: 700;
  }
  .btn-primary:hover { background: var(--primary) !important; }
  .btn-secondary { min-height: 40px; }
}
