/* ============================================================
   CORELINK — Design System v1.0
   Fuentes: Sora (headings/brand) + Inter (UI/datos)
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=Inter:wght@300;400;500;600&display=swap");

/* ── TOKENS ─────────────────────────────────────────────────── */
:root {
    /* Paleta */
    --cl-ink: #0f1b2d;
    --cl-ink-hover: #162436;
    --cl-ink-muted: #1e3050;
    --cl-accent: #2d7ff9;
    --cl-accent-dark: #1a5fbf;
    --cl-accent-light: #ebf3ff;
    --cl-teal: #00c8a0;
    --cl-teal-dark: #009e80;
    --cl-teal-light: #e6faf6;
    --cl-amber: #f59e0b;
    --cl-amber-light: #fef3c7;
    --cl-danger: #ef4444;
    --cl-danger-light: #fee2e2;
    --cl-surface: #f5f7fa;
    --cl-white: #ffffff;
    --cl-border: #e2e8f2;
    --cl-border-dark: #c8d4e8;
    --cl-muted: #64748b;
    --cl-muted-light: #94a3b8;

    /* Sidebar */
    --sidebar-w: 260px;
    --sidebar-bg: var(--cl-ink);
    --sidebar-item-h: 42px;
    --sidebar-text: #a8bccf;
    --sidebar-active: var(--cl-accent);
    --sidebar-hover: rgba(255, 255, 255, 0.06);

    /* Topbar */
    --topbar-h: 60px;

    /* Tipografía */
    --font-brand: "Sora", sans-serif;
    --font-ui: "Inter", sans-serif;

    /* Escalas */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 17px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 30px;

    /* Radios */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-xl: 14px;

    /* Sombras */
    --shadow-xs: 0 1px 3px rgba(15, 27, 45, 0.07);
    --shadow-sm: 0 2px 8px rgba(15, 27, 45, 0.09);
    --shadow-md: 0 4px 16px rgba(15, 27, 45, 0.12);
    --shadow-lg: 0 8px 32px rgba(15, 27, 45, 0.14);

    /* Transiciones */
    --t-fast: 120ms ease;
    --t-base: 200ms ease;
    --t-slow: 320ms ease;
}

/* ── RESET BASE ──────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-ui);
    font-size: var(--text-base);
    color: var(--cl-ink);
    background: var(--cl-surface);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--cl-accent);
    text-decoration: none;
}
a:hover {
    color: var(--cl-accent-dark);
}

img,
svg {
    display: block;
    max-width: 100%;
}

/* ── TIPOGRAFÍA ──────────────────────────────────────────────── */
.font-brand {
    font-family: var(--font-brand);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-brand);
    font-weight: 600;
    line-height: 1.25;
    color: var(--cl-ink);
}
h1 {
    font-size: var(--text-3xl);
}
h2 {
    font-size: var(--text-2xl);
}
h3 {
    font-size: var(--text-xl);
}
h4 {
    font-size: var(--text-lg);
}
h5 {
    font-size: var(--text-md);
}
h6 {
    font-size: var(--text-base);
}

.page-title {
    font-family: var(--font-brand);
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--cl-ink);
}
.page-subtitle {
    font-size: var(--text-sm);
    color: var(--cl-muted);
    margin-top: 2px;
}

/* ── LAYOUT SHELL ────────────────────────────────────────────── */
.cl-shell {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.cl-sidebar {
    width: var(--sidebar-w);
    height: 100vh; /* antes: min-height: 100vh */
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform var(--t-base);
    overflow: hidden; /* el scroll lo hace el nav */
}

.cl-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.cl-sidebar__logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.cl-sidebar__wordmark {
    font-family: var(--font-brand);
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
}
.cl-sidebar__wordmark span {
    color: var(--cl-accent);
}

.cl-sidebar__nav {
    flex: 1;
    min-height: 0; /* permite que el nav se encoja y haga scroll */
    padding: 14px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.cl-nav__section {
    margin-bottom: 6px;
}

.cl-nav__label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(168, 188, 207, 0.45);
    padding: 10px 20px 4px;
}

.cl-nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--sidebar-item-h);
    padding: 0 20px;
    color: var(--sidebar-text);
    font-size: var(--text-sm);
    font-weight: 400;
    cursor: pointer;
    transition:
        background var(--t-fast),
        color var(--t-fast);
    position: relative;
    border-radius: 0;
    text-decoration: none;
    user-select: none;
}

