/* VeraTap Owner Web – custom styles */

/* ═══════════════════════════════════════════════════════════════════════════════
   REFERENCE DESIGN – VeraTap dark theme (Poppins — owner site)
   ═══════════════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Same stack as web/main/static/agency/css/index.css */
    --vt-font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --bg-base:       #0b0d10;
    --bg-surface:    #111318;
    --bg-elevated:   #181c23;
    --bg-glass:      rgba(255,255,255,0.03);
    --border:        rgba(255,255,255,0.07);
    /* Horizontal rules in dark sidebar / mobile drawer (readable on all breakpoints) */
    --sidebar-hr-line: rgba(255, 255, 255, 0.3);
    /* Sidebar active item border — agency marketing purple */
    --border-active: rgba(99, 102, 241, 0.45);
    --accent-purple: #6366f1;
    --accent-purple-soft: #a5b4fc;
    --accent-purple-bg: rgba(99, 102, 241, 0.12);
    --accent-purple-glow: rgba(99, 102, 241, 0.55);
    --accent-red:    #e03030;
    --accent-red-dim:#7c1a1a;
    --accent-blue:   #3b82f6;
    --accent-glow:   rgba(224,48,48,0.15);
    --text-primary:  #edf0f4;
    --text-secondary:#7a8394;
    --text-muted:    #3e4452;
    --sidebar-w:     240px;
    --radius:        12px;
    --radius-sm:     8px;

    /* Main column (light) — sidebar keeps dark tokens above */
    --main-bg:          #ffffff;
    --main-text:        #4b5563;
    --main-heading:     #1f2937;
    --main-muted:       #6b7280;
    --main-border:      #e5e7eb;
    /* Purple outline for main-column panels (matches sidebar active accent) */
    --main-frame-border: var(--border-active);
    --main-frame-border-width: 2px;
    --main-surface:     #f9fafb;
    --main-elevated:    #f3f4f6;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   VIEW TRANSITIONS – smooth page navigation (Chrome/Edge, graceful fallback)
   ═══════════════════════════════════════════════════════════════════════════════ */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.15s;
    animation-timing-function: ease-out;
}

/* Fade out old page */
::view-transition-old(root) {
    animation-name: vt-fade-out;
}

/* Fade in new page */
::view-transition-new(root) {
    animation-name: vt-fade-in;
}

@keyframes vt-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes vt-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* HTMX loading indicator */
.htmx-request .content {
    opacity: 0.7;
    transition: opacity 0.1s ease-out;
}

/* Global dark theme – all pages */
body.vt-dark {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--vt-font-sans);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Bootstrap 5 — Poppins for components (buttons, forms, modals) */
    --bs-body-font-family: var(--vt-font-sans);
    --bs-font-sans-serif: var(--vt-font-sans);
}
/* Exclude .nav-link: same as .main link rule — .nav-item is on <li>, so pill <a> would match and beat pill-specific rules in Chromium (0,5,2) vs (0,5,1). */
body.vt-dark a:not(.btn):not(.nav-item):not(.nav-link):not(.sidebar-link):not(.dropdown-item) {
    color: var(--text-secondary);
}
body.vt-dark a:not(.btn):not(.nav-item):not(.nav-link):not(.sidebar-link):not(.dropdown-item):hover {
    color: var(--text-primary);
}
/* Any card in dark theme (fallback for cards outside .content) */
body.vt-dark .card:not(.auth-card) {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

/* App shell: sidebar stays dark; main column is light (see .main rules below) */
body.vt-layout {
    height: 100%;
    overflow-x: hidden;
    overflow-y: hidden; /* page itself doesn't scroll; main/content do */
    background: var(--main-bg);
}

body.vt-layout::before {
    display: none;
}

.layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    position: relative;
    z-index: 1;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.45), transparent);
}

.logo {
    display: block;
    padding: 6px 8px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.logo .logo-img {
    display: block;
    width: auto;
    max-width: 168px;
    height: auto;
    object-fit: contain;
}

.account-strip {
    padding: 10px 10px 14px;
    margin-bottom: 10px;
}

.account-strip .label {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--vt-font-sans);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.account-strip .agency-name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.35;
    word-break: break-word;
}

.account-strip .agency-id {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--vt-font-sans);
    letter-spacing: 0.04em;
    margin-top: 4px;
}

.account-strip .agency-email {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--vt-font-sans);
    letter-spacing: 0.04em;
    line-height: 1.35;
    margin-top: 6px;
    word-break: break-word;
}

/* Match gap from logo bottom rule → “MY AGENCY” (.logo margin-bottom + .account-strip padding-top) */
.sidebar-account-divider {
    margin: 18px 0 0;
    border: 0;
    border-top: 1px solid var(--sidebar-hr-line);
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.18s ease;
    position: relative;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
    user-select: none;
    text-decoration: none;
    width: 100%;
    box-sizing: border-box;
}

.sidebar .nav-item:hover {
    color: #ffffff;
    background: var(--bg-glass);
    border-color: var(--border);
}

.sidebar .nav-item.active {
    color: var(--accent-purple-soft);
    background: var(--accent-purple-bg);
    border-color: var(--border-active);
}

.sidebar .nav-item.active::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-purple);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px var(--accent-purple-glow);
}

.sidebar .nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.92;
    color: #ffffff;
}

/* Bootstrap Icons beside stroke SVGs — match size / alignment */
.sidebar .nav-item .nav-icon.bi {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 1.05rem;
    line-height: 1;
}

.sidebar .nav-item.active .nav-icon { opacity: 1; }

@keyframes vt-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.7); }
}

.sidebar .nav-section {
    padding: 14px 12px 4px;
    font-size: 10px;
    font-family: var(--vt-font-sans);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar .sub-items { padding-left: 26px; }

.sidebar .sub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12.5px;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sub-item::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.15s;
}

.sidebar .sub-item:hover {
    color: var(--text-primary);
}

.sidebar .sub-item:hover::before { background: var(--accent-purple); }

/* Footer stays fixed at bottom of sidebar (outside scroll area) */
.sidebar-footer {
    flex-shrink: 0;
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

.sidebar-footer .sidebar-footer-logout {
    text-decoration: none;
}

.sidebar .sidebar-footer .sidebar-footer-logout:hover,
.sidebar .sidebar-footer .sidebar-footer-logout:focus {
    color: var(--accent-red) !important;
    background: rgba(224, 48, 48, 0.12) !important;
    border-color: rgba(224, 48, 48, 0.35) !important;
}

.sidebar .sidebar-footer .sidebar-footer-logout:hover .nav-icon,
.sidebar .sidebar-footer .sidebar-footer-logout:focus .nav-icon {
    color: var(--accent-red);
    opacity: 1;
}

/* MAIN CONTENT */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto; /* main scrolls; sidebar stays fixed */
}

/* Constrain and center page content on desktop (max 1080px) */
.main-inner {
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: visible;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(17,19,24,0.7);
    backdrop-filter: blur(8px);
    gap: 16px;
    flex-shrink: 0;
}

.page-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    background: rgba(224,48,48,0.08);
    border: 1px solid rgba(224,48,48,0.25);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    color: #f87171;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-family: var(--vt-font-sans);
}

.live-badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f87171;
    animation: vt-pulse 1.8s ease-in-out infinite;
}

/* Live page (home): mobile-only banner — desktop uses topbar title + .live-badge */
.vt-live-page-banner {
    margin-inline: 10px;
    padding: 12px 14px;
    border-radius: var(--radius, 8px);
    border: 1px solid rgba(224, 48, 48, 0.22);
    background: rgba(224, 48, 48, 0.07);
    font-family: var(--vt-font-sans);
}
.vt-live-page-banner__badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #f87171;
}
.vt-live-page-banner__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f87171;
    flex-shrink: 0;
    animation: vt-pulse 1.8s ease-in-out infinite;
}

.page-title {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.auto-refresh-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 11.5px;
    font-family: var(--vt-font-sans);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.18s;
    letter-spacing: 0.04em;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
}
.auto-refresh-toggle.is-paused .toggle-pill {
    background: #94a3b8;
    box-shadow: none;
}
.auto-refresh-toggle.is-paused .toggle-knob {
    right: auto;
    left: 2px;
}

.auto-refresh-toggle:hover {
    border-color: rgba(59,130,246,0.3);
    color: var(--text-primary);
}

.toggle-pill {
    width: 28px;
    height: 15px;
    background: var(--accent-blue);
    border-radius: 100px;
    position: relative;
    box-shadow: 0 0 8px rgba(59,130,246,0.4);
}

.toggle-knob {
    position: absolute;
    right: 2px;
    top: 2px;
    width: 11px;
    height: 11px;
    background: white;
    border-radius: 50%;
    transition: all 0.18s;
}

.icon-btn {
    width: 34px;
    height: 34px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
    text-decoration: none;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.15);
}

