:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #f3f6f9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #f3f6f9;
}

a {
    color: #0b5cab;
}

button,
input,
select,
textarea {
    font: inherit;
}

.field-header {
    background: #ffffff;
    border-bottom: 1px solid #dce3ea;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.field-brand {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 1.25rem;
    font-weight: 800;
    text-decoration: none;
}

.field-brand img {
    display: block;
    width: auto;
    height: auto;
    max-height: 84px;
    max-width: min(320px, 70vw);
    object-fit: contain;
}

.field-date {
    margin: 4px 0 10px;
    color: #526071;
    font-size: 0.92rem;
}

.field-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.field-nav a,
.field-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 12px;
    border-radius: 8px;
    background: #eef4f9;
    text-decoration: none;
    font-weight: 650;
}

.field-shell {
    width: min(1400px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.field-page {
    display: grid;
    gap: 18px;
}

.field-panel {
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 12px;
    padding: 18px;
}

.field-panel h2 {
    margin-top: 0;
}

.field-message {
    margin: 0;
    padding: 12px 14px;
    border-radius: 8px;
}

.field-success {
    background: #e9f7ef;
    border: 1px solid #b9e3c9;
}

.field-error {
    background: #fff0ef;
    border: 1px solid #f2c0bc;
    color: #7f1d1d;
}

.empty-state {
    padding: 24px;
    text-align: center;
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 12px;
}

.customer-table-wrap {
    overflow-x: auto;
}

.customer-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 12px;
    overflow: hidden;
}

.customer-table th,
.customer-table td {
    padding: 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid #e7edf2;
}

.customer-table th {
    background: #f7f9fb;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.customer-table tr:last-child td {
    border-bottom: 0;
}

.inline-action {
    display: inline-block;
    margin: 0;
}

.inline-action button,
.field-form button,
.primary-field-action,
.login-form button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: #0b5cab;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.service-alerts {
    display: grid;
    gap: 8px;
}

.service-alert {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.alert-blue {
    background: #dbeafe;
    color: #172033;
}

.alert-red {
    background: #fee2e2;
}

.alert-yellow {
    background: #fef3c7;
}

.alert-green {
    background: #dcfce7;
}

.field-form,
.login-form {
    display: grid;
    gap: 10px;
}

.field-form label,
.login-form label,
.service-entry-form > div > label {
    font-weight: 700;
}

.field-form input,
.field-form select,
.field-form textarea,
.login-form input,
.service-entry-form input[type="file"],
.service-entry-form textarea,
.service-entry-form select {
    width: 100%;
    min-height: 44px;
    padding: 10px;
    border: 1px solid #b9c5d1;
    border-radius: 8px;
    background: #ffffff;
}

.field-form textarea,
.service-entry-form textarea {
    min-height: 120px;
    resize: vertical;
}

.compact-form {
    margin-bottom: 24px;
}

.service-entry-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.service-column {
    display: grid;
    align-content: start;
    gap: 10px;
}

.service-column fieldset {
    margin: 0;
    border: 1px solid #dce3ea;
    border-radius: 8px;
    padding: 10px;
}

.choice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    font-weight: 500;
}

.choice input {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}

.chemical-list {
    display: grid;
    gap: 8px;
}

.chemical-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 90px auto;
    gap: 8px;
    align-items: center;
}

.chemical-row input[type="number"] {
    width: 100%;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #b9c5d1;
    border-radius: 8px;
}

.primary-field-action {
    grid-column: 1 / -1;
    min-height: 52px;
    font-size: 1.05rem;
}

.site-footer {
    padding: 24px 16px;
    text-align: center;
    color: #667085;
}

.login-shell {
    min-height: calc(100vh - 80px);
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    background: #ffffff;
    border: 1px solid #dce3ea;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 14px 35px rgba(30, 41, 59, 0.09);
}

.login-card h1 {
    margin: 0;
    font-size: 2rem;
}

.login-subtitle {
    margin-top: 4px;
    color: #667085;
}

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.62);
}

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

.confirm-box {
    width: min(360px, 100%);
    padding: 18px;
    border-radius: 12px;
    background: #111827;
    color: #ffffff;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.confirm-title {
    margin-bottom: 10px;
    font-weight: 800;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.confirm-actions button {
    flex: 1;
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    font-weight: 800;
}

.confirm-no {
    background: #e5e7eb;
}

.confirm-yes {
    background: #dc2626;
    color: #ffffff;
}


/* PPC system branding */
.system-brand img {
    max-height: 72px;
    max-width: min(230px, 52vw);
}

.company-identity {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 4px;
    text-align: right;
}

.company-identity-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 150px;
    max-height: 54px;
    object-fit: contain;
}

.company-identity-text {
    min-width: 0;
    display: grid;
    justify-items: end;
    gap: 1px;
}

.company-identity-name {
    font-weight: 800;
    color: #172033;
}

.login-brand,
.setup-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.login-brand img {
    display: block;
    width: min(240px, 72vw);
    height: auto;
}

.setup-brand img {
    display: block;
    width: min(220px, 62vw);
    height: auto;
}

.setup-panel {
    width: min(560px, calc(100% - 32px));
    margin: 28px auto;
}

@media (max-width: 760px) {
    .field-header {
        position: static;
        padding: 10px;
    }

    .system-brand img {
        max-height: 58px;
        max-width: 190px;
    }

    .company-identity {
        align-items: flex-end;
    }

    .company-identity-logo {
        max-width: 110px;
        max-height: 42px;
    }

    .field-shell {
        padding: 10px;
    }

    .field-nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .field-nav a {
        width: 100%;
        min-height: 48px;
        text-align: center;
    }

    .customer-table-wrap {
        overflow: visible;
    }

    .customer-table,
    .customer-table tbody,
    .customer-table tr,
    .customer-table td {
        display: block;
        width: 100%;
    }

    .customer-table {
        border: 0;
        background: transparent;
    }

    .customer-table thead {
        display: none;
    }

    .customer-table tr {
        margin-bottom: 14px;
        overflow: hidden;
        border: 1px solid #dce3ea;
        border-radius: 12px;
        background: #ffffff;
    }

    .customer-table td {
        border-bottom: 1px solid #e7edf2;
        padding: 14px;
    }

    .customer-table td:last-child {
        border-bottom: 0;
    }

    .actions-cell .inline-action,
    .actions-cell .inline-action button,
    .actions-cell .field-link,
    .routine-cell .inline-action,
    .routine-cell .inline-action button {
        width: 100%;
    }

    .service-entry-form {
        grid-template-columns: 1fr;
    }

    .chemical-row {
        grid-template-columns: minmax(0, 1fr) 88px auto;
    }

    input,
    select,
    textarea,
    button {
        font-size: 16px;
    }
}

