:root {
    color-scheme: light;
    --ink: #1d2939;
    --muted: #667085;
    --line: #e4eaf2;
    --canvas: #f3f6fb;
    --surface: #fff;
    --blue: #315eea;
    --blue-dark: #244bd0;
    --teal: #0e9f9a;
    --danger: #d92d42;
    --radius-card: 1rem;
    --shadow-card: 0 8px 24px rgba(22, 37, 66, .06), 0 1px 3px rgba(22, 37, 66, .04);
    --shadow-raised: 0 18px 42px rgba(22, 37, 66, .14);
}

* {
    min-width: 0;
}

body.app-page {
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(ellipse at 85% 0, rgba(49, 94, 234, .07), transparent 32rem),
        var(--canvas);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: .95rem;
    -webkit-font-smoothing: antialiased;
}

.app-page .navbar {
    min-height: 68px;
    color: #fff;
    background: linear-gradient(110deg, #17283e, #223b5b);
    box-shadow: 0 4px 18px rgba(23, 40, 62, .13);
}

.navbar-brand {
    font-weight: 750;
    letter-spacing: -.035em;
}

.app-page .navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, .27);
    border-radius: .65rem;
}

.app-page .navbar .btn-outline-light:hover {
    color: #17283e;
    background: #fff;
}

.app-page main,
.app-page > .container,
.app-page > div.container {
    padding-bottom: clamp(2rem, 5vw, 4rem);
}

.app-page main.container,
.app-page > .container {
    width: min(100% - 2rem, 1200px);
    max-width: 1200px;
}

.billing-page main {
    width: min(100% - 2rem, 1440px);
    max-width: 1440px;
    margin-right: auto;
    margin-left: auto;
    padding-right: 0;
    padding-left: 0;
}

.page-heading {
    margin-bottom: 1.75rem !important;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1.5rem 0;
}

.auth-container {
    display: grid;
    max-width: 480px !important;
    place-items: center;
}

.auth-card {
    width: 100%;
}

.auth-card .card-body {
    overflow-wrap: anywhere;
}

.user-reset-form {
    min-width: 210px;
}

.app-page details > summary.btn {
    list-style: none;
}

.app-page details > summary.btn::-webkit-details-marker {
    display: none;
}

.page-heading h1,
.app-page h2.page-title {
    color: var(--ink);
    font-size: clamp(1.6rem, 2.7vw, 2.25rem);
    font-weight: 760;
    letter-spacing: -.05em;
}

.page-heading p {
    max-width: 58ch;
    margin-top: .4rem;
    color: var(--muted);
}

.app-page .text-muted {
    color: var(--muted) !important;
}

.app-page .btn {
    min-height: 40px;
    border-radius: .7rem;
    font-weight: 600;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease;
}

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

.app-page .btn-primary {
    color: #fff;
    background: var(--blue);
    border-color: var(--blue);
    box-shadow: 0 4px 10px rgba(49, 94, 234, .18);
}

.app-page .btn-primary:hover,
.app-page .btn-primary:focus {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
    box-shadow: 0 6px 14px rgba(49, 94, 234, .24);
}

.app-page .btn-outline-primary {
    color: var(--blue);
    border-color: #cbd7ff;
    background: #fff;
}

.app-page .btn-outline-primary:hover {
    color: #fff;
    background: var(--blue);
    border-color: var(--blue);
}

.app-page .btn-outline-secondary {
    color: #475467;
    border-color: #d6deea;
    background: #fff;
}

.app-page .btn-outline-secondary:hover {
    color: var(--ink);
    background: #f1f4f8;
    border-color: #c4cfdd;
}

.app-page .btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.app-page .form-label {
    color: #344054;
    font-size: .88rem;
    font-weight: 650;
}

.app-page .form-control,
.app-page .form-select {
    min-height: 44px;
    color: var(--ink);
    border-color: #d7dfeb;
    border-radius: .7rem;
    background-color: #fff;
}

.app-page input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.app-page input[type="number"]::-webkit-inner-spin-button,
.app-page input[type="number"]::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.app-page textarea.form-control {
    min-height: 110px;
}

.app-page textarea.line-concept {
    min-height: 44px;
    overflow-y: hidden;
    resize: vertical;
    line-height: 1.45;
}

.app-page .input-group > .form-control,
.app-page .input-group > .form-select,
.app-page .input-group > .input-group-text {
    border-radius: 0;
}

