/**
 * Clinic self-service portal styles.
 * Mobile-first, namespaced under .cp-* to avoid theme collisions.
 */

/* --- Design tokens --------------------------------------------------- */
/* Palette tuned to match petsnoot.com: white background, teal brand
 * accent, softly-rounded cards and pill-shaped CTAs. */
.clinic-portal-body {
    --cp-color-bg: #ffffff;
    --cp-color-surface: #ffffff;
    --cp-color-surface-soft: #f7f9fb;
    --cp-color-border: #edeef1;
    --cp-color-border-strong: #d9dde2;
    --cp-color-text: #2b333b;
    --cp-color-text-muted: #6b737b;
    --cp-color-text-dim: #8a9099;
    --cp-color-primary: #1dafa5;
    --cp-color-primary-hover: #178b83;
    --cp-color-primary-bg: #e0f5f3;
    --cp-color-danger: #d63638;
    --cp-color-danger-bg: #fdecec;
    --cp-color-warn: #b26d00;
    --cp-color-warn-bg: #fff4e0;
    --cp-color-success: #1e8e3e;
    --cp-color-success-bg: #e6f4ea;
    --cp-radius: 12px;
    --cp-radius-sm: 8px;
    --cp-radius-lg: 16px;
    --cp-radius-pill: 999px;
    --cp-shadow: 0 1px 2px rgba(20, 30, 45, 0.04), 0 4px 14px rgba(20, 30, 45, 0.05);
    --cp-shadow-lg: 0 6px 12px rgba(20, 30, 45, 0.06), 0 20px 40px rgba(20, 30, 45, 0.08);
    --cp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --cp-topbar-height: 170px;
    margin: 0;
    background: var(--cp-color-bg);
    color: var(--cp-color-text);
    font-family: var(--cp-font);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.clinic-portal-body * { box-sizing: border-box; }

.clinic-portal-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Topbar (dashboard/edit screens) --------------------------------
 * Transparent background so it flows into the body; no divider line. */
.cp-topbar {
    background: transparent;
    border-bottom: none;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    background-color: rgba(255, 255, 255, 0.85);
}
/* Topbar inner matches the content container below it, so the logo lines
 * up with the left edge of "My Clinics" / clinic cards and the user nav
 * lines up with the right edge of the same column. */
.cp-topbar__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: var(--cp-topbar-height);
}
.cp-topbar__brand {
    font-weight: 700;
    color: var(--cp-color-text);
    text-decoration: none;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    line-height: 0;
    flex: 0 0 auto;
}
/* Force the logo to render at a consistent height regardless of how
 * wide/tall the source image is or what the active theme injects (many
 * themes — Divi, Astra — force `img { height: auto !important }`, which
 * is why `max-height` alone sometimes loses). */
.cp-topbar__brand img,
.cp-topbar__brand .custom-logo-link img,
.clinic-portal-body .cp-brand-logo--topbar {
    height: 150px !important;
    width: auto !important;
    max-height: none !important;
    max-width: none !important;
    min-height: 150px !important;
    display: block !important;
    object-fit: contain;
}
@media (max-width: 640px) {
    .cp-topbar__brand img,
    .cp-topbar__brand .custom-logo-link img,
    .clinic-portal-body .cp-brand-logo--topbar {
        height: 90px !important;
        min-height: 90px !important;
    }
}
.cp-topbar__nav {
    display: flex;
    align-items: center;
    gap: 14px;
}
.cp-topbar__user {
    font-size: 14px;
    color: var(--cp-color-text-muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .cp-topbar__inner { padding: 12px 16px; }
    .cp-topbar__user { display: none; }
    .cp-topbar__brand img,
    .cp-topbar__brand .custom-logo-link img { max-height: 52px; }
}

/* --- Main / container ----------------------------------------------- */
.cp-main {
    flex: 1;
    padding: 48px 0 80px;
}
.cp-container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 28px;
}

/* --- Page title ----------------------------------------------------- */
.cp-page-title {
    margin: 0 0 8px;
    font-size: 32px;
    font-weight: 700;
    color: var(--cp-color-text);
    letter-spacing: -0.01em;
}
@media (max-width: 600px) {
    .cp-page-title { font-size: 24px; }
}

/* --- Typography helpers --------------------------------------------- */
.cp-muted { color: var(--cp-color-text-muted); }
.cp-small { font-size: 13px; }
.cp-center { text-align: center; }

