/* Componentes reutilizables */

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 0.86rem; font-weight: 600; line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer; user-select: none;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 80ms ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(23, 83, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn--primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(0.94); background: var(--danger); color: #fff; }
.btn--danger-soft { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--surface); }
.btn--danger-soft:hover { background: var(--danger-50); }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn--soft { background: var(--brand-50); border-color: transparent; color: var(--brand); box-shadow: none; }
.btn--soft:hover { background: var(--brand-100); }
.btn--sm { min-height: 32px; padding: 0 10px; font-size: 0.8rem; border-radius: var(--radius-sm); gap: 6px; }
.btn--xs { min-height: 26px; padding: 0 8px; font-size: 0.74rem; border-radius: 7px; gap: 4px; }
.btn--lg { min-height: 46px; padding: 0 20px; font-size: 0.95rem; }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255, 255, 255, 0.9) rgba(255, 255, 255, 0.9) transparent transparent;
  animation: spin 0.7s linear infinite;
}
.btn:not(.btn--primary):not(.btn--danger).is-loading::after { border-color: var(--brand) var(--brand) transparent transparent; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* Formularios */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-section__title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field__label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.field__label .req { color: var(--danger); margin-left: 2px; }
.field__hint { font-size: 0.76rem; color: var(--muted); }
.field__error { font-size: 0.78rem; font-weight: 550; color: var(--danger); display: flex; gap: 5px; align-items: flex-start; }
.input, .textarea, .dd__trigger {
  width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 0.9rem; line-height: 1.35; outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .textarea:hover, .dd__trigger:hover { border-color: var(--faint); }
.input:focus, .textarea:focus, .dd__trigger:focus-visible, .dd__trigger.is-open { border-color: var(--brand); box-shadow: var(--ring); border-radius: var(--radius); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .dd__trigger[aria-invalid="true"] { border-color: var(--danger); }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--muted); }
.textarea { min-height: 92px; resize: vertical; }
.input--sm { min-height: 34px; padding: 6px 10px; font-size: 0.84rem; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .input { padding-left: 46px; }
.input-affix__prefix { position: absolute; left: 12px; font-size: 0.8rem; font-weight: 600; color: var(--muted); pointer-events: none; }
.input-affix--suffix .input { padding-left: 12px; padding-right: 36px; }
.input-affix__suffix { position: absolute; right: 12px; font-size: 0.8rem; font-weight: 600; color: var(--muted); pointer-events: none; }
input[type="file"].input { padding: 5px 8px; font-size: 0.82rem; color: var(--muted); }
input[type="file"]::file-selector-button { margin-right: 10px; padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
input[type="date"].input, input[type="datetime-local"].input { min-height: 40px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; padding-top: 6px; }
.form-actions--sticky { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(180deg, transparent, var(--surface) 30%); }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 0.88rem; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check__box { width: 18px; height: 18px; flex: none; border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--surface); display: grid; place-items: center; transition: all var(--dur) var(--ease); }
.check__box .icon { width: 12px; height: 12px; color: #fff; opacity: 0; transform: scale(0.6); transition: all var(--dur) var(--ease); stroke-width: 3; }
.check input:checked + .check__box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .check__box .icon { opacity: 1; transform: none; }
.check input:focus-visible + .check__box { box-shadow: var(--ring); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.88rem; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track { width: 38px; height: 22px; flex: none; border-radius: 999px; background: var(--border-strong); position: relative; transition: background var(--dur) var(--ease); }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }

/* Desplegables propios (reemplazan a <select>) */
.dd-native { position: absolute !important; opacity: 0 !important; pointer-events: none !important; width: 1px !important; height: 1px !important; }
.dd__trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.dd__value { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd__value.is-placeholder { color: var(--faint); }
.dd__chevron { width: 16px; height: 16px; color: var(--muted); transition: transform var(--dur) var(--ease); }
.dd__trigger.is-open .dd__chevron { transform: rotate(180deg); }
.dd__trigger.input--sm { min-height: 34px; padding: 6px 10px; font-size: 0.84rem; }
.dd-panel {
  position: fixed; z-index: 90; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-4px); transition: opacity 120ms ease, transform 120ms var(--ease);
}
.dd-panel.is-up { transform: translateY(4px); }
.dd-panel.is-in { opacity: 1; transform: none; }
.dd-panel.is-leaving { opacity: 0; }
.dd-panel__head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--muted); }
.dd-panel__search { flex: 1; border: 0; outline: none; background: transparent; font-size: 0.86rem; color: var(--text); }
.dd-panel__list { overflow-y: auto; padding: 6px; }
.dd-panel__option { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 0.86rem; cursor: pointer; }
.dd-panel__option.is-active { background: var(--surface-3); }
.dd-panel__option[aria-selected="true"] { color: var(--brand); font-weight: 650; }
.dd-panel__option[aria-selected="true"]::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.dd-panel__option[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.dd-panel__group { padding: 8px 10px 4px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.dd-panel__empty { padding: 14px; text-align: center; font-size: 0.84rem; color: var(--muted); }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-xs); min-width: 0; }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card__header--divided { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.card__title { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; font-weight: 700; }
.card__title .icon { color: var(--muted); }
.card__subtitle { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.card__body { padding: 16px 18px 18px; }
.card__body--flush { padding: 0; }
.card__footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.card + .card { margin-top: 16px; }
.grid-2 > .card, .grid-3 > .card, .grid-4 > .card, .detail-grid > .card, .cards > .card, .kpi-grid > .card, .stack > .card { margin-top: 0; }
.card--interactive { transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card--interactive:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.cards { display: grid; gap: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { font-size: 1rem; }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.kpi { position: relative; display: block; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-xs); overflow: hidden; min-width: 0; color: var(--text); text-decoration: none; }
a.kpi:hover { text-decoration: none; color: var(--text); }
.kpi__label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-right: 40px; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.kpi__value { margin-top: 8px; font-size: 1.5rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__value--sm { font-size: 1.2rem; }
.kpi__meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 0.76rem; color: var(--muted); }
.kpi__icon { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-50); color: var(--brand); }
.kpi__icon--green { background: var(--success-50); color: var(--success); }
.kpi__icon--amber { background: var(--warning-50); color: var(--warning); }
.kpi__icon--red { background: var(--danger-50); color: var(--danger); }
.kpi__icon--violet { background: var(--violet-50); color: var(--violet); }
.kpi__icon--cyan { background: var(--info-50); color: var(--info); }
.kpi__info { display: inline-flex; color: var(--faint); cursor: help; }
.kpi__info .icon { width: 14px; height: 14px; }
.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 650; }
.trend--up { color: var(--success); }
.trend--down { color: var(--danger); }
.estimate-tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--warning-50); color: var(--warning); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; }

