/*
 * Shared components (UI optimization plan, Phase 2).
 * New component styles go here; legacy.css rules move here module by module in Phase 4.
 */

/* ---------- Tables ---------- */

/* 168 of 174 templates wrap tables in .table-responsive; smooth touch scrolling for them */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* ---------- Modals ---------- */

/* Bootstrap 4.0's footer is a no-wrap flex row, so 3+ buttons overflow on phones */
.modal-footer {
    flex-wrap: wrap;
    gap: var(--app-space-2);
}

/* Same specificity as Bootstrap's spacing rules, so the gap replaces them */
.modal-footer > :not(:first-child),
.modal-footer > :not(:last-child) {
    margin-right: 0;
    margin-left: 0;
}

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: var(--app-space-2);
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
    }
}

/* ---------- Status pill (Element/ui/status_badge, 'active' => bool) ---------- */

.app-status {
    display: inline-block;
    padding: 2px var(--app-space-2);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.app-status--active {
    color: var(--app-success);
    background-color: var(--app-success-bg);
}

.app-status--inactive {
    color: var(--app-text-muted);
    background-color: var(--app-gray-100);
}

/* ---------- Empty state (Element/ui/empty_state) ---------- */

.app-empty-state {
    padding: var(--app-space-6) var(--app-space-4);
    text-align: center;
    color: var(--app-text-muted);
}

.app-empty-state__icon {
    display: block;
    margin-bottom: var(--app-space-2);
    font-size: 2.5rem;
    color: var(--app-divider);
}

.app-empty-state__text {
    margin: 0;
}

/* ---------- Cards ---------- */

/* Edit pages and dashboards pull the card out to the content edges (was inline style="margin: 0 -15px;").
   Two classes so it beats .m-portlet's margin-bottom the way the inline style did. */
.m-portlet.app-card-bleed {
    margin: 0 -15px;
}

/* ---------- Dashboards (Franchisee and Exclusive plugins) ---------- */

/* Page wrapper: sits flush under the header (was inline style="margin-top: -15px;") */
.app-dashboard {
    margin-top: -15px;
}

/* Chart boxes: Morris and Chart.js size to the box, so it needs a fixed height */
.app-chart {
    width: 100%;
}

.app-chart--300 {
    height: 300px;
}

.app-chart--310 {
    height: 310px;
}

.app-chart--350 {
    height: 350px;
}

/* Filter row at the top of each tab (user, period, account dropdowns in col-md-* columns): below 768px the columns
   stack and the dropdowns touched. Gap only between two dropdown columns, so the empty date-range column adds none;
   the date range gets its own gap, which only shows once "Custom" makes it visible. */
@media (max-width: 767.98px) {
    .app-dashboard .light-border > .row > [class*="col-md-"]:has(select) + [class*="col-md-"]:has(select),
    .app-dashboard .light-border .line_chart_range {
        margin-top: var(--app-space-2);
    }
}

/* KPI target counters on the General tab (moved from a <style> block in Dashboard/index.ctp,
   scoped so its .fa-2x colour no longer leaks onto the rest of the page) */
.app-kpi .counter {
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 10px 0;
    background-color: #f5f5f5;
    border-radius: 5px;
}

/* Franchisee General tab: room for the performance line under each counter */
.app-kpi--tall .counter {
    min-height: 190px;
    cursor: pointer;
}

.app-kpi .count-title {
    margin-top: 10px;
    margin-bottom: 0;
    font-weight: normal;
    text-align: center;
}

.app-kpi .count-text {
    margin-top: 10px;
    margin-bottom: 0;
    font-size: 13px;
    font-weight: normal;
    text-align: center;
}

.app-kpi .performance-text {
    margin-top: 10px;
    margin-bottom: 0;
    font-size: 16px;
    font-weight: bold;
    font-style: oblique;
    text-align: center;
}

.app-kpi .fa-2x {
    display: table;
    float: none;
    margin: 0 auto;
    color: #ff5e00;
}

.app-kpi .custom_margin {
    margin-right: 50px;
    margin-left: 50px;
}

/* Finance tab: invoice count / amount next to the chart source select */
.app-invoice-summary p {
    margin-top: 1em;
}

.app-invoice-summary__divider {
    border-right: 1px solid #ccc;
}

.app-invoice-summary__value {
    color: crimson;
}

/* ---------- Advance Search panel (Element/ui/adv_search_open) ---------- */

/* Was inline style="min-width: 500px; margin-left: -300px;": centred-ish on the button, so it reached 200px (250px
   for --wide) right of the button's centre. The button sits at the right end of the list head, so the panel ran
   ~30px off the screen and cut off Apply. It now opens leftwards from the button's right edge. The selector matches
   the theme's .m-dropdown--align-center.m-dropdown--large rule (left: 50%) plus one class, so it wins. */
.m-dropdown.m-dropdown--align-center.m-dropdown--large .m-dropdown__wrapper.app-adv-search {
    min-width: 500px;
    left: auto;
    right: 0;
    margin-left: 0;
}

.m-dropdown.m-dropdown--align-center.m-dropdown--large .m-dropdown__wrapper.app-adv-search--wide {
    min-width: 700px;
}

.app-adv-search__apply {
    margin-right: 20px;
}

.app-adv-search__scroll {
    height: 65vh;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Phones and small tablets: the fixed 500/700px panel ran off the screen. Pin it under the header instead,
   full width, the way the header dropdowns already are (layout.css). */
@media (max-width: 768px) {
    .m-dropdown.m-dropdown--align-center.m-dropdown--large .m-dropdown__wrapper.app-adv-search {
        position: fixed;
        top: 64px;
        right: 8px;
        left: 8px;
        width: auto;
        min-width: 0;
        margin: 0;
    }

    .m-dropdown.m-dropdown--align-center.m-dropdown--large .m-dropdown__wrapper.app-adv-search .m-dropdown__arrow {
        display: none;
    }

    .app-adv-search__scroll {
        height: calc(100vh - 150px);
    }
}

/* ---------- Index page head with counters (.list-counter: 15 lists such as Lead, Contact, Franchisee; ui/list_tabs) ---------- */

/* legacy.css pins the counters with position: absolute !important at left 20-40% of the head, on top of the
   title and the buttons. Up to 991px they overlapped both: there the head becomes two rows instead, title and buttons
   on the first, the counters full width on the second (wrapping when there are many, e.g. Lead's stages). */
@media (max-width: 991.98px) {
    .m-portlet .m-portlet__head:has(.list-counter) {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        height: auto;
        padding-bottom: var(--app-space-3);
    }

    .m-portlet .m-portlet__head:has(.list-counter) > .m-portlet__head-caption {
        flex: 1 1 auto;
    }

    /* Its two lists (counters, buttons) become items of the head row, so the counters can take a row of their own */
    .m-portlet .m-portlet__head:has(.list-counter) > .m-portlet__head-tools {
        display: contents;
    }

    /* The buttons (Advance Search, Add, Import, Export; Lead also Missed / Todays Followups) are a display: table row in
       the theme, which can't wrap: Lead's six ran to 545px on a phone, so the page zoomed out and still cut off Import
       and Export. A wrapping row instead, right-aligned next to the title. */
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__head-tools > .m-portlet__nav:not(.list-counter) {
        order: 2;
        display: flex;
        flex: 1 1 auto;
        flex-wrap: wrap;
        align-items: flex-start; /* buttons line up at the top; Import is taller (its "Sample file" link is under it) */
        justify-content: flex-end;
        gap: var(--app-space-2);
        min-width: 0;
        margin-left: auto;
    }

    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__head-tools > .m-portlet__nav:not(.list-counter) > .m-portlet__nav-item {
        display: block;
        margin: 0;
        padding: 0;
    }

    /* Its 26px top margin centred the icon against neighbours in the theme's table row; top-aligned here, it isn't needed */
    .m-portlet .m-portlet__head:has(.list-counter) .app-import__btn {
        margin-top: 0;
    }

    /* Selector as specific as the theme's .m-portlet__head-tools .m-portlet__nav { display: table } plus one class */
    .m-portlet .m-portlet__head .m-portlet__head-tools .m-portlet__nav.list-counter {
        position: static !important; /* beats legacy's position: absolute !important */
        order: 3;
        flex: 0 0 100%;
        display: flex;
        flex-wrap: wrap;
        gap: var(--app-space-2);
        margin: var(--app-space-2) 0 0;
    }

    .m-portlet .m-portlet__head .m-portlet__head-tools .m-portlet__nav.list-counter > a,
    .m-portlet .m-portlet__head .m-portlet__head-tools .m-portlet__nav.list-counter > li {
        flex: 1 1 0;
        min-width: 96px;
    }

    .m-portlet .m-portlet__head .m-portlet__head-tools .m-portlet__nav.list-counter .m-portlet__nav-item {
        display: block !important; /* legacy: inline-block !important */
        margin: 0;
        height: 100%;
        text-align: center;
    }
}

/* Phones: next to the title the buttons only had ~200px and wrapped into a narrow column; give them their own row */
@media (max-width: 575.98px) {
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__head-tools > .m-portlet__nav:not(.list-counter) {
        flex-basis: 100%;
        justify-content: flex-start;
        gap: 6px;
        margin-top: var(--app-space-2);
    }

    /* Slimmer Advance Search, so Add / Import / Export fit on its row at 375px */
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__head-tools .m-dropdown__toggle.btn-grey-md {
        padding-right: var(--app-space-4) !important;
        padding-left: var(--app-space-4) !important;
    }

    /* A fixed layout instead of wrapping wherever the width happens to break: Lead's Missed / Todays Followups as two
       equal tiles on the first row, then Advance Search filling the second row before the icon buttons */
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .missed-followups,
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .todays-followups {
        flex: 1 1 calc(50% - 3px);
        padding: 0 !important; /* legacy: 0 15px !important */
    }

    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .missed-followups > a,
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .todays-followups > a {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: 40px;
        border-radius: var(--app-radius);
        background: var(--app-gray-100);
        white-space: nowrap;
    }

    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .missed-followups br,
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .todays-followups br {
        display: none; /* "Missed Followups" on one line */
    }

    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .missed-followups .m-badge,
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .todays-followups .m-badge {
        position: static; /* legacy pins it over the text's corner */
    }

    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .m-dropdown {
        flex: 1 1 auto;
    }

    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__nav > .m-dropdown > .m-dropdown__toggle {
        width: 100%;
    }

    /* Three counters to a row (Lead, Franchisee, ...) */
    .m-portlet .m-portlet__head .m-portlet__head-tools .m-portlet__nav.list-counter > a,
    .m-portlet .m-portlet__head .m-portlet__head-tools .m-portlet__nav.list-counter > li {
        min-width: 80px;
    }
}

/* Narrow phones (360px): slimmer still, so Export stays on the Advance Search row */
@media (max-width: 389.98px) {
    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__head-tools .m-dropdown__toggle.btn-grey-md {
        padding-right: 10px !important;
        padding-left: 10px !important;
    }

    .m-portlet .m-portlet__head:has(.list-counter) .m-portlet__head-tools > .m-portlet__nav:not(.list-counter) {
        gap: 4px;
    }

    /* The "Sample file" label sets the Import item's width */
    .m-portlet .m-portlet__head:has(.list-counter) .app-import__sample {
        font-size: 0.9rem;
    }
}

/* 992px and up the counters stay in the head row, but sat flush with its top edge and ran into (from 1500px past)
   the divider, with the table header 5px under it. A taller head with the counters centred, and a gap before the
   table. */
@media (min-width: 992px) {
    /* relative: the counters' top: 50% (and legacy's left: 20-40%) are then measured from the head, which is as wide
       as the card they were measured from before */
    .m-portlet .m-portlet__head:has(.list-counter) {
        position: relative;
        height: 96px;
    }

    .m-portlet .m-portlet__head .m-portlet__head-tools .m-portlet__nav.list-counter {
        top: 50%;
        transform: translateY(-50%);
    }

    .m-portlet .m-portlet__head:has(.list-counter) ~ .m-portlet__body {
        margin-top: var(--app-space-3);
    }
}

/* ---------- Lead list (plugins/Lead/src/Template/Lead/index.ctp) ---------- */

/* Advance Search tag fields: no per-tag remove button (was a <style> block in the page) */
.app-lead-list .bootstrap-tagsinput .tag [data-role="remove"] {
    display: none;
}

/* "B" brokerage badge, third state next to legacy.css's -red / -green */
.brokerage-confirm-orange {
    background-color: #bf570e;
}

/* ---------- Franchisee picker above lists (select.all_list_for_franchisee, select2 multiple) ----------
   User, Contact, Lead, Opportunity, Property and Role lists. Select2 puts its box right after the <select>, and its
   result list in <body> as #select2-all-list-for-franchisee-results, which is what scopes the dropdown rules.
   Multiple only: the Permission page's single-choice "Select Franchisee" has the same class and stays plain, like the
   "Select Role" under it. */

select.all_list_for_franchisee[multiple] + .select2-container {
    border: none; /* legacy .bottom-bordered-form .select2-container: underline */
}

select.all_list_for_franchisee[multiple] + .select2-container .select2-selection--multiple {
    min-height: 44px;
    padding: 5px 12px 5px 42px;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236f727d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21h18M5 21V7l7-4 7 4v14M9 21v-6h6v6M9 10h.01M15 10h.01'/%3E%3C/svg%3E") no-repeat 14px center;
    box-shadow: 0 1px 15px 1px rgba(69, 65, 78, 0.08);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select.all_list_for_franchisee[multiple] + .select2-container--focus .select2-selection--multiple,
select.all_list_for_franchisee[multiple] + .select2-container--open .select2-selection--multiple {
    border-color: var(--app-brand-dark);
    box-shadow: 0 0 0 3px var(--app-focus-ring);
}

select.all_list_for_franchisee[multiple] + .select2-container .select2-selection__rendered {
    display: flex !important; /* theme: display: inline */
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 0 !important;
}

/* Selected franchisees: dark pills, like the app's primary buttons */
select.all_list_for_franchisee[multiple] + .select2-container .select2-selection__choice {
    display: inline-flex;
    align-items: center;
    margin: 0 !important;
    padding: 4px 10px 4px 8px !important;
    border: none !important;
    border-radius: 999px !important;
    background: var(--app-brand-dark) !important;
    color: #ffffff !important;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
}

select.all_list_for_franchisee[multiple] + .select2-container .select2-selection__choice__remove {
    order: 2; /* the x after the name */
    margin: 0 0 0 6px !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 15px;
    font-weight: 400;
}

select.all_list_for_franchisee[multiple] + .select2-container .select2-selection__choice__remove:hover {
    color: #ffffff !important;
}

select.all_list_for_franchisee[multiple] + .select2-container .select2-search--inline,
select.all_list_for_franchisee[multiple] + .select2-container .select2-search__field {
    margin: 0 !important;
    font-size: 14px;
}

/* Same height as a chip row, so the placeholder sits in the middle of the box */
select.all_list_for_franchisee[multiple] + .select2-container .select2-search__field {
    height: 32px !important;
    line-height: 32px;
}

select.all_list_for_franchisee[multiple] + .select2-container .select2-search__field::placeholder {
    color: var(--app-text-muted);
}

/* The open list */
.select2-dropdown:has(#select2-all-list-for-franchisee-results[aria-multiselectable="true"]) {
    margin-top: 6px;
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius-lg) !important;
    box-shadow: var(--app-shadow);
    overflow: hidden;
}

#select2-all-list-for-franchisee-results[aria-multiselectable="true"] .select2-results__option {
    position: relative;
    padding: 10px 36px 10px 14px;
    font-size: 14px;
}

#select2-all-list-for-franchisee-results[aria-multiselectable="true"] .select2-results__option--highlighted {
    background: var(--app-gray-100) !important;
    color: var(--app-brand-dark) !important;
}

