/* NEXORA CRM — componentes */

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap; text-decoration: none !important; transition: background var(--dur), border-color var(--dur), color var(--dur), box-shadow var(--dur), transform .08s; user-select: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,.3), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-gradient { background: var(--gradient); color: #fff; }
.btn-gradient:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #DC2626; }
.btn-danger-ghost { background: var(--danger-50); color: var(--red-text); border-color: transparent; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-xs); border-radius: 8px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: var(--fs-base); border-radius: 10px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; font-size: var(--fs-sm); }
.link-btn:hover { text-decoration: underline; }
.link { color: var(--text); font-weight: 600; }
.link:hover { color: var(--primary); }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 9px 0 0 9px; }
.btn-group .btn:last-child { border-radius: 0 9px 9px 0; }

/* ---------- Badges, etiquetas, avatares ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; line-height: 1; vertical-align: middle; }
.badge-blue { background: var(--primary-50); color: var(--blue-text); }
.badge-green { background: var(--success-50); color: var(--green-text); }
.badge-amber { background: var(--warning-50); color: var(--amber-text); }
.badge-red { background: var(--danger-50); color: var(--red-text); }
.badge-violet { background: var(--violet-50); color: var(--violet-text); }
.badge-cyan { background: var(--cyan-50); color: var(--cyan-text); }
.badge-gray { background: var(--surface-3); color: var(--gray-text); }
.badge-sim { background: var(--violet-50); color: var(--violet-text); border: 1px dashed color-mix(in srgb, var(--violet) 40%, transparent); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; margin: 1px 3px 1px 0; border-radius: 10px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 500; border: 1px solid var(--border); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.prio { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 600; }
.prio-alta, .prio-urgente { color: var(--red-text); } .prio-media { color: var(--amber-text); } .prio-baja { color: var(--text-3); }
.avatar { --av: #2563EB; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%; background: color-mix(in srgb, var(--av) 16%, var(--surface)); color: var(--av); font-weight: 700; letter-spacing: .02em; border: 1px solid color-mix(in srgb, var(--av) 22%, transparent); }
:root[data-theme="dark"] .avatar { color: color-mix(in srgb, var(--av) 55%, #fff); }
.avatar-xs { width: 22px; height: 22px; font-size: 9.5px; }
.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-md { width: 38px; height: 38px; font-size: 13px; }
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); white-space: nowrap; }
.help-tip { display: inline-flex; color: var(--text-3); cursor: help; margin-left: 4px; vertical-align: middle; }
.help-tip:hover { color: var(--primary); }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 0; flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 650; }
.card-title > .ico { color: var(--text-3); }
.card-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 14px 18px 18px; flex: 1; min-width: 0; }
.card-body.flush { padding: 8px 0 0; }
.card-accent { background: var(--gradient-soft); border-color: color-mix(in srgb, var(--primary) 20%, var(--border)); }
.mini-title { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 8px; }
.mini-title:first-child { margin-top: 0; }

/* ---------- KPI ---------- */
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px 14px; box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 6px; color: var(--text); text-decoration: none !important; overflow: hidden; min-width: 0; transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur); }
.kpi-link:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; gap: 8px; }
.kpi-ico { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.kpi-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; flex: 1; min-width: 0; }
.kpi-value { font-size: 25px; font-weight: 750; letter-spacing: -.025em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); flex-wrap: wrap; position: relative; z-index: 1; }
.kpi-sub { color: var(--text-3); }
.kpi-spark { position: absolute; right: 0; bottom: 0; width: 46%; height: 42px; opacity: .9; pointer-events: none; }
.kpi-spark .spark { width: 100%; height: 100%; display: block; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: var(--fs-xs); padding: 2px 6px; border-radius: 6px; }
.delta.up { color: var(--green-text); background: var(--success-50); }
.delta.down { color: var(--red-text); background: var(--danger-50); }
.delta.flat { color: var(--text-3); background: var(--surface-3); }
.tone-blue { background: var(--primary-50); color: var(--primary); }
.tone-violet { background: var(--violet-50); color: var(--violet); }
.tone-green { background: var(--success-50); color: var(--success); }
.tone-amber { background: var(--warning-50); color: var(--warning); }
.tone-red { background: var(--danger-50); color: var(--danger); }
.tone-cyan { background: var(--cyan-50); color: var(--cyan); }
.tone-gray { background: var(--surface-3); color: var(--text-3); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.stat-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-sub { font-size: var(--fs-xs); color: var(--text-3); }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-4); }