.cl-nav__item:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
}

.cl-nav__item.active {
    background: rgba(45, 127, 249, 0.15);
    color: #ffffff;
}

.cl-nav__item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--cl-accent);
    border-radius: 0 2px 2px 0;
}

.cl-nav__item svg {
    width: 17px;
    height: 17px;
    opacity: 0.75;
    flex-shrink: 0;
    transition: opacity var(--t-fast);
}
.cl-nav__item:hover svg,
.cl-nav__item.active svg {
    opacity: 1;
}

.cl-nav__badge {
    margin-left: auto;
    background: var(--cl-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.6;
}

/* Sub-items */
.cl-nav__sub {
    display: none;
    padding: 2px 0 4px 44px;
}
.cl-nav__sub.open {
    display: block;
}
.cl-nav__sub-item {
    display: flex;
    align-items: center;
    height: 34px;
    color: rgba(168, 188, 207, 0.7);
    font-size: var(--text-xs);
    font-weight: 400;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition:
        color var(--t-fast),
        background var(--t-fast);
}
.cl-nav__sub-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}
.cl-nav__sub-item.active {
    color: var(--cl-accent);
}

.cl-nav__arrow {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform var(--t-base);
}

.cl-nav__item:focus:not(:focus-visible) {
    outline: none;
}

.cl-nav__item[aria-expanded="true"] .cl-nav__arrow {
    transform: rotate(90deg);
}

/* Botones usados como ítem de menú (ej. Planes) */
button.cl-nav__item {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    font-family: inherit;
    text-align: left;
    box-shadow: none;
    outline: none;
}

button.cl-nav__item:hover {
    background: var(--sidebar-hover, rgba(255, 255, 255, 0.06));
}

/* Empuja la flecha al extremo derecho */
.cl-nav__arrow {
    margin-left: auto;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform var(--t-fast);
}

/* Estado abierto: gira la flecha */
button.cl-nav__item[aria-expanded="true"] .cl-nav__arrow {
    transform: rotate(90deg);
}

/* Sidebar footer */
.cl-sidebar__footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.cl-sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cl-sidebar__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--cl-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-brand);
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.cl-sidebar__user-info {
    flex: 1;
    min-width: 0;
}
.cl-sidebar__user-name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cl-sidebar__user-role {
    font-size: var(--text-xs);
    color: rgba(168, 188, 207, 0.6);
}

/* ── MAIN AREA ────────────────────────────────────────────────── */
.cl-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── TOPBAR ──────────────────────────────────────────────────── */
.cl-topbar {
    height: var(--topbar-h);
    background: var(--cl-white);
    border-bottom: 1px solid var(--cl-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-xs);
}

.cl-topbar__breadcrumb {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-sm);
    color: var(--cl-muted);
}
.cl-topbar__breadcrumb a {
    color: var(--cl-muted);
    transition: color var(--t-fast);
}
.cl-topbar__breadcrumb a:hover {
    color: var(--cl-accent);
}
.cl-topbar__breadcrumb-sep {
    color: var(--cl-border-dark);
}
.cl-topbar__breadcrumb-current {
    color: var(--cl-ink);
    font-weight: 500;
}

.cl-topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cl-topbar__icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--cl-border);
    background: transparent;
    color: var(--cl-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background var(--t-fast),
        color var(--t-fast),
        border-color var(--t-fast);
}
.cl-topbar__icon-btn:hover {
    background: var(--cl-surface);
    color: var(--cl-ink);
    border-color: var(--cl-border-dark);
}
.cl-topbar__icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Notif badge */
.cl-notif-wrap {
    position: relative;
}
.cl-notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    background: var(--cl-danger);
    border-radius: 50%;
    border: 2px solid var(--cl-white);
}

/* ── CONTENT AREA ────────────────────────────────────────────── */
.cl-content {
    flex: 1;
    padding: 28px;
}

.cl-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

/* ── CARDS ───────────────────────────────────────────────────── */
.cl-card {
    background: var(--cl-white);
    border: 1px solid var(--cl-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cl-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cl-border);
}

.cl-card__title {
    font-family: var(--font-brand);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--cl-ink);
}

.cl-card__body {
    padding: 20px;
}
.cl-card__body--flush {
    padding: 0;
}
.cl-card__footer {
    padding: 14px 20px;
    border-top: 1px solid var(--cl-border);
    background: var(--cl-surface);
}

