html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.crm-navbar {
    gap: 1rem;
}

.crm-brand {
    align-items: center;
    display: inline-flex;
    min-width: 0;
    padding: 0;
}

.crm-brand-logo {
    display: block;
    height: 3rem;
    max-width: 13.75rem;
    width: auto;
}

.crm-brand-mobile {
    display: none;
    font-weight: 800;
    letter-spacing: 0;
}

.card-action-row {
    flex-wrap: wrap;
}

.responsive-actions {
    width: 100%;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

dl.row > dd {
    overflow-wrap: anywhere;
}

pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.navbar .nav-link {
    border-left: 3px solid transparent;
    border-radius: .45rem;
    padding-left: .75rem;
}

.navbar .nav-link.active {
    background: #e8f1ff;
    border-left-color: #0d6efd;
    color: #0b5ed7;
    font-weight: 600;
}

.navbar .dropdown-menu {
    border-color: #dbe3ef;
    border-radius: .75rem;
    box-shadow: 0 16px 38px rgba(15, 23, 42, .10);
    min-width: 15rem;
    padding: .5rem;
}

.navbar .dropdown-item {
    border-radius: .5rem;
    padding: .55rem .75rem;
}

.navbar .dropdown-item.active,
.navbar .dropdown-item:active {
    background: #e8f1ff;
    color: #0b5ed7;
    font-weight: 700;
}

.service-control-page {
    --crm-soft-blue: #eaf3ff;
    --crm-soft-yellow: #fff7df;
    --crm-soft-green: #eaf8ef;
    --crm-soft-red: #fff0f0;
}

.service-hero {
    background: #fff;
    border: 1px solid #dbe7f5;
    border-radius: 1rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .06);
}

