/* ============================================================
   Console CM Vida Plena — console.css
   Componentes de la app interna. Requiere tokens.css.
   CSS vanilla, sin frameworks. Iconos: Lucide (24px, stroke 2).
   ============================================================ */

/* ---------------------------------------------------------
   RESET / BASE
   --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--fw-semibold); line-height: var(--lh-tight); color: var(--text); }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }

/* números tabulares en datos / tablas / KPIs */
.tnum, .table td, .table th, .kpi-value, .badge, .data { font-variant-numeric: tabular-nums; }

/* foco visible global */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

::selection { background: rgba(0, 170, 240, .22); }

/* utilidades de texto */
.text-muted { color: var(--text-muted); }
.text-soft  { color: var(--text-soft); }
.eyebrow {
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted);
}
.page-title { font-size: var(--text-2xl); font-weight: var(--fw-bold); }

/* ---------------------------------------------------------
   APP SHELL — sidebar (240, colapsable) + topbar (56) + main
   --------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
  transition: grid-template-columns var(--t-ui);
}
.app-shell[data-collapsed="true"] { grid-template-columns: var(--sidebar-collapsed-w) 1fr; }

/* --- Sidebar --- */
.app-sidebar {
  grid-area: sidebar;
  background: var(--ink-deep);
  color: #C4D2DC;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: var(--z-sidebar);
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-h); padding: 0 var(--space-4);
  flex-shrink: 0; color: #fff; font-weight: var(--fw-bold);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  white-space: nowrap;
}
.sidebar-brand .logo-dot {
  width: 26px; height: 26px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: linear-gradient(150deg, var(--cyan), var(--green));
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-3) var(--space-2); display: flex; flex-direction: column; gap: 2px; }
.sidebar-section { font-size: 11px; font-weight: var(--fw-semibold); letter-spacing: .07em; text-transform: uppercase; color: #6B7E8C; padding: var(--space-4) var(--space-3) var(--space-2); white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3); border-radius: var(--radius);
  color: #AFC0CC; font-size: var(--text-base); font-weight: var(--fw-medium);
  cursor: pointer; white-space: nowrap; transition: background var(--t-micro), color var(--t-micro);
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.is-active { background: rgba(0, 170, 240, .16); color: #fff; box-shadow: inset 3px 0 0 var(--cyan); }
.nav-item .nav-badge { margin-left: auto; }

.app-shell[data-collapsed="true"] .sidebar-label,
.app-shell[data-collapsed="true"] .sidebar-section,
.app-shell[data-collapsed="true"] .nav-badge { display: none; }
.app-shell[data-collapsed="true"] .nav-item { justify-content: center; padding: 9px; }
.app-shell[data-collapsed="true"] .sidebar-brand { justify-content: center; padding: 0; }

/* --- Topbar --- */
.app-topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-h); padding: 0 var(--space-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar-search {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: var(--space-2);
  height: 36px; padding: 0 var(--space-3);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  cursor: text; transition: border-color var(--t-micro), box-shadow var(--t-micro);
}
.topbar-search:hover { border-color: var(--border-strong); }
.topbar-search svg { width: 16px; height: 16px; flex-shrink: 0; }
.topbar-search input { flex: 1; border: 0; background: none; font: inherit; color: var(--text); outline: none; }
.topbar-search .kbd { margin-left: auto; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); }

/* --- Main --- */
.app-main { grid-area: main; padding: var(--space-6); overflow-x: hidden; }
.app-main-inner { max-width: var(--content-max); margin: 0 auto; }

/* botón hamburguesa / colapsar */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; min-width: 36px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: none; color: var(--text-soft); cursor: pointer;
  transition: background var(--t-micro), color var(--t-micro);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------------------------------------------------------
   BOTONES — primary / secondary / ghost / danger · sm/md/lg
   --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font); font-size: var(--text-base); font-weight: var(--fw-semibold);
  line-height: 1; white-space: nowrap; cursor: pointer; user-select: none;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 0 var(--space-4); height: 38px;
  transition: background var(--t-micro), border-color var(--t-micro), color var(--t-micro), box-shadow var(--t-micro), transform var(--t-micro);
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { height: 46px; padding: 0 var(--space-6); font-size: var(--text-lg); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 38px; }
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-lg { width: 46px; }

/* primary = verde (acción) */
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 1px 2px rgba(53,125,23,.25); }
.btn-primary:hover { background: var(--green-700); }
.btn-primary:active { background: var(--green-800); }

