/* =========================================================
   Panel de administración WK-Soft
   Misma identidad que el sitio público: magenta del logo + negro,
   Plus Jakarta Sans, modo oscuro por defecto y modo claro.
   CSS sin compilar a propósito: el hosting no tiene Node.
   ========================================================= */

:root {
    --brand: #ec0896;
    --brand-600: #cc0080;
    --brand-300: #ff92d1;
    --violet: #7c3aed;

    --bg: #fbfbfd;
    --bg-elevated: #ffffff;
    --bg-subtle: #f3f3f7;
    --fg: #0b0b12;
    --muted: #5b5b6b;
    --faint: #616172;
    --line: rgb(11 11 18 / 0.08);
    --line-strong: rgb(11 11 18 / 0.14);
    --glass: rgb(255 255 255 / 0.75);
    --shadow: 0 20px 50px -25px rgb(20 20 40 / 0.25);

    --ok: #10b981;
    --danger: #f43f5e;
    --warn: #f59e0b;

    --radius: 20px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --sidebar: 268px;
    color-scheme: light;
}

.dark {
    --bg: #07070b;
    --bg-elevated: #0f0f16;
    --bg-subtle: #16161f;
    --fg: #f5f5f8;
    --muted: #a1a1b3;
    --faint: #8e8ea1;
    --line: rgb(255 255 255 / 0.08);
    --line-strong: rgb(255 255 255 / 0.14);
    --glass: rgb(10 10 16 / 0.7);
    --shadow: 0 20px 50px -25px rgb(0 0 0 / 0.7);
    color-scheme: dark;
}

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

/* El atributo hidden siempre gana (filtros, avisos, etc.), aunque el elemento tenga display propio */
[hidden] { display: none !important; }

html { -webkit-font-smoothing: antialiased; }

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--fg);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.025em; }
p { margin: 0; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }

.ic { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.85; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }

/* ---------- Estructura ---------- */
.app { display: flex; min-height: 100dvh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar);
    display: flex; flex-direction: column;
    padding: 22px 16px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--line);
    transition: transform 0.45s var(--ease);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 26px; }
.sidebar-brand img { height: 30px; width: auto; }
.sidebar-brand span {
    font-family: ui-monospace, Menlo, monospace; font-size: 10px; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--faint);
    border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px;
}
.logo-dark { display: none; }
.dark .logo-light-mode { display: none; }
.dark .logo-dark { display: block; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
    font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--faint); padding: 14px 12px 8px;
}
.nav a {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 14px;
    color: var(--muted); font-weight: 600; font-size: 14.5px;
    transition: background 0.25s, color 0.25s;
}
.nav a:hover { background: var(--bg-subtle); color: var(--fg); }
.nav a.active { background: rgb(236 8 150 / 0.1); color: var(--brand); }
.dark .nav a.active { color: var(--brand-300); }
.nav a.active::before {
    content: ''; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px;
    border-radius: 0 4px 4px 0; background: var(--brand);
}
.nav .count {
    margin-left: auto; font-size: 11.5px; font-weight: 700;
    background: var(--bg-subtle); color: var(--muted);
    padding: 2px 8px; border-radius: 999px;
}
.nav a.active .count { background: var(--brand-600); color: #fff; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.user-card {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-subtle);
}
.avatar {
    width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--violet));
}
.user-card .name { font-weight: 700; font-size: 14px; }
.user-card .role { font-size: 12px; color: var(--faint); }
.user-card form { margin-left: auto; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar); }

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 32px;
    background: var(--glass);
    backdrop-filter: blur(16px) saturate(1.5);
    border-bottom: 1px solid var(--line);
}
.topbar .crumb { font-size: 13px; color: var(--faint); }
.topbar .crumb b { color: var(--fg); font-weight: 600; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }

