/* Cobros - Listado por Zona */
:root {
    --primary: #D4A574;
    --primary-dark: #B8824F;
    --text: #333;
    --text-light: #666;
    --white: #fff;
    --bg: #f5f5f5;
    --border: #ddd;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Sora', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

.cobros-container { max-width: min(1600px, 96vw); margin: 0 auto; padding: 0 16px 40px; width: 100%; }

/* Header */
.cobros-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 20px 0;
    margin: 0 -16px 24px;
    padding-left: 16px;
    padding-right: 16px;
}
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    max-width: min(1600px, 96vw);
    margin: 0 auto;
    width: 100%;
}
.cobros-header h1 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.header-actions .btn.btn-secondary {
    background: rgba(255,255,255,0.95);
    color: var(--primary-dark);
    border: 2px solid rgba(255,255,255,0.9);
}
.header-actions .btn.btn-secondary:hover {
    background: var(--white);
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: transform 0.2s, background 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-pdf { background: #c62828; color: var(--white); }
.btn-pdf:hover { background: #b71c1c; }
.btn-back { background: rgba(255,255,255,0.2); color: var(--white); }
.btn-back:hover { background: rgba(255,255,255,0.3); }

/* Filters */
.filters-section {
    background: var(--white);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.filters-section h2 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    align-items: end;
}
.filter-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}
.filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}
.filter-group input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.filter-group input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}
.filter-group.filter-actions {
    display: flex;
    align-items: flex-end;
}
.btn-borrar-filtros {
    width: 100%;
    min-height: 42px;
    padding: 10px 14px;
    border: 2px solid var(--border);
    background: #fafafa;
    color: var(--text);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-borrar-filtros:hover { background: #eee; border-color: #bbb; }
.filter-group input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
}
.filter-info {
    display: flex;
    align-items: center;
    padding: 10px 0;
}
.filter-info span {
    font-size: 14px;
    color: var(--text-light);
}

/* Table */
.table-section {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.table-wrap { overflow-x: auto; }
.cobros-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1180px;
}
.cobros-table th.cobros-th-num,
.cobros-table td.cobros-td-num {
    text-align: right;
    white-space: nowrap;
}
.cobros-table th,
.cobros-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
.cobros-table th {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
    white-space: nowrap;
}
.cobros-table th i { margin-right: 6px; }
.cobros-table tbody tr:hover { background: #fafafa; }
.cobros-table td:nth-child(9) {
    max-width: 220px;
    white-space: normal;
    line-height: 1.35;
}
.cobros-periodos-hint {
    font-size: 10px;
    color: #757575;
    font-weight: 500;
    margin-top: 3px;
    line-height: 1.3;
    max-width: 140px;
}
.cobros-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.cobros-btn {
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.cobros-btn-pago { background: #2e7d32; color: #fff; }
.cobros-btn-pago:hover { background: #1b5e20; }
.cobros-btn-atraso { background: #1565c0; color: #fff; }
.cobros-btn-atraso:hover { background: #0d47a1; }
.cobros-btn-quitar { background: #6d4c41; color: #fff; }
.cobros-btn-quitar:hover { background: #4e342e; }

/* Modal atraso */
.cobros-modal[hidden] {
    display: none !important;
}
.cobros-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cobros-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
}
.cobros-modal-box {
    position: relative;
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 92%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.cobros-modal-box--wide { max-width: 480px; }
.cobros-modal--pago { z-index: 10001; }
.cobros-modal-cliente { font-weight: 600; margin: 0 0 8px; font-size: 14px; }
.cobros-modal-fields { margin-top: 12px; }
.cobros-modal-micro { font-size: 12px; color: var(--text-light); margin: 6px 0 0; }
.cobros-modal-box select,
.cobros-modal-box input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
}
.cobros-modal-box select { cursor: pointer; }
.cobros-modal-box h3 { margin: 0 0 12px; font-size: 1.1rem; }
.cobros-modal-hint { font-size: 13px; color: var(--text-light); margin: 0 0 16px; line-height: 1.45; }
.cobros-modal-box label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.cobros-modal-box input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    box-sizing: border-box;
}
.cobros-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.btn-primary { background: var(--primary); color: var(--white); border: none; padding: 10px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn-secondary { background: #eee; color: #333; border: none; padding: 10px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; }

/* Loading & Empty */
.loading, .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}
.loading i { font-size: 32px; color: var(--primary); margin-bottom: 10px; display: block; }
.empty-state i {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 12px;
    display: block;
}
.hidden { display: none !important; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 9999;
    display: none;
}
.toast.show { display: block; animation: fadeIn 0.3s; }
.toast.success { background: #2e7d32; color: var(--white); }
.toast.error { background: #c62828; color: var(--white); }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== Cobros responsive ========== */

.cobros-page {
    overflow-x: hidden;
}

.cobros-page .cobros-container {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
}

.cobros-header-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.cobros-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.cobros-header-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.cobros-nav-menu {
    position: relative;
}

.cobros-nav-menu > summary {
    list-style: none;
    cursor: pointer;
}

.cobros-nav-menu > summary::-webkit-details-marker {
    display: none;
}

.cobros-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
}

.cobros-nav-toggle:hover {
    background: rgba(255, 255, 255, 0.28);
}

.cobros-nav-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 300;
    min-width: 220px;
    padding: 8px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    border: 1px solid #e8e8e8;
}

.cobros-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
}

.cobros-nav-link:hover {
    background: #f5f0eb;
    color: #4e342e;
}

.cobros-nav-link i {
    width: 18px;
    color: #8d6e63;
    text-align: center;
}

.cobros-btn-toolbar-clear {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.cobros-page .filters-section,
.cobros-page .table-section,
.cobros-page .loading,
.cobros-page .empty-state {
    padding-left: 0;
    padding-right: 0;
}

.cobros-page .table-wrap {
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
}

.cobros-page .filter-group select,
.cobros-page .filter-group input[type="date"],
.cobros-page .btn-borrar-filtros {
    min-height: 44px;
}

.cobros-page .cobros-btn {
    min-height: 36px;
}

@media (min-width: 900px) {
    .cobros-header-content {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
    }

    .cobros-header-top {
        width: auto;
        flex: 0 1 auto;
    }

    .cobros-header-toolbar {
        width: auto;
        flex: 1 1 auto;
        justify-content: flex-end;
    }

    .cobros-btn-toolbar-clear {
        display: none;
    }
}

@media (max-width: 768px) {
    .cobros-page .cobros-container {
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    .cobros-header {
        margin-bottom: 16px;
    }

    .cobros-header-toolbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 250;
        margin: 0;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid #e0dcd8;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
        justify-content: center;
        width: 100%;
    }

    .cobros-header-toolbar .btn {
        min-height: 44px;
        padding: 10px 14px;
        font-size: 13px;
    }

    .cobros-header-toolbar .btn-pdf {
        flex: 1 1 auto;
        max-width: 160px;
        justify-content: center;
    }

    .cobros-header-toolbar .cobros-btn-toolbar-clear {
        flex: 1 1 auto;
        max-width: 160px;
        justify-content: center;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .cobros-link-desktop {
        display: none !important;
    }

    .cobros-btn-label {
        display: none;
    }

    .cobros-filter-actions-desktop {
        display: none;
    }

    .cobros-header-top h1 {
        font-size: 1.2rem;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filters-section {
        padding: 16px;
    }

    .cobros-table th,
    .cobros-table td {
        padding: 8px 10px;
        font-size: 12px;
    }

    .cobros-table {
        min-width: 980px;
    }

    .cobros-modal-box {
        width: calc(100% - 16px);
        max-height: 92vh;
        overflow-y: auto;
        margin: 8px;
    }

    .cobros-modal-actions {
        flex-wrap: wrap;
    }

    .cobros-modal-actions .btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .toast {
        left: 12px;
        right: 12px;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 480px) {
    .cobros-header-top h1 {
        font-size: 1.05rem;
    }

    .cobros-acciones {
        flex-direction: column;
        align-items: stretch;
    }

    .cobros-btn {
        width: 100%;
        text-align: center;
    }
}

.incompletos-section {
    margin-top: 28px;
    padding: 20px;
    background: #fff8f0;
    border: 1px solid #ffe0b2;
    border-radius: 12px;
}
.incompletos-header h2 {
    margin: 0 0 8px;
    font-size: 18px;
    color: #e65100;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.incompletos-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fff3e0;
    color: #bf360c;
    text-transform: uppercase;
}
.incompletos-hint {
    font-size: 13px;
    color: #666;
    margin: 0 0 14px;
    line-height: 1.5;
}
.incompletos-hint a { color: #1a237e; font-weight: 600; }
.incompletos-filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}
.incompletos-filtros label { font-weight: 600; font-size: 13px; }
.incompletos-filtros select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
}
.incompletos-resumen { font-size: 13px; color: #666; }
.incompletos-zona-block {
    margin-bottom: 18px;
    padding: 14px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #ffcc80;
}
.incompletos-zona-block h3 {
    margin: 0 0 10px;
    font-size: 15px;
    color: #ef6c00;
}
.cobros-table-incompletos { font-size: 13px; }
.cobros-table-incompletos th { background: #fff3e0; }
