:root {
    --bg: #0f172a;
    --panel: #ffffff;
    --page-bg: #f4f6f9;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #ca8a04;
    --blue: #2563eb;
    --gray: #64748b;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--page-bg);
    color: var(--text);
    margin: 0;
}

.topbar {
    background: var(--bg);
    color: #fff;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar .brand {
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar nav a {
    color: #cbd5e1;
    text-decoration: none;
    margin-left: 18px;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 6px;
}

.topbar nav a:hover, .topbar nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 14px; }
p.subtitle { color: var(--muted); margin-top: 0; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin: 20px 0 28px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.card .label {
    font-size: 12.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 6px;
}

.card .value {
    font-size: 23px;
    font-weight: 700;
}

.card .value.positive { color: var(--green); }
.card .value.negative { color: var(--red); }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 22px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.filters a {
    text-decoration: none;
    color: var(--muted);
    font-size: 13.5px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    margin-right: 6px;
    display: inline-block;
    margin-bottom: 6px;
}

.filters a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #64748b; }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

th, td {
    padding: 10px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

tr:hover td { background: #f8fafc; }

.table-wrap { overflow-x: auto; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }

.profit-pos { color: var(--green); font-weight: 700; }
.profit-neg { color: var(--red); font-weight: 700; }

form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #334155;
}

form input, form select, form textarea {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
}

form textarea { resize: vertical; min-height: 70px; }

.hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.actions-cell a { margin-right: 10px; font-size: 13px; text-decoration: none; }

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #dcfce7; color: #15803d; }
.alert-error { background: #fee2e2; color: #b91c1c; }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 10px;
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

.calc-box {
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 13.5px;
    margin-top: 10px;
}
.calc-box b { color: var(--text); }

/* =========================================================
 * LOGIN
 * ========================================================= */
.login-body {
    background: var(--bg);
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-wrap {
    width: 100%;
    padding: 20px;
}
.login-box {
    max-width: 380px;
    margin: 0 auto;
    background: var(--panel);
    border-radius: var(--radius);
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.login-brand {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2px;
}
.login-box label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #334155;
}
.login-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 14px;
}

.small-link {
    color: #cbd5e1 !important;
    font-size: 13px !important;
}

/* =========================================================
 * CATÁLOGO PÚBLICO
 * ========================================================= */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 22px;
}

.product-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: transform .15s ease, box-shadow .15s ease;
}
.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(15,23,42,0.10);
}

.product-thumb {
    aspect-ratio: 1 / 1;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.no-photo {
    font-size: 42px;
    opacity: .4;
}

.product-info { padding: 14px 14px 16px; }
.product-title {
    font-weight: 700;
    font-size: 14.5px;
    margin-bottom: 6px;
    line-height: 1.3;
}
.product-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
}
.product-excerpt {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.4;
}

/* Detalle de producto */
.product-detail {
    display: grid;
    grid-template-columns: minmax(280px, 1.1fr) 1fr;
    gap: 32px;
    margin-top: 10px;
}
@media (max-width: 760px) {
    .product-detail { grid-template-columns: 1fr; }
}

.main-media {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f1f5f9;
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.main-media img, .main-media video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.no-photo-big {
    font-size: 60px;
    opacity: .35;
}

.thumb-strip {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.thumb {
    width: 62px;
    height: 62px;
    border-radius: 8px;
    object-fit: cover;
    border: 2px solid transparent;
    cursor: pointer;
    background: #f1f5f9;
}
.thumb.active { border-color: var(--primary); }
.thumb-video {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: #fff;
    font-size: 20px;
}

.product-price-big {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    margin: 6px 0 4px;
}
.product-description {
    font-size: 14.5px;
    line-height: 1.6;
    color: #334155;
}

/* =========================================================
 * GALERÍA DE MEDIA EN EL PANEL ADMIN
 * ========================================================= */
.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 6px;
}
.media-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid var(--border);
}
.media-thumb img, .media-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.media-thumb-video video { object-fit: contain; background: #000; }
.media-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(220,38,38,0.9);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 12px;
    line-height: 1;
}
.media-delete:hover { background: #b91c1c; }
