:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --navy: #0b2545;
    --blue: #0066cc;
    --blue-hover: #0052a3;
    --cyan: #0ea5e9;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --green-bg: #dcfce7;
    --green-txt: #166534;
    --red-bg: #fee2e2;
    --red-txt: #991b1b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
}

/* Barra superior */
.topbar {
    background: var(--navy);
    color: #fff;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    background: var(--cyan);
    color: var(--navy);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}

.brand h1 {
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 0.78rem;
    color: #93c5fd;
}

.search-bar {
    flex: 1;
    max-width: 520px;
    display: flex;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
}

.search-bar:focus-within {
    border-color: var(--cyan);
}

.search-bar input {
    flex: 1;
    border: none;
    padding: 10px 14px;
    font-size: 0.95rem;
    outline: none;
}

.btn-clear {
    background: transparent;
    border: none;
    padding: 0 14px;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
}

.status-pill {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
}

.status-ok { background: #064e3b; color: #6ee7b7; }
.status-err { background: #7f1d1d; color: #fca5a5; }
.status-loading { background: #1e3a8a; color: #bfdbfe; }

/* Pestañas */
.tabs {
    background: var(--surface);
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tab {
    background: none;
    border: none;
    padding: 14px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

.badge {
    background: #e2e8f0;
    color: var(--text);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
}

.tab.active .badge {
    background: #dbeafe;
    color: var(--blue);
}

/* Contenedor */
.container {
    max-width: 1280px;
    margin: 24px auto;
    padding: 0 20px;
}

.panel { display: none; }
.panel.active { display: block; }

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.panel-header h2 { font-size: 1.35rem; color: var(--navy); }
.panel-header p { color: var(--muted); font-size: 0.9rem; }

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Botones */
.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-ghost { background: #e2e8f0; color: var(--text); }
.btn-ghost:hover { background: #cbd5e1; }

.btn-sm {
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-edit { background: #e0f2fe; color: #0369a1; }
.btn-edit:hover { background: #bae6fd; }
.btn-del { background: #fee2e2; color: #b91c1c; }
.btn-del:hover { background: #fecaca; }

/* Grid de Tarjetas estilo Tienda de Electrónica */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

.card-top {
    padding: 12px 14px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.sku-tag {
    background: #eff6ff;
    color: var(--blue);
    font-family: monospace;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #bfdbfe;
}

.id-tag {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 600;
}

.card-visual {
    padding: 14px;
    display: flex;
    justify-content: center;
}

.circuit-svg {
    width: 100%;
    max-width: 190px;
    height: 95px;
}

.card-body {
    padding: 0 16px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-body h3 {
    font-size: 1.05rem;
    color: var(--navy);
    margin-bottom: 6px;
}

.card-body .desc {
    font-size: 0.86rem;
    color: var(--muted);
    line-height: 1.4;
    flex: 1;
    margin-bottom: 14px;
}

.price-stock {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--navy);
}

.stock {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 6px;
}

.in-stock { background: var(--green-bg); color: var(--green-txt); }
.out-stock { background: var(--red-bg); color: var(--red-txt); }

.card-actions {
    background: #f8fafc;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Tablas */
.table-wrap {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    background: #f8fafc;
    color: var(--navy);
    font-weight: 700;
}

tr:hover td { background: #f8fafc; }

.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    display: inline-block;
}

.pill-mos { background: #e0f2fe; color: #0369a1; }
.pill-dom { background: #fef3c7; color: #92400e; }

.sku-mini {
    font-family: monospace;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.select-filter {
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
}

/* Modales */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 100;
    overflow-y: auto;
}

.hidden { display: none !important; }

.modal-card {
    background: var(--surface);
    width: 100%;
    max-width: 540px;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-card-wide {
    max-width: 680px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--muted);
}

.btn-close:hover {
    color: var(--navy);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: span 2; }

.form-group label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--navy);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.92rem;
    background: var(--surface);
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
}

/* Filas de detalle en ventas / presupuesto */
.detalle-row {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
}

.total-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--navy);
    font-weight: 800;
    font-size: 1.15rem;
    padding: 8px 12px;
    border-radius: 8px;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* Notificaciones Toast */
.toast {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.92rem;
}

.toast-ok { background: var(--green-bg); color: var(--green-txt); border: 1px solid #86efac; }
.toast-error { background: var(--red-bg); color: var(--red-txt); border: 1px solid #fca5a5; }

.empty-state, .empty-cell {
    text-align: center;
    padding: 32px;
    color: var(--muted);
    background: var(--surface);
    border-radius: 10px;
}

@media (max-width: 560px) {
    .topbar {
        padding: 12px 16px;
    }

    .tabs {
        padding: 0 12px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full {
        grid-column: span 1;
    }
}