:root {
    --bg-0: #030817;
    --bg-1: #071330;
    --bg-2: #0b1d45;
    --panel: rgba(13, 30, 70, 0.55);
    --panel-border: rgba(56, 189, 248, 0.18);
    --primary: #2563eb;
    --primary-2: #0ea5e9;
    --accent: #22d3ee;
    --text: #e2ecff;
    --muted: #8aa4d6;
    --danger: #f43f5e;
    --success: #10b981;
    --radius: 14px;
    --glow: 0 0 0 1px rgba(56, 189, 248, 0.25), 0 10px 40px -10px rgba(14, 165, 233, 0.45);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-tech: 'Orbitron', var(--font);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(37, 99, 235, 0.35), transparent 60%),
        radial-gradient(900px 500px at 110% 10%, rgba(34, 211, 238, 0.18), transparent 60%),
        linear-gradient(180deg, var(--bg-1), var(--bg-0));
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(56, 189, 248, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.06) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
    pointer-events: none;
    z-index: 0;
}

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

svg.icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Botones y formularios ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 10px;
    border: 1px solid transparent;
    font: 600 14px var(--font);
    letter-spacing: .3px;
    cursor: pointer;
    color: #fff;
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
    text-decoration: none !important;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 8px 24px -8px rgba(14, 165, 233, .7);
}
.btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 12px 30px -8px rgba(34, 211, 238, .8); }
.btn-ghost {
    background: rgba(56, 189, 248, .08);
    border-color: var(--panel-border);
    color: var(--text);
}
.btn-ghost:hover { background: rgba(56, 189, 248, .16); }
.btn-danger {
    background: rgba(244, 63, 94, .12);
    border-color: rgba(244, 63, 94, .35);
    color: #fda4af;
}
.btn-danger:hover { background: rgba(244, 63, 94, .25); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    margin-bottom: 8px;
}
.input-wrap { position: relative; }
.input-wrap svg.icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.input, select.input, textarea.input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(3, 8, 23, .6);
    border: 1px solid rgba(56, 189, 248, .22);
    border-radius: 10px;
    color: var(--text);
    font: 15px var(--font);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.input-wrap .input { padding-left: 42px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .18); }
.input::placeholder { color: #4f6894; }
select.input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
    background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%;
    background-size: 6px 6px;
    background-repeat: no-repeat;
    padding-right: 40px;
}
select.input option { background: var(--bg-1); color: var(--text); }
.field-error { color: #fda4af; font-size: 13px; margin-top: 6px; }
.input.is-invalid { border-color: rgba(244, 63, 94, .6); }

/* ---------- Alertas ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: rgba(16, 185, 129, .1); border-color: rgba(16, 185, 129, .35); color: #6ee7b7; }
.alert-error { background: rgba(244, 63, 94, .1); border-color: rgba(244, 63, 94, .35); color: #fda4af; }

/* ---------- Login ---------- */
.auth {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 410px;
    padding: 40px 36px 34px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    backdrop-filter: blur(16px);
    box-shadow: var(--glow);
    position: relative;
    overflow: hidden;
}
.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: -40%;
    width: 80%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: scan 3.5s linear infinite;
}
@keyframes scan { from { left: -80%; } to { left: 100%; } }
.auth-logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 28px; text-align: center; }
.auth-logo .logo-badge { width: 64px; height: 64px; margin-bottom: 14px; }
.auth-logo h1 { font-family: var(--font-tech); font-size: 22px; letter-spacing: 3px; margin: 0; }
.auth-logo p { color: var(--muted); margin: 6px 0 0; font-size: 14px; }

.logo-badge {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 0 24px rgba(34, 211, 238, .45);
    color: #fff;
}
.logo-badge svg { width: 60%; height: 60%; }

.text-gradient {
    background: linear-gradient(90deg, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---------- Layout de la app ---------- */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    padding: 24px 16px;
    background: rgba(3, 8, 23, .55);
    border-right: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand span { font-family: var(--font-tech); font-weight: 700; letter-spacing: 1.5px; font-size: 14px; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: #4f6894; padding: 14px 12px 6px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all .2s;
    text-decoration: none;
}
.nav a:hover { color: var(--text); background: rgba(56, 189, 248, .07); }
.nav a.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(37, 99, 235, .35), rgba(14, 165, 233, .08));
    border-color: rgba(56, 189, 248, .3);
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--panel-border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 12px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    font-weight: 700; font-size: 14px;
}
.user-chip small { display: block; color: var(--muted); font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 32px 40px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; margin-bottom: 28px; }
.page-head h2 { margin: 0; font-size: 26px; font-weight: 700; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 24px;
    backdrop-filter: blur(12px);
    margin-bottom: 24px;
}
.card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 20px; font-size: 16px; font-weight: 600; }
.card-title svg { color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 360px 1fr; gap: 24px; align-items: start; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center;
    background: rgba(14, 165, 233, .12);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, .25);
}
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.stat-label { color: var(--muted); font-size: 13px; }