/* --- Cards ---------------------------------------------------------- */
.cp-card {
    background: var(--cp-color-surface);
    border: 1px solid var(--cp-color-border);
    border-radius: var(--cp-radius-lg);
    padding: 28px;
    box-shadow: var(--cp-shadow);
}

/* --- Login page ----------------------------------------------------- */
.clinic-portal-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.cp-card--auth {
    width: 100%;
    max-width: 440px;
    padding: 36px 32px;
    border-radius: var(--cp-radius-lg);
    box-shadow: var(--cp-shadow-lg);
    border: 1px solid var(--cp-color-border);
}
.cp-logo { text-align: center; margin-bottom: 20px; }
/* Same defensive !important strategy for the login-page logo so it doesn't
 * get squashed by theme-injected img rules. */
.cp-logo img,
.clinic-portal-body .cp-brand-logo--login {
    height: 110px !important;
    width: auto !important;
    max-height: none !important;
    max-width: 100% !important;
    display: inline-block !important;
    object-fit: contain;
}
.cp-brand-link { display: inline-block; line-height: 0; }
.cp-brand {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--cp-color-text);
}
.cp-title {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
}
.cp-subtitle {
    margin: 0 0 24px;
    color: var(--cp-color-text-muted);
    text-align: center;
    font-size: 14px;
}

/* --- Form elements -------------------------------------------------- */
.cp-form { display: flex; flex-direction: column; gap: 14px; }
.cp-field { display: flex; flex-direction: column; gap: 6px; }
.cp-field__label {
    font-size: 14px;
    font-weight: 600;
    color: var(--cp-color-text);
}
.cp-field__hint {
    font-size: 13px;
    color: var(--cp-color-text-muted);
}
.cp-input,
.cp-field input[type="text"],
.cp-field input[type="email"],
.cp-field input[type="tel"],
.cp-field input[type="url"],
.cp-field input[type="password"],
.cp-field input[type="number"],
.cp-field input[type="date"],
.cp-field input[type="time"],
.cp-field select,
.cp-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cp-color-border-strong);
    border-radius: var(--cp-radius-sm);
    font-size: 16px;
    font-family: inherit;
    color: var(--cp-color-text);
    background: var(--cp-color-surface);
    transition: border-color .15s, box-shadow .15s;
}
.cp-field input:focus,
.cp-field select:focus,
.cp-field textarea:focus,
.cp-input:focus {
    outline: none;
    border-color: var(--cp-color-primary);
    box-shadow: 0 0 0 3px var(--cp-color-primary-bg);
}
.cp-field textarea { min-height: 120px; resize: vertical; }

.cp-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--cp-color-text);
    cursor: pointer;
}
.cp-checkbox input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--cp-color-primary);
}

/* --- Buttons -------------------------------------------------------- */
/* Selectors are doubled / state-qualified (a.cp-btn:link etc.) so that
   themes like Divi that force link colors globally (e.g. #page-container a)
   don't override our button text colors. */
