/* Base reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-page: #f4f7ff;
    --bg-surface: #ffffff;
    --bg-muted: #f7f9fd;
    --text-main: #12192f;
    --text-muted: #596584;
    --text-soft: #76809b;
    --line-soft: #e3e9f4;
    --line-strong: #d5deee;
    --accent: #3564d6;
    --accent-2: #5b5bd6;
    --danger: #d84f57;
    --success-bg: #e7f8ef;
    --success-text: #157347;
    --danger-bg: #fbecee;
    --danger-text: #9b2c35;
    --warning-bg: #fff6dc;
    --warning-text: #8a6a00;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --shadow-soft: 0 8px 26px rgba(18, 25, 47, 0.06);
}

body {
    font-family: "Inter", "Avenir Next", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 8% 0%, #eaf1ff 0%, transparent 35%),
        radial-gradient(circle at 90% 8%, #edf9ff 0%, transparent 32%),
        var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid #9eb7ff;
    outline-offset: 2px;
}

/* Shell + navbar */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(16px);
    background: rgba(252, 253, 255, 0.88);
    border-bottom: 1px solid var(--line-soft);
    box-shadow: 0 8px 24px rgba(38, 59, 122, 0.06);
}

.navbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0.9rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-brand {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 800;
    letter-spacing: -0.01em;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 999px;
    padding: 0.5rem 0.85rem;
    font-size: 0.86rem;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nav-links a:hover {
    background: #eef3ff;
    color: #1d2e60;
}

.nav-links a.active {
    color: #10214d;
    background: linear-gradient(180deg, #edf3ff 0%, #f4f7ff 100%);
    box-shadow: inset 0 0 0 1px #cfdbfb;
}

.nav-links .nav-cta {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(53, 100, 214, 0.23);
}

.nav-links .nav-cta:hover {
    color: #ffffff;
    background: linear-gradient(135deg, #2f59bf 0%, #5050bf 100%);
}

/* Layout */
.container {
    flex: 1;
    width: min(1240px, 100% - 2.2rem);
    margin: 1.25rem auto 0;
}

.auth-wrap {
    min-height: calc(100vh - 210px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: min(460px, 100%);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.page-header h1 {
    font-size: clamp(1.35rem, 2.2vw, 1.95rem);
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.2rem;
}

/* Reusable blocks */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-lg);
    padding: 1.05rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1.02rem;
    color: #18233f;
    margin-bottom: 0.65rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #edf1f8;
}

.card-muted {
    background: linear-gradient(180deg, #f8faff 0%, #f6f9fd 100%);
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
}

.col-span-6 {
    grid-column: span 6;
}

.col-span-8 {
    grid-column: span 8;
}

.col-span-4 {
    grid-column: span 4;
}

.col-span-12 {
    grid-column: span 12;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    border: 1px solid #e7edf7;
    border-radius: 15px;
    padding: 1rem;
    box-shadow: 0 6px 20px rgba(18, 25, 47, 0.05);
}

.stat-card .stat-value {
    font-size: 1.55rem;
    font-weight: 760;
    color: var(--text-main);
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 0.83rem;
    margin-top: 0.1rem;
}

.stat-card.primary {
    background: linear-gradient(135deg, #273c78 0%, #4057a8 100%);
    border-color: #324a95;
}

.stat-card.primary .stat-value,
.stat-card.primary .stat-label {
    color: #ffffff;
}

/* Tables */
.table-wrap {
    width: 100%;
    overflow: auto;
    border: 1px solid #e6ebf5;
    border-radius: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
    background: #ffffff;
}

thead th {
    text-align: left;
    padding: 0.68rem 0.75rem;
    background: #f6f9ff;
    font-weight: 680;
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    color: #516186;
    border-bottom: 1px solid #e1e8f6;
    text-transform: uppercase;
}

tbody td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #edf1f8;
    font-size: 0.89rem;
    vertical-align: top;
}

tbody tr:hover {
    background: #fafcff;
}

tbody a {
    color: #16357d;
    text-decoration: none;
}

tbody a:hover {
    text-decoration: underline;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 650;
    border: 1px solid transparent;
}

.badge-active {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #bde9ce;
}

.badge-canceled {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #f2c3c8;
}

.badge-pending {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: #f1df9b;
}

.badge-soft {
    background: #edf3ff;
    color: #274fba;
    border-color: #d5e2ff;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.52rem 0.92rem;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 640;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(53, 100, 214, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2f59bf 0%, #4f4fbe 100%);
}

.btn-secondary {
    background: #f7f9fd;
    color: #23345f;
    border-color: #d7e0ef;
}

.btn-secondary:hover {
    background: #edf2fb;
}

.btn-danger {
    background: #d84f57;
    color: #ffffff;
}

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

.btn-sm {
    padding: 0.38rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 9px;
}

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

.form-group label {
    display: block;
    font-size: 0.83rem;
    font-weight: 650;
    color: #2c3e67;
    margin-bottom: 0.32rem;
}

.form-help {
    margin-top: 0.25rem;
    color: var(--text-soft);
    font-size: 0.8rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.56rem 0.65rem;
    border: 1px solid #d4deee;
    border-radius: 10px;
    font-size: 0.88rem;
    color: var(--text-main);
    background: #ffffff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #7290dd;
    box-shadow: 0 0 0 3px rgba(114, 144, 221, 0.18);
    outline: none;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.form-section {
    margin-bottom: 0.95rem;
    border: 1px solid #e7edf7;
    border-radius: 12px;
    padding: 0.9rem;
    background: #fcfdff;
}

.form-section h3 {
    margin-bottom: 0.55rem;
    font-size: 0.93rem;
    color: #1d2f5e;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #31456f;
    font-size: 0.88rem;
}

/* Alerts */
.alert {
    padding: 0.72rem 0.9rem;
    border-radius: 10px;
    margin-bottom: 0.85rem;
    font-size: 0.86rem;
    border: 1px solid transparent;
}

.alert-success {
    background: #eaf9ef;
    color: #12643e;
    border-color: #bfebd0;
}

.alert-error {
    background: #feeff1;
    color: #942936;
    border-color: #f7ccd2;
}

.alert-info {
    background: #eaf4ff;
    color: #1e4f87;
    border-color: #c9ddf8;
}

/* Detail view */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.detail-item {
    border: 1px solid #e7edf7;
    background: #fbfcff;
    border-radius: 10px;
    padding: 0.6rem;
}

.detail-item label {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-weight: 650;
    display: block;
    margin-bottom: 0.1rem;
}

.detail-item span {
    font-size: 0.9rem;
}

/* Utility */
.empty-state {
    text-align: center;
    padding: 2.2rem 1rem;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
}

.filter-bar {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 0.8rem;
}

.filter-field {
    min-width: 220px;
    flex: 1;
}

.filter-label {
    display: block;
    font-size: 0.79rem;
    font-weight: 650;
    color: #40527b;
    margin-bottom: 0.28rem;
}

.filter-bar input,
.filter-bar select {
    padding: 0.52rem 0.62rem;
    border: 1px solid #d2dceb;
    border-radius: 9px;
    font-size: 0.84rem;
    width: 100%;
}

.actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
}

.muted-note {
    color: var(--text-soft);
    font-size: 0.82rem;
}

.footer {
    text-align: center;
    padding: 1rem;
    color: #8190ae;
    font-size: 0.78rem;
}

/* Dashboard specifics */
.dashboard-hero {
    background: linear-gradient(130deg, #f8faff 0%, #eef7ff 45%, #effff9 100%);
}

.dashboard-content-grid .card {
    grid-column: span 12;
}

.dashboard-table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.dashboard-more-note {
    margin-top: 0.5rem;
}

.dashboard-cfdi-table th,
.dashboard-cfdi-table td {
    white-space: nowrap;
}

.dashboard-cfdi-table {
    min-width: 960px;
}

/* CFDI flow */
.step-shell {
    display: grid;
    gap: 0.7rem;
}

.step-chip {
    font-size: 0.78rem;
    font-weight: 700;
    color: #3856af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.total-box {
    border: 1px solid #d9e4f6;
    background: linear-gradient(180deg, #f7faff 0%, #f4f8ff 100%);
    border-radius: 12px;
    padding: 0.8rem;
    margin-top: 0.8rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin: 0.23rem auto;
    max-width: 320px;
}

.total-row.total-final {
    border-top: 1px solid #d4dded;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    font-weight: 760;
    font-size: 1.02rem;
}

/* CFDI type colors */
.type-I { color: #155724; font-weight: 600; }
.type-E { color: #0c5460; font-weight: 600; }
.type-T { color: #856404; font-weight: 600; }
.type-N { color: #721c24; font-weight: 600; }

/* Reports UX refresh */
.reports-shell {
    display: grid;
    gap: 1rem;
}

.reports-hero {
    background: linear-gradient(135deg, #f6f8ff 0%, #eefaf7 100%);
    border: 1px solid #e2e8f5;
    border-radius: 14px;
    padding: 1.3rem;
}

.reports-kicker {
    color: #4460a8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    font-size: 0.72rem;
    margin-bottom: 0.35rem;
}

.reports-hero h1 {
    font-size: clamp(1.35rem, 3vw, 1.85rem);
    color: #12192f;
    margin-bottom: 0.35rem;
}

.reports-description {
    color: #4f5875;
    max-width: 65ch;
}

.reports-form {
    display: grid;
    gap: 1rem;
}

.reports-card {
    background: #ffffff;
    border: 1px solid #e7ecf4;
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(18, 25, 47, 0.04);
}

.reports-card h2 {
    border: 0;
    margin-bottom: 0.85rem;
    color: #18233f;
}

.report-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.7rem;
}

.report-type-card {
    text-align: left;
    border: 1px solid #dce3ef;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
    padding: 0.75rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.report-type-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(35, 56, 120, 0.1);
}

.report-type-card:focus-visible {
    outline: 3px solid #95b6ff;
    outline-offset: 2px;
}

.report-type-card.is-active {
    border-color: #3464d4;
    background: linear-gradient(180deg, #edf3ff 0%, #f6f9ff 100%);
    box-shadow: 0 10px 24px rgba(52, 100, 212, 0.16);
}

.report-type-label {
    display: block;
    font-weight: 650;
    color: #10214d;
    margin-bottom: 0.2rem;
}

.report-type-desc {
    display: block;
    font-size: 0.83rem;
    color: #5c6885;
}

.date-range-group {
    border: 1px solid #e5eaf4;
    border-radius: 10px;
    padding: 0.85rem;
    margin-top: 0.9rem;
}

.date-range-group legend {
    padding: 0 0.35rem;
    font-weight: 600;
    color: #1a2749;
    font-size: 0.86rem;
}

[data-field].is-hidden {
    display: none;
}

.report-summary {
    background: linear-gradient(135deg, #f7f9ff 0%, #f8fdfa 100%);
}

.report-summary p {
    color: #3d4968;
    margin-bottom: 0.8rem;
}

@media (max-width: 960px) {
    .col-span-6,
    .col-span-8,
    .col-span-4 {
        grid-column: span 12;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .navbar-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .nav-links {
        justify-content: flex-start;
    }

    .container {
        width: min(1240px, 100% - 1.2rem);
        margin-top: 0.85rem;
    }

    .card,
    .reports-hero,
    .reports-card {
        border-radius: 13px;
        padding: 0.85rem;
    }

    .filter-field {
        min-width: 100%;
    }

    .form-actions .btn,
    .actions .btn {
        width: 100%;
    }

    .actions .inline-form {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }
}
