:root { --crm-ink: #102a43; --crm-blue: #086c9f; --crm-line: #dbe4ec; }
[hidden] { display: none !important; }
.crm-app-tabs, #crm-drawer-backdrop { display: none; }
.crm-drawer-close { display: none; }
.crm-table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
#crm-install-banner { position: fixed; z-index: 1029; left: 12px; right: 12px; bottom: calc(82px + env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; background: var(--crm-ink); color: white; padding: 13px; border-radius: 16px; box-shadow: 0 6px 24px #102a4333; font: 13px/1.4 system-ui, sans-serif; }
#crm-install-banner img { border-radius: 10px; }
#crm-install-banner div { flex: 1; }
#crm-install-banner strong, #crm-install-banner span { display: block; }
#crm-install-banner span { color: #d2e2ef; font-size: 12px; margin-top: 2px; }
#crm-install-open, #crm-native-install { border: 0; background: #fff; color: var(--crm-ink); font-weight: 700; border-radius: 9px; padding: 11px; min-height: 44px; }
#crm-install-dismiss, #crm-install-close { border: 0; background: transparent; color: inherit; font-size: 27px; min-width: 32px; min-height: 44px; }
#crm-install-dialog { border: 0; border-radius: 22px; padding: 28px; width: calc(100% - 32px); max-width: 440px; max-height: calc(100dvh - 40px); overflow: auto; color: var(--crm-ink); box-shadow: 0 18px 70px #0005; font: 16px/1.55 system-ui, sans-serif; }
#crm-install-dialog::backdrop { background: #102a43aa; }
#crm-install-dialog img { border-radius: 16px; margin-bottom: 20px; }
#crm-install-dialog h2 { font-size: 25px; line-height: 1.2; font-weight: 750; margin-bottom: 12px; }
#crm-install-dialog ol { padding-left: 22px; }
#crm-install-dialog li { padding: 8px 0 8px 5px; }
#crm-install-close { float: right; margin: -16px -14px 0 0; }
#crm-native-install { color: #fff; background: var(--crm-blue); width: 100%; }
.crm-install-note { color: #526777; font-size: 13px; border-top: 1px solid var(--crm-line); padding-top: 14px; margin-bottom: 0; }
#crm-install-status { font-size: 13px; color: #086c9f; }
#crm-install-dialog, #crm-install-banner { text-align: left; }
.crm-install-help { color: var(--crm-blue); font-weight: 600; }
#crm-offline-status { position: fixed; top: env(safe-area-inset-top); left: 0; right: 0; z-index: 1080; text-align: center; background: #7c3015; color: #fff; padding: 10px 16px; font: 14px/1.5 system-ui, sans-serif; }
@media (max-width: 767px) {
    html { scroll-padding-top: 70px; }
    body { background: #f3f6fa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--crm-ink); padding-top: env(safe-area-inset-top); }
    body.crm-has-tabs { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    body.crm-menu-open { overflow: hidden; }
    #wrapper { display: block !important; }
    #page-content-wrapper { min-width: 0 !important; width: 100% !important; max-width: 100%; }
    #page-content-wrapper > .container-fluid { padding: 16px; height: auto !important; overflow: visible !important; }
    #sidebar-wrapper { position: fixed; left: 0; top: env(safe-area-inset-top); bottom: calc(70px + env(safe-area-inset-bottom)); width: min(82vw, 310px); min-height: 0; margin-left: 0 !important; transform: translateX(-105%); z-index: 1040; overflow-y: auto; box-shadow: 8px 0 25px #102a4320; }
    #wrapper.toggled #sidebar-wrapper { transform: translateX(0); }
    #sidebar-wrapper .list-group-item { min-height: 48px; padding: 13px 20px; font-size: 15px; }
    .crm-drawer-close { display: block; border: 0; border-bottom: 1px solid var(--crm-line); background: #fff; color: var(--crm-blue); min-height: 48px; width: 100%; text-align: right; padding: 10px 18px; font-weight: 600; }
    #crm-drawer-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; border: 0; z-index: 1035; background: #102a4377; }
    .crm-app-tabs { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1041; min-height: 70px; padding: 7px max(6px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); background: #fff; border-top: 1px solid var(--crm-line); box-shadow: 0 -4px 20px #102a4308; }
    .crm-app-tabs a, .crm-app-tabs button { flex: 1; min-width: 0; min-height: 53px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: #526777; text-decoration: none; background: transparent; border: 0; border-radius: 10px; font: 600 11px/1.2 -apple-system, BlinkMacSystemFont, sans-serif; }
    .crm-app-tabs i { font-size: 20px; }
    .crm-app-tabs [aria-current="page"], .crm-app-tabs [aria-expanded="true"] { background: #e8f3fa; color: #086c9f; }
    .crm-tab-icon { position: relative; }
    .crm-tab-count { position: absolute; top: -7px; left: 14px; background: #bf253b; color: #fff; border: 2px solid #fff; border-radius: 10px; font-size: 9px; padding: 2px 4px; }
    #page-content-wrapper > .navbar { background: #fff !important; top: env(safe-area-inset-top); z-index: 1020; min-height: 60px; padding: 8px 16px; box-shadow: 0 2px 12px #102a4305; }
    .navbar > span { order: -1; margin-left: 0 !important; flex: 1; font-size: 17px !important; }
    #menu-toggle { display: none; }
    .navbar-toggler { min-height: 44px; min-width: 44px; border-color: var(--crm-line); }
    .navbar-collapse .navbar-nav { gap: 8px; padding: 8px 0; }
    .navbar-collapse .form-control { width: 100% !important; margin: 0 !important; }
    .navbar .nav-link { padding: 10px 4px; }
    input.form-control, select.form-control, textarea.form-control, .bootstrap-select > button { font-size: 16px !important; min-height: 44px; }
    .btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; white-space: normal; }
    .card { border: 1px solid var(--crm-line); border-radius: 14px; box-shadow: 0 3px 10px #102a4304; overflow: hidden; }
    .card-header { font-weight: 600; background: #fff; border-color: var(--crm-line); }
    .card h4 { font-size: 24px; }
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    .nav-tabs .nav-item { flex-shrink: 0; }
    .nav-tabs .nav-link { min-height: 44px; padding: 12px; }
    .quick-ranges { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 8px; }
    .quick-range-btn { flex: 0 0 auto; }
    body[data-crm-page="index"] #page-content-wrapper > .container-fluid > .row.mb-4 > .col { flex: 0 0 50%; max-width: 50%; padding: 6px; }
    body[data-crm-page="index"] .card .fa-3x { font-size: 25px; }
    body[data-crm-page="index"] .card .h4 { font-size: 22px; overflow-wrap: anywhere; }
    body[data-crm-page="index"] #page-content-wrapper > .container-fluid > .row.mb-4 > .col .col-4 { padding-left: 4px; padding-right: 4px; }
    body[data-crm-page="index"] #page-content-wrapper > .container-fluid > .row.mb-4 > .col .col-8 { padding-left: 2px; padding-right: 2px; }
    body[data-crm-page="index"] #page-content-wrapper > .container-fluid > .row.mb-4 > .col .h4 { font-size: 20px; white-space: nowrap; overflow-wrap: normal; }
    body[data-crm-page="index"] .card-body { padding: 16px 12px; }
    body[data-crm-page="index"] canvas { max-width: 100%; }
    #fbFilterForm .form-row { display: block; }
    #fbFilterForm .col-auto { padding: 0; }
    #fbFilterForm select { width: 100%; }
    #fbFilterForm .btn-group { display: flex; overflow-x: auto; padding-bottom: 4px; }
    #fbFilterForm .btn-group .btn { flex: 0 0 auto; white-space: nowrap; padding: 9px 12px; }
    .crm-card-table, .crm-card-table tbody { display: block; width: 100%; }
    .crm-card-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .crm-card-table tr { display: flex; flex-direction: column; background: #fff !important; border: 1px solid var(--crm-line); border-radius: 14px; margin-bottom: 14px; padding: 15px; box-shadow: 0 3px 10px #102a4304; }
    .crm-card-table tbody td { display: block; border: 0; padding: 6px 0; background: transparent !important; text-align: left !important; overflow-wrap: anywhere; font-size: 14px; }
    .crm-card-table td::before { content: attr(data-label); display: inline-block; width: 105px; padding-right: 10px; font-weight: 500; color: #62778a; vertical-align: top; font-size: 12px; }
    #fbLeadsTable td:nth-child(2) { order: -2; font-size: 18px; font-weight: 700; padding: 0 0 8px; }
    #fbLeadsTable td:nth-child(2)::before { display: none; }
    #fbLeadsTable td:nth-child(3) { order: -1; padding-top: 0; }
    #fbLeadsTable a[href^="tel:"] { display: inline-block; padding: 10px 12px; border-radius: 9px; background: #e8f3fa; color: #065d8b; font-weight: 600; }
    .crm-card-table td:last-child { border-top: 1px solid #edf1f5; margin-top: 8px; padding-top: 10px; }
    body[data-crm-page="users"] .crm-card-table td:nth-child(2) { order: -1; font-size: 19px; font-weight: 700; }
    body[data-crm-page="users"] .crm-card-table td:nth-child(2)::before { display: none; }
    body[data-crm-page="users"] .crm-card-table .badge { white-space: normal; margin: 2px; padding: 6px; }
    body[data-crm-page="users"] .crm-card-table td a { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
    .modal-dialog { margin: 10px; max-width: calc(100% - 20px); }
    .modal-content { border: 0; border-radius: 16px; }
    .modal-dialog-scrollable { height: calc(100dvh - 20px); }
    .modal-body { padding: 16px; }
    .modal-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); flex-wrap: wrap; gap: 6px; }
    .modal .mfg { flex-wrap: wrap; gap: 6px; }
    .modal .mfg .form-control-sm { max-width: 100%; }
    #popup_container .notice, #popup_container .error { max-width: calc(100vw - 32px); }
    body:not(.crm-has-tabs) #crm-install-banner { bottom: calc(16px + env(safe-area-inset-bottom)); }
    body[data-crm-page="login"] { min-height: 100dvh; height: auto; padding-bottom: calc(130px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { #sidebar-wrapper { transition: none !important; } }
@media print { .crm-app-tabs, #crm-install-banner, #crm-install-dialog, #crm-offline-status, .crm-install-help { display: none !important; } }
