/* =============================================================================
   PULSE refreshed UI (SiteSetting ui_refresh = true)
   Loaded only by layout_refresh.html, after custom.css and dynamic-branding.css,
   so it can calm down the classic styles. Brand colour comes from --bs-primary
   (set by /dynamic-branding.css from Branding.primary_color).
   ============================================================================= */

:root {
    --r-bg: #F5F7F9;
    --r-surface: #FFFFFF;
    --r-subtle: #F9FAFB;
    --r-line: #E3E8ED;
    --r-line-soft: #EEF1F4;
    --r-ink: #14212B;
    --r-ink-2: #3B4A56;
    --r-muted: #5B6B78;
    --r-accent: var(--bs-primary, #027DB7);
    --r-accent-rgb: var(--bs-primary-rgb, 2, 125, 183);
    --r-accent-soft: rgba(var(--r-accent-rgb), 0.10);
    --r-ok-bg: #E7F4EC; --r-ok: #1E6B3A;
    --r-plan-bg: #E6F2F9; --r-plan: #025E8A;
    --r-warn-bg: #FBEFE6; --r-warn: #9A4A12;
    --r-off-bg: #EEF1F3; --r-off: #4B5864;
    --r-radius: 12px;
    --r-sidebar: 232px;
    --r-tabbar: 64px;
}

/* ---- Page ---------------------------------------------------------------- */
body.ui-refresh {
    background: var(--r-bg) !important;
    color: var(--r-ink) !important;
    min-height: 100vh;
    margin: 0;
}
body.ui-refresh h1, body.ui-refresh h2, body.ui-refresh h3,
body.ui-refresh h4, body.ui-refresh h5, body.ui-refresh h6 {
    color: var(--r-ink) !important;
    background: none !important;
    -webkit-text-fill-color: currentColor;
}
body.ui-refresh h1 { font-size: 1.6rem; font-weight: 700; }
body.ui-refresh h1 i, body.ui-refresh h2 i { color: var(--r-muted); font-size: 0.85em; }
body.ui-refresh a:not(.btn):not(.dropdown-item):not(.page-link) { color: var(--r-accent); }
body.ui-refresh .btn-secondary { background: var(--r-surface) !important; border: 1px solid #D5DCE2 !important; color: var(--r-ink) !important; }
body.ui-refresh .btn-outline-secondary { color: var(--r-ink-2) !important; border-color: #D5DCE2 !important; background: var(--r-surface) !important; }
body.ui-refresh textarea.form-control, body.ui-refresh textarea { border-color: #D5DCE2 !important; background: var(--r-surface) !important; }
body.ui-refresh textarea::placeholder, body.ui-refresh .form-control::placeholder { color: #8A97A3 !important; }
body.ui-refresh .form-select, body.ui-refresh .form-control { border-left-width: 1px !important; border-left-color: #D5DCE2 !important; }
body.ui-refresh .text-muted { color: var(--r-muted) !important; }

.r-main { padding: 24px 16px 32px; }
.r-container { max-width: 1240px; margin: 0 auto; }
body.ui-refresh .r-container > .container,
body.ui-refresh .r-container .container { max-width: none; padding-left: 0; padding-right: 0; margin-top: 0 !important; }

/* ---- Desktop sidebar ------------------------------------------------------ */
.r-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--r-sidebar);
    background: var(--r-surface); border-right: 1px solid var(--r-line);
    display: none; flex-direction: column; padding: 18px 12px; z-index: 1030;
}
.r-logo { display: flex; align-items: center; padding: 0 8px 18px; }
.r-logo img { max-height: 44px; max-width: 170px; object-fit: contain; }
.r-logo { text-decoration: none; }
.r-logo-text { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; color: var(--r-ink); }
.r-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.r-nav hr { margin: 8px 4px; border-color: var(--r-line); opacity: 1; }
.r-nav-link {
    display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 10px;
    border-radius: 8px; font-size: 0.9rem; color: var(--r-ink-2) !important; text-decoration: none;
}
.r-nav-link i { width: 18px; text-align: center; color: var(--r-muted); }
.r-nav-link:hover { background: var(--r-subtle); }
.r-nav-link.active { background: var(--r-accent-soft); color: var(--r-accent) !important; font-weight: 500; }
.r-nav-link.active i { color: var(--r-accent); }
.r-user { margin-top: auto; border-top: 1px solid var(--r-line-soft); padding-top: 8px; }
.r-user-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: none; border-radius: 8px; text-align: left; }
.r-user-btn:hover { background: var(--r-subtle); }
.r-user-text { display: flex; flex-direction: column; line-height: 1.2; }
.r-user-name { font-size: 0.875rem; font-weight: 500; color: var(--r-ink); }
.r-user-role { font-size: 0.75rem; color: var(--r-muted); }
.r-user-menu { padding: 6px; min-width: 210px; }
.r-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--r-accent-soft); color: var(--r-accent); font-weight: 500; font-size: 0.8rem;
}

/* ---- Phone top bar + bottom tab bar --------------------------------------- */
.r-topbar {
    position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; justify-content: space-between;
    height: 56px; padding: 0 12px; background: var(--r-surface); border-bottom: 1px solid var(--r-line);
}
.r-topbar .r-logo { padding: 0; }
.r-topbar .r-logo img { max-height: 34px; max-width: 150px; }
.r-avatar-btn { border: 1px solid var(--r-line); width: 40px; height: 40px; }

.r-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: var(--r-tabbar); background: var(--r-surface); border-top: 1px solid var(--r-line);
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
}
.r-tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 48px; border: 0; background: none; font-size: 0.7rem; color: var(--r-muted) !important; text-decoration: none;
}
.r-tab i { font-size: 1.15rem; }
.r-tab.active { color: var(--r-accent) !important; font-weight: 500; }
.r-tab-plus {
    justify-self: center; width: 52px; height: 52px; min-height: 0; margin-top: -20px; border-radius: 50%;
    background: var(--r-accent); color: #FFFFFF !important; box-shadow: 0 4px 12px rgba(var(--r-accent-rgb), 0.35);
}
.r-tab-plus i { font-size: 1.3rem; }
body.r-authed .r-main { padding-bottom: calc(var(--r-tabbar) + 24px); }

.r-sheet { border-radius: 16px 16px 0 0; height: auto !important; max-height: 85vh; }
.r-sheet .offcanvas-title { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; }
.r-sheet-actions { display: grid; gap: 8px; padding-bottom: 24px; }
.r-sheet-actions a {
    display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 16px;
    border: 1px solid var(--r-line); border-radius: var(--r-radius); color: var(--r-ink) !important;
    text-decoration: none; font-weight: 500;
}
.r-sheet-actions a i { color: var(--r-accent); width: 20px; text-align: center; }
.r-install { position: fixed; left: 12px; bottom: calc(var(--r-tabbar) + 12px); z-index: 1029; }

