/* Shared mobile enhancements. Desktop layout is owned by style.css. */
.mobile-only { display: none !important; }
.mobile-details, .mobile-filter-field { display: contents; }
.mobile-details > summary { display: none; }
@media (max-width: 767.98px) {
    .mobile-only { display: inline-flex !important; }
    [hidden].mobile-only { display: none !important; }
    body { --mobile-nav-height: 90px; padding: 0; }
    .main { padding: max(12px, env(safe-area-inset-top)) 12px 12px; gap: 12px; height: auto; min-height: 100dvh; padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
    .main-body { min-width: 0; padding-bottom: 8px; }
    .main-content, .main-content > .container-fluid { min-width: 0; max-width: 100%; }
    .main-content { max-height: none; overflow: visible; font-size: 14px; }
    .main-content > .container-fluid > .mt-5 { margin-top: 20px !important; }
    .main-content > .container-fluid { padding-inline: 0; }
    .topbar { flex-wrap: nowrap !important; gap: 12px !important; padding: 6px 0; }
    .topbar-logo img { width: 36px; height: 36px; object-fit: contain; }
    .topbar-right { margin-left: auto; gap: 10px; }
    .topbar-pill { display: none; }
    .topbar-iconlink, .topbar-avatar { min-width: 44px; min-height: 44px; }
    .topbar-search-panel, .topbar-notifications-panel, .topbar-account-menu {
        position: fixed; left: 12px; right: 12px; top: calc(76px + env(safe-area-inset-top));
        width: auto; max-width: none; max-height: calc(100dvh - 260px); overflow-y: auto;
    }
    /* Override the older, more specific mobile offsets in both panel states. */
    .topbar-search-panel, .topbar-search.is-open .topbar-search-panel,
    .topbar-notifications-panel, .topbar-notifications.is-open .topbar-notifications-panel,
    .topbar-account-menu, .topbar-account.is-open .topbar-account-menu {
        transform: none; white-space: normal; overflow-wrap: anywhere;
    }
    .topbar-search-input { min-width: 0; width: 0; }
    .topbar-search-submit { flex-shrink: 0; }
    .topbar-account-link { min-height: 44px; align-items: center; }
    .sidebar {
        left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
        padding: 10px 8px; gap: 6px; border-radius: 22px; background: var(--secondary);
        box-shadow: 0 6px 30px rgb(0 0 0 / 16%); max-height: none;
        display: flex; flex-wrap: nowrap; justify-content: space-between; align-items: center;
        overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .sidebar::-webkit-scrollbar { display: none; }
    .sidebar-menu, .sidebar-settings { display: contents; }
    .sidebar-item { flex: 0 0 44px; }
    .sidebar-icon { height: 44px; width: 44px; }
    .sidebar-icon svg { height: 25px; width: 25px; }
    .sidebar-item.current .sidebar-icon { transform: none; }
    .sidebar .sidebar-submenu {
        display: none; position: fixed; left: 12px; right: 12px; top: auto;
        bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
        transform: none !important; min-width: 0; border-radius: 20px;
        max-height: calc(100dvh - var(--mobile-nav-height) - 100px); overflow-y: auto;
    }
    .sidebar .sidebar-item.is-active .sidebar-submenu { display: block; opacity: 1; pointer-events: auto; }
    .sidebar-submenu-link { display: flex; align-items: center; min-height: 46px; padding-block: 8px; }
    .sidebar-submenu::before { display: none; }
    .session-countdown { bottom: calc(var(--mobile-nav-height) + 10px + env(safe-area-inset-bottom)); right: 12px; font-size: 11px; padding: 5px 10px; pointer-events: none; }
    .response-stack { left: 12px; right: 12px; top: 80px; width: auto; max-width: none; }
    .workspace-header, .page-header { position: relative; flex-wrap: wrap; gap: 12px !important; }
    .workspace-header:has(.page-header-actions) { padding-right: 0; }
    .workspace-header:has(.page-header-actions) > div:first-child { width: 100%; padding-right: 56px; }
    .workspace-header .page-header-actions { position: absolute; top: 0; right: 0; }
    .workspace-header h1, .page-header h1 { font-size: clamp(23px, 6vw, 30px); overflow-wrap: anywhere; }
    .workspace-header p { overflow-wrap: anywhere; }
    .workspace-stats, .clientes-stats { flex-wrap: wrap; gap: 16px !important; }
    .workspace-stats { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
    .workspace-stats .stat-item { min-width: 0; gap: 8px; align-items: center !important; min-height: 58px; padding: 10px 12px; border-radius: 14px; }
    .workspace-stats .stat-num { flex: 0 0 auto; margin: 0; font-size: 25px; }
    .stat-label { font-size: 10px; min-width: 0; overflow-wrap: anywhere; }
    .kb-trial { position: relative; inset: auto; width: 100%; margin-bottom: 0; z-index: auto; }
    .kb-trial-close { width: 44px; height: 44px; }

    .page-header-actions { flex-wrap: wrap; }
    .btn, .page-header-action, .card-icon, .taskboard-card-action, .clientes-pagination button { min-height: 44px; min-width: 44px;     padding: 12px 15px;}
    .btn.btn-sm{ padding: 12px 15px; }
    input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=hidden]), select, textarea, .ts-control { font-size: 12px !important; }
    .form-control, .form-select { min-height: 44px; }
    .modal .modal-dialog { margin: 0 !important; width: 100% !important; max-width: none !important; height: 100dvh; }
    .modal .modal-content { min-height: 100%; max-height: 100dvh; border-radius: 0; }
    .modal .modal-body { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
    .modal .modal-content > form { display: flex; flex-direction: column; min-height: 0; max-height: 100dvh; flex: 1; }
    .modal .modal-header, .modal .modal-footer { flex-shrink: 0; padding: 16px; }
    .modal .modal-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
    .modal .modal-footer .btn { flex: 1; }
    .mobile-filter-toggle { width: 100%; justify-content: space-between; margin-block: 10px; }
    .mobile-filters-collapsed { display: none !important; }
    .mobile-table { display: block; min-width: 0 !important; width: 100% !important; }
    .mobile-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .mobile-table colgroup { display: none; }
    .mobile-table tbody { display: grid; gap: 12px; width: 100%; }
    .mobile-table tbody tr { display: grid; width: 100%; padding: 14px 16px; border: 1px solid rgb(128 128 128 / 20%); border-radius: 18px; background: var(--secondary); }
    .mobile-table tbody tr[hidden] { display: none; }
    .mobile-table tbody td { width: 100% !important; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0 !important; font-size: 13px; border: 0; white-space: normal; overflow-wrap: anywhere; min-width: 0; text-align: right; }
    .mobile-table tbody td::before { content: attr(data-mobile-label); flex: 0 0 32%; text-align: left; font-size: 12px; font-weight: 600; opacity: .7; }
    .mobile-table tbody tr { position: relative; }
    .mobile-table tbody td:first-child:not([colspan]) { font-weight: 600; justify-content: flex-start; text-align: left; padding-right: 40px !important; margin-bottom: 6px; }
    .mobile-table tbody td:first-child::before { display: none; }
    .mobile-table .cliente-name-cell { gap: 10px; text-align: left; }
    .mobile-table tbody td.cliente-actions { position: absolute; top: 10px; right: 8px; width: 44px !important; padding: 0 !important; }
    .mobile-table tbody td.cliente-actions::before, .mobile-table tbody td.mobile-cell-empty { display: none; }
    .mobile-table .cliente-actions button { width: 44px; height: 44px; }
    .project-summary-users, .project-files-panel {     margin-bottom: 80px; }
    .task-name, .ticket-desc { font-size: 14px; }

    .mobile-table td > * { min-width: 0; max-width: 100%; }
    .mobile-table td[colspan] { display: block; text-align: center; }
    .mobile-table td[colspan]::before { display: none; }
    .clientes-table-wrap { overflow: visible; background: transparent; border: 0; border-radius: 0; }
    .mobile-board-picker { display: grid !important; gap: 8px; margin-bottom: 16px; }
    .leads-kanban, .taskboard-kanban { display: block; overflow: visible; }
    .lead-column, .taskboard-column { width: 100%; min-width: 0; }
    .mobile-board-hidden { display: none !important; }
    .mobile-card-status { width: 100%; margin-top: 12px; }
    .lead-card, .taskboard-card { overflow-wrap: anywhere; }
    .calendar-workspace { display: flex; flex-direction: column; }
    .calendar-agenda-panel { order: -1; width: 100%; min-width: 0; padding: 14px; }
    .calendar-sources-panel { width: 100%; }
    .fc .fc-toolbar { flex-wrap: wrap; gap: 12px; }
    .fc .fc-toolbar-title { font-size: 20px; }
    .fc .fc-button { min-height: 44px; }
    .fc .fc-list-event-title, .fc .fc-list-event-time { white-space: normal; overflow-wrap: anywhere; }
    .ticket-summary-actions, .calendar-header-actions { flex-wrap: wrap; gap: 10px; }
    .ticket-summary-card, .ticket-thread-card, .ticket-reply-card, .cliente-single-notes-card { padding: 16px; }
    .lead-single-description, .lead-single-notes { min-height: 0; }
    .mobile-details { display: block; margin-top: 14px; }
    .mobile-details > summary { display: list-item; min-height: 44px; padding-block: 12px; font-weight: 600; cursor: pointer; }
    .mobile-filter-toggle { display: flex !important; align-items: center; justify-content: flex-start; gap: 10px; padding: 14px 16px; min-height: 52px; border: 1px solid color-mix(in srgb, var(--primary) 12%, transparent); border-radius: 16px; color: var(--primary); background: var(--secondary); font: inherit; font-size: 14px; font-weight: 600; }
    .mobile-filter-chevron { margin-left: auto; font-size: 22px; line-height: 1; transition: transform .15s; }
    .mobile-filter-toggle[aria-expanded="true"] .mobile-filter-chevron { transform: rotate(180deg); }
    .mobile-filter-count { padding: 2px 8px; border-radius: 99px; background: var(--primary); color: var(--secondary); font-size: 12px; }
    .quotes-page .quotes-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; padding: 16px; margin-bottom: 16px; border-radius: 16px; background: var(--secondary); }
    .mobile-filter-field { display: grid; gap: 6px; min-width: 0; }
    .mobile-filter-label { font-size: 12px; font-weight: 600; }
    .mobile-filter-field[data-filter-field="entity"], .mobile-filter-field[data-filter-field="status"] { grid-column: 1 / -1; }
    .quotes-filters .form-control, .quotes-filters .form-select { width: 100%; min-width: 0; border-radius: 12px; padding: 10px 12px; }
    .quotes-filters input[type="date"] { min-width: 0; max-width: 100%; }
    .quotes-table.mobile-table tbody tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; padding: 18px; background: var(--secondary); }
    .quotes-table.mobile-table tbody td { min-width: 0; margin: 0; padding: 0 !important; text-align: left; justify-content: flex-start; overflow-wrap: break-word; }
    .quotes-table.mobile-table tbody td::before { display: none; }
    .quotes-table.mobile-table tbody td:nth-child(1) { order: 0; padding-right: 0 !important; font-size: 12px; opacity: .65; }
    .quotes-table.mobile-table tbody td:nth-child(1) a::before { content: '#'; }
    .quotes-table.mobile-table tbody td:nth-child(4) { order: 1; justify-content: flex-end; padding-right: 28px !important; font-size: 12px; opacity: .65; }
    .quotes-table.mobile-table tbody td:nth-child(3) { order: 2; grid-column: 1 / -1; font-size: 17px; line-height: 1.4; }
    .quotes-table.mobile-table tbody td:nth-child(2) { order: 3; grid-column: 1 / -1; padding-bottom: 4px !important; }
    .quotes-table.mobile-table .quote-entity-link { min-width: 0; width: 100%; }
    .quotes-table.mobile-table .quote-entity-link > div { min-width: 0; }
    .quotes-table.mobile-table tbody td:nth-child(5) { order: 4; grid-column: 1 / -1; display: block; }
    .quotes-table.mobile-table .quote-status-select { width: 100%; max-width: 100%; min-width: 0; border-radius: 12px; min-height: 46px; padding: 10px 36px 10px 12px; font-size: 14px !important; }
    .quotes-table.mobile-table tbody td:nth-child(6) { order: 5; grid-column: 1 / -1; font-size: 20px; padding-top: 6px !important; }
    .quotes-table.mobile-table tbody td:nth-child(7) { order: 6; grid-column: 1 / -1; padding-top: 10px !important; border-top: 1px solid color-mix(in srgb, var(--primary) 10%, transparent); }
    .quotes-table.mobile-table .quote-user-avatar { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; }
    .quotes-table.mobile-table .quote-user-avatar .user-avatar__image, .quotes-table.mobile-table .quote-user-avatar .user-avatar__initials { flex: 0 0 30px; }
    .quotes-table.mobile-table .quote-user-avatar .user-avatar__label { min-width: 0; white-space: normal; overflow-wrap: break-word; font-size: 12px; }
    .quotes-table.mobile-table tbody td[colspan] { grid-column: 1 / -1; }

}