.cp-btn,
a.cp-btn,
button.cp-btn,
a.cp-btn:link,
a.cp-btn:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 26px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.1;
    border: 1px solid transparent;
    border-radius: var(--cp-radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .12s ease;
    min-height: 46px;
    font-family: inherit;
    box-shadow: none;
}
.cp-btn:hover { transform: translateY(-1px); }
.cp-btn:active { transform: translateY(0); }
.cp-btn:focus-visible,
a.cp-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--cp-color-primary-bg);
}
.cp-btn--primary,
a.cp-btn--primary,
button.cp-btn--primary,
a.cp-btn--primary:link,
a.cp-btn--primary:visited {
    background: var(--cp-color-primary);
    border-color: var(--cp-color-primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(29, 175, 165, 0.25);
}
.cp-btn--primary:hover,
a.cp-btn--primary:hover,
button.cp-btn--primary:hover,
a.cp-btn--primary:focus,
a.cp-btn--primary:active {
    background: var(--cp-color-primary-hover);
    border-color: var(--cp-color-primary-hover);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(29, 175, 165, 0.35);
}
.cp-btn--ghost,
a.cp-btn--ghost,
button.cp-btn--ghost,
a.cp-btn--ghost:link,
a.cp-btn--ghost:visited {
    background: transparent;
    border-color: var(--cp-color-border-strong);
    color: var(--cp-color-text);
}
.cp-btn--ghost:hover,
a.cp-btn--ghost:hover,
button.cp-btn--ghost:hover,
a.cp-btn--ghost:focus,
a.cp-btn--ghost:active {
    border-color: var(--cp-color-text-muted);
    color: var(--cp-color-text);
    text-decoration: none;
}
.cp-btn--danger,
a.cp-btn--danger,
button.cp-btn--danger,
a.cp-btn--danger:link,
a.cp-btn--danger:visited {
    background: var(--cp-color-danger);
    border-color: var(--cp-color-danger);
    color: #fff;
}
.cp-btn--danger:hover,
a.cp-btn--danger:hover,
button.cp-btn--danger:hover { background: #b32a2c; border-color: #b32a2c; color: #fff; text-decoration: none; }
.cp-btn--block { width: 100%; }
.cp-btn--small { min-height: 38px; padding: 8px 18px; font-size: 14px; }

/* --- Alerts --------------------------------------------------------- */
.cp-alert {
    padding: 12px 14px;
    border-radius: var(--cp-radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.cp-alert--error {
    background: var(--cp-color-danger-bg);
    border-color: #f5c2c7;
    color: var(--cp-color-danger);
}
.cp-alert--warn {
    background: var(--cp-color-warn-bg);
    border-color: #ffe0a3;
    color: var(--cp-color-warn);
}
.cp-alert--success {
    background: var(--cp-color-success-bg);
    border-color: #b7dfc2;
    color: var(--cp-color-success);
}

/* --- Badges --------------------------------------------------------- */
.cp-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--cp-color-primary-bg);
    color: var(--cp-color-primary);
}
.cp-badge--warn { background: var(--cp-color-warn-bg); color: var(--cp-color-warn); }
.cp-badge--success { background: var(--cp-color-success-bg); color: var(--cp-color-success); }

/* --- Clinic dashboard grid ----------------------------------------- */
.cp-clinic-grid {
    margin-top: 32px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
}
@media (min-width: 600px) {
    .cp-clinic-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
    .cp-clinic-grid { grid-template-columns: repeat(3, 1fr); }
}

.cp-clinic-card {
    background: var(--cp-color-surface);
    border: 1px solid var(--cp-color-border);
    border-radius: var(--cp-radius-lg);
    box-shadow: var(--cp-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.cp-clinic-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--cp-shadow-lg);
    border-color: #d4d7dc;
}
.cp-clinic-card__body {
    padding: 24px 24px 10px;
    flex: 1;
}
.cp-clinic-card__title {
    margin: 0 0 8px;
    font-size: 19px;
    font-weight: 700;
    color: var(--cp-color-text);
    letter-spacing: -0.005em;
}
.cp-clinic-card__address {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--cp-color-text-muted);
    line-height: 1.5;
}
.cp-clinic-card__footer {
    padding: 14px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Edit screen header -------------------------------------------- */
.cp-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.cp-edit-header__identity {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1 1 auto;
}
.cp-edit-header__logo {
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    border-radius: 12px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--cp-color-border);
    padding: 6px;
    box-shadow: var(--cp-shadow);
}
.cp-edit-header__logo--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: var(--cp-color-text-muted);
    background: linear-gradient(135deg, #eef2f7, #e6ecf3);
    padding: 0;
}
.cp-edit-header__meta { min-width: 0; }
.cp-edit-header__meta h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.cp-edit-header__address {
    margin: 4px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 520px;
}
.cp-edit-header__actions { flex: 0 0 auto; }
.cp-back-link {
    color: var(--cp-color-text-muted);
    text-decoration: none;
    font-size: 13px;
    display: inline-block;
    margin-bottom: 2px;
}
.cp-back-link:hover { color: var(--cp-color-text); }

/* --- Edit layout: sticky left nav + panels ------------------------- */
.cp-edit-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    align-items: start;
}
@media (min-width: 960px) {
    .cp-edit-layout {
        grid-template-columns: 232px minmax(0, 1fr);
        gap: 32px;
    }
}