/* Stat cards */
.cl-stat {
    background: var(--cl-white);
    border: 1px solid var(--cl-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.cl-stat__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.cl-stat__icon svg {
    width: 20px;
    height: 20px;
}
.cl-stat__icon--blue {
    background: var(--cl-accent-light);
    color: var(--cl-accent);
}
.cl-stat__icon--teal {
    background: var(--cl-teal-light);
    color: var(--cl-teal-dark);
}
.cl-stat__icon--amber {
    background: var(--cl-amber-light);
    color: var(--cl-amber);
}
.cl-stat__icon--danger {
    background: var(--cl-danger-light);
    color: var(--cl-danger);
}

.cl-stat__body {
    flex: 1;
    min-width: 0;
}
.cl-stat__value {
    font-family: var(--font-brand);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--cl-ink);
    line-height: 1.1;
}
.cl-stat__label {
    font-size: var(--text-sm);
    color: var(--cl-muted);
    margin-top: 3px;
}
.cl-stat__delta {
    font-size: var(--text-xs);
    font-weight: 500;
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.cl-stat__delta--up {
    color: var(--cl-teal-dark);
}
.cl-stat__delta--down {
    color: var(--cl-danger);
}

/* ── TABLA ───────────────────────────────────────────────────── */
.cl-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.cl-table th {
    background: var(--cl-surface);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cl-muted);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--cl-border);
    white-space: nowrap;
}

.cl-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--cl-border);
    color: var(--cl-ink);
    vertical-align: middle;
}

.cl-table tbody tr:last-child td {
    border-bottom: none;
}

.cl-table tbody tr {
    transition: background var(--t-fast);
}
.cl-table tbody tr:hover {
    background: var(--cl-surface);
}

.cl-table__empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--cl-muted);
    font-size: var(--text-sm);
}

/* ── BOTONES ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    padding: 0 16px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition:
        background var(--t-fast),
        border-color var(--t-fast),
        color var(--t-fast),
        box-shadow var(--t-fast);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn:focus-visible {
    outline: 2px solid var(--cl-accent);
    outline-offset: 2px;
}
.btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--cl-accent);
    color: #fff;
    border-color: var(--cl-accent);
}
.btn-primary:hover {
    background: var(--cl-accent-dark);
    border-color: var(--cl-accent-dark);
}

.btn-primary:hover,
a.btn-primary:hover {
    background: var(--cl-accent-dark);
    border-color: var(--cl-accent-dark);
    color: #fff;
}

.btn-secondary {
    background: var(--cl-white);
    color: var(--cl-ink);
    border-color: var(--cl-border-dark);
}
.btn-secondary:hover {
    background: var(--cl-surface);
    border-color: #b0bfd4;
}

.btn-ghost {
    background: transparent;
    color: var(--cl-muted);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--cl-surface);
    color: var(--cl-ink);
}

.btn-danger {
    background: var(--cl-danger);
    color: #fff;
    border-color: var(--cl-danger);
}
.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-teal {
    background: var(--cl-teal);
    color: #fff;
    border-color: var(--cl-teal);
}
.btn-teal:hover {
    background: var(--cl-teal-dark);
    border-color: var(--cl-teal-dark);
}

.btn-sm {
    height: 30px;
    padding: 0 12px;
    font-size: var(--text-xs);
}
.btn-sm svg {
    width: 13px;
    height: 13px;
}
.btn-lg {
    height: 44px;
    padding: 0 22px;
    font-size: var(--text-md);
}

.btn[disabled],
.btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Icon-only */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
}
.btn-icon.btn-sm {
    width: 30px;
    height: 30px;
}

/* ── FORMULARIOS ─────────────────────────────────────────────── */
.cl-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cl-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--cl-ink);
    letter-spacing: 0.2px;
}
.cl-label .required {
    color: var(--cl-danger);
    margin-left: 2px;
}

.cl-input,
.cl-select,
.cl-textarea {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    font-family: var(--font-ui);
    font-size: var(--text-sm);
    color: var(--cl-ink);
    background: var(--cl-white);
    border: 1px solid var(--cl-border-dark);
    border-radius: var(--radius-md);
    outline: none;
    transition:
        border-color var(--t-fast),
        box-shadow var(--t-fast);
    appearance: none;
}

.cl-input::placeholder,
.cl-textarea::placeholder {
    color: var(--cl-muted-light);
}

