/* ==========================================================================================================
   OPS-1675 (lane/1675-rdw2-ops, redesign wave 2): the new look of Intake, Reports, Setup, Packages, Mileage, Client Map and
   Route Planner (js/modules/ops-redesign.js). Namespaced .op-*; uses the ChiroApp "cx" tokens from css/index.css.
   Nothing here applies unless the module sets body.op-on (new look on + this stylesheet loaded). The classic pages keep their
   markup, handlers and save path; this file only restyles them. --op-ready tells the module this stylesheet is loaded.
   No pills / chips: status words are plain coloured text. No emoji. Same app on phone, tablet and desktop.
   ========================================================================================================== */
:root { --op-ready: 1; --op-head: 'Poppins', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; }

/* ───────── shared: page header, cards, tiles, segmented tabs ───────── */
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) > .page-header { margin-bottom: 14px; }
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) > .page-header h1,
body.op-on #page-patients > .op-intake-detail-head h1 {
    font-family: var(--op-head); font-size: 2.1rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.12; color: var(--primary-text, var(--cx-text)); margin: 0;   /* BRAND-1677 */
}
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) > .page-header h1 > i { display: none; }
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) > .page-header .subtitle { color: var(--cx-text-2); font-size: 0.95rem; margin: 4px 0 0; }
@media (max-width: 600px) {
    body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) > .page-header h1,
    body.op-on #page-patients > .op-intake-detail-head h1 { font-size: 1.75rem; }
}

body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) .card,
body.op-on #page-patients > .op-intake-detail-part.card {
    background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1);
    -webkit-backdrop-filter: none; backdrop-filter: none; color: var(--cx-text); min-width: 0;
}
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage, #clientMapPage) .btn { border-radius: var(--cx-radius-md); min-height: 40px; }
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) h3 { font-family: var(--op-head); letter-spacing: -0.01em; }

.op-tiles { display: grid; gap: 10px; margin: 0 0 14px; min-width: 0; }
.op-tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.op-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; text-align: left; font: inherit; color: var(--cx-text);
    background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1);
    padding: 12px 14px; cursor: pointer; min-height: 44px;
}
.op-tile--static { cursor: default; }
.op-tile:focus-visible { outline: 2px solid var(--cx-focus); outline-offset: 2px; }
.op-tile-icon { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; margin-bottom: 4px; }
.op-tile-label { font-size: 0.8rem; color: var(--cx-text-2); line-height: 1.2; overflow-wrap: anywhere; }
.op-tile-value { font-family: var(--op-head); font-size: 1.35rem; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; min-width: 0; max-width: 100%; }
.op-money { font-variant-numeric: tabular-nums; }
.op-tone-info { background: var(--cx-info-bg); color: var(--cx-info-ink); }
.op-tone-ok { background: var(--cx-success-bg); color: var(--cx-success-ink); }
.op-tone-bad { background: var(--cx-danger-bg); color: var(--cx-danger-ink); }
.op-tone-muted { background: var(--cx-neutral-bg); color: var(--cx-neutral-ink); }
.op-value-ok { color: var(--cx-brand-ink); }
.op-value-bad { color: #b91c1c; }
[data-theme="dark"] .op-value-bad { color: #fca5a5; }
@media (max-width: 480px) {
    .op-tiles { gap: 8px; }
    .op-tile { padding: 10px; }
    .op-tile-value { font-size: 1.02rem; }
    .op-tile-label { font-size: 0.74rem; }
}

/* segmented tabs (no pills): the active one is a raised white segment */
.op-seg, body.op-on #page-financials .reports-tabs, body.op-on #routePlannerPage .route-planner-tabs {
    display: flex !important; gap: 4px !important; padding: 4px !important; margin: 0 0 14px !important; border: 0 !important;
    background: var(--cx-neutral-bg) !important; border-radius: var(--cx-radius-md) !important; min-width: 0; max-width: 100%;
}
.op-seg-btn, body.op-on #page-financials .reports-tab, body.op-on #routePlannerPage .route-tab {
    flex: 1 1 0 !important; min-width: 0 !important; min-height: 44px !important; display: inline-flex !important; align-items: center !important;
    justify-content: center !important; gap: 6px !important; padding: 6px 8px !important; margin: 0 !important; border: 0 !important;
    border-radius: 10px !important; background: transparent !important; color: var(--cx-text-2) !important; font: inherit !important;
    font-weight: 600 !important; font-size: 0.92rem !important; cursor: pointer; text-align: center; line-height: 1.2 !important;
}
.op-seg-btn.is-active, body.op-on #page-financials .reports-tab.active, body.op-on #routePlannerPage .route-tab.active {
    background: var(--cx-surface) !important; color: var(--cx-brand-ink) !important; box-shadow: var(--cx-shadow-1) !important;
}
.op-seg-count { font-weight: 700; color: #b91c1c; font-size: 0.8rem; white-space: nowrap; }
[data-theme="dark"] .op-seg-count { color: #fca5a5; }
@media (max-width: 480px) {
    body.op-on #page-financials .reports-tab > i, .op-seg-btn > i, body.op-on #routePlannerPage .route-tab > i { display: none !important; }
    .op-seg-btn, body.op-on #page-financials .reports-tab { font-size: 0.85rem !important; flex-wrap: wrap; }
}

/* fields: the cx look (thin border, rounded) instead of the classic heavy outline; same elements, same values */
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]):not([type="range"]), select, textarea) {
    border: 1px solid var(--cx-border); border-radius: 10px; background-color: var(--cx-surface); color: var(--cx-text); min-height: 44px; max-width: 100%;
}
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) textarea { min-height: 88px; }
body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage) :is(input, select, textarea):focus-visible { outline: 2px solid var(--cx-focus); outline-offset: 1px; border-color: var(--cx-brand); }