/* Nav */
.cp-tabs-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px;
    margin: 0 -14px 8px;       /* bleed to container edges on mobile */
    padding-left: 14px;
    padding-right: 14px;
    scrollbar-width: none;
    background: linear-gradient(to right, var(--cp-color-bg) 0, rgba(255,255,255,0) 20px, rgba(255,255,255,0) calc(100% - 20px), var(--cp-color-bg) 100%);
    position: sticky;
    top: 0;
    z-index: 5;
}
.cp-tabs-nav::-webkit-scrollbar { display: none; }

@media (min-width: 960px) {
    .cp-tabs-nav {
        flex-direction: column;
        gap: 2px;
        overflow: visible;
        padding: 0;
        margin: 0;
        background: none;
        position: sticky;
        top: 16px;
    }
}

.cp-tab,
a.cp-tab,
a.cp-tab:link,
a.cp-tab:visited {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--cp-color-text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
    flex: 0 0 auto;
}
.cp-tab:hover,
a.cp-tab:hover {
    color: var(--cp-color-text);
    background: #f1f4f8;
    text-decoration: none;
}
.cp-tab.is-active,
a.cp-tab.is-active,
a.cp-tab.is-active:link,
a.cp-tab.is-active:visited {
    color: var(--cp-color-primary);
    background: var(--cp-color-primary-bg);
    border-color: transparent;
    font-weight: 600;
}
.cp-tab__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    opacity: .9;
}
.cp-tab__icon svg { display: block; }

/* Panels */
.cp-edit-panels { min-width: 0; }
.cp-panel {
    display: none;
    animation: cpFadeIn .18s ease-out;
}
.cp-panel.is-active { display: block; }
@keyframes cpFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cp-panel__header {
    margin-bottom: 16px;
}
.cp-panel__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--cp-color-text);
    line-height: 1.2;
}
.cp-panel__lead {
    margin: 4px 0 0;
    color: var(--cp-color-text-muted);
    font-size: 14px;
}

/* Sections (cards inside panels — always open) */
.cp-section {
    background: var(--cp-color-surface);
    border: 1px solid var(--cp-color-border);
    border-radius: var(--cp-radius);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--cp-shadow);
}
.cp-section__title {
    margin: 0;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--cp-color-text);
    background: #fafbfc;
    border-bottom: 1px solid var(--cp-color-border);
    letter-spacing: .01em;
}
.cp-section__body {
    padding: 20px;
}

.cp-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 600px) {
    .cp-grid-2 { grid-template-columns: 1fr 1fr; }
}

.cp-save-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--cp-color-border);
    margin-top: 16px;
}

/* Tab-level save bar: single button at the bottom of a panel that
 * commits every section in that tab at once. Made slightly larger
 * and more prominent than the old per-section bars. */
.cp-save-bar--panel {
    margin-top: 20px;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid var(--cp-color-border);
    border-radius: var(--cp-radius-md);
    box-shadow: var(--cp-shadow);
    position: sticky;
    bottom: 16px;
    z-index: 2;
}
.cp-save-bar--panel .cp-btn--primary {
    padding: 10px 22px;
    font-size: 15px;
}
.cp-save-bar__status {
    flex: 1;
    font-size: 15px;
    color: var(--cp-color-text-muted);
    min-height: 1.4em;
}
.cp-save-bar__status.is-success,
.cp-save-bar__status.is-error {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.cp-save-bar__status.is-success {
    color: var(--cp-color-success);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.cp-save-bar__status.is-success::before {
    content: "";
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    background: var(--cp-color-success);
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center / contain no-repeat;
}
.cp-save-bar__status.is-error { color: var(--cp-color-danger); }

/* --- Hours grid ----------------------------------------------------- */
.cp-hours-row {
    display: grid;
    grid-template-columns: 110px 1fr 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--cp-color-border);
}
.cp-hours-row:last-child { border-bottom: none; }
.cp-hours-row__day { font-weight: 600; }
@media (max-width: 600px) {
    .cp-hours-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 12px 0;
    }
    .cp-hours-row__day { font-size: 15px; }
}

/* --- Checkbox groups (species/accreditations/insurance/etc.) ------- */
.cp-check-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}
@media (min-width: 600px) {
    .cp-check-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
    .cp-check-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.cp-check-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--cp-color-border);
    border-radius: var(--cp-radius-sm);
    background: var(--cp-color-surface);
    cursor: pointer;
    font-size: 14px;
}
.cp-check-grid label:hover { border-color: var(--cp-color-border-strong); }
.cp-check-grid input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--cp-color-primary); }

