@media (min-width: 1181px) {
    .tjc-smi {
        display: none !important;
    }
}

.tjc-smi-overlay[hidden] {
    display: none !important;
}

@media (max-width: 1180px) {
    html.tjc-smi-lock,
    html.tjc-smi-lock body {
        overflow: hidden;
    }

    .tjc-sales-mobile-items-active > .tjc-sales-items-head,
    .tjc-sales-mobile-items-active > .tjc-quote-item-rows,
    .tjc-sales-mobile-items-active > .tjc-sales-add-line,
    .tjc-sales-mobile-items-active > .tjc-muted-small,
    .tjc-sales-mobile-items-active > datalist,
    .tjc-sales-mobile-items-active > template {
        display: none !important;
    }

    .tjc-smi {
        border: 1px solid rgba(16, 42, 67, 0.12);
        border-radius: 28px;
        background: #fff;
        box-shadow: 0 16px 38px rgba(31, 54, 83, 0.08);
        padding: 18px;
        margin: 18px 0;
    }

    .tjc-smi-head,
    .tjc-smi-total-line {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
    }

    .tjc-smi-title {
        color: #64748b;
        font-size: 0.86rem;
        font-weight: 800;
        letter-spacing: 0.16em;
        text-transform: uppercase;
    }

    .tjc-smi-link {
        border: 0;
        background: transparent;
        color: #0ea5e9;
        font: inherit;
        font-weight: 800;
        padding: 0;
    }

    .tjc-smi-list {
        margin-top: 18px;
    }

    .tjc-smi-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        border-bottom: 1px solid rgba(15, 23, 42, 0.12);
        padding: 0;
    }

    .tjc-smi-row.is-reorder {
        grid-template-columns: 42px 1fr auto;
        align-items: center;
        padding: 10px 0;
    }

    .tjc-smi-row-main {
        width: 100%;
        min-height: 74px;
        border: 0;
        background: transparent;
        color: #0f172a;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        text-align: left;
        padding: 15px 0;
        font: inherit;
    }

    .tjc-smi-row-left,
    .tjc-smi-row-right {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .tjc-smi-row-left strong,
    .tjc-smi-row-right strong {
        color: #0f172a;
        font-size: 1.02rem;
        line-height: 1.25;
    }

    .tjc-smi-row-left strong,
    .tjc-smi-row-left span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tjc-smi-row-left span,
    .tjc-smi-row-right span {
        color: #64748b;
        font-size: 0.84rem;
        margin-top: 4px;
    }

    .tjc-smi-row-right {
        align-items: flex-end;
        text-align: right;
        white-space: nowrap;
    }

    .tjc-smi-delete {
        width: 34px;
        height: 34px;
        border-radius: 999px;
        border: 0;
        color: #fff;
        background: #ef4444;
        font-size: 1.45rem;
        font-weight: 900;
        line-height: 1;
    }

    .tjc-smi-move {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .tjc-smi-move button {
        width: 34px;
        height: 30px;
        border-radius: 10px;
        border: 1px solid rgba(15, 23, 42, 0.14);
        background: #f8fafc;
        color: #0f172a;
        font-weight: 900;
    }

    .tjc-smi-move button:disabled {
        opacity: 0.35;
    }

    .tjc-smi-add {
        border: 0;
        background: transparent;
        color: #0ea5e9;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 18px 0;
        width: 100%;
        text-align: left;
        font: inherit;
    }

    .tjc-smi-add span {
        align-items: center;
        background: #0ea5e9;
        border-radius: 999px;
        color: #fff;
        display: inline-flex;
        font-size: 1.55rem;
        font-weight: 900;
        height: 38px;
        justify-content: center;
        line-height: 1;
        width: 38px;
    }

    .tjc-smi-add strong {
        font-size: 1rem;
    }

    .tjc-smi-totals {
        border-top: 1px solid rgba(15, 23, 42, 0.12);
        margin-top: 2px;
        padding-top: 16px;
    }

    .tjc-smi-total-line {
        color: #0f172a;
        font-size: 1rem;
        padding: 9px 0;
    }

    .tjc-smi-total-line strong {
        font-size: 1.02rem;
    }

    .tjc-smi-overlay {
        position: fixed;
        inset: 0;
        z-index: 999999;
        background: #f8fbff;
        color: #0f172a;
        overflow: auto;
        padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
    }

    .tjc-smi-panel {
        max-width: 760px;
        margin: 0 auto;
    }

    .tjc-smi-nav {
        align-items: center;
        display: grid;
        grid-template-columns: 52px 1fr 52px;
        gap: 10px;
        margin-bottom: 22px;
        text-align: center;
    }

    .tjc-smi-nav strong {
        font-size: 1.18rem;
        font-weight: 900;
    }

    .tjc-smi-round,
    .tjc-smi-done {
        align-items: center;
        border: 1px solid rgba(15, 23, 42, 0.1);
        border-radius: 999px;
        display: inline-flex;
        font-size: 2rem;
        font-weight: 500;
        height: 48px;
        justify-content: center;
        line-height: 1;
        width: 48px;
    }

    .tjc-smi-round {
        background: #fff;
        color: #0f172a;
    }

    .tjc-smi-rotate {
        transform: rotate(45deg);
    }

    .tjc-smi-done {
        background: #0ea5e9;
        border-color: #0ea5e9;
        color: #fff;
        font-size: 1.65rem;
        justify-self: end;
    }

    .tjc-smi-search,
    .tjc-smi-manual,
    .tjc-smi-editor-card {
        background: #fff;
        border: 1px solid rgba(16, 42, 67, 0.12);
        border-radius: 24px;
        box-shadow: 0 14px 36px rgba(31, 54, 83, 0.08);
    }

    .tjc-smi-search {
        padding: 10px 14px;
        margin-bottom: 14px;
    }

    .tjc-smi-search input,
    .tjc-smi-manual input,
    .tjc-smi-field input,
    .tjc-smi-field textarea {
        width: 100%;
        border: 1px solid rgba(16, 42, 67, 0.14);
        border-radius: 16px;
        background: #fff;
        color: #0f172a;
        font: inherit;
        font-size: 1rem;
        padding: 14px 16px;
        box-sizing: border-box;
    }

    .tjc-smi-search input {
        border: 0;
        padding: 8px 2px;
        font-size: 1.05rem;
    }

    .tjc-smi-manual {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        padding: 10px;
        margin-bottom: 16px;
    }

    .tjc-smi-manual button {
        border: 0;
        border-radius: 16px;
        background: #0ea5e9;
        color: #fff;
        font-weight: 900;
        padding: 0 18px;
    }

    .tjc-smi-results {
        background: #fff;
        border: 1px solid rgba(16, 42, 67, 0.12);
        border-radius: 24px;
        box-shadow: 0 14px 36px rgba(31, 54, 83, 0.08);
        overflow: hidden;
    }

    .tjc-smi-result {
        align-items: center;
        background: transparent;
        border: 0;
        border-bottom: 1px solid rgba(15, 23, 42, 0.1);
        color: #0f172a;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        padding: 16px;
        text-align: left;
        width: 100%;
        font: inherit;
    }

    .tjc-smi-result strong {
        font-size: 0.98rem;
        min-width: 0;
    }

    .tjc-smi-result span {
        color: #475569;
        font-size: 0.92rem;
        white-space: nowrap;
    }

    .tjc-smi-editor-card {
        padding: 18px;
    }

    .tjc-smi-editor-item {
        align-items: center;
        background: transparent;
        border: 0;
        border-bottom: 1px solid rgba(15, 23, 42, 0.1);
        color: #0f172a;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 12px;
        padding: 0 0 16px;
        width: 100%;
        font: inherit;
        text-align: left;
    }

    .tjc-smi-editor-item strong {
        color: #0ea5e9;
        font-weight: 700;
        text-align: right;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tjc-smi-field {
        display: block;
        margin-top: 16px;
    }

    .tjc-smi-field > span {
        color: #64748b;
        display: block;
        font-size: 0.8rem;
        font-weight: 900;
        letter-spacing: 0.11em;
        margin-bottom: 8px;
        text-transform: uppercase;
    }

    .tjc-smi-field-inline {
        align-items: center;
        border-top: 1px solid rgba(15, 23, 42, 0.1);
        display: grid;
        grid-template-columns: auto minmax(100px, 1fr);
        gap: 14px;
        padding-top: 14px;
    }

    .tjc-smi-field-inline > span {
        margin: 0;
    }

    .tjc-smi-field-inline input {
        text-align: right;
    }
}

/* Stronger mobile override: keep the real sales item rows in the DOM for saving,
   but hide the original desktop editor rows while the isolated mobile item UI is active.
   This must beat older office UI rules that use body selectors and !important. */
@media (max-width: 1180px) {
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > .tjc-sales-items-head,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > .tjc-quote-item-rows,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > #tjc-quote-item-rows,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > #tjc-invoice-item-rows,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > .tjc-sales-add-line,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > .tjc-muted-small,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > datalist,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > template {
        display: none !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > .tjc-quote-item-rows .tjc-sales-item-row,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > #tjc-quote-item-rows .tjc-sales-item-row,
    body.tjc-office-dashboard-active .tjc-sales-mobile-items-active > #tjc-invoice-item-rows .tjc-sales-item-row {
        display: none !important;
    }
}

/* Mobile item card width cleanup: remove the original sales-items wrapper panel so
   only the isolated mobile item card is visible. The real rows remain hidden in the
   DOM for saving. */
@media (max-width: 1180px) {
    body.tjc-office-dashboard-active .tjc-sales-items-block.tjc-sales-mobile-items-active {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-items-block.tjc-sales-mobile-items-active > .tjc-smi {
        box-sizing: border-box;
        margin: 14px 0 18px !important;
        width: 100%;
    }
}

@media (max-width: 520px) {
    body.tjc-office-dashboard-active .tjc-sales-items-block.tjc-sales-mobile-items-active > .tjc-smi {
        margin-left: -6px !important;
        margin-right: -6px !important;
        padding-left: 16px;
        padding-right: 16px;
        width: calc(100% + 12px);
    }
}


/* Desktop sales item picker and professional totals summary. */
@media (min-width: 1181px) {
    html.tjc-smi-lock,
    html.tjc-smi-lock body {
        overflow: hidden;
    }

    .tjc-smi-overlay {
        position: fixed;
        inset: 0;
        z-index: 999999;
        background: rgba(15, 23, 42, 0.42);
        color: #0f172a;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        overflow: auto;
        padding: 72px 24px 48px;
        box-sizing: border-box;
    }

    .tjc-smi-overlay .tjc-smi-panel {
        width: min(760px, 100%);
        background: #ffffff;
        border: 1px solid rgba(16, 42, 67, 0.12);
        border-radius: 24px;
        box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
        padding: 22px;
        box-sizing: border-box;
    }

    .tjc-smi-overlay .tjc-smi-nav {
        align-items: center;
        display: grid;
        grid-template-columns: 44px 1fr 44px;
        gap: 12px;
        margin-bottom: 18px;
        text-align: center;
    }

    .tjc-smi-overlay .tjc-smi-nav strong {
        color: #0f172a;
        font-size: 1.15rem;
        font-weight: 900;
    }

    .tjc-smi-overlay .tjc-smi-round,
    .tjc-smi-overlay .tjc-smi-done {
        align-items: center;
        border: 1px solid rgba(15, 23, 42, 0.12);
        border-radius: 999px;
        cursor: pointer;
        display: inline-flex;
        font-size: 1.65rem;
        font-weight: 700;
        height: 44px;
        justify-content: center;
        line-height: 1;
        width: 44px;
    }

    .tjc-smi-overlay .tjc-smi-round {
        background: #f8fafc;
        color: #0f172a;
    }

    .tjc-smi-overlay .tjc-smi-rotate {
        transform: rotate(45deg);
    }

    .tjc-smi-overlay .tjc-smi-search {
        margin-bottom: 14px;
    }

    .tjc-smi-overlay .tjc-smi-search input,
    .tjc-smi-overlay .tjc-smi-manual input {
        width: 100%;
        border: 1px solid rgba(16, 42, 67, 0.16);
        border-radius: 16px;
        background: #fff;
        color: #0f172a;
        font: inherit;
        font-size: 1rem;
        padding: 14px 16px;
        box-sizing: border-box;
    }

    .tjc-smi-overlay .tjc-smi-manual {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        margin-bottom: 16px;
    }

    .tjc-smi-overlay .tjc-smi-manual button {
        border: 0;
        border-radius: 16px;
        background: #0ea5e9;
        color: #fff;
        cursor: pointer;
        font-weight: 900;
        padding: 0 22px;
    }

    .tjc-smi-overlay .tjc-smi-results {
        border: 1px solid rgba(16, 42, 67, 0.12);
        border-radius: 18px;
        max-height: 430px;
        overflow: auto;
    }

    .tjc-smi-overlay .tjc-smi-result {
        align-items: center;
        background: #fff;
        border: 0;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
        color: #0f172a;
        cursor: pointer;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 16px;
        padding: 14px 16px;
        text-align: left;
        width: 100%;
        font: inherit;
    }

    .tjc-smi-overlay .tjc-smi-result:hover,
    .tjc-smi-overlay .tjc-smi-result:focus {
        background: #f8fbff;
        outline: none;
    }

    .tjc-smi-overlay .tjc-smi-result strong {
        font-weight: 850;
        min-width: 0;
    }

    .tjc-smi-overlay .tjc-smi-result span {
        color: #475569;
        font-size: 0.92rem;
        white-space: nowrap;
    }

    .tjc-sales-form .tjc-sales-summary {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
        align-items: stretch;
        background: linear-gradient(135deg, #f8fbff 0%, #ffffff 100%);
        border: 1px solid rgba(16, 42, 67, 0.12);
        border-radius: 22px;
        box-shadow: 0 16px 36px rgba(31, 54, 83, 0.08);
        margin: 22px 0;
        padding: 18px;
        max-width: none;
    }

    .tjc-sales-form .tjc-sales-summary > div {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        min-height: 54px;
        background: #ffffff;
        border: 1px solid rgba(16, 42, 67, 0.1);
        border-radius: 16px;
        box-shadow: 0 8px 20px rgba(31, 54, 83, 0.05);
        padding: 12px 14px;
        box-sizing: border-box;
    }

    .tjc-sales-form .tjc-sales-summary > div span {
        color: #64748b;
        font-size: 0.78rem;
        font-weight: 900;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .tjc-sales-form .tjc-sales-summary > div strong {
        color: #0f172a;
        font-size: 1rem;
        font-weight: 900;
        text-align: right;
        white-space: nowrap;
    }

    .tjc-sales-form .tjc-sales-summary > div:last-child {
        background: #eff6ff;
        border-color: rgba(37, 99, 235, 0.16);
    }

    .tjc-sales-form .tjc-sales-summary > div:last-child span,
    .tjc-sales-form .tjc-sales-summary > div:last-child strong {
        color: #1d4ed8;
    }
}

@media (min-width: 1181px) and (max-width: 1180px) {
    .tjc-sales-form .tjc-sales-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Desktop sales totals cleanup: compact right-side stacked summary, overriding legacy office CSS without editing tjc-office-ui.css. */
@media (min-width: 901px) {
    body.tjc-office-dashboard-active .tjc-sales-form .tjc-sales-summary {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 390px !important;
        margin: 18px 0 8px auto !important;
        padding: 12px !important;
        border: 1px solid rgba(37, 99, 235, 0.12) !important;
        border-radius: 18px !important;
        background: #ffffff !important;
        box-shadow: 0 12px 28px rgba(31, 54, 83, 0.08) !important;
        box-sizing: border-box !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-form .tjc-sales-summary > div {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 16px !important;
        min-height: 42px !important;
        padding: 9px 12px !important;
        border: 1px solid rgba(16, 42, 67, 0.1) !important;
        border-radius: 12px !important;
        border-bottom: 1px solid rgba(16, 42, 67, 0.1) !important;
        background: #ffffff !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-form .tjc-sales-summary > div:last-child {
        padding-bottom: 9px !important;
        background: #eff6ff !important;
        border-color: rgba(37, 99, 235, 0.18) !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-form .tjc-sales-summary > div span {
        color: #64748b !important;
        font-size: 0.72rem !important;
        font-weight: 900 !important;
        letter-spacing: 0.08em !important;
        line-height: 1.15 !important;
        text-transform: uppercase !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-form .tjc-sales-summary > div strong {
        color: #0f172a !important;
        font-size: 0.92rem !important;
        font-weight: 900 !important;
        line-height: 1.15 !important;
        text-align: right !important;
        white-space: nowrap !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-form .tjc-sales-summary > div:last-child span,
    body.tjc-office-dashboard-active .tjc-sales-form .tjc-sales-summary > div:last-child strong {
        color: #1d4ed8 !important;
    }
}

/* Desktop sales email panel cleanup. Desktop/tablet-wide only so mobile item screens stay untouched. */
@media (min-width: 901px) {
    body.tjc-office-dashboard-active .tjc-sales-email-panel {
        max-width: none !important;
        margin: 22px 0 0 !important;
        padding: 20px !important;
        border: 1px solid rgba(37, 99, 235, 0.12) !important;
        border-radius: 18px !important;
        background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%) !important;
        box-shadow: 0 14px 34px rgba(31, 54, 83, 0.08) !important;
        box-sizing: border-box !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-head {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        gap: 18px !important;
        margin: 0 0 18px !important;
        padding: 0 0 14px !important;
        border-bottom: 1px solid rgba(16, 42, 67, 0.08) !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-head strong {
        display: block !important;
        margin: 0 0 5px !important;
        color: #0f172a !important;
        font-size: 1rem !important;
        font-weight: 900 !important;
        letter-spacing: -0.01em !important;
        line-height: 1.25 !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-head span {
        display: block !important;
        max-width: 680px !important;
        color: #64748b !important;
        font-size: 0.82rem !important;
        font-weight: 700 !important;
        line-height: 1.45 !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form {
        display: grid !important;
        gap: 16px !important;
        margin: 0 !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form .tjc-sales-grid {
        display: grid !important;
        grid-template-columns: minmax(260px, 0.75fr) minmax(360px, 1.25fr) !important;
        gap: 16px !important;
        align-items: start !important;
        margin: 0 !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form .tjc-form-field {
        display: grid !important;
        gap: 7px !important;
        margin: 0 !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form .tjc-form-field > span {
        color: #64748b !important;
        font-size: 0.72rem !important;
        font-weight: 900 !important;
        letter-spacing: 0.08em !important;
        line-height: 1.2 !important;
        text-transform: uppercase !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form input[type="email"],
    body.tjc-office-dashboard-active .tjc-sales-email-form input[type="text"],
    body.tjc-office-dashboard-active .tjc-sales-email-form textarea {
        width: 100% !important;
        min-height: 44px !important;
        padding: 11px 13px !important;
        border: 1px solid rgba(148, 163, 184, 0.42) !important;
        border-radius: 13px !important;
        background: #ffffff !important;
        color: #0f172a !important;
        font-size: 0.92rem !important;
        font-weight: 700 !important;
        line-height: 1.35 !important;
        box-shadow: 0 2px 0 rgba(15, 23, 42, 0.02) !important;
        box-sizing: border-box !important;
        transition: border-color 0.16s ease, box-shadow 0.16s ease !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form textarea {
        min-height: 138px !important;
        resize: vertical !important;
        white-space: pre-wrap !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form input[type="email"]:focus,
    body.tjc-office-dashboard-active .tjc-sales-email-form input[type="text"]:focus,
    body.tjc-office-dashboard-active .tjc-sales-email-form textarea:focus {
        border-color: rgba(37, 99, 235, 0.55) !important;
        box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1) !important;
        outline: none !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form .tjc-muted-small {
        display: inline-flex !important;
        align-items: center !important;
        width: fit-content !important;
        max-width: 100% !important;
        padding: 9px 12px !important;
        border: 1px solid rgba(245, 158, 11, 0.22) !important;
        border-radius: 999px !important;
        background: #fffbeb !important;
        color: #92400e !important;
        font-size: 0.78rem !important;
        font-weight: 800 !important;
        line-height: 1.25 !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-email-form .tjc-office-primary-action {
        justify-self: start !important;
        min-height: 44px !important;
        padding: 0 18px !important;
        border-radius: 13px !important;
        box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22) !important;
    }
}


/* Tablet/mobile sales form field containment fixes.
   Keeps iOS date inputs inside their cards and prevents payment form fields overlapping. */
@media (max-width: 1180px) {
    body.tjc-office-dashboard-active .tjc-sales-grid,
    body.tjc-office-dashboard-active .tjc-sales-payment-form {
        align-items: stretch !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-grid .tjc-form-field,
    body.tjc-office-dashboard-active .tjc-sales-payment-form .tjc-form-field {
        min-width: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-form input[type="date"],
    body.tjc-office-dashboard-active .tjc-sales-payment-form input[type="date"] {
        -webkit-appearance: none !important;
        appearance: none !important;
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        text-align: center !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-payment-form {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    body.tjc-office-dashboard-active .tjc-sales-payment-form .tjc-office-primary-action {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 820px) {
    body.tjc-office-dashboard-active .tjc-sales-grid,
    body.tjc-office-dashboard-active .tjc-sales-payment-form {
        grid-template-columns: 1fr !important;
    }
}


/* New customer panel inside quote/invoice forms */
.tjc-sales-new-customer-panel {
    grid-column: 1 / -1;
    border: 1px solid rgba(15, 23, 42, 0.10);
    background: #f8fbff;
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}
.tjc-sales-new-customer-panel[hidden] {
    display: none !important;
}
.tjc-sales-new-customer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.tjc-sales-new-customer-head strong {
    font-size: 15px;
    color: #0f172a;
}
.tjc-sales-new-customer-head span {
    font-size: 12px;
    color: #64748b;
    text-align: right;
}
.tjc-sales-new-customer-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
@media (max-width: 760px) {
    .tjc-sales-new-customer-panel {
        padding: 12px;
        border-radius: 14px;
    }
    .tjc-sales-new-customer-head {
        display: block;
    }
    .tjc-sales-new-customer-head span {
        display: block;
        margin-top: 4px;
        text-align: left;
    }
    .tjc-sales-new-customer-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .tjc-sales-new-customer-grid .tjc-field-span-2 {
        grid-column: auto;
    }
}

/* New sales customer: individual/business support */
.tjc-sales-new-customer-type{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
  margin:0 0 12px;
}
.tjc-sales-new-customer-type label{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:40px;
  border:1px solid #d7e3ef;
  border-radius:14px;
  background:#fff;
  color:#28415f;
  font-weight:900;
  cursor:pointer;
}
.tjc-sales-new-customer-type input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.tjc-sales-new-customer-type label.is-active{
  background:#eaf2ff;
  border-color:#2f6fe4;
  color:#174ea6;
}
.tjc-sales-new-customer-grid [hidden]{
  display:none!important;
}
@media (max-width:760px){
  .tjc-sales-new-customer-type{
    grid-template-columns:1fr;
  }
}


/* Quote/invoice New Client button and modal */
.tjc-sales-new-customer-open {
    align-self: end;
    min-height: 46px;
    width: 100%;
    border: 1px solid #cbd8ea;
    border-radius: 999px;
    background: #ffffff;
    color: #1d4ed8;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}
.tjc-sales-new-customer-open:hover,
.tjc-sales-new-customer-open:focus {
    border-color: #2f6fe4;
    background: #eef5ff;
    outline: none;
}
body.tjc-sales-new-customer-modal-open {
    overflow: hidden !important;
}
body > .tjc-sales-new-customer-panel:not([hidden]) {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    z-index: 99999 !important;
    width: min(720px, calc(100vw - 48px)) !important;
    max-width: calc(100vw - 48px) !important;
    max-height: min(760px, calc(100dvh - 48px)) !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    grid-column: auto !important;
    background: #ffffff !important;
    border: 1px solid #dbe7f3 !important;
    border-radius: 20px !important;
    box-shadow: 0 26px 70px rgba(15, 23, 42, 0.22) !important;
}
body > .tjc-sales-new-customer-panel:not([hidden])::before {
    content: "";
    position: fixed;
    inset: -100vmax;
    z-index: -1;
    background: rgba(15, 23, 42, 0.16);
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-head {
    position: relative;
    top: auto;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin: 0;
    padding: 18px 22px 14px;
    background: #ffffff;
    border-bottom: 1px solid #e6edf5;
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-head strong {
    display: block;
    font-size: 16px;
    line-height: 1.2;
    color: #0f172a;
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-head span {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #51627c;
    text-align: left;
}
.tjc-sales-new-customer-close {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid #d7e3ef;
    border-radius: 999px;
    background: #ffffff;
    color: #0f172a;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-type {
    margin: 0;
    padding: 16px 22px 0;
    background: #ffffff;
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px 22px 8px;
    background: #ffffff;
    align-content: start;
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-form-field {
    width: 100%;
    min-width: 0;
    margin: 0;
}
body > .tjc-sales-new-customer-panel:not([hidden]) input[type="text"],
body > .tjc-sales-new-customer-panel:not([hidden]) input[type="email"] {
    max-width: 100%;
    box-sizing: border-box;
    background: #ffffff;
    border-color: #d7e3ef;
}
body > .tjc-sales-new-customer-panel:not([hidden]) input[type="text"]:focus,
body > .tjc-sales-new-customer-panel:not([hidden]) input[type="email"]:focus {
    border-color: #2f6fe4;
    box-shadow: 0 0 0 3px rgba(47, 111, 228, 0.10);
    outline: none;
}
body > .tjc-sales-new-customer-panel:not([hidden]) > .tjc-muted-small,
body > .tjc-sales-new-customer-panel:not([hidden]) > [data-tjc-new-customer-status] {
    margin: 0;
    padding: 8px 22px 0;
    background: #ffffff;
}
.tjc-muted-small.is-error {
    color: #b91c1c !important;
    font-weight: 900;
}
.tjc-muted-small.is-success {
    color: #15803d !important;
    font-weight: 900;
}
.tjc-sales-new-customer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-actions {
    flex: 0 0 auto;
    position: relative;
    bottom: auto;
    z-index: 2;
    margin: 0;
    padding: 14px 22px 18px;
    background: #ffffff;
    border-top: 1px solid #e6edf5;
}
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-actions .tjc-office-primary-action,
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-actions .tjc-link-btn {
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 999px;
    font-weight: 900;
    white-space: nowrap;
}
@media (max-width: 760px) {
    .tjc-sales-new-customer-open {
        width: 100%;
        align-self: stretch;
    }
    body > .tjc-sales-new-customer-panel:not([hidden]) {
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
        border-radius: 18px !important;
    }
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-head,
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-type,
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-grid,
    body > .tjc-sales-new-customer-panel:not([hidden]) > .tjc-muted-small,
    body > .tjc-sales-new-customer-panel:not([hidden]) > [data-tjc-new-customer-status],
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-actions {
        padding-left: 16px;
        padding-right: 16px;
    }
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-grid {
        grid-template-columns: 1fr;
        padding-top: 14px;
        padding-bottom: 6px;
    }
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-grid .tjc-field-span-2 {
        grid-column: auto;
    }
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        padding-top: 12px;
        padding-bottom: 16px;
    }
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-actions .tjc-office-primary-action,
    body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-actions .tjc-link-btn {
        width: 100%;
        justify-content: center;
    }
}


/* New Client modal toggle hardening */
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-grid [hidden],
body > .tjc-sales-new-customer-panel:not([hidden]) .tjc-sales-new-customer-grid [style*="display: none"] {
    display: none !important;
}
body > .tjc-sales-new-customer-panel:not([hidden]) input[type="text"],
body > .tjc-sales-new-customer-panel:not([hidden]) input[type="email"] {
    border-radius: 12px !important;
    min-height: 40px !important;
}