/* ───────── Reports ───────── */
body.op-on #financialsContainer .financial-card-header h3 { font-size: 1.1rem; margin: 0; }
body.op-on #financialsContainer .financial-summary-card .stat-value { font-family: var(--op-head); }
body.op-on #financialsContainer .progress-container { background: var(--cx-neutral-bg); border-radius: 999px; }
body.op-on #financialsContainer .progress-bar { background: var(--cx-brand); border-radius: 999px; }
body.op-on #financialsContainer .detail-section h4 { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--cx-text-2); }
body.op-on #financialsContainer table th { color: var(--cx-text-2); font-size: 0.78rem; font-weight: 700; }
body.op-on #financialsContainer .btn-secondary, body.op-on #page-financials .btn-secondary { background: var(--cx-surface); border: 1px solid var(--cx-border); color: var(--cx-text); }
body.op-on #analyticsContainer .analytics-stat-card { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1); }
body.op-on #analyticsContainer .analytics-bar { background: var(--cx-brand); }

/* ───────── Intake (staff page) ───────── */
body.op-on #page-intake[data-op-intake-tab="new"] > .card:not(.intake-form-container) { display: none; }
body.op-on #page-intake[data-op-intake-tab="list"] > .intake-form-container { display: none; }
body.op-on #page-intake > .card { margin-top: 0; }
body.op-on #page-intake .form-section {
    border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); padding: 16px; margin-bottom: 14px; background: var(--cx-surface-2); min-width: 0;
}
body.op-on #page-intake .form-section > h3 { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 0 0 4px; }
body.op-on #page-intake .form-section > h3 > i {
    width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--cx-brand-soft); color: var(--cx-brand-ink); font-size: 1.25rem; flex: 0 0 auto;
}
body.op-on #page-intake .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
body.op-on #page-intake .form-actions .btn { flex: 1 1 140px; min-height: 48px; font-weight: 600; }
body.op-on #page-intake .card > h3 { font-size: 1.2rem; }
body.op-on .intake-item { border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); background: var(--cx-surface); }
body.op-on #page-intake .intake-item h4 > span[style], body.op-on #intakesList .list-section-title + .intake-item h4 > span[style] {
    background: none !important; padding: 0 !important; border-radius: 0 !important; color: var(--cx-brand-ink) !important; text-transform: none !important;
    font-size: 0.78rem !important;
}
/* intake detail (App.viewIntake; the classic page inside Patients) */
body.op-on #page-patients > .op-intake-detail-head { margin-bottom: 12px; }
body.op-on #page-patients > .op-intake-detail-part .form-section h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cx-text-2); margin: 0 0 2px; }
body.op-on #page-patients > .op-intake-detail-part .form-row { gap: 12px; flex-wrap: wrap; }