/* Tablas */
.table-wrap { overflow-x: auto; scrollbar-width: none; }
.table-wrap::-webkit-scrollbar { display: none; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.86rem; }
.table th {
  position: sticky; top: 0; z-index: 1; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-align: left; white-space: nowrap;
}
.table th:first-child { border-top-left-radius: var(--radius-md); }
.table th:last-child { border-top-right-radius: var(--radius-md); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .table th.num { text-align: right; }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.table__primary { font-weight: 650; color: var(--text); }
.table__primary:hover { color: var(--brand); }
.table__sub { display: block; font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.th-sort:hover { color: var(--text); text-decoration: none; }
.th-sort.is-active { color: var(--brand); }
.table--compact td { padding: 8px 12px; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.acc-toggle { display: none; }

@media (max-width: 720px) {
  .table.is-acc thead { display: none; }
  .table.is-acc, .table.is-acc tbody { display: block; }
  .table.is-acc tr { display: block; border-bottom: 1px solid var(--border); }
  .table.is-acc tbody tr:hover { background: transparent; }
  .table.is-acc td { display: none; border: 0; padding: 4px 14px; }
  .table.is-acc td.acc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; cursor: pointer; }
  .table.is-acc tr.is-open td { display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  .table.is-acc tr.is-open td.acc-head { text-align: left; }
  .table.is-acc tr.is-open td:last-child { padding-bottom: 14px; }
  .table.is-acc td:not(.acc-head)::before { content: attr(data-label); flex: none; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); text-align: left; }
  .table.is-acc td.actions { justify-content: flex-end; }
  .table.is-acc td.actions::before { content: none; }
  .acc-toggle { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border: 0; border-radius: 8px; background: var(--surface-3); color: var(--muted); transition: transform var(--dur) var(--ease); }
  .table.is-acc tr.is-open .acc-toggle { transform: rotate(180deg); }
  .table.is-acc tr.acc-single td { display: block; }
}

/* Insignias y estados */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--text-2); font-size: 0.74rem; font-weight: 650; line-height: 1.3; white-space: nowrap; }
.badge .icon { width: 12px; height: 12px; }
.badge--blue { background: var(--brand-50); color: var(--brand); }
.badge--green { background: var(--success-50); color: var(--success); }
.badge--amber { background: var(--warning-50); color: var(--warning); }
.badge--red { background: var(--danger-50); color: var(--danger); }
.badge--violet { background: var(--violet-50); color: var(--violet); }
.badge--cyan { background: var(--info-50); color: var(--info); }
.badge--outline { background: transparent; border: 1px solid var(--border-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: currentColor; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 600; }
.status--live .dot { animation: pulse-ring 1.8s infinite; }

/* Pestañas y control segmentado */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border: 0; background: transparent; color: var(--muted); font-size: 0.86rem; font-weight: 600; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand); }
.tab.is-active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.tab__count { padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 0.72rem; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius); background: var(--surface-3); gap: 2px; }
.segmented a, .segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 0.8rem; font-weight: 600; text-decoration: none; }
.segmented a:hover, .segmented button:hover { color: var(--text); text-decoration: none; }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Barra de filtros */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar__search { position: relative; flex: 1 1 260px; max-width: 380px; }
.toolbar__search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.toolbar__search .input { padding-left: 36px; }
.toolbar__filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar__filters .dd__trigger, .toolbar__filters .input { min-height: 38px; width: auto; min-width: 150px; }
.toolbar__spacer { flex: 1 1 auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: var(--radius-pill); background: var(--brand-50); color: var(--brand); font-size: 0.78rem; font-weight: 600; text-decoration: none; }
.chip:hover { text-decoration: none; background: var(--brand-100); }
.chip .icon { width: 14px; height: 14px; }

