/* ==========================================================================
   LOGICDATA CRM · Sistema de diseño (mobile-first, azul moderno)
   ========================================================================== */
:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --accent: #06b6d4;
  --grad: linear-gradient(135deg, #2563eb 0%, #1e40af 55%, #0b1a3a 100%);
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f8;
  --border: #e3e9f2;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --subtle: #94a3b8;
  --success: #059669; --success-bg: #ecfdf5; --success-bd: #a7f3d0;
  --warning: #b45309; --warning-bg: #fffbeb; --warning-bd: #fde68a;
  --danger: #dc2626;  --danger-bg: #fef2f2;  --danger-bd: #fecaca;
  --info: #0369a1;    --info-bg: #f0f9ff;    --info-bd: #bae6fd;
  --neutral: #475569; --neutral-bg: #f1f5f9; --neutral-bd: #e2e8f0;
  --wa: #25d366; --wa-dark: #128c7e;
  --sidebar: #0b1a3a;
  --sidebar-2: #102a5c;
  --sidebar-text: #aebcdb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --sidebar-w: 264px;
  --topbar-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2e; --surface-2: #0f1729; --surface-3: #18233b; --border: #1f2c47;
  --text: #e6ecf7; --text-2: #c3cee3; --muted: #8fa0bf; --subtle: #6b7c9c;
  --primary-50: #13254a; --primary-100: #1a3260;
  --success-bg: #062a20; --success-bd: #0d5c45; --success: #34d399;
  --warning-bg: #2b1d05; --warning-bd: #6b4a0b; --warning: #fbbf24;
  --danger-bg: #2c0d10; --danger-bd: #7a1d24; --danger: #f87171;
  --info-bg: #072338; --info-bd: #0c4a6e; --info: #38bdf8;
  --neutral-bg: #18233b; --neutral-bd: #263555; --neutral: #a5b4cf;
  --sidebar: #070d1a; --sidebar-2: #0d1a36;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111a2e; --surface-2: #0f1729; --surface-3: #18233b; --border: #1f2c47;
    --text: #e6ecf7; --text-2: #c3cee3; --muted: #8fa0bf; --subtle: #6b7c9c;
    --primary-50: #13254a; --primary-100: #1a3260;
    --success-bg: #062a20; --success-bd: #0d5c45; --success: #34d399;
    --warning-bg: #2b1d05; --warning-bd: #6b4a0b; --warning: #fbbf24;
    --danger-bg: #2c0d10; --danger-bd: #7a1d24; --danger: #f87171;
    --info-bg: #072338; --info-bd: #0c4a6e; --info: #38bdf8;
    --neutral-bg: #18233b; --neutral-bd: #263555; --neutral: #a5b4cf;
    --sidebar: #070d1a; --sidebar-2: #0d1a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .8rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
img { max-width: 100%; }
.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; stroke-width: 2; }
code, .mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85em; }
::selection { background: var(--primary-100); }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .25s ease;
}
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.25rem; color: #fff; }
.sidebar-brand .logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #06b6d4); color: #fff; font-weight: 800; font-size: 1.05rem;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .45);
}
.sidebar-brand b { display: block; font-size: 1rem; letter-spacing: .02em; }
.sidebar-brand span { font-size: .72rem; color: var(--sidebar-text); letter-spacing: .12em; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .5rem .75rem 1rem; scrollbar-width: thin; }
.nav-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #6f82ab; padding: 1rem .75rem .4rem; }
.nav-link {
  display: flex; align-items: center; gap: .75rem; padding: .58rem .75rem; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 500; transition: background .15s, color .15s; position: relative;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: rgba(59, 130, 246, .2); color: #fff; }
.nav-link.active::before { content: ""; position: absolute; left: -.75rem; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: #60a5fa; }
.nav-link .count { margin-left: auto; font-size: .7rem; background: var(--danger); color: #fff; border-radius: 99px; padding: 0 .45rem; font-weight: 600; }
.nav-link .tag { margin-left: auto; font-size: .62rem; background: rgba(255,255,255,.1); color: #cfe0ff; border-radius: 6px; padding: .05rem .4rem; }
.sidebar-foot { padding: .9rem 1rem; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; gap: .65rem; }
.sidebar-foot .who { flex: 1; min-width: 0; color: #fff; font-size: .85rem; }
.sidebar-foot .who small { display: block; color: var(--sidebar-text); }
.overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.show { opacity: 1; pointer-events: auto; }

.app-main { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 72px; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: .6rem;
  padding: 0 16px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { padding-left: 2.4rem; background: var(--surface-2); border-color: transparent; }
.topbar .search input:focus { background: var(--surface); }
.topbar .search .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.topbar .search kbd { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; display: none; z-index: 70; }
.search-results.show { display: block; }
.search-results .grp { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: .6rem .9rem .2rem; }
.search-results a { display: flex; gap: .7rem; align-items: center; padding: .55rem .9rem; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--primary-50); }
.search-results a small { display: block; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.content { padding: 16px; width: 100%; max-width: 1480px; margin: 0 auto; flex: 1; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: var(--muted); padding: .3rem 0; border-radius: 10px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.fab { color: #fff; }
.bottom-nav a.fab span.c { width: 44px; height: 44px; margin-top: -18px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); box-shadow: 0 8px 20px rgba(37, 99, 235, .45); }

@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .app-main { margin-left: var(--sidebar-w); padding-bottom: 0; }
  .bottom-nav, .only-mobile, .menu-btn { display: none !important; }
  .content { padding: 28px; }
  .topbar { padding: 0 28px; }
}
@media (max-width: 1023px) { .only-desktop { display: none !important; } }
@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-header .title { display: flex; align-items: center; gap: .8rem; min-width: 0; }
.page-header .title .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex-shrink: 0; }
.page-header p { margin: .15rem 0 0; color: var(--muted); }
.page-header .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ---------- Grid & utilities ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .grid-2, .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .grid-main-r { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
  .span-2 { grid-column: span 2; }
}
@media (min-width: 1280px) { .grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 640px) and (max-width: 1279px) { .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flex { display: flex; } .flex-col { flex-direction: column; } .wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .items-start { align-items: flex-start; } .justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; } .flex-1 { flex: 1; min-width: 0; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: 1rem; } .mb-4 { margin-bottom: 1.5rem; }
.ml-auto { margin-left: auto; } .p-0 { padding: 0 !important; }
.text-muted { color: var(--muted); } .text-subtle { color: var(--subtle); } .text-right { text-align: right; } .text-center { text-align: center; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-primary { color: var(--primary); } .text-info { color: var(--info); }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; } .nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-100 { width: 100%; } .hidden { display: none !important; }
.fs-lg { font-size: 1.15rem; } .fs-xl { font-size: 1.6rem; } .fs-sm { font-size: .8rem; } .fs-xs { font-size: .72rem; }
.pre { white-space: pre-line; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h3 { display: flex; align-items: center; gap: .5rem; font-size: .95rem; }
.card-header .sub { color: var(--muted); font-size: .8rem; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card.hover { transition: transform .15s, box-shadow .15s, border-color .15s; }
.card.hover:hover { transform: translateY(-2px); border-color: var(--primary-100); box-shadow: 0 10px 30px rgba(37, 99, 235, .1); }
.card-link { color: inherit; display: block; }
.card-link:hover { color: inherit; }
.section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin: 1.25rem 0 .6rem; }

/* ---------- KPIs ---------- */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: .8rem; font-weight: 500; display: flex; align-items: center; gap: .4rem; }
.kpi .value { font-size: 1.5rem; font-weight: 750; margin-top: .3rem; letter-spacing: -.02em; white-space: nowrap; }
.kpi .foot { display: flex; align-items: center; gap: .4rem; margin-top: .3rem; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
.kpi .ico { position: absolute; right: 14px; top: 14px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.kpi.success .ico { background: var(--success-bg); color: var(--success); }
.kpi.warning .ico { background: var(--warning-bg); color: var(--warning); }
.kpi.danger .ico { background: var(--danger-bg); color: var(--danger); }
.kpi.info .ico { background: var(--info-bg); color: var(--info); }
.kpi.hero { background: var(--grad); color: #fff; border: 0; }
.kpi.hero .label, .kpi.hero .foot { color: rgba(255, 255, 255, .8); }
.kpi.hero .ico { background: rgba(255, 255, 255, .15); color: #fff; }
.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; border-radius: 6px; padding: 0 .35rem; font-size: .75rem; }
.trend.up { color: var(--success); background: var(--success-bg); }
.trend.down { color: var(--danger); background: var(--danger-bg); }
.kpi.hero .trend { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid transparent; font: 600 .86rem/1 inherit; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--primary-100); outline-offset: 1px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-light { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-light:hover { background: var(--surface-2); color: var(--text); border-color: #cfd8e6; }
.btn-soft { background: var(--primary-50); color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); color: var(--primary-600); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); color: #fff; }
.btn-danger-soft { background: var(--danger-bg); color: var(--danger); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 32px; padding: 0 10px; font-size: .8rem; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: .74rem; border-radius: 7px; gap: .3rem; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-xs { width: 26px; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.icon-btn { position: relative; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
kbd { font: 600 .7rem/1 inherit; color: var(--muted); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: .2rem .4rem; background: var(--surface); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 1.4; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.no-dot::before { display: none; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bd); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: var(--info-bd); }
.badge-primary { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); border-color: var(--neutral-bd); }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 7px; font-size: .74rem; font-weight: 500; background: var(--surface-3); color: var(--text-2); }
.chip-primary { background: var(--primary-50); color: var(--primary); }

/* ---------- Forms ---------- */
label, .form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
.form-control, .form-select {
  width: 100%; min-height: 40px; padding: .55rem .8rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { min-height: auto; resize: vertical; }
.form-control:focus, .form-select:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.form-control::placeholder { color: var(--subtle); }
.form-select { appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; }
select[multiple].form-select { background-image: none; padding-right: .8rem; min-height: 120px; }
input[type="color"].form-control { padding: .2rem; height: 40px; }
input[type="file"].form-control { padding: .4rem; }
.form-check-input { width: 18px; height: 18px; accent-color: var(--primary); vertical-align: middle; margin: 0 .4rem 0 0; }
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .wide { grid-column: 1 / -1; } }
@media (min-width: 1100px) { .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.field .help { font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.field .errors { color: var(--danger); font-size: .78rem; margin-top: .3rem; }
.field.has-error .form-control, .field.has-error .form-select { border-color: var(--danger); }
.field-check { display: flex; align-items: center; gap: .2rem; padding-top: 1.5rem; }
.field-check label { margin: 0; font-weight: 500; }
ul.checks, .checks ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.checks label { display: inline-flex; align-items: center; gap: .3rem; font-weight: 500; padding: .35rem .65rem; border: 1px solid var(--border); border-radius: 9px; margin: 0; cursor: pointer; }
.checks input { accent-color: var(--primary); }
.input-group { display: flex; }
.input-group .form-control { border-radius: 10px 0 0 10px; }
.input-group .btn { border-radius: 0 10px 10px 0; height: auto; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; margin-bottom: 1rem; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: var(--info-bd); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bd); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }

/* ---------- Filters toolbar ---------- */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 16px; }
.filters .form-control, .filters .form-select { width: auto; min-width: 150px; flex: 1 1 150px; min-height: 38px; }
.filters .grow { flex: 3 1 220px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { padding: .38rem .75rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .8rem; border: 0; background: none; cursor: pointer; }
.seg a.active, .seg button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(15, 23, 42, .1); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: .7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table-sm td, .table-sm th { padding: .5rem .75rem; }
tr.clickable { cursor: pointer; }
.cell-main { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.cell-main b { display: block; color: var(--text); font-weight: 600; }
.cell-main small { color: var(--muted); }

/* ---------- Avatars ---------- */
.avatar { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: .8rem; flex-shrink: 0; background: var(--primary); }
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; border-radius: 8px; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.1rem; border-radius: 16px; }
.avatar.round { border-radius: 50%; }
.avatars { display: flex; } .avatars .avatar { border: 2px solid var(--surface); margin-left: -8px; } .avatars .avatar:first-child { margin-left: 0; }

/* ---------- Progress & meters ---------- */
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 99px; transition: width .4s; }
.progress.sm { height: 5px; }
.progress.success > span { background: var(--success); } .progress.warning > span { background: #f59e0b; } .progress.danger > span { background: var(--danger); }
.meter { margin-bottom: 1rem; }
.meter .top { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: .35rem; }
.meter .top b { font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: 18px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: .4rem; padding: .7rem .9rem; color: var(--muted); font-weight: 600; font-size: .85rem; border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .n { font-size: .7rem; background: var(--surface-3); color: var(--muted); border-radius: 99px; padding: 0 .45rem; }
.tab.active .n { background: var(--primary-50); color: var(--primary); }
.tab-panel { display: none; animation: fade .2s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .35rem; z-index: 80; display: none; }
.dropdown-menu.left { left: 0; right: auto; }
.dropdown.open .dropdown-menu { display: block; animation: aparecer .15s; }
.dropdown-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .7rem; border-radius: 8px; color: var(--text-2); font: 500 .85rem inherit; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: .3rem 0; }
.dropdown-header { padding: .5rem .7rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.notif-menu { width: min(380px, 92vw); max-height: 70vh; overflow: auto; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 110; display: none; align-items: flex-end; justify-content: center; background: rgba(2, 6, 23, .55); padding: 0; }
.modal.show { display: flex; animation: aparecer .15s; }
.modal-dialog { background: var(--surface); width: 100%; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg); }
@media (min-width: 640px) { .modal { align-items: center; padding: 16px; } .modal-dialog { max-width: 560px; border-radius: 18px; } .modal-dialog.lg { max-width: 820px; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- Toasts / messages ---------- */
.toasts { position: fixed; z-index: 150; right: 16px; left: 16px; bottom: 84px; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
@media (min-width: 640px) { .toasts { left: auto; top: 76px; bottom: auto; width: 380px; } }
.toast { pointer-events: auto; display: flex; gap: .65rem; align-items: flex-start; padding: .85rem 1rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); box-shadow: var(--shadow-lg); animation: slide .25s ease; }
.toast.success { border-left-color: var(--success); } .toast.success .icon { color: var(--success); }
.toast.danger { border-left-color: var(--danger); } .toast.danger .icon { color: var(--danger); }
.toast.warning { border-left-color: #f59e0b; } .toast.warning .icon { color: var(--warning); }
.toast.info .icon { color: var(--primary); }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; }
@keyframes slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: .75rem; padding: .75rem 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .main b { display: block; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .main small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.list-item { color: inherit; } a.list-item:hover { background: var(--surface-2); }
.ico-box { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-50); color: var(--primary); }
.ico-box.success { background: var(--success-bg); color: var(--success); }
.ico-box.warning { background: var(--warning-bg); color: var(--warning); }
.ico-box.danger { background: var(--danger-bg); color: var(--danger); }
.ico-box.info { background: var(--info-bg); color: var(--info); }
.ico-box.neutral { background: var(--neutral-bg); color: var(--neutral); }
.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: .55rem 1rem; margin: 0; font-size: .86rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .ico-box { width: 56px; height: 56px; margin: 0 auto .8rem; border-radius: 16px; }
.empty h3 { color: var(--text); margin-bottom: .3rem; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 8px; }
.tl-item { position: relative; display: flex; gap: .85rem; padding-bottom: 1.1rem; }
.tl-item::before { content: ""; position: absolute; left: 17px; top: 38px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-item .ico-box { width: 36px; height: 36px; z-index: 1; border: 3px solid var(--surface); }
.tl-item .body { flex: 1; min-width: 0; padding-top: .25rem; }
.tl-item .body b { font-weight: 600; }
.tl-item .meta { font-size: .75rem; color: var(--muted); }
.tl-item .txt { color: var(--text-2); font-size: .85rem; margin-top: .15rem; white-space: pre-line; word-break: break-word; }

/* ---------- Stepper (etapas del proyecto) ---------- */
.stepper { display: flex; overflow-x: auto; padding: .25rem 0 .5rem; gap: 0; scrollbar-width: thin; }
.step { flex: 1 0 96px; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; font-size: .72rem; color: var(--muted); }
.step::before { content: ""; position: absolute; top: 18px; left: -50%; right: 50%; height: 3px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border); z-index: 1; margin-bottom: .4rem; color: var(--subtle); }
.step.done .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.done::before, .step.current::before { background: var(--primary); }
.step.current .dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 5px var(--primary-50); }
.step.current { color: var(--primary); font-weight: 700; }
.step.done { color: var(--text-2); }
.step button { all: unset; cursor: pointer; display: contents; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kanban-col { background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 160px; display: flex; flex-direction: column; }
.kanban-col.over { outline: 2px dashed var(--primary); background: var(--primary-50); }
.kanban-col-head { display: flex; align-items: center; gap: .5rem; padding: .25rem .35rem .65rem; font-weight: 650; font-size: .85rem; }
.kanban-col-head .n { margin-left: auto; font-size: .72rem; color: var(--muted); background: var(--surface); border-radius: 99px; padding: 0 .5rem; }
.kanban-items { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 60px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: grab; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); transition: box-shadow .15s, transform .15s; }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: .5; transform: rotate(2deg); }
.kanban-card b { display: block; font-size: .86rem; color: var(--text); margin-bottom: .2rem; }
.kanban-card .meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .74rem; color: var(--muted); margin-top: .5rem; }
.kanban.compact { grid-auto-columns: minmax(230px, 1fr); }

/* ---------- Project cards ---------- */
.p-card { padding: 16px; display: flex; flex-direction: column; gap: .7rem; height: 100%; }
.p-card .top { display: flex; align-items: flex-start; gap: .7rem; }
.p-card h3 { font-size: .95rem; }
.p-card .stack { display: flex; flex-wrap: wrap; gap: .3rem; }
.p-card .bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; font-size: .78rem; color: var(--muted); }

/* ---------- Documento (cotización / factura) ---------- */
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.doc-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; padding: 22px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--primary-50), transparent); }
.doc-box { border: 2px solid var(--primary); border-radius: 12px; padding: .7rem 1.1rem; text-align: center; min-width: 210px; }
.doc-box b { display: block; font-size: 1.1rem; color: var(--primary); }
.doc-totals { margin-left: auto; width: 100%; max-width: 320px; }
.doc-totals .row { display: flex; justify-content: space-between; padding: .35rem 0; font-size: .88rem; }
.doc-totals .row.total { border-top: 2px solid var(--text); margin-top: .3rem; padding-top: .6rem; font-size: 1.1rem; font-weight: 750; }

/* ---------- Items editor ---------- */
.items-editor .item-row { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; background: var(--surface-2); position: relative; }
.items-editor .item-row .desc { grid-column: 1 / -1; }
.items-editor .item-row .sub { grid-column: 1 / -1; text-align: right; font-weight: 700; }
.items-editor .item-row .del { position: absolute; top: 6px; right: 6px; }
.items-editor .item-row .detalle { grid-column: 1 / -1; }
.items-editor .item-row.removed { display: none; }
.items-editor label { font-size: .7rem; margin-bottom: .2rem; }
@media (min-width: 900px) {
  .items-editor .item-row { grid-template-columns: minmax(0, 3fr) 90px 110px 130px 80px 120px 36px; align-items: end; background: var(--surface); }
  .items-editor .item-row .desc { grid-column: auto; }
  .items-editor .item-row .sub { grid-column: auto; padding-bottom: .55rem; }
  .items-editor .item-row .del { position: static; }
  .items-editor .item-row .detalle { grid-column: 1 / -1; }
}

/* ---------- WhatsApp ---------- */
.wa { display: grid; grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 190px); min-height: 480px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
@media (min-width: 1024px) { .wa, .wa.with-side { grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 150px); } }
@media (min-width: 1500px) { .wa.with-side { grid-template-columns: 320px minmax(0, 1fr) 290px; } }
@media (max-width: 1499px) { .wa .wa-side { display: none; } }
@media (max-width: 1023px) { .wa.chat-open .wa-list { display: none; } .wa:not(.chat-open) .wa-chat { display: none; } }
.wa-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.wa-list .head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .5rem; }
.wa-convs { overflow-y: auto; flex: 1; }
.wa-conv { display: flex; gap: .7rem; padding: .75rem 12px; border-bottom: 1px solid var(--border); color: inherit; align-items: center; }
.wa-conv:hover { background: var(--surface-2); color: inherit; }
.wa-conv.active { background: var(--primary-50); }
.wa-conv .main { flex: 1; min-width: 0; }
.wa-conv .main b { display: block; font-weight: 600; color: var(--text); }
.wa-conv .main small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-conv .side { text-align: right; font-size: .7rem; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.wa-conv .unread { background: var(--wa); color: #fff; border-radius: 99px; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; font-weight: 700; font-size: .7rem; }
.wa-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.wa-chat .head { display: flex; align-items: center; gap: .7rem; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.wa-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; background-color: var(--surface-2); background-image: radial-gradient(circle at 1px 1px, rgba(100, 116, 139, .12) 1px, transparent 0); background-size: 18px 18px; }
.bubble { max-width: min(78%, 560px); padding: .55rem .8rem .35rem; border-radius: 12px; box-shadow: 0 1px 1px rgba(15, 23, 42, .08); font-size: .88rem; white-space: pre-wrap; word-wrap: break-word; position: relative; animation: fade .2s; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; font-size: .66rem; color: var(--muted); margin-top: .2rem; }
.bubble.in { align-self: flex-start; background: var(--surface); border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: #d9fdd3; color: #0b1a0f; border-top-right-radius: 4px; }
.bubble.bot { align-self: flex-end; background: #dbeafe; color: #0b1a3a; border-top-right-radius: 4px; }
:root[data-theme="dark"] .bubble.out { background: #134d37; color: #e6f7ee; }
:root[data-theme="dark"] .bubble.bot { background: #1b3466; color: #e6ecf7; }
.bubble .who { font-size: .68rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: .25rem; margin-bottom: .1rem; }
.bubble.out .who { color: var(--wa-dark); }
.bubble .file { display: flex; align-items: center; gap: .5rem; background: rgba(0, 0, 0, .05); border-radius: 8px; padding: .45rem .6rem; margin-bottom: .35rem; color: inherit; font-weight: 600; }
.bubble.sys { align-self: center; background: var(--warning-bg); color: var(--warning); font-size: .74rem; padding: .3rem .7rem; border-radius: 8px; box-shadow: none; }
.bubble.fail { outline: 1px solid var(--danger); }
.wa-day { align-self: center; font-size: .7rem; background: var(--surface); color: var(--muted); padding: .2rem .6rem; border-radius: 8px; margin: .4rem 0; box-shadow: 0 1px 1px rgba(15,23,42,.06); }
.wa-compose { border-top: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.wa-compose .row { display: flex; gap: .5rem; align-items: flex-end; }
.wa-compose textarea { resize: none; max-height: 140px; }
.wa-sim { background: var(--warning-bg); border: 1px dashed var(--warning-bd); border-radius: 10px; padding: 8px; }
.wa-sim summary { cursor: pointer; list-style: none; }
.wa-sim summary::-webkit-details-marker { display: none; }
.wa-sim[open] summary { margin-bottom: .5rem; }
.typing { align-self: flex-end; font-size: .75rem; color: var(--muted); font-style: italic; }
.wa-side { border-left: 1px solid var(--border); overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Feed GitHub ---------- */
.feed-item { display: flex; gap: .75rem; padding: .8rem 18px; border-bottom: 1px solid var(--border); }
.feed-item.nuevo { animation: flash 2.5s ease; }
@keyframes flash { 0% { background: var(--primary-100); } 100% { background: transparent; } }
.commit-type { font-size: .66rem; font-weight: 700; text-transform: uppercase; padding: .05rem .4rem; border-radius: 5px; background: var(--neutral-bg); color: var(--neutral); }
.commit-type.feat { background: var(--success-bg); color: var(--success); }
.commit-type.fix, .commit-type.hotfix { background: var(--danger-bg); color: var(--danger); }
.commit-type.docs { background: var(--info-bg); color: var(--info); }
.commit-type.refactor, .commit-type.perf { background: var(--primary-50); color: var(--primary); }
.live { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; font-weight: 600; color: var(--success); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, .5); } 70% { box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); } 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); } }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.bars span { flex: 1; background: var(--primary-100); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.bars span.hoy { background: var(--primary); }

/* ---------- Secret field ---------- */
.secret { display: inline-flex; align-items: center; gap: .3rem; font-family: ui-monospace, Consolas, monospace; background: var(--surface-3); border-radius: 8px; padding: .2rem .5rem; font-size: .8rem; max-width: 100%; }
.secret span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--bg); }
@media (min-width: 960px) { .auth { grid-template-columns: 1.1fr 1fr; } }
.auth-hero { display: none; background: var(--grad); color: #fff; padding: 48px; position: relative; overflow: hidden; }
@media (min-width: 960px) { .auth-hero { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-hero::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -160px; bottom: -200px; background: radial-gradient(circle, rgba(6, 182, 212, .45), transparent 65%); }
.auth-hero h1 { color: #fff; font-size: 2.2rem; line-height: 1.15; max-width: 480px; }
.auth-hero ul { list-style: none; padding: 0; display: grid; gap: .8rem; max-width: 460px; position: relative; z-index: 1; }
.auth-hero li { display: flex; gap: .7rem; align-items: center; color: rgba(255, 255, 255, .9); }
.auth-hero li span { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .14); display: grid; place-items: center; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }

/* ---------- Misc ---------- */
.dot-status { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--subtle); }
.dot-status.ok { background: var(--success); box-shadow: 0 0 0 4px var(--success-bg); }
.dot-status.degradado { background: #f59e0b; box-shadow: 0 0 0 4px var(--warning-bg); }
.dot-status.caido { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.pagination { display: flex; gap: .3rem; justify-content: center; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 36px; height: 36px; padding: 0 .6rem; border-radius: 9px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: .82rem; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.legend { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .78rem; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: .3rem; vertical-align: -1px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .quick-actions { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .quick-actions { grid-template-columns: repeat(6, 1fr); } }
.qa { display: flex; flex-direction: column; gap: .45rem; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .84rem; transition: all .15s; box-shadow: var(--shadow); }
.qa:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }
.qa .ico-box { width: 38px; height: 38px; }
.rank { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; }
.rank .bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: .3rem; }
.rank .bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.copy { cursor: pointer; }
.status-line { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.mini-stat { padding: .7rem .9rem; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border); }
.mini-stat small { display: block; color: var(--muted); font-size: .72rem; }
.mini-stat b { font-size: 1.05rem; }
.cover { height: 6px; border-radius: var(--radius) var(--radius) 0 0; }
.error-page { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.error-page .code { font-size: 4rem; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media print { .sidebar, .topbar, .bottom-nav, .page-header .actions, .no-print { display: none !important; } .app-main { margin: 0; } }

/* ==========================================================================
   Componentes: selector con búsqueda, vista rápida, adjuntos, calendario
   ========================================================================== */
.ld-select { position: relative; display: flex; gap: .4rem; align-items: stretch; min-width: 0; width: 100%; }
.ld-native { position: absolute !important; opacity: 0 !important; pointer-events: none !important; width: 1px !important; height: 1px !important; left: 0; bottom: 0; }
.ld-trigger { text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; font: inherit; color: var(--text); }
.ld-trigger.placeholder { color: var(--subtle); }
.ld-trigger[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .12); }
.ld-nuevo { height: auto; min-height: 40px; flex-shrink: 0; }
.ld-select.con-nuevo { container-type: inline-size; }
@container (max-width: 300px) { .ld-nuevo span { display: none; } .ld-nuevo { width: 40px; padding: 0; } }
.filters .ld-select { flex: 1 1 160px; min-width: 150px; width: auto; }
.filters .ld-select .ld-trigger { min-height: 38px; }
.ld-panel { position: fixed; z-index: 130; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: aparecer .12s; }
.ld-buscar { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border-bottom: 1px solid var(--border); color: var(--subtle); }
.ld-buscar input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; width: 100%; padding: .2rem 0; }
.ld-panel ul { list-style: none; margin: 0; padding: .3rem; overflow-y: auto; flex: 1; }
.ld-panel li { padding: .5rem .65rem; border-radius: 8px; cursor: pointer; font-size: .86rem; color: var(--text-2); }
.ld-panel li.activo, .ld-panel li:hover { background: var(--primary-50); color: var(--primary); }
.ld-panel li.sel { font-weight: 700; color: var(--primary); }
.ld-panel li.sel::after { content: " \2713"; }
.ld-panel li.vacio { color: var(--subtle); }
.ld-panel li.disabled { opacity: .5; cursor: not-allowed; }
.ld-panel li.nada { color: var(--muted); cursor: default; text-align: center; }
.ld-crear { border: 0; border-top: 1px solid var(--border); background: var(--surface-2); color: var(--primary); font: 600 .85rem inherit; padding: .65rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: .4rem; }
.ld-crear:hover { background: var(--primary-50); }
.autocompletado { background-color: var(--success-bg) !important; transition: background-color 1.5s; }

/* Vista rápida */
.drawer-overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, .45); z-index: 95; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-overlay.show { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--bg); z-index: 96; transform: translateX(100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.drawer.show { transform: none; }
.drawer-cerrar { position: absolute; top: 12px; right: 12px; z-index: 2; background: var(--surface); }
.drawer-body { overflow-y: auto; flex: 1; padding: 20px; }
.rapida-head { display: flex; gap: .9rem; align-items: flex-start; padding-right: 44px; margin-bottom: 14px; }
.rapida-head h2 { font-size: 1.15rem; }
.rapida-acciones { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 16px; }
.drawer .card { margin-bottom: 14px; }
.drawer .tabs { margin-bottom: 12px; }
tr[data-rapida], [data-rapida].card { cursor: pointer; }
tr[data-rapida]:focus { outline: 2px solid var(--primary-100); outline-offset: -2px; }
.acciones { display: inline-flex; gap: 2px; align-items: center; justify-content: flex-end; }
.acciones form { display: inline; }
.acciones .btn { color: var(--muted); }
.acciones .btn:hover { color: var(--primary); }
.acciones .btn.peligro:hover { color: var(--danger); background: var(--danger-bg); }

/* Filtros avanzados */
details.avanzado { margin: -6px 0 16px; }
details.avanzado summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .82rem; list-style: none; display: inline-flex; align-items: center; gap: .35rem; }
details.avanzado summary::-webkit-details-marker { display: none; }
details.avanzado .filters { margin: .6rem 0 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.filters .rango { display: flex; align-items: center; gap: .35rem; flex: 1 1 260px; }
.filters .rango span { color: var(--muted); font-size: .8rem; }
.filters .rango .form-control { min-width: 110px; }

/* Adjuntos e imágenes */
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.adj { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.adj .thumb { height: 92px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); overflow: hidden; }
.adj .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.adj:hover .thumb img { transform: scale(1.05); }
.adj .pie { padding: .4rem .5rem; font-size: .72rem; }
.adj .pie b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.adj .pie small { color: var(--muted); }
.adj .ops { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.adj:hover .ops, .adj:focus-within .ops { opacity: 1; }
@media (hover: none) { .adj .ops { opacity: 1; } }
.adj .ops .btn { background: rgba(255, 255, 255, .92); color: #0f172a; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.adj .ops label.btn { margin: 0; font-weight: 600; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; border: 2px dashed var(--border); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; margin: 0; font-weight: 500; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.dropzone input[type=file] { display: none; }
.file-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.fp-item { width: 92px; text-align: center; }
.fp-item img, .fp-item .fp-ico { width: 92px; height: 70px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: grid; place-items: center; background: var(--surface-3); }
.fp-item small { display: block; font-size: .66rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-actual { display: block; max-width: 160px; max-height: 110px; border-radius: 10px; border: 1px solid var(--border); margin: .4rem 0; object-fit: contain; background: var(--surface-3); }
.lightbox { position: fixed; inset: 0; z-index: 140; background: rgba(2, 6, 23, .9); display: none; align-items: center; justify-content: center; }
.lightbox.show { display: flex; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 88vh; text-align: center; }
.lightbox img { max-width: 92vw; max-height: 80vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.lightbox figcaption { color: #e2e8f0; margin-top: .6rem; font-size: .85rem; }
.lb-btn { position: absolute; background: rgba(255, 255, 255, .12); color: #fff; border: 0; width: 46px; height: 46px; border-radius: 50%; font-size: 1.8rem; line-height: 1; cursor: pointer; }
.lb-btn:hover { background: rgba(255, 255, 255, .25); }
.lb-cerrar { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; }
.lb-next { right: 16px; top: 50%; }

/* Catálogo de servicios en el editor de ítems */
.catalogo { position: relative; margin-bottom: 12px; }
.catalogo .icon-buscar { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.catalogo input { padding-left: 2.3rem; }
.catalogo-lista { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; list-style: none; margin: 0; padding: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; display: none; }
.catalogo-lista.show { display: block; }
.catalogo-lista li { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 8px; cursor: pointer; }
.catalogo-lista li:hover { background: var(--primary-50); }
.catalogo-lista li b { display: block; font-size: .86rem; color: var(--text); }
.catalogo-lista li small { color: var(--muted); font-size: .74rem; }
.catalogo-lista li.nada { color: var(--muted); cursor: default; justify-content: center; }
.item-row.resaltado { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }

/* Calendario (flatpickr) con la paleta del CRM */
.flatpickr-calendar { font-family: inherit !important; border-radius: 12px !important; box-shadow: var(--shadow-lg) !important; border: 1px solid var(--border) !important; background: var(--surface) !important; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }
.flatpickr-day.today { border-color: var(--primary) !important; }
.flatpickr-months .flatpickr-month, .flatpickr-current-month, .flatpickr-weekday, .flatpickr-day, .flatpickr-time input { color: var(--text) !important; fill: var(--text) !important; }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled { color: var(--subtle) !important; }
.flatpickr-day:hover { background: var(--primary-50) !important; }
.fp-pie { display: flex; justify-content: space-between; padding: 6px 10px 10px; gap: 8px; }
.fp-hoy { border: 0; background: var(--primary-50); color: var(--primary); font: 600 .8rem inherit; padding: .35rem .7rem; border-radius: 8px; cursor: pointer; }
.fp-hoy:last-child { background: var(--surface-3); color: var(--muted); }
input.fecha { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' viewBox='0 0 24 24'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2.2rem; }

@keyframes aparecer { from { transform: translateY(6px); } to { transform: none; } }

/* ==========================================================================
   Planes, módulos y modalidades de contrato
   ========================================================================== */
.contratos { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.contrato-op { position: relative; display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); margin: 0; font-weight: 600; color: var(--text-2); transition: border-color .15s, background .15s; }
.contrato-op:hover { border-color: var(--primary-100); }
.contrato-op input { position: absolute; opacity: 0; pointer-events: none; }
.contrato-op .ico-box { width: 34px; height: 34px; }
.contrato-op small { display: block; font-weight: 500; color: var(--muted); font-size: .72rem; line-height: 1.25; }
.contrato-op > span:last-child { min-width: 0; }
.contrato-op:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.contrato-op:has(input:focus-visible) { outline: 2px solid var(--primary); }
.contrato-nota { margin-top: 10px; font-size: .8rem; color: var(--muted); display: flex; gap: .5rem; align-items: flex-start; }

.planes-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.plan-op { position: relative; display: flex; flex-direction: column; gap: .4rem; padding: 14px; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; margin: 0; font-weight: 400; transition: border-color .15s, box-shadow .15s, transform .15s; }
.plan-op:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.plan-op.activo { border-color: var(--plan, var(--primary)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--plan, var(--primary)) 25%, transparent); }
.plan-op .plan-nombre { font-weight: 700; font-size: 1rem; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.plan-op .plan-precio { font-size: 1.35rem; font-weight: 800; color: var(--plan, var(--primary)); letter-spacing: -.02em; }
.plan-op .plan-precio small { font-size: .75rem; font-weight: 600; color: var(--muted); }
.plan-op ul { list-style: none; padding: 0; margin: .2rem 0 0; display: grid; gap: .15rem; font-size: .76rem; color: var(--text-2); }
.plan-op li::before { content: "\2713  "; color: var(--success); font-weight: 700; }
.plan-op .check { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; color: #fff; }
.plan-op.activo .check { background: var(--plan, var(--primary)); border-color: var(--plan, var(--primary)); }
.plan-op .check .icon { opacity: 0; transition: opacity .15s; }
.plan-op.activo .check .icon { opacity: 1; }
.cinta { position: absolute; top: -9px; left: 14px; background: var(--plan, var(--primary)); color: #fff; font-size: .62rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; text-transform: uppercase; letter-spacing: .06em; }

.modulos-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.modulo-op { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); margin: 0; font-weight: 500; transition: border-color .15s, background .15s; }
.modulo-op:hover { border-color: var(--primary-100); }
.modulo-op input { accent-color: var(--primary); width: 17px; height: 17px; flex-shrink: 0; }
.modulo-op .ico-box { width: 30px; height: 30px; }
.modulo-op b { display: block; font-size: .82rem; color: var(--text); font-weight: 600; }
.modulo-op small { color: var(--muted); font-size: .72rem; }
.modulo-op:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.modulo-op.incluido { opacity: .75; cursor: default; background: var(--success-bg); border-color: var(--success-bd); }
.modulo-op.incluido small { color: var(--success); font-weight: 600; }

/* Página de precios */
.pricing { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); align-items: stretch; }
.price-card { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-top: 4px solid var(--plan, var(--primary)); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 18px; gap: .7rem; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.price-card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(15, 23, 42, .12); }
.price-card.destacado { box-shadow: 0 0 0 2px var(--plan, var(--primary)), var(--shadow); }
.price-card h3 { font-size: 1.15rem; }
.price-card .monto { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; color: var(--text); line-height: 1.1; }
.price-card .monto small { font-size: .85rem; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.price-card .ahorro { font-size: .76rem; color: var(--success); font-weight: 600; }
.price-card ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; font-size: .84rem; }
.price-card li { display: flex; gap: .45rem; align-items: flex-start; }
.price-card li .icon { color: var(--success); margin-top: 2px; }
.price-card li.no { color: var(--subtle); text-decoration: line-through; }
.price-card li.no .icon { color: var(--subtle); }
.price-card .pie { margin-top: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.matriz td.si { color: var(--success); text-align: center; }
.matriz td.nop { color: var(--subtle); text-align: center; }
.matriz th.plan-col { text-align: center; }
.precios-tabla td, .precios-tabla th { white-space: nowrap; }
.car-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.car-row.removed { display: none; }
.car-row .field-check { padding-top: 0; }

/* Selector del cotizador */
[hidden] { display: none !important; }
.plan-op.sin-plan { border-style: dashed; justify-content: center; }
.plan-op:focus-visible { outline: 2px solid var(--plan, var(--primary)); outline-offset: 2px; }
.plan-op .plan-precio:empty { display: none; }
[data-oferta] .contratos + .errors, [data-oferta] .modulos-grid { margin-top: 2px; }
[data-oferta-resumen] { margin-top: 14px; padding: .6rem .8rem; border-radius: 10px; background: var(--primary-50); color: var(--text-2); }

/* Campo con lista desplegable y texto libre (Asunto de la cotización) */
.combo { position: relative; }
.combo > input { padding-right: 2.4rem; }
.combo-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 8px; cursor: pointer; }
.combo-toggle:hover { background: var(--surface-2); color: var(--text); }
.combo .catalogo-lista { max-height: 360px; }
.catalogo-lista li.grupo { cursor: default; padding: .55rem .6rem .25rem; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--subtle); }
.catalogo-lista li.grupo:hover { background: none; }
.catalogo-lista li.activo { background: var(--primary-50); }
.combo .catalogo-lista li[data-i] { align-items: flex-start; gap: .55rem; padding: .45rem .55rem; }
.combo .catalogo-lista .ico-box { width: 28px; height: 28px; flex-shrink: 0; border-radius: 8px; margin-top: 1px; }
.combo .catalogo-lista .op-texto { flex: 1; min-width: 0; }
.combo .catalogo-lista .op-texto b { font-size: .84rem; line-height: 1.3; }
.combo .catalogo-lista .op-texto small { display: block; line-height: 1.35; margin-top: 1px; }
.combo .catalogo-lista .op-precio { color: var(--text-2); font-weight: 600; white-space: nowrap; }