/* ───────── Setup: categories as cards, the classic pills as one subtitle line ───────── */
body.op-on #page-setup .setup-category {
    background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1);
    margin-bottom: 12px; overflow: hidden; min-width: 0;
}
body.op-on #page-setup .setup-category-header { background: transparent; border: 0; border-radius: 0; padding: 14px 16px 4px; min-height: 52px; }
body.op-on #page-setup .setup-category-header:hover { background: var(--cx-surface-2); }
body.op-on #page-setup .setup-category-header > i:first-child {
    width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    background: var(--cx-brand-soft); color: var(--cx-brand-ink); font-size: 1.35rem;
}
body.op-on #page-setup .setup-category-header h2 { font-family: var(--op-head); font-size: 1.15rem; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
body.op-on #page-setup .setup-category-pills { display: block; padding: 0 16px 0 76px; margin: 0 0 14px; line-height: 1.55; }
body.op-on #page-setup .setup-category-pill {
    display: inline; padding: 2px 0; border: 0; background: none; border-radius: 0; font-size: 0.86rem; color: var(--cx-text-2);
    white-space: normal; letter-spacing: 0; transform: none;
}
body.op-on #page-setup .setup-category-pill > i { display: none; }
body.op-on #page-setup .setup-category-pill + .setup-category-pill::before { content: ', '; color: var(--cx-text-2); display: inline-block; white-space: pre; text-decoration: none; }
body.op-on #page-setup .setup-category-pill:hover { background: none; color: var(--cx-brand-ink); text-decoration: underline; transform: none; }
body.op-on #page-setup .setup-category.expanded .setup-category-content { padding: 4px 12px 14px; background: var(--cx-surface-2); border-top: 1px solid var(--cx-border); }
body.op-on #page-setup .setup-category-content .card { box-shadow: none; }
body.op-on #page-setup .setup-category.expanded .setup-category-header { padding-bottom: 14px; }
@media (max-width: 480px) {
    body.op-on #page-setup .setup-category-pills { padding-left: 16px; }
    body.op-on #page-setup .setup-category.expanded .setup-category-content { padding: 4px 6px 12px; }
}
/* Packages: the template list (Setup > Billing) */
body.op-on #prepaidPackagesCard .list-item-row { border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); padding: 10px 12px; margin-bottom: 8px; gap: 6px; }
body.op-on #prepaidPackagesCard .list-item-row span[style*="border-radius: 999px"] { background: none !important; padding: 0 !important; color: var(--cx-text-2) !important; font-weight: 600; }
body.op-on #prepaidPackagesCard .btn-icon { min-width: 44px; min-height: 44px; }
/* Packages: a client's packages (App.viewClientPackages, in the classic modal) */
body.op-on #modalBody .op-pkg { max-width: 560px !important; }
body.op-on #modalBody .op-pkg > div[style*="border-radius"], body.op-on #modalBody .op-pkg .package-history-row {
    background: var(--cx-surface) !important; border: 1px solid var(--cx-border) !important; border-radius: var(--cx-radius-lg) !important;
}
body.op-on #modalBody .op-pkg span[style*="border-radius: 12px"] { background: none !important; padding: 0 !important; font-size: 0.82rem !important; }
body.op-on #modalBody .op-pkg div[style*="height: 8px"] > div { background: var(--cx-brand) !important; }
body.op-on #modalBody .op-pkg details > summary { font-weight: 700; color: var(--cx-text) !important; min-height: 44px; display: flex; align-items: center; }