/* Estados vacíos */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 20px; gap: 6px; }
.empty__icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(135deg, var(--brand-50), var(--accent-50)); color: var(--brand); margin-bottom: 8px; }
.empty__icon .icon { width: 26px; height: 26px; }
.empty__title { font-size: 1rem; font-weight: 700; }
.empty__text { max-width: 420px; color: var(--muted); font-size: 0.88rem; margin: 0; }
.empty__actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.empty--sm { padding: 26px 16px; }
.empty--sm .empty__icon { width: 42px; height: 42px; border-radius: 12px; }

/* Paginación */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--muted); flex-wrap: wrap; }
.pagination__pages { display: flex; gap: 4px; }

/* Alertas */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid transparent; font-size: 0.86rem; }
.alert .icon { margin-top: 1px; }
.alert__title { font-weight: 700; margin-bottom: 2px; }
.alert--info { background: var(--info-50); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.alert--success { background: var(--success-50); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert--warning { background: var(--warning-50); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert--error { background: var(--danger-50); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert p { margin: 0; color: var(--text-2); }
.alerts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

/* Lista de definición */
.dl { display: flex; flex-direction: column; }
.dl__row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 0.86rem; }
.dl__row:last-child { border-bottom: 0; }
.dl__row dt { color: var(--muted); flex: 0 1 auto; min-width: 0; }
.dl__row dd.num { flex: none; }
.dl__row dd { margin: 0; text-align: right; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.dl--stack .dl__row { flex-direction: column; gap: 3px; }
.dl--stack .dl__row dd { text-align: left; }

/* Avatares */
.avatar { width: 32px; height: 32px; flex: none; display: inline-grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #3b6cf5, #7a3cff); color: #fff; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; }
.avatar--sm { width: 24px; height: 24px; font-size: 0.62rem; }
.avatar--lg { width: 44px; height: 44px; font-size: 0.95rem; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.person { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }

/* Progreso */
.progress { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress__bar { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #5b7cff); transition: width 900ms var(--ease); }
.progress--success .progress__bar { background: linear-gradient(90deg, #12a06e, #34c38f); }
.progress--warning .progress__bar { background: linear-gradient(90deg, #d97706, #f5a524); }
.progress--danger .progress__bar { background: linear-gradient(90deg, #d12d2d, #f26464); }
.progress--sm { height: 5px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--muted); margin-bottom: 6px; }
.ring { --size: 52px; width: var(--size); height: var(--size); }

/* Skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: var(--radius-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent); animation: shimmer 1.4s infinite; }
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent); }
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-line--lg { height: 22px; width: 60%; }
.skeleton-block { height: 120px; }

/* Modales y paneles laterales */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(8, 12, 24, 0.5); backdrop-filter: blur(3px); animation: fade-in 140ms ease; }
.modal-backdrop.is-leaving { opacity: 0; transition: opacity 140ms ease; }
.modal { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop-in 180ms var(--ease); }
.modal--wide { width: min(720px, 100%); }
.modal__icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--brand-50); color: var(--brand); margin-bottom: 12px; }
.modal--danger .modal__icon { background: var(--danger-50); color: var(--danger); }
.modal__title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.modal__body { color: var(--text-2); font-size: 0.9rem; }
.modal__body + .modal__body { margin-top: 12px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.modal__error { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-50); color: var(--danger); font-size: 0.84rem; font-weight: 550; }
.modal .form-grid { margin-top: 10px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 95; background: rgba(8, 12, 24, 0.45); animation: fade-in 160ms ease; }
.drawer { position: fixed; z-index: 96; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-lg); animation: drawer-in 240ms var(--ease); }
.drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer__body { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px; }
.drawer__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }

/* Menús emergentes */
.popover { position: fixed; z-index: 80; min-width: 220px; padding: 6px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop-in 140ms var(--ease); }
.menu__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font-size: 0.86rem; text-align: left; text-decoration: none; }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-3); text-decoration: none; }
.menu__item .icon { color: var(--muted); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger .icon { color: var(--danger); }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--border); }
.menu__header { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }

/* Notificaciones emergentes */
.toast-stack { position: fixed; top: 76px; right: 20px; z-index: 120; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 14px 14px; overflow: hidden;
  border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 0.87rem; pointer-events: auto; animation: toast-in 260ms var(--ease);
}
.toast__icon { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--success-50); color: var(--success); }
.toast--error .toast__icon { background: var(--danger-50); color: var(--danger); }
.toast--warning .toast__icon { background: var(--warning-50); color: var(--warning); }
.toast--info .toast__icon { background: var(--brand-50); color: var(--brand); }
.toast__text { flex: 1 1 auto; padding-top: 4px; color: var(--text); }
.toast__title { display: block; font-weight: 700; margin-bottom: 2px; }
.toast__action { font-weight: 650; margin-left: 4px; }
.toast__close { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.toast__close:hover { background: var(--surface-3); color: var(--text); }
.toast__timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--success); transform-origin: left; animation: toast-timer var(--toast-duration, 5s) linear forwards; opacity: 0.7; }
.toast--error .toast__timer { background: var(--danger); }
.toast--warning .toast__timer { background: var(--warning); }
.toast--info .toast__timer { background: var(--brand); }
.toast.is-paused .toast__timer { animation-play-state: paused; }
.toast.is-leaving { animation: toast-out 220ms var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Panel de notificaciones y búsqueda global */
.panel { position: fixed; z-index: 85; width: min(420px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 90px)); display: flex; flex-direction: column; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: pop-in 160ms var(--ease); overflow: hidden; }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel__title { font-weight: 700; }
.panel__body { overflow-y: auto; }
.panel__foot { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; font-size: 0.84rem; }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); transition: background var(--dur) var(--ease); }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.is-unread { background: color-mix(in srgb, var(--brand-50) 55%, transparent); }
.notif__icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--brand-50); color: var(--brand); }
.notif__title { font-size: 0.86rem; font-weight: 650; }
.notif__body { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.notif__time { font-size: 0.72rem; color: var(--faint); margin-top: 4px; }
.search-results__group { padding: 10px 16px 4px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.search-result { display: flex; align-items: center; gap: 12px; padding: 9px 16px; text-decoration: none; color: var(--text); }
.search-result:hover, .search-result.is-active { background: var(--surface-3); text-decoration: none; }
.search-result__icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--muted); }
.search-result__title { font-size: 0.86rem; font-weight: 600; }
.search-result__sub { font-size: 0.76rem; color: var(--muted); }