#select2-all-list-for-franchisee-results[aria-multiselectable="true"] .select2-results__option[aria-selected="true"] {
    background: transparent;
    color: var(--app-brand-dark);
    font-weight: 600;
}

#select2-all-list-for-franchisee-results[aria-multiselectable="true"] .select2-results__option[aria-selected="true"]::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 6px;
    height: 11px;
    margin-top: -7px;
    border: solid var(--app-brand-dark);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Single-choice franchisee select styled the same way (Role list's "Select Franchisee", bootstrap-select). Give the
   <select> the class app-franchisee-select: bootstrap-select copies it onto its wrapper div. Selectors carry
   .bottom-bordered-form-strength (and !important where legacy has it) to beat the underline style forms get. */
.bootstrap-select.app-franchisee-select {
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
}

.bootstrap-select.app-franchisee-select > .dropdown-toggle.btn {
    height: 44px;
    padding: 0 40px 0 42px !important;
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius-lg) !important;
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236f727d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21h18M5 21V7l7-4 7 4v14M9 21v-6h6v6M9 10h.01M15 10h.01'/%3E%3C/svg%3E") no-repeat 14px center !important;
    box-shadow: 0 1px 15px 1px rgba(69, 65, 78, 0.08) !important;
    color: var(--app-brand-dark) !important;
    font-size: 14px;
    font-weight: 600;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bootstrap-select.app-franchisee-select > .dropdown-toggle.bs-placeholder {
    color: var(--app-text-muted) !important;
    font-weight: 400;
}

.bootstrap-select.app-franchisee-select > .dropdown-toggle .filter-option {
    line-height: 42px;
}

.bootstrap-select.app-franchisee-select.open > .dropdown-toggle.btn,
.bootstrap-select.app-franchisee-select.show > .dropdown-toggle.btn,
.bootstrap-select.app-franchisee-select > .dropdown-toggle.btn:focus {
    border-color: var(--app-brand-dark) !important;
    box-shadow: 0 0 0 3px var(--app-focus-ring) !important;
    outline: none !important;
}

.bootstrap-select.app-franchisee-select > .dropdown-menu {
    margin-top: 6px;
    padding: 6px 0 0;
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius-lg) !important;
    box-shadow: var(--app-shadow) !important;
    overflow: hidden;
}