.app-page .input-group > :first-child {
    border-radius: .7rem 0 0 .7rem;
}

.app-page .input-group > :last-child {
    border-radius: 0 .7rem .7rem 0;
}

.app-page .input-group > :only-child {
    border-radius: .7rem;
}

.app-page .form-control:focus,
.app-page .form-select:focus {
    border-color: #9aafff;
    box-shadow: 0 0 0 .22rem rgba(49, 94, 234, .12);
}

.app-page .form-control::placeholder {
    color: #98a2b3;
}

.app-page .card,
.surface,
.metric-card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid rgba(222, 230, 241, .9) !important;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card) !important;
}

.card-dashboard {
    height: 100%;
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card-dashboard:hover,
.card-dashboard:focus-visible {
    color: inherit;
    transform: translateY(-4px);
    border-color: #c7d5ff !important;
    box-shadow: var(--shadow-raised) !important;
}

.card-dashboard .card-body {
    display: flex;
    min-height: 220px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 3vw, 2.5rem) !important;
}

.card-dashboard .card-title {
    margin-top: .25rem;
    font-weight: 700;
    letter-spacing: -.025em;
}

.card-dashboard .card-text {
    max-width: 25ch;
    margin-bottom: 0;
    line-height: 1.55;
}

.icon-large {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    margin-bottom: 1rem !important;
    color: var(--blue);
    background: #eef2ff;
    border-radius: 1.15rem;
    font-size: 1.8rem;
}

.card-dashboard .bi-file-earmark-text {
    color: #c77912 !important;
    background: #fff4df;
}

.card-dashboard .bi-receipt {
    color: #138252 !important;
    background: #e5f7ef;
}

.card-dashboard .bi-person-vcard {
    color: #0e7c86 !important;
    background: #e2f7f7;
}

.table-responsive {
    border-radius: .8rem;
    scrollbar-color: #b8c5d7 #f2f4f7;
    scrollbar-width: thin;
}

.app-page .table {
    --bs-table-color: var(--ink);
    --bs-table-striped-bg: #f8faff;
    --bs-table-hover-bg: #f1f5ff;
    margin-bottom: 0;
}

.app-page .table > :not(caption) > * > * {
    padding: .9rem .85rem;
    border-color: var(--line);
    vertical-align: middle;
}

