.mobile-header,
.mobile-sidebar-head {
    display: none;
}

.mobile-filter-action {
    display: none;
    margin-bottom: 16px;
}

.modal-actions {
    flex-wrap: wrap;
    gap: 10px;
}

.alert[data-auto-dismiss-flash] {
    animation: flash-auto-dismiss 4.6s ease forwards;
}

@keyframes flash-auto-dismiss {
    0%, 82% {
        opacity: 1;
        max-height: 90px;
        margin-bottom: 12px;
        padding-top: 12px;
        padding-bottom: 12px;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
        transform: translateY(-4px);
        overflow: hidden;
    }
}

.filter-card.compact {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.pending-stat-card {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.brand-mark,
.avatar {
    overflow: hidden;
    flex: 0 0 auto;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.user-card-link {
    display: block;
    color: inherit;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.user-card-link:hover,
.user-card-link.active {
    border-color: var(--accent-strong);
    background: #f7ffe9;
    transform: translateY(-1px);
}

.settings-company-form {
    margin-top: 14px;
}

.logo-settings-card {
    display: flex;
    flex-direction: column;
}

.logo-settings-form {
    margin-top: 14px;
    height: 100%;
}

.settings-company-form > .btn.primary,
.logo-settings-form > .btn.primary {
    width: 100%;
    height: 44px;
    min-height: 44px;
    align-self: end;
}

.instance-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(238, 245, 233, .42);
}

.instance-card p {
    margin: 0;
}

.instance-copy-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.instance-copy-row input {
    font-weight: 850;
}

.logo-upload-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.company-logo-preview {
    width: 74px;
    height: 74px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--accent);
    color: var(--ink);
    font-size: 1.8rem;
    font-weight: 950;
    overflow: hidden;
}

.company-logo-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.logo-settings-card .logo-upload-row {
    grid-template-columns: 116px minmax(0, 1fr);
    align-items: start;
}

.logo-settings-preview {
    width: 116px;
    height: 116px;
    border-radius: 22px;
}

.billing-history-table .btn {
    white-space: nowrap;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.payment-failure-message {
    margin-top: 6px;
    max-width: 260px;
    font-size: 12px;
}

.invoice-field label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.field-help {
    margin: 6px 0 0;
    font-size: .82rem;
}

.profile-card {
    padding: 18px;
}

.profile-form {
    display: grid;
    gap: 18px;
}

.profile-photo-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
    align-items: center;
}

.profile-photo-preview {
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--accent);
    color: var(--ink);
    font-size: 2.35rem;
    font-weight: 950;
    overflow: hidden;
    flex: 0 0 auto;
}

.profile-photo-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.profile-photo-row h2 {
    margin-bottom: 3px;
}

.profile-photo-row label {
    margin-top: 12px;
}

.profile-notification-box {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(238, 245, 233, .46);
}

.profile-notification-box p {
    margin: 0;
}

.profile-password-note {
    display: flex;
    align-items: end;
    min-height: 42px;
    font-weight: 760;
}

.profile-actions {
    justify-content: flex-end;
}

.payment-status-badge {
    min-width: 86px;
    justify-content: center;
}

.payment-status-paid {
    background: #eafad7;
}

.payment-status-pending {
    background: #f2f6ee;
}

.payment-status-upcoming {
    background: #e6f0ff;
    color: #0f4d91;
}

.payment-status-cancelled {
    background: #f2f2f2;
    color: #565f51;
}

.payment-status-error {
    background: #ffe7ea;
    color: #a1172a;
}

.payment-status-suspended {
    background: #fff1d6;
    color: #87540c;
}

.mobile-menu-button {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    flex: 0 0 auto;
}

.mobile-menu-button svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.8;
}

.mobile-menu-button i[data-lucide="menu"] {
    width: 22px;
    height: 16px;
    display: block;
    background:
        linear-gradient(var(--ink), var(--ink)) 0 0 / 100% 2px no-repeat,
        linear-gradient(var(--ink), var(--ink)) 0 50% / 100% 2px no-repeat,
        linear-gradient(var(--ink), var(--ink)) 0 100% / 100% 2px no-repeat;
    border-radius: 999px;
}