/* ---------- Formularios ---------- */
.form-section { border: 0; padding: 0; margin: 0 0 var(--sp-5); min-width: 0; }
.form-section legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 0; margin-bottom: 10px; }
.form-desc { color: var(--text-3); font-size: var(--fs-sm); margin-top: -4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.req { color: var(--danger); margin-left: 2px; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="search"]:not(#globalSearch), input[type="url"], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: var(--fs-sm); transition: border-color var(--dur), box-shadow var(--dur);
}
:root[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), :root[data-theme="dark"] select, :root[data-theme="dark"] textarea { background-color: var(--surface-2); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
input[readonly] { background: var(--surface-3); }
input[type="color"] { width: 54px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); }
.select-sm { min-height: 30px !important; height: 30px; padding: 4px 28px 4px 9px !important; font-size: var(--fs-xs) !important; width: auto !important; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-error { color: var(--red-text); font-size: var(--fs-xs); min-height: 0; }
.field-error:empty { display: none; }
.field-help { color: var(--text-3); font-size: var(--fs-xs); }
.form-alert { padding: 10px 12px; border-radius: 9px; background: var(--danger-50); color: var(--red-text); font-size: var(--fs-sm); font-weight: 600; margin-top: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); cursor: pointer; user-select: none; }
.check input, .chip-check input, input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix > span { position: absolute; left: 11px; color: var(--text-3); font-size: var(--fs-sm); pointer-events: none; }
.input-affix > input { padding-left: 24px; }
.input-affix.right > input { padding-left: 11px; padding-right: 42px; }
.affix-btn { position: absolute; right: 4px; width: 34px; height: 30px; border: 0; background: none; color: var(--text-3); border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.affix-btn:hover { background: var(--surface-3); color: var(--text); }
.chips-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 20px; font-size: var(--fs-xs); cursor: pointer; background: var(--surface); }
.chip-check:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--blue-text); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-4); }
.filters select, .filters input { width: auto; min-width: 140px; min-height: 36px; height: 36px; }
.filters .search-inline { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.filters .search-inline input { width: 100%; padding-left: 34px; }
.filters .search-inline .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.filter-count { font-size: var(--fs-xs); color: var(--text-3); margin-left: auto; white-space: nowrap; }

/* ---------- Alertas ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; font-size: var(--fs-sm); line-height: 1.45; }
.alert > .ico { margin-top: 1px; }
.alert-info { background: var(--primary-50); color: var(--blue-text); }
.alert-warn { background: var(--warning-50); color: var(--amber-text); }
.alert-danger { background: var(--danger-50); color: var(--red-text); }
.alert-success { background: var(--success-50); color: var(--green-text); }
.alert-sim { background: var(--violet-50); color: var(--violet-text); }

/* ---------- Tablas ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: var(--fs-sm); }
.table th { text-align: left; font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .table .right { text-align: right; font-variant-numeric: tabular-nums; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.th-sort .ico { opacity: .45; }
.th-sort.sorted { color: var(--text); }
.th-sort.sorted .ico { opacity: 1; color: var(--primary); }
.col-check { width: 40px; }
.col-actions { width: 48px; text-align: right; }
.row-muted td { opacity: .6; }
.row-danger { box-shadow: inset 3px 0 0 var(--danger); }
.row-warn { box-shadow: inset 3px 0 0 var(--warning); }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-main > span { display: flex; flex-direction: column; min-width: 0; }
.cell-main strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.cell-main small { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: var(--fs-xs); flex-wrap: wrap; }
.pager-ctrl { display: flex; align-items: center; gap: 4px; }
.pager-num { min-width: 52px; text-align: center; font-weight: 600; }
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--primary-50); border-bottom: 1px solid var(--border); flex-wrap: wrap; font-size: var(--fs-sm); animation: viewIn .15s; }
.bulkbar strong { margin-right: 6px; color: var(--blue-text); }
.card-list { display: none; }
.list-card { position: relative; padding: 14px 44px 14px 14px; border-bottom: 1px solid var(--border); }
.list-card.clickable { cursor: pointer; }
.list-card-check { position: absolute; top: 16px; right: 44px; }
.list-card-menu { position: absolute; top: 10px; right: 8px; }
.lc-title { font-weight: 650; margin-bottom: 4px; padding-right: 22px; }
.lc-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: var(--fs-xs); color: var(--text-3); align-items: center; }

/* ---------- Pestañas y segmentos ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border: 0; background: none; color: var(--text-3); font-weight: 600; font-size: var(--fs-sm); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color var(--dur), border-color var(--dur); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.tab.active .tab-count { background: var(--primary-50); color: var(--blue-text); }
.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; border: 1px solid var(--border); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 0; background: none; border-radius: 7px; color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Progreso, línea de tiempo, listas ---------- */
.progress { height: 7px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.progress-bar { display: block; height: 100%; border-radius: 6px; transition: width .5s var(--ease); }
.progress-bar.tone-blue { background: var(--primary); } .progress-bar.tone-green { background: var(--success); } .progress-bar.tone-amber { background: var(--warning); } .progress-bar.tone-red { background: var(--danger); } .progress-bar.tone-violet { background: var(--violet); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { display: flex; gap: 12px; padding: 0 0 16px; position: relative; }
.tl-ico { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; border: 3px solid var(--surface); }
.tl-body { flex: 1; min-width: 0; padding-top: 5px; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-head strong { font-weight: 600; font-size: var(--fs-sm); }
.tl-head time { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.tl-body p { color: var(--text-2); font-size: var(--fs-sm); margin: 3px 0 0; white-space: pre-line; }
.tl-meta { font-size: var(--fs-xs); color: var(--text-3); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dl { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.dl > div { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: var(--fs-sm); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow strong { display: block; font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .grow small { display: block; font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item a.grow { color: inherit; text-decoration: none; }
.list-item a.grow:hover strong { color: var(--primary); }
.list-val { font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.list-ico { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-1 { background: #FEF3C7; color: #92400E; } .rank-2 { background: #E2E8F0; color: #334155; } .rank-3 { background: #FFEDD5; color: #9A3412; }

/* ---------- Vacíos y skeleton ---------- */
.empty { text-align: center; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-ico { width: 56px; height: 56px; border-radius: 16px; background: var(--gradient-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.empty h3 { font-size: var(--fs-md); }
.empty p { color: var(--text-3); max-width: 420px; margin: 0 auto 8px; font-size: var(--fs-sm); }
.skeleton-wrap { display: grid; gap: 10px; }
.skeleton { height: 16px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.2s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(2px); opacity: 0; transition: opacity .18s; }
.overlay.open .overlay-backdrop { opacity: 1; }
.overlay.closing .overlay-backdrop { opacity: 0; }
.modal, .drawer { position: relative; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); min-width: 0; }
.modal { border-radius: var(--radius-xl); width: 100%; opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .18s var(--ease), transform .18s var(--ease); }
.overlay.open .modal { opacity: 1; transform: none; }
.overlay.closing .modal { opacity: 0; transform: translateY(6px) scale(.98); }
.modal-sm { max-width: 440px; } .modal-md { max-width: 600px; } .modal-lg { max-width: 820px; } .modal-xl { max-width: 1100px; }
.overlay-drawer { justify-content: flex-end; padding: 0; }
.drawer { height: 100vh; height: 100dvh; max-height: none; width: 100%; border-radius: 18px 0 0 18px; transform: translateX(30px); opacity: 0; transition: transform .22s var(--ease), opacity .22s var(--ease); }
.overlay.open .drawer { transform: none; opacity: 1; }
.overlay.closing .drawer { transform: translateX(30px); opacity: 0; }
.drawer-sm { max-width: 420px; } .drawer-md { max-width: 560px; } .drawer-lg { max-width: 760px; } .drawer-xl { max-width: 980px; }
.modal-head, .drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.modal-head h2, .drawer-head h2 { font-size: 17px; }
.modal-head p, .drawer-head p { margin: 4px 0 0; color: var(--text-3); font-size: var(--fs-sm); }
.modal-body, .drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot, .drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.drawer-foot { border-radius: 0 0 0 18px; }
.confirm-body { display: flex; gap: 14px; align-items: flex-start; }
.confirm-body p { margin: 4px 0 0; color: var(--text-2); }
.confirm-ico { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--primary-50); color: var(--primary); }
.confirm-ico.danger { background: var(--danger-50); color: var(--danger); }

/* ---------- Menú contextual, tooltip, toasts ---------- */
.ctx-menu { position: fixed; z-index: 200; min-width: 210px; max-width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 5px; animation: viewIn .12s var(--ease); max-height: 70vh; overflow-y: auto; }
.ctx-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; font-size: var(--fs-sm); color: var(--text); text-align: left; }
.ctx-item .ico { color: var(--text-3); }
.ctx-item:hover:not(:disabled), .ctx-item:focus-visible { background: var(--surface-3); outline: none; }
.ctx-item.danger { color: var(--red-text); } .ctx-item.danger .ico { color: var(--danger); }
.ctx-item:disabled { opacity: .45; cursor: not-allowed; }
.ctx-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.ctx-header { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; overflow: hidden; text-overflow: ellipsis; }
.tooltip { position: fixed; z-index: 300; max-width: 280px; padding: 6px 10px; border-radius: 7px; background: #0F172A; color: #F8FAFC; font-size: 12px; line-height: 1.4; pointer-events: none; box-shadow: var(--shadow-md); display: none; }
:root[data-theme="dark"] .tooltip { background: #F1F5F9; color: #0F172A; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 400; display: flex; flex-direction: column; gap: 8px; max-width: min(400px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--success); border-radius: 12px; box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: toastIn .22s var(--ease); }
.toast.out { opacity: 0; transform: translateX(20px); transition: all .2s; }
.toast > .ico { margin-top: 1px; }
.toast-success { border-left-color: var(--success); } .toast-success > .ico { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error > .ico { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); } .toast-warning > .ico { color: var(--warning); }
.toast-info { border-left-color: var(--primary); } .toast-info > .ico { color: var(--primary); }
.toast-msg { flex: 1; color: var(--text); font-weight: 500; }
.toast-close { border: 0; background: none; color: var(--text-3); padding: 2px; border-radius: 6px; }
.toast-action { border: 0; background: var(--primary-50); color: var(--blue-text); font-weight: 600; font-size: var(--fs-xs); padding: 4px 8px; border-radius: 6px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Gráficos ---------- */
.chart { width: 100%; min-height: 60px; position: relative; }
.chart-svg { display: block; overflow: visible; }
.ch-axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.ch-grid { stroke: var(--border); stroke-width: 1; }
.ch-track { fill: var(--surface-3); }
.ch-track-stroke { stroke: var(--surface-3); }
.ch-hlabel { fill: var(--text-2) !important; font-size: 12px !important; }
.ch-hvalue { fill: var(--text) !important; font-size: 12px !important; font-weight: 700; }
.ch-sub { fill: var(--text-3) !important; font-size: 10.5px !important; }
.ch-target { fill: var(--red-text) !important; font-size: 10.5px; font-weight: 600; }
.chart [data-tip] { transition: opacity var(--dur); }
.chart .drill { cursor: pointer; }
.chart .drill:hover, .chart .drill:focus-visible { opacity: .78; outline: none; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; font-size: var(--fs-xs); color: var(--text-2); }
.ch-leg { display: inline-flex; align-items: center; gap: 6px; }
.ch-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut-value { fill: var(--text); font-size: 20px; font-weight: 750; font-family: var(--font); }
.donut-label { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.gauge-value { fill: var(--text); font-size: 26px; font-weight: 750; font-family: var(--font); }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 160px; display: grid; gap: 4px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); padding: 4px 6px; border-radius: 6px; }
.donut-legend li.drill { cursor: pointer; }
.donut-legend li.drill:hover { background: var(--surface-3); }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend span { flex: 1; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend strong { font-variant-numeric: tabular-nums; }
.spark { display: block; }
.heat { display: grid; gap: 3px; font-size: 11px; }
.heat-col { text-align: center; color: var(--text-3); padding-bottom: 2px; }
.heat-row { color: var(--text-3); padding-right: 6px; display: flex; align-items: center; white-space: nowrap; }
.heat-cell { --a: 0; aspect-ratio: 1.6; min-height: 22px; border-radius: 5px; background: color-mix(in srgb, var(--primary) calc(var(--a) * 85% + 6%), var(--surface-3)); display: flex; align-items: center; justify-content: center; color: var(--text); font-weight: 600; font-size: 10.5px; }
.filters input[type="checkbox"] { min-width: 0; width: 16px; height: 16px; min-height: 0; flex: none; }
.span-full { grid-column: 1 / -1; }
.search-inline input, .ib-tools .search-inline input { padding-left: 34px !important; }