.app-page .table thead th {
    color: #e7ecf5;
    background: #263b58;
    border-color: #344b6b;
    font-size: .73rem;
    font-weight: 700;
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-page .table tbody tr:last-child td {
    border-bottom: 0;
}

.app-page .table .btn {
    min-height: 36px;
}

.billing-page {
    font-size: .95rem;
}

.metric-card {
    height: 100%;
    padding: clamp(1rem, 2vw, 1.35rem);
}

.metric-label {
    color: var(--muted);
    font-size: .82rem;
    font-weight: 650;
}

.metric-value {
    color: var(--ink);
    font-size: clamp(1.3rem, 2vw, 1.7rem);
    font-weight: 760;
    letter-spacing: -.045em;
    overflow-wrap: anywhere;
}

.metric-icon {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: .85rem;
    font-size: 1.15rem;
}

.view-tabs {
    gap: clamp(.7rem, 2vw, 1.5rem);
    border-bottom: 1px solid var(--line);
}

.view-tabs .nav-link {
    padding: .8rem .2rem;
    color: var(--muted);
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-weight: 650;
}

.view-tabs .nav-link:hover {
    color: var(--blue);
}

.view-tabs .nav-link.active {
    color: var(--blue);
    background: transparent;
    border-bottom-color: var(--blue);
}

.billing-table-header {
    border-color: var(--line) !important;
}

.document-actions-menu {
    position: fixed;
    z-index: 1080;
    width: min(250px, calc(100vw - 16px));
    max-height: min(70vh, 420px);
    overflow-y: auto;
    padding: .45rem;
    border: 1px solid rgba(33, 37, 41, .1);
    border-radius: .85rem;
    background: #fff;
    box-shadow: var(--shadow-raised);
}

.document-actions-menu[hidden] {
    display: none;
}

.document-actions-menu .dropdown-item {
    display: flex;
    min-height: 42px;
    align-items: center;
    border-radius: .55rem;
    white-space: normal;
}

.document-actions-menu .dropdown-item:focus {
    color: var(--ink);
    background: #f1f4fa;
}

.document-actions-menu .dropdown-item.text-danger:focus {
    color: #b02a37;
}

.document-actions-trigger[aria-expanded="true"] {
    color: var(--blue);
    background: #eaf0ff;
    border-color: #c8d5ff;
}

.doc-number {
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.doc-number:hover {
    color: var(--blue);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .38rem .68rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge::before {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    content: "";
}

.status-borrador { color: #667085; background: #f0f2f5; }
.status-enviado, .status-enviada, .status-pendiente { color: #a86400; background: #fff4df; }
.status-aceptado, .status-pagada { color: #138252; background: #e5f7ef; }
.status-rechazado, .status-vencida { color: #bd3232; background: #ffebeb; }
.status-facturado { color: #315eea; background: #eaf0ff; }

.empty-icon {
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    color: #52647c;
    background: #eef2f7;
    border-radius: 1rem;
    font-size: 1.4rem;
}

.line-item-row {
    padding: .75rem 0;
    border-bottom: 1px solid var(--line);
}

.line-item-row:last-child {
    border-bottom: 0;
}

.client-preview {
    min-height: 100%;
    background: #f7f9fd;
    border: 1px solid var(--line);
    border-radius: .85rem;
}

.tax-selection-description {
    min-height: 1.25rem;
    margin: .15rem 0 .55rem;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.line-vat-description {
    padding-left: .25rem;
    padding-right: .25rem;
}

.withholding-rate-input {
    max-width: 150px;
}

.profile-logo-preview {
    display: block;
    width: min(100%, 220px);
    max-height: 140px;
    object-fit: contain;
    object-position: left center;
}

.confirmation-icon {
    display: grid;
    width: 68px;
    height: 68px;
    place-items: center;
    border-radius: 50%;
    font-size: 1.7rem;
}

.confirmation-icon-danger {
    color: var(--danger);
    background: #fff0f1;
}

#action-confirmation .confirmation-icon-info {
    color: var(--blue);
    background: #eef2ff;
}

#action-confirmation.modal.fade .modal-dialog {
    transform: translateY(12px) scale(.98);
    transition: transform .2s ease-out;
}

#action-confirmation.modal.show .modal-dialog {
    transform: translateY(0) scale(1);
}

.app-page .modal-content {
    border: 1px solid rgba(222, 230, 241, .9) !important;
    border-radius: 1rem !important;
    box-shadow: var(--shadow-raised);
}

.app-page .modal-header,
.app-page .modal-footer {
    border-color: var(--line);
}

.pdf-document {
    margin: 0;
    color: #27364a;
    font-family: Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

.pdf-document .header {
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid #315eea;
}

.pdf-document .info-doc h2 {
    margin: 0 0 8px;
    font-size: 26px;
}

.pdf-document .info-doc p {
    margin: 4px 0;
}

.pdf-document .logo {
    color: #315eea;
    font-size: 24px;
    font-weight: bold;
}

.document-logo {
    width: auto;
    max-width: 200px;
    max-height: 100px;
    object-fit: contain;
}

.pdf-document .logo-caption {
    color: #667085;
    font-size: 14px;
    font-weight: normal;
}

.pdf-document .info-doc {
    float: right;
    text-align: right;
}

.pdf-document .party-details {
    display: table;
    width: 100%;
    margin: 0 -10px 22px;
    table-layout: fixed;
    border-spacing: 10px 0;
}

.pdf-document .party-column {
    display: table-cell;
    width: 50%;
    padding: 14px 16px;
    vertical-align: top;
    background: #f3f6fb;
}

.pdf-document .party-column h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

.pdf-document .party-column p {
    margin: 5px 0;
    overflow-wrap: anywhere;
}

.pdf-document .document-observations {
    margin: 0 0 22px;
    padding: 14px 16px;
    background: #f3f6fb;
}

.pdf-document .document-observations h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.pdf-document .document-observations p {
    margin: 4px 0;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.pdf-document table {
    width: 100%;
    margin-bottom: 20px;
    border-collapse: collapse;
}

.pdf-document th,
.pdf-document td {
    padding: 10px 9px;
    border: 1px solid #dce3ed;
    text-align: left;
}

.pdf-document thead {
    display: table-header-group;
}

.pdf-document tr {
    page-break-inside: avoid;
}

.pdf-document th {
    color: #fff;
    background: #263b58;
    font-size: 14px;
}

.pdf-document .totales {
    width: 48%;
    margin-left: auto;
}

.pdf-document .totales th {
    color: #27364a;
    background: #f3f6fb;
    text-align: right;
}

.pdf-document .totales td {
    font-weight: bold;
    text-align: right;
}

.pdf-document .withholding-amount {
    color: #c62828;
}

.pdf-document .totales .grand-total {
    border-top: 2px solid #315eea;
    font-size: 18px;
}

@page {
    size: A4;
    margin: 16mm;
}

.clear-floats {
    clear: both;
}

@media (min-width: 1400px) {
    .billing-page main {
        width: min(100% - 4rem, 1440px);
    }
}

@media (max-width: 991.98px) {
    .app-page .navbar {
        min-height: 62px;
    }

    .billing-page main {
        width: min(100% - 2rem, 900px);
    }
}

@media (max-width: 767.98px) {
    .app-page {
        font-size: .93rem;
    }

    .app-page main.container,
    .app-page > .container {
        width: min(100% - 1.25rem, 700px);
    }

    .billing-page main {
        width: calc(100% - 1.25rem);
    }

    .app-page .navbar .container,
    .app-page .navbar .container-fluid {
        padding-right: .75rem;
        padding-left: .75rem;
    }

    .app-page .navbar-brand {
        max-width: 58vw;
        overflow: hidden;
        font-size: .95rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-page .navbar .btn {
        min-height: 36px;
        padding: .35rem .55rem;
        font-size: .78rem;
        white-space: nowrap;
    }

    .page-heading {
        align-items: flex-start !important;
        gap: 1rem !important;
        margin-bottom: 1.25rem !important;
    }

    .header-actions {
        display: grid !important;
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .header-actions .btn {
        min-height: 44px;
        padding: .5rem;
        font-size: .84rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .view-tabs {
        gap: 1.1rem;
        margin-right: -.625rem;
        margin-left: -.625rem;
        padding-right: .625rem;
        padding-left: .625rem;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .view-tabs::-webkit-scrollbar {
        display: none;
    }

    .view-tabs .nav-link {
        white-space: nowrap;
    }

    .app-page .table > :not(caption) > * > * {
        padding: .75rem .65rem;
    }

    .billing-table-header {
        align-items: flex-start !important;
        gap: .5rem;
    }

    .billing-table-header > a {
        white-space: nowrap;
    }

    .surface.p-3,
    .surface.p-lg-4 {
        padding: 1rem !important;
    }

    .app-page .modal-dialog {
        margin: .5rem;
    }

    .app-page .modal-dialog-scrollable {
        height: calc(100% - 1rem);
    }

    .app-page .modal-body {
        padding-right: 1rem !important;
        padding-left: 1rem !important;
    }

}

@media (max-width: 575.98px) {
    .app-page .navbar {
        min-height: 58px;
    }

    .app-page .navbar .container,
    .app-page .navbar .container-fluid {
        flex-wrap: wrap;
        row-gap: .35rem;
    }

    .app-page .navbar-brand {
        max-width: 44vw;
        font-size: .85rem;
    }

    .app-page .navbar .ms-auto.d-flex {
        width: 100%;
        justify-content: flex-end;
    }

    .app-page .navbar .btn {
        padding: .3rem .42rem;
        font-size: .7rem;
    }

    .app-page .navbar .d-flex.gap-2 {
        gap: .35rem !important;
    }

    .page-heading h1,
    .app-page h2.page-title {
        font-size: 1.55rem;
    }

    .card-dashboard .card-body {
        min-height: 175px;
        padding: 1.2rem !important;
    }

    .icon-large {
        width: 52px;
        height: 52px;
        font-size: 1.5rem;
    }

    .metric-card {
        min-height: 112px;
    }

    .metric-value {
        font-size: 1.28rem;
    }

    .metric-icon {
        width: 36px;
        height: 36px;
        border-radius: .7rem;
    }

    .line-item-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
        margin-right: 0;
        margin-left: 0;
    }

    .line-item-row > div {
        width: auto;
        padding-right: 0;
        padding-left: 0;
    }

    .line-item-row > div:first-child {
        grid-column: 1 / -1;
    }

    .line-item-row > div:last-child {
        display: flex;
        grid-column: 1 / -1;
        justify-content: flex-end;
    }

    .line-item-row .form-control,
    .line-item-row .form-select {
        min-height: 42px;
    }

    .withholding-rate-input {
        max-width: 120px;
    }

    .billing-page #custom-dates {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
    }

    .billing-page #custom-dates.d-none {
        display: none !important;
    }

}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}