/* secondary = superficie con borde (acción neutra) */
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-muted); }

/* ghost = sin relleno */
.btn-ghost { background: none; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* danger */
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }

/* loading */
.btn[data-loading="true"] { color: transparent !important; position: relative; pointer-events: none; }
.btn[data-loading="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: #fff; animation: vp-spin .7s linear infinite;
}
.btn-secondary[data-loading="true"]::after, .btn-ghost[data-loading="true"]::after { color: var(--text); }
@keyframes vp-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------
   CARD (densa) + KPI
   --------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: var(--text-lg); font-weight: var(--fw-semibold); }
.card-header .card-actions { margin-left: auto; display: flex; gap: var(--space-2); }
.card-body { padding: var(--space-5); }
.card-footer { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-3); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-5);
}
.kpi-label { font-size: var(--text-sm); color: var(--text-muted); font-weight: var(--fw-medium); }
.kpi-value { font-size: var(--text-3xl); font-weight: var(--fw-bold); margin-top: var(--space-2); letter-spacing: -.01em; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; margin-top: var(--space-2); font-size: var(--text-sm); font-weight: var(--fw-semibold); }
.kpi-delta.up { color: var(--success-text); }
.kpi-delta.down { color: var(--error-text); }

/* ---------------------------------------------------------
   TABLA — sticky header, zebra, sort
   --------------------------------------------------------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-muted);
  font-size: var(--text-xs); font-weight: var(--fw-semibold);
  letter-spacing: .04em; text-transform: uppercase; text-align: left;
  padding: var(--space-3) var(--space-4); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ico { display: inline-flex; vertical-align: middle; margin-left: 4px; opacity: .4; }
.table th[aria-sort="ascending"] .sort-ico, .table th[aria-sort="descending"] .sort-ico { opacity: 1; color: var(--cyan-700); }
.table th[aria-sort="descending"] .sort-ico { transform: rotate(180deg); }
.table tbody td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.table tbody tr:hover td { background: var(--surface-2); }
.table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .td-actions { text-align: right; white-space: nowrap; }

/* ---------------------------------------------------------
   FORMULARIOS
   --------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field + .field { margin-top: var(--space-4); }
.label { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); }
.label .req { color: var(--error); margin-left: 2px; }
.hint { font-size: var(--text-xs); color: var(--text-muted); }
.field-error-msg { font-size: var(--text-xs); color: var(--error-text); display: flex; align-items: center; gap: 4px; }

.input, .select, .textarea {
  width: 100%; font-family: var(--font); font-size: var(--text-base); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 0 var(--space-3); height: 38px;
  transition: border-color var(--t-micro), box-shadow var(--t-micro);
}
.textarea { height: auto; min-height: 84px; padding: var(--space-3); line-height: var(--lh-normal); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--cyan); box-shadow: var(--focus-ring); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

.select {
  appearance: none; cursor: pointer; padding-right: var(--space-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237C8893' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--space-3) center;
}
.field.is-invalid .input, .field.is-invalid .select, .field.is-invalid .textarea { border-color: var(--error); }
.field.is-invalid .input:focus { box-shadow: 0 0 0 3px rgba(224, 52, 30, .25); }

/* input con icono / addon */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .lead-ico { position: absolute; left: var(--space-3); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.input-group .input { padding-left: var(--space-7); }

/* checkbox / radio */
.check, .radio { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-base); user-select: none; }
.check input, .radio input { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }

/* switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; border-radius: var(--radius-pill); background: var(--gray-300); transition: background var(--t-ui); flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--t-ui); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translate(18px, -50%); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }

/* ---------------------------------------------------------
   BADGE / CHIP (únicos con pill)
   --------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 10px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: var(--fw-semibold); line-height: 1; white-space: nowrap;
  background: var(--surface-2); color: var(--text-soft);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warn    { background: var(--warn-bg);    color: var(--warn-text); }
.badge-error   { background: var(--error-bg);   color: var(--error-text); }
.badge-info    { background: var(--info-bg);    color: var(--info-text); }
.badge-neutral { background: var(--surface-2);  color: var(--text-soft); }
.badge-whatsapp{ background: rgba(37,211,102,.14); color: #128C4B; }

.chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 28px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); white-space: nowrap;
}
.chip .chip-x { display: inline-flex; cursor: pointer; color: var(--text-muted); border-radius: 50%; }
.chip .chip-x:hover { color: var(--text); }
.chip.is-active { background: var(--info-bg); border-color: var(--cyan); color: var(--info-text); }

/* keyboard key */
.kbd {
  display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 6px;
  font-family: var(--font); font-size: 11px; font-weight: var(--fw-semibold);
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: var(--radius-sm); white-space: nowrap;
}