.service-id-label {
    color: #526172;
    font-size: .82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.service-context {
    color: #526172;
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.service-state-grid {
    display: grid;
    gap: .65rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: 52rem;
}

.service-state-item {
    background: #f8fafc;
    border: 1px solid #dbe3ef;
    border-left: 4px solid #6c757d;
    border-radius: .5rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: .65rem .75rem;
}

.service-state-item span,
.service-state-item small {
    color: #64748b;
    font-size: .75rem;
}

.service-state-item strong {
    font-size: .92rem;
    overflow-wrap: anywhere;
}

.state-operational { border-left-color: #0d6efd; }
.state-estimate { border-left-color: #8b5cf6; }
.state-invoice { border-left-color: #0f766e; }
.state-payment { border-left-color: #d99a00; }
.state-paid { border-left-color: #198754; background: #f0faf4; }

.service-action-bar {
    flex: 0 0 auto;
}

.service-primary-action {
    font-weight: 700;
}

.service-attention-strip {
    align-items: center;
    background: #fff8e1;
    border: 1px solid #f5d57a;
    border-radius: .5rem;
    color: #725300;
    display: flex;
    flex-wrap: wrap;
    font-size: .86rem;
    gap: .65rem 1.25rem;
    padding: .65rem .8rem;
}

.service-created-meta {
    color: #718096;
    font-size: .78rem;
}

.service-flash-hidden {
    opacity: 0;
    transform: translateY(-.25rem);
    transition: opacity .25s ease, transform .25s ease;
}

.service-title {
    letter-spacing: 0;
}

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

.service-summary-grid-compact {
    grid-template-columns: minmax(0, 2fr) minmax(14rem, 1fr) minmax(14rem, 1fr);
}

.summary-tile {
    border: 1px solid #e2e8f0;
    border-radius: .9rem;
    background: #fff;
    padding: 1rem;
    min-width: 0;
}

.summary-tile-action {
    background: #fff8e6;
    border-color: #ffd66b;
    box-shadow: 0 10px 26px rgba(245, 158, 11, .12);
}

.summary-tile-action .summary-icon {
    background: #fff0bf;
    color: #9a6700;
}

.service-assign-primary {
    font-weight: 700;
}

.summary-tile p,
.summary-tile a {
    overflow-wrap: anywhere;
}

.summary-icon,
.section-icon,
.timeline-icon {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    justify-content: center;
}

.summary-icon {
    background: #e8f1ff;
    color: #0d6efd;
    height: 2.4rem;
    width: 2.4rem;
}

.section-icon {
    background: #eef4ff;
    color: #0d6efd;
    height: 2rem;
    width: 2rem;
}

.service-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: .9rem;
    padding: 1rem;
}

.service-edit-toolbar,
.service-edit-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.service-edit-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(248, 249, 250, .96);
    padding: .75rem 0;
    backdrop-filter: blur(8px);
}

.service-edit-footer {
    justify-content: flex-end;
    padding: 1rem;
    border: 1px solid #dbe7f5;
    border-radius: .75rem;
    background: #fff;
}

.service-edit-aside {
    position: sticky;
    top: 7rem;
}

.service-list-table {
    min-width: 980px;
}

.service-main-cell {
    min-width: 14rem;
}

.service-actions-cell {
    min-width: 15rem;
}

.service-actions-cell .btn {
    white-space: nowrap;
}

.service-list-table tbody tr.service-row > * {
    border-left: 0;
}

.service-list-table tbody tr.service-row > *:first-child {
    border-left: .35rem solid transparent;
}

.service-row--new > *,
.service-row--pendiente-de-asignar > * {
    --bs-table-bg: #f8fbff;
}

.service-row--new > *:first-child,
.service-row--pendiente-de-asignar > *:first-child {
    border-left-color: #0d6efd;
}

.service-row--assigned > *,
.service-row--asignado > * {
    --bs-table-bg: #f7fbff;
}

.service-row--assigned > *:first-child,
.service-row--asignado > *:first-child {
    border-left-color: #0d6efd;
}

.service-row--on-the-way > *,
.service-row--en-camino > * {
    --bs-table-bg: #f5fcff;
}

.service-row--on-the-way > *:first-child,
.service-row--en-camino > *:first-child {
    border-left-color: #0dcaf0;
}

.service-row--in-progress > *,
.service-row--en-curso > *,
.service-row--en-domicilio > * {
    --bs-table-bg: #fbf7ff;
}

.service-row--in-progress > *:first-child,
.service-row--en-curso > *:first-child,
.service-row--en-domicilio > *:first-child {
    border-left-color: #6f42c1;
}

.service-row--waiting > *,
.service-row--pendiente-de-fotos > *,
.service-row--pendiente-de-precio > *,
.service-row--pendiente-de-revision > * {
    --bs-table-bg: #fffaf0;
}

.service-row--waiting > *:first-child,
.service-row--pendiente-de-fotos > *:first-child,
.service-row--pendiente-de-precio > *:first-child,
.service-row--pendiente-de-revision > *:first-child {
    border-left-color: #ffc107;
}

.service-row--performed > *,
.service-row--realizado > * {
    --bs-table-bg: #f4fbf7;
}

.service-row--performed > *:first-child,
.service-row--realizado > *:first-child {
    border-left-color: #198754;
}

.service-row--closed > *,
.service-row--cerrado > * {
    --bs-table-bg: #f8f9fa;
}

.service-row--closed > *:first-child,
.service-row--cerrado > *:first-child {
    border-left-color: #343a40;
}

.service-row--cancelled > *,
.service-row--cancelado > * {
    --bs-table-bg: #fff7f7;
}

.service-row--cancelled > *:first-child,
.service-row--cancelado > *:first-child {
    border-left-color: #dc3545;
}

.service-panel-blue {
    background: var(--crm-soft-blue);
    border-color: #bdd7ff;
}

.service-panel-yellow {
    background: var(--crm-soft-yellow);
    border-color: #ffe3a6;
}

.call-payload {
    max-height: 28rem;
}

.quick-actions {
    overflow-x: auto;
    padding-bottom: .25rem;
}

.quick-actions .btn {
    white-space: nowrap;
}

.service-tabs {
    border-bottom: 1px solid #dbe3ef;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
}

.service-tabs .nav-link {
    color: #526172;
    border: 0;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.service-tabs .nav-link.active {
    background: transparent;
    border-bottom-color: #0d6efd;
    color: #0d6efd;
    font-weight: 700;
}

.tab-counter,
.tab-state {
    background: #edf2f7;
    border-radius: 999px;
    color: #526172;
    display: inline-block;
    font-size: .68rem;
    line-height: 1;
    margin-left: .2rem;
    max-width: 8rem;
    overflow: hidden;
    padding: .28rem .42rem;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

.service-tabs .nav-link.active .tab-counter,
.service-tabs .nav-link.active .tab-state {
    background: #dbeafe;
    color: #0b5ed7;
}

.badge-status,
.badge-priority,
.badge-payment,
.badge-photo {
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-weight: 700;
    padding: .42rem .65rem;
}

.badge-status-new { background: #e8f1ff; color: #0b5ed7; }
.badge-status-waiting { background: #fff3cd; color: #8a5a00; }
.badge-status-performed { background: #d1e7dd; color: #0f5132; }
.badge-status-closed { background: #343a40; color: #fff; }
.badge-status-cancelled { background: #f8d7da; color: #842029; }
.badge-status-pendiente-de-fotos,
.badge-status-pendiente-de-precio,
.badge-status-pendiente-de-revision { background: #fff3cd; color: #8a5a00; }
.badge-status-pendiente-de-asignar { background: #e9f2ff; color: #315c8c; }
.badge-status-asignado,
.badge-status-assigned { background: #dcebff; color: #084298; }
.badge-status-aceptado-por-tecnico { background: #cfe2ff; color: #052c65; }
.badge-status-en-camino,
.badge-status-on-the-way { background: #efe7ff; color: #5a23a0; }
.badge-status-en-domicilio,
.badge-status-in-progress { background: #eadcff; color: #4c1d95; }
.badge-status-aceptado-por-cliente,
.badge-status-realizado,
.badge-status-completed { background: #d1e7dd; color: #0f5132; }
.badge-status-cerrado { background: #343a40; color: #fff; }
.badge-status-cancelacion-solicitada { background: #ffe5d0; color: #9a3412; }
.badge-status-nulo-pendiente-de-validar,
.badge-status-reclamacion { background: #f8d7da; color: #842029; }
.badge-status-nulo-confirmado,
.badge-status-cancelled { background: #e2e3e5; color: #41464b; }
.badge-status-pending-customer,
.badge-status-pending-material { background: #fff3cd; color: #8a5a00; }

.badge-priority-baja { background: #e2e3e5; color: #41464b; }
.badge-priority-normal { background: #e8f1ff; color: #0b5ed7; }
.badge-priority-alta { background: #fff3cd; color: #8a5a00; }
.badge-priority-urgente,
.badge-priority-urgente-ahora { background: #f8d7da; color: #842029; }

.badge-payment-pending { background: #fff3cd; color: #8a5a00; }
.badge-payment-partial { background: #cff4fc; color: #055160; }
.badge-payment-paid { background: #d1e7dd; color: #0f5132; }
.badge-payment-cancelled,
.badge-payment-refunded { background: #e2e3e5; color: #41464b; }

.photo-card {
    border: 1px solid #e2e8f0;
    border-radius: .9rem;
    overflow: hidden;
    background: #fff;
    height: 100%;
}

.photo-thumb {
    aspect-ratio: 4 / 3;
    background: #eef2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.photo-thumb img {
    height: 100%;
    object-fit: cover;
    width: 100%;
}

.photo-thumb-small {
    height: 54px;
    width: 72px;
    border-radius: .5rem;
    object-fit: cover;
}

.timeline {
    position: relative;
}

.timeline-item {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr);
    gap: .75rem;
    padding-bottom: 1rem;
}

.timeline-icon {
    background: #e8f1ff;
    color: #0d6efd;
    height: 2.1rem;
    width: 2.1rem;
}

.copy-feedback {
    min-height: 1.25rem;
}

.settlement-summary-card {
    color: inherit;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.settlement-summary-card:hover,
.settlement-summary-card.is-active {
    border-color: #0d6efd !important;
    box-shadow: 0 .4rem 1.4rem rgba(13, 110, 253, .12);
    color: inherit;
    transform: translateY(-1px);
}

.settlement-calendar-nav {
    flex-wrap: wrap;
}

.settlement-calendar-wrap {
    overflow-x: auto;
    padding-bottom: .25rem;
}

.settlement-calendar-weekdays,
.settlement-calendar-week {
    display: grid;
    gap: .75rem;
    grid-template-columns: repeat(7, minmax(150px, 1fr));
    min-width: 1080px;
}

.settlement-calendar-weekdays {
    color: #64748b;
    font-size: .82rem;
    font-weight: 700;
    margin-bottom: .5rem;
    text-transform: uppercase;
}

.settlement-calendar-week + .settlement-calendar-week {
    margin-top: .75rem;
}

.settlement-calendar-day {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #cbd5e1;
    border-radius: .85rem;
    min-height: 175px;
    padding: .75rem;
}

.settlement-calendar-day--pending {
    background: #fffaf0;
    border-left-color: #ffc107;
}

.settlement-calendar-day--settled {
    background: #f3fbf7;
    border-left-color: #198754;
}

.settlement-calendar-day--blocked {
    background: #fff5f5;
    border-left-color: #dc3545;
}

.settlement-calendar-day--muted {
    opacity: .55;
}

.settlement-calendar-services {
    max-height: 215px;
    overflow-y: auto;
    padding-right: .15rem;
}

.settlement-calendar-service {
    background: rgba(255, 255, 255, .82);
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: .65rem;
    color: inherit;
    display: block;
    margin-top: .6rem;
    padding: .55rem;
    text-decoration: none;
}

.settlement-calendar-service:hover {
    border-color: #0d6efd;
    box-shadow: 0 0 0 .12rem rgba(13, 110, 253, .12);
}

@media (min-width: 768px) {
    .responsive-actions {
        width: auto;
    }

    .border-md-start {
        border-left: 1px solid #e2e8f0;
        padding-left: 1.25rem;
    }
}

@media (min-width: 992px) {
    .w-lg-auto {
        width: auto !important;
    }

    .navbar .nav-link {
        border-left: 0;
        border-bottom: 3px solid transparent;
        padding: .55rem .7rem;
    }

    .navbar .nav-link.active {
        border-bottom-color: #0d6efd;
        border-left-color: transparent;
    }
}

@media (max-width: 1199.98px) {
    .service-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .service-summary-grid-compact > :first-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 575.98px) {
    .crm-brand-logo {
        display: none;
    }

    .crm-brand-mobile {
        display: inline;
    }

    .navbar-brand {
        max-width: calc(100vw - 5.5rem);
    }

    .mobile-card {
        padding: 1rem !important;
    }

    .table {
        font-size: 0.925rem;
    }

    .service-summary-grid {
        grid-template-columns: 1fr;
    }

    .service-summary-grid-compact > :first-child {
        grid-column: auto;
    }

    .service-state-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .service-action-bar,
    .service-action-bar > .btn,
    .service-action-bar > .dropdown {
        width: 100%;
    }

    .service-hero {
        border-radius: .75rem;
    }

    .service-edit-toolbar {
        position: static;
        align-items: stretch;
        flex-direction: column;
    }

    .service-edit-aside {
        position: static;
    }

    .service-edit-footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .service-edit-footer .btn {
        width: 100%;
    }

    .photo-grid-mobile {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .75rem;
    }

    .settlement-calendar-weekdays,
    .settlement-calendar-week {
        grid-template-columns: repeat(7, minmax(125px, 1fr));
        min-width: 900px;
    }
}