.bootstrap-select.app-franchisee-select .bs-searchbox {
    padding: 6px 12px 8px;
}

.bootstrap-select.app-franchisee-select .bs-searchbox .form-control {
    height: 38px;
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius) !important;
    box-shadow: none !important;
}

.bootstrap-select.app-franchisee-select .bs-searchbox .form-control:focus {
    border-color: var(--app-brand-dark) !important;
}

.bootstrap-select.app-franchisee-select .dropdown-menu li a {
    position: relative;
    padding: 10px 36px 10px 14px !important;
    font-size: 14px;
}

.bootstrap-select.app-franchisee-select .dropdown-menu li a:hover,
.bootstrap-select.app-franchisee-select .dropdown-menu li.active a {
    background: var(--app-gray-100) !important;
    color: var(--app-brand-dark) !important;
}

.bootstrap-select.app-franchisee-select .dropdown-menu li.selected a {
    background: transparent;
    color: var(--app-brand-dark) !important;
    font-weight: 600;
}

/* The first entry ("Select Franchisee") clears the filter: muted, like a placeholder */
.bootstrap-select.app-franchisee-select .dropdown-menu li:first-child a {
    color: var(--app-text-muted) !important;
}

/* ---------- Add / edit pages: one box, like the list pages' card ---------- */