/* ───────── Mileage ───────── */
body.op-on #page-mileage > .page-header { flex-wrap: wrap; gap: 12px; }
body.op-on #page-mileage .page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; }
body.op-on #page-mileage .page-header-actions .btn { min-height: 48px; flex: 1 1 160px; font-weight: 600; }
body.op-on #page-mileage .page-header-actions .btn:first-child { background: var(--cx-brand); border-color: var(--cx-brand); color: var(--cx-on-brand); order: -1; }
body.op-on #page-mileage .page-header-actions .btn:last-child { background: var(--cx-surface); border: 1px solid var(--cx-border); color: var(--cx-text); }
body.op-on #mileageSummaryBar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; background: none; border: 0; padding: 0; box-shadow: none; margin-bottom: 14px; }
body.op-on #mileageSummaryBar .mileage-stat {
    display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 2px; min-width: 0;
    background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1); padding: 12px 14px;
}
body.op-on #mileageSummaryBar .mileage-stat-label { font-size: 0.8rem; color: var(--cx-text-2); }
body.op-on #mileageSummaryBar .mileage-stat-value { font-family: var(--op-head); font-size: 1.35rem; font-weight: 700; color: var(--cx-text); overflow-wrap: anywhere; }
body.op-on #mileageSummaryBar .mileage-stat-value.mileage-business, body.op-on #mileageSummaryBar .mileage-stat-value.mileage-deduction { color: var(--cx-brand-ink); }
@media (max-width: 700px) { body.op-on #mileageSummaryBar { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
body.op-on #page-mileage .search-filter-bar { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
body.op-on #page-mileage #mileageFilter { display: flex; gap: 4px; padding: 4px; background: var(--cx-neutral-bg); border-radius: var(--cx-radius-md); flex-wrap: wrap; }
body.op-on #page-mileage #mileageFilter .pill {
    flex: 1 1 0; min-width: 0; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--cx-text-2); font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 8px;
}
body.op-on #page-mileage #mileageFilter .pill.active { background: var(--cx-surface); color: var(--cx-brand-ink); box-shadow: var(--cx-shadow-1); }
@media (max-width: 480px) { body.op-on #page-mileage #mileageFilter .pill { flex: 1 1 calc(50% - 4px); } }
body.op-on #page-mileage .mileage-date-range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.op-on #page-mileage .mileage-date-range input { flex: 1 1 130px; min-width: 0; min-height: 44px; }
body.op-on #page-mileage .mileage-trip-card { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1); min-width: 0; }
body.op-on #page-mileage .mileage-trip-distance { font-family: var(--op-head); font-weight: 700; }
body.op-on #page-mileage .mileage-classify-btn { min-height: 40px; border-radius: 10px; }

/* ───────── Route Planner (overlay inside Schedule) ───────── */
body.op-on #routePlannerPage { background: var(--cx-bg); }
body.op-on #routePlannerPage .avail-back-btn { color: var(--cx-brand-ink); font-weight: 600; padding-left: 0; min-height: 44px; }
body.op-on #routePlannerPage > .card { padding: 16px !important; }
body.op-on #routePlannerPage .route-summary-panel:not([style*="display: none"]) { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
body.op-on #routePlannerPage .route-summary-card {
    display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 2px; min-width: 0;
    background: var(--cx-surface); border: 1px solid var(--cx-border) !important; border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1); padding: 12px;
}
body.op-on #routePlannerPage .route-summary-card .label { font-size: 0.8rem; color: var(--cx-text-2); }
body.op-on #routePlannerPage .route-summary-card .value { font-family: var(--op-head); font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }
body.op-on #routePlannerPage .route-stop { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg); box-shadow: var(--cx-shadow-1); min-width: 0; }
body.op-on #routePlannerPage .route-stop-number { background: var(--cx-brand-soft); color: var(--cx-brand-ink); }
body.op-on #routePlannerPage .route-planner-warnings { border-radius: var(--cx-radius-md); }
body.op-on #routePlannerPage .route-planner-actions { display: flex !important; flex-wrap: wrap; gap: 10px; }
body.op-on #routePlannerPage .route-planner-actions[style*="display: none"] { display: none !important; }
body.op-on #routePlannerPage .route-planner-actions .btn { flex: 1 1 160px; min-height: 48px; }
body.op-on #routePlannerPage .route-date-pill { border-radius: var(--cx-radius-md); min-height: 44px; }
body.op-on #routePlannerPage .route-health-panel { border-radius: var(--cx-radius-lg); }

/* ───────── Client Map (overlay inside Clients) ───────── */
body.op-on #clientMapHeader { padding-top: calc(0.75rem + env(safe-area-inset-top, 0px)) !important; background: var(--cx-surface) !important; border-bottom-color: var(--cx-border) !important; gap: 10px; flex-wrap: wrap; }
body.op-on #clientMapHeader h1 { font-family: var(--op-head); font-size: 1.35rem !important; color: var(--cx-text) !important; }
body.op-on #clientMapHeader h1 > i { display: none; }
body.op-on #clientMapCountBadge { background: none !important; color: var(--cx-brand-ink) !important; padding: 0 !important; font-size: 0.9rem !important; }
body.op-on #clientMapHeader .btn { min-height: 44px; }
body.op-on #clientMapContainer { margin-bottom: env(safe-area-inset-bottom, 0px); }

/* ───────── iOS 16px: every field of these pages (and the classic pop-up) on phones / tablets / touch screens ───────── */
@media (max-width: 1024px), (pointer: coarse) {
    body.op-on :is(#page-financials, #page-intake, #page-setup, #page-mileage, #routePlannerPage, #clientMapPage, #opIntakeTabs) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
    body.op-on #page-patients > .op-intake-detail-part :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
    body.op-on #modal :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) { font-size: 16px !important; }
}