.field-page-title {
    margin: 0 0 16px;
    font-size: 1.45rem;
}

.customer-view-selector {
    margin-bottom: 16px;
}

.customer-view-selector > strong {
    display: block;
    margin: 10px 0 8px;
}

.local-nav {
    margin-bottom: 8px;
}

.current-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 12px;
    border-radius: 8px;
    background: #172033;
    color: #ffffff;
    font-weight: 700;
}

.chart-wrap {
    margin: 18px 0;
    overflow-x: auto;
}

.chart-wrap img {
    max-width: 100%;
    height: auto;
}

.history-date-list {
    margin: 0;
    padding-left: 20px;
}

.history-date-list li {
    margin: 6px 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}

.stat-card {
    display: grid;
    gap: 4px;
    padding: 16px;
    border: 1px solid #dce3ea;
    border-radius: 10px;
    background: #f8fafc;
}

.stat-card strong {
    font-size: 1.5rem;
}

.stat-card span {
    color: #667085;
}

.report-toolbar {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid #dce3ea;
    border-radius: 12px;
    background: #ffffff;
}

.report-toolbar p {
    margin: 0;
}

.service-report {
    overflow-x: auto;
    background: #ffffff;
}

/* Shared Field / Office navigation ---------------------------------------- */
.app-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.app-header-top .field-date {
    margin: 0;
}

.field-nav-stack {
    display: grid;
    gap: 8px;
}

.field-nav-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.field-nav-row a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 8px;
    background: #eef4f9;
    text-decoration: none;
    font-weight: 650;
}

.nav-row-label {
    min-width: 58px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #667085;
}

.office-nav-row {
    padding-top: 8px;
    border-top: 1px solid #dce3ea;
}

.office-nav-row a {
    background: #e8f0ff;
}

@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    .app-header-top {
        align-items: flex-start;
        gap: 4px;
    }

    .field-nav-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .nav-row-label {
        grid-column: 1 / -1;
        min-width: 0;
        padding-top: 2px;
    }

    .field-nav-row a {
        width: 100%;
    }
}

.app-user-status {
    margin: 2px 0 4px;
    color: #26384a;
    font-size: 0.92rem;
}

@media (max-width: 767px) {
    .app-user-status {
        font-size: 0.86rem;
    }
}


/* Header identity/actions ------------------------------------------------- */
.app-header-meta {
    margin-left: auto;
    display: grid;
    justify-items: end;
    gap: 3px;
    text-align: right;
}

.app-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 3px;
}

.header-company,
.header-logout,
.status-legend > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #f8fafc;
    color: #172033;
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.status-legend {
    position: relative;
}

.status-legend > summary {
    list-style: none;
}

.status-legend > summary::-webkit-details-marker {
    display: none;
}

.status-legend-popover {
    position: absolute;
    z-index: 500;
    top: calc(100% + 8px);
    right: 0;
    width: min(340px, 86vw);
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
    text-align: left;
}

.status-legend-popover > strong {
    display: block;
    margin-bottom: 9px;
}

.status-legend-popover > div {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 8px;
    align-items: center;
    margin: 7px 0;
}

.legend-swatch {
    width: 16px;
    height: 16px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 4px;
}