/* Kanban */
.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; min-height: 60vh; }
.kanban::-webkit-scrollbar { display: none; }
.kanban__column { flex: 0 0 290px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); border-radius: var(--radius-md); background: var(--surface-3); border: 1px solid var(--border); }
.kanban__head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; }
.kanban__title { font-size: 0.84rem; font-weight: 700; flex: 1 1 auto; min-width: 0; }
.kanban__count { padding: 1px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.kanban__total { padding: 0 14px 10px; font-size: 0.76rem; color: var(--muted); }
.kanban__cards { flex: 1 1 auto; min-height: 80px; overflow-y: auto; padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 8px; transition: background var(--dur) var(--ease); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.kanban__cards.is-over { background: color-mix(in srgb, var(--brand-50) 70%, transparent); }
.kanban-card { display: block; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); color: var(--text); text-decoration: none; cursor: grab; transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease); touch-action: manipulation; }
.kanban-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); text-decoration: none; }
.kanban-card.is-dragging { opacity: 0.4; }
.kanban-card.is-ghost { position: fixed; z-index: 200; pointer-events: none; box-shadow: var(--shadow-lg); transform: rotate(2deg); cursor: grabbing; }
.kanban-card__title { font-size: 0.86rem; font-weight: 650; }
.kanban-card__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 0.76rem; color: var(--muted); }
.kanban-placeholder { height: 4px; border-radius: 4px; background: var(--brand); margin: -2px 0; }