.cl-input:focus,
.cl-select:focus,
.cl-textarea:focus {
    border-color: var(--cl-accent);
    box-shadow: 0 0 0 3px rgba(45, 127, 249, 0.12);
}

.cl-input.error,
.cl-select.error,
.cl-textarea.error {
    border-color: var(--cl-danger);
}
.cl-input.error:focus,
.cl-select.error:focus,
.cl-textarea.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.cl-textarea {
    height: auto;
    padding: 10px 12px;
    resize: vertical;
    min-height: 90px;
    line-height: 1.55;
}

.cl-select {
    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%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
    cursor: pointer;
}

.cl-input-group {
    display: flex;
}
.cl-input-group .cl-input {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    border-right: none;
    flex: 1;
}
.cl-input-group .btn {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    flex-shrink: 0;
}

.cl-form-hint {
    font-size: var(--text-xs);
    color: var(--cl-muted);
}
.cl-form-error {
    font-size: var(--text-xs);
    color: var(--cl-danger);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Checkbox y switch */
.cl-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--cl-ink);
}
.cl-checkbox-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--cl-accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* Switch toggle */
.cl-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.cl-switch input {
    display: none;
}
.cl-switch__track {
    width: 36px;
    height: 20px;
    background: var(--cl-border-dark);
    border-radius: 10px;
    position: relative;
    transition: background var(--t-base);
}
.cl-switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--t-base);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.cl-switch input:checked ~ .cl-switch__track {
    background: var(--cl-accent);
}
.cl-switch input:checked ~ .cl-switch__track .cl-switch__thumb {
    transform: translateX(16px);
}
.cl-switch__label {
    font-size: var(--text-sm);
    color: var(--cl-ink);
}

/* ── BADGES / PILLS ──────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    line-height: 1.5;
}

.badge-blue {
    background: var(--cl-accent-light);
    color: var(--cl-accent-dark);
}
.badge-teal {
    background: var(--cl-teal-light);
    color: var(--cl-teal-dark);
}
.badge-amber {
    background: var(--cl-amber-light);
    color: #92400e;
}
.badge-danger {
    background: var(--cl-danger-light);
    color: #991b1b;
}
.badge-gray {
    background: #f1f5f9;
    color: var(--cl-muted);
}
.badge-ink {
    background: var(--cl-ink);
    color: #fff;
}

.badge-dot::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* ── ALERTAS ─────────────────────────────────────────────────── */
.cl-alert {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    border: 1px solid;
}
.cl-alert svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}
.cl-alert__body {
    flex: 1;
}
.cl-alert__title {
    font-weight: 600;
    margin-bottom: 2px;
}

.cl-alert--info {
    background: var(--cl-accent-light);
    border-color: #bfdbfe;
    color: #1e40af;
}
.cl-alert--success {
    background: var(--cl-teal-light);
    border-color: #99f6e4;
    color: #065f46;
}
.cl-alert--warning {
    background: var(--cl-amber-light);
    border-color: #fde68a;
    color: #92400e;
}
.cl-alert--danger {
    background: var(--cl-danger-light);
    border-color: #fecaca;
    color: #991b1b;
}

/* ── MODALES ─────────────────────────────────────────────────── */
.cl-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 27, 45, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-base);
}
.cl-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.cl-modal {
    background: var(--cl-white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    box-shadow: var(--shadow-lg);
    transform: translateY(8px) scale(0.99);
    transition: transform var(--t-base);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.cl-overlay.open .cl-modal {
    transform: translateY(0) scale(1);
}
.cl-modal--sm {
    max-width: 420px;
}
.cl-modal--lg {
    max-width: 720px;
}
.cl-modal--xl {
    max-width: 900px;
}

.cl-modal__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--cl-border);
}
.cl-modal__title {
    font-family: var(--font-brand);
    font-size: var(--text-lg);
    font-weight: 600;
    flex: 1;
}
.cl-modal__close {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--cl-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background var(--t-fast),
        color var(--t-fast);
}
.cl-modal__close:hover {
    background: var(--cl-surface);
    color: var(--cl-ink);
}
.cl-modal__close svg {
    width: 16px;
    height: 16px;
}