/* All 54 add/edit pages wrap their toolbar, summary card and tab card in .remove-m-content-padding (the toolbar is
   its direct child; reports, dashboards and others use the class without one, so they are left alone). Those blocks
   ran edge to edge (margin 0 -15px, toolbar pulled up -15px under the header), each with its own shadow. Now the
   wrapper is the box, white with the list card's shadow, 15px in from the edges and from the header like a list
   card, and the blocks sit inside it. */
.remove-m-content-padding:has(> .form-top-action) {
    background-color: #ffffff;
    box-shadow: 0 1px 15px 1px rgba(69, 65, 78, 0.08);
}

.remove-m-content-padding:has(> .form-top-action) > .form-top-action {
    margin: 0;
}

.remove-m-content-padding:has(> .form-top-action) > .m-portlet {
    margin-right: 0;
    margin-left: 0;
    box-shadow: none;
}

.remove-m-content-padding:has(> .form-top-action) > .m-portlet:last-child {
    margin-bottom: 0;
}

/* ---------- Add / edit toolbar (ui/record_toolbar, .form-top-action) ---------- */

/* Back To List sat ~5px from the left edge and the close x as close to the right: inner padding, so the first item
   lines up with the tabs and card content under it */
.form-top-action {
    padding-right: var(--app-space-5);
    padding-left: var(--app-space-5);
}