@media (max-width: 980px) {
    body.mobile-menu-open {
        overflow: hidden;
    }

    .app-shell {
        display: block;
        padding: 12px;
    }

    .mobile-header {
        position: sticky;
        top: 10px;
        z-index: 40;
        min-height: 64px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 16px;
        padding: 10px 12px;
        backdrop-filter: blur(18px);
    }

    .mobile-header .brand,
    .mobile-sidebar-head .brand {
        margin-bottom: 0;
        min-width: 0;
    }

    .mobile-header .brand > div:last-child,
    .mobile-sidebar-head .brand > div:last-child {
        min-width: 0;
    }

    .mobile-header strong,
    .mobile-sidebar-head strong,
    .mobile-header .muted,
    .mobile-sidebar-head .muted {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-sidebar-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding-bottom: 18px;
        margin-bottom: 6px;
        border-bottom: 1px solid var(--line);
    }

    .desktop-brand {
        display: none;
    }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 80;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        gap: 22px;
        padding: 18px;
        border: 0;
        border-radius: 0;
        background:
            radial-gradient(28rem 20rem at 90% -4rem, rgba(146, 255, 31, .19), transparent 70%),
            #fafcf7;
        box-shadow: none;
        overflow: auto;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-12px) scale(.98);
        transition: opacity .18s ease, transform .18s ease;
    }

    .sidebar.is-open {
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }

    .sidebar .nav {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .nav a,
    .nav button {
        min-height: 54px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: rgba(255, 255, 255, .72);
        color: var(--ink);
    }

    .nav a.active,
    .nav a:hover,
    .nav button:hover {
        background: #eafad7;
    }

    .nav svg {
        width: 20px;
        height: 20px;
    }

    .nav a.active svg {
        width: 32px;
        height: 32px;
    }

    .sidebar-bottom {
        grid-template-columns: 1fr;
        margin-top: auto;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .pending-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .pending-stat-card {
        min-height: 78px;
        display: grid;
        align-content: center;
        gap: 4px;
        padding: 10px;
        text-align: left;
    }

    .pending-stat-card strong {
        display: block;
        font-size: 1.35rem;
        line-height: 1;
    }

    .pending-stat-card .muted {
        display: block;
        font-size: .82rem;
        line-height: 1.15;
    }

    .form-grid .span-2,
    .form-grid .span-3 {
        grid-column: auto;
    }

    .catalog-shell,
    .filters-bar,
    .dashboard-main,
    .dashboard-secondary,
    .report-advisor-grid {
        grid-template-columns: 1fr;
    }

    .responsive-filter-form {
        display: none;
    }

    .mobile-filter-action {
        display: block;
    }

    .mobile-filter-action .btn {
        width: 100%;
        justify-content: center;
    }

    .filter-card,
    .filter-card.compact {
        grid-template-columns: 1fr;
    }

    .catalog-list {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .catalog-edit {
        grid-template-columns: 1fr;
    }

    .catalog-toolbar,
    .data-tool-head,
    .section-head,
    .report-summary-card {
        align-items: stretch;
        flex-direction: column;
    }

    .catalog-toolbar .btn,
    .data-tool-actions .btn,
    .page-actions .btn {
        width: 100%;
    }

    .funnel-row {
        grid-template-columns: 102px minmax(0, 1fr) 36px;
    }

    .advisor-bar-row {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .advisor-bar-row > strong:last-child {
        grid-column: 2;
    }

    .donut-row {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: left;
    }

    .donut-chart {
        width: min(230px, 72vw);
    }

    .donut-legend {
        width: 100%;
    }

    .donut-legend-item {
        grid-template-columns: 14px minmax(0, 1fr) 44px 40px;
    }

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

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

    .profile-photo-row {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .profile-actions {
        justify-content: stretch;
    }

    .profile-actions .btn {
        width: 100%;
        justify-content: center;
    }

}

@media (max-width: 560px) {
    .app-shell {
        padding: 10px;
    }

    .mobile-header {
        top: 8px;
        min-height: 60px;
        margin-bottom: 12px;
    }

    .brand-mark,
    .avatar {
        width: 36px;
        height: 36px;
        border-radius: 12px;
    }

    .page-title {
        font-size: 1.9rem;
        line-height: 1.02;
    }

    .card {
        padding: 14px;
    }

    .catalog-card {
        padding: 0;
    }

    .tabs {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        overflow-x: auto;
        padding-bottom: 4px;
        margin-inline: -2px;
    }

    .tabs a {
        white-space: nowrap;
    }

    .table-wrap {
        margin-inline: -14px;
        padding-inline: 14px;
    }

    table {
        min-width: 640px;
    }

    .catalog-table {
        min-width: 560px;
    }

    .billing-history-card .table-wrap {
        margin-inline: 0;
        padding-inline: 0;
        overflow: visible;
    }

    .billing-history-table {
        width: 100%;
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .billing-history-table thead {
        display: none;
    }

    .billing-history-table tbody {
        display: grid;
        gap: 10px;
    }

    .billing-history-table tr {
        display: grid;
        gap: 10px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #fff;
    }

    .billing-history-table td {
        display: grid;
        grid-template-columns: minmax(0, 92px) minmax(0, 1fr);
        align-items: center;
        gap: 8px;
        min-width: 0;
        padding: 0;
        border: 0;
        font-size: .9rem;
    }

    .billing-history-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .68rem;
        font-weight: 950;
        line-height: 1;
        text-transform: uppercase;
    }

    .billing-history-table td[data-label="Acciones"] {
        grid-template-columns: 1fr;
    }

    .billing-history-table td[data-label="Acciones"]::before {
        display: none;
    }

    .billing-history-table .btn {
        width: 100%;
        justify-content: center;
    }

    .billing-history-table .table-actions {
        width: 100%;
    }

    .billing-history-table .badge {
        width: max-content;
        max-width: 100%;
    }

    .billing-empty-row td {
        display: block;
    }

    .billing-empty-row td::before {
        display: none;
    }

    .board {
        grid-auto-columns: minmax(260px, 86vw);
        margin-inline: -10px;
        padding-inline: 10px;
    }

    .modal-backdrop {
        align-items: stretch;
        padding: 10px;
    }

    .modal-panel {
        max-height: calc(100dvh - 20px);
        border-radius: 16px;
    }

    .modal-head {
        align-items: stretch;
        flex-direction: column;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .instance-copy-row,
    .logo-upload-row,
    .logo-settings-card .logo-upload-row {
        grid-template-columns: 1fr;
    }

    .company-logo-preview {
        width: 64px;
        height: 64px;
    }

    .metric-card {
        align-items: flex-start;
    }

    .attention-list-row {
        grid-template-columns: 12px minmax(0, 1fr) 42px;
    }

    .attention-list-row span:last-child {
        display: none;
    }

    .summary-pills .pill {
        width: 100%;
        justify-content: space-between;
    }
}
