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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
}

.main-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.nav-btn {
    padding: 10px 25px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.nav-btn.active {
    background: #3498db;
    color: white;
}

.nav-btn:hover {
    background: #2980b9;
    color: white;
}

/* Vista de pagos */
.payments-view {
    max-width: 900px;
    margin: 0 auto;
}

.payments-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.summary-card {
    flex: 1;
    min-width: 150px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.summary-label {
    display: block;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.summary-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #2c3e50;
}

.summary-value.green {
    color: #27ae60;
}

.summary-value.red {
    color: #e74c3c;
}

.payments-filter {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 20px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.payments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.payment-row {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 5px solid #e74c3c;
    flex-wrap: wrap;
}

.payment-row.paid {
    border-left-color: #27ae60;
}

.payment-info {
    flex: 1;
    min-width: 250px;
}

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

.payment-status {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}

.status-paid {
    background: #d5f5e3;
    color: #27ae60;
}

.status-unpaid {
    background: #fadbd8;
    color: #c0392b;
}

.payment-details pre {
    font-family: inherit;
    white-space: pre-wrap;
    color: #555;
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.payment-details small {
    color: #95a5a6;
}

.payment-amount {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2c3e50;
    white-space: nowrap;
}

.payment-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.btn-toggle {
    padding: 6px 12px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-edit {
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
}

.payment-row.unpaid .btn-toggle {
    background: #e67e22;
}

.btn-delete {
    padding: 6px 12px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
}

.hidden {
    display: none !important;
}

/* Consolidado */
.consolidado-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.consolidado-section h2 {
    color: #34495e;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.consolidado-controls {
    margin-bottom: 15px;
}

.consolidado-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.consolidado-resumen {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.consolidado-resumen .green {
    color: #27ae60;
    font-weight: bold;
}

.consolidado-resumen .red {
    color: #e74c3c;
    font-weight: bold;
}

.consolidado-orders {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 450px;
    overflow-y: auto;
}

.consolidado-row {
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    padding: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.consolidado-row.selected {
    border-color: #3498db;
    background: #ebf5fb;
}

.consolidado-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.consolidado-check input[type="checkbox"] {
    margin-top: 6px;
    width: 18px;
    height: 18px;
    accent-color: #3498db;
    cursor: pointer;
}

.consolidado-info {
    flex: 1;
}

.consolidado-info pre {
    font-family: inherit;
    white-space: pre-wrap;
    color: #555;
    font-size: 0.8rem;
    margin: 4px 0;
}

.consolidado-info small {
    color: #95a5a6;
}

.consolidado-result {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.consolidado-result h2 {
    color: #34495e;
    margin-bottom: 15px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

#consolidado-text {
    width: 100%;
    height: 400px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 15px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

section h2 {
    color: #34495e;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

/* Estilos del Menú */
.day-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.day-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 15px;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.day-btn.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.day-btn.today {
    font-weight: bold;
}

.day-title {
    color: #34495e;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px dashed #bdc3c7;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.menu-item {
    background: #ecf0f1;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.menu-item:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
}

.menu-item .price {
    font-weight: bold;
    color: #27ae60;
    margin-top: 5px;
}

.menu-item:hover .price {
    color: #2ecc71;
}

.menu-item .delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    display: none;
}

.menu-item:hover .delete-btn {
    display: block;
}

.add-dish-form {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ecf0f1;
}

.add-dish-form h3 {
    margin-bottom: 10px;
    color: #7f8c8d;
}

.add-dish-form input[type="text"],
.add-dish-form textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    font-size: 1rem;
}

.add-dish-form textarea {
    resize: vertical;
    min-height: 90px;
}

.dish-replace-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Gestión de agregados */
.agregados-config {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
}

.agregados-config h3 {
    margin-bottom: 10px;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.agregados-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.agregado-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #ecf0f1;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
}

.agregado-remove {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
}

.agregados-add {
    display: flex;
    gap: 8px;
}

.agregados-add input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* Autocomplete dropdown */
.customer-add {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-dropdown.hidden {
    display: none;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.autocomplete-item:hover {
    background: #f0f0f0;
}

.text-muted {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-whatsapp {
    background: #25d366;
    color: white;
}

.btn-whatsapp:hover {
    background: #1ebe5b;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

/* Gestión de clientes */
.customer-add {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.customer-add input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.customer-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.customer-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ecf0f1;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.customer-tab.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
}

.customer-tab-info {
    display: flex;
    flex-direction: column;
}

.customer-tab-info small {
    opacity: 0.8;
    font-size: 0.75rem;
}

.customer-remove-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
}

.active-customer-label {
    font-weight: bold;
    color: #34495e;
    margin-bottom: 10px;
    padding: 10px;
    background: #ebf5fb;
    border-radius: 5px;
    border-left: 4px solid #3498db;
}

.empty-hint {
    text-align: center;
    color: #95a5a6;
    padding: 30px;
}

/* Estilos del Pedido */
.order-items {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 5px;
}

.order-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quantity-controls button {
    width: 25px;
    height: 25px;
    padding: 0;
    font-size: 1rem;
}

.quantity-controls span {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
}

.order-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 15px;
    background: #ecf0f1;
    border-radius: 5px;
    margin-bottom: 20px;
}

.order-actions {
    display: flex;
    gap: 10px;
}

.order-actions button {
    flex: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.modal-content textarea {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: monospace;
    font-size: 1rem;
    resize: none;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions button {
    flex: 1;
}

/* Modal de selección de jugo */
.juice-modal-content {
    max-width: 400px;
    text-align: center;
}

.juice-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.modal-section-label {
    text-align: left;
    font-weight: bold;
    color: #7f8c8d;
    margin-bottom: 8px;
    margin-top: 5px;
}

.base-options {
    flex-direction: row;
}

.base-options .juice-option {
    flex: 1;
    justify-content: center;
}

.juice-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.juice-option:hover {
    border-color: #3498db;
    background: #ebf5fb;
}

.juice-option.selected {
    border-color: #3498db;
    background: #ebf5fb;
    box-shadow: 0 0 0 2px #3498db inset;
}

.option-price {
    font-weight: bold;
    color: #27ae60;
}

/* Notificación */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #27ae60;
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Limpiar pedidos por día */
.day-cleaner {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 12px;
    margin-bottom: 15px;
    background: #fdf3f3;
    border: 1px solid #f5c6c6;
    border-radius: 5px;
    flex-wrap: wrap;
}

.clean-by-day,
.clean-by-fecha {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.day-cleaner label {
    font-weight: 600;
    color: #c0392b;
}

.day-cleaner select,
.day-cleaner input[type="date"] {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.day-cleaner .text-muted {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

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

/* Búsqueda de pedidos */
.payments-search {
    margin-bottom: 15px;
}

.payments-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    box-sizing: border-box;
}

.payments-search input:focus {
    outline: none;
    border-color: #3498db;
}

/* Encabezado de grupo por día */
.payment-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2c3e50;
    color: white;
    padding: 8px 14px;
    border-radius: 5px;
    margin: 12px 0 6px;
}

.payment-day-stats {
    font-size: 0.85rem;
}

.payment-day-stats .green {
    color: #2ecc71;
}

.payment-day-stats .red {
    color: #e74c3c;
}

/* Filtros del consolidado */
.consolidado-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #ecf0f1;
    border-radius: 5px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.consolidado-filter label {
    font-weight: 600;
    color: #2c3e50;
}

.consolidado-filter select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* ---------- Reportes ---------- */
.report-day-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    flex-wrap: wrap;
}

.report-day-selector label {
    font-weight: 600;
}

.report-day-selector select,
.report-day-selector input {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.report-content {
    padding: 10px 0;
}

.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.report-card {
    background: #2c3e50;
    color: white;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.report-card.green-bg {
    background: #27ae60;
}

.report-card.red-bg {
    background: #e74c3c;
}

.report-card-value {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.report-card-label {
    font-size: 0.8rem;
    opacity: 0.9;
}

.report-subtitle {
    margin: 15px 0 8px;
    color: #2c3e50;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

.report-table th {
    background: #3498db;
    color: white;
    padding: 8px 10px;
    text-align: left;
    font-size: 0.85rem;
}

.report-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.report-table tr:nth-child(even) td {
    background: #f9f9f9;
}

.stats-col {
    margin-bottom: 15px;
}

/* Historial por cliente */
.customer-history-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.customer-history-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 6px;
}

.customer-history-head strong {
    color: #2c3e50;
    font-size: 1rem;
}

.customer-history-orders {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.customer-history-order {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #555;
    padding: 2px 6px;
    background: #f5f7fa;
    border-radius: 4px;
}

.customer-history-order .text-muted {
    font-size: 0.8rem;
}

/* ---------- Deudores por día ---------- */
.deudores-view {
    margin-bottom: 20px;
}

.deudores-view h3 {
    color: #c0392b;
    margin-bottom: 12px;
}

.deudores-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deudor-day {
    background: #c0392b !important;
}

.deudores-actions {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.deudor-card.deudor-selected {
    border-color: #27ae60;
    background: #f0faf0;
}

.deudor-select {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.deudor-select input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #27ae60;
}

.comprobante-thumb {
    display: block;
    max-width: 120px;
    max-height: 90px;
    border-radius: 6px;
    border: 1px solid #ddd;
    margin-bottom: 6px;
    cursor: zoom-in;
    object-fit: cover;
}

.payment-pagado-por {
    font-size: 0.85rem;
    color: #2e7d32;
    margin-top: 2px;
}

.image-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    text-align: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 6px;
}

.reporte-pendientes-box {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
}

.reporte-pendientes-box textarea {
    width: 100%;
    height: 220px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.deudor-card {
    background: white;
    border: 1px solid #f5c6c6;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.deudor-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.deudor-card-head strong {
    color: #2c3e50;
    font-size: 1rem;
}

.deudor-amount {
    font-weight: 700;
    color: #e74c3c;
}

.deudor-orders {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 10px;
}

.deudor-order {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #555;
    padding: 3px 8px;
    background: #fdf3f3;
    border-radius: 4px;
}

.btn-cobrar {
    width: 100%;
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}

.btn-cobrar:hover {
    background: #219a52;
}


/* ===== Mejoras de UX / móvil ===== */

/* Foco visible para teclado */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #f39c12;
    outline-offset: 2px;
}

/* Diálogo genérico (reemplaza confirm/prompt) */
.dialog-content {
    max-width: 420px;
}
.dialog-message {
    font-size: 1.05rem;
    line-height: 1.45;
    color: #2c3e50;
    margin-bottom: 16px;
}
.dialog-content input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    margin-bottom: 16px;
}
.dialog-content input.hidden {
    display: none;
}

/* Avisos accesibles y sin tapar el contenido */
.notification {
    max-width: min(90vw, 420px);
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    header {
        margin-bottom: 16px;
    }
    header h1 {
        font-size: 1.6rem;
    }

    /* Navegación fija arriba, con scroll horizontal si no cabe */
    .main-nav {
        position: sticky;
        top: 0;
        z-index: 50;
        justify-content: flex-start;
        overflow-x: auto;
        gap: 8px;
        padding: 8px 4px;
        margin: 10px -12px 0;
        padding-left: 12px;
        padding-right: 12px;
        background: #f5f5f5;
        scrollbar-width: none;
    }
    .main-nav::-webkit-scrollbar {
        display: none;
    }
    .nav-btn {
        flex: 0 0 auto;
        padding: 10px 16px;
        min-height: 44px;
        white-space: nowrap;
    }

    section {
        padding: 14px;
    }

    /* Objetivos táctiles de al menos 44px */
    button,
    select,
    .day-btn {
        min-height: 44px;
    }
    .quantity-controls button {
        min-width: 44px;
        min-height: 44px;
    }
    .agregado-remove {
        min-width: 36px;
        min-height: 36px;
    }

    /* 16px evita el zoom automático de iOS al enfocar un campo */
    input[type="text"],
    input[type="date"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px;
    }

    .customer-add,
    .add-dish-form,
    .agregados-add {
        flex-wrap: wrap;
    }
    .customer-add input,
    .add-dish-form input,
    .agregados-add input {
        flex: 1 1 100%;
        min-width: 0;
    }

    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: none;
    }

    .order-item {
        flex-wrap: wrap;
        gap: 8px;
    }
    .order-item-info {
        flex: 1 1 100%;
    }

    /* Resumen de pagos en una fila compacta */
    .payments-summary {
        gap: 8px;
    }
    .payments-summary .summary-card {
        flex: 1 1 30%;
        min-width: 0;
        padding: 10px;
    }

    .payments-filter {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Filas de pedidos: acciones en rejilla bajo el detalle */
    .payment-row {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }
    .payment-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .payment-actions button {
        flex: 1 1 calc(50% - 5px);
        padding: 10px 8px;
    }

    .day-cleaner,
    .clean-by-day,
    .clean-by-fecha,
    .consolidado-actions,
    .deudores-actions,
    .report-day-selector {
        flex-wrap: wrap;
        gap: 8px;
    }
    .consolidado-actions button,
    .deudores-actions button {
        flex: 1 1 100%;
    }

    /* Los modales se anclan abajo como hoja, más fáciles con el pulgar */
    .modal {
        align-items: flex-end;
    }
    .modal-content {
        width: 100%;
        max-width: none;
        max-height: 92vh;
        overflow-y: auto;
        border-radius: 14px 14px 0 0;
        padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    }
    .modal-actions {
        flex-wrap: wrap;
    }

    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .payment-day-header {
        flex-wrap: wrap;
        gap: 4px 12px;
    }
    .payment-day-stats {
        font-size: 0.85rem;
    }
    /* Los 4 botones de navegación caben sin recortar */
    .main-nav {
        gap: 6px;
    }
    .nav-btn {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .main-nav {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        overflow-x: visible;
        gap: 4px;
    }
    .nav-btn {
        padding: 8px 2px;
        font-size: 0.78rem;
        border-radius: 14px;
        min-width: 0;
    }
}


/* ===== Estados de pedido ===== */
.estado-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.estado-recibido { background: #fdebd0; color: #a04000; }
.estado-preparando { background: #d6eaf8; color: #1b4f72; }
.estado-entregado { background: #d5f5e3; color: #1e8449; }

.btn-estado {
    background: #8e44ad;
    color: white;
}
.btn-estado:hover { background: #7d3c98; }

.estado-filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ===== Reporte por fechas ===== */
.range-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.table-scroll {
    overflow-x: auto;
    margin-bottom: 12px;
}
.report-content .btn-primary {
    margin: 4px 0 16px;
}

/* ===== Impresión de comandas ===== */
#print-area {
    display: none;
}
@media print {
    body > *:not(#print-area) {
        display: none !important;
    }
    #print-area {
        display: block;
        padding: 8mm;
        color: #000;
        background: #fff;
    }
    #print-area h2 {
        font-size: 1.3rem;
        margin-bottom: 6mm;
    }
    #print-area pre {
        font-family: 'Courier New', monospace;
        font-size: 1rem;
        line-height: 1.4;
        white-space: pre-wrap;
    }
}


/* ===== Acceso del personal ===== */
/* Mientras se comprueba la sesión no se muestra la app (evita ver pantallas vacías) */
body.auth-pending .container {
    visibility: hidden;
}

.login-view {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #f5f5f5;
}
.login-view.hidden {
    display: none;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 12px;
    padding: 28px 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.login-card h1 {
    font-size: 1.6rem;
    color: #2c3e50;
    text-align: center;
}
.login-sub {
    text-align: center;
    color: #7f8c8d;
    margin-bottom: 8px;
}
.login-card label {
    font-weight: 600;
    color: #34495e;
    font-size: 0.9rem;
}
.login-card input {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
    margin-bottom: 4px;
}
.login-error {
    min-height: 1.3em;
    color: #c0392b;
    font-size: 0.9rem;
}
.login-card button[type="submit"] {
    min-height: 46px;
}
.login-client-link {
    margin-top: 6px;
    text-align: center;
    color: #3498db;
    font-size: 0.9rem;
}

.user-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 6px;
    color: #7f8c8d;
    font-size: 0.9rem;
}
.user-bar.hidden {
    display: none;
}
.user-bar .btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Cuenta */
.account-content {
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}
.acc-block {
    border-top: 1px solid #ecf0f1;
    padding: 14px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.acc-block h4 {
    color: #34495e;
}
.acc-block input,
.acc-block select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
    width: 100%;
}
.acc-row {
    display: flex;
    gap: 8px;
}
.acc-row input {
    flex: 1;
    min-width: 0;
}
.users-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 6px;
}
.user-rol {
    color: #7f8c8d;
    margin-left: 4px;
}
.new-user-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Pedidos hechos por clientes desde la página pública */
.origen-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #e8daef;
    color: #6c3483;
    white-space: nowrap;
}
.payment-extra {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin: 2px 0;
}

/* Platos ya guardados en Pagos (no se vuelven a guardar) */
.item-guardado {
    color: #1e8449;
    background: #d5f5e3;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}


/* ===== Pagos: período y paginación ===== */
.period-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}
.period-label {
    font-weight: 600;
    color: #34495e;
}
.periodo-btn {
    padding: 8px 14px;
    border: 1px solid #ccd1d1;
    border-radius: 18px;
    background: #fff;
    color: #34495e;
    font-size: 0.9rem;
}
.periodo-btn.active {
    background: #3498db;
    border-color: #3498db;
    color: #fff;
}
.pagos-rango {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.pagos-rango.hidden {
    display: none;
}
.pagos-rango input[type="date"] {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
}
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}
.pager.hidden {
    display: none;
}
.pager-info {
    color: #7f8c8d;
    font-size: 0.9rem;
    text-align: center;
    flex: 1 1 180px;
}
.pager button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ===== Cierre del día ===== */
.cierre-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.cierre-toolbar input[type="date"] {
    padding: 9px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
}
.cierre-toolbar .btn-secondary {
    min-width: 44px;
}
.cierre-spacer {
    flex: 1 1 0;
}
.cierre-titulo {
    color: #2c3e50;
    margin-bottom: 12px;
}
.cierre-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.cierre-alerta {
    background: #fdebd0;
    color: #a04000;
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 600;
    margin: 8px 0;
}
.cierre-extras {
    color: #34495e;
    margin: 6px 0 12px;
}
.cierre-deuda {
    margin-top: 16px;
    padding: 12px;
    border: 1px dashed #c0392b;
    border-radius: 8px;
    color: #7b241c;
    background: #fdf2f0;
}

@media (max-width: 768px) {
    /* Con 5 botones, la navegación pasa a 2 filas (3 + 2) para que sigan siendo fáciles de tocar */
    .main-nav {
        grid-template-columns: repeat(3, 1fr);
    }
    .nav-btn {
        font-size: 0.85rem;
        padding: 10px 4px;
    }
    .pager {
        justify-content: center;
    }
    .pager-info {
        order: -1;
        flex-basis: 100%;
    }
    .pager button {
        flex: 1 1 45%;
    }
    .cierre-toolbar input[type="date"] {
        flex: 1 1 140px;
        font-size: 16px;
    }
    .cierre-toolbar #cierre-copiar,
    .cierre-toolbar #cierre-imprimir {
        flex: 1 1 45%;
    }
    .cierre-spacer {
        display: none;
    }
    .pagos-rango {
        width: 100%;
    }
}