@media (min-width: 992px) {
    .r-sidebar { display: flex; }
    .r-topbar, .r-tabbar, .r-sheet { display: none !important; }
    body.r-authed .r-main { margin-left: var(--r-sidebar); padding: 28px 36px 40px; }
    .r-install { display: none !important; } /* installing the app is a phone thing */
}

/* Classic chrome that the refreshed shell replaces */
body.ui-refresh .logo-header, body.ui-refresh .navbar-custom, body.ui-refresh .fab-container,
body.ui-refresh .fab-back-container, body.ui-refresh .mobile-footer-nav, body.ui-refresh .heartbeat-splash,
body.ui-refresh footer.footer { display: none !important; }

/* ---- Cards, tables, forms ------------------------------------------------- */
body.ui-refresh .card {
    border: 1px solid var(--r-line) !important; border-radius: var(--r-radius) !important;
    box-shadow: none !important; background: var(--r-surface) !important;
}
body.ui-refresh .card-header {
    background: var(--r-surface) !important; color: var(--r-ink) !important;
    border-bottom: 1px solid var(--r-line-soft) !important; font-weight: 500;
}
body.ui-refresh .card-header h1, body.ui-refresh .card-header h2, body.ui-refresh .card-header h3,
body.ui-refresh .card-header h4, body.ui-refresh .card-header h5 { font-size: 1.05rem; font-weight: 700; margin: 0; }

body.ui-refresh table thead th,
body.ui-refresh .table thead th,
body.ui-refresh .table > thead > tr > th {
    background: var(--r-subtle) !important; color: var(--r-muted) !important;
    font-size: 0.72rem !important; font-weight: 500 !important; letter-spacing: 0.05em; text-transform: uppercase;
    border-bottom: 1px solid var(--r-line) !important; border-top: 0 !important;
}
body.ui-refresh table thead th i { color: var(--r-muted) !important; }
body.ui-refresh .table { --bs-table-bg: var(--r-surface); margin-bottom: 0; }
body.ui-refresh .table td { border-color: var(--r-line-soft) !important; vertical-align: middle; }
body.ui-refresh .table-responsive { border: 1px solid var(--r-line); border-radius: var(--r-radius); background: var(--r-surface); }

body.ui-refresh .form-control, body.ui-refresh .form-select {
    min-height: 44px; border-color: #D5DCE2; border-radius: 10px; background-color: var(--r-surface);
}
body.ui-refresh .form-label, body.ui-refresh label { color: var(--r-ink-2); font-weight: 500; font-size: 0.875rem; }
body.ui-refresh .form-text { color: var(--r-muted); }
body.ui-refresh .btn { border-radius: 10px; font-weight: 500; }
body.ui-refresh .btn-sm { border-radius: 8px; }
body.ui-refresh .btn-primary { background: var(--r-accent) !important; border-color: var(--r-accent) !important; color: #FFFFFF !important; }
body.ui-refresh .badge { font-weight: 500; }
body.ui-refresh .alert { border-radius: var(--r-radius); }

/* ---- Shared refresh components (My week, Home, Doctors) ------------------- */
.r-pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.r-pagehead h1 { margin: 0; }
.r-sub { color: var(--r-muted); font-size: 0.9rem; margin-top: 2px; }
.r-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.r-card { background: var(--r-surface); border: 1px solid var(--r-line); border-radius: var(--r-radius); }
.r-card-pad { padding: 16px 18px; }
.r-card-title { font-size: 1rem; font-weight: 700; margin: 0; }
.r-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }

.r-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.r-tile { background: var(--r-surface); border: 1px solid var(--r-line); border-radius: var(--r-radius); padding: 14px 16px; }
.r-tile-label { font-size: 0.72rem; color: var(--r-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.r-tile-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.r-tile-sub { font-size: 0.82rem; color: var(--r-muted); }
.r-up { color: var(--r-ok) !important; } .r-down { color: var(--r-warn) !important; }
@media (max-width: 991.98px) { .r-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.r-filterbar {
    background: var(--r-surface); border: 1px solid var(--r-line); border-radius: var(--r-radius);
    padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px;
}
.r-seg { display: inline-flex; background: var(--r-line-soft); border-radius: 10px; padding: 3px; }
.r-seg a, .r-seg button {
    display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border: 0; border-radius: 8px;
    background: transparent; font-size: 0.875rem; color: var(--r-muted) !important; text-decoration: none; white-space: nowrap;
}
.r-seg .on { background: var(--r-surface); color: var(--r-ink) !important; font-weight: 500; box-shadow: 0 1px 2px rgba(20, 33, 43, 0.12); }
.r-chip {
    display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 999px;
    border: 1px solid #D5DCE2; background: var(--r-surface); font-size: 0.82rem; color: var(--r-ink) !important; text-decoration: none; white-space: nowrap;
}
.r-chip.on { border-color: var(--r-accent); background: var(--r-accent-soft); color: var(--r-accent) !important; font-weight: 500; }
.r-filterbar .form-select, .r-filterbar .form-control { min-height: 36px; height: 36px; padding-top: 0; padding-bottom: 0; font-size: 0.85rem; width: auto; }
.r-week { display: inline-flex; align-items: center; border: 1px solid #D5DCE2; border-radius: 10px; min-height: 38px; background: var(--r-surface); }
.r-week a { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; color: var(--r-ink) !important; text-decoration: none; }
.r-week span { font-size: 0.875rem; font-weight: 500; padding: 0 4px; white-space: nowrap; }
.r-divider { width: 1px; height: 24px; background: var(--r-line); }
.r-search { margin-left: auto; display: flex; gap: 6px; }
@media (max-width: 767.98px) { .r-search { margin-left: 0; width: 100%; } .r-search .form-control { flex: 1; width: 100%; } }

.r-pill { display: inline-block; text-decoration: none !important; font-size: 0.75rem; font-weight: 500; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.r-pill-completed { background: var(--r-ok-bg); color: var(--r-ok); }
.r-pill-planned { background: var(--r-plan-bg); color: var(--r-plan); }
.r-pill-canceled, .r-pill-cancelled { background: var(--r-off-bg); color: var(--r-off); }
.r-pill-late { background: var(--r-warn-bg); color: var(--r-warn); }
.r-pill-high { background: var(--r-ok-bg); color: var(--r-ok); }
.r-pill-mid { background: var(--r-plan-bg); color: var(--r-plan); }
.r-pill-low { background: var(--r-off-bg); color: var(--r-off); }

.r-list { background: var(--r-surface); border: 1px solid var(--r-line); border-radius: var(--r-radius); overflow: hidden; }
.r-row { display: grid; align-items: center; border-bottom: 1px solid var(--r-line-soft); font-size: 0.9rem; }
.r-row:last-child { border-bottom: 0; }
.r-row > * { padding: 10px 16px; min-width: 0; }
.r-row-head { background: var(--r-subtle); color: var(--r-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; border-bottom: 1px solid var(--r-line); }
.r-row-head > * { padding-top: 9px; padding-bottom: 9px; }
.r-dayhead { padding: 7px 16px; background: var(--r-bg); border-bottom: 1px solid var(--r-line-soft); font-size: 0.82rem; font-weight: 700; color: var(--r-ink-2); }
.r-dayhead span { font-weight: 400; color: var(--r-muted); }
.r-strong { font-weight: 500; color: var(--r-ink) !important; text-decoration: none; }
.r-small { display: block; font-size: 0.78rem; color: var(--r-muted); }
.r-note { font-size: 0.85rem; color: var(--r-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-num { text-align: right; font-variant-numeric: tabular-nums; }
.r-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.r-empty { padding: 32px 16px; text-align: center; color: var(--r-muted); }

/* Phone: list rows stack as cards */
@media (max-width: 767.98px) {
    .r-row-head { display: none; }
    .r-row { grid-template-columns: 1fr auto !important; padding: 10px 0; }
    .r-row > * { padding: 2px 14px; }
    .r-row > .r-hide-sm { display: none; }
    .r-row > .r-full { grid-column: 1 / -1; }
}

.r-datebox { width: 44px; text-align: center; flex-shrink: 0; line-height: 1.1; }
.r-datebox small { display: block; font-size: 0.68rem; color: var(--r-muted); text-transform: uppercase; }
.r-datebox b { font-size: 1.1rem; }
.r-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--r-line-soft); color: var(--r-ink) !important; text-decoration: none; }
.r-item:last-child { border-bottom: 0; }
.r-item-main { flex: 1; min-width: 0; }

.r-bar { height: 6px; border-radius: 999px; background: var(--r-line-soft); overflow: hidden; }
.r-bar > span { display: block; height: 6px; background: var(--r-ok); border-radius: 999px; }

.r-grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 991.98px) { .r-grid-2-1 { grid-template-columns: 1fr; } }

/* ---- Log a visit / case forms --------------------------------------------- */
body.ui-refresh form .row.mb-4 { margin-bottom: 1rem !important; }
@media (max-width: 767.98px) {
    body.ui-refresh .r-sticky-submit, body.ui-refresh form .d-flex.gap-2:has(> input[type=submit]),
    body.ui-refresh form .d-flex.gap-2:has(> button[type=submit]) {
        position: sticky; bottom: calc(var(--r-tabbar) + 8px); z-index: 5;
        background: var(--r-surface); padding: 10px; border: 1px solid var(--r-line); border-radius: var(--r-radius);
    }
}

@media (prefers-reduced-motion: reduce) { .r-sheet { transition: none !important; } }

/* ---- Desktop "+" (new visit / case / doctor) ------------------------------ */
.r-fab { position: fixed; right: 28px; bottom: 28px; z-index: 1035; display: none; }
.r-fab-btn {
    width: 58px; height: 58px; border: 0; border-radius: 50%; color: #FFFFFF; font-size: 1.4rem;
    background: linear-gradient(135deg, rgba(var(--r-accent-rgb), 0.85), var(--r-accent));
    box-shadow: 0 6px 18px rgba(var(--r-accent-rgb), 0.38); transition: transform 0.15s ease;
}
.r-fab-btn:hover { transform: scale(1.06); }
.r-fab-btn:focus-visible { outline: 3px solid rgba(var(--r-accent-rgb), 0.4); outline-offset: 3px; }
.r-fab-menu { padding: 6px; min-width: 200px; border-radius: var(--r-radius); margin-bottom: 10px !important; }
.r-fab-menu .dropdown-item { display: flex; align-items: center; gap: 12px; min-height: 42px; border-radius: 8px; font-weight: 500; }
.r-fab-menu .dropdown-item i { width: 18px; text-align: center; color: var(--r-accent); }
@media (min-width: 992px) { .r-fab { display: block; } }

/* ---- Blue gradient accents (from the brand colour) ------------------------ */
body.ui-refresh {
    background:
        linear-gradient(180deg, rgba(var(--r-accent-rgb), 0.16) 0px, rgba(var(--r-accent-rgb), 0.06) 260px, rgba(var(--r-accent-rgb), 0) 560px),
        var(--r-bg) !important;
    background-repeat: no-repeat !important;
}
.r-sidebar { background: linear-gradient(180deg, #FFFFFF 0%, rgba(var(--r-accent-rgb), 0.07) 100%), #FFFFFF; }
.r-topbar { background: linear-gradient(90deg, #FFFFFF 0%, rgba(var(--r-accent-rgb), 0.10) 100%), #FFFFFF; }
.r-tile { background: linear-gradient(160deg, #FFFFFF 55%, rgba(var(--r-accent-rgb), 0.07) 100%), #FFFFFF; }
.r-tile-value { color: var(--r-accent); }
body.ui-refresh .btn-primary, .r-tab-plus {
    background: linear-gradient(135deg, rgba(var(--r-accent-rgb), 0.85), var(--r-accent)) !important;
}
.r-sm-only { display: none; }
@media (max-width: 767.98px) { .r-sm-only { display: inline; } .r-row > .r-hide-sm.r-hide-sm { display: none !important; } }

/* ---- Home dashboard (same content as before, refreshed styling) ----------- */
body.ui-refresh .ai-summary-card, body.ui-refresh .ai-summary-card-mobile {
    background: linear-gradient(135deg, #024F75 0%, var(--r-accent) 55%, rgba(var(--r-accent-rgb), 0.78) 100%) !important;
    border-radius: var(--r-radius) !important; box-shadow: 0 6px 18px rgba(var(--r-accent-rgb), 0.18) !important;
}
/* Voice of Doctors: teal-to-blue so the two AI cards stay distinct */
body.ui-refresh .ai-summary-card[style*="38ef7d"], body.ui-refresh .ai-summary-card-mobile[style*="38ef7d"] {
    background: linear-gradient(135deg, #0B5F6B 0%, #0E7C86 45%, var(--r-accent) 100%) !important;
}
body.ui-refresh .ai-summary-card h5, body.ui-refresh .ai-summary-card h6,
body.ui-refresh .ai-summary-card-mobile h5, body.ui-refresh .ai-summary-card-mobile h6,
body.ui-refresh .ai-summary-card h5 i, body.ui-refresh .ai-summary-card-mobile h6 i { color: #FFFFFF !important; }
body.ui-refresh .ai-summary-card .form-select, body.ui-refresh .ai-summary-card-mobile .form-select {
    min-height: 34px; height: 34px; padding-top: 0; padding-bottom: 0; font-size: 0.85rem;
    background-color: #FFFFFF !important; color: var(--r-ink) !important; border: 0 !important;
}
body.ui-refresh .ai-summary-card .btn-primary, body.ui-refresh .ai-summary-card-mobile .btn-primary {
    background: rgba(255, 255, 255, 0.18) !important; border: 1px solid rgba(255, 255, 255, 0.45) !important;
}
body.ui-refresh .ai-summary-content, body.ui-refresh .ai-summary-content-mobile { background: rgba(255, 255, 255, 0.14) !important; }
body.ui-refresh .timeline-filter-card {
    background: var(--r-surface) !important; border: 1px solid var(--r-line) !important; box-shadow: none !important;
}
body.ui-refresh .timeline-filter-card h5, body.ui-refresh .timeline-filter-card .form-label { color: var(--r-ink) !important; }
body.ui-refresh .kpi-table, body.ui-refresh .kpi-table th, body.ui-refresh .kpi-table td { font-variant-numeric: tabular-nums; }
body.ui-refresh .mobile-section > .card, body.ui-refresh .mobile-section { border-radius: var(--r-radius); }
body.ui-refresh .mobile-heading { color: var(--r-ink) !important; font-weight: 700; }
body.ui-refresh .ai-summary-card label, body.ui-refresh .ai-summary-card-mobile label,
body.ui-refresh .ai-summary-content, body.ui-refresh .ai-summary-content *,
body.ui-refresh .ai-summary-content-mobile, body.ui-refresh .ai-summary-content-mobile *,
body.ui-refresh .ai-summary-card .text-muted, body.ui-refresh .ai-summary-card-mobile .text-muted,
body.ui-refresh .ai-loading { color: #FFFFFF !important; }

/* ---- Less white, stronger hierarchy (Cristina's feedback, 2026-10-06) ------
   Page and sidebar carry a light brand tint; cards stay white for reading,
   with a pale-blue header band; titles and column names are bold and dark. */
:root {
    --r-tint: rgba(var(--r-accent-rgb), 0.10);
    --r-tint-strong: rgba(var(--r-accent-rgb), 0.16);
    --r-head-ink: #0F2A3D;
    --r-line: #D6E2EB;
    --r-line-soft: #E6EEF4;
}
body.ui-refresh {
    background:
        linear-gradient(180deg, rgba(var(--r-accent-rgb), 0.22) 0px, rgba(var(--r-accent-rgb), 0.12) 320px, rgba(var(--r-accent-rgb), 0.08) 900px),
        #EEF4F8 !important;
    background-attachment: fixed !important;
}
.r-sidebar { background: linear-gradient(180deg, rgba(var(--r-accent-rgb), 0.10) 0%, rgba(var(--r-accent-rgb), 0.16) 100%), #FFFFFF !important; border-right-color: var(--r-line) !important; }
.r-nav-link { font-weight: 500; color: var(--r-head-ink) !important; }
.r-nav-link.active { background: var(--r-accent) !important; color: #FFFFFF !important; }
.r-nav-link.active i { color: #FFFFFF !important; }
.r-topbar { background: linear-gradient(90deg, rgba(var(--r-accent-rgb), 0.10), rgba(var(--r-accent-rgb), 0.18)), #FFFFFF !important; }
.r-tabbar { background: linear-gradient(0deg, rgba(var(--r-accent-rgb), 0.08), rgba(var(--r-accent-rgb), 0.08)), #FFFFFF; }

/* Page and card titles */
body.ui-refresh h1 { font-weight: 800 !important; color: var(--r-head-ink) !important; }
body.ui-refresh h2, body.ui-refresh h3, body.ui-refresh h4, body.ui-refresh h5, body.ui-refresh h6,
.r-card-title, body.ui-refresh .kpi-title, body.ui-refresh .mobile-heading { font-weight: 700 !important; color: var(--r-head-ink) !important; }

/* Cards: white body, pale-blue header band, blue-grey border */
body.ui-refresh .card { border-color: var(--r-line) !important; box-shadow: 0 1px 3px rgba(15, 42, 61, 0.06) !important; }
body.ui-refresh .card-header {
    background: linear-gradient(90deg, var(--r-tint-strong), var(--r-tint)) !important;
    border-bottom: 1px solid var(--r-line) !important; font-weight: 700 !important; color: var(--r-head-ink) !important;
}
.r-card, .r-list, .r-tile, .r-filterbar { border-color: var(--r-line) !important; box-shadow: 0 1px 3px rgba(15, 42, 61, 0.06); }
.r-card-head { padding-bottom: 8px; border-bottom: 2px solid var(--r-tint-strong); margin-bottom: 4px; }

/* Column names: bold, dark, on a light-blue band */
body.ui-refresh table thead th, body.ui-refresh .table thead th, body.ui-refresh .table > thead > tr > th, .r-row-head {
    background: var(--r-tint-strong) !important; color: var(--r-head-ink) !important;
    font-weight: 700 !important; font-size: 0.74rem !important; letter-spacing: 0.04em;
    border-bottom: 2px solid rgba(var(--r-accent-rgb), 0.30) !important;
}
body.ui-refresh table thead th i, body.ui-refresh table thead th a { color: var(--r-head-ink) !important; }
body.ui-refresh .table tbody tr:nth-child(even) td { background: rgba(var(--r-accent-rgb), 0.03); }
body.ui-refresh .table-hover tbody tr:hover td, .r-row:not(.r-row-head):hover { background: rgba(var(--r-accent-rgb), 0.06); }
body.ui-refresh table tbody td:first-child, body.ui-refresh .kpi-table tbody th { font-weight: 600; color: var(--r-head-ink); }

/* Tiles and day headers */
.r-tile-label { font-weight: 700 !important; color: var(--r-head-ink) !important; }
.r-dayhead { background: var(--r-tint) !important; color: var(--r-head-ink) !important; font-weight: 800 !important; border-bottom: 1px solid var(--r-line) !important; }
.r-strong { font-weight: 600 !important; }

/* ---- Home tables: no grey/white-on-white text (Cristina, 2026-10-06) ------- */
/* Drill-down tables inherited white text from the dashboard's dark styles */
body.ui-refresh #drill-down-week td, body.ui-refresh #drill-down-month td,
body.ui-refresh #doctor-engagement-section td,
body.ui-refresh #drill-down-week td *, body.ui-refresh #drill-down-month td *,
body.ui-refresh #doctor-engagement-section td * { color: var(--r-head-ink) !important; }
body.ui-refresh #drill-down-week td .fa-crown, body.ui-refresh #drill-down-month td .fa-crown,
body.ui-refresh #doctor-engagement-section td .fa-crown { color: #C98A00 !important; }
body.ui-refresh #drill-down-week td, body.ui-refresh #drill-down-month td,
body.ui-refresh #doctor-engagement-section td { background-color: var(--r-surface); }
/* Dates and times: dark, readable */
body.ui-refresh .table-date-primary { color: var(--r-head-ink) !important; font-weight: 600; }
body.ui-refresh .table-time-secondary, body.ui-refresh table .text-muted, body.ui-refresh table small { color: #3B4A56 !important; }
body.ui-refresh table td { color: var(--r-head-ink); }
/* "View by Representative" / engagement panels: light brand panel instead of dark slate */
body.ui-refresh .drill-down-section {
    background: linear-gradient(135deg, rgba(var(--r-accent-rgb), 0.16), rgba(var(--r-accent-rgb), 0.08)) !important;
    border: 1px solid var(--r-line) !important; box-shadow: none !important;
}
body.ui-refresh .drill-down-section .btn {
    background: var(--r-surface) !important; color: var(--r-head-ink) !important; border-color: var(--r-line) !important;
}
body.ui-refresh .drill-down-section .btn.active, body.ui-refresh .drill-down-section .btn[aria-pressed="true"] {
    background: var(--r-accent) !important; color: #FFFFFF !important; border-color: var(--r-accent) !important;
}
body.ui-refresh .drill-down-section h5, body.ui-refresh .drill-down-section h6,
body.ui-refresh .drill-down-section p, body.ui-refresh .drill-down-section small { color: var(--r-head-ink) !important; }

/* Phone Home (dashboard_mobile): same light panel. Its own CSS paints cells
   white for a dark slate panel, which left the numbers white-on-white. */
body.ui-refresh .unified-drill-down-section {
    background: linear-gradient(135deg, rgba(var(--r-accent-rgb), 0.16), rgba(var(--r-accent-rgb), 0.08)) !important;
    border: 1px solid var(--r-line) !important; box-shadow: none !important; padding: 10px !important;
}
body.ui-refresh .unified-drill-down-section .table { color: var(--r-head-ink) !important; }
body.ui-refresh .unified-drill-down-section .table tbody td,
body.ui-refresh .unified-drill-down-section .table tbody td * {
    color: var(--r-head-ink) !important; border-color: var(--r-line-soft) !important;
}
body.ui-refresh .unified-drill-down-section .table tbody td { background-color: var(--r-surface) !important; }
body.ui-refresh .unified-drill-down-section .table tbody td.current-col,
body.ui-refresh .unified-drill-down-section .table tbody td.current-col * {
    background-color: rgba(var(--r-accent-rgb), 0.10) !important; color: var(--r-accent) !important; font-weight: 700;
}
body.ui-refresh .unified-drill-down-section .table tbody td.current-col * { background-color: transparent !important; }
body.ui-refresh .unified-drill-down-section .table tbody td .fa-crown { color: #C98A00 !important; }
body.ui-refresh .unified-drill-down-section .btn-group [data-period] {
    background: var(--r-surface) !important; color: var(--r-head-ink) !important; border-color: var(--r-line) !important;
}
body.ui-refresh .unified-drill-down-section .btn-group [data-period].active {
    background: var(--r-accent) !important; color: #FFFFFF !important; border-color: var(--r-accent) !important;
}

/* ---- Note columns (Visits, Cases): wide and stable rows ------------------
   Wider fixed column; each note capped at two lines (full text on hover via
   the existing title attribute), so long notes no longer stretch the table. */
body.ui-refresh th[data-column="note"], body.ui-refresh td[data-column="note"] {
    width: 30%; min-width: 300px; max-width: 460px; text-align: left !important;
}
body.ui-refresh td[data-column="note"] > span, body.ui-refresh td[data-column="note"] .text-wrap {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    overflow: hidden; white-space: normal !important; line-height: 1.4; max-height: 2.8em;
    cursor: help; word-break: break-word;
}
body.ui-refresh table td { vertical-align: middle; }

/* ---- One palette for statuses and products (Cristina, 2026-10-06) --------
   Completed green · Planned blue · Cancelled red · Products indigo, with a
   left edge for the recorded engagement (positive / neutral / negative). */
:root {
    --st-done-bg: #DCF2E5; --st-done: #14532D; --st-done-bd: #A7D8BB;
    --st-plan-bg: #DCEEF9; --st-plan: #0B4A6F; --st-plan-bd: #A9CFE6;
    --st-cxl-bg: #FBE3E3;  --st-cxl: #8A1C1C;  --st-cxl-bd: #EFB4B4;
    --st-other-bg: #E9EEF3; --st-other: #334155; --st-other-bd: #CBD5E1;
    --pr-bg: #ECEBFB; --pr: #312E81; --pr-bd: #CFCBF5;
    --eng-pos: #2F9E5B; --eng-neu: #D19A1E; --eng-neg: #D14343;
}
body.ui-refresh .badge.r-status, body.ui-refresh .r-status {
    background: var(--st-other-bg) !important; color: var(--st-other) !important; border: 1px solid var(--st-other-bd) !important;
    font-weight: 600 !important; border-radius: 999px !important; padding: 0.3em 0.7em !important;
}
body.ui-refresh .r-status.r-status-completed, body.ui-refresh .r-status.r-status-done, .r-pill-completed {
    background: var(--st-done-bg) !important; color: var(--st-done) !important; border: 1px solid var(--st-done-bd) !important;
}
body.ui-refresh .r-status.r-status-planned, body.ui-refresh .r-status.r-status-confirmed, .r-pill-planned {
    background: var(--st-plan-bg) !important; color: var(--st-plan) !important; border: 1px solid var(--st-plan-bd) !important;
}
body.ui-refresh .r-status.r-status-canceled, body.ui-refresh .r-status.r-status-cancelled, .r-pill-canceled, .r-pill-cancelled {
    background: var(--st-cxl-bg) !important; color: var(--st-cxl) !important; border: 1px solid var(--st-cxl-bd) !important;
}
body.ui-refresh .badge.r-product, body.ui-refresh .r-product {
    background: var(--pr-bg) !important; color: var(--pr) !important; border: 1px solid var(--pr-bd) !important;
    font-weight: 600 !important; border-radius: 6px !important; padding: 0.3em 0.6em !important;
}
body.ui-refresh .r-product.r-eng-positive { box-shadow: inset 4px 0 0 var(--eng-pos); padding-left: 0.85em !important; }
body.ui-refresh .r-product.r-eng-neutral  { box-shadow: inset 4px 0 0 var(--eng-neu); padding-left: 0.85em !important; }
body.ui-refresh .r-product.r-eng-negative { box-shadow: inset 4px 0 0 var(--eng-neg); padding-left: 0.85em !important; }
/* Case products: same pill as visits; the edge is product indigo (cases have no engagement) */
body.ui-refresh .r-product.r-prod-case { box-shadow: inset 4px 0 0 var(--pr); padding-left: 0.85em !important; }
/* Visit type and other neutral badges in tables: calm slate, not grey-on-grey */
body.ui-refresh table .badge.bg-secondary:not(.r-product):not(.r-status) {
    background: var(--st-other-bg) !important; color: var(--st-other) !important; border: 1px solid var(--st-other-bd);
}
body.ui-refresh th[data-column="note"], body.ui-refresh td[data-column="note"] { min-width: 340px; }
/* ---- Logo: HCES's Branding logo is white (made for the classic blue bar), so
   it sits on a brand-blue panel in the sidebar and a brand-blue phone top bar. */
.r-sidebar .r-logo {
    background: linear-gradient(135deg, #024F75 0%, var(--r-accent) 100%);
    border-radius: 12px; padding: 14px 12px !important; margin-bottom: 14px; justify-content: center;
    box-shadow: 0 4px 12px rgba(var(--r-accent-rgb), 0.25);
}
.r-sidebar .r-logo img { max-width: 100%; max-height: 40px; }
.r-topbar {
    background: linear-gradient(90deg, #024F75 0%, var(--r-accent) 100%) !important; border-bottom: 0 !important;
}
.r-topbar .r-avatar-btn { background: rgba(255, 255, 255, 0.18) !important; color: #FFFFFF !important; border-color: rgba(255, 255, 255, 0.5) !important; }
.r-sidebar .r-logo .r-logo-text, .r-topbar .r-logo-text { color: #FFFFFF !important; }

/* ---- Expandable notes ("Show more" / tap to expand) ---------------------- */
.r-note-clamped { cursor: pointer; }
.r-note-clamped:focus-visible { outline: 2px solid rgba(var(--r-accent-rgb), 0.5); outline-offset: 2px; border-radius: 4px; }
body.ui-refresh .r-note-open, body.ui-refresh td[data-column="note"] .r-note-open {
    -webkit-line-clamp: unset !important; line-clamp: unset !important; max-height: none !important;
    display: block !important; overflow: visible !important; white-space: normal !important; text-overflow: clip !important;
}
.r-note-more {
    display: inline-block; margin-top: 2px; padding: 0; border: 0; background: none;
    font-size: 0.78rem; font-weight: 600; color: var(--r-accent); cursor: pointer;
}
.r-note-more:hover { text-decoration: underline; }

/* Every data card gets a brand-blue left edge (Home, Visits, Cases, My week) */
.r-tile { border-left: 4px solid var(--r-accent) !important; }

/* Benchmarks on data cards ("Last week: 4 ▲ 2"): up green, down calm grey */
.r-delta {
    display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 700; line-height: 1.5; vertical-align: 1px; white-space: nowrap;
}
.r-delta-up { background: var(--st-done-bg, #DCF2E5); color: var(--st-done, #14532D); }
.r-delta-down { background: #EEF1F4; color: #4B5864; }
.r-delta-flat { background: #EEF1F4; color: #4B5864; }
.r-vs { white-space: nowrap; }

/* Visits / Cases desktop tables, My week look: status edge, pills, hospital map link */
body.ui-refresh tr.r-trow { --r-edge: var(--st-other-bd, #CBD5E1); }
body.ui-refresh tr.r-trow.r-st-completed { --r-edge: #2E9E5B; }
body.ui-refresh tr.r-trow.r-st-planned { --r-edge: var(--r-accent); }
body.ui-refresh tr.r-trow.r-st-canceled, body.ui-refresh tr.r-trow.r-st-cancelled { --r-edge: #C24141; }
body.ui-refresh tr.r-trow > td:first-child { box-shadow: inset 4px 0 0 var(--r-edge); padding-left: 12px !important; }
body.ui-refresh tr.r-trow td[data-column="doctor"] strong { font-weight: 700; color: var(--r-head-ink); }
body.ui-refresh tr.r-trow .r-trow-status { display: inline-block; margin-top: 4px; font-size: 0.7rem; }
body.ui-refresh tr.r-trow td[data-column="products"] .r-chips { gap: 4px; }
body.ui-refresh tr.r-trow td[data-column="products"] .r-pill { font-size: 0.72rem; white-space: normal; text-align: left; }
.r-hosp-link {
    display: inline-flex; align-items: baseline; gap: 5px; font-weight: 600; text-decoration: none;
    color: var(--r-accent) !important;
}
.r-hosp-link:hover { text-decoration: underline; }

/* Visits / Cases on phones: the My week-style list replaces the old card/table views */
@media (max-width: 767.98px) {
    body.r-page-visits .item-container, body.r-page-cases .item-container,
    body.r-page-visits .items-table-container, body.r-page-cases .items-table-container,
    body.r-page-visits .view-toggle-container, body.r-page-cases .view-toggle-container { display: none !important; }
    .r-phone-list { margin-bottom: 12px; }
}

/* Visits / Cases card view (phones): action buttons on the right-hand side */
.r-card-actions { justify-content: flex-end; }

/* My week: edit / delete on each row */
.r-acts { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.r-acts .btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.r-seg { display: inline-flex; }
.r-wk-hosp-full { display: none; }
@media (max-width: 767.98px) {
    /* Phone: fewer filters (week, rep, status, doctor search) */
    .r-filterbar .r-hide-phone { display: none !important; }
    .r-acts .btn { width: 40px; height: 36px; }

    /* Phone: each visit/case is its own card, status as a coloured left edge.
       One type scale: name 1rem/700 · where 0.875/600 · body 0.85 · meta 0.78 */
    section.r-list:has(.r-wk-row) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
    section.r-list:has(.r-wk-row) .r-dayhead {
        background: transparent; border: 0; padding: 14px 2px 6px; font-size: 0.78rem; font-weight: 700;
        text-transform: uppercase; letter-spacing: 0.05em; color: var(--r-head-ink);
    }
    .r-wk-row {
        grid-template-columns: minmax(0, 1fr) auto !important;
        grid-template-areas: "doc when" "hosp hosp" "prod prod" "note note" "more more" "status acts";
        row-gap: 6px; padding: 12px 0 10px !important; margin-bottom: 10px;
        background: var(--r-surface); border: 1px solid var(--r-line) !important; border-left: 4px solid var(--st-other-bd) !important;
        border-radius: 12px; box-shadow: 0 1px 3px rgba(15, 42, 61, 0.08);
        font-size: 0.85rem; line-height: 1.35;
    }
    .r-wk-row.r-wk-st-completed { border-left-color: #2E9E5B !important; }
    .r-wk-row.r-wk-st-planned { border-left-color: var(--r-accent) !important; }
    .r-wk-row.r-wk-st-canceled, .r-wk-row.r-wk-st-cancelled { border-left-color: #C24141 !important; opacity: 0.85; }
    .r-wk-row > * { padding-left: 14px !important; padding-right: 14px !important; }

    .r-wk-row > .r-wk-doc { grid-area: doc !important; }
    .r-wk-row > .r-wk-doc .r-strong { font-size: 1rem; font-weight: 700; color: var(--r-head-ink) !important; line-height: 1.25; }
    .r-wk-row > .r-wk-doc .r-small, .r-wk-row > .r-wk-when .r-small { font-size: 0.78rem; color: var(--r-muted); margin-top: 1px; }
    .r-wk-row > .r-wk-when {
        grid-area: when !important; text-align: right !important; white-space: nowrap;
        font-size: 0.85rem; font-weight: 700; color: var(--r-head-ink);
    }
    .r-wk-row > .r-wk-hosp { grid-area: hosp !important; }
    .r-wk-hosp-short { display: none; }
    .r-wk-hosp-full {
        display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; font-weight: 600;
        color: var(--r-accent) !important; text-decoration: none;
    }
    .r-wk-row > .r-wk-prod { grid-area: prod !important; }
    .r-wk-row > .r-wk-prod .r-pill { font-size: 0.75rem; }
    .r-wk-row > .r-wk-note {
        grid-area: note !important; white-space: normal; font-size: 0.85rem; color: var(--r-ink-2);
        border-top: 1px dashed var(--r-line); padding-top: 6px !important; margin: 0 14px; padding-left: 0 !important; padding-right: 0 !important;
    }
    .r-wk-row > .r-wk-note:empty { display: none; }
    .r-wk-row > .r-note-more { grid-area: more; justify-self: start; }
    .r-wk-row > .r-wk-status { grid-area: status !important; align-self: center; }
    .r-wk-row > .r-acts { grid-area: acts !important; }
    .r-wk-row .r-acts .btn { width: 36px; height: 32px; }
}

/* Visits/Cases data cards: a card that needs action (planned cases past their date) */
.r-tile.r-tile-warn { border-left: 4px solid var(--r-accent) !important; background: linear-gradient(160deg, rgba(var(--r-accent-rgb), 0.06) 0%, rgba(var(--r-accent-rgb), 0.16) 100%), #FFFFFF; }
.r-tile.r-tile-warn .r-tile-value { color: var(--r-head-ink); }

/* Product-count badges ("2 products") join the product palette */
body.ui-refresh table .badge.bg-info {
    background: var(--pr-bg) !important; color: var(--pr) !important; border: 1px solid var(--pr-bd) !important; font-weight: 600 !important;
}
/* Note column wins over the column-resizer's inline widths */
body.ui-refresh th[data-column="note"], body.ui-refresh td[data-column="note"] { min-width: 340px !important; width: 340px !important; }

/* ---- Visits and Cases tables: wide Note, fixed proportions (2026-10-06) ----
   Fixed layout so columns keep their share whatever the content; the Note
   gets about a third of the width and shows three lines (full text on hover),
   which fits inside the existing row height. Action buttons sit 2x2. */
@media (min-width: 992px) {
    body.r-page-visits table[data-table-filter], body.r-page-cases table[data-table-filter] { table-layout: fixed; width: 100%; }

    body.r-page-visits th[data-column="date"]           { width: 7%; }
    body.r-page-visits th[data-column="doctor"]         { width: 12%; }
    body.r-page-visits th[data-column="practice"]       { width: 5%; }
    body.r-page-visits th[data-column="representative"] { width: 8%; }
    body.r-page-visits th[data-column="products"]       { width: 13%; }
    body.r-page-visits th[data-column="engagements"]    { width: 9%; }
    body.r-page-visits th[data-column="visit_type"]     { width: 6%; }
    body.r-page-visits th[data-column="note"]           { width: 32% !important; min-width: 0 !important; }
    body.r-page-visits th[data-column="actions"]        { width: 8%; }

    body.r-page-cases th[data-column="date"]            { width: 6%; }
    body.r-page-cases th[data-column="doctor"]          { width: 11%; }
    body.r-page-cases th[data-column="practice"]        { width: 5%; }
    body.r-page-cases th[data-column="hospital"]        { width: 8%; }
    body.r-page-cases th[data-column="status"]          { width: 7%; }
    body.r-page-cases th[data-column="representative"]  { width: 7%; }
    body.r-page-cases th[data-column="products"]        { width: 13%; }
    body.r-page-cases th[data-column="total"]           { width: 7%; }
    body.r-page-cases th[data-column="note"]            { width: 28% !important; min-width: 0 !important; }
    body.r-page-cases th[data-column="actions"]         { width: 8%; }

    /* My week look (2026-10-07): products as pills need room; engagement lives on the pills */
    body.r-page-visits table.r-eng-merged th[data-column="products"] { width: 22%; }
    body.r-page-cases th[data-column="products"]        { width: 16%; }
    body.r-page-cases th[data-column="note"]            { width: 27% !important; }

    body.r-page-visits td[data-column="note"], body.r-page-cases td[data-column="note"] { width: auto !important; min-width: 0 !important; }
    body.r-page-visits td[data-column="note"] > span, body.r-page-cases td[data-column="note"] > span,
    body.r-page-visits td[data-column="note"] .text-wrap, body.r-page-cases td[data-column="note"] .text-wrap {
        -webkit-line-clamp: 3; line-clamp: 3; max-height: 4.2em; font-size: 0.86rem;
    }
    body.r-page-visits table[data-table-filter] td, body.r-page-cases table[data-table-filter] td,
    body.r-page-visits table[data-table-filter] th, body.r-page-cases table[data-table-filter] th {
        overflow-wrap: anywhere; padding-left: 8px !important; padding-right: 8px !important;
    }
    /* Compact actions: small buttons, 2 x 2 */
    body.r-page-visits td[data-column="actions"], body.r-page-cases td[data-column="actions"] { white-space: normal !important; }
    body.r-page-visits td[data-column="actions"] .btn, body.r-page-cases td[data-column="actions"] .btn {
        padding: 0.2rem 0.4rem !important; font-size: 0.75rem !important; min-height: 0 !important; line-height: 1.2;
    }
    body.r-page-visits td[data-column="actions"] .btn-group, body.r-page-cases td[data-column="actions"] .btn-group { flex-wrap: wrap; }
}

/* Visits/Cases fixed layout, round 2: clean headers, no mid-word breaks, one row of actions */
@media (min-width: 992px) {
    body.r-page-visits th[data-column="representative"] { width: 9%; }
    body.r-page-visits th[data-column="note"]           { width: 29% !important; }
    body.r-page-visits th[data-column="actions"]        { width: 10%; }
    body.r-page-cases th[data-column="practice"]        { width: 6%; }
    body.r-page-cases th[data-column="hospital"]        { width: 7%; }
    body.r-page-cases th[data-column="representative"]  { width: 8%; }
    body.r-page-cases th[data-column="products"]        { width: 12%; }
    body.r-page-cases th[data-column="note"]            { width: 26% !important; }
    body.r-page-cases th[data-column="actions"]         { width: 10%; }

    body.r-page-visits table[data-table-filter] th, body.r-page-cases table[data-table-filter] th {
        overflow-wrap: normal !important; word-break: normal !important; hyphens: none;
        font-size: 0.68rem !important; letter-spacing: 0.02em !important; overflow: hidden;
    }
    /* Column icons take width these narrow columns need; the label and the
       filter funnel stay */
    body.r-page-visits table[data-table-filter] th i,
    body.r-page-cases table[data-table-filter] th i { display: none !important; }
    body.r-page-visits table[data-table-filter] th .filter-btn i,
    body.r-page-cases table[data-table-filter] th .filter-btn i { display: inline-block !important; }
    body.r-page-visits table[data-table-filter] th, body.r-page-cases table[data-table-filter] th { letter-spacing: 0 !important; }
    /* Short-code columns: slightly smaller text so words fit without breaking */
    body.r-page-visits td[data-column="practice"], body.r-page-visits td[data-column="visit_type"],
    body.r-page-cases td[data-column="practice"], body.r-page-cases td[data-column="hospital"],
    body.r-page-cases td[data-column="status"], body.r-page-cases td[data-column="total"] { font-size: 0.8rem !important; }
    body.r-page-cases th[data-column="practice"] { width: 7%; }
    body.r-page-cases th[data-column="hospital"] { width: 6%; }
    /* "Rep" header is short now: give the space back to Note */
    body.r-page-visits th[data-column="practice"]       { width: 6%; }
    body.r-page-visits th[data-column="doctor"]         { width: 11%; }
    body.r-page-visits th[data-column="representative"] { width: 8%; }
    body.r-page-visits th[data-column="note"]           { width: 30% !important; }
    body.r-page-cases th[data-column="representative"]  { width: 7%; }
    body.r-page-cases th[data-column="note"]            { width: 27% !important; }
    /* Practice column removed from Cases (Hospital already shows where): its 7% goes to Note, Products, Hospital */
    body.r-page-cases th[data-column="note"]            { width: 31% !important; }
    body.r-page-cases th[data-column="products"]        { width: 14%; }
    body.r-page-cases th[data-column="hospital"]        { width: 7%; }
    body.r-page-visits table[data-table-filter] td, body.r-page-cases table[data-table-filter] td {
        overflow-wrap: break-word !important; word-break: normal !important;
    }

    body.r-page-visits td[data-column="actions"], body.r-page-cases td[data-column="actions"] { white-space: nowrap !important; }
    body.r-page-visits td[data-column="actions"] > *, body.r-page-cases td[data-column="actions"] > * {
        display: inline-flex !important; vertical-align: middle; margin: 0 1px !important;
    }
    body.r-page-visits td[data-column="actions"] .btn-group, body.r-page-cases td[data-column="actions"] .btn-group { flex-wrap: nowrap !important; }
    body.r-page-visits td[data-column="actions"] .btn, body.r-page-cases td[data-column="actions"] .btn {
        padding: 0.18rem 0.32rem !important; font-size: 0.72rem !important;
    }
}

/* ---- My week rows on desktop (2026-10-18) --------------------------------
   Edit/delete always sit in the last column of the first line. "Show more"
   (added by script after the note) goes under the note instead of taking the
   Actions cell. The Rep column shows who did the case / visit (Everyone view). */
@media (min-width: 768px) {
    .r-wk-row > .r-acts { grid-column: -2; grid-row: 1; }
    .r-wk-row > .r-note-more { grid-column: -3; grid-row: 2; justify-self: start; padding: 0 16px 10px; margin-top: -6px; }
    .r-wk-rep { font-size: 0.85rem; color: var(--r-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .r-wk-rep i { color: var(--r-muted); font-size: 0.75rem; margin-right: 3px; }
}

/* ---- "Add to calendar" on My week rows and phone cards (2026-10-18) ------
   The menu opens above the button, aligned right so it never leaves the
   screen on phones; lists stop clipping while it is open. */
.r-acts .calendar-quick-action__options { left: auto; right: 0; transform: translateY(10px) scale(0.96); }
.r-acts .calendar-quick-action--open .calendar-quick-action__options { transform: translateY(0) scale(1); }
.r-list:has(.calendar-quick-action--open), .r-wk-row:has(.calendar-quick-action--open) { overflow: visible !important; }
.r-acts .calendar-quick-action__option { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* Rep on phone cards: own short line under the specialty, icon and name together */
.r-card-rep { white-space: nowrap; }
@media (max-width: 767.98px) {
    .r-wk-doc .r-card-rep { display: block; margin-top: 1px; }
    .r-wk-doc .r-card-rep i { font-size: 0.7rem; margin-right: 2px; }
}