/* ---------------------------------------------------------
   SEGMENTED CONTROL
   --------------------------------------------------------- */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.segmented button {
  appearance: none; border: 0; background: none; cursor: pointer;
  font-family: var(--font); font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-soft);
  padding: 5px var(--space-3); border-radius: var(--radius-sm); white-space: nowrap;
  transition: background var(--t-micro), color var(--t-micro);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented button.is-active {
  background: var(--surface); color: var(--text); font-weight: var(--fw-semibold); box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------
   BREADCRUMB
   --------------------------------------------------------- */
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); flex-wrap: wrap; }
.breadcrumb a { color: var(--text-muted); font-weight: var(--fw-medium); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--text-muted); opacity: .6; display: inline-flex; }
.breadcrumb .sep svg { width: 14px; height: 14px; }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: var(--fw-semibold); }

/* ---------------------------------------------------------
   DROPDOWN MENU
   --------------------------------------------------------- */
.menu {
  min-width: 200px; padding: var(--space-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.menu-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--text-base); color: var(--text); cursor: pointer; white-space: nowrap;
}
.menu-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.menu-item:hover { background: var(--surface-2); }
.menu-item:hover svg { color: var(--text-soft); }
.menu-item.is-danger { color: var(--error-text); }
.menu-item.is-danger svg { color: var(--error-text); }
.menu-item .menu-kbd { margin-left: auto; }
.menu-sep { height: 1px; background: var(--border); margin: var(--space-2) 0; }
.menu-label { padding: 6px var(--space-3); font-size: var(--text-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }

/* ---------------------------------------------------------
   MODAL — backdrop + card (focus trap por JS)
   --------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal-backdrop);
  background: rgba(14, 34, 48, .45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: var(--space-5);
  animation: vp-fade var(--t-ui);
}
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: var(--z-modal); animation: vp-pop var(--t-ui) var(--ease-out);
}
.modal-header { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5); border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: var(--text-xl); font-weight: var(--fw-bold); }
.modal-header .modal-sub { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.modal-header .icon-btn { margin-left: auto; margin-top: -4px; margin-right: -4px; }
.modal-body { padding: var(--space-5); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); }
@keyframes vp-fade { from { opacity: 0; } }
@keyframes vp-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------------------------------------------------
   TOAST — top-right, auto-dismiss
   --------------------------------------------------------- */
.toast-stack { position: fixed; top: var(--space-5); right: var(--space-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-3); width: 360px; max-width: calc(100vw - var(--space-8)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--text-muted);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  animation: vp-toast-in var(--t-ui) var(--ease-out);
}
.toast.is-leaving { animation: vp-toast-out var(--t-ui) forwards; }
.toast .toast-ico { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast .toast-body { flex: 1; }
.toast .toast-title { font-size: var(--text-base); font-weight: var(--fw-semibold); }
.toast .toast-msg { font-size: var(--text-sm); color: var(--text-soft); margin-top: 2px; }
.toast .toast-x { color: var(--text-muted); cursor: pointer; }
.toast.t-success { border-left-color: var(--success); } .toast.t-success .toast-ico { color: var(--success); }
.toast.t-warn    { border-left-color: var(--warn); }    .toast.t-warn .toast-ico { color: var(--warn); }
.toast.t-error   { border-left-color: var(--error); }   .toast.t-error .toast-ico { color: var(--error); }
.toast.t-info    { border-left-color: var(--info); }    .toast.t-info .toast-ico { color: var(--info); }
@keyframes vp-toast-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes vp-toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------------------------------------------------------
   COMMAND PALETTE (Cmd+K)
   --------------------------------------------------------- */
.cmdk-backdrop { position: fixed; inset: 0; z-index: var(--z-command); background: rgba(14, 34, 48, .45); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; animation: vp-fade var(--t-ui); }
.cmdk {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: vp-pop var(--t-ui) var(--ease-out);
}
.cmdk-input-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.cmdk-input-row svg { width: 18px; height: 18px; color: var(--text-muted); }
.cmdk-input-row input { flex: 1; border: 0; background: none; outline: none; font: inherit; font-size: var(--text-lg); color: var(--text); }
.cmdk-list { max-height: 360px; overflow-y: auto; padding: var(--space-2); }
.cmdk-group-label { padding: var(--space-3) var(--space-3) var(--space-2); font-size: var(--text-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.cmdk-item { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border-radius: var(--radius); cursor: pointer; font-size: var(--text-base); color: var(--text); }
.cmdk-item svg { width: 18px; height: 18px; color: var(--text-muted); }
.cmdk-item .cmdk-kbd { margin-left: auto; }
.cmdk-item[aria-selected="true"], .cmdk-item:hover { background: var(--info-bg); color: var(--info-text); }
.cmdk-item[aria-selected="true"] svg { color: var(--info-text); }
.cmdk-footer { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-muted); }

/* ---------------------------------------------------------
   KANBAN
   --------------------------------------------------------- */
.kanban { display: flex; gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-3); align-items: flex-start; }
.kanban-col { flex: 0 0 288px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: 100%; }
.kanban-col-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
.kanban-col-head .col-title { font-size: var(--text-sm); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.kanban-col-head .col-count { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 1px 8px; }
.kanban-col-head .col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-col-body { display: flex; flex-direction: column; gap: var(--space-2); padding: 0 var(--space-3) var(--space-3); overflow-y: auto; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-3); box-shadow: var(--shadow-sm); cursor: grab;
  transition: box-shadow var(--t-micro), transform var(--t-micro);
}
.kanban-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kanban-card .kc-title { font-size: var(--text-base); font-weight: var(--fw-medium); color: var(--text); }
.kanban-card .kc-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }
.kanban-card .kc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-3); font-size: var(--text-xs); color: var(--text-muted); }

