* {
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    margin: 0;
    background: #f4f6f9;
    color: #222;
}

.login-body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #111827;
}

.login-container {
    width: 360px;
    background: #ffffff;
    padding: 35px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

.login-logo {
    width: 120px;
    margin-bottom: 15px;
}

.login-container h2 {
    margin: 5px 0;
}

.login-container p {
    color: #666;
    margin-bottom: 25px;
}

.login-container input {
    width: 100%;
    padding: 13px;
    margin-bottom: 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.login-container button {
    width: 100%;
    padding: 13px;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: #111827;
    color: white;
    padding: 25px 20px;
}

.sidebar-logo {
    width: 110px;
    display: block;
    margin: 0 auto 15px;
}

.sidebar h3 {
    text-align: center;
    margin-bottom: 30px;
}

.sidebar a {
    display: block;
    color: #e5e7eb;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.sidebar a:hover {
    background: #374151;
}

.content {
    flex: 1;
    padding: 35px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-top: 25px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.card h3 {
    margin-top: 0;
}

.sidebar {
    width: 250px;
    background: #071126;
    color: white;
    padding: 25px 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.content {
    margin-left: 250px;
    flex: 1;
    padding: 35px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 18px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
    transition: 0.2s;
}

.card:hover {
    transform: translateY(-3px);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.page-header h1 {
    margin-bottom: 5px;
}

.page-header p {
    margin-top: 0;
    color: #6b7280;
}

.btn-primary,
.btn-secondary,
.btn-small {
    display: inline-block;
    text-decoration: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
}

.btn-primary {
    background: #071126;
    color: #fff;
    padding: 12px 18px;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
    padding: 12px 18px;
}

.btn-small {
    background: #e5e7eb;
    color: #111827;
    padding: 7px 10px;
    font-size: 13px;
    margin-right: 5px;
}

.btn-small.danger {
    background: #fee2e2;
    color: #991b1b;
}

.table-card,
.form-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
}

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

.data-table th {
    text-align: left;
    background: #f3f4f6;
    color: #374151;
    padding: 14px;
    font-size: 14px;
}

.data-table td {
    padding: 14px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}

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

.empty-table {
    text-align: center;
    color: #6b7280;
    padding: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

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

.form-group.full {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 7px;
    color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 13px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    font-size: 15px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #071126;
}

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

.badge {
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

.badge.abierta {
    background: #dbeafe;
    color: #1e40af;
}

.badge.convertida {
    background: #dcfce7;
    color: #166534;
}

.badge.anulada {
    background: #fee2e2;
    color: #991b1b;
}

.btn-small.success {
    background: #dcfce7;
    color: #166534;
}

.item-row {
    display: grid;
    grid-template-columns: 1fr 120px 150px 50px;
    gap: 10px;
    margin-bottom: 12px;
}

.item-row select,
.item-row input {
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
}

.total-box {
    margin: 25px 0;
    padding: 18px;
    background: #f3f4f6;
    border-radius: 12px;
    text-align: right;
    font-size: 20px;
}

.total-box span {
    margin-left: 10px;
    font-weight: 800;
}

.cliente-select-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 999;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-card {
    background: #fff;
    width: 760px;
    max-width: 95%;
    border-radius: 18px;
    padding: 26px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-close {
    border: none;
    background: #fee2e2;
    color: #991b1b;
    font-size: 24px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
}

#cliente-modal {
    display: none !important;
}

#cliente-modal.show {
    display: flex !important;
}

.inline-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.badge.abierta {
    background: #dbeafe;
    color: #1e40af;
}

.badge.cerrada {
    background: #dcfce7;
    color: #166534;
}

.invoice-card {
    background: #fff;
    border-radius: 18px;
    padding: 35px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    gap: 30px;
}

.invoice-logo {
    width: 120px;
}

.invoice-info {
    text-align: right;
}

.invoice-client {
    margin: 25px 0;
}

.invoice-table {
    margin-top: 20px;
}

.invoice-total {
    text-align: right;
    margin-top: 25px;
}

@media print {
    .sidebar,
    .no-print {
        display: none !important;
    }

    .content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
    }

    .invoice-card {
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 20px !important;
    }
}

.invoice-summary-row {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    margin-bottom: 10px;
    font-size: 18px;
}

.invoice-summary-row span {
    min-width: 140px;
    text-align: right;
}

.total-final {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #d1d5db;
    font-size: 24px;
}

.dashboard-cards {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 28px;
}

.kpi-card h3 {
    color: #6b7280;
    font-size: 15px;
    margin-bottom: 12px;
}

.kpi-value {
    font-size: 30px;
    font-weight: 800;
    margin: 0;
    color: #071126;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 22px;
}

.chart-card {
    background: #fff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
}

.chart-card h3 {
    margin-top: 0;
    margin-bottom: 18px;
}

.chart-card canvas {
    max-height: 320px;
}

@media (max-width: 900px) {
    .dashboard-cards,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.kpi-danger {
    background: #991b1b;
    color: #fff;
    border: 2px solid #ef4444;
}

.kpi-danger h3,
.kpi-danger .kpi-value {
    color: #fff;
}

.kpi-warning {
    background: #f59e0b;
    color: #111827;
    border: 2px solid #d97706;
}

.kpi-critical {
    background: #991b1b;
    color: #fff;
    border: 2px solid #ef4444;
}

.kpi-warning h3,
.kpi-warning .kpi-value,
.kpi-warning small {
    color: #111827;
}

.kpi-critical h3,
.kpi-critical .kpi-value,
.kpi-critical small {
    color: #fff;
}

.kpi-card small {
    display: block;
    margin-top: 8px;
    font-weight: 600;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
}