/* KPI Grid - Horizontal layout */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    padding: 2rem 3rem;
    background: #f8f9fa;
}

.kpi-card {
    background: white;
    padding: 1.75rem 2rem;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.kpi-card h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: #1a2332;
    line-height: 1.2;
}

.kpi-value.positive {
    color: #28a745;
}

.kpi-value.warning {
    color: #ffc107;
}

.kpi-value.danger {
    color: #dc3545;
}

/* Filters - Modern minimal design */
.filters-section {
    background: white;
    padding: 1.5rem 3rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 180px;
}

.filter-group label {
    font-size: 0.8125rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: white;
    color: #1a2332;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #00d9ff;
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
}

/* Table - Clean and spacious */
.table-section {
    background: white;
    padding: 0;
    margin: 2rem 3rem;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1.25rem 1.5rem;
    text-align: left;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #1a2332;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e9ecef;
}

.data-table tbody td {
    border-bottom: 1px solid #f8f9fa;
    color: #495057;
    font-size: 0.9375rem;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

.text-center {
    text-align: center !important;
}

/* Status Badges - Modern design */
.status-badge {
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.status-draft {
    background: #e3f2fd;
    color: #1976d2;
}

.status-confirmed {
    background: #e8f5e9;
    color: #388e3c;
}

.status-partially_invoiced {
    background: #fff3e0;
    color: #f57c00;
}

.status-invoiced {
    background: #e1bee7;
    color: #7b1fa2;
}

.status-cancelled {
    background: #ffebee;
    color: #c62828;
}

/* Pagination - Clean design */
.pagination-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem 3rem;
}

.pagination-section span {
    color: #6c757d;
    font-weight: 500;
    font-size: 0.9375rem;
}

/* Modal - Modern design with backdrop blur
 * IMPORTANTE: estas reglas neutralizan los estilos de base-mobile-first.css
 * que esperan el patron .modal-overlay > .modal con toggle de .active.
 * Aqui .modal es el overlay + se toglea con style.display = 'flex'/'none'.
 */
.modal {
    display: none;
    position: fixed;
    z-index: 1100;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(26, 35, 50, 0.7);
    backdrop-filter: blur(8px);
    justify-content: center;
    align-items: flex-start;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
    flex-direction: row;
    border-radius: 0;
    max-height: none;
}

.modal-content {
    background-color: white;
    margin: 3% auto;
    padding: 0;
    border-radius: 20px;
    width: 90%;
    max-width: 650px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    /* Reset base-mobile-first.css overrides */
    opacity: 1;
    transform: none;
    transition: none;
}

.modal-large {
    max-width: 1100px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 2.5rem;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a2332;
}

.close {
    font-size: 1.75rem;
    font-weight: 300;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.close:hover {
    background: #f8f9fa;
    color: #1a2332;
}

.modal-body {
    padding: 2rem 2.5rem;
}

/* Form sections */
.form-section {
    padding: 2rem 2.5rem;
    border-bottom: 1px solid #f8f9fa;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h4 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #1a2332;
    font-size: 1.125rem;
    font-weight: 600;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    background: white;
    color: #1a2332;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #00d9ff;
    box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.items-table th,
.items-table td {
    padding: 8px;
    text-align: left;
    border: 1px solid #ddd;
}

.items-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 13px;
}

.items-table input,
.items-table select {
    width: 100%;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-icon:hover {
    opacity: 0.7;
}

.totals-container {
    max-width: 400px;
    margin-left: auto;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.totals-row.total {
    border-top: 2px solid #333;
    margin-top: 8px;
    padding-top: 12px;
    font-weight: 600;
    font-size: 16px;
}

/* Form Actions */
.form-actions {
    padding: 1.5rem 2.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    border-top: 1px solid #f8f9fa;
    background: #fafbfc;
    border-radius: 0 0 20px 20px;
}

/* Action Buttons */
.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    border-radius: 8px;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

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

.btn-danger:hover {
    background: #c82333;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3);
}

.btn-light {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #e9ecef;
}

.btn-light:hover {
    background: #e9ecef;
}

/* Additional utilities */
.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Totals Container */
.totals-container {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 400px;
    margin-left: auto;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 0.625rem 0;
    font-size: 0.9375rem;
    color: #495057;
}

.totals-row.total {
    border-top: 2px solid #1a2332;
    margin-top: 0.75rem;
    padding-top: 1rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: #1a2332;
}

/* Alerts */
.alerts-section {
    padding: 1.5rem 3rem;
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border-left: 4px solid;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border-color: #ffc107;
    color: #856404;
}

/* Tab content */
.tab-content {
    display: none;
}

.tab-content:first-of-type {
    display: block;
}

/* Progress Bars */
.progress-bar {
    width: 100%;
    height: 24px;
    background-color: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #00d9ff;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Action Buttons */
.btn-action {
    padding: 0.375rem 0.75rem;
    margin: 0 0.25rem;
    border: none;
    border-radius: 6px;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-action.btn-info {
    background: #17a2b8;
}

.btn-action.btn-primary {
    background: #00d9ff;
}

.btn-action.btn-success {
    background: #28a745;
}

.btn-action.btn-danger {
    background: #dc3545;
}

/* Badges */
.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-block;
}

.badge-primary {
    background: #00d9ff;
    color: white;
}

.badge-success {
    background: #28a745;
    color: white;
}

.badge-info {
    background: #17a2b8;
    color: white;
}

.badge-warning {
    background: #ffc107;
    color: #1a2332;
}

.badge-danger {
    background: #dc3545;
    color: white;
}

.badge-secondary {
    background: #6c757d;
    color: white;
}

/* Reset modal overrides from base-mobile-first.css in all breakpoints */
@media (min-width: 640px) {
    .modal {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
        align-items: flex-start;
        padding: 0;
        border-radius: 0;
        flex-direction: row;
        width: 100%;
        max-height: none;
    }
    .modal-content {
        opacity: 1;
        transform: none;
        transition: none;
        width: 90%;
    }
}

/* Modal Large */
.modal-large {
    max-width: 900px;
}

/* Form Sections */
.form-section h4 {
    margin-bottom: 1rem;
    color: #1a2332;
    font-size: 1.125rem;
    border-bottom: 2px solid #00d9ff;
    padding-bottom: 0.5rem;
}

/* Sales Menu Cards */
.sales-menu-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.sales-menu-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 217, 255, 0.15);
    border-color: #00d9ff;
    background: white;
}

.sales-menu-card:active {
    transform: translateY(-2px);
}