/* avatar */
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: var(--fw-bold); color: #fff; background: var(--cyan-600); flex-shrink: 0; }
.avatar.green { background: var(--green-600); }
.avatar.amber { background: var(--warn); }

/* ---------------------------------------------------------
   EMPTY STATE
   --------------------------------------------------------- */
.empty-state { text-align: center; padding: var(--space-8) var(--space-5); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.empty-state .empty-ico { width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-lg); background: var(--surface-2); color: var(--text-muted); }
.empty-state .empty-ico svg { width: 24px; height: 24px; }
.empty-state h4 { font-size: var(--text-lg); font-weight: var(--fw-semibold); }
.empty-state p { font-size: var(--text-sm); color: var(--text-muted); max-width: 360px; }

/* ---------------------------------------------------------
   SKELETON LOADER
   --------------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; border-radius: var(--radius-sm); animation: vp-shimmer 1.4s ease infinite; }
.skeleton.text { height: 12px; margin: 6px 0; }
.skeleton.title { height: 18px; width: 50%; }
.skeleton.circle { border-radius: 50%; }
@keyframes vp-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .btn[data-loading="true"]::after { animation-duration: 1.4s; } * { scroll-behavior: auto !important; } }

/* ============================================================
   PLANIFICADOR (P0) — componentes específicos del módulo
   ============================================================ */

/* ---------------------------------------------------------
   KANBAN CARD DETALLADA
   proyecto · prioridad · due · tags · comentarios · tiempo
   --------------------------------------------------------- */
.kanban-card .kc-top { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.kc-project { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: var(--fw-semibold); color: var(--text-muted); }
.kc-project .proj-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.kc-prio { margin-left: auto; }
/* prioridad como barra de color izquierda opcional */
.kanban-card.prio-high  { box-shadow: inset 3px 0 0 var(--error), var(--shadow-sm); }
.kanban-card.prio-med   { box-shadow: inset 3px 0 0 var(--warn), var(--shadow-sm); }
.kanban-card.prio-low   { box-shadow: inset 3px 0 0 var(--gray-400), var(--shadow-sm); }
.kc-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: var(--fw-medium); background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); }
.kc-stats { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.kc-stat { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--fw-medium); }
.kc-stat svg { width: 14px; height: 14px; }
.kc-stat.is-due-soon { color: var(--warn-text); }
.kc-stat.is-overdue { color: var(--error-text); }
.kc-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.kc-avatars { display: flex; }
.kc-avatars .avatar { width: 24px; height: 24px; border: 2px solid var(--surface); margin-left: -8px; }
.kc-avatars .avatar:first-child { margin-left: 0; }

/* estado de columna mientras se arrastra (DnD) */
.kanban-col.is-drop-target { outline: 2px dashed var(--cyan); outline-offset: -2px; background: var(--info-bg); }
.kanban-card.is-dragging { opacity: .4; }
.kanban-card.is-ghost { opacity: .9; box-shadow: var(--shadow-md); transform: rotate(1.5deg); cursor: grabbing; }