.stats-bar {
    display: flex;
    gap: 1px;
    padding: 0 28px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.stat-chip {
    padding: 10px 18px;
    font-family: var(--vt-font-sans);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-chip .val {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-chip .val.stat-val--awaiting { color: #f87171; }

.content {
    flex: 1;
    overflow: auto;
    padding: 28px;
    display: flex;
    flex-direction: column;
}

/* Main column — white background, dark gray type (sidebar unchanged) */
body.vt-layout .main {
    background: var(--main-bg);
    color: var(--main-text);
    position: relative;
    z-index: 1;
}

body.vt-layout .main .topbar {
    background: var(--main-bg);
    border-bottom: 1px solid var(--main-border);
}

body.vt-layout .main .page-title {
    color: var(--main-heading);
}

body.vt-layout .main .page-title > .bi {
    font-size: 1.2em;
    color: var(--main-heading);
    flex-shrink: 0;
}

body.vt-layout .main .stats-bar {
    background: var(--main-surface);
    border-bottom: 1px solid var(--main-border);
}

body.vt-layout .main .stat-chip {
    color: var(--main-muted);
}

body.vt-layout .main .stat-chip .val {
    color: var(--main-heading);
}

body.vt-layout .main .icon-btn {
    background: var(--main-surface);
    border: 1px solid var(--main-border);
    color: var(--main-muted);
}

body.vt-layout .main .icon-btn:hover {
    color: var(--main-heading);
    border-color: #d1d5db;
}

body.vt-layout .main .auto-refresh-toggle {
    background: var(--main-surface);
    border: 1px solid var(--main-border);
    color: var(--main-muted);
}

body.vt-layout .main .auto-refresh-toggle:hover {
    color: var(--main-heading);
    border-color: #d1d5db;
}
body.vt-layout .main .auto-refresh-toggle.is-paused .toggle-pill {
    background: #94a3b8;
}

body.vt-layout .main .empty-title {
    color: var(--main-heading);
}

body.vt-layout .main .empty-sub {
    color: var(--main-muted);
}

body.vt-layout .main .orb-ring {
    border-color: var(--main-border);
}

body.vt-layout .main .orb-ring:nth-child(2) {
    border-color: rgba(99, 102, 241, 0.2);
}

body.vt-layout .main .orb-core {
    background: var(--main-surface);
    border: 1px solid var(--main-border);
}

body.vt-layout .main .orb-core svg {
    color: var(--main-muted);
    stroke-width: 2.85;
}

body.vt-layout .main .btn-ghost {
    background: var(--main-surface);
    color: var(--main-text);
    border: 1px solid var(--main-border);
}

body.vt-layout .main .btn-ghost:hover {
    color: var(--main-heading);
    border-color: #d1d5db;
}

/* Links in main column (body.vt-dark defaults assume dark page bg).
   Exclude .nav-link: Bootstrap puts .nav-item on <li>, so pill <a> would still match and get indigo over pill colors. */
body.vt-layout .main a:not(.btn):not(.nav-item):not(.nav-link):not(.sidebar-link):not(.dropdown-item) {
    color: #4f46e5;
}
body.vt-layout .main a:not(.btn):not(.nav-item):not(.nav-link):not(.sidebar-link):not(.dropdown-item):hover {
    color: #4338ca;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    animation: vt-fadeUp 0.5s ease forwards;
}

@keyframes vt-fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.empty-orb {
    position: relative;
    width: 90px;
    height: 90px;
}

.orb-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid var(--border);
    animation: vt-spin 8s linear infinite;
}

.orb-ring:nth-child(2) {
    inset: 10px;
    border-color: rgba(224,48,48,0.15);
    animation: vt-spin 12s linear infinite reverse;
}

@keyframes vt-spin {
    to { transform: rotate(360deg); }
}

.orb-core {
    position: absolute;
    inset: 22px;
    background: var(--bg-elevated);
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-core svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.empty-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.empty-sub {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    max-width: 320px;
    line-height: 1.6;
    font-family: var(--vt-font-sans);
}

.empty-cta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--vt-font-sans);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
    border: none;
    letter-spacing: 0.02em;
}

.btn-primary {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 4px 16px rgba(224,48,48,0.3);
}

.btn-primary:hover {
    background: #c52828;
    box-shadow: 0 4px 20px rgba(224,48,48,0.45);
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.15);
}

body.vt-layout .content ::-webkit-scrollbar { width: 5px; }
body.vt-layout .content ::-webkit-scrollbar-track { background: transparent; }
body.vt-layout .content ::-webkit-scrollbar-thumb { background: var(--main-border); border-radius: 10px; }

body.vt-layout .app-header-mobile {
    background: var(--main-bg);
    border-bottom: 1px solid var(--main-border);
    color: var(--main-heading);
}
body.vt-layout .app-header-mobile__brand { color: var(--main-heading); }
body.vt-layout .app-header-mobile__brand-logo {
    filter: none;
}
body.vt-layout .app-header-mobile .btn-outline-secondary {
    border-color: var(--main-border);
    color: var(--main-heading);
    background-color: var(--main-bg);
    -webkit-appearance: none;
    appearance: none;
}
body.vt-layout .app-header-mobile .btn-outline-secondary:hover {
    background: var(--main-surface);
    color: var(--main-heading);
    border-color: #d1d5db;
}
body.vt-layout .app-header-mobile .app-header-mobile__menu .bi-list {
    color: var(--main-heading);
}

.sidebar .sub-item.active { color: var(--text-primary); }
.sidebar .sub-item.active::before { background: var(--accent-purple); }

/* Content area — light theme inside main column */
body.vt-layout .content .table-modern-wrapper,
body.vt-layout .content .table-responsive {
  background: var(--main-bg);
  border: 1px solid var(--main-border);
  border-radius: var(--radius);
  overflow: hidden;
}
body.vt-layout .content .table {
  color: var(--main-text);
  margin-bottom: 0;
}
body.vt-layout .content .table thead th {
  background: var(--main-surface);
  border-bottom: 1px solid var(--main-border);
  color: var(--main-muted);
  font-size: 11px;
  font-family: var(--vt-font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 14px;
}
body.vt-layout .content .table tbody td {
  border-bottom: 1px solid var(--main-border);
  padding: 12px 14px;
  color: var(--main-text);
}
body.vt-layout .content .table tbody tr:last-child td { border-bottom: none; }
body.vt-layout .content .alert {
  background: var(--main-surface);
  border: 1px solid var(--main-border);
  color: var(--main-heading);
  border-radius: var(--radius-sm);
}

/* Colored alert text for success/error states in main content */
body.vt-layout .content .alert-success {
  color: #15803d;
}

body.vt-layout .content .alert-danger,
body.vt-layout .content .alert-error {
  color: #b91c1c;
}
body.vt-layout .content .text-muted { color: var(--main-muted) !important; }
body.vt-layout .content .avatar-circle {
    background: var(--main-surface) !important;
    border: 1px solid var(--main-border);
    color: var(--main-heading);
}

/* Content area — cards and forms */
body.vt-layout .content .card {
    background: var(--main-bg);
    border: var(--main-frame-border-width) solid var(--main-frame-border);
    color: var(--main-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
body.vt-layout .content .card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: var(--main-frame-border);
}
body.vt-layout .content .img-thumbnail {
    background-color: var(--main-bg);
    border: var(--main-frame-border-width) solid var(--main-frame-border);
}
body.vt-layout .content .form-control,
body.vt-layout .content .form-select {
    background: var(--main-bg);
    border-color: var(--main-border);
    color: var(--main-heading);
}
body.vt-layout .content .form-control::placeholder {
    color: #9ca3af;
}
body.vt-layout .content .form-control:focus,
body.vt-layout .content .form-select:focus {
    background: var(--main-bg);
    color: var(--main-heading);
}
body.vt-layout .content .form-label,
body.vt-layout .content .form-label.small.text-muted {
    color: var(--main-muted);
}
body.vt-layout .content h4,
body.vt-layout .content h5,
body.vt-layout .content h6 {
    color: var(--main-heading);
}

/*
 * Bootstrap Icons (font): the visible glyph is drawn on i.bi::before, not on the <i>.
 * Heavier look in the main column only — desktop sidebar and offcanvas sit outside .main.
 */
body.vt-layout .main i.bi::before {
    -webkit-text-stroke: 0.65px currentColor;
    paint-order: stroke fill;
}

/* Topbar filter/export stroke SVGs (main only; sidebar Live/Search SVGs are outside .main) */
body.vt-layout .main .topbar .icon-btn svg {
    stroke-width: 2.85;
}
body.vt-layout .content .nav-pills .nav-link {
    color: var(--main-muted);
}
body.vt-layout .content .nav-pills .nav-link:hover {
    color: var(--main-heading);
    background-color: var(--main-surface);
}
body.vt-layout .content .nav-pills .nav-link.active,
body.vt-layout .content .nav-pills .nav-link.active.btn-sm,
body.vt-layout .content .nav-pills .nav-link.active:link,
body.vt-layout .content .nav-pills .nav-link.active:visited,
body.vt-layout .content .nav-pills .nav-link.active.btn-sm:link,
body.vt-layout .content .nav-pills .nav-link.active.btn-sm:visited {
    background-color: var(--accent-purple);
    color: #fff !important;
    -webkit-text-fill-color: #fff;
}
body.vt-layout .content .nav-pills .nav-link.active:hover,
body.vt-layout .content .nav-pills .nav-link.active:focus,
body.vt-layout .content .nav-pills .nav-link.active:focus-visible,
body.vt-layout .content .nav-pills .nav-link.active.btn-sm:hover,
body.vt-layout .content .nav-pills .nav-link.active.btn-sm:focus,
body.vt-layout .content .nav-pills .nav-link.active.btn-sm:focus-visible {
    background-color: var(--accent-purple);
    color: #fff !important;
    -webkit-text-fill-color: #fff;
}

/* Settings sub-pages: one row on phone; scroll horizontally instead of wrapping */
@media (max-width: 767.98px) {
    body.vt-layout .content .vt-settings-subnav-scroll {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
    }
    body.vt-layout .content .vt-settings-subnav-scroll .nav {
        flex-wrap: nowrap;
    }
    body.vt-layout .content .vt-settings-subnav-scroll .nav-item {
        flex-shrink: 0;
    }
    body.vt-layout .content .vt-settings-subnav-scroll .nav-link {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    body.vt-layout .content .vt-settings-subnav-scroll::-webkit-scrollbar {
        height: 6px;
    }
    body.vt-layout .content .vt-settings-subnav-scroll::-webkit-scrollbar-thumb {
        background: color-mix(in srgb, var(--main-muted, #64748b) 45%, transparent);
        border-radius: 999px;
    }
}

.vt-card-max-500 { max-width: 500px; }
.vt-max-w-180 { max-width: 180px; }
.vt-th-avatar { width: 40px; }
.vt-progress-thin { height: 6px; }
.vt-progress-thin .progress-bar { width: 0; }
.vt-avatar-client { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-secondary); }
.vt-avatar-employee { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-secondary); }
/* Supervisor: orange ring (distinct from sidebar purple highlight) */
.vt-avatar-supervisor { box-shadow: 0 0 0 2px var(--vt-orange, #ff7043); }

/* Live feed: tap-in / tap-out detail rows hidden until summary row clicked */
.vt-visit-detail.d-none { display: none !important; }

/*
 * Live (#live-table) and Search (#search-results): .vt-live-feed defines columns; header + cards use
 * subgrid so labels and values share one track layout. Tablet / phone adjust --vt-live-grid only.
 */
body.vt-layout #live-table .vt-live-feed, body.vt-layout #search-results .vt-live-feed {
    --vt-live-grid: 48px minmax(11rem, 1fr) minmax(11rem, 1fr) minmax(12ch, 14ch) minmax(6.25rem, max-content) 40px;
    --vt-live-col-gap: 24px;
    /* Same value on .vt-live-feed-header and .vt-live-entry so subgrid columns stay aligned */
    --vt-live-card-pad-x: 14px;
    display: grid;
    grid-template-columns: var(--vt-live-grid);
    column-gap: var(--vt-live-col-gap);
    row-gap: 12px;
    padding: 0 16px;
    max-width: 100%;
    min-width: 0;
}
body.vt-layout #live-table .vt-live-feed-header, body.vt-layout #search-results .vt-live-feed-header {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    column-gap: var(--vt-live-col-gap);
    justify-items: stretch;
    align-items: end;
    padding: 4px var(--vt-live-card-pad-x) 10px;
    font-size: 11px;
    font-family: var(--vt-font-sans);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--main-muted);
}
body.vt-layout #live-table .vt-live-feed-th:not(.vt-live-col-chevron):not(.vt-live-col-avatar), body.vt-layout #search-results .vt-live-feed-th:not(.vt-live-col-chevron):not(.vt-live-col-avatar) {
    text-align: start;
    justify-self: stretch;
    min-width: 0;
}
body.vt-layout #live-table .vt-live-feed-th.vt-live-col-chevron, body.vt-layout #search-results .vt-live-feed-th.vt-live-col-chevron {
    text-align: right;
    justify-self: stretch;
}
body.vt-layout #live-table .vt-live-entry, body.vt-layout #search-results .vt-live-entry {
    grid-column: 1 / -1;
    border: 1px solid var(--main-border);
    border-radius: var(--radius);
    background: #ffffff;
    /* Vertical padding so avatar + supervisor ring (box-shadow) stay inside the clip for border-radius */
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    display: grid;
    grid-template-columns: subgrid;
    column-gap: var(--vt-live-col-gap);
    justify-items: stretch;
    row-gap: 0;
    /* Horizontal inset lives on summary / detail rows so hover fill matches header and breathes at avatar + caret. */
    padding: 8px 0;
    color: #111827;
}
body.vt-layout #live-table .vt-live-entry-summary, body.vt-layout #search-results .vt-live-entry-summary {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    column-gap: var(--vt-live-col-gap);
    justify-items: stretch;
    align-items: center;
    row-gap: 8px;
    /* Inset hover fill from card left/right by the same amount as padding-block (token matches header rhythm). */
    margin-inline: var(--vt-live-card-pad-x);
    padding: var(--vt-live-card-pad-x);
    color: #111827;
    background: #ffffff;
}
body.vt-layout #live-table .vt-visit-detail, body.vt-layout #search-results .vt-visit-detail {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    column-gap: var(--vt-live-col-gap);
    justify-items: stretch;
    align-items: center;
    row-gap: 8px;
    margin-inline: var(--vt-live-card-pad-x);
    padding: 12px var(--vt-live-card-pad-x);
    color: #111827;
    border-top: 1px solid #e5e7eb;
}
body.vt-layout #live-table .vt-live-entry-summary:hover, body.vt-layout #search-results .vt-live-entry-summary:hover {
    background: #f3f4f6;
}
body.vt-layout #live-table .vt-live-entry-summary, body.vt-layout #search-results .vt-live-entry-summary .text-muted {
    color: #4b5563 !important;
}
body.vt-layout #live-table .vt-visit-tap-in-row, body.vt-layout #search-results .vt-visit-tap-in-row {
    background: rgba(0, 128, 0, 0.12);
    color: #166534;
}
body.vt-layout #live-table .vt-visit-tap-out-row, body.vt-layout #search-results .vt-visit-tap-out-row {
    background: rgba(200, 0, 0, 0.12);
    color: #991b1b;
}
body.vt-layout #live-table .vt-live-col-avatar, body.vt-layout #search-results .vt-live-col-avatar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
/* Ring inside the 32×32 box so overflow:hidden on the card does not clip (global uses box-shadow). */
body.vt-layout #live-table .vt-live-col-avatar .avatar-circle.vt-avatar-supervisor,
body.vt-layout #search-results .vt-live-col-avatar .avatar-circle.vt-avatar-supervisor {
    box-shadow: none;
    border: 2px solid var(--vt-orange, #ff7043);
}
body.vt-layout #live-table .vt-live-col-chevron, body.vt-layout #search-results .vt-live-col-chevron {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Live grid: left-align text in every data column (summary + tap subrows). */
body.vt-layout #live-table .vt-live-col:not(.vt-live-col-avatar):not(.vt-live-col-chevron), body.vt-layout #search-results .vt-live-col:not(.vt-live-col-avatar):not(.vt-live-col-chevron) {
    text-align: start;
    justify-self: stretch;
    min-width: 0;
}
body.vt-layout #live-table .vt-live-col-clinician,
body.vt-layout #live-table .vt-live-col-patient,
body.vt-layout #search-results .vt-live-col-clinician,
body.vt-layout #search-results .vt-live-col-patient {
    overflow-wrap: break-word;
    word-break: normal;
}
body.vt-layout #live-table .vt-live-col-date, body.vt-layout #search-results .vt-live-col-date,
body.vt-layout #live-table .vt-live-col-duration, body.vt-layout #search-results .vt-live-col-duration {
    font-variant-numeric: tabular-nums;
}
body.vt-layout #live-table .vt-live-col-duration.vt-live-duration--value, body.vt-layout #search-results .vt-live-col-duration.vt-live-duration--value {
    color: #15803d;
    font-weight: 500;
}
body.vt-layout #live-table .vt-live-entry-summary:hover .vt-live-col-duration.vt-live-duration--value, body.vt-layout #search-results .vt-live-entry-summary:hover .vt-live-col-duration.vt-live-duration--value {
    color: #166534;
}
/* Subrows: col 3 = tap date (same track as patient); col 4 = tap time (same track as parent visit date) */
body.vt-layout #live-table .vt-visit-detail-kind, body.vt-layout #search-results .vt-visit-detail-kind {
    text-align: start;
    min-width: 0;
}
body.vt-layout #live-table .vt-visit-detail-kind .vt-tap-kind, body.vt-layout #search-results .vt-visit-detail-kind .vt-tap-kind {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.92;
}
body.vt-layout #live-table .vt-visit-detail-date, body.vt-layout #search-results .vt-visit-detail-date,
body.vt-layout #live-table .vt-visit-detail-time, body.vt-layout #search-results .vt-visit-detail-time {
    text-align: start;
    font-variant-numeric: tabular-nums;
    min-width: 0;
}
body.vt-layout #live-table .vt-visit-detail-time, body.vt-layout #search-results .vt-visit-detail-time {
    font-weight: 500;
}
body.vt-layout #live-table .vt-visit-detail-duration-spacer, body.vt-layout #search-results .vt-visit-detail-duration-spacer {
    min-width: 0;
}