/* ---------- Zona de subida ---------- */
.dropzone {
    border: 2px dashed rgba(56, 189, 248, .35);
    border-radius: 14px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: rgba(3, 8, 23, .35);
    position: relative;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: rgba(14, 165, 233, .08); box-shadow: inset 0 0 30px rgba(34, 211, 238, .12); }
.field label.dropzone { text-transform: none; letter-spacing: normal; font-weight: 400; font-size: inherit; color: var(--text); margin: 0; }
.dropzone.disabled { opacity: .45; pointer-events: none; }
.dropzone svg { width: 42px; height: 42px; color: var(--accent); margin-bottom: 10px; }
.dropzone strong { display: block; font-size: 15px; margin-bottom: 4px; }
.dropzone span { color: var(--muted); font-size: 13px; }
.dropzone input[type=file] { display: none; }

.preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin-top: 14px; }
.preview img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--panel-border); }
.preview-info { color: var(--muted); font-size: 13px; margin-top: 10px; }

.empty-note {
    padding: 16px;
    border-radius: 10px;
    background: rgba(250, 204, 21, .08);
    border: 1px solid rgba(250, 204, 21, .3);
    color: #fde68a;
    font-size: 14px;
    margin-bottom: 18px;
}

/* ---------- Filtros ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--muted);
    background: rgba(56, 189, 248, .06);
    border: 1px solid var(--panel-border);
    text-decoration: none !important;
    transition: all .2s;
}
.chip:hover { color: var(--text); border-color: rgba(56, 189, 248, .45); }
.chip.active { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); border-color: transparent; }

/* ---------- Galería ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.tile {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    background: var(--bg-0);
    transition: transform .2s, box-shadow .2s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--glow); }
.tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; cursor: zoom-in; }
.tile-info { padding: 10px 12px; font-size: 12px; }
.tile-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.tile-meta { display: flex; justify-content: space-between; color: var(--muted); }
.tile-tag {
    position: absolute; top: 8px; left: 8px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    background: rgba(3, 8, 23, .75);
    border: 1px solid rgba(56, 189, 248, .4);
    color: var(--accent);
    backdrop-filter: blur(6px);
}
.tile-actions { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .2s; }
.tile:hover .tile-actions { opacity: 1; }
.tile-actions .btn { padding: 6px 8px; background: rgba(3, 8, 23, .8); }

.empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--muted);
}
.empty svg { width: 54px; height: 54px; color: rgba(56, 189, 248, .4); margin-bottom: 12px; }

/* ---------- Tabla ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--panel-border);
}
.table td { padding: 14px 12px; border-bottom: 1px solid rgba(56, 189, 248, .08); vertical-align: middle; }
.table tr:hover td { background: rgba(56, 189, 248, .04); }
.badge {
    display: inline-block;
    min-width: 28px;
    padding: 3px 10px;
    border-radius: 999px;
    text-align: center;
    font-size: 12px; font-weight: 600;
    background: rgba(14, 165, 233, .15);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, .3);
}
.text-muted { color: var(--muted); }

.badge-danger { background: rgba(244, 63, 94, .15); color: #fda4af; border-color: rgba(244, 63, 94, .35); }

/* ---------- Marketplace ---------- */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.search-bar .input-wrap { flex: 1; min-width: 220px; }
.thumb {
    width: 56px; height: 56px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    background: var(--bg-0);
    display: block;
}
.thumb-empty { display: grid; place-items: center; color: var(--muted); font-size: 10px; text-align: center; }
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.producto-foto { display: grid; place-items: center; min-height: 280px; padding: 12px; overflow: hidden; }
.producto-foto img { max-width: 100%; max-height: 320px; border-radius: 10px; object-fit: contain; }
[hidden] { display: none !important; }

/* ---------- Paginación ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 36px; padding: 7px 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    border: 1px solid var(--panel-border);
    color: var(--muted);
    text-decoration: none !important;
}
.pagination a:hover { color: #fff; border-color: var(--accent); }
.pagination .current { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }
.pagination .disabled { opacity: .4; }

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(2, 6, 18, .92);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center; justify-content: center;
    padding: 30px;
    cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 12px; box-shadow: 0 0 60px rgba(34, 211, 238, .3); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 14px; }
    .brand { padding: 0 8px 0 0; }
    .nav { flex-direction: row; }
    .nav-label { display: none; }
    .sidebar-footer { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; }
    .user-chip { margin: 0; }
    .user-chip div:last-child { display: none; }
    .main { padding: 24px 16px 40px; }
    .stats { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .hide-sm { display: none; }
}