/* Línea de tiempo */
.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); }
.timeline__item { position: relative; display: flex; gap: 14px; padding: 0 0 18px; }
.timeline__dot { position: relative; z-index: 1; width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); color: var(--muted); }
.timeline__dot .icon { width: 15px; height: 15px; }
.timeline__content { flex: 1 1 auto; min-width: 0; padding-top: 5px; }
.timeline__title { font-size: 0.86rem; font-weight: 600; }
.timeline__meta { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.timeline__body { margin-top: 6px; font-size: 0.85rem; color: var(--text-2); white-space: pre-line; }

/* Tooltip simple */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  z-index: 50; width: max-content; max-width: 280px; padding: 7px 10px; border-radius: 8px; background: #0b1122; color: #fff;
  font-size: 0.74rem; font-weight: 500; line-height: 1.4; text-transform: none; letter-spacing: 0; white-space: normal; text-align: left;
  box-shadow: var(--shadow); pointer-events: none; animation: fade-in 120ms ease;
}

/* Gráficos */
.chart { position: relative; width: 100%; height: 280px; }
.chart--sm { height: 200px; }
.chart--lg { height: 340px; }
.chart__empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: var(--muted); font-size: 0.86rem; background: color-mix(in srgb, var(--surface) 80%, transparent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.78rem; color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 10px; height: 10px; border-radius: 3px; }

@media (max-width: 720px) {
  .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .toolbar__search { max-width: none; flex-basis: 100%; }
  .toolbar__filters { width: 100%; }
  .toolbar__filters .dd__trigger, .toolbar__filters .input { flex: 1 1 140px; min-width: 0; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi__value { font-size: 1.15rem; }
  .kpi__icon { display: none; }
  .modal { padding: 18px; }
  .toast-stack { top: 72px; right: 12px; left: 12px; width: auto; }
  .kanban__column { flex-basis: 84vw; }
}