.legend-green { background: #dcfce7; }
.legend-yellow { background: #fef3c7; }
.legend-red { background: #fee2e2; }
.legend-blue { background: #dbeafe; }

@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    .app-header-top {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: start;
    }

    .field-brand img {
        max-height: 64px;
        max-width: min(210px, 48vw);
    }

    .app-header-meta {
        justify-items: end;
    }

    .app-header-actions {
        flex-wrap: wrap;
    }
}

/* Company hub / compact management navigation */
.header-company {
    text-decoration: none;
}

.company-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 16px 0 24px;
}

.company-hub-card {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 88px;
    padding: 14px 16px;
    border: 1px solid #cfd8d2;
    border-radius: 8px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    box-sizing: border-box;
}

.company-hub-card strong {
    font-size: 1.05rem;
}

.company-hub-card span {
    color: #59645d;
    line-height: 1.35;
}

.company-hub-card:hover,
.company-hub-card:focus {
    border-color: #7e9185;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    .company-hub-grid {
        grid-template-columns: 1fr;
    }
}

.history-row-void td {
    opacity: 0.72;
    background: #f8fafc;
}

.history-row-void td:first-child {
    border-left: 4px solid #b42318;
}

/* Phase 4 completion: compact service photo thumbnails */
.service-photo-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(72px,1fr));gap:.45rem;max-width:360px}.service-photo-thumb{display:block;border-radius:8px;overflow:hidden;border:1px solid #d9e2ec;background:#fff;aspect-ratio:1/1}.service-photo-thumb img{display:block;width:100%;height:100%;object-fit:cover}
.ticket-photo-grid{max-width:640px}.ticket-photo-item{display:flex;flex-direction:column;gap:.35rem}.ticket-photo-item form{margin:0}.ticket-photo-item .small{font-size:.8rem;padding:.35rem .55rem}

/* Phase 5: mobile-first service readings and customer profile details */
.service-reading-list {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.service-reading-row {
    display: grid;
    grid-template-columns: minmax(120px, 0.9fr) minmax(120px, 1.1fr);
    gap: 10px;
    align-items: center;
}

.service-reading-row span {
    font-weight: 700;
}

.service-reading-row input {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
}

.customer-profile-media {
    display: grid;
    gap: 14px;
}

.customer-pool-profile-photo {
    display: block;
    width: min(100%, 720px);
    max-height: 460px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid #dce3ea;
}

.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.equipment-card {
    border: 1px solid #dce3ea;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    display: grid;
    gap: 5px;
}

.equipment-card > strong {
    font-size: 1rem;
}

.equipment-notes {
    margin-top: 6px;
}

.button-link {
    display: inline-block;
    padding: 10px 14px;
    min-height: 44px;
    box-sizing: border-box;
    border-radius: 8px;
    background: #0b5cab;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

@media (max-width: 640px) {
    .service-reading-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}


/* Platform read-only View as User banner */
.impersonation-banner {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 16px;
    background: #fff4cc;
    border-bottom: 2px solid #d39b00;
    color: #4d3900;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.impersonation-banner div { display: flex; flex-direction: column; gap: 2px; }
.impersonation-banner strong { font-size: .95rem; }
.impersonation-banner span { font-size: .86rem; }
.impersonation-banner form { margin: 0; flex: 0 0 auto; }
.impersonation-banner button {
    border: 0;
    border-radius: 7px;
    padding: 8px 11px;
    background: #5c4300;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
@media (max-width: 640px) {
    .impersonation-banner { align-items: stretch; padding: 9px 10px; }
    .impersonation-banner span { display: none; }
    .impersonation-banner button { white-space: nowrap; }
}


/* User activity and history chart controls */
.activity-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-weight: 700;
    font-size: .9rem;
}
.activity-status::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #7a8694;
}
.activity-active::before { background: #198754; }
.activity-recent::before { background: #d79b00; }
.activity-offline::before { background: #7a8694; }
.activity-list {
    display: grid;
    gap: 8px;
}
.activity-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #e3e8ee;
}
.activity-list-row > div {
    display: grid;
    gap: 2px;
}
.chart-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
}
.chart-heading-row h3 { margin: 0; }
.chart-modal-open { border: 0; cursor: pointer; font: inherit; }
.chart-dialog {
    width: min(900px, calc(100vw - 28px));
    max-height: 90vh;
    border: 0;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 18px 60px rgba(0,0,0,.28);
}
.chart-dialog::backdrop { background: rgba(0,0,0,.55); }
.chart-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.chart-dialog-header h3 { margin: 0; }
.chart-dialog-close {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}
.filter-clean-date {
    display: inline-grid;
    gap: 4px;
    margin-right: 8px;
    font-size: .85rem;
}
@media (max-width: 640px) {
    .activity-list-row { align-items: flex-start; }
    .chart-dialog { padding: 10px; }
    .filter-clean-date { display: grid; margin: 0 0 8px; }
}

/* Saved route ordering */
.route-day-tools {
    display: grid;
    gap: 12px;
}
.route-day-tools-heading,
.route-order-heading,
.route-summary,
.route-save-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.route-user-picker,
.route-picker-form {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0;
}
.route-user-picker label,
.route-picker-form label {
    font-weight: 700;
}
.route-user-picker select,
.route-picker-form select {
    min-width: 190px;
}
.route-hint {
    margin: 0;
}
.field-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border-radius: 8px;
    background: #1769aa;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.field-action-button:hover,
.field-action-button:focus {
    background: #12558b;
    color: #fff;
}
.route-stop-badge {
    display: inline-block;
    margin-left: 7px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #e6f1fa;
    color: #174d73;
    font-size: .75rem;
    font-weight: 800;
    vertical-align: middle;
}
.route-stop-unplaced,
.route-unplaced-count {
    background: #fff0c7;
    color: #704d00;
}
.route-order-page h1 {
    margin-bottom: 4px;
}
.route-order-controls {
    margin: 16px 0;
    padding: 12px;
    border: 1px solid #dce4ec;
    border-radius: 10px;
    background: #f8fafc;
}
.route-summary {
    margin: 14px 0 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dce4ec;
}
.route-summary span {
    padding: 4px 8px;
    border-radius: 999px;
    background: #edf2f7;
    font-size: .84rem;
    font-weight: 700;
}
.route-summary .route-unplaced-count {
    background: #fff0c7;
}
.route-sort-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}
.route-sort-item {
    display: grid;
    grid-template-columns: 30px 38px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 11px 12px;
    border: 1px solid #d8e0e8;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    cursor: grab;
}
.route-sort-item.is-dragging {
    opacity: .55;
    cursor: grabbing;
}
.route-sort-unplaced {
    border-style: dashed;
    border-color: #d6a637;
    background: #fffdf6;
}
.route-drag-handle {
    font-size: 1.15rem;
    color: #6f7c89;
    text-align: center;
}
.route-stop-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #1769aa;
    color: #fff;
    font-weight: 800;
}
.route-stop-info {
    min-width: 0;
    display: grid;
    gap: 3px;
}
.route-stop-info span {
    color: #596775;
    font-size: .9rem;
}
.route-stop-info em {
    color: #865d00;
    font-size: .8rem;
    font-style: normal;
    font-weight: 700;
}
.route-move-buttons {
    display: flex;
    gap: 6px;
}
.route-move-buttons button {
    width: 38px;
    min-height: 38px;
    padding: 0;
    font-size: 1.05rem;
}
.route-save-bar {
    margin-top: 14px;
    justify-content: flex-end;
}
.route-clear-form {
    margin-top: 10px;
    text-align: right;
}
.secondary-button {
    background: #eef2f5 !important;
    color: #263746 !important;
    border: 1px solid #ccd6df !important;
}
.route-message,
.route-install-warning {
    margin: 12px 0;
    padding: 11px 13px;
    border-radius: 9px;
}
.route-message-success {
    background: #e8f5ec;
    border: 1px solid #9ed0aa;
    color: #245b31;
}
.route-message-error,
.route-install-warning {
    background: #fff0ee;
    border: 1px solid #e5aaa4;
    color: #7b2e27;
}
.route-install-warning p {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .route-day-tools-heading,
    .route-order-heading,
    .route-summary,
    .route-save-bar {
        align-items: stretch;
    }
    .route-user-picker,
    .route-picker-form {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    .route-user-picker select,
    .route-picker-form select,
    .field-action-button {
        width: 100%;
    }
    .route-sort-item {
        grid-template-columns: 26px 34px minmax(0, 1fr);
        padding: 10px 8px;
    }
    .route-move-buttons {
        grid-column: 2 / 4;
        justify-content: flex-end;
    }
    .route-move-buttons button {
        width: 46px;
        min-height: 42px;
    }
    .route-save-bar,
    .route-clear-form {
        text-align: stretch;
    }
    .route-save-bar button,
    .route-clear-form button {
        width: 100%;
    }
}

/* Phase 8: Rain Day batch service workflow */
.field-page-title-row,
.route-day-actions,
.rain-day-heading,
.rain-day-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.field-page-title-row .field-page-title { margin: 0; }
.route-day-actions { justify-content: flex-end; }

.rain-day-button,
.rain-day-submit {
    background: #355f8a;
    border-color: #355f8a;
}

.rain-day-page {
    display: grid;
    gap: 16px;
}

.rain-day-heading h1 { margin: 0 0 4px; }
.rain-day-user-picker { margin: 0; }

.rain-day-summary {
    padding: 12px 14px;
    border: 1px solid #d9e2ec;
    border-radius: 10px;
    background: #f8fafc;
}

.rain-day-form {
    display: grid;
    gap: 12px;
}

.rain-day-form textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 110px;
    resize: vertical;
}

.rain-day-customer-list {
    border: 1px solid #d9e2ec;
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
}

.rain-day-customer-list summary {
    cursor: pointer;
    font-weight: 700;
}

.rain-day-customer-list ol {
    margin: 12px 0 0;
    padding-left: 24px;
    display: grid;
    gap: 9px;
}

.rain-day-customer-list li {
    padding-left: 4px;
}

.rain-day-customer-list li strong,
.rain-day-customer-list li span,
.rain-day-customer-list li small {
    display: block;
}

.rain-day-customer-list li span,
.rain-day-customer-list li small {
    color: #52606d;
    margin-top: 2px;
}

.rain-day-errors,
.route-message-warning {
    padding: 11px 13px;
    border-radius: 9px;
    border: 1px solid #d39b00;
    background: #fff7df;
    color: #5c4300;
}

@media (max-width: 640px) {
    .field-page-title-row,
    .rain-day-heading,
    .rain-day-summary {
        align-items: stretch;
    }

    .field-page-title-row .field-action-button,
    .route-day-actions,
    .route-day-actions .field-action-button,
    .rain-day-heading .field-action-button,
    .rain-day-submit {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }
}

/* Internal daily route map */
.route-map-page {
    display: grid;
    gap: 14px;
}
.route-map-heading,
.route-map-progressbar,
.route-map-progress-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.route-map-heading h1 {
    margin: 0 0 4px;
}
.route-map-picker {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #dce4ec;
    border-radius: 10px;
    background: #f8fafc;
}
.route-map-warning,
.route-geocode-status {
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid #e8ca77;
    background: #fff6d8;
    color: #614600;
}
.route-geocode-status {
    border-color: #a9c7de;
    background: #eef7fd;
    color: #174d73;
}
.route-map-progressbar {
    padding: 10px 12px;
    border: 1px solid #dce4ec;
    border-radius: 10px;
    background: #fff;
}
.route-map-progressbar > div:first-child {
    display: grid;
    gap: 2px;
}
.route-map-progressbar span {
    font-size: .84rem;
    color: #637180;
}
.route-map-layout {
    display: grid;
    grid-template-columns: minmax(270px, 34%) minmax(0, 1fr);
    min-height: 650px;
    border: 1px solid #d5dee7;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.route-map-sidebar {
    max-height: 650px;
    overflow-y: auto;
    border-right: 1px solid #d5dee7;
    background: #f8fafc;
}
.route-map-stop {
    border-bottom: 1px solid #dde5ec;
    background: #fff;
}
.route-map-stop.is-current {
    box-shadow: inset 4px 0 0 #1769aa;
    background: #f2f8fc;
}
.route-map-stop.is-complete {
    opacity: .72;
}
.route-map-stop-focus {
    width: 100%;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.route-map-stop-number,
.ppc-route-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #1769aa;
    color: #fff;
    font-weight: 800;
    line-height: 1;
}
.route-map-stop.is-complete .route-map-stop-number,
.ppc-route-marker.is-complete {
    background: #2c8a52;
}
.route-map-stop-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}
.route-map-stop-copy strong {
    font-size: .96rem;
}
.route-map-stop-copy span {
    font-size: .83rem;
    color: #5d6b78;
}
.route-map-stop-copy em {
    font-size: .76rem;
    font-style: normal;
    font-weight: 700;
    color: #2c6f47;
}
.route-map-stop-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 11px 60px;
}
.route-map-stop-actions a {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 7px;
    background: #edf2f7;
    color: #174d73;
    text-decoration: none;
    font-size: .82rem;
    font-weight: 700;
}
.route-map-stop-actions .route-nav-link {
    background: #1769aa;
    color: #fff;
}
.route-map-canvas-wrap {
    position: relative;
    min-width: 0;
}
.route-map-canvas {
    width: 100%;
    height: 650px;
    background: #e8eef3;
}
.route-map-legend {
    position: absolute;
    z-index: 500;
    left: 10px;
    bottom: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 7px 9px;
    border-radius: 8px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 1px 5px rgba(0,0,0,.18);
    font-size: .76rem;
    font-weight: 700;
}
.route-map-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.route-map-legend-pin {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #1769aa;
}
.route-map-legend-pin.is-complete {
    background: #2c8a52;
}
.ppc-route-marker-shell {
    background: transparent;
    border: 0;
}
.ppc-route-marker {
    width: 36px;
    height: 36px;
    border: 3px solid #fff;
    box-shadow: 0 2px 7px rgba(0,0,0,.35);
}
.route-map-popup {
    min-width: 190px;
    line-height: 1.45;
}
.route-map-popup a {
    font-weight: 700;
}

