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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.login-container h1 {
    color: #667eea;
    margin-bottom: 30px;
    text-align: center;
}

h1 {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

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

.user-info {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8em;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

select,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

select:focus,
input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-warning {
    background: #ed8936;
    color: white;
}

.btn-info {
    background: #4299e1;
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

select:disabled,
input:disabled {
    background: #e2e8f0;
    cursor: not-allowed;
}

.pedido-item {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid #667eea;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #667eea;
    color: white;
    font-weight: bold;
}

.total-row {
    background: #fef3c7 !important;
    font-weight: bold;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.stat-number {
    font-size: 2em;
    font-weight: bold;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #a0aec0;
}

.pedido-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
    border-left: 5px solid #667eea;
}

.pedido-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.pedido-cliente {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

.pedido-item-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 100px;
    gap: 10px;
    align-items: end;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.filtros-historico {
    background: #f7fafc;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.filtros-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 15px;
    align-items: end;
}

.badge-archivado {
    background: #fed7d7;
    color: #c53030;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9em;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.35);
}

.tab {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.85);
    border-radius: 8px 8px 0 0;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.18);
}

.tab.active {
    color: #ffffff;
    border-bottom-color: #ffffff;
    background: rgba(255, 255, 255, 0.22);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Clase utilitaria para tablas en móvil */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 15px;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    /* Header apilado */
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .user-info {
        justify-content: center;
        width: 100%;
        padding: 10px;
    }

    .user-info .btn {
        flex: 1;
        margin: 5px;
        font-size: 0.9em;
        padding: 10px;
        min-width: 80px;
    }

    /* Grillas a una sola columna */
    .main-grid,
    .stats-grid,
    .form-row,
    .filtros-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Ajustes de tarjetas y login */
    .card {
        padding: 15px;
    }

    .login-container {
        margin: 30px auto;
        width: 100%;
        padding: 20px;
    }

    /* Inputs y botones más grandes para el dedo */
    input,
    select,
    .btn {
        padding: 12px;
        font-size: 16px;
    }

    .form-row>div {
        margin-bottom: 5px;
    }

    /* Tablas con scroll horizontal */
    table {
        min-width: 500px;
    }

    /* Fuerza el ancho para activar scroll si es necesario */

    /* Ajuste de items de pedido */
    .pedido-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .pedido-header>div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .pedido-item-row {
        font-size: 0.95em;
    }

    /* Modales */
    .modal-content {
        width: 95%;
        margin: 15% auto;
        padding: 20px;
        max-height: 90vh;
    }

    /* Pestañas */
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
    }

    .tab {
        padding: 10px 15px;
        font-size: 14px;
    }
}

/* Clases extraídas de inline styles */
.text-center-mb-15 {
    text-align: center;
    margin-bottom: 15px;
}

.logo-img {
    width: 150px;
    height: auto;
    max-width: 100%;
    background: white;
    border-radius: 50%;
    /* Circle badge */
    padding: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.w-100 {
    width: 100%;
}

.modal-content-sm {
    max-width: 500px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.logo-img-sm {
    width: 60px;
    /* Slightly larger for better touch target */
    height: 60px;
    border-radius: 12px;
    object-fit: contain;
    /* Ensure potato fits */
    background: white;
    /* Ensure consistent background if png has transparency */
    padding: 5px;
    /* Spacing for the icon inside the box */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.mb-0 {
    margin-bottom: 0;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.crear-usuario-box {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.mw-220 {
    max-width: 220px;
}

.mw-260 {
    max-width: 260px;
}

.mw-160 {
    max-width: 160px;
}

.graph-box {
    background: #f7fafc;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.text-primary-mb-20 {
    color: #667eea;
    margin-bottom: 20px;
}

.text-primary-mt-30-mb-15 {
    color: #667eea;
    margin-top: 30px;
    margin-bottom: 15px;
}

.resumen-total-items {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.resumen-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.3em;
    color: #48bb78;
}

.mt-20-w-100 {
    width: 100%;
    margin-top: 20px;
}

.bg-light-p-15 {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
}

.section-title {
    color: #667eea;
    margin-bottom: 15px;
}

.resumen-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #667eea;
}

.items-title {
    margin-top: 20px;
    color: #667eea;
}

.mensaje-estado-cerrado {
    background: #fed7d7;
    border: 2px solid #fc8181;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.mensaje-estado-cerrado h3 {
    color: #c53030;
}

.graph-title-sm {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.graph-bar-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Footer Styles */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9em;
    z-index: 1000;
}

.app-footer p {
    margin: 0;
}

/* Edit Modal Styles */
.edit-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #edf2f7;
    background: #f8fafc;
    border-radius: 5px;
    margin-bottom: 5px;
}

.edit-item-details {
    flex-grow: 1;
}

.edit-item-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-icon {
    padding: 5px 10px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    color: white;
}

.btn-delete {
    background: #e53e3e;
}

.btn-edit {
    background: #3182ce;
}

.brand-name {
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Divider styles */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 2px solid #e2e8f0;
}

.divider span {
    padding: 0 10px;
    color: #a0aec0;
    font-weight: bold;
    font-size: 0.9em;
}

/* Usuarios grid */
.usuarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.user-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.user-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: #2d3748;
}

.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
}

.role-admin {
    background: #f56565;
    color: white;
}

.role-cliente {
    background: #48bb78;
    color: white;
}

.user-body {
    margin-bottom: 15px;
}

.user-body p {
    margin: 8px 0;
    font-size: 0.9em;
    color: #4a5568;
}

.user-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

.text-muted {
    color: #a0aec0;
    font-size: 0.85em;
    font-style: italic;
}