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

:root {
    --bg:                #0d1117;
    --sidebar-bg:        #161b22;
    --border:            #30363d;
    --text:              #e6edf3;
    --text-muted:        #8b949e;
    --btn-hover:         #2d333b;
    --btn-active:        #7C3AED;
    --btn-active-border: #8B5CF6;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.layout {
    display: flex;
    height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
    width: 5%;
    min-width: 72px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 8px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 14px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.nav-btn:hover {
    background: var(--btn-hover);
    border-color: var(--border);
}

.nav-btn.active {
    background: var(--btn-active);
    border-color: var(--btn-active-border);
}

.nav-btn i    { font-size: 1.3rem; color: #ffffff; }
.nav-btn span {
    font-size: 0.6rem;
    color: #ffffff;
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

/* ── Main ────────────────────────────────────────────── */
.main {
    flex: 1;
    background: var(--bg);
    padding: 36px 40px;
    overflow-y: auto;
}

/* ── Secciones ───────────────────────────────────────── */
.seccion { display: flex; flex-direction: column; gap: 24px; }
.oculta  { display: none !important; }

.sec-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sec-titulo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

/* ── Botón agregar ───────────────────────────────────── */
.btn-agregar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #7C3AED;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-agregar:hover { background: #8B5CF6; }

/* ── Grid clientes ───────────────────────────────────── */
.grid-clientes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}

/* ── Card cliente ────────────────────────────────────── */
.card-cliente {
    background: #161b22;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 18px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    transition: border-color 0.15s;
}
.card-cliente:hover { border-color: #A78BFA; }

.card-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.card-nombre {
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    color: var(--text);
}

.card-dato {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: var(--text-muted);
}
.card-dato i { font-size: 0.68rem; color: #A78BFA; }

.btn-eliminar {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #484f58;
    cursor: pointer;
    padding: 5px 6px;
    border-radius: 6px;
    font-size: 0.72rem;
    transition: color 0.15s, background 0.15s;
}
.btn-eliminar:hover {
    color: #f85149;
    background: rgba(248, 81, 73, 0.1);
}

.sin-datos {
    color: var(--text-muted);
    font-size: 0.9rem;
    grid-column: 1 / -1;
}

/* ── Modal overlay ───────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #161b22;
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 480px;
    max-width: 95vw;
    padding: 28px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }

.modal-cerrar {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}
.modal-cerrar:hover { color: var(--text); background: var(--btn-hover); }

/* ── Formulario ──────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.campo { display: flex; flex-direction: column; gap: 6px; }

.campo label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.campo input {
    background: #0d1117;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}
.campo input:focus        { border-color: #8B5CF6; }
.campo input::placeholder { color: #484f58; }

/* ── Modal footer ────────────────────────────────────── */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-cancelar {
    padding: 10px 18px;
    background: #21262d;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-cancelar:hover { background: var(--btn-hover); }

.btn-guardar {
    padding: 10px 20px;
    background: #7C3AED;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-guardar:hover { background: #8B5CF6; }

/* ── Logo sidebar ────────────────────────────────────── */
.sidebar-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 4px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    overflow: hidden;
    width: 100%;
}

.logo-img {
    width: 80%;
    max-width: 90px;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
}

/* ── Responsive móvil ────────────────────────────────── */
@media (max-width: 768px) {

    .layout {
        flex-direction: column;
    }

    /* Sidebar se convierte en barra fija inferior */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        min-width: unset;
        height: auto;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 6px 8px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
        z-index: 100;
    }

    .sidebar-logo { display: none; }

    .nav {
        flex-direction: row;
        width: 100%;
        gap: 4px;
    }

    .nav-btn {
        flex: 1;
        padding: 10px 4px;
        border-radius: 10px;
        border-color: transparent;
    }

    .nav-btn i    { font-size: 1.2rem; }
    .nav-btn span { font-size: 0.55rem; }

    /* Contenido principal con espacio para la barra inferior */
    .main {
        padding: 20px 16px 85px;
    }

    /* Grid de clientes en 2 columnas en móvil */
    .grid-clientes {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Header de sección */
    .sec-header { flex-wrap: wrap; gap: 12px; }
    .sec-titulo  { font-size: 1.1rem; }

    /* Formulario modal en 1 columna */
    .form-grid { grid-template-columns: 1fr; }

    .modal { padding: 20px 16px; }
}

/* Pantallas muy pequeñas: 1 columna */
@media (max-width: 400px) {
    .grid-clientes {
        grid-template-columns: 1fr;
    }
}

/* ── Layout clientes 70/30 ───────────────────────────── */
.clientes-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.clientes-grid-wrap {
    flex: 1;
    min-width: 0;
}

/* ── Panel lateral derecho ───────────────────────────── */
.clientes-panel {
    width: 20%;
    min-width: 240px;
    background: #161b22;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    position: sticky;
    top: 0;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.panel-vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 50px 20px;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.85rem;
}
.panel-vacio i    { font-size: 1.8rem; color: #30363d; }
.panel-vacio p    { line-height: 1.5; }

.panel-cargando {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 50px;
    color: var(--text-muted);
    font-size: 1.4rem;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
}

.panel-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.panel-nombre    { font-weight: 600; font-size: 0.95rem; }
.panel-subtitulo { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.panel-pedidos { padding: 8px 18px 18px; }

/* ── Card seleccionada ───────────────────────────────── */
.card-cliente { cursor: pointer; }
.card-cliente.seleccionada {
    border-color: #7C3AED;
    background: #1c1033;
}

/* ── Items de pedido ─────────────────────────────────── */
.pedido-item {
    padding: 12px 0;
    border-bottom: 1px solid #21262d;
}
.pedido-item:last-child { border-bottom: none; }

.pedido-producto { font-weight: 600; font-size: 0.88rem; margin-bottom: 3px; }
.pedido-desc     { font-size: 0.73rem; color: var(--text-muted); margin-bottom: 7px; }

.pedido-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.pedido-monto { font-weight: 700; font-size: 0.88rem; }

.estado-badge {
    font-size: 0.67rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.estado-pendiente  { background: rgba(154,103,0,0.25);   color: #e3b341; }
.estado-en_proceso { background: rgba(124,58,237,0.25);  color: #C4B5FD; }
.estado-completado { background: rgba(26,127,55,0.25);   color: #3fb950; }
.estado-entregado  { background: rgba(100,100,100,0.2);  color: #8b949e; }

.pedido-fecha {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.pedido-fecha i { font-size: 0.65rem; color: #A78BFA; }

/* ── Responsive: panel debajo en móvil ───────────────── */
@media (max-width: 768px) {
    .clientes-layout  { flex-direction: column; }
    .clientes-panel   { width: 100%; min-width: unset; position: static; max-height: none; }
}

/* ══════════════════════════════════════════════════════
   Sección Ventas
   ══════════════════════════════════════════════════════ */

.ventas-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.vstat-card {
    background: #161b22;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.vstat-icon {
    font-size: 1.4rem;
    color: #7C3AED;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
}
.vstat-num {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}
.vstat-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.ventas-lista-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #161b22;
}
.ventas-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.ventas-tabla thead th {
    background: #1c2128;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.ventas-tabla tbody tr {
    border-bottom: 1px solid rgba(48,54,61,0.6);
    transition: background 0.12s;
}
.ventas-tabla tbody tr:last-child { border-bottom: none; }
.ventas-tabla tbody tr:hover { background: #1c2128; }
.ventas-tabla td { padding: 11px 16px; vertical-align: middle; }

.venta-num   { color: var(--text-muted); font-size: 0.78rem; width: 36px; }
.venta-cliente {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    font-weight: 500;
}
.venta-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.venta-prod-nombre { font-weight: 500; color: var(--text); }
.venta-prod-desc   { font-size: 0.73rem; color: var(--text-muted); margin-top: 2px; }
.venta-fecha       { color: var(--text-muted); white-space: nowrap; font-size: 0.82rem; }
.venta-monto       { font-weight: 700; color: #3fb950; white-space: nowrap; }

@media (max-width: 768px) {
    .ventas-stats { grid-template-columns: repeat(2, 1fr); }
    .vstat-card   { padding: 14px; }
    .venta-prod-desc { display: none; }
    .venta-fecha  { display: none; }
}

/* ══════════════════════════════════════════════════════
   Barra de acciones global
   ══════════════════════════════════════════════════════ */

.barra-acciones {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.btn-accion {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 26px;
    background: #7C3AED;
    border: 1px solid #8B5CF6;
    border-radius: 10px;
    color: #fff;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.btn-accion i {
    color: #E9D5FF;
    font-size: 1.05rem;
}
.btn-accion:hover {
    background: #6D28D9;
    border-color: #7C3AED;
    box-shadow: 0 4px 14px rgba(124,58,237,0.4);
}
.btn-accion:active {
    background: #5B21B6;
}

@media (max-width: 768px) {
    .barra-acciones {
        gap: 8px;
        margin-bottom: 16px;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .barra-acciones::-webkit-scrollbar { display: none; }
    .btn-accion {
        padding: 12px 18px;
        font-size: 0.88rem;
        flex-shrink: 0;
    }
}