@media (max-width: 800px) {
    .route-map-layout {
        grid-template-columns: 1fr;
        min-height: 0;
    }
    .route-map-canvas-wrap {
        order: -1;
    }
    .route-map-canvas {
        height: 55vh;
        min-height: 420px;
    }
    .route-map-sidebar {
        max-height: none;
        border-right: 0;
        border-top: 1px solid #d5dee7;
    }
    .route-map-progress-actions {
        width: 100%;
    }
    .route-map-progress-actions button {
        flex: 1 1 140px;
    }
}


/* PPC account setup branding */
.account-setup-panel {
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}
.account-setup-brand {
    text-align: center;
    margin: 0 0 18px;
}
.account-setup-brand img {
    display: inline-block;
    max-width: min(300px, 78vw);
    max-height: 96px;
    width: auto;
    height: auto;
}

/* PPC 0.9.0 Field Readiness */
.readiness-hero{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap}.readiness-hero h1{margin-bottom:.25rem}.readiness-section-heading{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.readiness-stock-form{display:grid;gap:14px}.readiness-stock-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:10px}.readiness-stock-row{display:grid;grid-template-columns:minmax(0,1fr) 100px;gap:10px;align-items:center;padding:12px;border:1px solid #d6dee7;border-radius:9px;background:#fff}.readiness-stock-row.is-low{border-color:#d92d20;background:#fff6f5}.readiness-stock-row span{display:grid;gap:3px}.readiness-stock-row small{color:#657383}.readiness-stock-row input{width:100%}.readiness-list{display:grid;gap:12px}.readiness-notice,.readiness-checklist{padding:14px;border:1px solid #d6dee7;border-radius:9px;background:#fff}.readiness-notice.is-complete,.readiness-checklist.is-complete{background:#f5fbf7;border-color:#b7dfc4}.readiness-notice h3,.readiness-checklist h3{margin:.1rem 0 .35rem}.readiness-notice form,.readiness-checklist form{margin-top:10px}.readiness-checklist>div:first-child{display:flex;align-items:center;justify-content:space-between;gap:10px}.readiness-badge{display:inline-flex;padding:3px 7px;border-radius:999px;background:#eaf2f8;color:#174d73;font-size:.75rem;font-weight:800}.readiness-done{margin-top:8px;font-weight:800;color:#237044}.readiness-checklist ul{margin:.5rem 0 .2rem 1.2rem;padding:0}@media(max-width:650px){.readiness-stock-grid{grid-template-columns:1fr}.readiness-stock-row{grid-template-columns:minmax(0,1fr) 90px}.readiness-hero .field-action-button{width:100%;text-align:center}}
.field-search-form{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.field-search-form input{flex:1 1 260px;min-width:0}.knowledge-article h2{margin:.2rem 0 .75rem}.knowledge-meta{font-size:.78rem;font-weight:800;text-transform:uppercase;letter-spacing:.04em;color:#617387}.knowledge-body{line-height:1.55;white-space:normal}

/* PPC 0.9.7 - LSI water balance */
.lsi-heading-row{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap}
.lsi-input-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:14px;margin-bottom:16px}
.lsi-input-grid label{display:flex;flex-direction:column;gap:6px;font-weight:600}
.lsi-result{margin-top:18px;padding:18px;border:1px solid var(--field-border,#d7dde5);border-radius:12px;background:#f7f9fb}
.lsi-score-wrap{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap}
.lsi-score-label{font-weight:700;text-transform:uppercase;letter-spacing:.06em}
.lsi-score{font-size:2.25rem;line-height:1}
.lsi-status{font-weight:700}
.lsi-result-balanced{border-left:6px solid #2f855a}
.lsi-result-caution{border-left:6px solid #d69e2e}
.lsi-result-low{border-left:6px solid #b91c1c}
.lsi-result-high{border-left:6px solid #805ad5}
.lsi-result-error{border-left:6px solid #b91c1c}
.lsi-result-details{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-top:14px}
.lsi-result-details>div{padding:10px;border-radius:8px;background:rgba(255,255,255,.75)}
.lsi-result-details span{display:block;font-size:.85rem;opacity:.75;margin-bottom:3px}
.lsi-service-launch{margin-top:14px}
@media(max-width:640px){.lsi-input-grid{grid-template-columns:1fr}.lsi-heading-row .primary-field-action{width:100%;text-align:center}.lsi-score{font-size:2rem}}

/* PPC 0.9.8 - historical chemistry source notice */
.lsi-source-notice {
    margin: 14px 0 18px;
    padding: 14px 16px;
    border: 1px solid rgba(0,0,0,.14);
    border-radius: 10px;
    background: rgba(0,0,0,.035);
}
.lsi-source-notice strong,
.lsi-source-notice span {
    display: block;
}
.lsi-source-notice span {
    margin-top: 3px;
    font-size: .92rem;
    opacity: .75;
}
.lsi-source-notice p {
    margin: 9px 0 0;
}
.lsi-source-empty {
    border-style: dashed;
}


/* PPC 0.9.10 - mobile accordion navigation and profile history matrices */
.nav-row-toggle {
    display: none;
}

.nav-row-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.pool-volume-row,
.volume-inline-form,
.history-heading-row,
.service-ticket-dialog-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pool-volume-row {
    margin-bottom: 14px;
}

.volume-inline-form {
    margin: 0;
}

.volume-inline-form input {
    width: 150px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid #b9c5d1;
    border-radius: 8px;
    background: #fff;
}

.volume-inline-form button,
.history-ticket-link,
.service-ticket-dialog-close {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.volume-inline-form button {
    background: #0b5cab;
    color: #fff;
}

.history-heading-row,
.service-ticket-dialog-header {
    justify-content: space-between;
    align-items: flex-start;
}

.history-heading-row h2,
.service-ticket-dialog-header h2 {
    margin-bottom: 4px;
}

.history-matrix-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

.history-matrix {
    min-width: 0;
    table-layout: auto;
}

.chemical-usage-matrix {
    min-width: max-content;
}

.history-matrix th,
.history-matrix td {
    white-space: nowrap;
    text-align: center;
}

.history-matrix .history-sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 106px;
    text-align: left;
    background: #fff;
    box-shadow: 1px 0 0 #dce3ea;
}

.history-matrix thead .history-sticky-col {
    z-index: 3;
    background: #f7f9fb;
}

.history-ticket-link {
    background: transparent;
    color: #0b5cab;
    padding: 4px 2px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.history-row-void {
    opacity: .6;
}

.service-ticket-dialog {
    width: min(900px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    border: 0;
    border-radius: 14px;
    padding: 18px;
    overflow: auto;
    color: #172033;
    background: #fff;
    box-shadow: 0 20px 70px rgba(0,0,0,.28);
}

.service-ticket-dialog::backdrop {
    background: rgba(15, 23, 42, .58);
}

.service-ticket-dialog-close {
    background: #eef4f9;
    color: #172033;
}

.service-ticket-dialog-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.service-ticket-dialog-grid section {
    padding: 12px;
    border: 1px solid #dce3ea;
    border-radius: 10px;
    background: #f8fafc;
}

.service-ticket-dialog-grid h3 {
    margin-top: 0;
}

@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    .field-nav-stack {
        display: grid;
        gap: 8px;
    }

    .field-nav-row,
    .field-nav-row.office-nav-row,
    .field-nav-row.systems-nav-row {
        display: block;
        padding: 0;
        border-top: 0;
    }

    .nav-row-toggle {
        display: flex;
        width: 100%;
        min-height: 46px;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 14px;
        border: 1px solid #dce3ea;
        border-radius: 10px;
        background: #f3f5f7;
        color: #26384a;
        cursor: pointer;
        font: inherit;
    }

    .nav-row-toggle .nav-row-label {
        min-width: 0;
        padding: 0;
        color: inherit;
        font-size: .82rem;
    }

    .nav-row-chevron {
        transition: transform .16s ease;
    }

    .field-nav-row.is-open .nav-row-chevron {
        transform: rotate(180deg);
    }

    .nav-row-links {
        display: none;
        width: 100%;
        padding-top: 6px;
        gap: 6px;
    }

    .field-nav-row.is-open .nav-row-links {
        display: grid;
        grid-template-columns: 1fr;
    }

    .field-nav-row .nav-row-links a {
        width: 100%;
        min-height: 44px;
        justify-content: flex-start;
        padding: 10px 14px;
    }

    .office-nav-row .nav-row-links a {
        background: #e8f0ff;
    }

    .systems-nav-row .nav-row-links a {
        background: #eef4f9;
    }

    .history-heading-row {
        align-items: stretch;
    }

    .history-heading-row .button-link {
        align-self: flex-start;
    }

    .service-ticket-dialog {
        width: 100vw;
        max-width: none;
        height: 100dvh;
        max-height: none;
        margin: 0;
        border-radius: 0;
        padding: 16px;
    }

    .service-ticket-dialog-grid {
        grid-template-columns: 1fr;
    }

    .volume-inline-form {
        width: 100%;
        align-items: stretch;
    }

    .volume-inline-form input {
        flex: 1 1 150px;
        width: auto;
    }
}


/* iPhone Safari accordion hardening */
@media screen and (max-width: 700px), screen and (hover: none) and (pointer: coarse) {
    .field-header .field-nav-stack .field-nav-row {
        display: block !important;
        grid-template-columns: none !important;
        width: 100% !important;
    }

    .field-header .field-nav-stack .nav-row-toggle {
        display: flex !important;
        width: 100% !important;
        grid-column: auto !important;
    }

    .field-header .field-nav-stack .nav-row-links {
        display: none !important;
        width: 100% !important;
        grid-column: auto !important;
    }

    .field-header .field-nav-stack .field-nav-row.is-open .nav-row-links {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    .field-header .field-nav-stack .nav-row-links > a {
        width: 100% !important;
    }
}


/* PPC mobile accordion: server-selected, independent of Safari viewport reporting */
.field-nav-stack.mobile-accordion {
    display: grid !important;
    gap: 8px !important;
}

.field-nav-stack.mobile-accordion .field-nav-row,
.field-nav-stack.mobile-accordion .field-nav-row.office-nav-row,
.field-nav-stack.mobile-accordion .field-nav-row.systems-nav-row {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border-top: 0 !important;
}

.field-nav-stack.mobile-accordion .nav-row-toggle {
    display: flex !important;
    width: 100% !important;
    min-height: 48px !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 14px !important;
    border: 1px solid #dce3ea !important;
    border-radius: 10px !important;
    background: #eef2f5 !important;
    color: #26384a !important;
}

.field-nav-stack.mobile-accordion .nav-row-toggle .nav-row-label {
    min-width: 0 !important;
    padding: 0 !important;
    color: inherit !important;
}

.field-nav-stack.mobile-accordion .nav-row-links {
    display: none !important;
    width: 100% !important;
    padding-top: 6px !important;
}

.field-nav-stack.mobile-accordion .field-nav-row.is-open .nav-row-links {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 6px !important;
}

.field-nav-stack.mobile-accordion .nav-row-links > a {
    width: 100% !important;
    min-height: 44px !important;
    justify-content: flex-start !important;
    padding: 10px 14px !important;
}

.field-nav-stack.mobile-accordion .field-nav-row.is-open .nav-row-chevron {
    transform: rotate(180deg);
}


/* PPC profile mobile cleanup: preserve true history matrices and compact summary */
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    /* History tables must stay tables; older PPC mobile rules turn generic
       customer-table markup into stacked cards. */
    .history-matrix-wrap.customer-table-wrap {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        width: 100% !important;
    }

    .history-matrix.customer-table {
        display: table !important;
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
        background: #fff !important;
        border: 1px solid #dce3ea !important;
        border-radius: 12px !important;
    }

    .history-matrix.customer-table thead {
        display: table-header-group !important;
    }

    .history-matrix.customer-table tbody {
        display: table-row-group !important;
    }

    .history-matrix.customer-table tr {
        display: table-row !important;
        width: auto !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        overflow: visible !important;
    }

    .history-matrix.customer-table th,
    .history-matrix.customer-table td {
        display: table-cell !important;
        width: auto !important;
        min-width: 0 !important;
        padding: 8px 5px !important;
        white-space: nowrap !important;
        vertical-align: middle !important;
        border-bottom: 1px solid #e7edf2 !important;
    }

    .history-matrix.customer-table th {
        background: #f7f9fb !important;
        font-size: .76rem !important;
        line-height: 1.2;
    }

    .history-matrix.customer-table .history-sticky-col {
        min-width: 94px !important;
        position: sticky !important;
        left: 0 !important;
    }

    .chemical-usage-matrix.customer-table {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Customer profile summary only: compact the existing four-column table
       without changing customer lists elsewhere in PPC. */
    .customer-profile-summary .customer-table-wrap {
        overflow: visible !important;
    }

    .customer-profile-summary .customer-table,
    .customer-profile-summary .customer-table tbody {
        display: block !important;
        width: 100% !important;
    }

    .customer-profile-summary .customer-table thead {
        display: none !important;
    }

    .customer-profile-summary .customer-table tr {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        width: 100% !important;
        margin: 0 !important;
        border: 1px solid #dce3ea !important;
        border-radius: 12px !important;
        overflow: hidden !important;
        background: #fff !important;
    }

    .customer-profile-summary .customer-table td {
        display: block !important;
        width: auto !important;
        padding: 12px !important;
        border-bottom: 1px solid #e7edf2 !important;
    }

    .customer-profile-summary .customer-cell,
    .customer-profile-summary .routine-cell {
        font-size: .9rem;
        line-height: 1.35;
    }

    .customer-profile-summary .customer-cell {
        border-right: 1px solid #e7edf2;
    }

    .customer-profile-summary .customer-cell strong {
        font-size: 1.05rem;
    }

    .customer-profile-summary .alerts-cell,
    .customer-profile-summary .actions-cell {
        grid-column: 1 / -1;
    }

    .customer-profile-summary .alerts-cell {
        padding: 10px 12px !important;
    }

    .customer-profile-summary .service-alerts {
        gap: 6px;
    }

    .customer-profile-summary .service-alert {
        padding: 8px 10px;
        font-size: .86rem;
        line-height: 1.3;
    }

    .customer-profile-summary .actions-cell {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 10px 12px 12px !important;
        border-bottom: 0 !important;
    }

    .customer-profile-summary .actions-cell br {
        display: none;
    }

    .customer-profile-summary .actions-cell > a,
    .customer-profile-summary .actions-cell > button,
    .customer-profile-summary .actions-cell > form,
    .customer-profile-summary .actions-cell .inline-action,
    .customer-profile-summary .actions-cell .inline-action button,
    .customer-profile-summary .actions-cell .field-link,
    .customer-profile-summary .actions-cell .primary-field-action {
        width: 100% !important;
        margin: 0 !important;
    }

    .customer-profile-summary .actions-cell .field-link,
    .customer-profile-summary .actions-cell button {
        min-height: 42px !important;
    }

    .customer-profile-summary .actions-cell .field-link:last-child {
        grid-column: 1 / -1;
    }
}

@media (max-width: 430px) {
    .customer-profile-summary .customer-table tr {
        grid-template-columns: 1fr;
    }

    .customer-profile-summary .customer-cell {
        border-right: 0;
    }

    .customer-profile-summary .routine-cell {
        border-top: 1px solid #e7edf2;
    }
}


/* PPC profile summary tightening */
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    .customer-profile-summary {
        font-size: .92rem;
    }

    .customer-profile-summary .customer-table tr {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr) !important;
    }

    .customer-profile-summary .customer-table td {
        padding: 10px 12px !important;
        line-height: 1.28 !important;
        font-size: .9rem !important;
    }

    .customer-profile-summary .actions-cell br {
        display: none !important;
    }

    .customer-profile-summary .customer-cell,
    .customer-profile-summary .routine-cell {
        min-width: 0;
    }

    .customer-profile-summary .customer-cell strong {
        display: block;
        margin-bottom: 6px;
        font-size: 1rem !important;
    }

    .customer-profile-summary .customer-cell a,
    .customer-profile-summary .routine-cell a {
        overflow-wrap: anywhere;
    }

    .customer-profile-summary .customer-cell .inline-action,
    .customer-profile-summary .routine-cell .inline-action {
        margin-top: 6px !important;
    }

    .customer-profile-summary .routine-cell .inline-action button,
    .customer-profile-summary .customer-cell .inline-action button {
        min-height: 38px !important;
        padding: 8px 10px !important;
    }

    .customer-profile-summary .alerts-cell {
        grid-column: 1 / -1 !important;
    }

    .customer-profile-summary .actions-cell {
        grid-column: 1 / -1 !important;
    }
}

@media (max-width: 430px) {
    .customer-profile-summary .customer-table tr {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .customer-profile-summary .customer-cell,
    .customer-profile-summary .routine-cell {
        border-right: 0 !important;
    }

    .customer-profile-summary .customer-cell {
        padding-bottom: 8px !important;
    }

    .customer-profile-summary .routine-cell {
        padding-top: 8px !important;
    }
}


/* PPC five-date viewport containment */
@media (max-width: 700px), (hover: none) and (pointer: coarse) {
    .service-history-panel,
    .chemical-history-panel,
    .history-matrix-wrap {
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
    }

    .history-matrix.customer-table,
    .chemical-usage-matrix.customer-table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
    }

    .history-matrix.customer-table th,
    .history-matrix.customer-table td {
        min-width: 0 !important;
        width: auto !important;
        padding: 7px 3px !important;
        font-size: .72rem !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: clip;
    }

    .history-matrix.customer-table .history-label-col,
    .chemical-usage-matrix.customer-table th:first-child {
        width: 64px !important;
        min-width: 64px !important;
        max-width: 64px !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .history-matrix.customer-table .history-ticket-link {
        padding: 2px 0 !important;
        font-size: .68rem !important;
        min-height: 0 !important;
        white-space: nowrap;
    }

    .customer-profile-summary .customer-cell br,
    .customer-profile-summary .routine-cell br {
        display: initial !important;
    }
}


/* Compact customer profile summary */
.customer-profile-summary .customer-table-wrap {
    overflow: visible;
}
.customer-profile-summary .customer-table {
    width: 100%;
}
.customer-profile-summary .customer-table tr {
    display: grid;
    grid-template-columns: 1fr;
}
.customer-profile-summary .customer-table thead {
    display: none;
}
.customer-profile-summary .customer-table td {
    display: block;
    width: 100%;
}
.customer-profile-summary .customer-cell,
.customer-profile-summary .routine-cell {
    padding: 14px 16px !important;
}
.customer-profile-summary .customer-cell {
    border-bottom: 0 !important;
}
.customer-profile-summary .routine-cell {
    border-top: 1px solid #e7edf2;
}
.customer-profile-summary .customer-identity-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    line-height: 1.35;
}
.customer-profile-summary .customer-identity-line strong {
    font-size: 1.08rem;
}
.customer-profile-summary .customer-email,
.customer-profile-summary .customer-phone {
    font-size: .94rem;
}
.customer-profile-summary .customer-contact-missing {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 6px;
    color: #6b7280;
    font-size: .9rem;
}
.customer-profile-summary .customer-address {
    margin-top: 10px;
    line-height: 1.35;
}
.customer-profile-summary .customer-service-line {
    margin-bottom: 8px;
    font-weight: 600;
}
.customer-profile-summary .customer-meta-line {
    margin-bottom: 8px;
    line-height: 1.35;
}
.customer-profile-summary .customer-date-line {
    line-height: 1.45;
}
.customer-profile-summary .customer-management-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.customer-profile-summary .customer-management-actions form,
.customer-profile-summary .customer-management-actions .inline-action {
    margin: 0;
}
.customer-profile-summary .customer-management-actions a,
.customer-profile-summary .customer-management-actions button {
    width: auto !important;
    min-height: 40px;
    margin: 0 !important;
}
.customer-profile-summary .customer-edit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
@media (max-width: 430px) {
    .customer-profile-summary .customer-management-actions {
        display: grid;
        grid-template-columns: 1fr;
    }
    .customer-profile-summary .customer-management-actions a,
    .customer-profile-summary .customer-management-actions form,
    .customer-profile-summary .customer-management-actions button {
        width: 100% !important;
    }
}


/* Final profile-card layout cleanup */
.customer-profile-summary .customer-management-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-top: 12px !important;
}
.customer-profile-summary .customer-management-actions > a,
.customer-profile-summary .customer-management-actions > form,
.customer-profile-summary .customer-management-actions .inline-action,
.customer-profile-summary .customer-management-actions button {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
}
.customer-profile-summary .customer-management-actions a,
.customer-profile-summary .customer-management-actions button {
    min-height: 42px !important;
    padding: 8px 10px !important;
    font-size: .88rem !important;
    line-height: 1.15 !important;
}

.customer-profile-summary .alerts-cell {
    padding: 12px 16px !important;
}
.customer-profile-summary .service-alerts {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
}
.customer-profile-summary .service-alert {
    margin: 0 !important;
    padding: 10px 12px !important;
    min-width: 0 !important;
    font-size: .84rem !important;
    line-height: 1.28 !important;
}

.customer-profile-summary .actions-cell {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    padding: 12px 16px 16px !important;
}
.customer-profile-summary .actions-cell br {
    display: none !important;
}
.customer-profile-summary .actions-cell > a,
.customer-profile-summary .actions-cell > button,
.customer-profile-summary .actions-cell > form,
.customer-profile-summary .actions-cell .inline-action {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
}
.customer-profile-summary .actions-cell > form button,
.customer-profile-summary .actions-cell .inline-action button,
.customer-profile-summary .actions-cell > button,
.customer-profile-summary .actions-cell .field-link,
.customer-profile-summary .actions-cell .primary-field-action {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 44px !important;
    padding: 9px 10px !important;
    margin: 0 !important;
    font-size: .9rem !important;
    line-height: 1.15 !important;
    text-align: center !important;
    border-radius: 8px !important;
}
.customer-profile-summary .actions-cell .field-link:last-child {
    grid-column: 1 / -1 !important;
}

@media (max-width: 430px) {
    .customer-profile-summary .customer-management-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
    .customer-profile-summary .service-alerts {
        grid-template-columns: 1fr !important;
    }
    .customer-profile-summary .customer-management-actions a,
    .customer-profile-summary .customer-management-actions button {
        font-size: .78rem !important;
        padding: 7px 5px !important;
    }
}


/* Compact customers listing cards */
@media (max-width: 760px) {
    .customer-listing .customer-table-wrap {
        overflow: visible !important;
    }

    .customer-listing .customer-table,
    .customer-listing .customer-table tbody {
        display: block !important;
        width: 100% !important;
    }

    .customer-listing .customer-table thead {
        display: none !important;
    }

    .customer-listing .customer-table tr {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
        margin-bottom: 12px !important;
        overflow: hidden !important;
        border: 1px solid #dce3ea !important;
        border-radius: 12px !important;
        background: #fff !important;
    }

    .customer-listing .customer-table td {
        display: block !important;
        width: 100% !important;
        padding: 12px 14px !important;
        border-bottom: 1px solid #e7edf2 !important;
        font-size: .9rem !important;
        line-height: 1.32 !important;
    }

    .customer-listing .customer-cell {
        border-bottom: 0 !important;
    }

    .customer-listing .routine-cell {
        border-top: 1px solid #e7edf2 !important;
    }

    .customer-listing .customer-identity-line {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 8px;
    }

    .customer-listing .customer-identity-line strong {
        font-size: 1rem;
    }

    .customer-listing .customer-email,
    .customer-listing .customer-phone {
        font-size: .86rem;
    }

    .customer-listing .customer-contact-missing {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 12px;
        margin-top: 5px;
        color: #6b7280;
        font-size: .84rem;
    }

    .customer-listing .customer-address {
        margin-top: 8px;
        line-height: 1.3;
    }

    .customer-listing .customer-service-line {
        margin-bottom: 6px;
        font-weight: 600;
    }

    .customer-listing .customer-meta-line {
        margin-bottom: 6px;
    }

    .customer-listing .customer-date-line {
        line-height: 1.4;
    }

    .customer-listing .customer-management-actions {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0,1fr)) !important;
        gap: 6px !important;
        margin-top: 10px !important;
    }

    .customer-listing .customer-management-actions > a,
    .customer-listing .customer-management-actions > form,
    .customer-listing .customer-management-actions button {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
    }

    .customer-listing .customer-management-actions a,
    .customer-listing .customer-management-actions button {
        min-height: 38px !important;
        padding: 7px 6px !important;
        font-size: .78rem !important;
        line-height: 1.12 !important;
    }

    .customer-listing .alerts-cell {
        padding: 10px 12px !important;
    }

    .customer-listing .service-alerts {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0,1fr)) !important;
        gap: 6px !important;
    }

    .customer-listing .service-alert {
        margin: 0 !important;
        padding: 8px 9px !important;
        font-size: .78rem !important;
        line-height: 1.22 !important;
    }

    .customer-listing .actions-cell {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0,1fr)) !important;
        gap: 6px !important;
        padding: 10px 12px 12px !important;
        border-bottom: 0 !important;
    }

    .customer-listing .actions-cell br {
        display: none !important;
    }

    .customer-listing .actions-cell > a,
    .customer-listing .actions-cell > button,
    .customer-listing .actions-cell > form,
    .customer-listing .actions-cell .inline-action {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
    }

    .customer-listing .actions-cell > form button,
    .customer-listing .actions-cell .inline-action button,
    .customer-listing .actions-cell > button,
    .customer-listing .actions-cell .field-link,
    .customer-listing .actions-cell .primary-field-action {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        min-height: 40px !important;
        padding: 8px 8px !important;
        margin: 0 !important;
        font-size: .82rem !important;
        line-height: 1.12 !important;
        text-align: center !important;
    }

    .customer-listing .actions-cell .field-link:last-child {
        grid-column: 1 / -1 !important;
    }
}

@media (max-width: 430px) {
    .customer-listing .service-alerts {
        grid-template-columns: 1fr !important;
    }
}


/* Center button-styled links in customer listing management row */
.customer-listing .customer-management-actions > a,
.customer-listing .customer-management-actions .button-link {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
}