.cl-modal__body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}
.cl-modal__footer {
    padding: 16px 22px;
    border-top: 1px solid var(--cl-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── DROPDOWN ────────────────────────────────────────────────── */
.cl-dropdown {
    position: relative;
    display: inline-block;
}
.cl-dropdown__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 180px;
    background: var(--cl-white);
    border: 1px solid var(--cl-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 150;
    overflow: hidden;
    display: none;
}
.cl-dropdown__menu.open {
    display: block;
}
.cl-dropdown__item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    font-size: var(--text-sm);
    color: var(--cl-ink);
    cursor: pointer;
    transition: background var(--t-fast);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.cl-dropdown__item:hover {
    background: var(--cl-surface);
}
.cl-dropdown__item svg {
    width: 14px;
    height: 14px;
    color: var(--cl-muted);
}
.cl-dropdown__item.danger {
    color: var(--cl-danger);
}
.cl-dropdown__item.danger svg {
    color: var(--cl-danger);
}
.cl-dropdown__divider {
    border: none;
    border-top: 1px solid var(--cl-border);
    margin: 4px 0;
}

/* ── PAGINACIÓN ──────────────────────────────────────────────── */
.cl-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}
.cl-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--cl-border);
    background: var(--cl-white);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--cl-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast);
}
.cl-page-btn:hover {
    background: var(--cl-surface);
    color: var(--cl-ink);
    border-color: var(--cl-border-dark);
}
.cl-page-btn.active {
    background: var(--cl-accent);
    border-color: var(--cl-accent);
    color: #fff;
}
.cl-page-btn[disabled] {
    opacity: 0.4;
    pointer-events: none;
}

/* ── TABS ────────────────────────────────────────────────────── */
.cl-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--cl-border);
    margin-bottom: 20px;
}
.cl-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--cl-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition:
        color var(--t-fast),
        border-color var(--t-fast);
    text-decoration: none;
    white-space: nowrap;
}
.cl-tab:hover {
    color: var(--cl-ink);
}
.cl-tab.active {
    color: var(--cl-accent);
    border-bottom-color: var(--cl-accent);
}
.cl-tab svg {
    width: 14px;
    height: 14px;
}

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.cl-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 10px;
}
.cl-empty__icon {
    width: 48px;
    height: 48px;
    color: var(--cl-border-dark);
}
.cl-empty__title {
    font-family: var(--font-brand);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--cl-ink);
}
.cl-empty__text {
    font-size: var(--text-sm);
    color: var(--cl-muted);
    max-width: 320px;
}

/* ── TOOLTIP ─────────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
    cursor: default;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--cl-ink);
    color: #fff;
    font-size: var(--text-xs);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-fast);
    z-index: 300;
}
[data-tooltip]:hover::after {
    opacity: 1;
}

/* ── GRID HELPERS ────────────────────────────────────────────── */
.cl-grid {
    display: grid;
    gap: 16px;
}
.cl-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}
.cl-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}
.cl-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
.cl-grid-form {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 20px;
}

/* ── SPACERS ─────────────────────────────────────────────────── */
.cl-spacer {
    flex: 1;
}
.mt-1 {
    margin-top: 4px;
}
.mt-2 {
    margin-top: 8px;
}
.mt-3 {
    margin-top: 12px;
}
.mt-4 {
    margin-top: 16px;
}
.mt-6 {
    margin-top: 24px;
}
.mb-4 {
    margin-bottom: 16px;
}
.mb-6 {
    margin-bottom: 24px;
}
.flex {
    display: flex;
}
.items-center {
    align-items: center;
}
.gap-2 {
    gap: 8px;
}
.gap-3 {
    gap: 12px;
}
.gap-4 {
    gap: 16px;
}
.text-sm {
    font-size: var(--text-sm);
}
.text-xs {
    font-size: var(--text-xs);
}
.text-muted {
    color: var(--cl-muted);
}
.font-medium {
    font-weight: 500;
}
.font-semibold {
    font-weight: 600;
}

/* ── SCROLLBAR ───────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--cl-border-dark);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #a0aebe;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 900px) {
    .cl-sidebar {
        transform: translateX(-100%);
    }
    .cl-sidebar.mobile-open {
        transform: translateX(0);
    }
    .cl-main {
        margin-left: 0;
    }
    .cl-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .cl-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    .cl-content {
        padding: 16px;
    }
}
@media (max-width: 600px) {
    .cl-grid-2,
    .cl-grid-3,
    .cl-grid-4,
    .cl-grid-form {
        grid-template-columns: 1fr;
    }
    .cl-page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