.content { padding: 32px; max-width: 1280px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(26px, 3vw, 34px); font-weight: 800; letter-spacing: -0.035em; }
.page-head p { color: var(--muted); margin-top: 6px; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--muted);
    border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; margin-bottom: 12px;
}
.eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 10px 2px rgb(236 8 150 / 0.5); }

/* ---------- Tarjetas ---------- */
.card {
    position: relative; isolation: isolate; overflow: hidden;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    --mx: 50%; --my: 50%;
}
/* Borde iluminado que sigue al mouse (igual que el sitio) */
.card.glow::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
    background: radial-gradient(380px circle at var(--mx) var(--my), rgb(236 8 150 / 0.6), transparent 40%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    opacity: 0; transition: opacity 0.4s;
}
.card.glow:hover::after { opacity: 1; }
.card-body { padding: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 17px; font-weight: 700; }
.card-head p { font-size: 13px; color: var(--faint); margin-top: 2px; }

.icon-tile {
    width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
    display: grid; place-items: center;
    background: linear-gradient(135deg, rgb(236 8 150 / 0.16), rgb(124 58 237 / 0.1));
    border: 1px solid rgb(236 8 150 / 0.22);
    color: var(--brand);
}
.dark .icon-tile { color: var(--brand-300); }

/* ---------- Estadísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 44px; line-height: 1; font-weight: 800; letter-spacing: -0.05em; }
.stat-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--brand); }
.dark .stat-link { color: var(--brand-300); }
.stat-link .ic { transition: transform 0.3s var(--ease); }
.stat:hover .stat-link .ic { transform: translateX(4px); }
.stat .blob {
    position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%;
    background: radial-gradient(circle, rgb(236 8 150 / 0.18), transparent 70%); z-index: -1;
}

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field label .opt { color: var(--faint); font-weight: 500; }
.input, .textarea, .select {
    width: 100%; font: inherit; color: var(--fg);
    background: var(--bg); border: 1px solid var(--line-strong); border-radius: 14px;
    padding: 12px 14px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.textarea { resize: vertical; min-height: 96px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgb(236 8 150 / 0.15); }
.hint { font-size: 12px; color: var(--faint); margin-top: 6px; }

/* Zona para soltar el logo, con vista previa */
.drop {
    position: relative; display: flex; align-items: center; gap: 14px;
    padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: 16px;
    background: var(--bg); cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.drop:hover, .drop.drag { border-color: var(--brand); background: rgb(236 8 150 / 0.05); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .preview {
    width: 56px; height: 56px; flex-shrink: 0; border-radius: 12px;
    display: grid; place-items: center; overflow: hidden;
    background: #fff; border: 1px solid var(--line); color: var(--faint);
}
.drop .preview img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.drop .t1 { font-weight: 600; font-size: 14px; }
.drop .t2 { font-size: 12px; color: var(--faint); }

/* ---------- Botones ---------- */
.btn {
    position: relative; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 700; font-size: 14px; white-space: nowrap;
    padding: 11px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
    transition: transform 0.2s var(--ease), background 0.25s, border-color 0.25s, color 0.25s, box-shadow 0.25s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 10px 28px -10px rgb(236 8 150 / 0.7); }
.btn-primary:hover { background: #a50068; box-shadow: 0 16px 36px -12px rgb(236 8 150 / 0.8); }
.btn-primary::after {
    content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 50%;
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.35), transparent);
    transform: skewX(-12deg); opacity: 0;
}
.btn-primary:hover::after { opacity: 1; animation: sheen 0.9s var(--ease); }
@keyframes sheen { from { left: -60%; } to { left: 130%; } }
.btn-ghost { background: var(--bg-elevated); color: var(--fg); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--faint); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: rgb(244 63 94 / 0.3); }
.btn-danger-ghost:hover { background: rgb(244 63 94 / 0.1); }
.btn-sm { padding: 8px 13px; font-size: 13px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn {
    width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px;
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--fg); }
.icon-btn.danger:hover { background: rgb(244 63 94 / 0.12); color: var(--danger); }