/* Browsers without subgrid: flex feed + explicit per-row grids (column widths may not match header). */
@supports not (grid-template-columns: subgrid) {
    body.vt-layout #live-table .vt-live-feed,
    body.vt-layout #search-results .vt-live-feed {
        display: flex;
        flex-direction: column;
        gap: 12px;
        grid-template-columns: none;
        column-gap: normal;
        row-gap: normal;
    }

    body.vt-layout #live-table .vt-live-feed-header,
    body.vt-layout #search-results .vt-live-feed-header {
        grid-column: auto;
        display: grid;
        grid-template-columns: var(--vt-live-grid);
        column-gap: var(--vt-live-col-gap);
        padding: 4px var(--vt-live-card-pad-x) 10px;
    }

    body.vt-layout #live-table .vt-live-entry,
    body.vt-layout #search-results .vt-live-entry {
        grid-column: auto;
        display: block;
        padding: 8px 0;
    }

    body.vt-layout #live-table .vt-live-entry-summary,
    body.vt-layout #search-results .vt-live-entry-summary,
    body.vt-layout #live-table .vt-visit-detail,
    body.vt-layout #search-results .vt-visit-detail {
        display: grid;
        grid-template-columns: var(--vt-live-grid);
        column-gap: var(--vt-live-col-gap);
        align-items: center;
    }

    body.vt-layout #live-table .vt-live-entry-summary,
    body.vt-layout #search-results .vt-live-entry-summary {
        margin-inline: var(--vt-live-card-pad-x);
        padding: var(--vt-live-card-pad-x);
    }

    body.vt-layout #live-table .vt-visit-detail,
    body.vt-layout #search-results .vt-visit-detail {
        margin-inline: var(--vt-live-card-pad-x);
        padding: 12px var(--vt-live-card-pad-x);
    }
}