@media (max-width: 767.98px) {
    .form-top-action {
        padding-right: var(--app-space-3);
        padding-left: var(--app-space-3);
    }
}

/* ---------- Add / edit pages on phones (ui/record_toolbar, summary card, record tabs) ---------- */

/* Radio lists that FormHelper renders as bare <label><input>Yes</label> pairs (no Metronic .m-radio styling) inside
   .m-radio-inline ran together as "◯Yes◯No" at every width */
.m-radio-inline > label:not(.m-radio) {
    margin-right: var(--app-space-4);
}

.m-radio-inline > label:not(.m-radio) > input[type="radio"] {
    margin-right: var(--app-space-1);
}

@media (max-width: 767.98px) {
    /* Toolbar: its col-md-* columns are 100% wide below 768px, so the right group (Active, close, navigator) always
       took a row of its own under Back / Save. Share the row; the right group still wraps if it doesn't fit. */
    .form-top-action {
        align-items: center;
    }

    .form-top-action > [class*="col-md-"]:first-child {
        flex: 1 1 auto;
        width: auto;
    }

    .form-top-action > [class*="col-md-"]:last-child:not(:first-child) {
        flex: 0 0 auto;
        width: auto;
    }

    /* Summary card (photo, name, contact lines; Created/Modified/... on the right): legacy's 50px side padding, and
       the stats floated right on a row of their own, far from the name */
    .form-accordion-container {
        padding: 0 var(--app-space-4);
    }

    .form-accordion-container .form-row-one-right-ul.float-right {
        float: none !important; /* Bootstrap's .float-right is !important */
        padding-top: var(--app-space-2);
    }

    .form-accordion-container .form-row-one-right-ul .m-nav__item:first-child {
        padding-left: 0 !important; /* legacy: padding 5px 20px !important */
    }

    /* Record tabs (Company Info, Financial Details, ...): they wrapped into uneven rows. One row that scrolls
       sideways instead. The head is a display: table, whose cells grow with their content, so it becomes a block. */
    .m-portlet .m-portlet__head:has(> .m-portlet__head-tools > .m-tabs-line) {
        display: block;
        height: auto;
    }

    .m-portlet .m-portlet__head:has(> .m-portlet__head-tools > .m-tabs-line) > .m-portlet__head-tools {
        display: block;
    }

    .m-portlet .m-portlet__head .m-portlet__head-tools > .nav.m-tabs-line {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .m-portlet .m-portlet__head .m-portlet__head-tools > .nav.m-tabs-line::-webkit-scrollbar {
        display: none;
    }

    .m-portlet .m-portlet__head .m-portlet__head-tools > .nav.m-tabs-line .m-tabs__item {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

/* ---------- Lead add / edit ---------- */

/* Short sub-card heads (Followup, Matching, Favorites…; were inline style="height: 1.5rem;").
   Two classes to beat the theme's .m-portlet .m-portlet__head height. */
.m-portlet__head.app-portlet-head--compact {
    height: 1.5rem;
}

/* Header strip: the Owner cell, long names wrap inside 150px (was inline) */
.app-lead-owner {
    width: 150px;
    word-break: break-all;
}

/* Appointment / matching-property lists (moved from a <style> block in Lead/edit.ctp) */
.custom_scrollbar {
    height: 300px;
    overflow-y: scroll;
}

.custom_scrollbar::-webkit-scrollbar-track {
    background-color: #f5f5f5;
}

.custom_scrollbar::-webkit-scrollbar {
    width: 5px;
    background-color: #f5f5f5;
}

.custom_scrollbar::-webkit-scrollbar-thumb {
    background-color: #000000;
    border: 2px solid #555555;
}

/* ---------- Import button (Element/ui/import_button) ---------- */

.app-import {
    text-align: center;
}

/* Top margin = the pill's height + gap below the button (22 + 4px), so the button lines up with its neighbours */
.app-import__btn {
    margin-top: 26px;
}

/* "Sample file" under the Import button */
.app-import__sample {
    /* table: on its own line under the button, but only as wide as the text, centred by the auto margins */
    display: table;
    margin: 4px auto 0;
    padding: 2px 0;           /* keeps the 22px height the button's top margin balances */
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--app-brand-dark);
    white-space: nowrap;
    text-decoration: none;
}

.app-import__sample:hover,
.app-import__sample:focus {
    color: var(--app-brand-dark);
    text-decoration: underline;
}

.app-import__sample .la {
    margin-right: 4px;
    font-size: 1.1rem;
    font-weight: 700;
    vertical-align: -2px;
}


/* ---------- Invoice modal (Property and Opportunity Element/invoice_modal) ---------- */

/* One invoice line box (moved from a <style> block in the modal; Opportunity's copy is identical) */
.inv_new_div {
    margin-bottom: 12px;
    padding-left: 15px;
    border: 1px solid var(--app-gray-300);
    border-radius: 6px;
}

/* ---------- Property inspection OTP modal: animated checklist (moved from Property/Element/otp_modal.ctp) ---------- */

.checklist span:before, .checklist span:after {
    content: "";
    display: inline-block;
    background: #fff;
    width: 0;
    height: 0.2rem;
    position: absolute;
    transform-origin: 0% 0%;
}

.checklist {
    position: relative;
    height: auto;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.checklist input {
    display: none;
}

.checklist input:checked ~ span {
    background: #000000;
    border-color: #000000;
}

.checklist input:checked ~ span:before {
    width: 1rem;
    height: 0.15rem;
    transition: width 0.1s;
    transition-delay: 0.3s;
}

.checklist input:checked ~ span:after {
    width: 0.4rem;
    height: 0.15rem;
    transition: width 0.1s;
    transition-delay: 0.2s;
}

.checklist label {
    padding-left: 2rem;
    position: relative;
    z-index: 2;
    cursor: pointer;
    margin-bottom: 0;
}

.checklist span {
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid #ccc;
    position: absolute;
    left: 0;
    transition: all 0.2s;
    z-index: 1;
    box-sizing: content-box;
}

.checklist span:before {
    transform: rotate(-55deg);
    top: 1rem;
    left: 0.37rem;
}

.checklist span:after {
    transform: rotate(35deg);
    bottom: 0.35rem;
    left: 0.2rem;
}

/* ---------- Property list (plugins/Property/src/Template/Property/index.ctp) ---------- */

/* Advance Search tag fields: no per-tag remove button (was a <style> block in the page, as on the Lead list) */
.app-property-list .bootstrap-tagsinput .tag [data-role="remove"] {
    display: none;
}

/* Marketing status badge with a hover tooltip (Property and Project lists; was a <style> block in each) */
.marketing-status {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    color: white;
    cursor: pointer;
}

.marketing-status .tooltip-text {
    position: absolute;
    bottom: 125%;
    left: 50%;
    z-index: 1;
    width: 150px;
    margin-left: -60px;
    padding: 5px;
    text-align: center;
    color: #fff;
    background-color: black;
    border-radius: 5px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.marketing-status:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ---------- Property edit toolbar ---------- */

/* Items that sit a little lower than the rest (were inline padding-top … !important; legacy.css sets the
   items' padding with !important too, hence the three classes) */
.form-right-action-ul .m-nav__item.app-nav-item--pt-5 {
    padding-top: 5px !important;
}

.form-right-action-ul .m-nav__item.app-nav-item--pt-7 {
    padding-top: 7px !important;
}

.form-right-action-ul .m-nav__item.app-nav-item--pt-8 {
    padding-top: 8px !important;
}

/* "Live On Web" box when the property is live. Was inline; !important keeps it ahead of the theme's solid-checkbox
   colours (up to four classes deep), as the inline style was. */
.app-live-on {
    background-color: #6fdfa6 !important;
}

/* ---------- Property edit: gallery ---------- */

/* Delete "x" pinned to the thumbnail's right edge (was inline right: 0px) */
.app-gallery-delete {
    right: 0;
}

/* Thumbnail drawn as a stretched background; the image URL stays inline per image */
.app-gallery-thumb {
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* ---------- Project list (plugins/Project/src/Template/Project/index.ctp) ---------- */

/* Advance Search tag fields: no per-tag remove button (was a <style> block in the page, as on Lead/Property) */
.app-project-list .bootstrap-tagsinput .tag [data-role="remove"] {
    display: none;
}

/* ---------- Project add / edit / units ---------- */

/* Project logo preview (was a <style> block in add/edit; Account's same-id image is sized differently, hence the scope) */
.app-project-form #selectGroupImage {
    height: 70px !important;
}

/* Sold units in the units list (toggled by edit_unit.js; was a <style> block in list_units.ctp) */
.sold_units_clr {
    color: var(--app-danger) !important;
}

/* Project edit: developer's website / social links (were inline; long URLs break, colour stays on hover) */
a.app-link-plain,
a.app-link-plain:hover {
    word-break: break-all;
    color: #575962;
}

/* Project units list: unit chips per floor/facing (were inline) */
.app-unit-chip {
    display: inline-block;
    padding: 0 5px;
}

/* ---------- Opportunity list (plugins/Opportunity/src/Template/Opportunity/index.ctp) ---------- */

/* Were a <style> block in the page: space between AND/OR radios, and no per-tag remove button in Advance Search */
.app-opportunity-list .m-radio--solid {
    margin-right: 10px;
}

.app-opportunity-list .bootstrap-tagsinput .tag [data-role="remove"] {
    display: none;
}

/* ---------- Account list (plugins/Account/src/Template/Account/index.ctp) ---------- */

/* Was a <style> block in the page: no per-tag remove button in Advance Search */
.app-account-list .bootstrap-tagsinput .tag [data-role="remove"] {
    display: none;
}

/* Account form (plugins/Account/src/Template/Account/{add,edit}.ctp): group logo preview (was a <style> block in both) */
.app-account-form #selectGroupImage {
    max-height: 100px !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* Google Places suggestions above Bootstrap modals (Google's default is 1000, the modal 1050). Was a <style> block in
   Account's opportunity and property modals; it applied page-wide once they were on the page. */
.pac-container {
    z-index: 1050;
}

/* ---------- Contact list (plugins/Contact/src/Template/Contact/index.ctp) ---------- */

/* Was a <style> block in the page: no per-tag remove button in Advance Search */
.app-contact-list .bootstrap-tagsinput .tag [data-role="remove"] {
    display: none;
}

/* ---------- Appointment list and calendars (plugins/Appointment/src/Template) ---------- */

/* Activity-type chips: the All / Appointment / Follow Up / Task filter buttons and the calendar legend.
   Were inline style="background-color: …; color: #ffffff;". !important keeps them winning over the theme's
   a:hover / code / .btn colours in every state, as the inline style did. */
.app-type-chip {
    color: #ffffff !important;
}

.btn.app-type-chip {
    cursor: pointer;
}

.app-type-chip--all { background-color: var(--app-type-all) !important; }
.app-type-chip--appointment { background-color: var(--app-type-appointment) !important; }
.app-type-chip--followup { background-color: var(--app-type-followup) !important; }
.app-type-chip--task { background-color: var(--app-type-task) !important; }

/* Calendar card: wide side padding around FullCalendar (was inline style="padding: 10px 50px;") */
.m-portlet.app-calendar-card {
    padding: 10px 50px;
}

/* Phones: the 50px (plus the card body's own padding) left FullCalendar a 190-250px strip in the middle */
@media (max-width: 767.98px) {
    .m-portlet.app-calendar-card {
        padding: 0;
    }

    .m-portlet.app-calendar-card > .m-portlet__body {
        padding: var(--app-space-3);
    }
}

/* ---------- Invoice lists (plugins/Invoice/src/Template) ---------- */

/* Active tab of ui/list_tabs (Customer / Master Franchisee / Franchisor Admin invoices and receipts; was inline
   style="background: antiquewhite;"). Three classes so it beats legacy's .li-nurturing background, as the inline style did. */
.list-counter .m-portlet__nav-item.app-list-tab--active {
    background: antiquewhite;
}

/* ---------- Reports (plugins/Report/src/Template) ---------- */

/* Page wrapper: flush under the header (was inline style="margin-top: -15px;"; the Opportunity report used -35px) */
.app-report {
    margin-top: -15px;
}

.app-report.app-report--tight {
    margin-top: -35px;
}

/* Filter-bar buttons (Apply / Export / Search; was inline style="padding: 0.45rem 1rem !important;" on 24 buttons) */
.btn.app-report__btn {
    padding: 0.45rem 1rem !important;
}

/* Phones: Clear Filters, Export and Apply each sit in their own col-md-1, which is a full-width row below 768px, so
   they stacked. Those columns shrink to their button and share a line. Keyed on .app-report__btn (Export / Apply in
   all 12 report filter bars; not every report has the .app-report wrapper). */
@media (max-width: 767.98px) {
    .row:has(.app-report__btn) > [class*="col-md-"]:has(.app-report__btn),
    .row:has(.app-report__btn) > [class*="col-md-"]:has(.btn-delete-selected) {
        flex: 0 0 auto;
        width: auto;
        max-width: none;
    }
}

/* Were <style> blocks copied into the reports, in four variants: AND/OR radio spacing (Opportunity, General, Finance) and
   typeahead menus as floating panels (Opportunity, Lead, Property, activity report). Each page's wrapper gets the
   modifier for the rules its block had. Scoped to the report, so typeahead menus elsewhere keep their look (the
   copies applied page-wide while a report was open). */
.app-report--radio-gap .m-radio--solid {
    margin-right: 10px;
}

.app-report--typeahead .tt-menu {
    background: #ffffff;
    box-shadow: 0 0 15px 1px rgba(69, 65, 78, 0.2);
}

.app-report--typeahead .tt-menu .tt-suggestion {
    padding: 5px 15px !important;
    font-size: 1rem;
}

/* ---------- Users (plugins/User/src/Template) ---------- */

/* Show/hide-password eye inside a password field (Change Password; User add/edit). Was inline style="position: absolute; …". */
.app-password-toggle {
    position: absolute;
    top: 40%;
    right: 10px;
    cursor: pointer;
}

.app-password-toggle--high {
    top: 20%;
}

/* ---------- Permission (plugins/Permission/src/Template/Permission/index.ctp) ---------- */

/* Each module card's "check all" box beside its title. Was inline style on the label. */
.app-permission-check-all {
    margin-left: 10px;
    margin-top: 17px;
}