/* ---------------------------------------------------------
   VISTA LISTA AGRUPABLE
   --------------------------------------------------------- */
.list-toolbar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
.group-by { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-soft); }
.list-view { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-group + .list-group { border-top: 1px solid var(--border); }
.list-group-head {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); background: var(--surface-2);
  font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-soft);
  cursor: pointer; user-select: none; position: sticky; top: 0; z-index: 1;
}
.list-group-head .caret { transition: transform var(--t-micro); display: inline-flex; }
.list-group-head .caret svg { width: 16px; height: 16px; }
.list-group[data-collapsed="true"] .caret { transform: rotate(-90deg); }
.list-group[data-collapsed="true"] .list-group-body { display: none; }
.list-group-head .group-count { margin-left: auto; font-weight: var(--fw-medium); color: var(--text-muted); }
.list-row {
  display: grid; grid-template-columns: 24px 1fr auto auto auto; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-sm);
}
.list-row:hover { background: var(--surface-2); }
.list-row .lr-title { font-weight: var(--fw-medium); color: var(--text); display: flex; align-items: center; gap: var(--space-2); }
.list-row .lr-sub { color: var(--text-muted); font-size: var(--text-xs); }
.list-row .lr-due { color: var(--text-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------
   MARKDOWN RENDERER (render-only)
   --------------------------------------------------------- */
.md-body { font-size: var(--text-base); line-height: var(--lh-normal); color: var(--text); }
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-body h1 { font-size: var(--text-2xl); font-weight: var(--fw-bold); margin: var(--space-5) 0 var(--space-3); }
.md-body h2 { font-size: var(--text-xl); font-weight: var(--fw-bold); margin: var(--space-5) 0 var(--space-3); }
.md-body h3 { font-size: var(--text-lg); font-weight: var(--fw-semibold); margin: var(--space-4) 0 var(--space-2); }
.md-body p { margin: var(--space-3) 0; }
.md-body ul, .md-body ol { margin: var(--space-3) 0; padding-left: var(--space-6); }
.md-body li { margin: var(--space-1) 0; }
.md-body li::marker { color: var(--text-muted); }
.md-body a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.md-body strong { font-weight: var(--fw-semibold); color: var(--text); }
.md-body code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: var(--radius-sm); }
.md-body pre { background: var(--ink-deep); color: #D6E4EC; padding: var(--space-4); border-radius: var(--radius); overflow-x: auto; margin: var(--space-3) 0; font-size: var(--text-sm); }
.md-body pre code { background: none; border: 0; color: inherit; padding: 0; }
.md-body blockquote { margin: var(--space-3) 0; padding: var(--space-2) var(--space-4); border-left: 3px solid var(--cyan); background: var(--info-bg); color: var(--text-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-5) 0; }
.md-body table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); margin: var(--space-3) 0; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 6px var(--space-3); text-align: left; }
.md-body th { background: var(--surface-2); font-weight: var(--fw-semibold); }
.md-body input[type="checkbox"] { accent-color: var(--green); margin-right: 6px; }

/* ---------------------------------------------------------
   FILTROS MULTI-CRITERIO (barra de chips activos)
   --------------------------------------------------------- */
.filter-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.filter-bar .fb-label { font-size: var(--text-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-right: var(--space-1); }
.filter-bar .fb-clear { margin-left: auto; font-size: var(--text-sm); color: var(--link); cursor: pointer; font-weight: var(--fw-medium); }
.filter-bar .fb-clear:hover { text-decoration: underline; }

/* ============================================================
   NEGOCIO — Facturación · RRHH · Confirma · Estadísticas · Preoc.
   ============================================================ */

/* ---------------------------------------------------------
   UPLOAD CSV/XLSX — dropzone + progreso
   --------------------------------------------------------- */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-5); text-align: center; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  cursor: pointer; transition: border-color var(--t-micro), background var(--t-micro);
}
.dropzone:hover { border-color: var(--text-muted); }
.dropzone.is-over { border-color: var(--cyan); background: var(--info-bg); }
.dropzone .dz-ico { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); background: var(--surface-2); color: var(--cyan-700); }
.dropzone .dz-ico svg { width: 22px; height: 22px; }
.dropzone .dz-title { font-size: var(--text-base); font-weight: var(--fw-semibold); color: var(--text); }
.dropzone .dz-sub { font-size: var(--text-sm); color: var(--text-muted); }