/*
 * Tablet (sidebar + main below “wide” 1080 breakpoint): Search keeps roomier columns.
 * Live page: compress grid + gaps so the feed fits the narrow main column without horizontal scroll.
 */
@media (min-width: 768px) and (max-width: 1079.98px) {
    body.vt-layout #live-table {
        min-width: 0;
        max-width: 100%;
    }

    body.vt-layout #search-results .vt-live-feed {
        --vt-live-grid: 44px minmax(9.5rem, 1fr) minmax(9.5rem, 1fr) minmax(11ch, 13ch) minmax(6rem, max-content) 36px;
        --vt-live-col-gap: 22px;
    }

    body.vt-layout #live-table .vt-live-feed {
        /* Wider avatar track; clinician + patient share equal fr; date/duration/chevron stay compact. */
        --vt-live-grid: 48px minmax(0, 1fr) minmax(0, 1fr) minmax(7ch, 10ch) minmax(2.35rem, max-content) 26px;
        /* Tighter between patient–date–duration–caret; extra clinician–patient via padding on clinician cells below. */
        --vt-live-col-gap: 12px;
        --vt-live-card-pad-x: 10px;
        padding: 0 12px;
    }

    body.vt-layout #live-table .vt-live-feed-header {
        font-size: 10px;
        padding: 4px var(--vt-live-card-pad-x) 8px;
    }

    /*
     * Header uses horizontal padding only; summary/detail used margin-inline + padding, which shifted
     * subgrid columns vs the header. Drop horizontal margin on tablet so tracks align.
     */
    body.vt-layout #live-table .vt-live-entry-summary,
    body.vt-layout #live-table .vt-visit-detail,
    body.vt-layout #search-results .vt-live-entry-summary,
    body.vt-layout #search-results .vt-visit-detail {
        margin-inline: 0;
    }

    body.vt-layout #live-table .vt-live-feed-th--clinician,
    body.vt-layout #live-table .vt-live-feed-th--patient,
    body.vt-layout #live-table .vt-live-feed-th--date,
    body.vt-layout #live-table .vt-live-feed-th--duration {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.vt-layout #live-table .vt-live-entry-summary,
    body.vt-layout #search-results .vt-live-entry-summary {
        align-items: start;
    }

    body.vt-layout #live-table .vt-live-entry-summary .text-nowrap {
        white-space: normal;
    }

    body.vt-layout #live-table .vt-live-col-clinician,
    body.vt-layout #search-results .vt-live-col-clinician {
        line-height: 1.25;
    }

    body.vt-layout #live-table .vt-live-feed-header .vt-live-feed-th--clinician,
    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-clinician {
        padding-inline-end: 14px;
        box-sizing: border-box;
    }

    body.vt-layout #live-table .vt-live-col-clinician .vt-clinician-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Padding works inside the track; margin often has no visible effect with subgrid + card overflow. */
    body.vt-layout #live-table .vt-live-feed-header .vt-live-col-avatar,
    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-avatar,
    body.vt-layout #search-results .vt-live-feed-header .vt-live-col-avatar,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-avatar {
        padding-inline-end: 10px;
        box-sizing: border-box;
    }
}

/* Desktop (1080+): header uses padding only; margin-inline on rows shifted subgrid vs column headers (e.g. Patient). */
@media (min-width: 1080px) {
    body.vt-layout #live-table .vt-live-entry-summary,
    body.vt-layout #live-table .vt-visit-detail,
    body.vt-layout #search-results .vt-live-entry-summary,
    body.vt-layout #search-results .vt-visit-detail {
        margin-inline: 0;
    }
}

/*
 * Small screens only (phones): card list (not a wide table). Tablet/desktop unchanged (md+).
 */
@media (max-width: 767.98px) {
    body.vt-layout #live-table,
    body.vt-layout #search-results {
        min-width: 0;
        max-width: 100%;
    }

    body.vt-layout #live-table .vt-live-feed,
    body.vt-layout #search-results .vt-live-feed {
        --vt-live-col-gap: 10px;
        --vt-live-card-pad-x: 10px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        grid-template-columns: none;
        column-gap: normal;
        row-gap: normal;
        padding: 0 10px;
        width: 100%;
        min-width: 0;
        position: relative;
    }

    /* Live page only: more space between stacked visit cards on phones */
    body.vt-layout #live-table .vt-live-feed {
        gap: 20px;
    }

    /* Keep column headers for SR only (table headers redundant on stacked cards). */
    body.vt-layout #live-table .vt-live-feed-header,
    body.vt-layout #search-results .vt-live-feed-header {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
        grid-column: unset;
        display: block;
    }

    body.vt-layout #live-table .vt-live-entry,
    body.vt-layout #search-results .vt-live-entry {
        grid-column: auto;
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        column-gap: normal;
        row-gap: 0;
        width: 100%;
        min-width: 0;
    }

    /* Card summary: stacked grid (avatar | clinician | chevron, then patient, then date | duration). */
    body.vt-layout #live-table .vt-live-entry-summary,
    body.vt-layout #search-results .vt-live-entry-summary {
        grid-column: auto;
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "vtCardAvatar vtCardClin vtCardChev"
            "vtCardPatient vtCardPatient vtCardPatient"
            "vtCardDate vtCardDate vtCardDur";
        column-gap: var(--vt-live-col-gap);
        row-gap: 10px;
        align-items: start;
        justify-items: stretch;
        margin-inline: 0;
        padding: 12px var(--vt-live-card-pad-x);
        min-height: 44px;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-avatar,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-avatar {
        grid-area: vtCardAvatar;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-clinician,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-clinician {
        grid-area: vtCardClin;
        min-width: 0;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-chevron,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-chevron {
        grid-area: vtCardChev;
        align-self: start;
        padding-top: 2px;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-patient,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-patient {
        grid-area: vtCardPatient;
        min-width: 0;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-date,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-date {
        grid-area: vtCardDate;
        min-width: 0;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-duration,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-duration {
        grid-area: vtCardDur;
        justify-self: end;
        text-align: end;
        min-width: 0;
    }

    body.vt-layout #live-table .vt-live-entry-summary .text-nowrap,
    body.vt-layout #search-results .vt-live-entry-summary .text-nowrap {
        white-space: normal;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-mobile-field-label,
    body.vt-layout #search-results .vt-live-entry-summary .vt-mobile-field-label {
        display: block;
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--main-muted);
        margin-bottom: 2px;
        font-family: var(--vt-font-sans);
    }

    /* Tap detail rows: single column, hide empty grid placeholders. */
    body.vt-layout #live-table .vt-visit-detail,
    body.vt-layout #search-results .vt-visit-detail {
        grid-column: auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        grid-template-columns: none;
        column-gap: normal;
        margin-inline: 0;
        padding: 12px var(--vt-live-card-pad-x);
    }

    body.vt-layout #live-table .vt-visit-detail .vt-live-col-avatar,
    body.vt-layout #live-table .vt-visit-detail .vt-live-col-chevron,
    body.vt-layout #live-table .vt-visit-detail .vt-visit-detail-duration-spacer,
    body.vt-layout #search-results .vt-visit-detail .vt-live-col-avatar,
    body.vt-layout #search-results .vt-visit-detail .vt-live-col-chevron,
    body.vt-layout #search-results .vt-visit-detail .vt-visit-detail-duration-spacer {
        display: none !important;
    }

    body.vt-layout #live-table .vt-visit-detail .vt-visit-detail-kind,
    body.vt-layout #search-results .vt-visit-detail .vt-visit-detail-kind {
        margin-bottom: 2px;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col:not(.vt-live-col-avatar):not(.vt-live-col-chevron),
    body.vt-layout #live-table .vt-visit-detail .vt-live-col:not(.vt-live-col-avatar):not(.vt-live-col-chevron),
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col:not(.vt-live-col-avatar):not(.vt-live-col-chevron),
    body.vt-layout #search-results .vt-visit-detail .vt-live-col:not(.vt-live-col-avatar):not(.vt-live-col-chevron) {
        overflow-wrap: break-word;
    }

    /* Mobile: full name one line; title below on its own line (see .vt-clinician--mobile in live_table.html). */
    body.vt-layout #live-table .vt-clinician--mobile .vt-clinician-name-mobile,
    body.vt-layout #search-results .vt-clinician--mobile .vt-clinician-name-mobile {
        display: block;
        line-height: 1.25;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    body.vt-layout #live-table .vt-clinician--mobile .vt-clinician-title,
    body.vt-layout #search-results .vt-clinician--mobile .vt-clinician-title {
        display: block;
        margin-top: 0.2em;
        font-weight: 500;
        line-height: 1.2;
        white-space: nowrap;
        overflow-wrap: normal;
        word-break: normal;
    }

    @supports not (grid-template-columns: subgrid) {
        body.vt-layout #live-table .vt-live-feed,
        body.vt-layout #search-results .vt-live-feed {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        body.vt-layout #live-table .vt-live-feed {
            gap: 20px;
        }

        body.vt-layout #live-table .vt-live-entry,
        body.vt-layout #search-results .vt-live-entry {
            display: flex;
            flex-direction: column;
        }

        body.vt-layout #live-table .vt-live-entry-summary,
        body.vt-layout #search-results .vt-live-entry-summary {
            display: grid;
            grid-template-columns: auto 1fr auto;
            grid-template-areas:
                "vtCardAvatar vtCardClin vtCardChev"
                "vtCardPatient vtCardPatient vtCardPatient"
                "vtCardDate vtCardDate vtCardDur";
        }

        body.vt-layout #live-table .vt-visit-detail,
        body.vt-layout #search-results .vt-visit-detail {
            display: flex;
            flex-direction: column;
        }
    }
}