/* --- Portal support footer (admin-configured WYSIWYG message) ------ */
.cp-support {
    margin-top: 40px;
    padding: 24px 0 48px;
    border-top: 1px solid var(--cp-color-border);
    background: var(--cp-color-surface-soft);
}
.cp-support__inner {
    font-size: 14px;
    color: var(--cp-color-text-muted);
    line-height: 1.6;
}
.cp-support__inner h1,
.cp-support__inner h2,
.cp-support__inner h3,
.cp-support__inner h4 {
    color: var(--cp-color-text);
    margin-top: 0;
    margin-bottom: 8px;
}
.cp-support__inner p:first-child { margin-top: 0; }
.cp-support__inner p:last-child { margin-bottom: 0; }
.cp-support__inner a { color: var(--cp-color-primary); }
.cp-support__inner a:hover { color: var(--cp-color-primary-hover); }
.cp-support__inner ul,
.cp-support__inner ol { padding-left: 20px; }

/* --- Services & pricing table -------------------------------------- */
/* Wrap the table in a scroll container capped at ~60vh so that the
   sticky <thead> has something to stick against and the column
   headings stay visible no matter how many services are added. */
.cp-services-scroll {
    max-height: 60vh;
    overflow: auto;
    border: 1px solid var(--cp-color-border);
    border-radius: var(--cp-radius-sm);
    background: var(--cp-color-surface);
}
.cp-services-table { width: 100%; border-collapse: collapse; }
.cp-services-table th, .cp-services-table td {
    padding: 10px;
    border-bottom: 1px solid var(--cp-color-border);
    text-align: left;
    vertical-align: middle;
    font-size: 14px;
}
.cp-services-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--cp-color-surface-soft);
    border-bottom: 2px solid var(--cp-color-border-strong);
    font-weight: 600;
    color: var(--cp-color-text);
}
.cp-services-table input[type="number"] { width: 100px; }
.cp-services-table .cp-svc-actions { white-space: nowrap; }
.cp-services-add {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
@media (max-width: 700px) {
    .cp-services-scroll { max-height: none; overflow: visible; border: 0; background: transparent; }
    .cp-services-table thead { display: none; }
    .cp-services-table, .cp-services-table tbody, .cp-services-table tr, .cp-services-table td { display: block; width: 100%; }
    .cp-services-table tr {
        border: 1px solid var(--cp-color-border);
        border-radius: var(--cp-radius-sm);
        margin-bottom: 10px;
        padding: 8px;
    }
    .cp-services-table td { border: none; padding: 6px 8px; }
    .cp-services-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: var(--cp-color-text-muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .04em;
    }
}

/* --- Media gallery -------------------------------------------------- */
.cp-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.cp-gallery__item {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #f0f2f4;
    border-radius: var(--cp-radius-sm);
    overflow: hidden;
    border: 1px solid var(--cp-color-border);
    cursor: move;
}
.cp-gallery__item img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.cp-gallery__remove {
    position: absolute;
    top: 6px; right: 6px;
    background: rgba(0,0,0,.65);
    color: #fff;
    border: none;
    width: 28px; height: 28px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.cp-logo-preview {
    width: 120px;
    height: 120px;
    border: 1px solid var(--cp-color-border);
    border-radius: var(--cp-radius-sm);
    object-fit: contain;
    background: #fff;
    padding: 8px;
    display: block;
}

/* --- Overview (Details tab read-only block) ---------------------- */
.cp-overview {
    display: grid;
    grid-template-columns: minmax(260px, 1.3fr) 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 720px) {
    .cp-overview { grid-template-columns: 1fr; }
}
.cp-overview__map-hint { margin-top: 8px; }
.cp-overview__heading {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cp-color-text-muted);
}
.cp-mini-map {
    width: 100%;
    height: 220px;
    border-radius: var(--cp-radius-sm);
    overflow: hidden;
    background: #eef2f7;
    border: 1px solid var(--cp-color-border);
    position: relative;
}
.cp-mini-map--empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--cp-color-text-muted);
    font-size: 14px; text-align: center; padding: 16px;
    background: repeating-linear-gradient(45deg, #f5f7fa 0 10px, #eef2f7 10px 20px);
}
.cp-mini-map__loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--cp-color-text-muted); font-size: 13px;
}
.cp-mini-map .leaflet-control-attribution { font-size: 10px; }