.upload-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.upload-item .ui-ico { width: 32px; height: 32px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--success-bg); color: var(--success-text); }
.upload-item .ui-ico svg { width: 18px; height: 18px; }
.upload-item .ui-meta { flex: 1; min-width: 0; }
.upload-item .ui-name { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item .ui-size { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.upload-item .ui-pct { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-soft); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }

.progress { height: 8px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.progress-bar { height: 100%; background: var(--green); border-radius: var(--radius-pill); transition: width var(--t-ui); }
.progress-bar.indeterminate { width: 40% !important; animation: vp-indet 1.2s ease infinite; }
@keyframes vp-indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ---------------------------------------------------------
   DATE PICKER chileno — DD/MM/YY · L como primer día
   --------------------------------------------------------- */
.datepicker { width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--space-4); }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.dp-head .dp-month { font-size: var(--text-base); font-weight: var(--fw-semibold); color: var(--text); text-transform: capitalize; }
.dp-nav { width: 30px; height: 30px; border-radius: var(--radius-sm); border: 0; background: none; color: var(--text-soft); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dp-nav:hover { background: var(--surface-2); color: var(--text); }
.dp-nav svg { width: 18px; height: 18px; }
.dp-weekdays, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-weekdays { margin-bottom: var(--space-2); }
.dp-weekdays span { text-align: center; font-size: 11px; font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; }
.dp-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: var(--text-sm); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; font-variant-numeric: tabular-nums; border: 1px solid transparent; }
.dp-day:hover { background: var(--surface-2); }
.dp-day.is-muted { color: var(--text-muted); opacity: .5; }
.dp-day.is-today { border-color: var(--cyan); font-weight: var(--fw-semibold); }
.dp-day.is-selected { background: var(--green); color: #fff; font-weight: var(--fw-semibold); }
.dp-day.is-selected:hover { background: var(--green-700); }
.dp-day.in-range { background: var(--success-bg); border-radius: 0; }
.dp-day.is-disabled { color: var(--text-muted); opacity: .35; cursor: not-allowed; }

/* ---------------------------------------------------------
   WIZARD / STEPPER multi-paso
   --------------------------------------------------------- */
.stepper { display: flex; align-items: center; gap: 0; }
.step { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: var(--text-sm); font-weight: var(--fw-bold); border: 2px solid var(--border-strong); background: var(--surface); color: var(--text-muted); flex-shrink: 0; }
.step-dot svg { width: 16px; height: 16px; }
.step-label { font-size: var(--text-sm); font-weight: var(--fw-medium); color: var(--text-soft); white-space: nowrap; }
.step-connector { width: 48px; min-width: 24px; flex: 1; height: 2px; background: var(--border); margin: 0 var(--space-3); }
.step.is-done .step-dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.is-done + .step-connector, .step-connector.is-done { background: var(--green); }
.step.is-current .step-dot { border-color: var(--cyan); color: var(--cyan-700); }
.step.is-current .step-label { color: var(--text); font-weight: var(--fw-semibold); }
.stepper.vertical { flex-direction: column; align-items: flex-start; gap: 0; }
.stepper.vertical .step { align-items: flex-start; }
.stepper.vertical .step-connector { width: 2px; height: 24px; min-width: 0; margin: var(--space-1) 0 var(--space-1) 13px; }

/* ============================================================
   PRINT — reportes (Facturación imprime)
   ============================================================ */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #111; --border: #ccc; }
  body { background: #fff; color: #111; }
  .app-sidebar, .app-topbar, .toc, .no-print, .toast-stack,
  .modal-backdrop, .cmdk-backdrop, .segmented, .filter-bar .fb-clear { display: none !important; }
  .app-shell { display: block; }
  .app-main { padding: 0; }
  .app-main-inner { max-width: none; }
  .card, .table-wrap, .list-view, .kpi { box-shadow: none !important; border-color: #ccc; }
  a { color: #111; text-decoration: none; }
  .print-only { display: block !important; }
  .sb-section, .card, .kpi, tr, .list-row { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }   /* repetir header en cada página */
  @page { margin: 16mm; }
}
.print-only { display: none; }

/* ---------------------------------------------------------
   HELPERS
   --------------------------------------------------------- */
.divider { height: 1px; background: var(--border); border: 0; margin: var(--space-5) 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
[hidden] { display: none !important; }