/* ---------- Listados ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; min-width: 220px; }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .input { padding-left: 42px; border-radius: 999px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elevated); color: var(--muted);
    transition: all 0.2s;
}
.chip:hover { color: var(--fg); border-color: var(--line-strong); }
.chip.on { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.chip small { opacity: 0.65; margin-left: 3px; }

.rows { display: flex; flex-direction: column; }
.row {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 24px; border-bottom: 1px solid var(--line);
    transition: background 0.2s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--bg-subtle); }
.thumb {
    width: 52px; height: 52px; flex-shrink: 0; border-radius: 14px; overflow: hidden;
    background: #fff; border: 1px solid var(--line); display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; }
/* Flechas ↑ ↓ para ordenar (productos) */
.mover { display: flex; margin-right: 6px; padding-right: 6px; border-right: 1px solid var(--line); }
.mover .icon-btn { width: 34px; }
.mover .icon-btn:disabled { opacity: 0.3; cursor: default; background: transparent; color: var(--muted); }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
    background: var(--bg-subtle); color: var(--muted); border: 1px solid var(--line);
}
.badge.brand { background: rgb(236 8 150 / 0.12); color: var(--brand); border-color: rgb(236 8 150 / 0.25); }
.dark .badge.brand { color: var(--brand-300); }
.badge.ok { background: rgb(16 185 129 / 0.12); color: var(--ok); border-color: rgb(16 185 129 / 0.25); }
.badge.warn { background: rgb(245 158 11 / 0.12); color: var(--warn); border-color: rgb(245 158 11 / 0.25); }
.badge.violet { background: rgb(124 58 237 / 0.12); color: #8b5cf6; border-color: rgb(124 58 237 / 0.25); }

/* Grilla de clientes */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 20px 24px 24px; }
.mini {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    border: 1px solid var(--line); border-radius: 16px; background: var(--bg);
    transition: border-color 0.2s, transform 0.3s var(--ease);
}
.mini:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.mini .row-actions { opacity: 0; transition: opacity 0.2s; }
.mini:hover .row-actions, .mini:focus-within .row-actions { opacity: 1; }

.empty { padding: 56px 24px; text-align: center; color: var(--faint); }
.empty .icon-tile { margin: 0 auto 14px; }