.cp-rating {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 6px;
}
.cp-rating__stars {
    display: inline-flex; align-items: center; gap: 1px;
    line-height: 1;
}
.cp-rating .cp-star { font-size: 20px; line-height: 1; }
.cp-rating .cp-star--full { color: #ffc107; }
.cp-rating .cp-star--empty { color: #e0e0e0; }
.cp-rating .cp-star--half { display: inline-flex; align-items: center; }
.cp-rating__meta {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px;
    font-size: 14px; color: var(--cp-color-text);
}
.cp-rating__value { font-size: 18px; font-weight: 700; }
.cp-rating__count { color: var(--cp-color-text-muted); }
.cp-rating__link {
    font-size: 13px;
    color: var(--cp-color-primary);
    text-decoration: none;
}
.cp-rating__link:hover { text-decoration: underline; }

/* --- Scoped image uploader ---------------------------------------- */
.cp-uploader {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: start;
    margin-top: 10px;
}
.cp-uploader__preview {
    position: relative;
    width: 120px;
    height: 120px;
}
.cp-uploader__preview .cp-logo-preview {
    width: 100%;
    height: 100%;
    margin: 0;
}
.cp-logo-preview__empty {
    width: 120px;
    height: 120px;
    border: 1px dashed var(--cp-color-border-strong);
    border-radius: var(--cp-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cp-color-text-muted);
    background: #f7f9fc;
}
.cp-uploader__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.cp-uploader .cp-btn { cursor: pointer; }
.cp-upload-status {
    font-size: 13px;
    color: var(--cp-color-text-muted);
    min-height: 1em;
}
.cp-upload-status.is-info { color: var(--cp-color-primary); }
.cp-upload-status.is-error { color: #b42318; }
.cp-upload-status.is-success { color: #067647; }

/* --- Modal (crop, confirms) --------------------------------------- */
body.cp-modal-open { overflow: hidden; }
.cp-modal {
    position: fixed; inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.cp-modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.cp-modal__panel {
    position: relative;
    background: #fff;
    border-radius: var(--cp-radius-md);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
    width: min(720px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cp-modal-in 180ms ease-out;
}
@keyframes cp-modal-in {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}
.cp-modal__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--cp-color-border);
}
.cp-modal__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--cp-color-text);
}
.cp-modal__body {
    padding: 16px 20px;
    overflow: auto;
    flex: 1 1 auto;
}
.cp-modal__footer {
    padding: 12px 20px;
    border-top: 1px solid var(--cp-color-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: #fafbfc;
}
.cp-crop-stage {
    background: #0f172a;
    border-radius: var(--cp-radius-sm);
    overflow: hidden;
    max-height: 60vh;
    margin-top: 10px;
}
.cp-crop-stage img {
    display: block;
    max-width: 100%;
}
/* Cropper.js rescales the image inside its own wrapper; make sure the
 * container height is reasonable on small screens. */
.cp-crop-stage .cropper-container { max-height: 60vh; }

/* --- Utility ------------------------------------------------------- */
.cp-inline-note {
    padding: 10px 12px;
    background: var(--cp-color-primary-bg);
    border-radius: var(--cp-radius-sm);
    font-size: 13px;
    color: var(--cp-color-primary);
    margin-top: 8px;
}
.cp-hr { border: none; border-top: 1px solid var(--cp-color-border); margin: 16px 0; }

/* Hide WP admin bar if theme re-enables */
.clinic-portal-body #wpadminbar { display: none !important; }
.clinic-portal-body html[lang] { margin-top: 0 !important; }

/* Honor the HTML `hidden` attribute. Several portal rules set
 * display: block/flex/grid which beat the UA stylesheet, so we need
 * an explicit reset for elements we toggle via the `hidden` attr. */
.clinic-portal-body [hidden] { display: none !important; }

/* --- Accessibility polish ------------------------------------------ */
.clinic-portal-body :focus-visible {
    outline: 2px solid var(--cp-color-primary);
    outline-offset: 2px;
}
.clinic-portal-body a:not(.cp-btn):not(.cp-tab) { color: var(--cp-color-primary); }
.clinic-portal-body a:not(.cp-btn):not(.cp-tab):hover { color: var(--cp-color-primary-hover); }

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .clinic-portal-body *,
    .clinic-portal-body *::before,
    .clinic-portal-body *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode friendliness: keep portal light for predictable contrast.
 * (We deliberately don't invert colors — form inputs and form state
 *  are easier to read in light mode, and clinic owners are used to
 *  admin-like interfaces.) */

/* Mobile tweaks --------------------------------------------------- */
@media (max-width: 480px) {
    .cp-main { padding: 16px 0 40px; }
    .cp-container { padding: 0 14px; }
    .cp-section__title { padding: 12px 16px; font-size: 14px; }
    .cp-section__body { padding: 16px; }
    .cp-edit-header__logo { width: 56px; height: 56px; border-radius: 10px; }
    .cp-edit-header__logo--placeholder { font-size: 22px; }
    .cp-edit-header__meta h1 { font-size: 20px; }
    .cp-panel__title { font-size: 19px; }
    .cp-card--auth { padding: 24px 20px; }
    .cp-clinic-card__body { padding: 16px 16px 4px; }
    .cp-clinic-card__footer { padding: 8px 16px 16px; }
    .cp-btn { font-size: 14px; }
    .cp-save-bar { flex-direction: column; align-items: stretch; gap: 8px; }
    .cp-save-bar button { width: 100%; }
    .cp-topbar__inner { padding: 10px 14px; }
    .cp-uploader { grid-template-columns: 1fr; }
    .cp-uploader__preview { width: 100%; max-width: 180px; }
    .cp-modal__footer { flex-wrap: wrap; }
    .cp-modal__footer .cp-btn { flex: 1 1 auto; }
    .cp-crop-stage { max-height: 55vh; }
}

/* Gallery placeholder while dragging */
.cp-gallery__placeholder {
    background: #f0f2f4;
    border: 2px dashed var(--cp-color-border-strong) !important;
}

/* Inputs: keep font-size >= 16px on mobile so iOS Safari doesn't zoom */
@media (max-width: 600px) {
    .cp-field input, .cp-field select, .cp-field textarea,
    .cp-services-table input[type="number"] { font-size: 16px; }
}

/* ================================================================== */
/* Analytics dashboard                                                  */
/* ================================================================== */
.cp-analytics {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.cp-analytics__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.cp-analytics__hint {
    margin: 0;
    font-size: 13px;
    color: #666;
    flex: 1 1 240px;
}

.cp-analytics__range {
    display: inline-flex;
    background: #f2f4f6;
    border-radius: 999px;
    padding: 4px;
    gap: 2px;
}

.cp-range-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.cp-range-btn:hover { color: #008080; }
.cp-range-btn.is-active {
    background: #fff;
    color: #008080;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.cp-analytics__cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.cp-metric-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 96px;
}

.cp-metric-card__label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
}

.cp-metric-card__value {
    font-size: 28px;
    line-height: 1.2;
    color: #111827;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.cp-metric-card__delta {
    font-size: 13px;
    font-weight: 600;
    margin-top: auto;
    color: #6b7280;
}
.cp-metric-card__delta.is-up   { color: #047857; }
.cp-metric-card__delta.is-down { color: #b91c1c; }
.cp-metric-card__delta.is-flat { color: #6b7280; }
.cp-metric-card__delta.is-up::before   { content: '▲ '; font-size: 10px; }
.cp-metric-card__delta.is-down::before { content: '▼ '; font-size: 10px; }

.cp-analytics__chart-wrap {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 18px 20px 22px;
}

.cp-analytics__chart-title {
    margin: 0 0 2px 0;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}

.cp-analytics__chart-sub {
    margin: 0 0 16px 0;
    font-size: 13px;
    color: #6b7280;
}

.cp-chart-box {
    position: relative;
    width: 100%;
    /* Canvas sizing is driven by Chart.js's "maintainAspectRatio: false"
       plus a fixed height attribute on the canvas; this wrapper just
       constrains horizontal overflow on very small screens. */
}

.cp-analytics__status {
    font-size: 13px;
    color: #6b7280;
    min-height: 18px;
}
.cp-analytics__status.is-error { color: #b91c1c; font-weight: 600; }

@media (max-width: 600px) {
    .cp-metric-card__value { font-size: 22px; }
    .cp-analytics__toolbar { flex-direction: column; align-items: stretch; }
    .cp-analytics__range { align-self: flex-start; }
}