@media (max-width: 380px) {
    body.vt-layout #live-table .vt-live-feed,
    body.vt-layout #search-results .vt-live-feed {
        --vt-live-col-gap: 8px;
        --vt-live-card-pad-x: 8px;
        gap: 10px;
        padding: 0 8px;
    }

    body.vt-layout #live-table .vt-live-feed {
        gap: 16px;
    }

    body.vt-layout .vt-live-page-banner {
        margin-inline: 8px;
        padding: 10px 12px;
    }

    body.vt-layout #live-table .vt-live-entry-summary,
    body.vt-layout #search-results .vt-live-entry-summary {
        padding: 10px var(--vt-live-card-pad-x);
        row-gap: 8px;
        column-gap: var(--vt-live-col-gap);
    }

    body.vt-layout #live-table .vt-visit-detail,
    body.vt-layout #search-results .vt-visit-detail {
        padding: 10px var(--vt-live-card-pad-x);
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-mobile-field-label,
    body.vt-layout #search-results .vt-live-entry-summary .vt-mobile-field-label {
        font-size: 9px;
    }

    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-date,
    body.vt-layout #live-table .vt-live-entry-summary .vt-live-col-duration,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-date,
    body.vt-layout #search-results .vt-live-entry-summary .vt-live-col-duration {
        font-size: 0.8125rem;
    }

    body.vt-layout #live-table .vt-clinician--mobile .vt-clinician-title,
    body.vt-layout #search-results .vt-clinician--mobile .vt-clinician-title {
        font-size: 0.8125rem;
    }
}

body.vt-layout .content .form-select-caret {
    color: var(--main-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DESIGN SYSTEM – Phase 1 (legacy tokens for auth / Bootstrap overrides)
   Breakpoints: use min-width 360px, 480px, 768px, 1080px (mobile-first).
   ═══════════════════════════════════════════════════════════════════════════════ */
:root {
    /* Typography */
    --font-sans: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;

    /* Spacing (4px base) */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */

    /* Radius (--radius, --radius-sm from reference design above) */
    --radius-md: 0.375rem;  /* 6px */
    --radius-lg: 0.5rem;    /* 8px */
    --radius-xl: 0.75rem;   /* 12px */
    --radius-full: 9999px;

    /* Shadows (stronger for modern elevation) */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.15);

    /* Breakpoints (for reference; use in media: 360px, 480px, 768px, 1080px) */
    --bp-360: 360px;
    --bp-480: 480px;
    --bp-768: 768px;
    --bp-1080: 1080px;

    /* Content width (desktop) – main + flash area cap at this width when viewport is wider */
    --content-max-width: 1440px;

    /* Brand & shell */
    --vt-orange: #ff7043;
    --vt-orange-hover: #e64a19;
    --vt-orange-light: rgba(255, 112, 67, 0.12);
    --sidebar-bg: #1a1b2e;
    --sidebar-text: #a0a4b8;
    --sidebar-active-bg: rgba(99, 102, 241, 0.18);
    --sidebar-active-text: #a5b4fc;
    --sidebar-width: 260px;
    --content-bg: #f0f2f6;
}

/* Apply design-system font to body */
body {
    font-family: var(--font-sans);
    background: var(--content-bg);
}

/* Content column – distinct background so cards pop */
.app-content-wrap {
    background: var(--content-bg);
}

/* ── VT Brand Button – pill, bold ── */
.btn-vt {
    background-color: var(--vt-orange);
    border: none;
    color: #fff;
    border-radius: var(--radius-full);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.02em;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.btn-vt:hover, .btn-vt:focus {
    background-color: var(--vt-orange-hover);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 112, 67, 0.4);
}
.btn-vt.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
}