/* Layout de 2 columnas: formulario + listado */
.split { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.split > .sticky { position: sticky; top: 90px; }

/* ---------- Mensajes ---------- */
.msg { display: block; padding: 18px 24px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background 0.2s; }
.msg:hover { background: var(--bg-subtle); }
.msg:last-child { border-bottom: 0; }
.msg-top { display: flex; align-items: center; gap: 12px; }
.msg-top .avatar { width: 40px; height: 40px; }
.msg-meta { font-size: 12.5px; color: var(--faint); }
.msg-text { margin-top: 8px; margin-left: 52px; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

dialog.modal {
    width: min(620px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 24px;
    background: var(--bg-elevated); color: var(--fg); box-shadow: 0 40px 120px -20px rgb(0 0 0 / 0.6);
}
dialog.modal[open] { animation: pop 0.4s var(--ease); }
dialog.modal::backdrop { background: rgb(7 7 11 / 0.6); backdrop-filter: blur(6px); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.kv div { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.kv span { display: block; font-size: 11.5px; color: var(--faint); font-weight: 600; }
.kv b { font-size: 14px; word-break: break-word; }
.quote { white-space: pre-line; line-height: 1.65; padding: 16px 18px; border-radius: 16px; background: var(--bg-subtle); border-left: 3px solid var(--brand); }

/* ---------- Avisos ---------- */
.flash {
    display: flex; align-items: center; gap: 12px; padding: 14px 18px; margin-bottom: 20px;
    border-radius: 16px; font-weight: 600; font-size: 14px;
    animation: pop 0.5s var(--ease);
}
.flash.ok { background: rgb(16 185 129 / 0.1); color: var(--ok); border: 1px solid rgb(16 185 129 / 0.25); }
.flash.err { background: rgb(244 63 94 / 0.1); color: var(--danger); border: 1px solid rgb(244 63 94 / 0.25); }
.flash ul { margin: 0; padding-left: 18px; font-weight: 500; }
.flash-nota { display: block; margin-top: 2px; font-size: 13px; font-weight: 500; opacity: 0.85; }
.flash .x { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: 0.6; }

/* ---------- Paginación ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--line); font-size: 13px; color: var(--faint); }

/* ---------- Edición ---------- */
.back { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 18px; }
.back:hover { color: var(--fg); }
.back .ic { transition: transform 0.3s var(--ease); }
.back:hover .ic { transform: translateX(-4px); }
.edit-wrap { max-width: 760px; }
.current-logo { display: flex; align-items: center; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); }
.current-logo .thumb { width: 72px; height: 72px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
    position: relative; overflow: hidden; isolation: isolate;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 48px; background: #07070b; color: #f5f5f8;
}
.login-art .blob { position: absolute; border-radius: 50%; filter: blur(110px); z-index: -1; animation: blob 18s ease-in-out infinite; }
.login-art .b1 { width: 520px; height: 520px; background: rgb(236 8 150 / 0.45); top: -160px; left: -120px; }
.login-art .b2 { width: 460px; height: 460px; background: rgb(124 58 237 / 0.4); bottom: -160px; right: -120px; animation-delay: -7s; }
.login-art .grid {
    position: absolute; inset: 0; z-index: -1;
    background-image: linear-gradient(to right, rgb(255 255 255 / 0.06) 1px, transparent 1px), linear-gradient(to bottom, rgb(255 255 255 / 0.06) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 70% 60% at 40% 40%, #000 30%, transparent 75%);
}
@keyframes blob { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(6%, -6%) scale(1.08); } }
.login-art h1 { font-size: clamp(34px, 4vw, 54px); line-height: 1.04; font-weight: 800; letter-spacing: -0.045em; max-width: 520px; }
.login-art p { color: #a1a1b3; margin-top: 16px; max-width: 440px; font-size: 16px; }
.text-gradient {
    background: linear-gradient(100deg, var(--brand) 0%, #b42cff 45%, var(--brand-300) 70%, var(--brand) 100%);
    background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: shine 6s linear infinite;
}
@keyframes shine { from { background-position: 200% center; } to { background-position: -200% center; } }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form .box { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.035em; }
.login-form .sub { color: var(--muted); margin: 8px 0 28px; }
.login-form .field { margin-bottom: 16px; }
.pass-wrap { position: relative; }
.pass-wrap .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; }

.theme-float { position: fixed; top: 16px; right: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .split { grid-template-columns: 1fr; }
    .split > .sticky { position: static; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: 0 0 80px rgb(0 0 0 / 0.4); }
    .menu-open .sidebar { transform: none; }
    .scrim { position: fixed; inset: 0; z-index: 35; background: rgb(7 7 11 / 0.55); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
    .menu-open .scrim { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }
    .menu-btn { display: grid; }
    .topbar { padding: 12px 16px; }
    .content { padding: 20px 16px; }
    .stats { grid-template-columns: 1fr; }
    .login { grid-template-columns: 1fr; }
    .login-art { display: none; }
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .row { padding: 14px 16px; align-items: flex-start; }
    .row-sub { white-space: normal; }
    .toolbar, .card-head, .card-body, .grid-cards, .msg, .pager { padding-left: 16px; padding-right: 16px; }
    .mini .row-actions { opacity: 1; }
    .msg-text { margin-left: 0; }
    .kv { grid-template-columns: 1fr; }
}

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

/* ---------- Ajustes ---------- */
.topbar .menu-btn { display: none; }
.field .drop { display: flex; }
.mini { position: relative; }
.mini .row-actions {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: var(--bg-elevated); border: 1px solid var(--line); border-radius: 12px; padding: 2px;
    box-shadow: var(--shadow);
}
@media (max-width: 900px) {
    .topbar .menu-btn { display: grid; }
}
@media (max-width: 640px) {
    .mini .row-actions { position: static; transform: none; box-shadow: none; border: 0; background: none; }
}

/* =========================================================
   Edición asistida: logo, vista previa, validación, guardado
   ========================================================= */
.split-edit { grid-template-columns: 1fr 360px; }
.split-edit > .sticky { position: sticky; top: 90px; }

.public-url { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.public-url a { color: var(--brand); font-weight: 600; }
.dark .public-url a { color: var(--brand-300); }
.public-url a:hover { text-decoration: underline; }

.input.invalid, .textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgb(244 63 94 / 0.12); }
.field-error { margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--danger); }
.counter { float: right; font-variant-numeric: tabular-nums; }

/* Logo */
.drop-text { display: flex; flex-direction: column; min-width: 0; }
.drop .t1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop.busy { pointer-events: none; }
.drop.busy .preview { opacity: 0.4; }
.drop-spinner {
    display: none; position: absolute; left: 30px; top: 50%; width: 28px; height: 28px; margin-top: -14px;
    border-radius: 50%; border: 3px solid rgb(236 8 150 / 0.25); border-top-color: var(--brand);
    animation: spin 0.8s linear infinite;
}
.drop.busy .drop-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.drop.changed { border-style: solid; border-color: var(--ok); background: rgb(16 185 129 / 0.05); }
.drop.error { border-style: solid; border-color: var(--danger); background: rgb(244 63 94 / 0.05); }
.drop .preview img { animation: pop 0.45s var(--ease); }

.logo-info {
    display: flex; align-items: center; gap: 10px; margin-top: 10px;
    font-size: 12.5px; color: var(--muted);
}
.logo-info-text { flex: 1; min-width: 0; }
.logo-info-text b { color: var(--ok); }
.link-btn { font: inherit; font-weight: 700; color: var(--brand); background: none; border: 0; cursor: pointer; padding: 0; }
.dark .link-btn { color: var(--brand-300); }
.link-btn:hover { text-decoration: underline; }
.logo-notes { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.logo-notes li { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 8px 10px; border-radius: 10px; }
.logo-notes li.warn { background: rgb(245 158 11 / 0.1); color: var(--warn); }
.logo-notes li.err { background: rgb(244 63 94 / 0.1); color: var(--danger); font-weight: 600; }
.logo-notes li.info { background: var(--bg-subtle); color: var(--muted); }

/* Acciones del formulario */
.form-actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.dirty-note { margin-right: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--warn); }
.dirty-note .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 4px rgb(245 158 11 / 0.2); }
.btn[disabled] { opacity: 0.7; cursor: progress; }
.btn .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgb(255 255 255 / 0.4); border-top-color: #fff; animation: spin 0.8s linear infinite; }

/* Vista previa de la tarjeta del sitio (siempre en estilo oscuro, como el sitio por defecto) */
.site-preview-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 10px; }
.site-card {
    border-radius: 24px; padding: 8px; background: #0f0f16; border: 1px solid rgb(255 255 255 / 0.08); color: #f5f5f8;
    box-shadow: 0 30px 80px -30px rgb(236 8 150 / 0.35);
}
.site-card-media {
    position: relative; height: 200px; border-radius: 18px; display: grid; place-items: center; overflow: hidden;
    background: radial-gradient(circle at 50% 120%, rgb(236 8 150 / 0.3), transparent 60%), #16161f;
}
.site-card-media img { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 20px 30px rgb(0 0 0 / 0.35)); transition: transform 0.6s var(--ease); }
.site-card:hover .site-card-media img { transform: scale(1.08) rotate(-3deg); }
.site-card-empty { color: #6c6c7e; }
.site-card-badge { position: absolute; top: 12px; left: 12px; font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: #a1a1b3; border: 1px solid rgb(255 255 255 / 0.1); border-radius: 999px; padding: 3px 9px; background: rgb(10 10 16 / 0.6); }
.site-card-body { padding: 18px 14px 12px; }
.site-card-body h2 { font-size: 21px; font-weight: 800; }
.site-card-body p { margin-top: 6px; color: #a1a1b3; font-size: 14px; min-height: 42px; }
.site-card-body p:first-letter { text-transform: uppercase; }
.site-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid rgb(255 255 255 / 0.08); font-size: 13px; font-weight: 700; }
.site-card-foot > span { display: inline-flex; align-items: center; gap: 8px; }
.site-card-foot > span + span { color: #a1a1b3; font-weight: 500; }
.site-card-arrow { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #16161f; }
.is-placeholder { opacity: 0.45; }

/* Fila recién guardada */
.row.resaltar, .mini.resaltar { animation: resaltar 2.6s var(--ease); }
@keyframes resaltar {
    0%, 30% { background: rgb(16 185 129 / 0.16); box-shadow: inset 3px 0 0 var(--ok); }
    100% { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}

@media (max-width: 1100px) {
    .split-edit { grid-template-columns: 1fr; }
    .split-edit > .sticky { position: static; order: -1; }
}

/* =========================================================
   Clientes por producto: filtros, selección y asignación masiva
   ========================================================= */
.toolbar.filters { flex-direction: column; align-items: stretch; gap: 12px; }
.filter-row { display: flex; gap: 12px; align-items: flex-start; }
.filter-label {
    flex-shrink: 0; width: 96px; padding-top: 7px;
    font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint);
}
.chip-logo { display: inline-flex; align-items: center; gap: 6px; }
.chip-logo img { width: 18px; height: 18px; border-radius: 50%; background: #fff; object-fit: contain; }
.chip-warn small { color: var(--warn); opacity: 1; font-weight: 700; }
.chip-warn.on small { color: #fff; }

.select-hint { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 12px 24px 0; font-size: 12.5px; color: var(--faint); }

.prod-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.prod-tags .badge { font-size: 10.5px; padding: 2px 7px; }

/* Casilla de selección en cada cliente */
.pick { position: relative; flex-shrink: 0; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span {
    width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
    border: 1.5px solid var(--line-strong); background: var(--bg-elevated); color: transparent;
    transition: all 0.2s var(--ease);
}
.pick:hover span { border-color: var(--brand); }
.pick input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; transform: scale(1.05); }
.pick input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.mini.picked { border-color: var(--brand); background: rgb(236 8 150 / 0.06); }

/* Barra flotante de asignación */
.bulk-bar {
    position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(calc(-50% + var(--sidebar) / 2));
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
    padding: 10px 10px 10px 18px; border-radius: 999px;
    background: var(--glass); backdrop-filter: blur(18px) saturate(1.5);
    border: 1px solid var(--line-strong); box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.55);
    animation: subir 0.45s var(--ease);
}
.bulk-bar[hidden] { display: none; }
@keyframes subir { from { opacity: 0; transform: translate(calc(-50% + var(--sidebar) / 2), 20px); } }
.bulk-count { font-size: 14px; color: var(--muted); white-space: nowrap; }
.bulk-count b { color: var(--fg); }
.bulk-bar .select { width: auto; min-width: 200px; padding: 9px 14px; border-radius: 999px; }
.select.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgb(244 63 94 / 0.12); }

/* Elegir productos en el formulario del cliente */
.prod-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.prod-check { position: relative; cursor: pointer; }
.prod-check input { position: absolute; opacity: 0; }
.prod-check-box {
    display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 14px;
    border: 1px solid var(--line-strong); background: var(--bg); font-size: 13.5px; font-weight: 600; color: var(--muted);
    transition: all 0.2s var(--ease);
}
.prod-check-box img { width: 24px; height: 24px; border-radius: 50%; background: #fff; object-fit: contain; flex-shrink: 0; }
.prod-check-box > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-check-box .tick { opacity: 0; color: var(--brand); transition: opacity 0.2s; }
.prod-check:hover .prod-check-box { border-color: var(--faint); }
.prod-check input:checked + .prod-check-box { border-color: var(--brand); background: rgb(236 8 150 / 0.08); color: var(--fg); }
.prod-check input:checked + .prod-check-box .tick { opacity: 1; }
.prod-check input:focus-visible + .prod-check-box { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (max-width: 900px) {
    .bulk-bar { transform: translateX(-50%); width: calc(100% - 24px); border-radius: 20px; bottom: 12px; }
    @keyframes subir { from { opacity: 0; transform: translate(-50%, 20px); } }
}
@media (max-width: 640px) {
    .filter-row { flex-direction: column; gap: 6px; }
    .filter-label { width: auto; padding: 0; }
    .select-hint { padding: 12px 16px 0; }
}

/* Espacio para que la barra de asignación no tape la última fila */
body.con-barra .content { padding-bottom: 120px; }

/* =========================================================
   Contraste AA (≥ 4,5:1) en ambos temas — auditoría axe
   El magenta #EC0896 queda para fondos y decoración; para TEXTO se usa
   un tono más profundo en tema claro. Los colores de estado (verde,
   ámbar, rojo) son oscuros en tema claro y brillantes en tema oscuro.
   ========================================================= */
:root {
    --brand-ink: #b0006f;
    --violet-ink: #6d28d9;
    --ok: #047857;
    --warn: #9a4a08;
    --danger: #be123c;
}
.dark {
    --brand-ink: #ff92d1;
    --violet-ink: #a78bfa;
    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #fb7185;
}
.nav a.active, .dark .nav a.active,
.icon-tile, .dark .icon-tile,
.stat-link, .dark .stat-link,
.badge.brand, .dark .badge.brand,
.public-url a, .dark .public-url a,
.link-btn, .dark .link-btn,
.prod-check-box .tick { color: var(--brand-ink); }
.badge.violet { color: var(--violet-ink); }
.chip small { opacity: 1; }
.chip-warn small { color: var(--warn); }
.chip.on small, .chip-warn.on small { color: #fff; }

/* Mensajes: el título abre el mensaje (botón propio, no anidado con las acciones) */
.msg-open { all: unset; cursor: pointer; font-weight: 700; }
.msg-open:hover { text-decoration: underline; }
.msg-open:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 6px; }

/* =========================================================
   Estadísticas
   ========================================================= */
:root { --chart: #cc0080; --ok-text: #047857; --danger-text: #be123c; }
.dark { --chart: #ec0896; --ok-text: #34d399; --danger-text: #fb7185; }

.live {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px;
    border: 1px solid var(--line-strong); background: var(--bg-elevated); font-size: 14px; color: var(--muted);
}
.live b { color: var(--fg); font-size: 16px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgb(16 185 129 / 0.6); animation: live-pulso 2s infinite; }
@keyframes live-pulso { 70% { box-shadow: 0 0 0 9px rgb(16 185 129 / 0); } 100% { box-shadow: 0 0 0 0 rgb(16 185 129 / 0); } }

.head-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.refresh .ic { transition: transform 0.3s var(--ease); }
.refresh.cargando { pointer-events: none; opacity: 0.75; }
.refresh.cargando .ic { animation: girar 0.8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.filtros { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.actualizado { font-size: 12.5px; color: var(--faint); }
/* Mientras se traen los números nuevos, se mantiene lo anterior atenuado (sin saltos) */
.metricas-cuerpo { transition: opacity 0.25s; }
.metricas-cuerpo.cargando { opacity: 0.55; }
.periodos .chip { text-decoration: none; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.icon-tile.sm { width: 34px; height: 34px; border-radius: 11px; }
.icon-tile.sm .ic { width: 16px; height: 16px; }
.kpi-value { font-size: 30px; line-height: 1.05; font-weight: 800; letter-spacing: -0.04em; }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 22px; font-size: 12.5px; }
.kpi-note { color: var(--faint); }
.kpi-caption { font-size: 12.5px; color: var(--faint); margin: 10px 2px 24px; }
.kpis + .chart-card { margin-top: 24px; }
.stat .delta { align-self: flex-start; margin-top: -8px; font-size: 12.5px; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg-subtle); color: var(--muted); }
.delta.bien { color: var(--ok-text); background: rgb(16 185 129 / 0.12); }
.delta.mal { color: var(--danger-text); background: rgb(244 63 94 / 0.12); }
.delta.neutro { font-weight: 600; }

.chart-card { margin-bottom: 24px; overflow: visible; }
.chart { position: relative; margin: 0; height: 300px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--brand); outline-offset: 6px; border-radius: 8px; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .eje text { fill: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--chart); opacity: 0.1; }
.chart .linea { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .linea.parcial { stroke-dasharray: 4 4; }
.chart .cruz { stroke: var(--line-strong); stroke-width: 1; }
.chart .punto { fill: var(--chart); stroke: var(--bg-elevated); stroke-width: 2; }
.chart-tip {
    position: absolute; top: 0; z-index: 2; pointer-events: none; min-width: 170px;
    padding: 10px 12px; border-radius: 12px; background: var(--bg-elevated); border: 1px solid var(--line-strong);
    box-shadow: var(--shadow); font-size: 12.5px; transform: translateX(-50%);
}
.chart-tip .t { color: var(--faint); font-weight: 600; margin-bottom: 6px; }
.chart-tip .r { display: flex; align-items: center; gap: 8px; }
.chart-tip .r + .r { margin-top: 3px; }
.chart-tip .r b { font-size: 14px; color: var(--fg); font-variant-numeric: tabular-nums; }
.chart-tip .r span { color: var(--muted); }
.chart-tip .key { width: 12px; height: 2px; border-radius: 2px; background: var(--chart); }
.chart-tip .key.off { background: transparent; }
.chart-table { margin-top: 14px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-weight: 600; width: max-content; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.chart-table th, .chart-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.chart-table th { color: var(--faint); font-weight: 600; }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-table small { color: var(--faint); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.rank-card .card-head .icon-tile { width: 38px; height: 38px; border-radius: 12px; }
.rank { padding: 6px 0 10px; }
.rank-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 84px 70px; align-items: center; gap: 12px;
    padding: 9px 24px; font-size: 14px;
}
.rank-row:has(> :nth-child(4)) { grid-template-columns: minmax(0, 1fr) 84px 84px 64px; }
.rank-row:not(.rank-head):hover { background: var(--bg-subtle); }
.rank-head { font-size: 11.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 8px; padding-bottom: 6px; }
.rank-name { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rank-bar { display: block; height: 4px; border-radius: 4px; background: var(--bg-subtle); }
.rank-bar i { display: block; height: 100%; min-width: 4px; border-radius: 4px; background: var(--chart); }
.rank .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank .strong { font-weight: 700; }
.rank .muted { color: var(--muted); }
.rank-more { padding: 6px 24px 4px; font-size: 12.5px; color: var(--faint); }
.empty.sm { padding: 34px 24px; font-size: 14px; }

.privacy-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 24px; font-size: 12.5px; color: var(--faint); max-width: 860px; }
.privacy-note .ic { margin-top: 2px; }

@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi-value { font-size: 26px; }
    .chart { height: 240px; }
    .rank-row { padding-left: 16px; padding-right: 16px; grid-template-columns: minmax(0, 1fr) 72px 56px; }
    .rank-row:has(> :nth-child(4)) { grid-template-columns: minmax(0, 1fr) 58px 64px 50px; }
}
@media (prefers-reduced-motion: reduce) { .live-dot, .refresh.cargando .ic { animation: none; } }
@media (max-width: 1280px) and (min-width: 901px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
