:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Header */
.app-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-badge {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.subtitle {
    color: #94a3b8;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: -1.5rem auto 2rem;
    padding: 0 1rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Tabs */
.tabs-nav {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.5rem 0;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.03);
}

.tab-content {
    display: none;
    padding: 2rem 1.5rem;
}

.tab-content.active {
    display: block;
}

/* Forms */
.search-form {
    margin-bottom: 1.5rem;
}

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

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

.form-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input,
.form-group select {
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    color: var(--text-main);
    background-color: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* State Boxes */
.state-box {
    padding: 2.5rem 1.5rem;
    text-align: center;
    border-radius: var(--radius-md);
    background: #f8fafc;
    border: 1px dashed var(--border);
}

.state-box .icon-bubble {
    width: 56px;
    height: 56px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1rem;
}

.state-box.error {
    background: var(--danger-light);
    border-color: #fecaca;
    border-style: solid;
}

.state-box.error .icon-bubble {
    background: #fee2e2;
}

.state-box h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.state-box p {
    color: var(--text-muted);
    font-size: 0.875rem;
    max-width: 450px;
    margin: 0 auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Result Presentation */
.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.doc-title h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.doc-title .doc-number {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 600;
}

.status-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge.aceptado {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.status-badge.creado {
    background: #f1f5f9;
    color: #475569;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
}

.info-item {
    font-size: 0.875rem;
}

.info-item .label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.125rem;
}

.info-item .value {
    font-weight: 600;
    color: var(--text-main);
}

/* Total Box */
.total-highlight {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.total-highlight .total-label {
    font-weight: 600;
    color: #1e40af;
    font-size: 0.875rem;
}

.total-highlight .total-amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e3a8a;
}

/* Download Actions */
.download-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.btn-download {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-pdf {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.btn-pdf:hover { background-color: #fca5a5; color: #7f1d1d; }

.btn-ticket {
    background-color: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}
.btn-ticket:hover { background-color: #fcd34d; color: #78350f; }

.btn-xml {
    background-color: #e0e7ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
}
.btn-xml:hover { background-color: #c7d2fe; color: #312e81; }

.btn-cdr {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.btn-cdr:hover { background-color: #a7f3d0; color: #064e3b; }

/* Footer */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}