/* Inverse of btn-vt: white fill, orange text & ring (Search page Clear All) */
.btn-vt-outline {
    background-color: #fff;
    color: var(--vt-orange);
    border: 1px solid var(--vt-orange);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.02em;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.btn-vt-outline:hover,
.btn-vt-outline:focus {
    background-color: var(--vt-orange-light);
    color: var(--vt-orange-hover);
    border-color: var(--vt-orange-hover);
    transform: translateY(-1px);
}

/* Disabled VT button – grey outlined pill to indicate no changes */
.btn-vt:disabled,
.btn-vt.disabled {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: default;
    box-shadow: none;
    transform: none;
    opacity: 1;
}

/* Owner profile page – circular thumb */
.profile-image-thumb {
    aspect-ratio: 1;
    width: 160px;
    max-width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* Keep hit target / focus outline round when thumb is wrapped in a link */
a:has(> .profile-image-thumb) {
    display: inline-block;
    border-radius: 50%;
    overflow: hidden;
    line-height: 0;
    vertical-align: middle;
}

.profile-image-modal {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
}

.vt-link { color: var(--vt-orange); }
.vt-link:hover { color: var(--vt-orange-hover); }
.vt-text { color: var(--vt-orange); }

/* ── Sidebar – dark, modern ── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: var(--space-5) var(--space-4);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    /* Flex layout for scrollable nav */
    display: flex;
    flex-direction: column;
}

.sidebar hr { border-color: var(--sidebar-hr-line); }

.sidebar-brand span {
    color: #fff;
    font-size: var(--font-size-xl);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.sidebar-link {
    color: var(--sidebar-text) !important;
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff !important;
}

.sidebar-link.active {
    background-color: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
    border-left: 3px solid var(--accent-purple, #6366f1);
    padding-left: calc(var(--space-4) - 3px);
}

/* Sidebar submenus (nested items under primary links) */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

/* Match primary nav row spacing (icon — label — caret) */
.sidebar .nav-item.sidebar-toggle {
    justify-content: flex-start;
    gap: 10px;
}

.sidebar-caret {
    font-size: 0.7rem;
    opacity: 0.9;
}

.sidebar-submenu {
    display: block; /* override .nav flex layout so items stack */
    list-style: none;
    /* Vertical guide line under the main icon, slightly indented but still within sidebar width */
    border-left: 1px solid var(--sidebar-text);
    margin-left: var(--space-3);
    padding-left: var(--space-3);
    margin-top: 0.25rem;
    margin-bottom: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.sidebar-submenu.show {
    /* max-height is controlled via inline style from JS for smooth animation */
}

.sidebar-sublink {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    font-size: var(--font-size-xs);
    text-decoration: none;
    display: block;
    white-space: normal; /* allow wrapping for longer labels */
}

/* Sub-items: no hover background (only the main nav item has the “big” hover) */
.sidebar-submenu .sidebar-link,
.sidebar-submenu .sidebar-sublink {
    width: 100%;
    box-sizing: border-box;
}
.sidebar-submenu .sidebar-link:hover,
.sidebar-submenu .sidebar-sublink:hover {
    background-color: transparent !important;
    color: #fff !important;
}
/* Keep active purple when hovering over the selected sub-item */
.sidebar-submenu .sidebar-link.active:hover,
.sidebar-submenu .sidebar-sublink.active:hover {
    background-color: var(--sidebar-active-bg) !important;
    color: var(--sidebar-active-text) !important;
}

.sidebar-toggle.open {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Scrollable nav area - contains all nav items including Settings */
.sidebar .sidebar-nav {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px; /* Space for scrollbar */
}

/* Thin scrollbar for sidebar nav */
.sidebar .sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar .sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar .sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
.sidebar .sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Settings section header */
.sidebar .sidebar-settings-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text, rgba(255,255,255,0.5));
    padding: 16px 12px 8px;
    margin-top: 8px;
    border-top: 1px solid var(--sidebar-hr-line, rgba(255, 255, 255, 0.15));
}

/* Settings items - slightly indented */
.sidebar .sidebar-settings-item {
    padding-left: 16px;
}

/* Logout button */
.sidebar .sidebar-logout {
    margin-top: 16px;
    border-top: 1px solid var(--sidebar-hr-line, rgba(255, 255, 255, 0.15));
    padding-top: 12px;
}
.sidebar .sidebar-logout:hover,
.sidebar .sidebar-logout:focus {
    color: var(--accent-red, #ef4444) !important;
    background: rgba(239, 68, 68, 0.12) !important;
}

/* Floating particles in sidebar (PS5-style ambiance) */
.sidebar-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.sidebar-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
    filter: blur(0.5px);
    opacity: 0.7;
    animation-name: sidebarFloat;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

@keyframes sidebarFloat {
    0% {
        transform: translate3d(0, 0, 0);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    60% {
        opacity: 0.9;
    }
    100% {
        transform: translate3d(var(--tx, 0), var(--ty, -40px), 0);
        opacity: 0;
    }
}

/* Hide sidebar below 768px */
@media (max-width: 767.98px) {
    .sidebar { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PHASE 2 – Shell & layout responsive (360, 480, 768, 1080)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Mobile header (visible below 768px) – touch-friendly */
/* Fixed (not sticky): iOS Safari often clips or hides sticky headers inside overflow
   scrollers when the URL bar shows/hides; fixed + safe-area matches the visual viewport. */
.app-header-mobile {
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: var(--shadow-sm);
    min-height: 48px;
    padding-left: var(--space-3);
    padding-right: var(--space-3);
    padding-top: env(safe-area-inset-top, 0px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    isolation: isolate;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}
.app-header-mobile__menu {
    min-width: 52px;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    -webkit-appearance: none;
    appearance: none;
    background-color: #fff;
    color: #374151;
}
.app-header-mobile__menu .bi-list {
    font-size: 1.65rem;
    line-height: 1;
    color: inherit;
}
.app-header-mobile__brand {
    font-size: var(--font-size-lg);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--sidebar-bg);
}
.app-header-mobile__brand-logo {
    display: block;
    width: auto;
    max-width: none;
    height: 1.5rem;
    object-fit: contain;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
/* Reserve space under fixed mobile header (header is out-of-flow; only shows < md) */
@media (max-width: 767.98px) {
    body.vt-layout .main-inner {
        padding-top: calc(env(safe-area-inset-top, 0px) + 3.5rem);
    }
}

/* iOS Safari: 100vh vs visible viewport; -webkit-fill-available tracks the *small* viewport better */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 767.98px) {
        body.vt-layout .layout {
            height: -webkit-fill-available;
        }
    }
}

@media (min-width: 480px) {
    .app-header-mobile { min-height: 52px; padding-left: var(--space-4); padding-right: var(--space-4); }
    .app-header-mobile__brand { font-size: var(--font-size-xl); }
    .app-header-mobile__brand-logo {
        width: auto;
        max-width: none;
        height: 1.5rem;
    }
}

/* Offcanvas sidebar – same dark theme as desktop */
.offcanvas-sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    --bs-offcanvas-width: 50vw;
    max-width: 50vw;
}
.offcanvas-sidebar .sidebar-link.active {
    border-left: 3px solid var(--accent-purple, #6366f1);
    padding-left: calc(var(--space-4) - 3px);
}
.offcanvas-sidebar__header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    padding: var(--space-4);
}
.offcanvas-sidebar__header .offcanvas-title { color: #fff; font-weight: var(--font-weight-bold); }
.offcanvas-sidebar__logo {
    display: block;
    width: auto;
    max-width: 140px;
    height: 24px;
    object-fit: contain;
}
.offcanvas-sidebar__body {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}
/* Mobile drawer – agency block: label, Agency ID, email; name is white */
.offcanvas-sidebar__org-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.offcanvas-sidebar__org-name {
    color: #ffffff;
    font-size: 0.95rem;
}
.offcanvas-sidebar__org-id {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}
.offcanvas-sidebar__org-email {
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    line-height: 1.35;
    word-break: break-word;
}
/* Settings block title — same type specs and inset as “MY AGENCY” */
.offcanvas-sidebar .offcanvas-sidebar__nav-heading {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.offcanvas-sidebar__settings-heading {
    padding-left: 0;
    padding-right: 0;
}
.offcanvas-sidebar__hr { border-color: var(--sidebar-hr-line); }
/* Match gap from drawer header rule → “MY AGENCY” (same as .offcanvas-sidebar__body padding-top) */
.offcanvas-sidebar__hr--org {
    margin: var(--space-4) 0 0;
    border-top-color: var(--sidebar-hr-line);
}
/* Mobile drawer: text-only nav (no leading icons) */
.offcanvas-sidebar .sidebar-link > i.bi {
    display: none !important;
}
/* Live row: stroke SVG (same three-wave icon as desktop sidebar) */
.offcanvas-sidebar .sidebar-link .nav-icon {
    width: 16px;
    height: 16px;
    color: #ffffff;
}
/* Mobile drawer: nav links read as white (overrides global .sidebar-link gray) */
.offcanvas-sidebar .sidebar-link,
.offcanvas-sidebar .sidebar-link:hover,
.offcanvas-sidebar .sidebar-link:focus,
.offcanvas-sidebar .sidebar-link.active {
    color: #ffffff !important;
}
.offcanvas-sidebar .sidebar-link.text-danger {
    color: #ffffff !important;
}
.offcanvas-sidebar .sidebar-link.text-danger:hover,
.offcanvas-sidebar .sidebar-link.text-danger:focus {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.06) !important;
}

/* Flash area – responsive padding; alerts rounded */
.flash-area {
    padding: var(--space-3);
}
.flash-area .alert {
    border-radius: var(--radius-lg);
    border: none;
}
@media (min-width: 480px) {
    .flash-area { padding: var(--space-3) var(--space-4); }
}
@media (min-width: 768px) {
    .flash-area { padding: var(--space-4); }
}
@media (min-width: 1080px) {
    .flash-area {
        padding: var(--space-4) var(--space-6);
        max-width: var(--content-max-width);
        margin-left: auto;
        margin-right: auto;
    }
}

/* Main content – fill container so max-width can apply; padding and max-width by breakpoint */
.app-main {
    padding: var(--space-3);
    width: 100%;
    min-width: 0; /* allow flex child to shrink so it can respect max-width */
    box-sizing: border-box;
}
@media (min-width: 360px) {
    .app-main { padding: var(--space-4); }
}
@media (min-width: 480px) {
    .app-main { padding: var(--space-4); }
}
@media (min-width: 768px) {
    .app-main { padding: var(--space-4) var(--space-5); }
}
@media (min-width: 1080px) {
    .app-main {
        padding: var(--space-5) var(--space-6);
        max-width: var(--content-max-width);
        margin-left: auto;
        margin-right: auto;
    }
}

/* ── Avatar Circles ── */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.avatar-circle.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.7rem;
}

/* Avatar circle images (staff photos) */
img.avatar-circle {
    object-fit: cover;
    background-color: var(--vt-avatar-client-bg, #6c757d);
}

img.avatar-circle.avatar-sm {
    width: 32px;
    height: 32px;
}

/* ── HTMX loading indicator ── */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

/* View All Connected — search + last-name sort (upper-right toolbar) */
.staff-view-all-toolbar {
    flex: 1 1 auto;
    max-width: 100%;
    justify-content: flex-end;
}
@media (min-width: 768px) {
    .staff-view-all-toolbar {
        flex: 0 0 auto;
        max-width: none;
    }
}
.staff-search-field-wrap {
    position: relative;
    flex: 0 1 auto;
    min-width: min(14rem, 100%);
    max-width: 20rem;
}
.staff-search-field-wrap .staff-search-input {
    padding-right: 2.25rem;
    min-width: 0;
    width: 100%;
}
.staff-search-clear {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm, 0.375rem);
    background: transparent;
    color: var(--main-muted, #6b7280);
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.staff-search-clear:hover {
    color: var(--main-heading, #1f2937);
    background: rgba(0, 0, 0, 0.06);
}
.staff-search-field-wrap:not(.staff-search-field-wrap--has-value) .staff-search-clear {
    opacity: 0.35;
    pointer-events: none;
}

/* Separator under Connect Staff page title (replaces nav-tabs bottom edge) */
.staff-page-head-rule {
    border: 0;
    border-top: 1px solid #0a0a0a;
    margin: 0 0 1rem 0;
    opacity: 1;
}

/* View All Connected: breathing room between rows */
#staff-list .staff-list-view-all.list-group {
    gap: 0.75rem;
}
#staff-list .staff-list-view-all .list-group-item {
    border-radius: var(--radius-lg, 0.5rem);
    /* Full frame on every row: Bootstrap clears border-top on + .list-group-item, which hides the top edge when using gap */
    border: 1px solid var(--main-border, rgba(15, 23, 42, 0.14));
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.05),
        0 2px 8px rgba(15, 23, 42, 0.06);
}

#staff-list .staff-list-view-all .list-group-item + .list-group-item {
    /* Defeat Bootstrap’s collapsed top border between stacked items */
    border-top: 1px solid var(--main-border, rgba(15, 23, 42, 0.14));
    margin-top: 0;
}

/* View All Connected row: avatar + name (left), Active centered in flexible middle, Remove right */
.staff-row-view-all {
    display: flex;
    align-items: center;
    gap: 0.75rem 1rem;
    width: 100%;
    min-width: 0;
}
.staff-row-view-all__leading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 0 1 auto;
    min-width: 0;
}
.staff-row-view-all__info {
    min-width: 0;
    flex: 1 1 auto;
}
/* Employee + Supervisor: one row from md up; stacked on small phones */
.staff-row-view-all__roles {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.25rem;
}
.staff-row-view-all__status {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 3.5rem;
}
.staff-row-view-all__remove {
    flex: 0 0 auto;
}
.staff-visit-status {
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.staff-visit-status--active {
    color: var(--bs-success, #198754);
}
.staff-visit-status--inactive {
    color: var(--bs-secondary-color, #6c757d);
}

@media (max-width: 767.98px) {
    .staff-row-view-all {
        gap: 0.5rem 0.65rem;
    }
    .staff-row-view-all__status {
        min-width: 0;
    }
    .staff-row-view-all__roles {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
}

/* View All Connected: Remove — global `.btn { border: none }` strips outline buttons; restore visible red frame */
#staff-list .staff-list-view-all .btn.staff-remove-open {
    flex-shrink: 0;
    align-self: center;
    background-color: #fff;
    color: var(--bs-danger);
    border: 1px solid var(--bs-danger) !important;
    box-shadow: none;
}
#staff-list .staff-list-view-all .btn.staff-remove-open:hover,
#staff-list .staff-list-view-all .btn.staff-remove-open:focus-visible {
    background-color: var(--bs-danger);
    color: #fff !important;
    border: 1px solid var(--bs-danger) !important;
    box-shadow: none;
}
#staff-list .staff-list-view-all .btn.staff-remove-open:active {
    background-color: #b02a37;
    color: #fff !important;
    border: 1px solid #b02a37 !important;
}

/* Staff list loading spinner – overlay on top of list without shifting layout */
#staff-list-wrapper {
    position: relative;
    min-height: 80px; /* keeps a bit of space when list is empty/loading */
}

#staff-spinner {
    position: absolute;
    inset: 0;
    display: none; /* will be shown when it has .htmx-request */
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none; /* don't block clicks when visible */
}

#staff-spinner.htmx-request {
    display: flex;
}

/* ── Card Plan Border ── */
.card.border-warning {
    border-color: var(--vt-orange) !important;
}

/* ── Smooth page transitions ── */
main {
    animation: fadeIn 0.15s ease-in;
}
@keyframes fadeIn {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PHASE 3 – Page-level styling (cards, forms, buttons, modals, auth)
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Cards – strong elevation, very rounded */
.app-main .card,
.card {
    border-radius: 1rem;
    border: none;
    box-shadow: var(--shadow-md);
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.app-main .card:hover,
.card:hover {
    box-shadow: var(--shadow-lg);
}
.app-main .card-body,
.card-body {
    padding: var(--space-6);
}
@media (min-width: 768px) {
    .app-main .card-body,
    .card-body {
        padding: var(--space-8);
    }
}

/* Form controls – larger, rounded, clear focus (no white fields) */
.form-control,
.form-select {
    font-size: var(--font-size-base);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: var(--space-3) var(--space-4);
    min-height: 3rem;
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--vt-orange);
    box-shadow: 0 0 0 3px var(--vt-orange-light);
    outline: none;
}
.form-control::placeholder {
    color: #9ca3af;
}
.form-label,
.app-main .form-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: rgba(0, 0, 0, 0.75);
    margin-bottom: var(--space-1);
}
.form-label.small.text-muted {
    font-weight: var(--font-weight-normal);
    color: var(--bs-secondary-color);
}
.input-group .form-control:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}
.input-group .btn:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

