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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 360px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #2c3e50;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

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

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
}

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

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

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

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

.btn-success {
    background: #27ae60;
    color: white;
}

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

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

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

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

/* App Layout */
.app-container {
    min-height: 100vh;
}

.app-header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    font-size: 1.25rem;
}

.app-header .user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-tabs {
    background: #34495e;
    display: flex;
    overflow-x: auto;
}

.nav-tabs button {
    background: none;
    border: none;
    color: #bdc3c7;
    padding: 1rem 1.5rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.nav-tabs button:hover {
    background: rgba(255,255,255,0.1);
}

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

.app-content {
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.card-header h2 {
    font-size: 1.25rem;
    color: #2c3e50;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
}

tr:hover {
    background: #f8f9fa;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

/* Líneas de factura */
.lineas-table input {
    width: 100%;
    padding: 0.25rem;
}

.lineas-table .col-cant {
    width: 80px;
}

.lineas-table .col-precio,
.lineas-table .col-iva,
.lineas-table .col-importe {
    width: 100px;
    text-align: right;
}

.lineas-table td.col-precio,
.lineas-table td.col-iva,
.lineas-table td.col-importe {
    text-align: right;
}

.lineas-table .col-acciones {
    width: 50px;
}

/* Resumen factura */
.factura-resumen {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #eee;
}

.resumen-grupo {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.resumen-total {
    display: flex;
    justify-content: flex-end;
    gap: 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 2px solid #2c3e50;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: auto;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Preview */
.preview-container {
    display: flex;
    gap: 1.5rem;
}

.preview-pdf {
    flex: 1;
    min-height: 500px;
}

.preview-pdf iframe {
    width: 100%;
    height: 500px;
    border: 1px solid #ddd;
}

.preview-info {
    width: 250px;
}

.preview-info h4 {
    margin-bottom: 0.5rem;
}

.preview-info p {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Utilities */
.hidden {
    display: none !important;
}

.error {
    color: #e74c3c;
    margin-top: 0.5rem;
}

.success {
    color: #27ae60;
}

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

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Checkbox inline */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-tabs {
        flex-wrap: nowrap;
    }

    .nav-tabs button {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .form-row {
        flex-direction: column;
    }

    .preview-container {
        flex-direction: column;
    }

    .preview-info {
        width: 100%;
    }

    .actions {
        flex-direction: column;
    }

    table {
        font-size: 0.875rem;
    }

    th, td {
        padding: 0.5rem;
    }
}
