:root {
    --bg: #f4f7f6;
    --white: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --accent: #0984e3;
    --danger: #d63031;
    --success: #00b894;
    --excel: #217346; 
    --border: #dfe6e9;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body { 
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    padding: 20px; 
    line-height: 1.6;
}

header { 
    max-width: 900px; 
    margin: 0 auto 30px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 20px; 
}

h1 { font-size: 1.8rem; flex-shrink: 0; }

/* Contenedor del buscador */
.search-container {
    flex-grow: 1;
    max-width: 400px;
}

#search-input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    background: var(--white);
}

#search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(9, 132, 227, 0.1);
}

/* Contenedor de Botones de Acción */
.actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Botones Generales */
button { 
    padding: 10px 20px; 
    border-radius: 8px; 
    border: 1px solid var(--border); 
    cursor: pointer; 
    font-weight: 600; 
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

button:active { transform: scale(0.98); }
button:hover { filter: brightness(0.9); }

.primary { background: var(--accent) !important; color: white; border: none; }
.secondary { background: white; color: var(--text); }

/* Estilo específico para botón Excel */
.excel-btn {
    background-color: var(--excel) !important;
    color: white;
    border: none;
}

.excel-btn:hover {
    background-color: #1e6b41 !important;
    filter: brightness(1.1);
}

/* Formulario Overlay */
.hidden { display: none !important; }

#form-container {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(4px); 
    display: flex; 
    align-items: center; 
    justify-content: center;
    z-index: 999;
}

.form-card { 
    background: white; 
    padding: 30px; 
    border-radius: 16px; 
    width: 90%; 
    max-width: 400px; 
    display: grid; 
    gap: 15px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.form-card input { 
    padding: 12px; 
    border: 2px solid var(--border); 
    border-radius: 8px; 
    font-size: 1rem;
    outline: none;
}

.form-card input:focus { border-color: var(--accent); }

.form-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

/* Tablas y Contenedores */
main { max-width: 900px; margin: 0 auto; }

details { 
    background: var(--white); 
    border-radius: 12px; 
    margin-bottom: 20px; 
    box-shadow: var(--shadow); 
    overflow: hidden;
    border: 1px solid var(--border);
}

summary { 
    padding: 18px; 
    font-weight: 700; 
    cursor: pointer; 
    background: #fdfdfd;
    list-style: none; 
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}

summary:hover { background: #f1f2f6; }

summary::after {
    content: '▾';
    color: var(--text-light);
    margin-left: 10px;
}

.table-container { 
    padding: 0 15px 15px; 
    overflow-x: auto; 
}

table { width: 100%; border-collapse: collapse; min-width: 500px; }

th { 
    text-align: left; 
    color: var(--text-light); 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    padding: 15px 10px; 
    letter-spacing: 1px;
}

td { 
    padding: 15px 10px; 
    border-top: 1px solid #f1f2f6; 
    font-size: 0.95rem;
}

tr:hover { background-color: #f9fbfc; }

.stock-input { 
    width: 70px; 
    padding: 6px; 
    border: 1px solid var(--border); 
    border-radius: 6px; 
    text-align: center; 
    font-weight: bold;
}

.delete-btn {
    color: var(--danger);
    background: #fff1f1;
    border: 1px solid #ffcccc;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    padding: 0;
}

.delete-btn:hover {
    background: var(--danger);
    color: white;
}

/* Totales */
.cat-total {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent); 
    background: rgba(9, 132, 227, 0.08); 
    padding: 5px 14px;
    border-radius: 6px; 
    border: 1px solid rgba(9, 132, 227, 0.2);
    margin-left: auto; 
}

td:nth-child(6) {
    font-weight: 700;
    color: var(--text);
}

.grand-total-card {
    background: var(--text);
    color: white;
    padding: 25px;
    border-radius: 16px;
    text-align: right;
    margin-top: 40px;
    margin-bottom: 50px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
    border-left: 5px solid var(--accent);
}

.grand-total-card h3 {
    font-size: 1.4rem;
}

.grand-total-card span {
    color: var(--accent);
    font-size: 1.6rem;
    display: block;
    margin-top: 5px;
}

/* Responsividad para móviles */
@media (max-width: 600px) {
    header { 
        flex-direction: column; 
        align-items: stretch;
    }
    .search-container { 
        max-width: 100%; 
        order: 3;
    }
    .actions {
        order: 2;
        width: 100%;
    }
    .actions button {
        flex: 1; /* Hace que ambos botones midan lo mismo en el móvil */
    }
}