/* Picker caret for select (e.g. Business Type) */
.form-select-caret {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 0.875rem;
    color: var(--text-muted, #6b7280);
}
body.vt-dark .form-select-caret {
    color: var(--text-secondary);
}
.form-select-has-caret {
    padding-right: 2rem;
    appearance: none;
    background-image: none;
}

/* Secondary / outline buttons */
.btn-outline-secondary {
    border-radius: var(--radius-lg);
    font-weight: var(--font-weight-medium);
}
.btn-secondary {
    border-radius: var(--radius-lg);
    font-weight: var(--font-weight-medium);
}

/* Dashboard page headings – larger, tighter tracking */
.app-main h4 {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-5);
    color: #111;
}
.app-main h5 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-4);
    color: #1a1a1a;
}
.app-main h6 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: #333;
}

/* Nav pills – full pill shape, bold active */
.nav-pills .nav-link {
    color: #64748b;
    font-size: var(--font-size-sm);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-5);
    font-weight: var(--font-weight-medium);
    transition: background-color 0.2s ease, color 0.2s ease;
}
.nav-pills .nav-link:hover {
    color: #334155;
    background-color: rgba(0, 0, 0, 0.05);
}
.nav-pills .nav-link.active {
    background-color: var(--vt-orange);
    color: #fff;
    font-weight: var(--font-weight-semibold);
}

/* Auth pages – dark theme, no white */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    padding: var(--space-4);
}
.auth-page--login {
    background: #ffffff;
}
.auth-page--login .auth-card {
    background: #f3f4f6;
    border-color: #d1d5db;
    border-top: 6px solid var(--accent-purple);
    box-shadow: inset 0 6px 0 0 var(--accent-purple), 0 18px 40px rgba(15, 23, 42, 0.18);
}
.auth-page--login .auth-card .card-body {
    background: #f3f4f6;
    color: #1f2937;
}
.auth-page--login .auth-card .form-control {
    background: #ffffff;
    border-color: #9ca3af;
    border-width: 1px;
    border-style: solid;
    color: #111111;
}
.auth-page--login .auth-card .form-control::placeholder {
    color: #6b7280;
}
.auth-page--login .auth-card .form-control:focus {
    background: #ffffff;
    border-color: var(--accent-purple);
    color: #111111;
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.28);
}
.auth-page--login .auth-card .btn-outline-secondary {
    background: #ffffff;
    border-color: #9ca3af;
    border-width: 1px;
    border-style: solid;
    color: #111111;
}
.auth-page--login .auth-card .btn-outline-secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #111111;
}
.auth-page--login .auth-card .input-group > .btn-outline-secondary,
.auth-page--login .auth-card .input-group > .btn-outline-secondary:focus,
.auth-page--login .auth-card .input-group > .btn-outline-secondary:hover,
.auth-page--login .auth-card .input-group > .btn-outline-secondary:active {
    border-top-right-radius: var(--radius-lg) !important;
    border-bottom-right-radius: var(--radius-lg) !important;
}
.auth-page--login .auth-card .auth-card__subtitle,
.auth-page--login .auth-card .small.text-muted,
.auth-page--login .auth-card .text-muted {
    color: #6b7280 !important;
}
/* Login page on mobile: prevent page bounce/scroll behind centered card */
body.auth-login-page {
    height: 100dvh;
    overflow: hidden;
}
body.auth-login-page .auth-page--login {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
}
.auth-page:not(.auth-page--login)::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(ellipse 60% 50% at 20% 90%, rgba(224,48,48,0.06) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at 80% 10%, rgba(59,130,246,0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.auth-page .card {
    position: relative;
    z-index: 1;
}
@media (min-width: 360px) {
    .auth-page { padding: var(--space-5); }
}
@media (min-width: 480px) {
    .auth-page { padding: var(--space-8); }
}
.auth-card {
    width: 100%;
    max-width: 400px;
    border-radius: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: none;
    overflow: hidden;
    background: var(--bg-elevated);
    border-top: 4px solid var(--accent-purple);
}
.auth-card.auth-card--wide {
    max-width: 420px;
}
.auth-card .card-body {
    padding: var(--space-6);
}
@media (min-width: 480px) {
    .auth-card .card-body {
        padding: var(--space-8);
    }
}
.auth-card .auth-card__logo {
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: auto;
    max-width: 200px;
    height: auto;
    object-fit: contain;
}
.auth-card .auth-card__title {
    font-size: var(--font-size-2xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.auth-card .auth-card__subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}
.auth-card .auth-card__back {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}
.auth-card .auth-card__back:hover {
    color: var(--accent-red);
}
/* Auth form controls – dark inputs and labels */
.auth-card .form-control {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-primary);
}
.auth-card .form-control::placeholder {
    color: var(--text-muted);
}
.auth-card .form-control:focus {
    background: var(--bg-surface);
    border-color: var(--accent-red);
    color: var(--text-primary);
}
.auth-card .form-label,
.auth-card .alert {
    color: var(--text-secondary);
}
.auth-card .alert-danger {
    background: rgba(224, 48, 48, 0.15);
    border-color: rgba(224, 48, 48, 0.3);
    color: #f87171;
}
.auth-card .alert-success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}
.auth-card .text-muted {
    color: var(--text-muted);
}
.auth-card .vt-link {
    color: var(--accent-red);
}
.auth-card .vt-link:hover {
    color: #f87171;
}
.auth-card .btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-secondary);
}
.auth-card .btn-outline-secondary:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

/* Modals – rounded, strong shadow */
.modal-content {
    border-radius: 1.25rem;
    border: none;
    box-shadow: var(--shadow-xl);
}
.modal-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-weight: var(--font-weight-bold);
}
.modal-body {
    padding: var(--space-6);
}
.modal-footer {
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
@media (max-width: 479.98px) {
    .modal-dialog {
        margin: var(--space-3);
        max-width: calc(100% - var(--space-6));
    }
}

/* Modals in dark theme (layout and auth pages) – no white, readable text */
body.vt-dark .modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
body.vt-dark .modal-header {
    border-bottom-color: var(--border);
}
body.vt-dark .modal-title {
    color: var(--text-primary);
    font-weight: 700;
}
body.vt-dark .modal-body {
    color: var(--text-secondary);
}
body.vt-dark .modal-body p {
    color: var(--text-primary);
}
body.vt-dark .modal-footer {
    border-top-color: var(--border);
}
body.vt-dark .modal .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.8;
}
body.vt-dark .modal .btn-close:hover {
    opacity: 1;
}
body.vt-dark .modal .btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-primary);
}
body.vt-dark .modal .btn-outline-secondary:hover {
    background: var(--bg-glass);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}
body.vt-dark .modal .btn-primary {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: #fff;
}
body.vt-dark .modal .btn-primary:hover {
    background: #c52828;
    border-color: #c52828;
    color: #fff;
}

body.vt-layout .modal-content {
    background: var(--main-bg);
    border: 1px solid var(--main-border);
    color: var(--main-text);
}
body.vt-layout .modal-header {
    border-bottom-color: var(--main-border);
}
body.vt-layout .modal-title {
    color: var(--main-heading);
    font-weight: 700;
}
body.vt-layout .modal-body {
    color: var(--main-text);
}
body.vt-layout .modal-body p {
    color: var(--main-text);
}
body.vt-layout .modal-footer {
    border-top-color: var(--main-border);
}
body.vt-layout .modal .btn-close {
    filter: none;
    opacity: 0.7;
}
body.vt-layout .modal .btn-close:hover {
    opacity: 1;
}
body.vt-layout .modal .btn-outline-secondary {
    border-color: var(--main-border);
    color: var(--main-heading);
}
body.vt-layout .modal .btn-outline-secondary:hover {
    background: var(--main-surface);
    border-color: #d1d5db;
    color: var(--main-heading);
}

/* Logout confirm — narrow dialog, extra vertical space, no rules between body/footer */
#logoutConfirmModal .modal-dialog--logout-confirm {
    max-width: 20rem;
    width: calc(100% - 2rem);
    margin-left: auto;
    margin-right: auto;
}
#logoutConfirmModal .logout-confirm-modal__body {
    border: none !important;
    padding: 2.75rem 1.75rem 1.5rem;
    min-height: 9.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
#logoutConfirmModal .logout-confirm-modal__footer {
    border: none !important;
    border-top: none !important;
    padding: 0 1.75rem 2.25rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   PHASE 4 – Tables, lists, and small-screen behavior
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Data tables – dark theme when in app */
body.vt-dark .app-main .table-modern-wrapper,
body.vt-dark .table-modern-wrapper {
    border-radius: 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: none;
    max-width: 100%;
    overflow-x: auto;
}
body.vt-dark .app-main .table-modern-wrapper .table,
body.vt-dark .table-modern-wrapper .table {
    margin-bottom: 0;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}
body.vt-dark .app-main .table-modern-wrapper thead th,
body.vt-dark .table-modern-wrapper thead th {
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: var(--font-weight-semibold);
    background: var(--bg-surface);
    white-space: nowrap;
}
body.vt-dark .app-main .table-modern-wrapper tbody td,
body.vt-dark .table-modern-wrapper tbody td {
    border-top: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
body.vt-dark .app-main .table-modern-wrapper tbody tr:last-child td,
body.vt-dark .table-modern-wrapper tbody tr:last-child td {
    border-bottom: none;
}

/* Live / HTMX tables — match light main column when dashboard layout is active */
body.vt-dark.vt-layout .table-modern-wrapper,
body.vt-dark.vt-layout .app-main .table-modern-wrapper {
    background: var(--main-bg);
    border: 1px solid var(--main-border);
}
body.vt-dark.vt-layout .table-modern-wrapper .table,
body.vt-dark.vt-layout .app-main .table-modern-wrapper .table {
    color: var(--main-text);
}
body.vt-dark.vt-layout .table-modern-wrapper thead th,
body.vt-dark.vt-layout .app-main .table-modern-wrapper thead th {
    background: var(--main-surface);
    border-bottom: 1px solid var(--main-border);
    color: var(--main-muted);
}
body.vt-dark.vt-layout .table-modern-wrapper tbody td,
body.vt-dark.vt-layout .app-main .table-modern-wrapper tbody td {
    border-bottom: 1px solid var(--main-border);
    color: var(--main-text);
}

@media (max-width: 480px) {
    .app-main .table-modern-wrapper .table > :not(caption) > * > * {
        padding: var(--space-2) var(--space-3);
    }
    .app-main .table-modern-wrapper .table {
        font-size: var(--font-size-xs);
    }
}

/* List groups (e.g. Connect Staff) – dark theme */
body.vt-dark .list-group {
    background: transparent;
}
body.vt-dark .list-group-item {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-primary);
}

/* Staff list items – dark theme */
body.vt-dark .staff-list-item {
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: none;
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    background: var(--bg-elevated);
    color: var(--text-primary);
}

body.vt-dark.vt-layout .list-group-item {
    background: var(--main-bg);
    border-color: var(--main-border);
    color: var(--main-text);
}

body.vt-dark.vt-layout .staff-list-item {
    background: var(--main-bg);
    border: 1px solid var(--main-border);
    color: var(--main-text);
}

.staff-list-item > .d-flex {
    gap: var(--space-4);
}

@media (max-width: 480px) {
    .staff-list-item > .d-flex {
        flex-direction: column;
        align-items: flex-start;
    }
    .staff-list-item .avatar-circle {
        margin-bottom: var(--space-2);
    }
    .staff-list-item .d-flex.gap-1 {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        row-gap: var(--space-2);
    }
}

/* Search form – comfortable layout on small phones */
.search-form .form-control.form-control-sm {
    font-size: var(--font-size-sm);
}

/* Search page: clearly darker outlines on client, employee, and date fields */
body.vt-layout .content .search-form #search-client-name,
body.vt-layout .content .search-form input[name="employeeName"],
body.vt-layout .content .search-form input.search-date-input {
    border-color: #64748b;
}
body.vt-layout .content .search-form #search-client-name:focus,
body.vt-layout .content .search-form input[name="employeeName"]:focus,
body.vt-layout .content .search-form input.search-date-input:focus {
    border-color: #475569;
    box-shadow: 0 0 0 0.2rem rgba(71, 85, 105, 0.28);
}

/* View All Connected: darker “search by name” field (same weight as search page) */
body.vt-layout .content .staff-search-field-wrap .staff-search-input,
body.vt-layout .content #staff-search-q {
    border-color: #64748b;
}
body.vt-layout .content .staff-search-field-wrap .staff-search-input:focus,
body.vt-layout .content #staff-search-q:focus {
    border-color: #475569;
    box-shadow: 0 0 0 0.2rem rgba(71, 85, 105, 0.28);
}

body.vt-layout .content .staff-search-clear {
    color: #475569;
}
body.vt-layout .content .staff-search-clear:hover {
    color: #1e293b;
    background: rgba(15, 23, 42, 0.08);
}

/* Public profile: darker borders on all form fields in the card */
body.vt-layout .content #profile-form .form-control {
    border-color: #64748b;
}
body.vt-layout .content #profile-form .form-control:focus {
    border-color: #475569;
    box-shadow: 0 0 0 0.2rem rgba(71, 85, 105, 0.28);
}

/* Account settings: read-only agency fields (white fill, muted text) */
body.vt-layout .content #account-settings-fields .form-control[readonly] {
    background-color: #fff;
    color: #94a3b8;
    border-color: #e5e7eb;
    cursor: default;
    -webkit-text-fill-color: #94a3b8;
}
body.vt-layout .content #account-settings-fields .form-control[readonly]::placeholder {
    color: #cbd5e1;
    opacity: 1;
}
body.vt-layout .content #account-settings-fields .form-control[readonly]:focus {
    border-color: #e5e7eb;
    box-shadow: none;
    color: #94a3b8;
    -webkit-text-fill-color: #94a3b8;
}
body.vt-layout .content .account-settings-disclaimer a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
body.vt-layout .content .account-settings-disclaimer a:hover {
    color: var(--bs-link-hover-color, #0a58ca);
}

/* Search: date row full width of form (shares row with actions); inputs grow to use space */
.search-form .search-date-range {
    flex-wrap: nowrap;
    gap: 0.35rem;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}
.search-form .search-date-input {
    box-sizing: border-box;
    text-align: center;
    flex: 1 1 9.75rem;
    min-width: 9.75rem;
    width: auto;
    max-width: 14rem;
}
.search-form .search-date-input::-webkit-datetime-edit {
    text-align: center;
}
.search-form .search-date-input::-webkit-datetime-edit-fields-wrapper {
    text-align: center;
    justify-content: center;
}
.search-form .search-date-to {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--main-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Mobile: fixed min-widths + gap overflow the field row; allow equal flex shrink so both stay fully visible */
@media (max-width: 767.98px) {
    .search-form .search-date-range {
        gap: 0.2rem;
        overflow-x: visible;
    }
    .search-form .search-date-input {
        flex: 1 1 0;
        min-width: 0;
        max-width: 100%;
        font-size: 0.8125rem;
    }
    .search-form .search-date-to {
        font-size: 0.65rem;
        letter-spacing: 0.04em;
    }
}

/* Search / Clear: action column */
.search-form .search-form-actions .btn {
    white-space: nowrap;
}

/* Small phones: tighter date row + stacked form columns */
@media (max-width: 480px) {
    .search-form .search-date-range {
        gap: 0.1rem;
    }
    .search-form .search-date-input {
        font-size: 0.75rem;
    }
    .search-form .row > [class*="col-"],
    .search-form .row > [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}
