/* style_essence.css: light theme foundation, layout, typography, and components. */

/* ==========================================================================
   SECTION 1: THEME & VARIABLES
   ========================================================================== */

:root {
    /* Safe Area Insets */
    --sat: env(safe-area-inset-top);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
    --sar: env(safe-area-inset-right);

    /* Brand Colors (Nature's Vibration Theme) */
    --primary-color: #97B881;
    /* Sage Green */
    --primary-dark: #7da066;
    /* Deep Sage */
    --primary-light: #f0f7ec;
    /* Soft Sage Tint */
    --primary-50: #f7f9f5;
    --primary-100: #edf2ea;

    --secondary-color: #E88D78;
    /* Coral */
    --secondary-dark: #d67560;
    /* Deep Coral */
    --secondary-light: #fdf2f0;
    /* Soft Coral Tint */
    --secondary-50: #fff9f8;
    --secondary-100: #fef2f0;

    --ocean: #8FB8CA;
    --ocean-dark: #6D94A6;
    --ocean-light: #E8F3F8;

    --sun: #ECD489;
    --sun-dark: #C5AF6B;
    --sun-light: #FBF7E6;

    /* Neutral Tones */
    --text-primary: #1f2937;
    /* Gray 800 */
    --text-secondary: #4b5563;
    /* Gray 600 */
    --text-muted: #9ca3af;
    /* Gray 400 */

    --bg-body: #fafcf9;
    /* Off-white Body */
    --bg-card: #ffffff;
    /* Pure White Card */
    --border-color: #f1f5f9;
    /* Gray 100 */
    --border-strong: #e2e8f0;
    /* Gray 200 */

    /* Backdrop Overlay (no blur — GPU performance) */
    --backdrop-light: rgba(15, 20, 25, 0.52);

    /* SaaS Spacing System (8px rhythm) */
    --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 */

    /* Layered Elevation System (Shadows) - Premium SaaS */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.05), 0 1px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 24px -4px rgba(0, 0, 0, 0.08), 0 4px 10px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px -6px rgba(0, 0, 0, 0.1), 0 8px 16px -6px rgba(0, 0, 0, 0.05);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);

    /* Dynamic Chart Settings */
    --table-font-size: 15px;

    /* Typography Scale - Visual Hierarchy */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Label Hierarchy */
    --label-size: 0.7rem;
    --label-weight: 700;
    --label-color: #9ca3af;
    --label-tracking: 0.05em;

    /* Data Value Hierarchy */
    --data-size: 1rem;
    --data-weight: 700;
    --data-color: #1f2937;

    /* Fonts */
    --font-body: "Poppins", sans-serif;
    --font-heading: "Quicksand", sans-serif;

    /* Transitions - Premium SaaS (Snappier, softer finish) */
    --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-base: 250ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   SECTION 2: GLOBAL RESETS & BASE STYLES
   ========================================================================== */

/* Disable all transitions during dark/light mode toggle to prevent repaint
   storms caused by `transition: all` on broad selectors. The .theme-transitioning
   class is added to <html> for exactly one frame during ThemeManager.toggle(). */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
}

/* Light/Dark cross-fade (View Transitions API, see ThemeManager.toggle). */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 380ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
    mix-blend-mode: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(151, 184, 129, 0.04) 0%, transparent 25%),
        radial-gradient(circle at 100% 100%, rgba(232, 141, 120, 0.03) 0%, transparent 25%);
    background-attachment: fixed;
    background-repeat: no-repeat;
}

@supports (height: 100dvh) {
    body {
        height: 100dvh;
    }
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
}

/* Global Scrollbar - Premium Minimalist */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: #f3f4f6;
}
::-webkit-scrollbar-thumb {
    background-color: #97B881;
    border-radius: 8px;
    border: 2px solid #f3f4f6;
}
::-webkit-scrollbar-thumb:hover {
    background-color: #7da066;
}
* {
    scrollbar-width: thin;
    scrollbar-color: #97B881 #f3f4f6;
}

/* Custom Inner Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #97B881;
    border-radius: 6px;
    border: 1px solid white;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #7da066;
}

/* Horizontal Scrollbar for Tables */
::-webkit-scrollbar-track.horizontal {
    background: #f3f4f6;
}
::-webkit-scrollbar-thumb.horizontal {
    background-color: #E88D78;
    border-radius: 6px;
}
::-webkit-scrollbar-thumb.horizontal:hover {
    background-color: #d67560;
}

/* Premium Focus States - Visual Hierarchy Enhancement */
input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.20), var(--shadow-sm);
    border-color: var(--primary-color) !important;
    transform: translateY(-1px);
    outline: none;
}

/* Clear Focus Ring for Keyboard Navigation - Idea 7 */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* Enhanced Focus for Interactive Elements */
button:focus-visible,
[role="button"]:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(151, 184, 129, 0.25);
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* Interactive Element Transitions - P1-C: explicit props (was transition:all) */
button,
a,
.nav-item,
.clickable {
    transition: transform var(--transition-fast), opacity var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

button:active {
    transform: none;
}

/* ==========================================================================
   SECTION 2A: VISUAL HIERARCHY ENHANCEMENTS (IDEA 6 - Label Styling)
   ========================================================================== */

/* Consistent Label Hierarchy - Muted text for labels, bold for data */
.form-label {
    display: block;
    font-size: var(--label-size);
    font-weight: var(--label-weight);
    color: var(--label-color);
    text-transform: uppercase;
    letter-spacing: var(--label-tracking);
    margin-bottom: 0.25rem;
}

/* Section Headers - Clear hierarchy */
.section-header {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-header i {
    color: var(--primary-color);
    width: 18px;
    height: 18px;
}

/* Card Header Styling - Information Density (Idea 8) */
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* Data Value Styling - Bold values with muted labels */
.data-value {
    font-size: var(--data-size);
    font-weight: var(--data-weight);
    color: var(--data-color);
    line-height: 1.3;
}

.data-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.125rem;
}

/* Icon Sizing Standardization - Idea 9 */
.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-base {
    width: 20px;
    height: 20px;
}

.icon-lg {
    width: 24px;
    height: 24px;
}

.icon-xl {
    width: 32px;
    height: 32px;
}

/* Spacing Rhythm - Idea 3 (8px base unit) */
.space-rhythm-1 { padding: 0.25rem; }
.space-rhythm-2 { padding: 0.5rem; }
.space-rhythm-3 { padding: 0.75rem; }
.space-rhythm-4 { padding: 1rem; }
.space-rhythm-5 { padding: 1.25rem; }
.space-rhythm-6 { padding: 1.5rem; }
.space-rhythm-8 { padding: 2rem; }

.gap-rhythm-1 { gap: 0.25rem; }
.gap-rhythm-2 { gap: 0.5rem; }
.gap-rhythm-3 { gap: 0.75rem; }
.gap-rhythm-4 { gap: 1rem; }
.gap-rhythm-6 { gap: 1.5rem; }
.gap-rhythm-8 { gap: 2rem; }

/* ==========================================================================
   SECTION 2B: COLOR WEIGHT DISTRIBUTION (IDEA 2)
   ========================================================================== */

/* Primary Actions - Sage (Modern Flat 2.0) */
.btn-primary {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border: 1px solid #84a86d;
    box-shadow: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: #72945c;
    box-shadow: none;
    transform: none;
}

.btn-primary:active {
    background-color: #6f9059;
}

/* Secondary Actions - Coral Accent (Modern Flat 2.0) */
.btn-accent {
    background-color: var(--secondary-color);
    color: white;
    font-weight: 600;
    border: 1px solid #df7d66;
    box-shadow: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.btn-accent:hover {
    background-color: var(--secondary-dark);
    border-color: #c46450;
    box-shadow: none;
    transform: none;
}

.btn-accent:active {
    background-color: #be5f4b;
}

/* Ghost Buttons - Muted (Modern Flat 2.0) */
.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
    font-weight: 500;
    box-shadow: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.btn-ghost:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-dark);
    box-shadow: none;
    transform: none;
}

/* Background Hierarchy */
.bg-primary-surface {
    background-color: var(--primary-light);
    border: 1px solid rgba(151, 184, 129, 0.2);
}

.bg-secondary-surface {
    background-color: var(--secondary-light);
    border: 1px solid rgba(232, 141, 120, 0.2);
}

.bg-neutral-surface {
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
}

/* Text Hierarchy */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--primary-color); }
.text-highlight { color: var(--secondary-color); }

/* Card Elevation - Idea 4 */
.elevation-1 {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
}

.elevation-2 {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.elevation-3 {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

/* Divider Lines - Idea 5 */
.divider-light {
    height: 1px;
    background-color: #f1f5f9;
    margin: 1rem 0;
}

.divider-medium {
    height: 1px;
    background-color: #e2e8f0;
    margin: 1.5rem 0;
}

.divider-section {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-strong), transparent);
    margin: 2rem 0;
}

/* Mobile Touch Targets - Idea 10 (44px minimum) */
.min-h-touch {
    min-height: 44px;
}

.min-w-touch {
    min-width: 44px;
}

.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced Touch Target for Small Buttons */
.btn-touch {
    min-height: 44px;
    padding: 0.625rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Ensure all interactive elements have adequate touch targets */
@media (pointer: coarse) {
    button:not([class*="w-"]):not([style*="width"]) {
        min-height: 44px;
    }
    
    a.nav-item {
        min-height: 48px;
    }
}

/* SaaS Utility Classes */
.glass-panel {
    background-color: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.elevation-low {
    box-shadow: var(--shadow-sm);
}

.elevation-md {
    box-shadow: var(--shadow-md);
}

.elevation-high {
    box-shadow: var(--shadow-lg);
}

.rounded-saas {
    border-radius: 1rem;
}

.rounded-saas-lg {
    border-radius: 1.5rem;
}

.text-gradient-sage {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bg-soft-sage {
    background-color: var(--primary-50);
}

.bg-soft-coral {
    background-color: var(--secondary-50);
}

/* Section Transitions - P1-C: tuned contain-intrinsic-size (was 1000px) */
.tab-content {
    /* Animations are now applied dynamically via JS on tab switch */
    content-visibility: auto;
    contain-intrinsic-size: 600px;
}

/* ==========================================================================
   SECTION 3: ESSENCE CHART TABLE STYLING
   ========================================================================== */

.table-container {
  overflow-x: auto;
  scroll-behavior: smooth;
  border-radius: 0 0 0.75rem 0.75rem;
}

/* Thicker Horizontal Scrollbar for Tables - Sage Brand Color */
.table-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.table-container::-webkit-scrollbar-track {
    background: #f0f7ec;
    border-radius: 4px;
}
.table-container::-webkit-scrollbar-thumb {
    background-color: #97B881;
    border-radius: 6px;
    border: 2px solid #f0f7ec;
}
.table-container::-webkit-scrollbar-thumb:hover {
    background-color: #7da066;
}

#resultsTable {
  border-spacing: 0;
  width: 100%;
}

#resultsTable th:not(:first-child),
#resultsTable td:not(:first-child) {
  font-size: var(--table-font-size) !important;
}

#resultsTable th:first-child,
#resultsTable td:first-child {
  font-size: 14px !important;
}

#historyTable {
  font-size: var(--table-font-size);
}

/* Sticky Column Logic */
#resultsTable .sticky {
  position: -webkit-sticky;
  position: sticky;
  z-index: 200 !important;
  transform: translateZ(0);
}

#resultsTable thead th:first-child.sticky {
  z-index: 300 !important;
}

#resultsTable thead th {
  position: sticky;
  top: 0;
  z-index: 10;
}

#resultsTable td {
  /* font-weight is NOT transitioned: animating it re-shapes text and re-measures the
     column every frame for 150 ms on each hovered cell (jank on weak GPUs). */
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}

/* Cell Hover Effects - P1-C: gated hover */
#resultsTable td:not(.sticky):hover {
  z-index: 30;
  position: relative;
  border-radius: 4px;
  background-color: white !important;
  font-weight: 700;
  outline: 1.5px solid var(--primary-color);
  color: var(--primary-dark);
}

#resultsTable td.sticky:hover {
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

/* Specific Highlight Borders (Fixes missing left border due to collapse) */
.border-x-sage, .border-x-coral {
    position: relative;
    z-index: 5;
    outline-offset: -1.5px;
}

.border-x-sage {
    outline: 1.5px solid var(--primary-color);
}

.border-x-coral {
    outline: 1.5px solid var(--secondary-color);
}

tr[data-category="personalMonth"] td {
  vertical-align: middle;
}

.milestone-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    box-shadow: 0 0 0 1px white;
}

/* ==========================================================================
   SECTION 4: ANIMATIONS & TOASTS
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-in {
    animation: slideIn 0.2s ease-out;
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Staggered Load Animation */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stagger-1 {
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
}

.stagger-2 {
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.stagger-3 {
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both;
}

.stagger-4 {
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.stagger-5 {
    animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

.animate-fade-in {
    animation: fadeIn var(--transition-base) forwards;
}

.animate-slide-up {
    animation: slideUp var(--transition-base) forwards;
}

.animate-pulse {
    animation: none;
}

.animate-scale-up {
    animation: scaleUp var(--transition-base) forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Micro-interactions */
button:active,
.clickable:active {
    transform: none;
}

.nav-item:active {
    transform: none;
}

.hover-lift {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hover-lift:hover {
}

/* Icon Animations */
i[data-lucide] {
    transition: transform var(--transition-fast);
}

button:hover i[data-lucide] {
}

.rotate-on-hover:hover {
}

/* Toast Container Refinement */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

#toast-container>div {
    pointer-events: auto;
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
}

.nav-item {
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-fast);
    border-left: 4px solid transparent;
    position: relative;
    overflow: hidden;
    margin-bottom: 2px;
}

.nav-item:hover {
    background-color: var(--secondary-light);
    color: var(--primary-dark);
}

.nav-item.bg-sage-light {
    border-left-color: var(--primary-color);
    background: linear-gradient(to right, rgba(232, 141, 120, 0.18), white) !important;
    color: var(--secondary-dark) !important;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* Sidebar Active Indicator */
.nav-item.bg-sage-light::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    bottom: 20%;
    width: 4px;
    background-color: rgba(232, 141, 120, 0.8);
    border-radius: 4px 0 0 4px;
}

/* Sidebar Enhancement */
aside {
    box-shadow: var(--shadow-sm);
    z-index: 40;
}

aside .p-6.border-b {
    background-color: white;
}

/* Header Refinement */
header {
    background-color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
}

/* Active Client Chip */
#active-client-chip {
    animation: slideUp var(--transition-fast) forwards;
}

/* Card Improvements */
.bg-white.rounded-2xl,
.bg-white.rounded-xl {
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
    border: 1px solid var(--border-color);
}

.bg-white.rounded-2xl:hover,
.bg-white.rounded-xl:hover {
    border-color: var(--primary-light);
}

/* Morning Brief Hero Card - Coral Theme */
#brief-hero-card {
    background:
        radial-gradient(circle at top right, rgba(232, 141, 120, 0.18), transparent 35%),
        radial-gradient(circle at bottom left, rgba(214, 117, 96, 0.14), transparent 40%),
        linear-gradient(135deg, rgba(232, 141, 120, 0.08) 0%, rgba(255, 255, 255, 0.98));
    border: 1px solid rgba(232, 141, 120, 0.22);
    box-shadow: var(--shadow-md);
}

/* Metrics Cards */
.metrics-card {
    background: white;
    padding: var(--space-4);
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    box-shadow: var(--shadow-sm);
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-base);
}

.metrics-card:hover {
}

/* Scratchpad Section */
#morning-scratchpad {
    border-radius: 1rem;
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    background-color: var(--bg-body);
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-base);
}

#morning-scratchpad:focus {
    background-color: white;
    box-shadow: var(--shadow-md);
}

input,
select,
textarea {
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#resultsTable tr td.sticky {
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
}

#ciTimelineContainer {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

/* ==========================================================================
   SECTION 5: CUSTOM FORM ELEMENTS & TAG STYLES
   ========================================================================== */

/* Range Slider */
input[type=range] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

input[type=range]::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #e5e7eb;
    border-radius: 2px;
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #e5e7eb;
    border-radius: 2px;
    border: none;
}

input[type=range]::-moz-range-progress {
    background: var(--primary-color);
    border-radius: 2px;
    height: 4px;
}

/* Clean Accordion (Hides default triangle) */
details>summary {
    list-style: none;
}

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

/* Tags in Modal */
.tag-system {
    background-color: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #e9d5ff;
    white-space: nowrap;
}

.tag-manual {
    background-color: #ffffff;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tag-manual:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
}

/* Active Tags (Pills in the Quick Event Logger composer) */
#activeMilestoneTags .ms-pill,
#activeMilestoneTags .ms-empty {
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-sentiment {
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-sentiment:active {
    opacity: 0.8;
}

/* ==========================================================================
   SECTION 6: PRINT STYLES
   ========================================================================== */

@media print {

    aside,
    header,
    #quickNavContainer,
    #recentProfilesContainer,
    #currentInfluencesBox button,
    #historyButtons,
    #toast-container,
    footer,
    #user-status-container,
    #login-button,
    .no-print {
        display: none !important;
    }

    body {
        background: white !important;
        color: black !important;
        height: auto !important;
        overflow: visible !important;
    }

    main {
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
    }

    .shadow-sm,
    .shadow-md,
    .shadow-lg {
        box-shadow: none !important;
    }

    .border {
        border: 1px solid #ddd !important;
    }

    .table-container {
        overflow: visible !important;
        mask-image: none !important;
        -webkit-mask-image: none !important;
    }

    .bg-white,
    tr,
    .bg-gray-50 {
        break-inside: avoid;
    }

    #notes {
        display: block !important;
    }
}

/* ==========================================================================
   SECTION 7: UTILITY CLASSES
   ========================================================================== */

.text-sage {
    color: var(--primary-color);
}

.text-sage-dark {
    color: var(--primary-dark);
}

.bg-sage {
    background-color: var(--primary-color);
}

.bg-sage-light {
    background-color: var(--primary-light);
}

.bg-purple-light {
    background-color: #ede9fe;
}

.bg-purple-light\/20 {
    background-color: rgba(237, 233, 254, 0.2);
}

.bg-purple-light\/30 {
    background-color: rgba(237, 233, 254, 0.3);
}

.bg-purple-light\/10 {
    background-color: rgba(237, 233, 254, 0.1);
}

.border-sage {
    border-color: var(--primary-color);
}

.text-coral {
    color: var(--secondary-color);
}

.text-coral-dark {
    color: var(--secondary-dark);
}

.bg-coral {
    background-color: var(--secondary-color);
}

.bg-coral-light {
    background-color: var(--secondary-light);
}

.border-coral {
    border-color: var(--secondary-color);
}

/* ==========================================================================
   SECTION 8: RESPONSIVE DESIGN (DESKTOP-FIRST)
   ========================================================================== */

/* 1. 4K/Ultra-Wide (Large Screens) */
@media (min-width: 2560px) {
    :root {
        --table-font-size: 14px;
    }
}

/* Base View: FHD (1920px) is the default (No media query needed) */

/* 2. Large Laptop (14-15 inch) */
@media (max-width: 1440px) {
    /* Adjustments for layouts that might be too wide */
}

/* 3. Standard Laptop (Smaller laptops & 720p) */
@media (max-width: 1280px) {

    /* Sidebar collapsed state - only applies when user manually collapses */
    .rail-sidebar[data-expanded="false"] {
        width: 4.5rem !important;
    }
    
    .rail-sidebar[data-expanded="false"] .nav-label,
    .rail-sidebar[data-expanded="false"] .rail-quick-label,
    .rail-sidebar[data-expanded="false"] .rail-sync-label,
    .rail-sidebar[data-expanded="false"] .rail-sync-text,
    .rail-sidebar[data-expanded="false"] .rail-sync-time,
    .rail-sidebar[data-expanded="false"] .sidebar-logo-wrap,
    .rail-sidebar[data-expanded="false"] .sidebar-logo-wrap img {
        opacity: 0 !important;
        width: 0 !important;
        overflow: hidden;
        white-space: nowrap;
    }
    
    .rail-sidebar[data-expanded="false"] .nav-item {
        justify-content: center !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100%;
    }

    .rail-sidebar[data-expanded="false"] .nav-item .flex-shrink-0 {
        margin: 0 auto;
    }

    /* REDUCE MAIN CONTENT MAX-WIDTH to fit viewport */
    .max-w-7xl {
        max-width: 100% !important;
    }
    
    .max-w-3xl {
        max-width: 100% !important;
    }

    /* REDUCE PADDING - Smaller laptops need less whitespace */
    .tab-content {
        padding: 1rem !important;
    }
    
    .tab-content.p-4, 
    .tab-content.p-4\.md\:p-8,
    [class*="view-"] {
        padding: 1rem !important;
    }
    
    div[class*="max-w-"][class*="mx-auto"] {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    /* REDUCE GAPS in grids */
    /* REDUCE GAPS in grids */
    .gap-8 {
        gap: 1rem !important;
    }
    
    .gap-6 {
        gap: 0.75rem !important;
    }

    /* REDUCE SPACING in cards */
    .p-8 {
        padding: 1.25rem !important;
    }
    
    .p-6 {
        padding: 1rem !important;
    }
    
    .p-10 {
        padding: 1.5rem !important;
    }

    /* REDUCE HERO CARD sizing */
    #brief-hero-card {
        min-height: auto !important;
        padding: 1.5rem !important;
    }
    
    #brief-hero-card.p-6 {
        padding: 1.25rem !important;
    }
    
    #brief-hero-card.p-10 {
        padding: 1.5rem !important;
    }

    /* COMPACT VIBE CARD */
    #morning-practitioner-vibe {
        padding: 1rem 1.5rem !important;
    }

    /* FONT SIZING - Slightly smaller on small laptops */
    .text-3xl {
        font-size: 1.75rem !important;
    }
    
    .text-2xl {
        font-size: 1.375rem !important;
    }
    
    .text-xl {
        font-size: 1.125rem !important;
    }
    
    .text-lg {
        font-size: 1rem !important;
    }

    /* REDUCE METRICS CARDS */
    .metrics-card {
        padding: 0.75rem !important;
    }
    /* REDUCE INPUT SIZING */
    input, select, textarea {
        font-size: 14px !important;
        padding: 0.5rem 0.75rem !important;
    }

    /* TABLET-LIKE BEHAVIOR for 1280px */
    #resultsTable th:not(:first-child),
    #resultsTable td:not(:first-child) {
        padding: 0.5rem 0.25rem;
        font-size: var(--table-font-size) !important;
    }

    #resultsTable th:first-child,
    #resultsTable td:first-child {
        padding: 0.5rem 0.25rem;
        font-size: 14px !important;
    }

    /* Pipeline: Ensure gap between columns */
    #pipeline-board {
        gap: 0.5rem !important;
    }

    /* REDUCE BORDER RADIUS */
    .rounded-3xl {
        border-radius: 1.25rem !important;
    }
    
    .rounded-2xl {
        border-radius: 1rem !important;
    }
    
    .rounded-\[2\.5rem\] {
        border-radius: 1.5rem !important;
    }

    /* HEADER COMPACT */
    header {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* REDUCE MODAL PADDING */
    .modal-body, 
    [class*="modal"] .p-8,
    [class*="Modal"] .p-8 {
        padding: 1rem !important;
    }

    /* REDUCE ESSENCE CHART GRID */
    .essence-grid {
        font-size: var(--table-font-size) !important;
    }

    /* ESSENCE TABLE - COMPACT MODE for small laptops */
    #resultsTable {
        font-size: var(--table-font-size) !important;
    }
    
    #resultsTable th,
    #resultsTable td {
        padding: 0.375rem 0.2rem !important;
        min-width: 50px !important;
        max-width: 80px !important;
    }
    
    #resultsTable th:first-child,
    #resultsTable td:first-child {
        min-width: 80px !important;
        max-width: 100px !important;
    }

    /* Horizontal scroll container - ensure smooth scrolling */
    .table-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* REDUCE VIEW-SPECIFIC SECTIONS */
    #view-calculator {
        padding: 0.75rem !important;
    }

    /* COMPACT PIPELINE CARDS */
    .pipeline-col .bg-white {
        padding: 0.75rem !important;
    }

    /* REDUCE BOTTOM NAV (if visible) */
    #mobile-bottom-nav {
        padding: 0.5rem !important;
    }
    
    .bottomnav-item {
        padding: 0.5rem !important;
        min-width: 44px !important;
    }
}

/* 3.1 Laptop Large (1440px) - ensure gap exists */
@media (min-width: 1281px) and (max-width: 1440px) {
    /* Sidebar respects user's toggle preference at 1440px */
    
    #pipeline-board {
        gap: 0.5rem !important;
    }
    
    #pipeline-board .pipeline-col,
    #pipeline-board > div {
        min-width: 220px !important;
    }
}

/* 4. Tablet Landscape (Horizontal tablets & netbooks) */
@media (max-width: 1024px) {
    /* Tablet Landscape Specific Styles */
}

/* 5. Tablet Portrait (768px - Critical Breakpoint) */
@media (max-width: 768px) {

    /* Fix layout shift: Ensure main content has padding to clear the fixed header + bottom nav */
    main {
        padding-top: 56px !important; /* compact mobile header */
        padding-bottom: 0 !important;
        min-height: 100vh;
    }

    /* Stabilize Form Container */
    #view-calculator>div.bg-white {
        min-height: 250px;
    }

    .tab-content {
        padding-bottom: 5.5rem !important; /* bottom nav height + safe area */
    }

    /* Ensure Saved Profiles list is scrollable */
    #view-history .max-h-\[calc\(100vh-140px\)\] {
        max-height: calc(100vh - 120px) !important;
    }

    /* Disable outer scroll - only table area scrolls */
    #view-history {
        overflow: hidden !important;
        height: auto !important;
    }

    /* Table container - flex fills remaining space, only this scrolls */
    #historyContainer {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    #historyScrollContainer {
        flex: 1;
        overflow: auto;
        min-height: 0;
    }

    #toast-container {
        bottom: 5.5rem !important;
        right: 16px;
        left: 16px;
    }

    .modal-content {
        max-height: 90vh;
        width: 95% !important;
    }

    /* Stack 2-Column Grid on Mobile */
    #clientIntelligenceModal .grid {
        display: flex;
        flex-direction: column;
    }

    /* Adjust heights for mobile stacking */
    #clientIntelligenceModal .grid>div {
        min-height: auto;
        max-height: 40vh;
    }

}

/* 6. Mobile (Smartphones) */
@media (max-width: 480px) {
    .p-4,
    .p-6,
    .p-8 {
        padding: 1rem !important;
    }

    #resultsTable th,
    #resultsTable td {
        padding: 0.4rem 0.2rem;
    }

    /* Adjust header text for small screens */
    h2 {
        font-size: 1.1rem;
    }
}

/* ==========================================================================
    SECTION 8A: MODERN LAYOUT — RAIL SIDEBAR, BOTTOM NAV, MORE DRAWER
    ========================================================================== */

/* --- RAIL SIDEBAR (Desktop Collapsible) --- */
.rail-sidebar {
    width: 16rem; /* 256px expanded */
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Ensure sidebar header never compresses or gets cut off */
.rail-sidebar > .p-4.border-b {
    flex-shrink: 0;
}

/* Ensure sidebar nav fills remaining space */
.rail-sidebar > nav {
    flex: 1 1 0;
    min-height: 0;
}

/* Ensure sync panel at bottom never gets pushed off */
.rail-sidebar > .sidebar-sync-panel {
    flex-shrink: 0;
}

/* Keep the expanded rail compact enough for the full analysis menu. */
.rail-sidebar[data-expanded="true"] .rail-sidebar-nav {
    gap: 0.0625rem;
    padding: 0.5rem;
}

.rail-sidebar[data-expanded="true"] .rail-sidebar-nav .nav-item {
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    font-size: 0.8125rem;
}

.rail-sidebar::-webkit-scrollbar {
    width: 4px;
}

.rail-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.rail-sidebar::-webkit-scrollbar-thumb {
    background: rgba(151, 184, 129, 0.3);
    border-radius: 4px;
}

.rail-sidebar[data-expanded="false"] {
    width: 4.5rem !important; /* 72px collapsed rail */
}

.rail-sidebar[data-expanded="false"] .nav-label,
.rail-sidebar[data-expanded="false"] .rail-quick-label,
.rail-sidebar[data-expanded="false"] .rail-sync-label,
.rail-sidebar[data-expanded="false"] .rail-sync-text,
.rail-sidebar[data-expanded="false"] .rail-sync-time,
.rail-sidebar[data-expanded="false"] .sidebar-logo-wrap,
.rail-sidebar[data-expanded="false"] .sidebar-logo-wrap img {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    /* opacity only — animating the label width reflows every nav row */
    transition: opacity 150ms ease;
}

.rail-sidebar[data-expanded="false"] .nav-item {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    gap: 0 !important;
    width: 100%;
}

.rail-sidebar[data-expanded="false"] .nav-item .flex-shrink-0 {
    margin: 0 auto;
}

/* Tooltip on hover when collapsed */
.rail-sidebar[data-expanded="false"] .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1f2937;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 150ms ease;
    z-index: 100;
}

.rail-sidebar[data-expanded="false"] .nav-item:hover::after {
    opacity: 1;
}

.sync-panel-inner {
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sync-panel-inner:hover {
    border-color: rgba(151, 184, 129, 0.35);
}

/* === Sync Ring Animations === */
/* Smooth spinner: a fixed-length arc that rotates (compositor-only transform)
   instead of animating stroke-dashoffset, which repainted every frame and looked jerky. */
@keyframes syncRingPulse {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes syncTextIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

#sync-ring-arc-collapsed, #sync-ring-arc-expanded {
    transform-box: fill-box;
    transform-origin: center;
}

#sync-status.sync-text-in, #sync-label-collapsed.sync-text-in {
    animation: syncTextIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

#sync-progress-fill {
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
    #sync-status.sync-text-in, #sync-label-collapsed.sync-text-in { animation: none; }
    .rail-sidebar [id^="sync-ring-arc"], .rail-sidebar [id^="sync-status-dot"] { animation: none !important; }
}

@keyframes syncRingSpin {
    0% { transform: rotate(-90deg); }
    100% { transform: rotate(270deg); }
}

@keyframes syncRingSuccess {
    0% { stroke-dashoffset: 97.4; }
    100% { stroke-dashoffset: 0; }
}

@keyframes syncRingExpandedSpin {
    0% { transform: rotate(-90deg); }
    100% { transform: rotate(270deg); }
}

@keyframes syncRingExpandedSuccess {
    0% { stroke-dashoffset: 106.8; }
    100% { stroke-dashoffset: 0; }
}

/* Batch 2b: compositor-only. The old versions animated box-shadow, which
   repainted every frame — and `error-active` has no auto-reset, so a persistent
   sync error pulsed a paint loop in the header forever. The halo is now static
   (see the .syncing-active / .error-active rules) and only scale+opacity move. */
@keyframes syncDotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

@keyframes syncDotPulseCoral {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

@keyframes indicatorPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

@keyframes collapsedSyncPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.9); }
}

/* === Sync Indicator Dot (Expanded Header) === */
#sync-indicator {
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.3s ease;
}

#sync-indicator.online {
    background: #97B881;
    box-shadow: 0 0 8px rgba(151, 184, 129, 0.6);
}

#sync-indicator.offline {
    background: #E88D78;
    box-shadow: 0 0 8px rgba(232, 141, 120, 0.6);
}

#sync-indicator.syncing {
    background: #f59e0b;
    animation: indicatorPulse 0.8s ease-in-out infinite;
}

/* === Connection Badge === */
#sync-connection-badge {
}

/* === Sync Status Dot Glow States ===
   Batch 1c/2b: `will-change: transform` removed (the animation is transform +
   opacity, so the compositor promotes it by itself and we stop pinning a layer
   for the life of the page). The glow is a static halo now instead of an
   animated box-shadow. NOTE: `.error-active` is never auto-reset, so this used
   to keep a paint-bound animation running in the header until the next success. */
#sync-status-dot.syncing-active {
    animation: syncDotPulse 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

#sync-status-dot-collapsed.syncing-active {
    animation: syncDotPulse 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

#sync-status-dot.error-active {
    animation: syncDotPulseCoral 2s ease-in-out infinite;
}

#sync-status-dot-collapsed.error-active {
    animation: syncDotPulseCoral 2s ease-in-out infinite;
}

/* === Collapsed View Visibility === */
.rail-sidebar[data-expanded="false"] .rail-icon-expanded {
    display: none;
}

.rail-sidebar[data-expanded="false"] .rail-icon-collapsed {
    display: flex;
}

.rail-sidebar[data-expanded="true"] .rail-icon-collapsed {
    display: none;
}

.rail-sidebar[data-expanded="true"] .rail-icon-expanded {
    display: block;
}

/* === Collapsed Ring States === */
.rail-sidebar[data-sync-state="syncing"] #sync-ring-arc-collapsed {
    stroke: #97B881;
    stroke-dashoffset: 65;
    animation: syncRingPulse 1.4s linear infinite;
}

.rail-sidebar[data-sync-state="syncing"] #sync-status-dot-collapsed {
    background: #97B881;
    animation: collapsedSyncPulse 0.8s ease-in-out infinite;
}

.rail-sidebar[data-sync-state="success"] #sync-ring-arc-collapsed {
    stroke: #97B881;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.5s ease-out;
}

.rail-sidebar[data-sync-state="success"] #sync-status-dot-collapsed {
    background: #97B881;
}

.rail-sidebar[data-sync-state="error"] #sync-ring-arc-collapsed {
    stroke: #E88D78;
    stroke-dashoffset: 50;
}

.rail-sidebar[data-sync-state="error"] #sync-status-dot-collapsed {
    background: #E88D78;
}

.rail-sidebar[data-sync-state="offline"] #sync-ring-arc-collapsed {
    stroke: #E88D78;
    stroke-dashoffset: 70;
}

.rail-sidebar[data-sync-state="offline"] #sync-status-dot-collapsed {
    background: #E88D78;
}

/* === Expanded Ring States === */
.rail-sidebar[data-sync-state="syncing"] #sync-ring-arc-expanded {
    stroke: #97B881;
    stroke-dashoffset: 65;
    animation: syncRingPulse 1.4s linear infinite;
}

.rail-sidebar[data-sync-state="syncing"] #sync-status-dot {
    background: #97B881;
    animation: collapsedSyncPulse 0.8s ease-in-out infinite;
}

.rail-sidebar[data-sync-state="success"] #sync-ring-arc-expanded {
    stroke: #97B881;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.5s ease-out;
}

.rail-sidebar[data-sync-state="success"] #sync-status-dot {
    background: #97B881;
}

.rail-sidebar[data-sync-state="error"] #sync-ring-arc-expanded {
    stroke: #E88D78;
    stroke-dashoffset: 55;
}

.rail-sidebar[data-sync-state="error"] #sync-status-dot {
    background: #E88D78;
}

.rail-sidebar[data-sync-state="offline"] #sync-ring-arc-expanded {
    stroke: #E88D78;
    stroke-dashoffset: 75;
}

.rail-sidebar[data-sync-state="offline"] #sync-status-dot {
    background: #E88D78;
}

/* Legacy classes kept for backwards compat */
.rail-sidebar[data-expanded="false"] .sidebar-sync-panel .rail-sync-label,
.rail-sidebar[data-expanded="false"] .sidebar-sync-panel .rail-sync-text,
.rail-sidebar[data-expanded="false"] .sidebar-sync-panel .rail-sync-time {
    display: none;
}

/* Active nav indicator bar */
.rail-sidebar .nav-item.bg-sage-light {
    position: relative;
}

.rail-sidebar .nav-item.bg-sage-light::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    height: 50%;
    width: 3px;
    background: rgba(232, 141, 120, 0.8);
    border-radius: 0 4px 4px 0;
}

/* ==========================================================================
   FLOATING ISLAND SIDEBAR (Option 2)
   Detached card sidebar that floats off the edges with elevated shadow.
   ========================================================================== */

/* Sidebar background becomes transparent so the floating card stands out.
   Use both classes for higher specificity (beats .rail-sidebar base rule at line ~11156). */
.rail-sidebar.rail-sidebar--floating {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Outer wrap: 12px inset all around so the card "floats" off the edges */
.rail-floating-wrap {
    padding: 12px 0 12px 12px;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Right edge needs breathing room on narrow screens too */
@media (max-width: 1280px) {
    .rail-floating-wrap {
        padding-right: 4px;
    }
}

@media (min-width: 1280px) {
    .rail-floating-wrap {
        padding-right: 8px;
    }
}

/* The floating card itself */
.rail-floating {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    box-shadow:
        0 12px 32px -10px rgba(15, 23, 42, 0.10),
        0 4px 10px -4px rgba(15, 23, 42, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    overflow: hidden;
    /* Deliberately not animated. Collapsing this card changes its width, which
       reflows the whole app — this card, the rail, and the main content column —
       on every frame for the length of the animation. The collapse snaps
       instead; the nav labels cross-fade on opacity, which is composited. */
}

/* Keep content above */
.rail-floating > .rail-sidebar-head,
.rail-floating > .rail-sidebar-nav,
.rail-floating > .sidebar-sync-panel {
    position: relative;
    z-index: 1;
}

/* Header inside floating card — no bottom border, blend with the card */
.rail-floating > .rail-sidebar-head {
    border-bottom: 1px solid var(--border-color);
}

/* Nav inside floating card — no extra padding since wrap already has inset */
.rail-floating > .rail-sidebar-nav {
    flex: 1 1 0;
    min-height: 0;
    padding: 0.5rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sync panel inside floating card */
.rail-floating > .sidebar-sync-panel {
    background: transparent;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    padding: 0.375rem;
}

/* Sync panel inner card: keep light, sits on floating card */
.rail-floating .sync-panel-inner {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

/* Collapsed state — keep card, just shrink horizontally */
.rail-sidebar--floating[data-expanded="false"] .rail-floating {
    width: 64px;
}

.rail-sidebar--floating[data-expanded="false"] .rail-floating-wrap {
    padding: 12px 0 12px 12px;
}

.rail-sidebar--floating[data-expanded="false"] .rail-floating > .rail-sidebar-nav {
    padding: 0.5rem;
}

/* Scrollbar styling for the floating card nav */
.rail-floating > .rail-sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.rail-floating > .rail-sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.rail-floating > .rail-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(151, 184, 129, 0.3);
    border-radius: 4px;
}

.rail-floating > .rail-sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(151, 184, 129, 0.5);
}

/* --- MOBILE BOTTOM NAVIGATION BAR --- */
#mobile-bottom-nav {
    padding-top: 0.375rem;
}

.bottomnav-item {
    position: relative;
}

.bottomnav-item.text-sage-dark {
    color: var(--primary-dark);
}

.bottomnav-item.text-sage-dark::after {
    content: '';
    position: absolute;
    top: -0.375rem;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

/* --- MOBILE MORE DRAWER --- */
#more-drawer.open {
    transform: translateY(0) !important;
}

#more-drawer-backdrop.open {
    opacity: 1 !important;
}

.drawer-tile .w-11 {
    transition: transform 150ms ease;
}

/* --- FLUID TYPOGRAPHY --- */
.text-fluid-xs { font-size: clamp(0.7rem, 0.65rem + 0.25vw, 0.8rem); }
.text-fluid-sm { font-size: clamp(0.8rem, 0.75rem + 0.3vw, 0.95rem); }
.text-fluid-base { font-size: clamp(0.9rem, 0.85rem + 0.35vw, 1.05rem); }
.text-fluid-lg { font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem); }
.text-fluid-xl { font-size: clamp(1.25rem, 1.1rem + 0.75vw, 1.75rem); }
.text-fluid-2xl { font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem); }

/* --- RESPONSIVE SPACING TOKENS --- */
@media (max-width: 639px) {
    .space-responsive { gap: 0.75rem; }
    .p-responsive { padding: 1rem; }
}
@media (min-width: 640px) and (max-width: 1024px) {
    .space-responsive { gap: 1rem; }
    .p-responsive { padding: 1.5rem; }
}
@media (min-width: 1024px) {
    .space-responsive { gap: 1.5rem; }
    .p-responsive { padding: 2rem; }
}

/* --- MOBILE: Adjust padding for bottom nav + top header --- */
@media (max-width: 768px) {
    .tab-content {
        padding-bottom: 5.5rem !important; /* 88px for bottom nav + safe area */
    }

    /* Toast positioning above bottom nav */
    #toast-container {
        bottom: 5.5rem !important;
        right: 1rem !important;
        left: 1rem !important;
    }

    /* Modals: bottom sheet style on mobile */
    .modal-mobile-sheet {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 94dvh !important;
        border-radius: 1.25rem 1.25rem 0 0 !important;
        margin: 0 !important;
        transform: none !important;
    }
}

/* ==========================================================================
    SECTION 8B: TABLET PORTRAIT RESPONSIVE (768px – 1280px)
    Targets 10.4" tablets (1200x2000), iPad portrait, and similar devices.
    Auto-collapses sidebar to icon rail, ensures header stays visible,
    prevents content overlap, and keeps all controls accessible.
    ========================================================================== */

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {

    /* --- Sidebar: force icon-rail mode --- */
    .rail-sidebar {
        max-height: 100dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /* Force collapsed rail regardless of data-expanded attribute */
    .rail-sidebar[data-expanded="true"] {
        width: 4.5rem !important;
    }

    .rail-sidebar[data-expanded="true"] .nav-label,
    .rail-sidebar[data-expanded="true"] .rail-quick-label,
    .rail-sidebar[data-expanded="true"] .rail-sync-label,
    .rail-sidebar[data-expanded="true"] .rail-sync-text,
    .rail-sidebar[data-expanded="true"] .rail-sync-time,
    .rail-sidebar[data-expanded="true"] .sidebar-logo-wrap,
    .rail-sidebar[data-expanded="true"] .sidebar-logo-wrap img {
        opacity: 0 !important;
        width: 0 !important;
        overflow: hidden !important;
        white-space: nowrap;
        /* opacity only — animating the label width reflows every nav row */
        transition: opacity 150ms ease;
    }

    .rail-sidebar[data-expanded="true"] .nav-item {
        justify-content: center !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        position: relative;
    }

    .rail-sidebar[data-expanded="true"] .nav-item .flex-shrink-0 {
        margin: 0;
    }

    /* Show collapse-open icon, hide collapse-close icon */
    .rail-sidebar[data-expanded="true"] .rail-icon-expanded {
        display: none !important;
    }

    .rail-sidebar[data-expanded="true"] .rail-icon-collapsed {
        display: flex !important;
    }

    /* Tooltip on hover when in tablet rail mode */
    .rail-sidebar[data-expanded="true"] .nav-item::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 8px);
        top: 50%;
        transform: translateY(-50%);
        background: #1f2937;
        color: white;
        font-size: 0.7rem;
        font-weight: 600;
        padding: 4px 10px;
        border-radius: 6px;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        transition: opacity 150ms ease;
        z-index: 100;
    }

    .rail-sidebar[data-expanded="true"] .nav-item:hover::after {
        opacity: 1;
    }

    /* Sync panel compact mode */
    .rail-sidebar[data-expanded="true"] .sidebar-sync-panel .rail-icon-expanded {
        display: none !important;
    }

    .rail-sidebar[data-expanded="true"] .sidebar-sync-panel .rail-icon-collapsed {
        display: flex !important;
    }

    /* --- Desktop header: ensure always visible above content --- */
    .app-shell-header {
        z-index: 50 !important;
    }

    /* --- Main content: fit remaining space, no overlap --- */
    .app-shell-main {
        min-width: 0;
    }

    /* --- Compact content padding --- */
    .tab-content {
        padding: 0.75rem !important;
    }

    .tab-content.p-4,
    .tab-content.p-4\.md\:p-8,
    [class*="view-"] {
        padding: 0.75rem !important;
    }

    /* --- Full-width content containers --- */
    .max-w-7xl {
        max-width: 100% !important;
    }

    .max-w-3xl {
        max-width: 100% !important;
    }

    div[class*="max-w-"][class*="mx-auto"] {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    /* --- Reduce gaps --- */
    .gap-8 {
        gap: 1rem !important;
    }

    .gap-6 {
        gap: 0.75rem !important;
    }

    /* --- Compact cards --- */
    .p-8 {
        padding: 1.25rem !important;
    }

    .p-6 {
        padding: 1rem !important;
    }

    .p-10 {
        padding: 1.25rem !important;
    }

    /* --- Compact hero --- */
    #brief-hero-card {
        min-height: auto !important;
        padding: 1.25rem !important;
    }

    /* --- Pipeline kanban --- */
    #pipeline-board {
        gap: 0.5rem !important;
    }

    .kanban-column {
        min-width: 260px !important;
        flex-shrink: 0 !important;
    }

    /* --- Touch-friendly targets --- */
    button {
        min-height: 40px;
    }

    .nav-item {
        padding: 0.5rem 0.5rem !important;
        min-height: 2.5rem;
    }
}

/* --- 768px+: Bottom padding not needed --- */
@media (min-width: 768px) {
    main {
        padding-bottom: 0 !important;
    }
}

/* ==========================================================================
    SECTION 9: FUTURE TIMELINE & CORE CARDS
    ========================================================================== */

#cardsContainer>div {
    border-radius: 1.25rem;
    padding: var(--space-4);
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-base);
}

#cardsContainer>div:hover {
    border-color: var(--primary-light);
}

.timeline-card {
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-base);
    border-radius: 1.5rem !important;
    border: 1px solid var(--border-color) !important;
    background: white !important;
    box-shadow: var(--shadow-md) !important;
}

.timeline-card:hover {
    border-color: var(--primary-light) !important;
}

.current-year-card {
    border: 2px solid var(--secondary-color) !important;
    background: linear-gradient(to bottom, white, var(--secondary-50)) !important;
    box-shadow: 0 15px 30px -10px rgba(232, 141, 120, 0.2), var(--shadow-lg) !important;
}

#ft-viewport,
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#ft-viewport {
    padding: 1rem 0;
}

#ft-viewport::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Planes of Expression Inline */
#planesInlineDisplay span {
    background: white;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-fast);
}

#planesInlineDisplay span:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-50);
}

/* ==========================================================================
    SECTION 10: MORNING BRIEF THEMES & PREMIUM TOUCHES
    ========================================================================== */

/* Legacy Themes Removed - Now managed in Section 40 */

/* ==========================================================================
   SECTION 10: DRAG & DROP PIPELINE REFINEMENT
   ========================================================================== */

.draggable {
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.draggable.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    cursor: grabbing !important;
}

.reading-delivered {
    opacity: 0.7;
    filter: grayscale(0.3);
    background-color: #f0fdf4 !important;
    /* Very light green */
    border-style: dashed !important;
}

/* ponytail: the old .reading-delivered::after 'PAID' sticker is gone. It keyed off
   isDelivered, which normalizeHistory() force-sets on every Completed reading, so a
   0-paid card showed PAID next to its UNPAID chip. Payment state is now the single
   getPaymentState() chip in pipeline.js — isDelivered only styles the card here. */

.pipeline-col-highlight {
    background-color: rgba(151, 184, 129, 0.05) !important;
    border-color: var(--primary-color) !important;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.2s ease;
}

/* ==========================================================================
    SECTION 11: HYBRID RESPONSIVE PROFILE LIST (Table to Cards)
    ========================================================================== */

@media (max-width: 768px) {

    /* Hide Table Header */
    #historyTable thead {
        display: none;
    }

    #historyTable,
    #historyTable tbody,
    #historyTable tr,
    #historyTable td {
        display: block;
        width: 100%;
    }

    #historyTable tr {
        margin-bottom: 0.5rem;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        padding: 0.5rem 0.75rem;
        box-shadow: var(--shadow-sm);
        position: relative;
        border-left-width: 3px !important;
        overflow: hidden;
    }

    #historyTable tr.bg-coral-light {
        background-color: var(--secondary-light) !important;
    }

    #historyTable td {
        padding: 0 !important;
        white-space: normal !important;
        border: none !important;
    }

    /* Column Specific Hiding */
    #historyTable td:nth-child(1),
    /* Serial # */
    #historyTable td:nth-child(2),
    /* DOB */
    #historyTable td:nth-child(4),
    /* Birth */
    #historyTable td:nth-child(5),
    /* Path */
    #historyTable td:nth-child(6) {
        /* Destiny */
        display: none !important;
    }

    #historyTable td:nth-child(3) {
        /* Integrated Card Cell */
        display: block !important;
        width: 100%;
    }

    /* Actions Bar - INTEGRATED */
    #historyTable td:last-child {
        display: block;
        border-top: none;
        padding-top: 0.5rem !important;
        margin-top: 0;
    }

    #historyTable td:last-child .flex {
        justify-content: flex-start !important;
        gap: 0.25rem !important;
        width: 100%;
    }

    #historyTable td:last-child button {
        flex: 1;
        display: flex;
        justify-content: center;
        padding: 0.5rem 0.25rem !important;
        background: var(--bg-body);
        border-radius: 0.5rem;
        box-shadow: none;
        border: 1px solid rgba(0, 0, 0, 0.03);
    }
}

/* Desktop Table Column Layout (769px+) */
@media (min-width: 769px) {
    #historyScrollContainer {
        overflow-x: auto;
        overflow-y: auto;
    }

    #historyTable {
        width: 100%;
        min-width: 58rem;
        table-layout: auto;
    }

    #historyTable thead th {
        vertical-align: middle;
    }

    /* # column */
    #historyTable th:first-child,
    #historyTable td:first-child {
        width: 4rem;
        text-align: center;
    }

    /* DOB column */
    #historyTable th:nth-child(2),
    #historyTable td:nth-child(2) {
        width: 7rem;
    }

    /* Name column - takes remaining space */
    #historyTable th:nth-child(3),
    #historyTable td:nth-child(3) {
        width: auto;
        min-width: 12rem;
    }

    /* Birth No, Life Path, Destiny columns - equal width */
    #historyTable th:nth-child(4),
    #historyTable td:nth-child(4),
    #historyTable th:nth-child(5),
    #historyTable td:nth-child(5),
    #historyTable th:nth-child(6),
    #historyTable td:nth-child(6) {
        width: 6rem;
        text-align: center;
    }

    /* Actions column */
    #historyTable th:last-child,
    #historyTable td:last-child {
        width: 15rem;
        text-align: right;
        white-space: nowrap;
    }

    #historyTable th:nth-child(3) .truncate,
    #historyTable td:nth-child(3) .truncate {
        max-width: 100%;
    }

    #historyTable .history-actions-head,
    #historyTable .history-actions-cell {
        position: sticky;
        right: 0;
        z-index: 3;
        background: #ffffff;
        box-shadow: -12px 0 18px -18px rgba(15, 23, 42, 0.35);
    }

    #historyTable .history-actions-wrap {
        flex-wrap: nowrap;
    }

    #historyTable .history-actions-wrap button {
        flex: 0 0 auto;
    }

    /* Consistent row height */
    #historyTable tbody tr {
        height: 2rem;
    }

    /* Hover row highlight */
    #historyTable tbody tr:hover {
        background-color: rgba(151, 184, 129, 0.08);
    }
}

@media (min-width: 769px) and (max-width: 1279px) {
    #historyTable th:first-child,
    #historyTable td:first-child {
        width: 3.5rem;
    }

    #historyTable th:nth-child(2),
    #historyTable td:nth-child(2) {
        width: 6.25rem;
    }

    #historyTable th:nth-child(5),
    #historyTable td:nth-child(5) {
        width: 4.75rem;
    }

    #historyTable th:nth-child(4),
    #historyTable td:nth-child(4),
    #historyTable th:nth-child(6),
    #historyTable td:nth-child(6) {
        width: 4.75rem;
    }

    #historyTable th:last-child,
    #historyTable td:last-child {
        width: 12.25rem;
    }
}

@media (min-width: 769px) and (max-width: 1023px) {
    #historyTable .history-actions-wrap {
        gap: 0.25rem !important;
    }

    #historyTable .history-actions-wrap button {
        padding: 0.4rem !important;
    }
}

/* ==========================================================================
    SECTION 12: TOUCH INTERACTION & GESTURE SUPPORT
    ========================================================================== */

/* Touch Action Optimization - Remove 300ms tap delay */
button,
a,
input,
select,
textarea,
[onclick] {
    touch-action: manipulation;
}

/* Prevent text selection on touch interactions */
button,
.nav-item,
.btn-sentiment,
.draggable {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Active State for Touch Feedback */
@media (hover: none) and (pointer: coarse) {

    button:active,
    .nav-item:active,
    .btn-sentiment:active {
        transform: none;
        opacity: 0.8;
    }

    .draggable:active {
        transform: none;
    }
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Swipe Animation for Sidebar */
aside {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* ==========================================================================
    SECTION 13: PIPELINE PREMIUM STYLING
    ========================================================================== */

.pipeline-col {
    background-color: rgba(248, 250, 252, 0.5);
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 500px;
}

.pipeline-col h3 {
    font-size: 0.875rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .pipeline-card {
        min-height: 100px;
        padding: 0.75rem;
    }

.pipeline-card:hover {
    border-color: var(--primary-light);
}

.pipeline-card.priority-star::before {
    content: '★';
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: var(--sun-dark);
    font-size: 0.75rem;
}

/* Touch-friendly drag scroll for pipeline */
.pipeline-scroll-track {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.pipeline-scroll-track::-webkit-scrollbar {
    height: 16px;
}

.pipeline-scroll-track::-webkit-scrollbar-track {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.pipeline-scroll-track::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 20px;
    border: 4px solid #f8fafc;
}

/* ==========================================================================
    SECTION 14: TABLE TOUCH SCROLLING
    ========================================================================== */

.table-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Touch-friendly table scroll indicators */
.table-scroll-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.15s ease, background-color 0.2s ease;
    z-index: 30;
    pointer-events: auto;
}

.table-scroll-indicator:hover {
    background: rgba(255, 255, 255, 1);
    color: var(--primary-dark);
}

.table-scroll-indicator:active {
    transform: translateY(-50%);
}

.table-container:hover .table-scroll-indicator,
.table-container:focus-within .table-scroll-indicator,
.group:hover .table-scroll-indicator {
    opacity: 1;
}

.table-scroll-indicator.left {
    left: 8px;
}

.table-scroll-indicator.right {
    right: 8px;
}

/* ==========================================================================
    SECTION 14: INTELLIGENCE & PATTERN MATRIX
    ========================================================================== */

#user-intel-body tr {
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-fast);
}

#user-intel-body tr:hover {
    background-color: var(--primary-50);
}

#user-intel-body td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Heatmap Cell Variations */
.heatmap-cell {
    border-radius: 6px;
    font-weight: 700;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-base);
}

.heatmap-cell:hover {
    z-index: 10;
}

/* Strategic Insights Section */
.insight-card {
    background: white;
    padding: 1rem;
    border-radius: 1rem;
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-base);
}

.insight-card:hover {
    border-left-color: var(--primary-dark);
}

.insight-card h5 {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.insight-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Radar Trend Section */
#user-radar-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: none;
    border-radius: 1.25rem;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
    SECTION 15: MODERN MODAL REFINEMENTS (GLOBAL)
    ========================================================================== */

.fixed.inset-0.bg-black\/70 {
    background-color: rgba(15, 23, 42, 0.75) !important;
    /* Deep Slate Semi-opaque */
    backdrop-filter: none !important;
    /* No blur for performance */
    transition: opacity var(--transition-base);
}

/* Modal Body Shadow Layering */
.bg-white.rounded-2xl.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), var(--shadow-2xl) !important;
    border: 1px solid var(--border-strong);
}

/* Modal Header Refinement */
.modal-header,
#editHistoryModal .p-4.border-b,
#quickEditModal .p-4.border-b,
#clientIntelligenceModal .p-4.border-b {
    background-color: #ffffff !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 1.25rem 1.5rem !important;
}

/* Modal Footer Refinement */
.modal-footer,
#editHistoryModal .p-4.border-t,
#quickEditModal .p-4.border-t {
    background-color: var(--primary-50) !important;
    border-top: 1px solid var(--border-color) !important;
    padding: 1rem 1.5rem !important;
}

/* Mobile Modal Centering Fix */
@media (max-width: 768px) {

    /* Reset Wrapper to Center */
    #authModal.flex,
    #editHistoryModal.flex,
    #clientIntelligenceModal.flex,
    #meaningModal.flex,
    #dataManagementModal.flex,
    #quickEditModal.flex,
    #readingActionModal.flex,
    #customConfirmModal.flex,
    #customPromptModal.flex,
    #quickCalcModal.flex,
    #addClientPipelineModal.flex,
    #quickLoadModal.flex {
        align-items: center !important;
        justify-content: center !important;
        padding: 1rem !important;
    }

    /* Modal Content Styling for Mobile
       #milestoneModal is deliberately absent from both lists: the Quick Event
       Logger owns its own responsive sizing (see the QUICK EVENT LOGGER block)
       so that it can go full-bleed on phones with its composer pinned to the
       bottom edge. The desktop rules still apply to it above 768px. */
    #authModal > .bg-white,
    #editHistoryModal > .bg-white,
    #clientIntelligenceModal > .bg-white,
    #meaningModal > .bg-white,
    #dataManagementModal > .bg-white,
    #quickEditModal > .bg-white,
    #readingActionModal > .bg-white,
    #customConfirmModal > .bg-white,
    #customPromptModal > .bg-white,
    #quickCalcModal > .bg-white,
    #addClientPipelineModal > .bg-white,
    #quickLoadModal > .bg-white {
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 1.25rem !important;
        max-height: 90dvh !important;
        margin: auto !important;
        transform: none !important;
        box-shadow: var(--shadow-2xl) !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal-content .p-6,
    #editHistoryModal .p-6,
    #quickEditModal .p-6,
    #meaningModal #meaningText {
        padding: 1.25rem !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Ensure form grids stack properly on mobile within modals */
    .modal-content .grid-cols-2,
    #editHistoryModal .grid-cols-2,
    #quickEditModal .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
     SECTION 37: PIPELINE CARD ACTION BUTTONS MOBILE FIX
     ========================================================================== */

@media (max-width: 768px) {

    /* Allow buttons to share row width */
    .mobile-action-buttons {
        flex-wrap: nowrap !important;
        overflow: visible !important;
        width: auto !important;
        gap: 0.5rem !important;
    }

    /* Circular Touch Targets */
    .mobile-action-buttons button {
        flex: none !important;
        min-width: 32px !important;
        width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 50% !important;
        background-color: #f9fafb;
        border: 1px solid transparent;
        transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.2s ease;
    }

    .mobile-action-buttons button:active {
        background-color: #e5e7eb;
    }

    /* Icon sizing */
    .mobile-action-buttons button i {
        width: 16px !important;
        height: 16px !important;
    }
}

@media (max-width: 768px) {

    /* Increase touch targets */
    input,
    select,
    textarea {
        min-height: 44px;
        padding: 12px 16px !important;
        font-size: 16px !important;
        /* Prevents zoom on iOS */
    }

    /* Better focus states for touch */
    input:focus,
    select:focus,
    textarea:focus {
        outline: none;
        box-shadow: 0 0 0 2px var(--primary-color);
    }

    /* Form group spacing */
    .form-group {
        margin-bottom: 16px;
    }

    /* Larger checkboxes and radio buttons */
    input[type="checkbox"],
    input[type="radio"] {
        min-width: 24px;
        min-height: 24px;
        width: 24px;
        height: 24px;
    }

    /* Better range slider on touch */
    input[type="range"] {
        min-height: 44px;
        padding: 8px 0;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
        margin-top: -10px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
}

/* ==========================================================================
    SECTION 17: TABLET SPECIFIC OPTIMIZATIONS (768px - 1024px)
    ========================================================================== */

@media (min-width: 768px) and (max-width: 1024px) {

    /* Compact sidebar for tablet — use rail-sidebar class, not generic aside */
    .rail-sidebar {
        max-height: 100dvh !important;
        overflow-y: auto !important;
    }

    aside .text-sm {
        font-size: 0.8rem !important;
    }

    aside .gap-3 {
        gap: 0.5rem !important;
    }

    aside .py-3 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    /* Reduce padding on main content */
    .tab-content {
        padding: 1rem !important;
    }

    /* History table tablet optimization */
    #historyTable th, 
    #historyTable td {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
/* Pipeline tablet optimization */
#pipeline-board {
    gap: 0.5rem !important;
    display: flex !important;
    flex-nowrap: nowrap !important;
    overflow-x: auto !important;
    padding-bottom: 1rem !important;
    contain: layout style paint;
}

.kanban-column {
    min-width: 280px !important;
    flex-shrink: 0 !important;
}

    #pipeline-board::-webkit-scrollbar {
        height: 8px;
    }

    #pipeline-board::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }

    #pipeline-board::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
    }

    #resultsTable th,
    #resultsTable td {
        padding: 0.5rem !important;
    }

    /* Better touch targets on tablet */
    button {
        min-height: 40px;
    }

    /* Nav items */
    .nav-item {
        padding: 0.5rem 0.75rem !important;
    }
}

/* ==========================================================================
    SECTION 18: IMPROVED SCROLL BEHAVIOR
    ========================================================================== */

/* Momentum scrolling for all scrollable containers */
.overflow-y-auto,
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Custom scrollbar for modals - subtle and visible */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* ==========================================================================
    SECTION 19: MOBILE NAVIGATION IMPROVEMENTS
    ========================================================================== */

@media (max-width: 768px) {

    /* Sticky header improvements */
    header {
        position: sticky;
        top: 0;
        z-index: 30;
        background: rgba(255, 255, 255, 0.95);

    }

    /* Better mobile navigation */
    .nav-item {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        padding: 0.75rem 1rem !important;
    }

    /* Quick action buttons */
    .quick-action-btn {
        min-width: 48px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ==========================================================================
    SECTION 20: UTILITY CLASSES FOR MOBILE
    ========================================================================== */

/* Touch-friendly loading states */
.touch-spinner {
    animation: spin 1s linear infinite;
    -webkit-animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@-webkit-keyframes spin {
    from {
        -webkit-transform: rotate(0deg);
    }

    to {
        -webkit-transform: rotate(360deg);
    }
}

/* Mobile-safe fixed positioning */
.mobile-fixed-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-fixed-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Batch 1b: `.skeleton` / `@keyframes skeleton-loading` removed — unreferenced.
   The only skeleton system is the transform-based `.sk-*` shimmer in skeleton.css. */

/* ==========================================================================
    SECTION 21: CALCULATOR FORM MOBILE OPTIMIZATION (320px-768px)
    ========================================================================== */

@media (max-width: 768px) {

    /* Compact Calculator Form Container */
    #view-calculator>div.bg-white {
        padding: 1rem !important;
    }

    /* Single column form layout */
    #calculatorForm .grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* Reset any grid columns to full width */
    #calculatorForm .md\:col-span-4,
    #calculatorForm .md\:col-span-6,
    #calculatorForm .lg\:col-span-2,
    #calculatorForm .lg\:col-span-3,
    #calculatorForm .lg\:col-span-4 {
        width: 100% !important;
        flex: none !important;
        max-width: 100% !important;
    }

    /* Form field containers */
    #calculatorForm>.grid>div {
        width: 100% !important;
    }

    /* Labels - smaller but readable */
    #calculatorForm label {
        font-size: 0.7rem !important;
        margin-bottom: 0.25rem !important;
        font-weight: 600 !important;
        color: #6b7280 !important;
    }

    /* Input touch targets */
    #calculatorForm input,
    #calculatorForm select {
        min-height: 44px !important;
        padding: 10px 14px !important;
        font-size: 14px !important;
        width: 100% !important;
        border-radius: 0.5rem !important;
    }

    /* Date input special handling */
    #calculatorForm input[type="text"].smart-date-input {
        letter-spacing: 0.05em !important;
    }

    /* Keep placeholders visible on mobile */

    /* Form action buttons - full width, side by side */
    #calculatorForm>.grid>div:last-child {
        display: flex !important;
        gap: 0.5rem !important;
        margin-top: 0.5rem !important;
    }

    #calculatorForm button[type="submit"],
    #calculatorForm button[type="button"]#clearFormBtn {
        flex: 1 !important;
        height: 44px !important;
        padding: 0.5rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #calculatorForm button[type="submit"] span,
    #calculatorForm button[type="button"]#clearFormBtn span {
        display: inline-block !important;
        font-size: 0.75rem !important;
        white-space: nowrap !important;
    }

    #calculatorForm button i {
        width: 16px !important;
        height: 16px !important;
        margin-right: 6px !important;
    }

    /* CRM Section - Stack vertically */
    #calculatorForm .grid.lg\:grid-cols-2 {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* CRM Cards */
    #calculatorForm .bg-white.rounded-xl.border.border-gray-200.shadow-sm {
        width: 100% !important;
    }

    /* Reading history card - reduced height */
    #calculatorForm .bg-white.rounded-xl.border.border-gray-200.shadow-sm.flex.flex-col.h-\[300px\] {
        height: 220px !important;
        min-height: 220px !important;
    }

    /* CRM Card internal padding */
    #calculatorForm .bg-white.p-4.rounded-xl {
        padding: 0.75rem !important;
    }

    /* CRM grid inside cards */
    #calculatorForm .grid.grid-cols-2.gap-4 {
        gap: 0.75rem !important;
    }

    #calculatorForm .grid.grid-cols-2.gap-4>div {
        width: 100% !important;
    }

    /* Observations textarea */
    #calculatorForm textarea {
        width: 100% !important;
        min-height: 80px !important;
        padding: 0.75rem !important;
        font-size: 14px !important;
    }

    /* Save Info button */
    #calculatorForm button[type="button"].px-6.py-2 {
        width: 100% !important;
        height: 44px !important;
    }
}

/* ==========================================================================
    SECTION 22: GRACEFUL VIEWPORT INTEGRATION (FAB, TOASTS, MODALS)
    ========================================================================== */

/* Body Stability - Prevents UI "jumps" on mobile pull-to-refresh */
body {
    overscroll-behavior-y: none;
    min-height: 100dvh;
}

/* 1. TOAST CONTAINER - Intelligent Stacking */
#toast-container {
    position: fixed;
    /* Respect bottom and right safe areas */
    bottom: max(24px, env(safe-area-inset-bottom, 24px));
    right: max(24px, env(safe-area-inset-right, 24px));
    z-index: 100000;
    /* Above FAB and Modals */
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.3s ease;
}

@media (max-width: 768px) {
    #toast-container {
        /* On mobile, stack TOASTS above the FAB area (~80px height) */
        bottom: calc(max(80px, env(safe-area-inset-bottom, 80px)) + 20px);
        right: max(16px, env(safe-area-inset-right, 16px));
        left: max(16px, env(safe-area-inset-left, 16px));
    }

    #toast-container>div {
        width: 100%;
        min-width: 0;
        box-shadow: var(--shadow-lg);
    }
}

/* 3. MODAL VIEWPORT INTEGRATION */
@media (max-width: 768px) {
    .modal-content {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-height: 94dvh !important;
        border-radius: 1.5rem 1.5rem 0 0 !important;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 20px)) !important;
        transform: translateY(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .modal-content.active {
        transform: translateY(0) !important;
    }

    /* ═══════════════════════════════════════════════════════
       QUICK LOAD + ADD-CLIENT modals — mobile bottom-sheet
       
       Problem: both modals have a "wrapper" div with
       class="fixed inset-0 z-10 w-screen overflow-hidden p-4 … flex …"
       that fights the outer overlay flexbox and clips content.
       
       Fix: neutralise the wrapper so only the outer overlay
       (the id="…Modal" div itself) controls layout.
       ═══════════════════════════════════════════════════════ */

    /* 1. Outer overlay → pin to bottom */
    #quickLoadModal,
    #addClientPipelineModal {
        align-items: flex-end !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    /* 2. Kill the wrapper completely */
    #quickLoadModal > div.fixed,
    #addClientPipelineModal > div.fixed {
        all: unset !important;          /* wipes every inline/Tailwind style */
        display: block !important;
        /* nothing else — it's now a transparent passthrough */
    }

    /* 3. The actual panel → full-width bottom-sheet */
    #quickLoadModal .pointer-events-auto,
    #addClientPipelineModal .pointer-events-auto {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 92dvh !important;
        border-radius: 1.25rem 1.25rem 0 0 !important;
        margin: 0 !important;
    }

    /* 4. Compact header (first child = header bar) */
    #quickLoadModal .pointer-events-auto > :first-child,
    #addClientPipelineModal .pointer-events-auto > :first-child {
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
    }

    /* 5. Compact search row (second child = search/filter bar) */
    #quickLoadModal .pointer-events-auto > :nth-child(2),
    #addClientPipelineModal .pointer-events-auto > :nth-child(2) {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* 6. Kill the "Active View: Newest First" label */
    .quick-load-sort-row {
        display: none !important;
    }
}

/* 4. AUTO-SUGGESTIONS & DROPDOWNS SAFETY */
#morning-search-results,
#editReferredBySuggestions,
.command-bar-results {
    max-height: calc(100dvh - 200px);
    /* Never grow past viewport */
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Ensure no clipping in the Brief Hero Card */
#brief-hero-card {
    z-index: 40;
    isolation: isolate;
    overflow: visible !important;
    /* Allow search results to flow out */
}

#morning-search-dropdown {
    z-index: 4000 !important;
}

/* ==========================================================================
    SECTION 23: PIPELINE CARDS MOBILE COMPACT MODE
    ========================================================================== */

@media (max-width: 768px) {

    /* Card compact mode - hide secondary info by default */
    .pipeline-card-compact .card-secondary-info {
        display: none !important;
    }

    .pipeline-card-compact .card-secondary-info.expanded {
        display: block !important;
    }

    /* Card title - single line */
    #pipeline-board .draggable h4,
    #pipeline-board .draggable .font-bold.text-sm {
        font-size: 0.8rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* Card meta info compact */
    #pipeline-board .text-xs.text-gray-500 {
        font-size: 0.65rem !important;
    }

    /* Expand indicator */
    .card-expand-btn {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f3f4f6;
        border-radius: 50%;
        font-size: 0.75rem;
        color: #9ca3af;
        cursor: pointer;
    }

    /* Hide expand indicator if actions are visible */
    #pipeline-board .draggable:hover .card-expand-btn,
    #pipeline-board .draggable.expanded .card-expand-btn {
        display: none;
    }

    /* Mobile column optimization */
    #pipeline-board .pipeline-col {
        min-width: 280px !important;
        max-width: 280px !important;
    }

    /* Column header compact */
    #pipeline-board .pipeline-col h3 {
        font-size: 0.8rem !important;
        padding: 0.5rem !important;
    }
}

@media (min-width: 1280px) {
    #pipeline-board {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 0.5rem !important;
    }

    #pipeline-board > div {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: none !important;
    }
}

@media (min-width: 1025px) and (max-width: 1279px) {
    /* Pipeline columns for laptop small screens (1025-1280px) */
    #pipeline-board {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 0.75rem !important;
        padding-bottom: 0.5rem !important;
    }

    #pipeline-board .pipeline-col,
    #pipeline-board > div {
        min-width: 200px !important;
        max-width: 220px !important;
        flex-shrink: 0 !important;
        flex-grow: 1 !important;
    }
    
    /* Smaller fonts for compact laptops */
    #pipeline-board .font-bold.text-sm {
        font-size: 0.75rem !important;
    }
    
    #pipeline-board .text-xs {
        font-size: 0.65rem !important;
    }
    
    #pipeline-board h4 {
        font-size: 0.7rem !important;
    }
}

/* ==========================================================================
    SECTION 24: PIPELINE HORIZONTAL SCROLL - SMOOTH & NON-GLITCHY
    ========================================================================== */

@media (max-width: 768px) {

    /* Main board container - horizontal scroll with momentum */
    #pipeline-board {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-behavior: smooth;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 0 8px;
        gap: 0;
        scroll-anchoring: none;
        transform: translateZ(0);
        will-change: scroll-position;
        scroll-padding-inline: 8px;
    }

    #pipeline-board::-webkit-scrollbar {
        display: none;
    }

    /* Columns - full-width snap on mobile */
    #pipeline-board .pipeline-col,
    #pipeline-board [ondrop] {
        scroll-snap-align: start;
        flex-shrink: 0;
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        scroll-padding: 0;
        border-radius: 0 0 1.25rem 1.25rem !important;
        box-sizing: border-box;
    }

    #pipeline-board .pipeline-col > div:first-child,
    #pipeline-board [ondrop] > div:first-child {
        padding: 0.75rem;
    }

    #pipeline-board .pipeline-col span[id^="count-"],
    #pipeline-board [ondrop] span[id^="count-"] {
        min-width: 1.75rem;
        min-height: 1.75rem;
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    /* Mobile tab bar */
    #pipeline-mobile-tabs {
        display: flex !important;
		justify-content: center;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 0.35rem;
        padding: 0.4rem 0.5rem;
        background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(250,252,249,0.92));
        border-bottom: 1px solid rgba(151, 184, 129, 0.12);
    }

    #pipeline-mobile-tabs::-webkit-scrollbar {
        display: none;
    }

    .pipeline-mobile-tab {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        min-height: 2.35rem;
        padding: 0.55rem 0.35rem;
        opacity: 0.62;
        transform: translateY(1px) scale(0.96);
        transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
        white-space: nowrap;
        min-width: 0;
        width: 100%;
    }

    .pipeline-mobile-tab-active {
        opacity: 1 !important;
        transform: scale(1) !important;
        box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
        border-color: rgba(151, 184, 129, 0.35) !important;
    }

    .pipeline-mobile-tab-label {
        line-height: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Column indicator dots */
    #pipeline-dots {
        display: flex;
        justify-content: center;
        gap: 6px;
        padding: 0.5rem 1rem;
        background: white;
        position: sticky;
        bottom: 0;
        z-index: 20;
        margin-top: 0;
        box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.04);
    }

    #pipeline-dots .dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #e5e7eb;
        cursor: pointer;
        transition: width, background-color 0.2s ease;
        flex-shrink: 0;
    }

    #pipeline-dots .dot:hover {
        background: #d1d5db;
    }

    #pipeline-dots .dot.active {
        background: var(--primary-color);
        width: 18px;
        border-radius: 3px;
    }

    /* Hide floating arrows on mobile */
    #ft-float-prev,
    #ft-float-next {
        display: none !important;
    }

    /* Prevent scroll snap on cards during drag */
    #pipeline-board.drag-active {
        scroll-snap-type: none;
    }
}

/* Mobile pipeline viewport fix:
   Keep the column selector bar visible above the board and let the board
   consume the remaining height so each column scrolls internally instead of
   forcing the whole page to grow. */
@media (max-width: 1024px) {
    #view-pipeline:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
        gap: clamp(0.75rem, 0.55rem + 0.7vw, 1rem);
    }

    #view-pipeline .section-page-header {
        flex: 0 0 auto;
        margin-bottom: 0 !important;
    }

    #pipeline-stats-bar {
        flex: 0 0 auto;
        margin-bottom: 0 !important;
    }

    #pipeline-mobile-tabs {
        order: 3;
        display: flex !important;
        flex: 0 0 auto;
        margin-top: 0.25rem;
        margin-bottom: 0.35rem;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
        position: relative;
        z-index: 25;
    }

    #pipeline-dots {
        order: 5;
        flex: 0 0 auto;
        margin-top: 0;
        margin-bottom: 0.35rem;
    }

    #pipeline-board-container {
        order: 4;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    #pipeline-calendar {
        order: 4;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    #pipeline-calendar:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
    }

    #pipeline-board {
        height: 100% !important;
        min-height: 0 !important;
    }

    #pipeline-board .pipeline-col {
        height: 100% !important;
    }
}

@media (max-width: 1024px) {
    #pipeline-mobile-tabs {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        align-items: stretch;
        overflow: hidden;
        justify-content: stretch;
    }

    .pipeline-mobile-tab {
        min-height: 2.5rem;
        font-size: 0.6rem;
        letter-spacing: 0.08em;
    }
}

@media (min-width: 1025px) {
    #view-pipeline:not(.hidden) {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: hidden !important;
        gap: clamp(1rem, 0.78rem + 0.45vw, 1.35rem);
    }

    #view-pipeline .section-page-header {
        margin-bottom: 0 !important;
    }

    #pipeline-stats-bar {
        margin-bottom: 0 !important;
    }

    #pipeline-board-container {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden;
    }

    #pipeline-board {
        height: 100% !important;
        min-height: 0 !important;
    }

    #pipeline-board .pipeline-col {
        height: 100% !important;
        min-height: 0 !important;
    }

    #pipeline-board .pipeline-col > div:last-child {
        min-height: 0 !important;
    }
}

/* Search clear button — Option 1: Fade + Scale (mockups/clear-button-animations.html) */
.search-clear-btn {
    transform: translateY(-50%) !important;
    transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.15s, color 0.15s !important;
}
.search-clear-btn.search-clear-hidden {
    opacity: 0 !important;
    transform: translateY(-50%) scale(0.4) !important;
    pointer-events: none !important;
}

/* ==========================================================================
    SECTION 25: HISTORY CARDS MOBILE - CONDENSED LAYOUT
   ========================================================================== */

@media (max-width: 640px) {

    /* Card container - 2 Row Layout */
    #historyTable tbody tr {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        margin-bottom: 0.75rem !important;
        padding: 0.75rem !important;
        background: white !important;
        border-radius: 12px !important;
        border: 1px solid #f3f4f6 !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    #historyTable tbody tr td {
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
    }

    /* Row 1: Serial # (Left) */
    #historyTable tbody tr td:nth-child(1) {
        order: 1;
        width: auto !important;
        min-width: 30px !important;
        padding-right: 0.5rem !important;
    }

    /* Row 1: Name (Fill) */
    #historyTable tbody tr td:nth-child(3) {
        /* ==========================================================================
   SECTION 25: HISTORY TABLE MOBILE - COMPACT ACTION BAR
   ========================================================================== */

        @media (max-width: 768px) {

            /* History Header - Mobile Search */
            #view-history .px-4.py-3.md\:px-6.md\:py-4 {
                padding: 0.75rem !important;
            }

            #view-history .relative.w-full.md\:w-64 {
                width: 100% !important;
            }

            #view-history #historySearchInput {
                min-height: 44px !important;
                padding: 12px 40px 12px 36px !important;
                font-size: 14px !important;
            }

            #view-history #historySearchInput+i {
                top: 50% !important;
                transform: translateY(-50%) !important;
            }

            #view-history #clearSearchBtn {
                top: 50% !important;
                transform: translateY(-50%) !important;
                right: 8px !important;
            }

            /* Re-Index button compact */
            #view-history button[title="Re-sort & Clean Database"] {
                padding: 10px 12px !important;
                min-height: 44px !important;
            }

            /* Card container - 2 Row Layout */
            #historyTable tbody tr {
                display: flex !important;
                flex-wrap: wrap !important;
                align-items: center !important;
                margin-bottom: 0.75rem !important;
                padding: 0.75rem !important;
                background: white !important;
                border-radius: 12px !important;
                border: 1px solid #f3f4f6 !important;
                box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
            }

            #historyTable tbody tr td {
                padding: 0 !important;
                border: none !important;
                background: transparent !important;
            }

            /* Row 1: Serial # (Left) */
            #historyTable tbody tr td:nth-child(1) {
                order: 1;
                width: auto !important;
                min-width: 30px !important;
                padding-right: 0.5rem !important;
            }

            /* Row 1: Name (Fill) */
            #historyTable tbody tr td:nth-child(3) {
                order: 2;
                flex: 1 0 50% !important;
                width: auto !important;
            }

            /* Hide extra columns */
            #historyTable tbody tr td:nth-child(2),
            #historyTable tbody tr td:nth-child(4),
            #historyTable tbody tr td:nth-child(5),
            #historyTable tbody tr td:nth-child(6) {
                display: none !important;
            }

            /* Row 2: Actions (Redesigned Grid for Mobile) */
            #historyTable tbody tr td:last-child {
                order: 3;
                flex: 1 0 100% !important;
                width: 100% !important;
                margin-top: 0.5rem !important;
                padding: 0.75rem 0 0.25rem 0 !important;
                border-top: 1px solid #f1f5f9 !important;
            }

            /* Multi-row action bar for touch safety */
            #historyTable tbody tr td:last-child .flex {
                display: grid !important;
                grid-template-columns: repeat(4, 1fr) !important;
                /* 4 columns */
                gap: 0.4rem !important;
                overflow: visible !important;
            }

            /* Uniform button sizes for the grid */
            #historyTable tbody tr td:last-child button {
                flex: none !important;
                width: 100% !important;
                height: 34px !important;
                padding: 0 !important;
                display: flex !important;
                align-items: center !important;
                justify-content: center !important;
                border-radius: 8px !important;
                background: #f8fafc !important;
                border: 1px solid #f1f5f9 !important;
            }

            /* Icon sizing */
            #historyTable tbody tr td:last-child button i {
                width: 16px !important;
                height: 16px !important;
                margin: 0 !important;
                flex-shrink: 0 !important;
                display: inline-flex !important;
                align-items: center !important;
                justify-content: center !important;
            }

            /* Hide dividers on mobile */
            #historyTable tbody tr td:last-child .w-px {
                display: none !important;
            }

            /* Touch feedback */
            #historyTable tbody tr td:last-child button:active {
                background: #e2e8f0 !important;
            }

            /* Button color variants */
            #historyTable tbody tr td:last-child button[title="Pin to Top"],
            #historyTable tbody tr td:last-child button[title="Unpin"] {
                background: #fef3c7 !important;
                color: #d97706 !important;
            }

            #historyTable tbody tr td:last-child button[title="Delete"] {
                background: #fef2f2 !important;
                color: #dc2626 !important;
            }

            #historyTable tbody tr td:last-child button[title="Load"] {
                background-color: var(--primary-color) !important;
                color: white !important;
            }

            /* History container bottom buttons - Grid Layout for Mobile */
            #historyButtons {
                padding: 0.75rem !important;
                display: grid !important;
                grid-template-columns: 1fr 1fr !important;
                /* Two equal columns */
                gap: 0.5rem !important;
                justify-content: stretch !important;
                padding-bottom: 3rem !important;
                /* Added padding to lift buttons up */
                margin-bottom: 1rem !important;
                /* Extra margin for safety */
            }

            #historyButtons button {
                flex: 1 1 auto !important;
                width: 100% !important;
                padding: 10px 8px !important;
                font-size: 11px !important;
                border-radius: 10px !important;
                min-height: 40px !important;
                justify-content: center !important;
                margin: 0 !important;
            }

            /* Make Sync button span full width if present */
            #manualSyncBtn:not(.hidden) {
                grid-column: span 2 !important;
                order: -1;
                /* Keep sync at top of the footer */
            }

            #historyButtons button i {
                width: 14px !important;
                height: 14px !important;
            }
        }

        /* ==========================================================================
    SECTION 26: INTELLIGENCE VIEW MOBILE HEIGHT
    ========================================================================== */

        @media (max-width: 768px) {

            /* Matrix height reduction */
            #view-intelligence .lg\:col-span-2 .bg-white.border.border-gray-200.rounded-2xl {
                height: 400px !important;
            }

            /* Insights panel stack below matrix */
            #view-intelligence .flex.flex-col.gap-6.h-\[600px\] {
                height: auto !important;
                flex-direction: column !important;
            }

            /* Radar chart compact */
            #view-intelligence .bg-gradient-to-br {
                min-height: 150px !important;
                padding: 1rem !important;
            }

            /* Insights list - scrollable */
            #user-insights-body {
                max-height: 200px !important;
                overflow-y: auto !important;
            }

            /* Filter buttons wrap if needed */
            #view-intelligence .flex.gap-2.flex-1 {
                flex-wrap: wrap !important;
            }

            /* Dimension toggle compact */
            #view-intelligence .flex.bg-gray-50.rounded-lg.p-1.gap-1 {
                gap: 0.25rem !important;
            }

            #view-intelligence .flex.bg-gray-50.rounded-lg.p-1.gap-1 button {
                padding: 0.4rem 0.75rem !important;
                font-size: 0.7rem !important;
            }
        }

        /* ==========================================================================
    SECTION 27: INFLUENCES GRID MOBILE
    ========================================================================== */

        @media (max-width: 480px) {

            /* Single column influences */
            #influencesGrid {
                grid-template-columns: 1fr !important;
                gap: 0.75rem !important;
                padding: 1rem !important;
            }

            #currentInfluencesBox {
                padding: 1rem !important;
            }

            #currentInfluencesBox h3 {
                font-size: 0.9rem !important;
            }
        }

        /* ==========================================================================
    SECTION 28: FUTURE TIMELINE MOBILE
    ========================================================================== */

        @media (max-width: 768px) {

            /* Timeline card width */
            #ft-track .bg-white.rounded-xl {
                min-width: 200px !important;
                max-width: 200px !important;
            }

            /* Timeline header */
            #futureTimelineContainer {
                padding: 0.5rem !important;
            }

            #futureTimelineContainer h3 {
                font-size: 0.9rem !important;
            }

            /* Navigation arrows - show on mobile */
            #ft-prev,
            #ft-next {
                width: 32px !important;
                height: 32px !important;
            }
        }

        /* ==========================================================================
    SECTION 38: MODERN MOBILE MODAL REFINEMENTS (GLOBAL)
    ========================================================================== */

        @media (max-width: 768px) {
            /* Refined Modal Headers for Mobile */
            .modal-content .border-b,
            #authModal .border-b,
            #editHistoryModal .border-b,
            #quickEditModal .border-b,
            #quickCalcModal .border-b,
            #addClientPipelineModal .border-b,
            #quickLoadModal .border-b,
            padding: 0.75rem 1rem !important;
            background: #ffffff !important;
        }

        .modal-content h3,
        #authModal h3,
        #editHistoryModal h3,
        #quickEditModal h3,
        #quickCalcModal h3,
        #addClientPipelineModal h3,
        #quickLoadModal h3 {
            font-size: 0.9rem !important;
        }

        /* Standardized labels for mobile forms */
        .modal-content label {
            font-size: 9px !important;
            margin-bottom: 0.25rem !important;
        }
    }

    .modal-content input,
    .modal-content select,
    .modal-content textarea,
    #authModal input,
    #authModal select,
    #editHistoryModal input,
    #editHistoryModal select,
    #quickEditModal input,
    #quickEditModal select,
    #quickCalcModal input,
    #addClientPipelineModal input,
    #quickLoadModal input {
        /* 44px + 16px: this block used to force 28px/12px, which silently defeated the
           touch-target + iOS no-zoom guard at the top of this media query. */
        min-height: 44px !important;
        height: 44px !important;
        padding: 0 0.75rem !important;
        font-size: 16px !important;
        background-color: #f9fafb !important;
        border-color: #f1f5f9 !important;
        border-radius: 0.4rem !important;
    }

    /* Specialized Textareas - Concise */
    textarea {
        height: auto !important;
        min-height: 44px !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 16px !important;
    }

    /* 5. MODAL FOOTERS */
    .modal-content .border-t,
    #authModal .p-4.border-t,
    #editHistoryModal .p-4.border-t,
    #quickEditModal .p-4.border-t,
    #quickCalcModal .p-4.border-t,
    #addClientPipelineModal .p-4.border-t,
    #quickLoadModal .p-4.border-t {
        padding: 0.75rem 1.25rem !important;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem)) !important;
    }

    /* Primary Action Buttons in Modals */
    .modal-content button[type="submit"],
    #quickEditModal button[onclick*="save"],
    #editHistoryModal button[onclick*="save"] {
        height: 40px !important;
        font-size: 14px !important;
        border-radius: 0.75rem !important;
    }
}

@media (max-width: 768px) {
    #secondaryStatsContainer {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    #secondaryStatsContainer .bg-white.p-5 {
        padding: 1rem !important;
    }

    #secondaryStatsContainer h4 {
        font-size: 0.75rem !important;
    }
}

/* ==========================================================================
    SECTION 30: RECENT PROFILES MOBILE
    ========================================================================== */

@media (max-width: 768px) {
    #recentProfilesList {
        gap: 0.5rem !important;
    }

    #recentProfilesList button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
}

/* ==========================================================================
    SECTION 31: HISTORY CARD SWIPE HINTS & ACTIONS
    ========================================================================== */

@media (max-width: 768px) {
    /* Swipe action overlay styles are already defined in Section 25 */

    /* Additional swipe feedback */
    .swipe-feedback {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        padding: 0.75rem 1rem;
        border-radius: 8px;
        font-size: 0.8rem;
        font-weight: 600;
        opacity: 0;
        transition: opacity 0.15s ease;
        pointer-events: none;
        z-index: 5;
    }

    .swipe-feedback.load-action {
        left: 0;
        background: rgba(151, 184, 129, 0.9);
        color: white;
    }

    .swipe-feedback.archive-action {
        right: 0;
        background: rgba(232, 141, 120, 0.9);
        color: white;
    }

    /* Show feedback when swiping */
    #historyTable tbody tr[data-swiping="left"] .swipe-feedback.archive-action {
        opacity: 1;
    }

    #historyTable tbody tr[data-swiping="right"] .swipe-feedback.load-action {
        opacity: 1;
    }

    /* Mobile card delete button */
    .mobile-delete-btn {
        position: absolute;
        right: 0.5rem;
        top: 50%;
        transform: translateY(-50%);
        width: 32px;
        height: 32px;
        display: none;
        align-items: center;
        justify-content: center;
        background: #fee2e2;
        border-radius: 50%;
        color: #dc2626;
        cursor: pointer;
        z-index: 15;
    }

    #historyTable tbody tr.expanded .mobile-delete-btn {
        display: flex;
    }
}

/* Hide dots on desktop */
@media (min-width: 1025px) {
    #pipeline-dots {
        display: none !important;
    }
}

/* ==========================================================================
    SECTION 33: MOBILE HEADER USER STATUS
    ========================================================================== */

@media (max-width: 768px) {
    #mobile-user-status {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    #mobile-user-status .user-status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #e5e7eb;
    }

    #mobile-user-status .user-status-dot.logged-in {
        background: #22c55e;
    }

    #mobile-user-status .user-status-dot.syncing {
        background: #f59e0b;
        animation: pulse 1s infinite;
    }
}

/* ==========================================================================
    SECTION 34: MOBILE FORM INPUT PLACEHOLDER HIDING
    ========================================================================== */

@media (max-width: 480px) {
    /* Hide placeholders on mobile for cleaner UI */
}

/* Ensure labels are always visible */
label {
    display: block !important;
}

/* ==========================================================================
    SECTION 35: MOBILE TOAST IMPROVEMENTS
    ========================================================================== */

@media (max-width: 768px) {
    #toast-container>div {
        max-width: 100% !important;
        width: calc(100% - 32px) !important;
    }
}

/* ==========================================================================
    SECTION 36: MOBILE FOOTER SAFE AREA
    ========================================================================== */

@media (max-width: 768px) {
    footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    .tab-content {
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* ==========================================================================
    SECTION 37: MOBILE DATE INPUT PICKER
    ========================================================================== */

@media (max-width: 768px) {

    /* Style native date picker on mobile */
    input[type="date"] {
        -webkit-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 40px !important;
    }
}

/* ==========================================================================
    SECTION 38: MOBILE ACTION BUTTON MINIMIZE
    ========================================================================== */

@media (max-width: 768px) {

    /* Hide button text, show only icons on small screens */
    .btn-icon-only {
        padding: 0.5rem !important;
    }

    .btn-icon-only span {
        display: none !important;
    }

    .btn-icon-only i {
        margin: 0 !important;
    }

    /* Apply to certain buttons in forms */
    #calculatorForm .bg-white.rounded-lg.font-bold.h-\[42px\] span,
    #calculatorForm button[type="button"].bg-white.hover\:bg-gray-50 span {
        display: none;
    }

    #calculatorForm button[type="button"].bg-white.hover\:bg-gray-50 {
        padding: 0.5rem !important;
    }
}

/* ==========================================================================
    SORT DROPDOWN STYLES (MODALS)
    ========================================================================== */

[id$="SortMenu"] {
    position: absolute;
    z-index: 100;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 140px;
    padding: 0.25rem 0;
}

[id$="SortMenu"] button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

[id$="SortMenu"] button:hover {
    background-color: #f3f4f6;
}

[id$="SortMenu"] button i {
    width: 12px;
    height: 12px;
    color: #9ca3af;
}

[id$="SortMenu"] button:hover i {
    color: var(--primary-color);
}

/* ==========================================================================
    SECTION 40: BRIEF DASHBOARD THEMES
    ========================================================================== */

#brief-hero-card {
    transition: background 1s ease, border-color 1s ease, transform 0.5s ease;
}

/* Vibrant, time-specific gradients on the Hero Card (12 Themes) - Sage Theme */
.brief-theme-1 {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.94) 0%, rgba(15, 23, 42, 0.96) 100%) !important;
    border-color: rgba(151, 184, 129, 0.18) !important;
    color: #e2e8f0 !important;
}

/* 00-02 Deep Night */
.brief-theme-2 {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.92) 0%, rgba(15, 23, 42, 0.94) 100%) !important;
    border-color: rgba(151, 184, 129, 0.16) !important;
    color: #e2e8f0 !important;
}

/* 02-04 Pre-Dawn */
.brief-theme-3 {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.90) 0%, rgba(30, 41, 59, 0.92) 100%) !important;
    border-color: rgba(151, 184, 129, 0.14) !important;
    color: #e2e8f0 !important;
}

/* 04-06 Dawn */
.brief-theme-4 {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.88) 0%, rgba(30, 41, 59, 0.90) 100%) !important;
    border-color: rgba(151, 184, 129, 0.12) !important;
    color: #e2e8f0 !important;
}

/* 06-08 Sunrise */
.brief-theme-5 {
    background: linear-gradient(135deg, rgba(240, 247, 236, 0.96) 0%, rgba(255, 255, 255, 0.98) 100%) !important;
    border-color: rgba(151, 184, 129, 0.28) !important;
}

/* 08-10 Morning */
.brief-theme-6 {
    background: linear-gradient(135deg, rgba(240, 247, 236, 0.94) 0%, rgba(255, 255, 255, 0.96) 100%) !important;
    border-color: rgba(151, 184, 129, 0.26) !important;
}

/* 10-12 Midday */
.brief-theme-7 {
    background: linear-gradient(135deg, rgba(240, 247, 236, 0.92) 0%, rgba(255, 255, 255, 0.94) 100%) !important;
    border-color: rgba(151, 184, 129, 0.24) !important;
}

/* 12-14 Afternoon */
.brief-theme-8 {
    background: linear-gradient(135deg, rgba(240, 247, 236, 0.90) 0%, rgba(255, 255, 255, 0.92) 100%) !important;
    border-color: rgba(151, 184, 129, 0.22) !important;
}

/* 14-16 Warm Afternoon */
.brief-theme-9 {
    background: linear-gradient(135deg, rgba(240, 247, 236, 0.88) 0%, rgba(255, 255, 255, 0.90) 100%) !important;
    border-color: rgba(151, 184, 129, 0.20) !important;
}

/* 16-18 Sunset Golden */
.brief-theme-10 {
    background: linear-gradient(135deg, rgba(240, 247, 236, 0.86) 0%, rgba(255, 255, 255, 0.88) 100%) !important;
    border-color: rgba(151, 184, 129, 0.18) !important;
}

/* 18-20 Sunset Orange */
.brief-theme-11 {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.86) 0%, rgba(30, 41, 59, 0.88) 100%) !important;
    border-color: rgba(151, 184, 129, 0.16) !important;
    color: #e2e8f0 !important;
}

/* 20-22 Evening */
.brief-theme-12 {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.88) 0%, rgba(15, 23, 42, 0.90) 100%) !important;
    border-color: rgba(151, 184, 129, 0.14) !important;
    color: #e2e8f0 !important;
}

/* 22-00 Night */

/* Dark mode text overrides for nighttime themes (Themes 1-4) */
.brief-theme-1 h1,
.brief-theme-1 h1 span,
.brief-theme-1 p,
.brief-theme-1 #morning-date-display,
.brief-theme-2 h1,
.brief-theme-2 h1 span,
.brief-theme-2 p,
.brief-theme-2 #morning-date-display,
.brief-theme-3 h1,
.brief-theme-3 h1 span,
.brief-theme-3 p,
.brief-theme-3 #morning-date-display,
.brief-theme-4 h1,
.brief-theme-4 h1 span,
.brief-theme-4 p,
.brief-theme-4 #morning-date-display {
    color: white !important;
}

/* Adjust Input and Sub-card for dark themes */
.brief-theme-1 #morning-quick-search,
.brief-theme-2 #morning-quick-search,
.brief-theme-3 #morning-quick-search,
.brief-theme-4 #morning-quick-search {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.brief-theme-1 #morning-quick-search::placeholder,
.brief-theme-2 #morning-quick-search::placeholder,
.brief-theme-3 #morning-quick-search::placeholder,
.brief-theme-4 #morning-quick-search::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

.brief-theme-1 .group i,
.brief-theme-2 .group i,
.brief-theme-3 .group i,
.brief-theme-4 .group i {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Practitioner Vibe Sub-card Adjustment */
.brief-theme-1 #morning-practitioner-vibe,
.brief-theme-2 #morning-practitioner-vibe,
.brief-theme-3 #morning-practitioner-vibe,
.brief-theme-4 #morning-practitioner-vibe {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

.brief-theme-1 #morning-practitioner-vibe *,
.brief-theme-2 #morning-practitioner-vibe *,
.brief-theme-3 #morning-practitioner-vibe *,
.brief-theme-4 #morning-practitioner-vibe * {
    color: white !important;
}

/* Background Hero Icon Adjustment */
.brief-theme-1 #morning-hero-icon,
.brief-theme-2 #morning-hero-icon,
.brief-theme-3 #morning-hero-icon,
.brief-theme-4 #morning-hero-icon {
    color: white !important;
    opacity: 0.15 !important;
}

/* Themed card & section borders for depth inside the view */
.brief-theme-1 section,
.brief-theme-1 .bg-white {
    border-color: #334155 !important;
}

.brief-theme-2 section,
.brief-theme-2 .bg-white {
    border-color: #4338ca !important;
}

.brief-theme-3 section,
.brief-theme-3 .bg-white {
    border-color: #7c3aed !important;
}

.brief-theme-4 section,
.brief-theme-4 .bg-white {
    border-color: #c2410c !important;
}

.brief-theme-5 section,
.brief-theme-5 .bg-white {
    border-color: #dcfce7 !important;
}

.brief-theme-6 section,
.brief-theme-6 .bg-white {
    border-color: #cffafe !important;
}

.brief-theme-7 section,
.brief-theme-7 .bg-white {
    border-color: #fef9c3 !important;
}

.brief-theme-8 section,
.brief-theme-8 .bg-white {
    border-color: #fef3c7 !important;
}

.brief-theme-9 section,
.brief-theme-9 .bg-white {
    border-color: #fee2e2 !important;
}

.brief-theme-10 section,
.brief-theme-10 .bg-white {
    border-color: #ffedd5 !important;
}

.brief-theme-11 section,
.brief-theme-11 .bg-white {
    border-color: #ede9fe !important;
}

.brief-theme-12 section,
.brief-theme-12 .bg-white {
    border-color: #e2e8f0 !important;
}

/* ==========================================================================
    SECTION 41: skeleton LOADERS
   ========================================================================== */

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.animate-pulse {
    animation: none;
}

/* Batch 1b: `.skeleton-bg/-card/-line/-avatar/-rect` removed — unreferenced
   in the app; the `.sk-*` classes in skeleton.css are the live system. */

/* ==========================================================================
    SECTION 42: PIPELINE SMART ENHANCEMENTS
   ========================================================================== */

/* Idea 7: Loyalty Glow */
.loyalty-silver {
    border: 1px solid #cbd5e1 !important;
    background-color: #f8fafc !important;
}

.loyalty-silver h5 {
    color: #475569 !important;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
}

.loyalty-gold {
    border: 1px solid #fde68a !important;
    background-color: #fffbeb !important;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.1);
}

.loyalty-gold h5 {
    color: #b45309 !important;
    text-shadow: 0 0 1px rgba(217, 119, 6, 0.2);
}

/* Idea 11: Financial Leak Pulse — static badge; the animated glow was
   removed for performance and the dead keyframe along with it. */
.financial-leak-badge {
    background-color: #fee2e2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca !important;
}

/* Inquiry Card */
.reading-inquiry {
    background-color: #f5f3ff !important;
}

.reading-inquiry::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #4f46e5;
}

/* Scheduled Card (Future) */
.reading-scheduled {
    background-color: #f0f9ff !important;
    border-left-color: #0284c7 !important;
}

.reading-scheduled::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #0284c7;
}

/* Scheduled Card (Today) */
.reading-scheduled-today {
    background-color: #e0f2fe !important;
    border-left-color: #0369a1 !important;
}

.reading-scheduled-today::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #0369a1;
    opacity: 0.9;
}

@keyframes today-glow {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* In Progress Card */
.reading-in-progress {
    background-color: #fffbeb !important;
}

.reading-in-progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #d97706;
}

/* Completed Card */
.reading-completed {
    background-color: #f0fdf4 !important;
}

.reading-completed::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #059669;
}

/* Time Conflict Indicator — vibrant warning orange (not faded) */
.time-conflict-warning {
    border-color: #ea580c !important;
    border-left-color: #ea580c !important;
    background-color: #fff7ed !important;
    box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.18), 0 2px 8px rgba(234, 88, 12, 0.22);
    animation: none;
}
.clash-badge {
    background-color: #ea580c !important;
    color: white !important;
    animation: none;
    border: 1px solid rgba(255,255,255,0.5);
    font-weight: 800;
}
@keyframes clash-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
@keyframes clash-badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* Missed Scheduled Reading */
.reading-missed {
    background-color: #fff1f2 !important;
    border-left-color: #e11d48 !important;
}

.reading-missed::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #e11d48;
}

.missed-badge {
    background-color: #e11d48 !important;
    color: white !important;
    animation: none;
}

@keyframes missed-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

.today-badge {
    background-color: #0284c7 !important;
    color: white !important;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.4);
}

/* Tomorrow's scheduled time: gold-on-gold was ~2.2:1. Deep amber text on the same soft
   tint keeps the "upcoming" look and clears 5.8:1; dark mode gets a light gold on a
   darker tint instead of Tailwind's yellow-900 wash. */
.tomorrow-badge {
    background-color: var(--sun-light) !important;
    color: #7a5c0f !important;
    border: 1px solid #d9b95a !important;
}

html.dark .tomorrow-badge {
    background-color: rgba(236, 212, 137, 0.16) !important;
    color: #f4d98a !important;
    border-color: rgba(236, 212, 137, 0.45) !important;
}

/* ==========================================================================
   SECTION 32: MICRO-INTERACTIONS & VIBRATIONAL ANIMATIONS (V1.0.9)
   ========================================================================== */

/* Idea 2: Growth Transitions (Staggered Chart) - Optimized with CSS-only stagger */
.essence-row-animate {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

.essence-rows-trigger .essence-row-animate {
    opacity: 1;
    transform: translateY(0);
}

.essence-rows-trigger .essence-row-animate:nth-child(1) { transition-delay: 0.02s; }
.essence-rows-trigger .essence-row-animate:nth-child(2) { transition-delay: 0.04s; }
.essence-rows-trigger .essence-row-animate:nth-child(3) { transition-delay: 0.06s; }
.essence-rows-trigger .essence-row-animate:nth-child(4) { transition-delay: 0.08s; }
.essence-rows-trigger .essence-row-animate:nth-child(5) { transition-delay: 0.10s; }
.essence-rows-trigger .essence-row-animate:nth-child(6) { transition-delay: 0.12s; }
.essence-rows-trigger .essence-row-animate:nth-child(7) { transition-delay: 0.14s; }
.essence-rows-trigger .essence-row-animate:nth-child(8) { transition-delay: 0.16s; }
.essence-rows-trigger .essence-row-animate:nth-child(9) { transition-delay: 0.18s; }
.essence-rows-trigger .essence-row-animate:nth-child(10) { transition-delay: 0.20s; }
.essence-rows-trigger .essence-row-animate:nth-child(n+11) { transition-delay: 0.22s; }

/* Idea 3: Magnetic Kanban */
.draggable {
    cursor: grab;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                box-shadow 0.2s ease, 
                opacity 0.2s ease;
}

.draggable:active {
    cursor: grabbing;
}

.draggable.dragging {
    transform: scale(1.05) rotate(1deg) !important;
    box-shadow: var(--shadow-xl) !important;
    opacity: 0.9 !important;
    z-index: 1000;
}

/* Odometer / Counter Animation */
@keyframes countUp {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.revenue-counter-update {
    animation: countUp 0.3s ease-out forwards;
}

/* Idea 4: Insight Glow (Ruler Effect) */
#resultsTable tbody tr {
    transition: background-color 0.15s ease;
}

/* Idea 5: Success Ripple */
.success-ripple-container {
    position: relative;
    overflow: hidden;
}

@keyframes success-ripple {
    0% { transform: scale(0); opacity: 0.5; }
    100% { transform: scale(4); opacity: 0; }
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background-color: var(--secondary-color);
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    animation: success-ripple 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 10;
}

/* UI Feedback for Action */
.action-confirmed-pop {
    animation: popScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popScale {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.pb-safe-bottom {
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* ==========================================================================
    SECTION 44: RESPONSIVENESS PLAN - PHASE 1 (Foundation & Global)
    ========================================================================== */

/* 1.1 Standardized Breakpoint Utilities */
/* Already using Tailwind defaults - xs:480px, sm:640px, md:768px, lg:1024px, xl:1280px, 2xl:1536px */

/* 1.2 Modal System Overhaul */
.modal-container {
    inset: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 
            env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.modal-panel {
    max-height: calc(100dvh - 2rem);
    max-width: min(560px, calc(100vw - 1rem));
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Mobile-specific modal behavior */
@media (max-width: 640px) {
    .modal-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 85dvh;
        border-radius: 1.5rem 1.5rem 0 0;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .modal-panel.active {
        transform: translateY(0);
    }
    
    .modal-content {
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }
}

/* Modal backdrop scroll prevention */
.modal-backdrop-scroll-lock {
    overflow: hidden;
}

.modal-backdrop-scroll-lock body {
    overflow: hidden;
    height: 100dvh;
}

/* 1.3 Touch Target Standards */
@media (pointer: coarse) {
    button, 
    [role="button"],
    .clickable,
    select {
        min-height: 44px;
        min-width: 44px;
    }

    /* Checkboxes/radios stay glyph-sized — the wrapping label is the tap target.
       A 44px box rendered as a giant checkbox (e.g. "Keep me signed in"). */
    input[type="checkbox"],
    input[type="radio"] {
        min-height: 24px;
        min-width: 24px;
    }
    
    .tap-target-lg {
        min-height: 56px;
    }
    
    /* Larger touch targets for small interactive elements */
    .pipeline-card[draggable="true"] {
        touch-action: pan-x pan-y;
    }
}

/* 1.4 Foldable Device Support */
@supports (height: 100dvh) {
    .viewport-full {
        height: 100dvh;
    }
    
    .modal-max-height {
        max-height: calc(100dvh - 2rem);
    }
}

@supports (height: 100svh) {
    .sheet-handle {
        height: 100svh;
    }
}

/* ==========================================================================
    SECTION 45: RESPONSIVENESS PLAN - PHASE 2 (View-Specific)
    ========================================================================== */

/* 2.1 Morning Brief Dashboard */
#brief-hero-card {
    min-height: auto;
    padding: 2rem;
}

@media (max-width: 640px) {
    #brief-hero-card {
        flex-direction: column;
        padding: 1.5rem;
    }
    
    #morning-quick-search {
        font-size: 16px;
    }
    
    #morning-practitioner-vibe {
        width: 100%;
        justify-content: center;
        flex-wrap: nowrap;
    }
}

/* Search Results Dropdown */
#morning-search-results,
#editReferredBySuggestions,
.command-bar-results {
    max-height: min(300px, calc(100dvh - 200px));
}

/* 2.2 Essence Calculator */
@media (max-width: 480px) {
    #calculatorForm .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    #calculatorForm input,
    #calculatorForm select {
        width: 100%;
    }
}

/* Core Numbers Cards — Bento + Classic (Option 7) exact mock */
#cardsContainer {
    grid-template-columns: 1fr;
}
@media (min-width: 380px) {
    #cardsContainer {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 768px) {
    #cardsContainer {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* 2.3 Essence Chart Table - Enhanced */
@media (max-width: 640px) {
    #resultsTable {
        font-size: var(--table-font-size) !important;
    }
    
    #resultsTable th,
    #resultsTable td {
        padding: 0.35rem 0.15rem;
        white-space: nowrap;
    }
    
    #resultsTable td:first-child,
    #resultsTable th:first-child {
        position: sticky;
        left: 0;
        z-index: 30;
        background: white;
    }
    
    .current-year-row {
        background: var(--secondary-light) !important;
    }
}

/* 2.4 Reading Pipeline */
@media (max-width: 768px) {
    #pipeline-board {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding: 0 0.5rem;
        gap: 0.75rem !important;
    }
    
    .pipeline-column {
        min-width: 85vw;
        scroll-snap-align: center;
        margin: 0 8px;
    }
    .pipeline-column:first-child {
        margin-left: 0;
    }
    .pipeline-column:last-child {
        margin-right: 0;
    }
    .pipeline-card {
        min-height: 100px;
        padding: 0.75rem;
    }
    
    .pipeline-card[draggable="true"] {
        touch-action: pan-x pan-y;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .pipeline-column {
        min-width: 280px;
    }
}

/* Pipeline Carousel Dots */
#pipeline-dots {
    pointer-events: auto;
}

#pipeline-dots .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d1d5db;
    transition: width, background-color 0.2s ease;
    border: none;
    padding: 0;
    cursor: pointer;
}

#pipeline-dots .dot:hover {
    background: #9ca3af;
}

#pipeline-dots .dot.active {
    background: #97B841;
    width: 24px;
    border-radius: 9999px;
}

/* 2.5 Lo-Shu Grid */
#loshu-grid-display {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
}

@media (max-width: 480px) {
    #loshu-grid-display {
        max-width: 240px;
        gap: 8px;
        padding: 12px;
    }
    
    #loshu-grid-display > div {
        font-size: 1.25rem;
    }
    
    #loshu-kua-number {
        font-size: 2.5rem;
    }
}

/* Planes Grid */
#loshu-planes-container {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    #loshu-planes-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .plane-card {
        padding: 0.75rem;
    }
}

/* 2.6 Revenue Analytics */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

@media (min-width: 768px) {
    .chart-container {
        height: 400px;
    }
}

@media (min-width: 1280px) {
    .chart-container {
        height: 500px;
    }
}

.revenue-metric-card {
    padding: 1rem;
}

@media (min-width: 768px) {
    .revenue-metric-card {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .revenue-metric-card {
        padding: 1rem;
    }
    
    .revenue-value {
        font-size: 1.5rem;
    }
}

/* 2.7 Mobile & Name Analysis Tabs */
.analysis-tabs {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.analysis-tabs button {
    flex-shrink: 0;
    scroll-snap-align: start;
}

@media (max-width: 480px) {
    .analysis-tabs button {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* ==========================================================================
    SECTION 46: RESPONSIVENESS PLAN - PHASE 3 (Navigation & Shell)
    ========================================================================== */

/* 3.1 Sidebar Navigation */
@media (max-width: 1024px) {
    aside:not(#rail-sidebar) {
        position: fixed;
        z-index: 50;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    aside:not(#rail-sidebar).active {
        transform: translateX(0);
    }
}

@media (min-width: 1024px) {
    aside:not(#rail-sidebar) {
        position: relative;
        transform: none;
    }
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Touch swipe support */
@media (max-width: 1024px) {
    main {
        touch-action: pan-y;
    }
}

/* 3.2 Header Responsiveness */
header {
    position: sticky;
    top: 0;
    z-index: 30;
    padding-top: env(safe-area-inset-top);
}

@media (max-width: 640px) {
    header {
        height: auto;
        min-height: 60px;
    }
    
    #top-client-name {
        max-width: 80px;
    }
}

/* ==========================================================================
    SECTION 47: RESPONSIVENESS PLAN - PHASE 4 (Accessibility & Edge Cases)
    ========================================================================== */

/* 4.1 Reduced Motion Support — the single motion contract for the app.
   Two ways in, both resolve to the same behaviour:
     · the OS preference (prefers-reduced-motion), honoured unless the user
       explicitly opts back in with html[data-motion="full"], and
     · html[data-motion] set by the app's motion manager (auto/full/reduced/off).
   'reduced' collapses motion to its end state; 'off' removes it outright. */
@media (prefers-reduced-motion: reduce) {

    html:not([data-motion="full"]) *,
    html:not([data-motion="full"]) *::before,
    html:not([data-motion="full"]) *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
    animation: none !important;
    transition: none !important;
}

/* Nothing on screen to animate while the tab is backgrounded.
   Pairs with the visibilitychange listener in app_bootstrap.js. */
html[data-app-hidden] *,
html[data-app-hidden] *::before,
html[data-app-hidden] *::after {
    animation-play-state: paused !important;
}

/* 4.2 High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-strong: #000;
        --text-primary: #000;
    }
    
    button, input, select {
        border-width: 2px;
    }
    
    .border {
        border-width: 2px;
    }
}

/* 4.3 Focus Visible for Keyboard Navigation */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* ==========================================================================
    SECTION 48: RESPONSIVENESS PLAN - PHASE 5 (Validation Fixes)
    ========================================================================== */

/* 5.1 No Horizontal Scroll at 320px */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* 5.2 All Touch Targets Minimum 36x36px */
@media (pointer: coarse) {
    .nav-item,
    .quick-action-btn,
    .pipeline-card button,
    #historyTable tbody tr td:last-child button {
        min-height: 36px;
        min-width: 36px;
    }
}

/* 5.3 Modal Scrollable Without Background Scroll */
.modal-open {
    overflow: hidden;
}

/* 5.4 Table Readable with Sticky Headers */
#resultsTable thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: white;
}

#resultsTable thead th:first-child {
    z-index: 40;
}

/* 5.5 No Content Hidden Behind Fixed Headers */
main {
    padding-top: max(80px, env(safe-area-inset-top));
}

@media (min-width: 768px) {
    main {
        padding-top: 1rem;
    }
}

/* ==========================================================================
    SECTION 49: PRINT STYLES ENHANCEMENT
    ========================================================================== */

@media print {
    .no-print { display: none !important; }
    main { 
        padding: 0 !important; 
        overflow: visible !important;
    }
    #resultsTable {
        font-size: var(--table-font-size) !important;
        width: 100% !important;
    }
    
    #resultsTable th,
    #resultsTable td {
        padding: 0.25rem !important;
    }
}

/* ==========================================================================
    SECTION 50: ADDITIONAL RESPONSIVENESS UTILITIES
    ========================================================================== */

/* Safe Area Utilities */
.pb-safe {
    padding-bottom: env(safe-area-inset-bottom);
}

.pt-safe {
    padding-top: env(safe-area-inset-top);
}

.pl-safe {
    padding-left: env(safe-area-inset-left);
}

.pr-safe {
    padding-right: env(safe-area-inset-right);
}

/* Viewport-Height Utilities */
.h-dvh {
    height: 100dvh;
}

.h-svh {
    height: 100svh;
}

.max-h-dvh {
    max-height: 100dvh;
}

/* Touch Action Utilities */
.touch-none {
    touch-action: none;
}

.touch-pan-y {
    touch-action: pan-y;
}

/* Scroll Snap Utilities */
.snap-x {
    scroll-snap-type: x mandatory;
}

.snap-center {
    scroll-snap-align: center;
}

/* Mobile First Grid Defaults */
.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

/* Responsive Grid Generators */
@media (min-width: 640px) {
    .sm\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .md\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ponytail: Fluid section width and grid utilities removed — original max-w-6xl + fixed grids restored */

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

/* ==========================================================================
    SECTION 51: FINAL VALIDATION CHECKLIST STYLES
    ========================================================================== */

/* Mobile 320px Clean */
@media (max-width: 320px) {
    .p-4, .p-6, .p-8 {
        padding: 0.75rem !important;
    }
    
    button {
        padding: 0.5rem 0.75rem;
    }
    
    .text-sm {
        font-size: 0.7rem;
    }
}

/* Tablet Responsive */
@media (min-width: 481px) and (max-width: 768px) {
    .tab-content {
        padding: 1rem;
    }
}

/* Desktop Clean */
@media (min-width: 1024px) {
    main {
        max-width: 100%;
    }
}

/* Ultra-Wide Centered */
@media (min-width: 1536px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    /* Pipeline: Large screens - ensure comfortable gap */
    #pipeline-board {
        gap: 0.5rem !important;
    }
}

/* End of Responsiveness Plan Styles */

/* Task 1.3: Mobile Header Safe Area Padding */
@media (max-width: 768px) {
    .mobile-header {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    
    .tab-content {
        padding-top: calc(80px + env(safe-area-inset-top, 0px));
    }
}

/* Task 3.1: Mobile-Optimized Form Inputs */
@media (max-width: 480px) {
    /* Use fluid typography */
    #calculatorForm label {
        font-size: 0.75rem;
    }
    
    /* Better input spacing */
    #calculatorForm input,
    #calculatorForm select {
        min-height: 48px;
        padding: 12px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    /* Stack all form fields */
    #calculatorForm .grid {
        gap: 1rem;
    }
}

/* Task 4.1: Enhanced Table Scrolling */
.table-container {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Horizontal scroll hint */
.table-scroll-hint {
    position: sticky;
    right: 0;
    background: linear-gradient(to right, transparent, white 20%);
    padding: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.table-container:hover .table-scroll-hint,
.table-container.scrolling .table-scroll-hint {
    opacity: 1;
}

/* Task 5.1: Bottom Sheet Modal Fixes */
@media (max-width: 768px) {
    .modal-content {
        max-height: 92dvh;
        border-radius: 1.5rem 1.5rem 0 0;
        transform: translateY(0) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .modal-content.closing {
        transform: translateY(100%) !important;
    }
    
    /* Safe area for modal footer */
    .modal-footer {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* Task 4.3: Sticky Column Fix */
#resultsTable th:first-child,
#resultsTable td:first-child {
    position: sticky;
    left: 0;
    z-index: 30;
    background: white;
}

/* Add shadow to indicate more content */
#resultsTable th:first-child::after,
#resultsTable td:first-child::after {
    content: '';
    position: absolute;
    right: -3px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to right, rgba(0,0,0,0.1), transparent);
}

/* ==========================================================================
    SECTION 42: ANIMATIONS
    ========================================================================== */

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.skeleton-once {
    animation: skeleton-pulse 1.5s ease-in-out 1;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.animate-shake {
    animation: shake 0.3s ease-in-out;
}

/* --- Essence Chart Smart Highlights --- */
.hl-age, .hl-age-force { background-color: #97B881 !important; background: #97B881 !important; color: white !important; }
.hl-py-calendar, .hl-py-calendar-force { background-color: #E88D78 !important; background: #E88D78 !important; color: white !important; }
.hl-py-birthday, .hl-py-birthday-force { background-color: #7da066 !important; background: #7da066 !important; color: white !important; }
.hl-essence { background-color: #97B881 !important; background: #97B881 !important; color: white !important; }
.hl-hidden { background-color: #7da066 !important; background: #7da066 !important; color: white !important; }

/* Dual PY Indicator */
.py-dual-indicator {
    position: relative;
}
.py-dual-indicator::after {
    content: '⬌';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #E88D78;
    z-index: 20;
}

@keyframes scale-in {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes slide-up {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.animate-scale-in { animation: scale-in 0.3s ease-out forwards; }
.animate-fade-in { animation: fade-in 0.2s ease-out forwards; }
.animate-slide-up { animation: slide-up 0.3s ease-out forwards; }

/* --------------------------------------------------------------------------
   Smooth Section Entrance (Tab Switch)
   -------------------------------------------------------------------------- */
@keyframes section-enter {
    0% {
        opacity: 0;
        transform: translateY(6px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-section-enter {
    animation: section-enter 0.22s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

/* Subtle stagger for major child blocks inside an entering section */
.animate-section-enter > .section-page-header,
.animate-section-enter > .section-shell-card,
.animate-section-enter > .metrics-card,
.animate-section-enter > .bg-white.rounded-2xl,
.animate-section-enter > .bg-white.rounded-xl,
.animate-section-enter > section,
.animate-section-enter > .grid > div {
    animation: none;
}

.animate-section-enter > .section-page-header { animation-delay: 0.04s; }
.animate-section-enter > .section-shell-card { animation-delay: 0.08s; }
.animate-section-enter > .metrics-card { animation-delay: 0.10s; }
.animate-section-enter > .bg-white.rounded-2xl { animation-delay: 0.12s; }
.animate-section-enter > .bg-white.rounded-xl { animation-delay: 0.14s; }
.animate-section-enter > section:nth-of-type(1) { animation-delay: 0.06s; }
.animate-section-enter > section:nth-of-type(2) { animation-delay: 0.12s; }
.animate-section-enter > section:nth-of-type(3) { animation-delay: 0.18s; }
.animate-section-enter > section:nth-of-type(4) { animation-delay: 0.24s; }
.animate-section-enter > .grid > div:nth-child(1) { animation-delay: 0.08s; }
.animate-section-enter > .grid > div:nth-child(2) { animation-delay: 0.14s; }
.animate-section-enter > .grid > div:nth-child(3) { animation-delay: 0.20s; }
.animate-section-enter > .grid > div:nth-child(4) { animation-delay: 0.26s; }

@keyframes section-enter-child {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   SECTION 40: RESPONSIVE SECTION HEADERS (ENHANCEMENT PLAN)
   ========================================================================== */

/* Responsive Section Headers */
.section-header {
    @apply flex items-center gap-3 mb-6;
}

.section-header-icon {
    @apply bg-sage/10 p-2 rounded-lg text-sage-dark hidden md:flex;
}

.section-title {
    @apply font-bold text-gray-800 font-heading;
}

.section-subtitle {
    @apply text-xs text-gray-500;
}

/* Tablet Adjustments */
@media (max-width: 1024px) {
    .section-header {
        @apply mb-4;
    }
    .section-header-icon {
        @apply p-1.5;
    }
    .section-title {
        @apply text-xl;
    }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .section-header {
        @apply flex-col items-start gap-2 mb-4;
    }
    .section-header-icon {
        @apply hidden;
    }
    .section-title {
        @apply text-lg;
    }
    .section-subtitle {
        @apply text-[10px];
    }
}

/* Standard Section Card Header */
.section-card-header {
    @apply flex items-center justify-between mb-4;
}

.section-card-title {
    @apply font-bold text-gray-700 flex items-center gap-2 text-sm;
}

.section-card-meta {
    @apply text-[10px] font-bold text-gray-400 uppercase tracking-widest;
}

.aurora-search {
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 9999px;
    padding: 0.625rem 3rem 0.625rem 2.75rem;
    width: 100%;
    font-size: 0.875rem;
    color: #1f2937;
    outline: none;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.25s ease;
}
.aurora-search:focus {
    background: #ffffff;
    border-color: rgba(151, 184, 129, 0.4);
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.15);
}
.aurora-search::placeholder {
    color: #9ca3af;
}
.aurora-go-btn {
    background: rgba(151, 184, 129, 0.15);
    border: none;
    border-radius: 9999px;
    padding: 0.375rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #5b8c4a;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.2s ease;
}
.aurora-go-btn:hover {
    background: rgba(151, 184, 129, 0.25);
}
.aurora-search-wrap {
    position: relative;
}

/* ==========================================================================
   SECTION 55: APP SHELL SAAS UPGRADE
   Shared late overrides for a more premium responsive frame.
   ========================================================================== */

:root {
    --shell-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(250, 252, 249, 0.96) 100%);
    --shell-card-bg: rgba(255, 255, 255, 0.99);
    --shell-border: rgba(148, 163, 184, 0.18);
    --shell-border-strong: rgba(151, 184, 129, 0.2);
    --shell-shadow: 0 18px 44px -24px rgba(15, 23, 42, 0.28);
    --shell-shadow-strong: 0 28px 60px -28px rgba(15, 23, 42, 0.32);
    --shell-content-width: clamp(72rem, 64rem + 5.33vw, 110rem); /* ponytail: fluid, 1680px at 1920px viewport, scales to ~1760px on ultra-wide */
}

body.app-shell {
    position: relative;
    min-height: 100dvh;
    background:
        radial-gradient(circle at top left, rgba(151, 184, 129, 0.16), transparent 30%),
        radial-gradient(circle at 85% 12%, rgba(143, 184, 202, 0.12), transparent 24%),
        radial-gradient(circle at bottom right, rgba(232, 141, 120, 0.11), transparent 26%),
        linear-gradient(180deg, #f8fbf6 0%, #f4f8f4 48%, #f8faf9 100%);
}

.app-shell-main,
.app-shell-rail,
.app-shell-header,
.app-shell-mobile-header,
.app-shell-mobile-nav,
.app-shell-drawer {
    position: relative;
    z-index: 1;
}

/* Ensure main content fills remaining space without overflow */
.app-shell-main {
    min-width: 0;
    flex: 1 1 0;
}

/* Ensure sidebar never overlaps content */
.app-shell-rail {
    flex-shrink: 0;
    position: relative;
    z-index: 40;
}

.app-shell-main {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
        transparent;
}

.app-shell-header,
.app-shell-mobile-header,
.app-shell-mobile-nav,
.app-shell-drawer,
.app-shell-rail {
    background: var(--shell-bg) !important;
    border-color: var(--shell-border) !important;
}

.app-shell-rail {
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.7), var(--shell-shadow);
}

.app-shell-header,
.app-shell-mobile-header {
    box-shadow: none;
}

.app-shell-mobile-nav {
    box-shadow: none;
}

.app-shell-drawer {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 251, 247, 0.98)) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.88);
}

.rail-sidebar {
    width: clamp(15.5rem, 15rem + 0.8vw, 17rem);
}

.rail-sidebar .sidebar-sync-panel {
    padding: 0.5rem;
}

.rail-sidebar .sidebar-sync-panel .sync-panel-inner {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 248, 244, 0.94));
    border: 1px solid rgba(151, 184, 129, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 16px 32px -26px rgba(15, 23, 42, 0.35);
}

.app-shell-header,
.app-shell-mobile-header {
    border-bottom-color: rgba(148, 163, 184, 0.16) !important;
}

.app-shell-header #headerTitle {
    letter-spacing: -0.02em;
}

.nav-item {
    min-height: 2.5rem;
    border-left: 0;
    border: 1px solid transparent;
    border-radius: 1rem;
    color: #475569;
}

.nav-item:hover {
    background-color: rgba(151, 184, 129, 0.12);
    border-color: rgba(151, 184, 129, 0.20);
    color: var(--primary-dark);
    transform: none;
}

.nav-item.bg-sage-light {
    background: linear-gradient(135deg, rgba(232, 141, 120, 0.18), rgba(255, 255, 255, 0.98)) !important;
    border: 1px solid rgba(232, 141, 120, 0.20);
    color: var(--secondary-dark);
    box-shadow: 0 16px 24px -24px rgba(232, 141, 120, 0.9);
}

.nav-item.bg-sage-light::after {
    display: none;
}

.rail-sidebar .nav-item.bg-sage-light::before {
    top: 20%;
    height: 60%;
    width: 4px;
    box-shadow: 0 0 12px rgba(232, 141, 120, 0.35);
}

/* 90% width: Brief, Essence Console, Client Records, Reading Pipeline */
#view-morning > .max-w-6xl {
    max-width: 90vw !important;
}

/* Client Records: view-history has max-width on the view, override its children */
#view-history > .section-page-header,
#view-history > .history-summary-grid,
#view-history > .history-filter-bar,
#view-history > #historyContainer {
    max-width: 90vw !important;
}

/* Essence Console: no max-w-6xl wrapper, override direct children */
#view-calculator > div {
    max-width: 90vw !important;
}

/* Reading Pipeline: max-width is on the view itself, override it */
#view-pipeline {
    max-width: 90vw !important;
}

.tab-content {
    position: relative;
    padding-left: clamp(1rem, 0.5rem + 1.4vw, 2rem);
    padding-right: clamp(1rem, 0.5rem + 1.4vw, 2rem);
}

[id^="view-"] {
    isolation: isolate;
}

#view-morning > div,
#view-calculator > div,
#view-intelligence > div {
    max-width: min(100%, var(--shell-content-width));
    margin-left: auto;
    margin-right: auto;
}

#view-history,
#view-pipeline {
    max-width: min(100%, calc(var(--shell-content-width) + 2rem));
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    contain: layout style;
}

#brief-hero-card {
    position: relative;
    border-radius: 1.5rem;
    background:
        radial-gradient(circle at top right, rgba(151, 184, 129, 0.22), transparent 30%),
        radial-gradient(circle at bottom left, rgba(151, 184, 129, 0.16), transparent 36%),
        linear-gradient(135deg, rgba(240, 247, 236, 0.96), rgba(255, 255, 255, 0.98));
    border: 1px solid rgba(151, 184, 129, 0.28);
    box-shadow: var(--shell-shadow-strong);
}
.aurora-bg-layer {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
}

#brief-hero-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(120deg, transparent 0%, rgba(151, 184, 129, 0.18) 38%, transparent 66%);
    pointer-events: none;
}

.metrics-card,
#cardsContainer > div,
.pipeline-col,
.bg-white.rounded-2xl,
.bg-white.rounded-xl {
    background: var(--shell-card-bg);
    box-shadow: var(--shell-shadow);
    border-color: var(--shell-border);
}

.metrics-card {
    border-radius: 1.35rem;
    padding: clamp(0.95rem, 0.8rem + 0.4vw, 1.2rem);
    transition: border-color 0.15s ease;
}

.metrics-card:hover {
    transform: none;
    border-color: rgba(151, 184, 129, 0.2);
    border-color: var(--shell-border-strong);
}

input,
select,
textarea,
button {
    border-radius: 0.95rem;
}

input:focus,
select:focus,
textarea:focus {
    box-shadow: 0 0 0 4px rgba(151, 184, 129, 0.12);
}

#mobile-bottom-nav {
    padding-top: 0.5rem;
}

.bottomnav-item {
    min-width: 4rem;
    border: 1px solid transparent;
    border-radius: 1rem;
    transition: transform var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.bottomnav-item:hover {
    background: rgba(151, 184, 129, 0.08);
    border-color: rgba(151, 184, 129, 0.12);
}

.bottomnav-item.text-sage-dark {
    background: rgba(151, 184, 129, 0.12);
    border-color: rgba(151, 184, 129, 0.16);
}

.bottomnav-item.text-sage-dark::after {
    top: -0.5rem;
}

@media (max-width: 1023px) {
    .tab-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    #view-history,
    #view-pipeline {
        max-width: 100%;
    }
}

@media (max-width: 767px) {
    .app-shell-mobile-header {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .app-shell-main {
        padding-top: 4rem;
    }

    .tab-content {
        padding-top: 1rem;
    }

    #brief-hero-card {
        min-height: 0;
        border-radius: 1.75rem;
        padding: 1.25rem;
    }

    .metrics-card {
        gap: 0.75rem;
    }
}

@media (min-width: 1536px) {
    .tab-content {
        padding-left: 2.25rem;
        padding-right: 2.25rem;
    }
}

/* ==========================================================================
   SECTION 56: PROFESSIONAL SECTION LAYOUT UPGRADE
   Shared view framing for headers, shells, cards, and data surfaces.
   ========================================================================== */

:root {
    --section-header-bg:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 249, 244, 0.98));
    --section-header-border: rgba(148, 163, 184, 0.16);
    --section-header-shadow: 0 24px 48px -34px rgba(15, 23, 42, 0.32);
    --section-header-glow: radial-gradient(circle at top right, rgba(143, 184, 202, 0.16), transparent 32%);
    --section-surface-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 252, 249, 0.92));
    --section-surface-border: rgba(148, 163, 184, 0.16);
}

.section-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: clamp(1.35rem, 1rem + 0.8vw, 2rem);
}

.section-shell--compact {
    gap: clamp(1.1rem, 0.85rem + 0.7vw, 1.6rem);
}

.section-shell--wide {
    gap: clamp(1.5rem, 1.05rem + 0.95vw, 2.25rem);
}

.section-page-header {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    gap: clamp(0.75rem, 0.55rem + 0.5vw, 1rem);
    padding: clamp(0.6rem, 0.48rem + 0.4vw, 0.85rem) clamp(0.85rem, 0.6rem + 0.7vw, 1.1rem);
    border: 1px solid var(--section-header-border);
    border-radius: 1.35rem;
    background: var(--section-header-glow), var(--section-header-bg);
    box-shadow: var(--section-header-shadow);
    overflow: hidden;
}

.section-page-header::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: linear-gradient(180deg, var(--primary-color), rgba(232, 141, 120, 0.85));
    opacity: 0.9;
}

.section-page-header::after {
    content: "";
    position: absolute;
    inset: auto -10% -45% auto;
    width: 14rem;
    height: 14rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(151, 184, 129, 0.12), transparent 66%);
    pointer-events: none;
    z-index: 0;
}

.section-page-header > * {
    position: relative;
    z-index: 1;
}

.section-page-header .bg-sage\/10,
.section-page-header [class*="bg-sage/10"] {
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border-radius: 0.95rem;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(151, 184, 129, 0.18), rgba(151, 184, 129, 0.08)) !important;
    border: 1px solid rgba(151, 184, 129, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    flex: 0 0 auto;
}

.section-page-header .bg-sage\/10 i,
.section-page-header [class*="bg-sage/10"] i {
    width: 1.1rem;
    height: 1.1rem;
}

.section-page-header h1,
.section-page-header h2 {
    margin: 0;
    font-size: clamp(1.02rem, 0.92rem + 0.45vw, 1.35rem);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #1e293b;
}

.section-page-header p {
    margin-top: 0.18rem;
    font-size: 0.72rem;
    line-height: 1.35;
    color: #64748b;
    max-width: 34rem;
}

.section-page-header .bg-white,
.section-page-header .bg-white\/95,
.section-page-header .bg-gray-50,
.section-page-header .bg-gray-50\/50 {
    border-color: rgba(148, 163, 184, 0.16) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), 0 14px 28px -26px rgba(15, 23, 42, 0.38);
}

.section-page-header .rounded-xl,
.section-page-header .rounded-lg {
    border-radius: 0.95rem !important;
}

.section-page-header .ml-auto,
.section-page-header [id$="-actions"],
.section-page-header [id*="header-actions"] {
    margin-left: auto !important;
}

.section-page-header button,
.section-page-header select,
.section-page-header input {
    min-height: 2.35rem;
}

.section-page-header button {
    border-radius: 0.85rem;
}

.section-page-header > button,
.section-page-header .ml-auto > button,
.section-page-header [id$="-actions"] > button,
.section-page-header [id*="header-actions"] > button,
.section-page-header .relative > button[class*="w-10 h-10"],
.section-page-header .relative > button[class*="w-10"],
#clearHistoryBtn {
    width: 2.35rem;
    height: 2.35rem;
    min-width: 2.35rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: #64748b;
    box-shadow: 0 10px 20px -18px rgba(15, 23, 42, 0.45);
    transition: transform var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

.section-page-header > button:hover,
.section-page-header .ml-auto > button:hover,
.section-page-header [id$="-actions"] > button:hover,
.section-page-header [id*="header-actions"] > button:hover,
.section-page-header .relative > button[class*="w-10 h-10"]:hover,
.section-page-header .relative > button[class*="w-10"]:hover,
#clearHistoryBtn:hover {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(151, 184, 129, 0.24);
    color: var(--primary-dark);
}

.section-page-header .flex.bg-white,
.section-page-header .flex.bg-gray-50,
.section-page-header .flex.bg-gray-100\/50 {
    padding: 0.22rem !important;
    gap: 0.2rem;
    border-radius: 1rem !important;
    background: rgba(255, 255, 255, 0.8) !important;
}

.section-page-header .flex.bg-white > button,
.section-page-header .flex.bg-gray-50 > button,
.section-page-header .flex.bg-gray-100\/50 > button {
    min-height: 2rem;
    padding: 0.42rem 0.72rem !important;
    border-radius: 0.78rem !important;
    font-size: 0.7rem !important;
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
}

.section-page-header input[type="text"],
.section-page-header input[type="search"] {
    min-height: 2.35rem;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    font-size: 0.82rem;
}

.section-page-header--sticky {
    top: 0.75rem;
    background:
        radial-gradient(circle at top right, rgba(143, 184, 202, 0.14), transparent 34%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(246, 250, 246, 0.96));
    border-color: rgba(148, 163, 184, 0.18) !important;
    box-shadow: 0 22px 44px -34px rgba(15, 23, 42, 0.42);
}

.section-page-header.section-page-header--sticky {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.section-shell-card,
#view-revenue #revenue-dashboard-content > .bg-white,
#view-analysis #analysisNameResults > .bg-white,
#view-analysis #section-analysis-name > .bg-white,
#view-analysis #section-analysis-mobile > .bg-white,
#view-loshu #section-loshu-grid .bg-white,
#view-loshu #section-loshu-planes > .bg-white,
#view-loshu #section-loshu-analysis > .bg-white,
#view-intelligence .grid > .bg-white,
#view-intelligence > .bg-white {
    position: relative;
    overflow: hidden;
}

.section-shell-card::before,
#view-revenue #revenue-dashboard-content > .bg-white::before,
#view-analysis #analysisNameResults > .bg-white::before,
#view-analysis #section-analysis-name > .bg-white::before,
#view-analysis #section-analysis-mobile > .bg-white::before,
#view-loshu #section-loshu-grid .bg-white::before,
#view-loshu #section-loshu-planes > .bg-white::before,
#view-loshu #section-loshu-analysis > .bg-white::before,
#view-intelligence .grid > .bg-white::before,
#view-intelligence > .bg-white::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 26%),
        radial-gradient(circle at top right, rgba(151, 184, 129, 0.08), transparent 24%);
    pointer-events: none;
}

.section-shell-card--hero {
    background:
        radial-gradient(circle at top right, rgba(143, 184, 202, 0.14), transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 247, 0.94));
}

#view-calculator > .section-shell-card,
#view-revenue #revenue-dashboard-content > .bg-white,
#view-analysis #section-analysis-name > .bg-white,
#view-analysis #section-analysis-mobile > .bg-white,
#view-analysis #analysisNameResults > .bg-white,
#view-loshu #section-loshu-grid .bg-white,
#view-loshu #section-loshu-planes > .bg-white,
#view-loshu #section-loshu-analysis > .bg-white,
#view-intelligence .grid > .bg-white,
#view-intelligence > .bg-white {
    background: var(--section-surface-bg);
    border-color: var(--section-surface-border) !important;
    box-shadow: 0 22px 46px -34px rgba(15, 23, 42, 0.3);
}

#view-analysis .border-t.border-gray-100,
#view-intelligence .border-b.border-gray-100,
#view-intelligence .border-t.border-gray-100,
#view-loshu .border-b.border-gray-100 {
    border-color: rgba(148, 163, 184, 0.14) !important;
}

#view-analysis .bg-gray-50,
#view-analysis .bg-gray-50\/80,
#view-loshu .bg-gray-50,
#view-intelligence .bg-gray-50,
#view-intelligence .bg-gray-50\/50,
#view-pipeline .bg-gray-50,
#view-calculator .bg-gray-50\/50 {
    background: linear-gradient(180deg, rgba(248, 250, 251, 0.92), rgba(242, 247, 244, 0.9)) !important;
}

/* Configuration — horizontal section rail (replaces the old left sidebar) */
.cfg-rail {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 1rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.cfg-rail::-webkit-scrollbar {
    display: none;
}
.cfg-nav-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 0 0 auto;
    padding: 0.55rem 0.95rem;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
    font-weight: 500;
    color: #4b5563;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.cfg-nav-item.active {
    background: #6b8f71;
    color: white;
    font-weight: 600;
}
.cfg-nav-item:not(.active):hover {
    background: #f3f4f6;
    color: #374151;
}
.cfg-section .bg-gray-50,
.cfg-section .bg-sage\/5,
.cfg-section .bg-coral-light\/20,
.cfg-section .bg-orange-50\/60,
.cfg-section .bg-blue-50\/50 {
    border-radius: 0.75rem;
}

/* ==========================================================================
   SETTINGS › SERVICES & CATEGORIES — Catalog Workbench
   Row, rail and inspector surfaces use the shared semantic variables, so the
   dark theme aliases in dark-mode.css apply without a second rule set.
   ========================================================================== */

.svc-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

/* --- catalog health strip --- */
.svc-healthbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 1rem;
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-xs);
}
.svc-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
}
.svc-metric {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 3.75rem;
}
.svc-metric-value {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 1.0625rem;
    line-height: 1.2;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.svc-metric-label {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.svc-prefill {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-left: var(--space-4);
    border-left: 1px solid var(--border-color);
}
.svc-prefill-text b {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}
.svc-prefill-text small {
    display: block;
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* --- switch (shared by health strip + inspector) --- */
.svc-switch {
    position: relative;
    width: 2.5rem;
    height: 1.375rem;
    flex: none;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--border-strong);
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.svc-switch:hover {
    border-color: var(--primary-color);
}
.svc-switch-knob {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: #fff;
    transition: left 0.15s ease;
}
.svc-switch.on {
    background: var(--primary-color);
    border-color: var(--primary-dark);
}
.svc-switch.on .svc-switch-knob {
    left: 1.1875rem;
}

/* --- workbench shell --- */
/* #cfg-services is the query container: the pane count follows the real content
   width, not the viewport. Categories get the wider share of the split. */
#cfg-services {
    container-type: inline-size;
}
.svc-wb {
    display: grid;
    grid-template-columns: 14.4rem minmax(0, 1fr);
    min-height: 32rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 1.125rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* --- left: category rail --- */
.svc-rail {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--primary-50);
    border-right: 1px solid var(--border-color);
}
.svc-rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: var(--space-3) var(--space-3) var(--space-2);
}
.svc-rail-title {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.svc-ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 0.25rem 0.375rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    box-shadow: none;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.svc-ghost-btn:hover {
    color: var(--ocean-dark);
    background: var(--ocean-light);
    border-color: var(--ocean);
}
.svc-ghost-btn.is-on {
    color: var(--ocean-dark);
    background: var(--ocean-light);
    border-color: var(--ocean);
}
.svc-catlist {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--space-2) var(--space-2);
    overflow-y: auto;
    max-height: 22rem;
}
.svc-cat-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4375rem 0.5rem;
    border-radius: 0.625rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.svc-cat-row:hover {
    background: var(--bg-card);
}
.svc-cat-row.is-active {
    background: var(--bg-card);
    border-color: var(--primary-color);
}
.svc-cat-row.is-merge {
    background: var(--ocean-light);
    border-color: var(--ocean);
}
.svc-cat-dot {
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    flex: none;
}
.svc-cat-main {
    flex: 1;
    min-width: 0;
}
.svc-cat-name {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.svc-cat-star {
    width: 0.625rem !important;
    height: 0.625rem !important;
    flex: none;
    color: var(--sun-dark);
    fill: currentColor;
}
.svc-cat-sub {
    display: block;
    font-size: 0.625rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.svc-cat-acts {
    display: flex;
    gap: 1px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.svc-cat-row:hover .svc-cat-acts,
.svc-cat-row.is-active .svc-cat-acts,
.svc-cat-row.is-editing .svc-cat-acts,
.svc-cat-row:focus-within .svc-cat-acts {
    opacity: 1;
}
.svc-cat-row.is-editing {
    gap: 0.25rem;
    background: var(--bg-card);
    border-color: var(--primary-color);
}
.svc-cat-editinput {
    flex: 1;
    min-width: 0;
    font-size: 0.6875rem;
    padding: 0.1875rem 0.375rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background: var(--bg-card);
    color: var(--text-primary);
}
.svc-cat-editinput:focus {
    outline: none;
    border-color: var(--primary-color);
}
.svc-rail-add {
    display: flex;
    gap: 0.375rem;
    padding: var(--space-2) var(--space-3);
}
.svc-rail-add input {
    flex: 1;
    min-width: 0;
    font-size: 0.6875rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-card);
    color: var(--text-primary);
}
.svc-rail-add input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.16);
}
.svc-rail-add button {
    width: 1.875rem;
    height: 1.875rem;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 0.5rem;
    border: 1px solid var(--primary-dark);
    background: var(--primary-color);
    color: #fff;
    box-shadow: none;
    transition: background-color 0.15s ease;
}
.svc-rail-add button:hover {
    background: var(--primary-dark);
}
.svc-rail-add button svg {
    width: 0.875rem;
    height: 0.875rem;
}
.svc-mergebar {
    flex-direction: column;
    gap: 0.375rem;
    padding: var(--space-3);
    border-top: 1px solid var(--border-color);
    background: var(--ocean-light);
}
.svc-mergebar > div {
    display: flex;
    gap: 0.375rem;
}
.svc-mergebar p {
    font-size: 0.5625rem;
    text-align: center;
    color: var(--text-muted);
}
.svc-merge-exec {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.375rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--ocean-dark);
    background: var(--ocean);
    color: #fff;
    box-shadow: none;
    transition: background-color 0.15s ease;
}
.svc-merge-exec:hover {
    background: var(--ocean-dark);
}
.svc-merge-exec:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.svc-merge-cancel {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.375rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    color: var(--text-secondary);
    box-shadow: none;
    transition: background-color 0.15s ease;
}
.svc-merge-cancel:hover {
    background: var(--bg-body);
}
.svc-rail-foot {
    display: flex;
    align-items: flex-start;
    gap: 0.3125rem;
    margin-top: auto;
    padding: 0 var(--space-3) var(--space-3);
    font-size: 0.5625rem;
    line-height: 1.45;
    color: var(--text-muted);
}
.svc-rail-foot svg {
    width: 0.625rem;
    height: 0.625rem;
    flex: none;
    margin-top: 0.125rem;
    color: var(--sun-dark);
}

/* --- center: toolbar + table --- */
.svc-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-card);
}
.svc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-color);
}
.svc-search {
    position: relative;
    flex: 1 1 10rem;
    min-width: 8rem;
}
.svc-search > svg {
    position: absolute;
    left: 0.5625rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.8125rem;
    height: 0.8125rem;
    color: var(--text-muted);
}
.svc-search input {
    width: 100%;
    font-size: 0.6875rem;
    padding: 0.4375rem 0.5625rem 0.4375rem 1.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.svc-search input:focus {
    outline: none;
    background: var(--bg-card);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.16);
}
.svc-select {
    font-size: 0.6875rem;
    /* A long category name must not stretch the toolbar past the phone viewport. */
    max-width: 10rem;
    padding: 0.4375rem 1.5rem 0.4375rem 0.5625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--bg-body);
    color: var(--text-primary);
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b9487' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.375rem center;
    background-size: 0.75rem;
}
.svc-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-card);
}
.svc-quickfilters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.svc-chip {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.3125rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.svc-chip:hover {
    border-color: var(--primary-color);
    color: var(--primary-dark);
}
.svc-chip[aria-pressed="true"] {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-dark);
}
.svc-chip span {
    font-variant-numeric: tabular-nums;
    opacity: 0.7;
    margin-left: 0.0625rem;
}
.svc-healthnote {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem var(--space-3);
    background: var(--sun-light);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.6875rem;
    color: var(--text-secondary);
}
.svc-healthnote > svg {
    width: 0.875rem;
    height: 0.875rem;
    flex: none;
    color: var(--sun-dark);
}
/* style_essence.css loads after Tailwind, so .hidden needs a paired rule here. */
.svc-healthnote.hidden {
    display: none;
}
.svc-healthnote-btn {
    margin-left: auto;
    flex: none;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.25rem 0.5625rem;
    border-radius: 0.4375rem;
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.svc-healthnote-btn:hover {
    background: var(--bg-body);
    border-color: var(--primary-color);
}
.svc-bulkbar {
    padding: 0.5rem var(--space-3);
    background: var(--primary-light);
    border-bottom: 1px solid var(--border-color);
}
.svc-bulk-act {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.25rem 0.4375rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    color: var(--ocean-dark);
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.svc-bulk-act:hover {
    background: var(--bg-card);
    border-color: var(--ocean);
}
.svc-bulk-act-price {
    color: var(--sun-dark);
}
.svc-bulk-act-price:hover {
    border-color: var(--sun);
}
.svc-bulk-act-danger {
    color: var(--secondary-dark);
}
.svc-bulk-act-danger:hover {
    border-color: var(--secondary-color);
}

.svc-list {
    flex: 1;
    min-height: 12rem;
}
.svc-thead,
.svc-row {
    display: grid;
    grid-template-columns: 1.375rem 1rem 1.5rem minmax(0, 1fr) 5.25rem 4.75rem 4.5rem;
    gap: 0.5rem;
    align-items: center;
    padding-left: var(--space-3);
    padding-right: var(--space-3);
}
.svc-thead {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}
.svc-thead > span {
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}
.svc-ta-r {
    text-align: right;
}
.svc-row {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.13s ease;
}
.svc-row:hover {
    background: var(--primary-50);
}
.svc-row.is-checked {
    background: var(--primary-50);
}
.svc-row.is-sel {
    background: var(--primary-light);
}
.svc-row.is-compact {
    padding-top: 0.1875rem;
    padding-bottom: 0.1875rem;
}
/* Keyboard focus must be visible on the interactive surfaces that are not native
   buttons: the row, the category rail row and the inline price cell. */
.svc-row:focus-visible,
.svc-cat-row:focus-visible,
.svc-price:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}
.svc-row.is-compact .svc-meta {
    display: none;
}
.svc-check {
    display: grid;
    place-items: center;
}
.svc-check input {
    width: 0.8125rem;
    height: 0.8125rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}
.svc-grip {
    display: grid;
    place-items: center;
    color: var(--border-strong);
    cursor: grab;
}
.svc-row:hover .svc-grip {
    color: var(--text-muted);
}
.svc-grip svg {
    width: 0.75rem;
    height: 0.75rem;
}
.svc-star {
    display: grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--border-strong);
    box-shadow: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.svc-star:hover {
    color: var(--sun-dark);
    background: var(--sun-light);
}
.svc-star.on {
    color: var(--sun-dark);
}
.svc-star.on svg {
    fill: currentColor;
}
.svc-star svg {
    width: 0.8125rem;
    height: 0.8125rem;
}
.svc-main {
    min-width: 0;
}
.svc-name {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.svc-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4375rem;
    margin-top: 1px;
    font-size: 0.625rem;
    color: var(--text-muted);
}
.svc-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 0.1875rem;
    min-width: 0;
}
.svc-meta svg {
    width: 0.625rem;
    height: 0.625rem;
    flex: none;
}
.svc-meta-desc {
    display: block !important;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.svc-cat-chip {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    max-width: 100%;
    padding: 0.125rem 0.4375rem;
    border-radius: 0.3125rem;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--tint, var(--primary-color)) 16%, transparent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.svc-cat-chip::before {
    content: "";
    width: 0.3125rem;
    height: 0.3125rem;
    border-radius: 50%;
    background: var(--tint, var(--primary-color));
    flex: none;
}
.svc-price {
    justify-self: end;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    padding: 0.1875rem 0.375rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    cursor: text;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.svc-price:hover {
    border-color: var(--border-strong);
    background: var(--bg-body);
}
.svc-price.is-zero {
    color: var(--secondary-dark);
    background: var(--secondary-light);
    font-weight: 700;
}
.svc-price.is-edit {
    border-color: var(--primary-color);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.16);
    outline: none;
    cursor: text;
}
.svc-acts {
    display: flex;
    justify-content: flex-end;
    gap: 1px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.svc-row:hover .svc-acts,
.svc-row.is-sel .svc-acts,
.svc-row:focus-within .svc-acts {
    opacity: 1;
}
.svc-icon-btn {
    display: grid;
    place-items: center;
    width: 1.625rem;
    height: 1.625rem;
    flex: none;
    border-radius: 0.4375rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.svc-icon-btn:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}
.svc-icon-btn.is-danger:hover {
    background: var(--secondary-light);
    color: var(--secondary-dark);
}
.svc-icon-btn.is-star {
    color: var(--sun-dark);
}
.svc-icon-btn.is-save {
    background: var(--primary-color);
    border-color: var(--primary-dark);
    color: #fff;
}
.svc-icon-btn.is-save:hover {
    background: var(--primary-dark);
    color: #fff;
}
.svc-icon-btn svg {
    width: 0.8125rem;
    height: 0.8125rem;
}
.svc-icon-btn-xs {
    width: 1.375rem;
    height: 1.375rem;
    border-radius: 0.3125rem;
}
.svc-icon-btn-xs svg {
    width: 0.6875rem;
    height: 0.6875rem;
}
.svc-open-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 2.375rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.svc-open-empty svg {
    width: 1.625rem;
    height: 1.625rem;
    opacity: 0.45;
}

/* --- add service --- */
.svc-addrow-wrap {
    border-top: 1px solid var(--border-color);
    background: var(--primary-50);
}
.svc-addrow {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    width: 100%;
    padding: 0.625rem var(--space-3);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--primary-dark);
    background: transparent;
    border: 0;
    box-shadow: none;
    transition: background-color 0.15s ease;
}
.svc-addrow:hover,
.svc-addrow.is-open {
    background: var(--primary-light);
}
.svc-addrow svg {
    width: 0.8125rem;
    height: 0.8125rem;
}
.svc-addform {
    padding: var(--space-3);
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}
.svc-addgrid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) 5.5rem 6.5rem 2.125rem;
    gap: 0.375rem;
    align-items: end;
}
.svc-addmeta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
    margin-top: 0.375rem;
}
.svc-add-field {
    display: block;
    min-width: 0;
}
.svc-add-field > span {
    display: block;
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.1875rem;
}
.svc-add-field input,
.svc-add-field select {
    width: 100%;
    font-size: 0.6875rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.4375rem;
    background: var(--bg-body);
    color: var(--text-primary);
}
.svc-add-field input:focus,
.svc-add-field select:focus {
    outline: none;
    background: var(--bg-card);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.16);
}
.svc-add-submit {
    width: 2.125rem;
    height: 2.125rem;
    display: grid;
    place-items: center;
    border-radius: 0.5rem;
    border: 1px solid var(--primary-dark);
    background: var(--primary-color);
    color: #fff;
    box-shadow: none;
    transition: background-color 0.15s ease;
}
.svc-add-submit:hover {
    background: var(--primary-dark);
}
.svc-add-submit svg {
    width: 0.9375rem;
    height: 0.9375rem;
}

/* --- right: inspector --- */
.svc-inspector {
    display: flex;
    flex-direction: column;
    min-width: 0;
    grid-column: 1 / -1;
    background: var(--primary-50);
    border-top: 1px solid var(--border-color);
}
.svc-insp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 2.75rem 1.25rem;
    text-align: center;
    font-size: 0.6875rem;
    line-height: 1.55;
    color: var(--text-muted);
}
.svc-insp-empty svg {
    width: 1.625rem;
    height: 1.625rem;
    opacity: 0.4;
}
.svc-insp-empty b {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.svc-insp-head {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: var(--space-3);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}
.svc-insp-badge {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    margin-top: 0.375rem;
    flex: none;
}
.svc-insp-title {
    flex: 1;
    min-width: 0;
}
.svc-insp-title b {
    display: block;
    font-size: 0.8125rem;
    line-height: 1.3;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.svc-insp-title small {
    display: block;
    margin-top: 1px;
    font-size: 0.625rem;
    color: var(--text-muted);
}
.svc-insp-body {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: var(--space-3);
    overflow-y: auto;
}
.svc-field {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
    min-width: 0;
}
.svc-field > span {
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.svc-field input,
.svc-field select,
.svc-field textarea {
    width: 100%;
    font-size: 0.6875rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.4375rem;
    background: var(--bg-card);
    color: var(--text-primary);
    resize: vertical;
}
.svc-field input:focus,
.svc-field select:focus,
.svc-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.16);
}
.svc-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.svc-money {
    position: relative;
    display: block;
}
.svc-money em {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-style: normal;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--text-muted);
}
.svc-money input {
    padding-left: 1.1875rem;
    font-weight: 600;
}
.svc-togglerow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.5625rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
}
.svc-togglerow b {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-primary);
}
.svc-togglerow small {
    display: block;
    font-size: 0.5625rem;
    line-height: 1.35;
    color: var(--text-muted);
}
.svc-preview {
    padding: 0.5rem 0.5625rem;
    border: 1px dashed var(--primary-color);
    border-radius: 0.5rem;
    background: var(--bg-card);
}
.svc-preview b {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.5625rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--primary-dark);
}
.svc-preview svg {
    width: 0.6875rem;
    height: 0.6875rem;
}
.svc-preview p {
    margin-top: 0.25rem;
    font-size: 0.625rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.svc-preview p b {
    display: inline;
    font-size: inherit;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-primary);
}
.svc-insp-foot {
    display: flex;
    gap: 0.375rem;
    padding: var(--space-3);
    margin-top: auto;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}
.svc-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3125rem;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.svc-btn:hover {
    background: var(--bg-body);
    border-color: var(--primary-color);
}
.svc-btn svg {
    width: 0.75rem;
    height: 0.75rem;
}
.svc-btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-dark);
    color: #fff;
}
.svc-btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

/* Touch devices: reveal the row/category actions permanently and enlarge targets */
@media (hover: none) {
    .svc-acts,
    .svc-cat-acts {
        opacity: 1 !important;
    }
    .svc-icon-btn {
        width: 2rem;
        height: 2rem;
    }
    .svc-star {
        width: 2rem;
        height: 2rem;
    }
}

/* --- responsive: measured against the real content column (#cfg-services) --- */

/* Wide content column: three panes — rail · table · inspector. */
/* Wide content column: three panes — rail · table · inspector. */
@container (min-width: 1040px) {
    .svc-wb {
        grid-template-columns: 15.6rem minmax(0, 1fr) 20rem;
    }
    .svc-inspector {
        grid-column: auto;
        border-left: 1px solid var(--border-color);
        border-top: 0;
    }
}

@container (max-width: 720px) {
    /* The rail is a fixed 12rem column at every width today, so on a phone it ate
       most of the content column and left the table ~150px. Stack it instead. */
    .svc-wb {
        grid-template-columns: minmax(0, 1fr);
    }
    .svc-rail {
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }
    .svc-catlist {
        max-height: 13rem;
    }
    .svc-prefill {
        width: 100%;
        justify-content: space-between;
        padding-left: 0;
        padding-top: var(--space-2);
        border-left: 0;
        border-top: 1px solid var(--border-color);
    }
}

@container (max-width: 620px) {
    .svc-thead,
    .svc-row {
        grid-template-columns: 1.25rem 1.5rem minmax(0, 1fr) 4.125rem 4.125rem;
    }
    .svc-thead > span:nth-child(2),
    .svc-thead > span:nth-child(5),
    .svc-row .svc-grip,
    .svc-row .svc-cat-chip {
        display: none;
    }
    .svc-act-dup {
        display: none;
    }
}

@container (max-width: 560px) {
    .svc-addgrid {
        grid-template-columns: 1fr 1fr;
    }
    .svc-addgrid > .svc-add-field:first-child,
    .svc-add-submit {
        grid-column: 1 / -1;
    }
    .svc-add-submit {
        width: 100%;
        height: 2.25rem;
    }
}

/* No container queries (iOS 15, Safari <= 16.3, Chrome < 105): the same stacking rules,
   mapped to viewport widths. @supports not(...) keeps this dead in every modern browser. */
@supports not (container-type: inline-size) {
    @media (max-width: 768px) {
        .svc-wb { grid-template-columns: minmax(0, 1fr); }
        .svc-rail { border-right: 0; border-bottom: 1px solid var(--border-color); }
        .svc-catlist { max-height: 13rem; }
        .svc-prefill {
            width: 100%;
            justify-content: space-between;
            padding-left: 0;
            padding-top: var(--space-2);
            border-left: 0;
            border-top: 1px solid var(--border-color);
        }
    }
    @media (max-width: 700px) {
        .svc-thead,
        .svc-row { grid-template-columns: 1.25rem 1.5rem minmax(0, 1fr) 4.125rem 4.125rem; }
        .svc-thead > span:nth-child(2),
        .svc-thead > span:nth-child(5),
        .svc-row .svc-grip,
        .svc-row .svc-cat-chip,
        .svc-act-dup { display: none; }
    }
    @media (max-width: 640px) {
        .svc-addgrid { grid-template-columns: 1fr 1fr; }
        .svc-addgrid > .svc-add-field:first-child,
        .svc-add-submit { grid-column: 1 / -1; }
        .svc-add-submit { width: 100%; height: 2.25rem; }
    }
    /* Wide column keeps the two-pane layout it would have had. */
    @media (min-width: 1024px) {
        .svc-wb { grid-template-columns: 15.6rem minmax(0, 1fr) 20rem; }
        .svc-inspector { grid-column: auto; border-left: 1px solid var(--border-color); border-top: 0; }
    }
}

#view-analysis .border-gray-200,
#view-loshu .border-gray-200,
#view-intelligence .border-gray-200,
#view-pipeline .border-gray-200,
#view-calculator .ring-gray-200 {
    border-color: rgba(148, 163, 184, 0.18) !important;
}

#view-intelligence table,
#view-history table {
    border-spacing: 0;
}

#view-intelligence thead,
#view-history thead {
}

#view-intelligence thead.bg-white,
#view-history thead.bg-gray-50 {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 247, 0.94)) !important;
}

#view-intelligence tbody tr:hover,
#view-history tbody tr:hover {
    background: rgba(151, 184, 129, 0.06);
}

@media (max-width: 767px) {
    .section-page-header {
        align-items: stretch;
        gap: 0.65rem;
        border-radius: 1rem;
        padding: 0.5rem 0.75rem;
    }

    .section-page-header::before {
        width: 100%;
        height: 4px;
        inset: 0 0 auto 0;
    }

    .section-page-header .bg-sage\/10,
    .section-page-header [class*="bg-sage/10"] {
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 0.8rem;
    }

    .section-page-header h1,
    .section-page-header h2 {
        font-size: 0.98rem;
    }

    .section-page-header p {
        font-size: 0.68rem;
        max-width: none;
    }

    .section-page-header .ml-auto,
    .section-page-header [id$="-actions"],
    .section-page-header [id*="header-actions"] {
        margin-left: 0 !important;
    }

    .section-page-header > button,
    .section-page-header .ml-auto > button,
    .section-page-header [id$="-actions"] > button,
    .section-page-header [id*="header-actions"] > button,
    .section-page-header .relative > button[class*="w-10"],
    #clearHistoryBtn {
        width: 2.2rem;
        height: 2.2rem;
        min-width: 2.2rem;
    }

    .section-page-header .flex.bg-white,
    .section-page-header .flex.bg-gray-50,
    .section-page-header .flex.bg-gray-100\/50 {
        width: 100%;
        flex-wrap: wrap;
    }

    .section-page-header .flex.bg-white > button,
    .section-page-header .flex.bg-gray-50 > button,
    .section-page-header .flex.bg-gray-100\/50 > button {
        flex: 1 1 auto;
        min-width: 0;
    }

    .section-page-header--sticky {
        top: 0.5rem;
    }

    #view-pipeline .section-page-header {
        margin-bottom: 0.5rem !important;
    }

    #view-pipeline .section-page-header .macos-title-cluster {
        flex-direction: row !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    #view-pipeline .section-page-header p {
        font-size: 0.65rem !important;
        margin-top: 0 !important;
    }
}

/* ==========================================================================
   SECTION 57: ESSENCE CHART PREMIUM SURFACE
   Compact brand-consistent table shell and readability upgrades.
   ========================================================================== */

.essence-chart-shell {
    border-radius: 1.6rem !important;
    background:
        radial-gradient(circle at top right, rgba(143, 184, 202, 0.1), transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 247, 0.94));
    border-color: rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 28px 54px -36px rgba(15, 23, 42, 0.32) !important;
}

.essence-chart-topbar {
    position: relative;
    padding: 1rem 1.25rem !important;
    background:
        linear-gradient(180deg, rgba(248, 251, 247, 0.96), rgba(245, 249, 244, 0.92)) !important;
}

.essence-chart-topbar > div:first-child h3 {
    font-size: 0.98rem;
    letter-spacing: -0.025em;
}

#quickNavContainer > div {
    gap: 0.5rem !important;
}

#quickNavContainer > div > div {
    border-radius: 9999px !important;
}

#quickNavContainer .mr-auto {
    padding: 0.35rem 0.65rem !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 16px 30px -26px rgba(15, 23, 42, 0.28);
}

#quickNavContainer .mr-auto .bg-sage-light {
    background: rgba(151, 184, 129, 0.14) !important;
}

#quickNavContainer button,
#quickNavContainer input {
    min-height: 2.125rem;
}

.essence-toolbar-client,
.essence-toolbar-group,
.essence-toolbar-input-wrap,
.essence-toolbar-tools {
    min-height: 2.125rem;
}

.essence-toolbar-chip,
.essence-toolbar-go,
.essence-toolbar-input {
    height: 2.125rem !important;
}

.essence-toolbar-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
    border-radius: 9999px !important;
    font-size: 0.75rem !important;
    line-height: 1;
    white-space: nowrap;
}

.essence-toolbar-chip--active {
    min-width: 4.25rem;
}

.essence-toolbar-input-wrap {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 16px 30px -28px rgba(15, 23, 42, 0.25);
}

.essence-toolbar-input {
    border: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    font-size: 0.72rem !important;
}

.essence-toolbar-go {
    min-width: 2.8rem;
    border-radius: 0 !important;
    font-size: 0.68rem !important;
}

.essence-toolbar-tools .essence-toolbar-chip {
    width: 2.125rem !important;
    height: 2.125rem !important;
    min-width: 2.125rem !important;
    padding: 0 !important;
    border-radius: 0.75rem !important; /* rounded-xl matching Copy Summary & Reset */
}

.essence-toolbar-tools .essence-toolbar-chip svg,
.essence-toolbar-tools .essence-toolbar-chip i {
    width: 1.35rem !important;
    height: 1.35rem !important;
}

/* Tablet (sm–lg): stack Identity bar + Chart header in 2 rows, never clip pills */
@media (min-width: 640px) and (max-width: 1023.98px) {
    #coreNumbersContainer .border-b {
        overflow: visible;
    }
    #quickNavContainer {
        min-width: 0;
        max-width: 100%;
    }
    #quickNavContainer > div {
        flex-wrap: wrap;
    }
    .essence-toolbar-client {
        max-width: 100%;
        min-width: 0;
    }
    .essence-toolbar-controls {
        max-width: 100%;
        min-width: 0;
    }
    .essence-chart-topbar {
        overflow: visible;
    }
}

/* Option 5: Numerology Color-Coded Ring Tokens (Dedicated Palette - Squircle Style) */
#pmToggleBtn.active {
    background-color: #E8F3F8 !important;
    color: #4A7A8C !important;
    border: 1px solid #8FB8CA !important;
}
#tlToggleBtn.active {
    background-color: #FEF3C7 !important;
    color: #B45309 !important;
    border: 1px solid #F59E0B !important;
}
#pcToggleBtn.active {
    background-color: #F3E8FF !important;
    color: #7E22CE !important;
    border: 1px solid #A855F7 !important;
}
#pcycleToggleBtn.active {
    background-color: #f0f7ec !important;
    color: #587944 !important;
    border: 1px solid #97B881 !important;
}

.dark #pmToggleBtn.active {
    background-color: rgba(110, 168, 194, 0.22) !important;
    color: #bae6fd !important;
    border: 1px solid #8FB8CA !important;
}
.dark #tlToggleBtn.active {
    background-color: rgba(245, 158, 11, 0.22) !important;
    color: #fde68a !important;
    border: 1px solid #F59E0B !important;
}
.dark #pcToggleBtn.active {
    background-color: rgba(168, 85, 247, 0.22) !important;
    color: #e9d5ff !important;
    border: 1px solid #A855F7 !important;
}
.dark #pcycleToggleBtn.active {
    background-color: rgba(151, 184, 129, 0.22) !important;
    color: #dcfce7 !important;
    border: 1px solid #97B881 !important;
}

#pmToggleBtn:not(.active):hover {
    color: #6D94A6 !important;
    border-color: #8FB8CA !important;
}
#tlToggleBtn:not(.active):hover {
    color: #D97706 !important;
    border-color: #F59E0B !important;
}
#pcToggleBtn:not(.active):hover {
    color: #9333EA !important;
    border-color: #A855F7 !important;
}
#pcycleToggleBtn:not(.active):hover {
    color: #587944 !important;
    border-color: #97B881 !important;
}

.essence-toolbar-row2 {
    flex-wrap: wrap;
}

.essence-toolbar-tools {
    flex-wrap: nowrap;
}

#quickNavContainer > div > .flex.bg-gray-100,
#quickNavContainer > div > .flex.items-center.border {
    background: rgba(255, 255, 255, 0.84) !important;
    border: 1px solid rgba(148, 163, 184, 0.16) !important;
    box-shadow: 0 16px 30px -28px rgba(15, 23, 42, 0.25);
}

#quickNavContainer > div > .flex.bg-gray-100 {
    padding: 0.22rem !important;
}

#quickNavContainer > div > .flex.bg-gray-100 button,
#quickNavContainer > div > .flex.items-center.border button,
#quickNavContainer > div > .flex.items-center.gap-2 button {
    border-radius: 0.75rem !important;
    font-size: 0.68rem !important;
    font-weight: 700;
}

#quickNavContainer > div > .flex.items-center.gap-2 button {
    min-width: 2rem;
    padding-left: 0.55rem !important;
    padding-right: 0.55rem !important;
}

.essence-shell-accent {
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--ocean), var(--lavender));
    background-size: 200% 100%;
}

.essence-table-scroll {
    position: relative;
    padding-bottom: 0.2rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 251, 247, 0.78));
}

.essence-table-scroll::after {
    content: "";
    position: sticky;
    right: 0;
    display: block;
    float: right;
    width: 3rem;
    height: 100%;
    margin-left: -3rem;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(250, 252, 249, 0.96));
    pointer-events: none;
    z-index: 45;
}

#resultsTable {
    min-width: max-content;
    background: transparent;
    border-spacing: 0;
}

    #resultsTable thead th {
        top: 0;
        padding: 0.8rem 0.5rem !important;
        font-size: var(--table-font-size) !important;
        font-family: var(--font-body);
        letter-spacing: 0.04em;
        text-transform: uppercase;
        border-bottom: 2px solid rgba(151, 184, 129, 0.18) !important;
        background: linear-gradient(180deg, rgba(248, 251, 247, 0.98), rgba(241, 246, 239, 0.96)) !important;
        color: #64748b !important;
        box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.7);
        position: relative;
    }

    #resultsTable thead th::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, rgba(151, 184, 129, 0.08), rgba(151, 184, 129, 0.2), rgba(151, 184, 129, 0.08));
    }

#resultsTable thead th:first-child.sticky,
#resultsTable th:first-child {
    min-width: 9rem !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    background: linear-gradient(135deg, #e88d78, #dc7d67) !important;
    color: white !important;
    border-right: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-bottom: 2px solid rgba(214, 117, 96, 0.3) !important;
    box-shadow: 10px 0 24px -22px rgba(15, 23, 42, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    letter-spacing: 0.06em;
}

#resultsTable td:first-child {
    min-width: 9rem !important;
    padding: 0.72rem 1rem !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 247, 0.96)) !important;
    color: #334155 !important;
    border-right: 1px solid rgba(148, 163, 184, 0.12) !important;
    box-shadow: 10px 0 24px -24px rgba(15, 23, 42, 0.3);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

#resultsTable td {
    min-width: 3.1rem;
    padding: 0.6rem 0.4rem !important;
    border-right: 1px solid rgba(148, 163, 184, 0.06) !important;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06) !important;
    background: rgba(255, 255, 255, 0.72);
    color: #475569;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

#resultsTable tbody tr {
    transition: background 0.18s ease;
}

#resultsTable tbody tr:hover td:not(.sticky):not([class*="bg-sage"]):not([class*="bg-coral"]) {
    background: rgba(240, 247, 236, 0.5) !important;
}

#resultsTable tbody tr:nth-child(even) td:not(.sticky) {
    background: rgba(247, 250, 247, 0.7);
}

#resultsTable tbody tr:nth-child(even):hover td:not(.sticky):not([class*="bg-sage"]):not([class*="bg-coral"]) {
    background: rgba(240, 247, 236, 0.6) !important;
}

/* Active Year / Active Age cell highlights in light mode */
#resultsTable td.bg-sage-light {
    background: linear-gradient(180deg, rgba(240, 247, 236, 0.9), rgba(227, 240, 218, 0.85)) !important;
    color: var(--primary-dark) !important;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(151, 184, 129, 0.12);
}

#resultsTable td.bg-coral-light {
    background: linear-gradient(180deg, rgba(253, 242, 240, 0.9), rgba(250, 230, 226, 0.85)) !important;
    color: var(--secondary-dark) !important;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(232, 141, 120, 0.1);
}

#resultsTable td.bg-sage-light:hover {
    background: #ddedd4 !important;
    color: var(--primary-dark) !important;
}

#resultsTable td.bg-coral-light:hover {
    background: #f8e0db !important;
    color: var(--secondary-dark) !important;
}

#resultsTable td[data-value="4"],
#resultsTable td[data-value="8"] {
    color: #6d7f93;
}

#resultsTable .border-x-sage,
#resultsTable .border-x-coral {
    outline-width: 2px;
    border-radius: 0.42rem;
}

.essence-chart-legend {
    gap: 0.85rem !important;
    padding-top: 0.8rem !important;
    padding-bottom: 0.9rem !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 247, 0.98)) !important;
}

.essence-chart-legend > div {
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(248, 250, 251, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: background-color 0.15s ease, border-color 0.15s ease;
    background: rgba(240, 247, 236, 0.8);
    border-color: rgba(151, 184, 129, 0.2);
}

@media (max-width: 1023px) {
    .essence-chart-topbar {
        padding: 0.5rem 0.85rem !important;
    }

    #quickNavContainer > div {
        justify-content: flex-start !important;
        gap: 0.45rem !important;
    }

    .essence-toolbar-client {
        margin-bottom: 0 !important;
    }

    .essence-toolbar-controls {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.3rem !important;
        width: 100% !important;
        overflow: visible !important;
    }

    .essence-toolbar-group {
        display: inline-flex !important;
        gap: 0.3rem !important;
        width: auto !important;
    }

    .essence-toolbar-group > span {
        display: none;
    }

    .essence-toolbar-chip--active {
        min-width: 0;
    }

    .essence-toolbar-input-wrap {
        width: auto !important;
    }

    .essence-toolbar-input {
        width: auto !important;
    }

    .essence-toolbar-tools {
        display: inline-flex !important;
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
        align-items: center;
        min-width: 0;
    }

    /* Tablet row 2: jump + tools — allow wrap */
    .essence-toolbar-row2 {
        flex-wrap: wrap !important;
    }
}

@media (max-width: 767px) {
    .essence-chart-shell {
        border-radius: 1.2rem !important;
    }

    .essence-chart-topbar {
        gap: 0.5rem !important;
        padding: 0.65rem 0.75rem !important;
    }

    /* Row 1: Client info full width */
    .essence-toolbar-client {
        width: 100% !important;
        max-width: none !important;
        font-size: 0.8rem !important;
        padding: 0.5rem 0.75rem !important;
    }

    .essence-toolbar-client .flex.items-center.justify-between {
        gap: 0.5rem !important;
    }

    /* Row 2: Controls horizontal scroll - generous vertical padding to prevent border clipping */
    .essence-toolbar-controls {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        gap: 0.35rem !important;
        padding-top: 0.375rem !important;
        padding-bottom: 0.375rem !important;
        padding-left: 0.2rem !important;
        padding-right: 0.2rem !important;
        align-items: center !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100% !important;
    }

    .essence-toolbar-controls::-webkit-scrollbar {
        display: none;
    }

    .essence-toolbar-group {
        display: inline-flex !important;
        gap: 0.25rem !important;
    }

    #quickNavContainer button,
    #quickNavContainer input {
        min-height: 2.125rem !important;
    }

    .essence-toolbar-chip {
        height: 2.125rem !important;
        min-height: 2.125rem !important;
        padding-left: 0.45rem !important;
        padding-right: 0.45rem !important;
        font-size: 0.72rem !important;
        box-sizing: border-box !important;
        flex-shrink: 0 !important;
    }

    .essence-toolbar-input-wrap {
        height: 2.125rem !important;
        min-height: 2.125rem !important;
    }

    .essence-toolbar-input {
        height: 2.125rem !important;
        min-height: 2.125rem !important;
        font-size: 0.72rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .essence-toolbar-go {
        height: 2.125rem !important;
        min-height: 2.125rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        font-size: 0.68rem !important;
    }

    .essence-toolbar-tools {
        display: inline-flex !important;
        gap: 0.35rem !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }

    /* Mobile toggle buttons: rounded-xl matching Copy Summary & Reset */
    .essence-toolbar-tools .essence-toolbar-chip {
        width: 2.125rem !important;
        min-width: 2.125rem !important;
        height: 2.125rem !important;
        min-height: 2.125rem !important;
        padding: 0 !important;
        border-radius: 0.75rem !important;
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
    }

    .essence-toolbar-tools .essence-toolbar-chip svg,
    .essence-toolbar-tools .essence-toolbar-chip i {
        width: 1.35rem !important;
        height: 1.35rem !important;
        stroke-width: 2 !important;
    }

    /* Table font sizes - first column fixed, rest respects settings */
    #resultsTable th:not(:first-child),
    #resultsTable td:not(:first-child) {
        font-size: var(--table-font-size) !important;
    }

    #resultsTable th:first-child,
    #resultsTable td:first-child {
        font-size: 13px !important;
        min-width: 6.9rem !important;
        padding-left: 0.7rem !important;
        padding-right: 0.7rem !important;
    }

    #resultsTable td {
        min-width: 2.75rem;
        padding: 0.5rem 0.26rem !important;
    }

    .essence-chart-legend {
        gap: 0.55rem !important;
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .essence-chart-legend > div {
        width: 100%;
        justify-content: flex-start;
    }
}

/* --- PIPELINE REFRESH CSS APPENDED --- */
.pipeline-hero {
    background:
        radial-gradient(circle at top left, rgba(151, 184, 129, 0.18), transparent 34%),
        radial-gradient(circle at top right, rgba(232, 141, 120, 0.16), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,0.96), rgba(250,252,249,0.92));
    /* backdrop-filter: blur(12px); PERFORMANCE FIX */
}

.pipeline-hero-icon,
.pipeline-card-avatar {
    background: linear-gradient(135deg, rgba(151, 184, 129, 0.24), rgba(151, 184, 129, 0.08));
}

.pipeline-shell {
    border-color: rgba(151, 184, 129, 0.12);
    background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(248,250,247,0.98));
}

.pipeline-stage-inquiry .pipeline-column-head {
    background: linear-gradient(180deg, rgba(244, 239, 255, 0.95), rgba(255,255,255,0.9));
}

.pipeline-stage-scheduled .pipeline-column-head {
    background: linear-gradient(180deg, rgba(239, 246, 255, 0.95), rgba(255,255,255,0.9));
}

.pipeline-stage-progress .pipeline-column-head {
    background: linear-gradient(180deg, rgba(255, 247, 237, 0.95), rgba(255,255,255,0.9));
}

.pipeline-stage-completed .pipeline-column-head {
    background: linear-gradient(180deg, rgba(240, 247, 236, 0.98), rgba(255,255,255,0.9));
}

.pipeline-column-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(255,255,255,0.92);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    font-size: 0.95rem;
    font-weight: 700;
}

.pipeline-column-body {
    background:
        linear-gradient(180deg, rgba(250,252,249,0.9), rgba(247,249,245,0.98));
}

.pipeline-card {
    box-shadow: 0 18px 40px rgba(31, 41, 55, 0.06);
}

.pipeline-action-btn,
.pipeline-column-action {
    border-radius: 9999px;
    background: rgba(255,255,255,0.82);
}

.pipeline-action-btn:hover,
.pipeline-column-action:hover {
    background: rgba(151, 184, 129, 0.12);
}

.pipeline-empty-state,
.pipeline-today-shell,
.pipeline-today-empty {
    background:
        radial-gradient(circle at top right, rgba(151, 184, 129, 0.1), transparent 35%),
        linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,250,247,0.98));
}

.pipeline-time-pill,
.pipeline-metric-chip,
.pipeline-stats-card {
    background: rgba(255,255,255,0.78);
    border: 1px solid rgba(255,255,255,0.88);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.pipeline-time-pill,
.pipeline-metric-chip {
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.pipeline-stats-shell {
    background:
        radial-gradient(circle at top left, rgba(151, 184, 129, 0.14), transparent 34%),
        radial-gradient(circle at top right, rgba(232, 141, 120, 0.12), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,247,0.98));
}

.pipeline-stats-card {
    border-radius: 1.25rem;
    padding: 1rem;
}

#pipeline-dots .dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 9999px;
    background: rgba(151, 184, 129, 0.22);
    border: none;
    transition: width, background-color 0.2s ease;
}

#pipeline-dots .dot.active {
    width: 1.9rem;
    background: linear-gradient(90deg, #97B881, #E88D78);
}

@media (max-width: 767px) {
    .pipeline-hero {
        border-radius: 1.5rem;
    }

    #pipeline-board {
        gap: 0 !important;
        padding: 0 !important;
        scroll-padding-inline: 0;
    }

    .pipeline-column {
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        scroll-snap-align: start;
    }

    .pipeline-card {
        border-radius: 1.1rem;
    }

    #pipeline-board-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    #pipeline-prev,
    #pipeline-next {
        opacity: 1 !important;
        z-index: 50 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
    }

    .pipeline-column-head {
        padding: 0.75rem;
    }

    .pipeline-column-count {
        min-width: 2rem;
        min-height: 2rem;
        font-size: 0.875rem;
    }

    .pipeline-column-body {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .pipeline-card .mobile-action-buttons {
        gap: 0.25rem;
    }

    .pipeline-card .mobile-action-buttons button {
        padding: 0.375rem !important;
    }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    body.tablet-portrait-layout #rail-sidebar,
    body.tablet-portrait-layout .app-shell-header {
        display: none !important;
    }

    body.tablet-portrait-layout .app-shell-mobile-header {
        display: flex !important;
    }

    body.tablet-portrait-layout #mobile-bottom-nav {
        display: block !important;
    }

    body.tablet-portrait-layout #more-drawer {
        display: block !important;
    }

    body.tablet-portrait-layout #more-drawer-backdrop.hidden {
        display: none !important;
    }

    body.tablet-portrait-layout #more-drawer-backdrop:not(.hidden) {
        display: block !important;
    }

    body.tablet-portrait-layout .app-shell-main {
        padding-top: calc(max(3.75rem, 3.25rem + env(safe-area-inset-top))) !important;
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)) !important;
    }

}

/* ==========================================================================
   SECTION 9: CLIENT RECORDS TABLE ENHANCEMENTS
   ========================================================================== */

/* --- Base Table Structure --- */
#view-history {
    --history-table-header-bg: #f8fafc;
    --history-table-row-hover: rgba(240, 247, 236, 0.45);
    --history-table-border: #f1f5f9;
    --history-table-text: #1f2937;
    --history-table-text-secondary: #4b5563;
    --history-table-text-muted: #9ca3af;
    --history-action-bg: #f3f4f6;
    --history-action-hover: #e5e7eb;
    --history-active-row-bg: #fdf2f0;
    --history-active-row-border: #E88D78;
    --history-mobile-badge-bg-b: #eff6ff;
    --history-mobile-badge-border-b: #dbeafe;
    --history-mobile-badge-bg-p: #f0f7ec;
    --history-mobile-badge-border-p: rgba(151, 184, 129, 0.25);
    --history-mobile-badge-bg-d: #f5f3ff;
    --history-mobile-badge-border-d: #ede9fe;
}

/* Table Container */
#historyContainer {
    border-radius: 0.75rem;
    border: 1px solid var(--history-table-border);
    background-color: var(--bg-card);
    overflow: hidden;
}

#historyScrollContainer {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

#historyScrollContainer::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#historyScrollContainer::-webkit-scrollbar-track {
    background: transparent;
}

#historyScrollContainer::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 6px;
    border: 2px solid var(--bg-card);
}

/* --- Table Header --- */
#historyTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.875rem;
    line-height: 1.4;
}

#historyTable thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

#historyTable thead tr {
    background-color: var(--history-table-header-bg);
}

#historyTable th {
    padding: 0.625rem 0.75rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--history-table-text-muted);
    border-bottom: 1px solid var(--history-table-border);
    white-space: nowrap;
    transition: background-color 150ms ease, color 150ms ease;
}

#historyTable th:first-child {
    border-top-left-radius: 0.5rem;
}

#historyTable th:last-child {
    border-top-right-radius: 0.5rem;
}

#historyTable th.cursor-pointer:hover {
    background-color: rgba(0, 0, 0, 0.02);
    color: var(--text-secondary);
}

/* --- Table Body & Rows --- */
#historyTable tbody tr {
    background-color: transparent;
    transition: background-color 150ms ease, box-shadow 150ms ease;
}

#historyTable tbody tr:not(:last-child) td {
    border-bottom: 1px solid var(--history-table-border);
}

#historyTable tbody tr:hover {
    background-color: var(--history-table-row-hover);
}

#historyTable td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    color: var(--history-table-text);
}

/* Active / Selected Row */
#historyTable tbody tr.bg-coral-light {
    background-color: var(--history-active-row-bg) !important;
    border-left: 3px solid var(--history-active-row-border) !important;
}

#historyTable tbody tr.border-l-transparent {
    border-left: 3px solid transparent;
}

/* --- Action Buttons --- */
#historyTable .history-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background-color: var(--history-action-bg);
    color: var(--history-table-text-secondary);
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset var(--transition-fast);
    border: none;
    cursor: pointer;
}

#historyTable .history-action-rail {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

#historyTable .history-action-rail-desktop,
#historyTable .history-action-rail-mobile {
    display: none;
}

@media (min-width: 768px) {
    #historyTable .history-action-rail-desktop {
        display: inline-flex;
    }
}

@media (max-width: 1024px) {
    #historyTable tbody td:last-child > .history-action-rail-mobile {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        gap: 0.375rem;
        justify-content: stretch;
        align-items: center;
        padding-top: 0.1rem;
    }

    #historyTable tbody td:last-child > .history-action-rail-mobile .history-action-btn {
        width: min(1.75rem, 100%);
        min-width: 0;
        height: 1.75rem;
        justify-self: center;
        border-radius: 0.55rem;
    }

    #historyTable tbody td:last-child > .history-action-rail-mobile .history-action-btn i {
        width: 0.825rem;
        height: 0.825rem;
    }
}

#historyTable .history-action-btn.history-action-intelligence {
    background: rgba(143, 184, 202, 0.16);
    color: #4f7b8f;
    box-shadow: inset 0 0 0 1px rgba(143, 184, 202, 0.18);
}

#historyTable .history-action-btn.history-action-edit {
    background: rgba(232, 141, 120, 0.14);
    color: var(--secondary-dark);
    box-shadow: inset 0 0 0 1px rgba(232, 141, 120, 0.18);
}

#historyTable .history-action-btn.history-action-pipeline {
    background: rgba(151, 184, 129, 0.14);
    color: var(--primary-dark);
    box-shadow: inset 0 0 0 1px rgba(151, 184, 129, 0.18);
}

#historyTable .history-action-btn.history-action-menu-trigger {
    background-color: var(--history-action-bg);
    color: var(--history-table-text-secondary);
}

#historyTable .history-action-btn:hover {
    transform: none;
    box-shadow: none;
}

#historyTable .history-action-btn:active {
    background-color: var(--history-action-hover);
}

#historyTable .history-action-btn.history-action-primary {
    background-color: var(--primary-color);
    color: #fff;
    border: 1px solid #84a86d;
    box-shadow: none;
}

#historyTable .history-action-btn.history-action-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: none;
    transform: none;
}

#historyTable .history-action-btn.history-action-intelligence:hover {
    background: rgba(143, 184, 202, 0.24);
    color: #2f6d87;
}

#historyTable .history-action-btn.history-action-edit:hover {
    background: rgba(232, 141, 120, 0.22);
    color: var(--secondary-dark);
}

#historyTable .history-action-btn.history-action-pipeline:hover {
    background: rgba(151, 184, 129, 0.22);
    color: var(--primary-dark);
}

#historyTable .history-action-btn.history-action-menu-trigger:hover {
    background-color: var(--history-action-hover);
    color: var(--history-table-text);
}

#historyTable .history-action-btn.history-action-danger:hover {
    background-color: #fef2f2;
    color: #ef4444;
}

#historyTable .history-action-btn.history-action-info:hover {
    background-color: #eff6ff;
    color: #3b82f6;
}

#historyTable .history-action-btn.history-action-success:hover {
    background-color: #f0fdf4;
    color: #22c55e;
}

#historyRowActionMenu {
    box-shadow: var(--shadow-xl);
    border-color: var(--history-table-border);
    background-color: var(--bg-card);
}

#historyRowActionMenu button {
    border-radius: 0.75rem;
}

/* --- Mobile Compact Badges (Birth/Life/Destiny) --- */
.history-mobile-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0 0.375rem;
    height: 1.25rem;
    border-radius: 0.375rem;
    border: 1px solid transparent;
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
    box-sizing: border-box;
}

.history-mobile-badge .history-badge-label {
    font-size: 0.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.7;
}

.history-mobile-badge.history-badge-birth {
    background-color: var(--history-mobile-badge-bg-b);
    border-color: var(--history-mobile-badge-border-b);
    color: #2563eb;
}

.history-mobile-badge.history-badge-path {
    background-color: var(--history-mobile-badge-bg-p);
    border-color: var(--history-mobile-badge-border-p);
    color: var(--primary-dark);
}

.history-mobile-badge.history-badge-destiny {
    background-color: var(--history-mobile-badge-bg-d);
    border-color: var(--history-mobile-badge-border-d);
    color: #7c3aed;
}

/* --- Status Badges (New, Intake, Referral) --- */
.history-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0 0.375rem;
    height: 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid transparent;
    box-sizing: border-box;
}

.history-status-badge i,
.history-status-badge svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.history-status-badge:is(button, a),
button.history-status-badge,
a.history-status-badge {
    height: 1.25rem !important;
    min-height: 1.25rem !important;
    max-height: 1.25rem !important;
    min-width: 0 !important;
    padding: 0 0.375rem !important;
    margin: 0 !important;
    font-family: inherit !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    letter-spacing: 0.02em !important;
    text-transform: uppercase !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    border-radius: 0.375rem !important;
    box-shadow: none !important;
    outline: none !important;
}

.history-status-badge.history-badge-new {
    background-color: rgba(232, 141, 120, 0.1);
    color: var(--secondary-dark);
    border-color: rgba(232, 141, 120, 0.2);
}

.history-status-badge.history-badge-intake {
    background-color: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border-color: rgba(59, 130, 246, 0.2);
}

.history-status-badge.history-badge-referral {
    background-color: rgba(151, 184, 129, 0.1);
    color: var(--primary-dark);
    border-color: rgba(151, 184, 129, 0.2);
}

.history-status-badge.history-badge-referred-by {
    background-color: rgba(232, 141, 120, 0.1);
    color: var(--secondary-dark);
    border-color: rgba(232, 141, 120, 0.2);
}

.history-status-badge.history-badge-repeat {
    background-color: rgba(151, 184, 129, 0.1);
    color: var(--primary-dark);
    border-color: rgba(151, 184, 129, 0.2);
}

.history-status-badge.history-badge-karmic {
    background-color: rgba(235, 160, 126, 0.1);
    color: #a06a50;
    border-color: rgba(235, 160, 126, 0.2);
}

.history-status-badge.history-badge-deceased {
    background-color: rgba(148, 163, 184, 0.1);
    color: #64748b;
    border-color: rgba(148, 163, 184, 0.2);
}

.history-status-badge.history-badge-renamed {
    background-color: rgba(232, 141, 120, 0.1);
    color: var(--secondary-dark);
    border-color: rgba(232, 141, 120, 0.2);
}

.history-status-badge.history-badge-master {
    background-color: rgba(235, 160, 126, 0.15);
    color: #b06030;
    border-color: rgba(235, 160, 126, 0.25);
}

.history-status-badge.history-badge-matching {
    background-color: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border-color: rgba(59, 130, 246, 0.2);
}

.history-status-badge.history-badge-birthday-today {
    background-color: rgba(232, 141, 120, 0.15);
    color: var(--secondary-dark);
    border-color: rgba(232, 141, 120, 0.35);
    padding: 0 0.25rem;
}

.history-status-badge.history-badge-birthday-upcoming {
    background-color: rgba(245, 158, 11, 0.12);
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.3);
    font-size: 0.6875rem;
    padding: 0 0.3rem;
}

/* --- Empty & Loading States --- */
#historyEmptyState {
    background-color: var(--bg-card);
}

#historySentinel {
    color: var(--primary-dark);
}

/* Mobile card row dark mode — ensure dark bg, border, and no light bleed */
@media (max-width: 767px) {
}

/* Responsive floating menus used by Client Records */
/* The menus are moved to <body> (portal), outside #view-history where --history-table-border is defined:
   define it here too, otherwise the border falls back to a dark currentColor outline. */
.history-floating-menu { --history-table-border: #e5e7eb; }

.history-floating-menu {
    position: fixed !important;
    background: var(--bg-card);
    border: 1px solid var(--history-table-border);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 100ms ease, visibility 0s linear 100ms;
}

.history-floating-menu[data-open="true"] {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 100ms ease, visibility 0s;
}

.history-sort-menu {
    width: 17rem;
    max-width: min(17rem, calc(100vw - 1rem));
}

.history-action-menu {
    width: 15.5rem;
    max-width: min(15.5rem, calc(100vw - 1rem));
}

.history-action-menu .history-action-menu-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem 0.5rem;
    border-bottom: 1px solid rgba(241, 245, 249, 0.95);
}

.history-action-menu .history-action-menu-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.history-action-menu .history-action-menu-subtitle {
    margin-top: 0.08rem;
    font-size: 0.625rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.history-action-menu .history-action-menu-avatar {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-light), #ffffff);
    color: var(--primary-dark);
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid rgba(151, 184, 129, 0.18);
}

.history-action-menu .history-action-menu-body {
    padding: 0.4rem;
}

.history-action-menu .history-action-menu-section {
    padding: 0.18rem 0;
}

.history-action-menu .history-action-menu-divider {
    margin: 0.35rem 0.2rem;
    border-top: 1px solid rgba(226, 232, 240, 0.9);
}

.history-action-menu .history-action-menu-label {
    padding: 0 0.45rem 0.3rem;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.history-action-menu .history-action-menu-list {
    display: grid;
    gap: 0.25rem;
}

.history-action-menu .history-action-menu-list button {
    width: 100%;
    justify-content: flex-start;
    border-radius: 0.8rem;
    padding: 0.58rem 0.72rem;
    font-size: 0.72rem;
    line-height: 1.1;
}

/* ==========================================================================
   CLIENT RECORDS: "More actions" menu (compact, flat, keyboard friendly)
   ========================================================================== */
/* One-element icon (no lucide pass, no SVG nodes) for the per-row trigger */
.history-action-btn .ham-dots {
    display: block; width: 1rem; height: 1rem; margin: 0 auto; background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='5' cy='12' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='19' cy='12' r='2'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='5' cy='12' r='2'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3Ccircle cx='19' cy='12' r='2'/%3E%3C/svg%3E") center / contain no-repeat;
}
.history-action-menu .ham-handle { display: none; width: 2.5rem; height: 0.25rem; border-radius: 99px; background: var(--history-table-border); margin: 0.5rem auto 0; }
.history-action-menu .ham-head { display: flex; align-items: center; gap: 0.625rem; padding: 0.75rem 0.75rem 0.625rem; border-bottom: 1px solid var(--history-table-border); }
.history-action-menu .ham-avatar { width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }
.history-action-menu .ham-name { font-size: 0.8125rem; font-weight: 700; color: var(--text-primary); line-height: 1.25; }
.history-action-menu .ham-meta { font-size: 0.6875rem; color: var(--text-muted); line-height: 1.25; }
.history-action-menu .ham-body { padding: 0.375rem; }
.history-action-menu .ham-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 0.375rem; padding: 0.125rem 0 0.375rem; }
.history-action-menu .ham-tile, .history-action-menu .ham-item {
    border: 0; background: transparent; color: var(--text-primary); cursor: pointer; box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.history-action-menu .ham-tile { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; padding: 0.5rem 0.25rem; min-height: 2.75rem; border: 1px solid var(--history-table-border); border-radius: 0.75rem; font-size: 0.6875rem; font-weight: 600; }
.history-action-menu .ham-tile:hover, .history-action-menu .ham-tile:focus-visible { background: rgba(151, 184, 129, 0.14); border-color: rgba(151, 184, 129, 0.45); }
.history-action-menu .ham-item { display: flex; align-items: center; gap: 0.625rem; width: 100%; padding: 0.5rem 0.625rem; min-height: 2.5rem; border-radius: 0.625rem; font-size: 0.8125rem; font-weight: 600; text-align: left; }
.history-action-menu .ham-item:hover, .history-action-menu .ham-item:focus-visible { background: rgba(151, 184, 129, 0.14); }
.history-action-menu .ham-item.danger { color: var(--secondary-dark); }
.history-action-menu .ham-item.danger:hover, .history-action-menu .ham-item.danger:focus-visible { background: rgba(232, 141, 120, 0.14); }
.history-action-menu .ham-item svg, .history-action-menu .ham-tile svg { width: 1rem; height: 1rem; flex-shrink: 0; color: var(--text-muted); }
.history-action-menu .ham-item.danger svg { color: var(--secondary-dark); }
.history-action-menu .ham-tile.wa svg { color: #16a34a; }
.history-action-menu .ham-tile.call svg { color: #2f6d87; }
.history-action-menu .ham-item .ham-star svg, .history-action-menu .ham-item svg.ham-star-on { color: #f59e0b; fill: currentColor; }
.history-action-menu .ham-sep { height: 1px; background: var(--history-table-border); margin: 0.25rem 0.25rem; }
.history-action-menu :focus-visible { outline: 2px solid var(--primary-color); outline-offset: -2px; }
@media (max-width: 767px) {
    .history-action-menu .ham-handle { display: block; }
    .history-action-menu .ham-item { min-height: 2.75rem; font-size: 0.875rem; }
    .history-action-menu .ham-tile { min-height: 3rem; font-size: 0.75rem; }
}
@media (prefers-reduced-motion: reduce) { .history-floating-menu, .history-action-menu .ham-item, .history-action-menu .ham-tile { transition: none; } }

@media (max-width: 767px) {
    .history-sort-menu {
        width: calc(100vw - 1rem) !important;
        max-width: calc(100vw - 1rem) !important;
    }

    .history-action-menu {
        width: calc(100vw - 1rem) !important;
        max-width: calc(100vw - 1rem) !important;
    }

    .history-action-menu .history-action-menu-header {
        padding: 0.7rem 0.8rem 0.45rem;
    }
}

/* ==========================================================================
   SECTION 9B: CLIENT RECORDS TABLE — RESPONSIVE
   ========================================================================== */

/* Desktop Large (1440px+) */
@media (min-width: 1440px) {
    #historyTable {
        font-size: 0.9375rem;
    }

    #historyTable th,
    #historyTable td {
        padding: 0.75rem 1rem;
    }

    #historyTable .history-action-btn {
        width: 2.25rem;
        height: 2.25rem;
    }
}

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    #historyTable {
        font-size: 0.8125rem;
    }

    #historyTable th,
    #historyTable td {
        padding: 0.5rem 0.625rem;
    }

    #historyTable th {
        font-size: 0.625rem;
    }

    #historyTable .history-action-btn {
        width: 1.75rem;
        height: 1.75rem;
    }
}

/* Mobile (< 768px) */
@media (max-width: 767px) {
    #view-history {
        padding: 0.5rem !important;
    }

    #historyContainer {
        border-radius: 0.5rem;
        border: none;
        background-color: transparent;
    }

    #historyTable {
        font-size: 0.8125rem;
    }

    #historyTable thead {
        display: none;
    }

    #historyTable tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 0.625rem 0.75rem;
        margin-bottom: 0.5rem;
        background-color: var(--bg-card);
        border-radius: 0.75rem;
        border: 1px solid var(--history-table-border);
        box-shadow: var(--shadow-sm);
    }

    #historyTable tbody tr:not(:last-child) td {
        border-bottom: none;
    }

    /* Name cell takes full width on mobile */
    #historyTable tbody td:nth-child(3) {
        flex: 1 1 100%;
        order: 1;
        padding: 0 0 0.375rem 0;
    }

    /* Mobile badges row */
    #historyTable tbody td:nth-child(4),
    #historyTable tbody td:nth-child(5),
    #historyTable tbody td:nth-child(6) {
        display: none;
    }

    /* Actions row */
    #historyTable tbody td:last-child {
        flex: 1 1 100%;
        order: 3;
        padding: 0.375rem 0 0 0;
        text-align: left;
    }

    #historyTable tbody td:last-child > div {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.375rem;
    }

    /* Serial number hidden, shown inline in name cell */
    #historyTable tbody td:first-child,
    #historyTable tbody td:nth-child(2) {
        display: none;
    }

    #historyTable .history-action-btn {
        width: 2rem;
        height: 2rem;
    }

    .history-mobile-badge,
    .history-status-badge {
        height: 1.375rem;
        font-size: 0.6875rem;
    }

    .history-mobile-badge .history-badge-label {
        font-size: 0.4375rem;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
    #view-history {
        padding: 0.375rem !important;
    }

    #historyTable tbody tr {
        padding: 0.5rem;
        margin-bottom: 0.375rem;
        border-radius: 0.625rem;
    }

    #historyTable {
        font-size: 0.75rem;
    }

    #historyTable .history-action-btn {
        width: 1.75rem;
        height: 1.75rem;
    }

    #historyTable tbody td:last-child > .history-action-rail-mobile .history-action-btn {
        width: min(1.75rem, 100%);
        min-width: 0;
        height: 1.75rem;
        justify-self: center;
        border-radius: 0.5rem;
    }

    #historyTable tbody td:last-child > .history-action-rail-mobile .history-action-btn i {
        width: 0.8rem;
        height: 0.8rem;
    }

    .history-mobile-badge,
    .history-status-badge {
        height: 1.25rem;
        font-size: 0.625rem;
        padding: 0 0.25rem;
    }

    .history-mobile-badge .history-badge-label {
        font-size: 0.375rem;
    }
}

/* Very Small Mobile (320px) */
@media (max-width: 359px) {
    #historyTable tbody tr {
        padding: 0.375rem;
    }

    #historyTable .history-action-btn {
        width: 1.5rem;
        height: 1.5rem;
    }

    #historyTable tbody td:last-child > .history-action-rail-mobile .history-action-btn {
        width: min(1.5rem, 100%);
        min-width: 0;
        height: 1.5rem;
        justify-self: center;
        border-radius: 0.45rem;
    }

    #historyTable tbody td:last-child > .history-action-rail-mobile .history-action-btn i {
        width: 0.7rem;
        height: 0.7rem;
    }

    .history-mobile-badge,
    .history-status-badge {
        height: 1.125rem;
        font-size: 0.5625rem;
        padding: 0 0.1875rem;
    }
}

/* ==========================================================================
   FIXED FIRST COLUMN FONT SIZE
   The sticky Year column always uses a readable fixed size regardless
   of the user's table-font-size setting or keyboard shortcuts.
   ========================================================================== */
#resultsTable th:first-child,
#resultsTable td:first-child {
    font-size: 15px !important;
}

/* ==========================================================================
   TAILWIND UTILITY OVERRIDES
   Explicit overrides for CDN-generated utility classes.
   ========================================================================== */

/* Margin Bottom Utilities */
.mb-0 { margin-bottom: 0px !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-5 { margin-bottom: 1.25rem !important; }
.mb-6 { margin-bottom: 1.5rem !important; }
.mb-7 { margin-bottom: 1.75rem !important; }
.mb-8 { margin-bottom: 0.8rem !important; }
.mb-9 { margin-bottom: 2.25rem !important; }
.mb-10 { margin-bottom: 2.5rem !important; }
.mb-11 { margin-bottom: 2.75rem !important; }
.mb-12 { margin-bottom: 3rem !important; }
.mb-14 { margin-bottom: 3.5rem !important; }
.mb-16 { margin-bottom: 4rem !important; }
.mb-20 { margin-bottom: 5rem !important; }

/* ==========================================================================
   SECTION 60: MACOS DESIGN LANGUAGE ENHANCEMENTS
   Glassmorphism, Vibrancy, Spring Animations, Floating Dock, Window Chrome
   ========================================================================== */

/* --- MacOS Design Tokens --- */
:root {
    /* MacOS Spring Curves */
    --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-soft: cubic-bezier(0.16, 1, 0.3, 1.2);
    --spring-snappy: cubic-bezier(0.22, 1, 0.36, 1);
    
    /* MacOS Glassmorphism */
    --glass-light: rgba(255, 255, 255, 0.72);
    --glass-light-border: rgba(255, 255, 255, 0.45);
    
    /* MacOS Inner Highlights for 3D Depth */
    --inner-highlight-light: inset 0 1px 0 0 rgba(255, 255, 255, 0.65);
    --inner-shadow-pressed: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    
    /* MacOS Ambient Shadows */
    --shadow-ambient: 0 4px 24px -4px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-floating: 0 8px 32px -4px rgba(0, 0, 0, 0.12), 0 2px 8px -2px rgba(0, 0, 0, 0.06);
    --shadow-dock: 0 12px 40px -8px rgba(0, 0, 0, 0.18), 0 4px 12px -4px rgba(0, 0, 0, 0.08);
    --shadow-modal-macos: 0 24px 60px -12px rgba(0, 0, 0, 0.18), 0 8px 20px -8px rgba(0, 0, 0, 0.1);

    /* Flat 2.0 Button Tokens */
    --btn-primary-bg: var(--primary-color);
    --btn-primary-hover: var(--primary-dark);
    --btn-primary-border: #84a86d;
    --btn-primary-text: #ffffff;
    --btn-accent-bg: var(--secondary-color);
    --btn-accent-hover: var(--secondary-dark);
    --btn-accent-border: #df7d66;
    --btn-accent-text: #ffffff;
    --btn-ghost-bg: transparent;
    --btn-ghost-hover: var(--primary-light);
    --btn-ghost-border: var(--border-strong);
    --btn-ghost-text: var(--text-secondary);
}

/* --- MacOS Spring Animations --- */
@keyframes macosSpringIn {
    from { opacity: 0; transform: scale(0.92) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes macosSpringUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes macosDockBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.macos-spring-in {
    animation: macosSpringIn 0.45s var(--spring-bounce) forwards;
}

.macos-spring-up {
    animation: macosSpringUp 0.5s var(--spring-soft) forwards;
}

/* --- Sidebar Glassmorphism (MacOS Vibrancy) --- */
.rail-sidebar {
    background: #ffffff !important;
    border-right: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: 4px 0 24px -4px rgba(0, 0, 0, 0.04) !important;
}

/* Sidebar nav items - MacOS style */
.rail-sidebar .nav-item {
    position: relative;
    border-radius: 0.625rem;
    transition: background-color 0.15s ease, color 0.15s ease;
    overflow: hidden;
}

.rail-sidebar .nav-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.25s var(--spring-snappy);
    background: linear-gradient(135deg, rgba(151, 184, 129, 0.1), rgba(151, 184, 129, 0.04));
    box-shadow: var(--inner-highlight-light);
}

.rail-sidebar .nav-item:hover::before {
    opacity: 1;
}

.rail-sidebar .nav-item:hover {
    transform: none;
}

.rail-sidebar .nav-item.bg-sage-light {
    background: linear-gradient(135deg, rgba(232, 141, 120, 0.14), rgba(232, 141, 120, 0.06)) !important;
    box-shadow: var(--inner-highlight-light), 0 1px 3px rgba(232, 141, 120, 0.15) !important;
    border: 1px solid rgba(232, 141, 120, 0.18) !important;
    color: var(--secondary-dark) !important;
}

/* --- Header Glassmorphism --- */
.app-shell-header {
    background: #ffffff !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
}

.app-shell-mobile-header {
    background: #ffffff !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
}

/* ===========================================================
   Floating Capsule — Aurora Flow (Aurora Capsule variant)
   Header + bottom nav float as elevated pill shapes
   =========================================================== */

/* Desktop header: outer canvas becomes transparent; the inner .capsule-pill
   is the actual visible bar. */
.app-shell-header {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.app-shell-header .capsule-pill {
    width: 100%;
    max-width: 1536px;
    margin: 0 auto;
    height: 56px;
    padding: 0.4rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 9999px;
    box-shadow:
        0 10px 30px -10px rgba(15, 23, 42, 0.10),
        0 2px 6px -2px rgba(15, 23, 42, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    transition: box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
                border-color 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Make the top bar float: header is just a transparent container.
   The .capsule-pill itself is sticky + has its own margins, so ONLY
   the pill is visible at the top when scrolling — no full-width bar. */
.app-shell-header {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    z-index: 30 !important;
}

/* The pill carries the visual: sticky to the top, centered, with margins
   so it always reads as a floating capsule — never a full-width bar. */
.app-shell-header .capsule-pill {
    position: sticky !important;
    top: 0.75rem !important;
    z-index: 31 !important;
    width: 100%;
    max-width: 1320px;
    margin: 0.75rem auto 0 !important;
}

@media (max-width: 1279px) {
    .app-shell-header .capsule-pill {
        max-width: 1152px;
    }
}

@media (max-width: 1023px) {
    .app-shell-header .capsule-pill {
        max-width: calc(100% - 1rem);
        margin: 0.5rem 0.5rem 0 !important;
    }
}

/* Mobile header uses the classic flat style (no capsule override)
   so the app-shell-mobile-header gradient/blur/border from above applies. */

/* Mobile bottom nav: canvas transparent; inner pill floats at bottom */
.app-shell-mobile-nav {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-top: none !important;
    box-shadow: none !important;
}

.app-shell-mobile-nav .capsule-nav {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    height: 64px;
    padding: 0.4rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 0.25rem;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 9999px;
    box-shadow:
        0 10px 30px -8px rgba(15, 23, 42, 0.12),
        0 2px 6px -2px rgba(15, 23, 42, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Bottom nav items inside capsule: tighten padding since pill wraps them */
.app-shell-mobile-nav .bottomnav-item {
    min-width: 0;
    flex: 1 1 0;
    border-radius: 9999px;
    border: 1px solid transparent;
    background: transparent;
    height: 48px;
    padding: 0.25rem 0.5rem;
}

.app-shell-mobile-nav .bottomnav-item::after {
    display: none;
}

.app-shell-mobile-nav .bottomnav-item.text-sage-dark {
    background: linear-gradient(135deg, rgba(151, 184, 129, 0.20), rgba(151, 184, 129, 0.10));
    border-color: rgba(151, 184, 129, 0.28);
    color: #4d6f3a;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.app-shell-mobile-nav .bottomnav-item:hover {
    background: rgba(151, 184, 129, 0.08);
}

/* Touch targets stay ≥ 44px (the pill height of 48px handles it) */

/* Compact screens: shrink pill padding so it fits at 320px */
@media (max-width: 380px) {
    .app-shell-mobile-nav .capsule-nav {
        height: 60px;
        padding: 0.35rem 0.4rem;
    }
    .app-shell-mobile-nav .bottomnav-item {
        height: 44px;
    }
}

/* Tablet portrait: give the desktop pill a bit more breathing room */
@media (min-width: 768px) and (max-width: 1023px) {
    .app-shell-header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Segmented controls wrap on tablet to prevent overflow */
    .macos-segmented-control {
        flex-wrap: wrap;
        gap: 0.15rem;
    }
    .macos-segmented-control button,
    .macos-segmented-control .segment-btn {
        flex: 0 1 auto;
        min-width: 0;
        padding: 0.4rem 0.55rem;
        font-size: 0.68rem;
    }

    /* Capsule pill: allow wrap on narrow tablet landscape */
    .app-shell-header .capsule-pill {
        flex-wrap: wrap;
        height: auto;
        max-height: none;
        padding: 0.35rem 0.9rem;
        gap: 0.5rem;
    }

    /* Intelligence matrix + sidebar: cap height to viewport */
    #view-intelligence .lg\:col-span-2 > div:first-child {
        max-height: 55vh !important;
        height: auto !important;
    }
    #view-intelligence .flex.flex-col.gap-4 {
        max-height: 55vh !important;
        height: auto !important;
    }

}


/* --- MacOS Card Enhancements --- */
.macos-card {
    background: var(--bg-card);
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-ambient);
    transition: border-color 0.15s ease;
    position: relative;
    overflow: hidden;
}

.macos-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    opacity: 0.6;
    pointer-events: none;
}

.macos-card:hover {
    transform: none;
    border-color: rgba(151, 184, 129, 0.25);
}

.macos-card:active {
    transform: none;
    transition-duration: 0.1s;
}

/* --- MacOS Button Enhancements --- */
.macos-btn {
    position: relative;
    border-radius: 0.625rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    overflow: hidden;
}

.macos-btn::before {
    display: none;
}

.macos-btn:active {
    opacity: 0.8;
}

.macos-btn-primary {
    background-color: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: 1px solid var(--btn-primary-border);
    box-shadow: none;
}

.macos-btn-primary:hover {
    background-color: var(--btn-primary-hover);
    border-color: #72945c;
    box-shadow: none;
    transform: none;
    filter: none;
}

/* --- Floating Dock Mobile Navigation (MacOS Dock Style) --- */
#mobile-bottom-nav {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px) + 0.5rem) !important;
    width: auto !important;
    padding: 0 !important;
    z-index: 50;
}

#mobile-bottom-nav > div {
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 9999px;
    box-shadow: var(--shadow-dock), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.bottomnav-item {
    position: relative;
    min-width: 3.25rem;
    border-radius: 1rem;
    padding: 0.375rem 0.5rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.bottomnav-item:hover {
    background: rgba(151, 184, 129, 0.1);
    transform: none;
}

.bottomnav-item:active {
    transform: none;
    transition-duration: 0.1s;
}

.bottomnav-item.text-sage-dark {
    background: linear-gradient(135deg, rgba(151, 184, 129, 0.18), rgba(151, 184, 129, 0.08));
    box-shadow: var(--inner-highlight-light), 0 1px 3px rgba(151, 184, 129, 0.15);
    border: 1px solid rgba(151, 184, 129, 0.2);
    color: var(--primary-dark);
    animation: macosDockBounce 0.4s var(--spring-bounce);
}

.bottomnav-item.text-sage-dark::after {
    display: none;
}

/* Mobile content padding adjustment for floating dock */
@media (max-width: 768px) {
    .tab-content {
        padding-bottom: 5rem !important;
    }
    
    #toast-container {
        bottom: 5.5rem !important;
    }
    
}

/* --- MacOS Modal Enhancements --- */
.modal-content {
    border-radius: 1.25rem !important;
    box-shadow: var(--shadow-modal-macos) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    overflow: hidden;
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

.modal-backdrop {
    background: var(--backdrop-light) !important;
    transition: opacity 0.2s ease !important;
    will-change: opacity;
}

.modal-panel {
    border-radius: 1.25rem !important;
    box-shadow: var(--shadow-modal-macos) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    overflow: hidden;
}

/* Modal open animation */
.modal-content.active {
    animation: macosSpringIn 0.4s var(--spring-bounce) forwards !important;
}

/* --- MacOS Input Enhancements --- */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="search"],
select,
textarea {
    border-radius: 0.75rem !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    background: linear-gradient(180deg, #ffffff, #fafbfc) !important;
    box-shadow: var(--inner-shadow-pressed) !important;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.25s var(--spring-snappy) !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(151, 184, 129, 0.12), var(--inner-shadow-pressed) !important;
    outline: none !important;
}

/* --- MacOS Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 100px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 100px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* --- MacOS Toggle Switch --- */
.macos-toggle {
    appearance: none;
    width: 2.75rem;
    height: 1.5rem;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 100px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: none;
    outline: none;
}

.macos-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.5rem - 4px);
    height: calc(1.5rem - 4px);
    background: white;
    border-radius: 50%;
    box-shadow: none;
    transition: transform 0.2s ease;
}

.macos-toggle:checked {
    background: var(--primary-color);
}

.macos-toggle:checked::after {
    transform: translateX(1.25rem);
    box-shadow: none;
}

/* --- MacOS Search/Command Bar --- */
#command-bar-input,
#omni-search-input {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: none !important;
    border-radius: 1rem !important;
}

/* --- Synergy Gauge Animation --- */
@keyframes synGaugeFill {
    from { stroke-dasharray: 0 339.292; }
}
.syn-gauge-circle {
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}
.syn-gauge-bg {
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

/* --- Synergy Skeleton: transform shimmer (compositor-only).
   Batch 1b: was a background-position animation, which repainted on the main
   thread every frame for every placeholder. Same look, no per-frame paint. --- */
.syn-skeleton {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
    border-radius: 12px;
}
.syn-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, #e8e8e8, transparent);
    animation: synShimmer 1.4s ease-in-out infinite;
}
@keyframes synShimmer {
    100% { transform: translateX(100%); }
}

/* --- Synergy Tooltips --- */
.syn-tip {
    position: relative;
    cursor: help;
}
.syn-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: #1f2937;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 150ms ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    line-height: 1.4;
    max-width: 220px;
    white-space: normal;
    text-transform: none;
    letter-spacing: normal;
}
.syn-tip:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* --- Synergy Anchor Nav --- */
.syn-anchor-nav {
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}
.syn-anchor-nav::-webkit-scrollbar { display: none; }
#view-synergy { content-visibility: visible !important; }
.syn-nav-btn {
    flex-shrink: 0;
    border: 1px solid transparent;
}

/* Anchor nav active button — light mode */
.syn-nav-btn.active {
    background: rgba(151, 184, 129, 0.25) !important;
    color: #4d6f3a !important;
}

/* --- MacOS Tooltip --- */
.macos-tooltip {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.88)) !important;
    border-radius: 0.5rem !important;
    padding: 0.375rem 0.75rem !important;
    font-size: 0.75rem !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* --- MacOS Toast --- */
#toast-container > div {
    background: #ffffff !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    border-radius: 1rem !important;
    box-shadow: var(--shadow-floating) !important;
}

/* --- MacOS Drawer Enhancements --- */
#more-drawer {
    background: #ffffff !important;
    border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 -8px 40px -8px rgba(0, 0, 0, 0.12) !important;
}

#more-drawer-backdrop {
    background: rgba(0, 0, 0, 0.25) !important;
}

/* --- MacOS Tab Content Animations --- */
.tab-content {
    animation: macosSpringUp 0.4s var(--spring-soft) forwards;
}

/* --- Auto-enhance existing cards with MacOS styling --- */
.bg-white.rounded-2xl.shadow-sm,
.bg-white.rounded-xl.shadow-sm,
.bg-white.rounded-2xl.border,
.bg-white.rounded-xl.border,
section.bg-white,
[class*="section-shell-card"] {
    position: relative;
    overflow: hidden;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.35s var(--spring-snappy);
}

.bg-white.rounded-2xl.shadow-sm:hover,
.bg-white.rounded-xl.shadow-sm:hover,
.bg-white.rounded-2xl.border:hover,
.bg-white.rounded-xl.border:hover {
    transform: none;
    border-color: rgba(151, 184, 129, 0.18);
}

.bg-white.rounded-2xl.shadow-sm::before,
.bg-white.rounded-xl.shadow-sm::before,
.bg-white.rounded-2xl.border::before,
.bg-white.rounded-xl.border::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    opacity: 0.5;
    pointer-events: none;
    z-index: 1;
}

/* --- Auto-enhance buttons with MacOS styling --- */
button[class*="bg-gradient-to-r"],
button[class*="bg-sage"],
button[class*="from-sage"] {
    position: relative;
    overflow: hidden;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

button[class*="bg-gradient-to-r"]::before,
button[class*="bg-sage"]::before,
button[class*="from-sage"]::before {
    display: none;
}

button[class*="bg-gradient-to-r"]:active,
button[class*="bg-sage"]:active,
button[class*="from-sage"]:active {
    opacity: 0.8;
}

/* --- MacOS Subtle Background Texture --- */
body {
    background-image:
        radial-gradient(circle at 0% 0%, rgba(151, 184, 129, 0.04) 0%, transparent 30%),
        radial-gradient(circle at 100% 100%, rgba(232, 141, 120, 0.04) 0%, transparent 30%),
        radial-gradient(circle at 50% 50%, rgba(143, 184, 202, 0.02) 0%, transparent 50%);
}

/* --- Responsive MacOS adjustments --- */
@media (max-width: 767px) {
    /* Ensure floating dock doesn't get cut off on very small screens */
    #mobile-bottom-nav > div {
        max-width: calc(100vw - 2rem);
        overflow-x: auto;
        scrollbar-width: none;
    }
    
    #mobile-bottom-nav > div::-webkit-scrollbar {
        display: none;
    }
}

/* Tablet portrait: sidebar collapsed with glassmorphism */
@media (min-width: 768px) and (max-width: 1023px) {
    .rail-sidebar {
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.8)) !important;
    }
}

/* ==========================================================================
   SECTION 58: macOS-STYLE TITLEBAR ENHANCEMENTS
   Native-inspired toolbar patterns for section headers.
   ========================================================================== */

/* Native Segmented Control (like Safari/Xcode toolbar) */
.macos-segmented-control {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(248,250,252,0.88));
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 0.8rem;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03), 0 1px 0 rgba(255,255,255,0.6);
    gap: 0.08rem;
}

.macos-segmented-control button,
.macos-segmented-control .segment-btn {
    position: relative;
    padding: 0.42rem 0.8rem;
    border-radius: 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.15s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    white-space: nowrap;
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.macos-segmented-control button:hover,
.macos-segmented-control .segment-btn:hover {
    color: #475569;
    background: rgba(148, 163, 184, 0.08);
}

.macos-segmented-control button.active,
.macos-segmented-control button[data-active="true"],
.macos-segmented-control .segment-btn.active {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    color: var(--secondary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,1);
    border: 1px solid var(--secondary-color);
}

/* Toolbar Action Group (like Finder toolbar) */
.macos-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.28rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(248,250,252,0.82));
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 0.9rem;
    box-shadow: 0 10px 20px -18px rgba(15, 23, 42, 0.3), inset 0 1px 0 rgba(255,255,255,0.9);
}

.macos-toolbar-group .macos-toolbar-divider {
    width: 1px;
    height: 1.2rem;
    background: rgba(148, 163, 184, 0.18);
    margin: 0 0.15rem;
    flex-shrink: 0;
}

.macos-toolbar-group button {
    width: 2.1rem;
    height: 2.1rem;
    min-width: 2.1rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.7rem;
    color: #64748b;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.15s ease;
    cursor: pointer;
}

.macos-toolbar-group button:hover {
    background: rgba(255,255,255,0.95);
    border-color: rgba(148, 163, 184, 0.18);
    color: var(--primary-dark);
}

.macos-toolbar-group button:active {
    opacity: 0.8;
}

/* Document Proxy Badge (like macOS document icon) */
.macos-proxy-badge {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.85rem;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.macos-proxy-badge::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.macos-proxy-badge.sage {
    background: linear-gradient(135deg, rgba(151,184,129,0.18), rgba(151,184,129,0.06)) !important;
    border: 1px solid rgba(151,184,129,0.18) !important;
    color: #5a7a4a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 5px -2px rgba(151,184,129,0.18);
}

.macos-proxy-badge.ocean {
    background: linear-gradient(135deg, rgba(143,184,202,0.18), rgba(143,184,202,0.06)) !important;
    border: 1px solid rgba(143,184,202,0.18) !important;
    color: #4a7a8a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 5px -2px rgba(143,184,202,0.18);
}

.macos-proxy-badge.coral {
    background: linear-gradient(135deg, rgba(232,141,120,0.14), rgba(232,141,120,0.05)) !important;
    border: 1px solid rgba(232,141,120,0.16) !important;
    color: #b0604a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 5px -2px rgba(232,141,120,0.14);
}

.macos-proxy-badge.lavender {
    background: linear-gradient(135deg, rgba(196,181,212,0.18), rgba(196,181,212,0.06)) !important;
    border: 1px solid rgba(196,181,212,0.18) !important;
    color: #7a6a8a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 5px -2px rgba(196,181,212,0.15);
}

.macos-proxy-badge.sun {
    background: linear-gradient(135deg, rgba(236,212,137,0.18), rgba(236,212,137,0.06)) !important;
    border: 1px solid rgba(236,212,137,0.18) !important;
    color: #8a7a3a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 5px -2px rgba(236,212,137,0.14);
}

.macos-proxy-badge.clay {
    background: linear-gradient(135deg, rgba(235,160,126,0.14), rgba(235,160,126,0.05)) !important;
    border: 1px solid rgba(235,160,126,0.16) !important;
    color: #a06a50;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 5px -2px rgba(235,160,126,0.12);
}

.macos-proxy-badge i {
    width: 1.1rem;
    height: 1.1rem;
    position: relative;
    z-index: 1;
}

/* Title Cluster (tight vertical rhythm) */
.macos-title-cluster {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 0;
    flex: 1 1 auto;
}

.macos-title-cluster > div:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.macos-title-cluster h2 {
    font-size: clamp(1rem, 0.9rem + 0.4vw, 1.22rem) !important;
    line-height: 1.15 !important;
    letter-spacing: -0.025em !important;
}

.macos-title-cluster p {
    margin-top: 0.12rem !important;
    font-size: 0.68rem !important;
    line-height: 1.3 !important;
    color: #8896aa !important;
}

/* Path Bar (breadcrumb trail) */
.macos-path-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    margin-top: 0.4rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(248,250,252,0.45));
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 0.6rem;
    font-size: 0.66rem;
    color: #94a3b8;
    width: fit-content;
}

.macos-path-bar .path-segment {
    font-weight: 700;
    color: #64748b;
}

.macos-path-bar .path-segment.active {
    color: var(--primary-dark);
}

.macos-path-bar i {
    width: 0.7rem;
    height: 0.7rem;
    color: #cbd5e1;
}

/* Live Status Chips (inline with title) */
.macos-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 0.55rem;
    font-size: 0.68rem;
    font-weight: 700;
    border: 1px solid;
    white-space: nowrap;
}

.macos-status-chip .status-dot {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 999px;
    flex-shrink: 0;
}

.macos-status-chip.sage {
    background: rgba(151,184,129,0.08);
    border-color: rgba(151,184,129,0.15);
    color: var(--primary-dark);
}

.macos-status-chip.sage .status-dot { background: var(--primary-color); }

.macos-status-chip.ocean {
    background: rgba(143,184,202,0.08);
    border-color: rgba(143,184,202,0.15);
    color: var(--ocean-dark);
}

.macos-status-chip.ocean .status-dot { background: var(--ocean); }

.macos-status-chip.coral {
    background: rgba(232,141,120,0.06);
    border-color: rgba(232,141,120,0.12);
    color: var(--secondary-dark);
}

.macos-status-chip.coral .status-dot { background: var(--secondary-color); }

.macos-status-chip.sun {
    background: rgba(236,212,137,0.08);
    border-color: rgba(236,212,137,0.15);
    color: var(--sun-dark);
}

.macos-status-chip.sun .status-dot { background: var(--sun); }

/* ---- Responsive ---- */
@media (max-width: 767px) {
    .macos-title-cluster {
        gap: 0.6rem;
    }
    
    .macos-proxy-badge {
        width: 2.05rem;
        height: 2.05rem;
        border-radius: 0.7rem;
    }
    
    .macos-proxy-badge i {
        width: 1rem;
        height: 1rem;
    }
    
    .macos-segmented-control {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.15rem;
        justify-content: center;
    }
    
    .macos-segmented-control button,
    .macos-segmented-control .segment-btn {
        flex: 0 1 auto;
        min-width: 0;
        padding: 0.4rem 0.55rem;
        font-size: 0.68rem;
    }
    
    .macos-toolbar-group {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .macos-toolbar-group button {
        width: 2rem;
        height: 2rem;
        min-width: 2rem;
    }
    
    .macos-path-bar {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .macos-status-chip {
        padding: 0.2rem 0.5rem;
        font-size: 0.64rem;
    }
}

/* --- Smart Suggestion chips (Father / Mother / Sibling / Spouse / Duplicate) --- */
.smart-suggestion-host {
    font-feature-settings: "ss01", "cv11";
}
.smart-suggestion-host .smart-chip {
    position: relative;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.smart-suggestion-host .smart-chip:hover {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
}
.smart-suggestion-host .smart-chip button[data-action="link"] {
    transition: opacity 0.15s ease;
}
.smart-suggestion-host .smart-chip button[data-action="link"]:active {
    opacity: 0.7;
}
.smart-suggestion-host.smart-chip-spouse {
    width: 100%;
}
.smart-suggestion-host.smart-chip-spouse .smart-chip {
    width: 100%;
}
.smart-suggestion-host.smart-chip-spouse .smart-chip p {
    white-space: normal;
    word-break: break-word;
}
@media (max-width: 480px) {
    .smart-suggestion-host .smart-chip {
        padding: 0.4rem 0.5rem;
    }
    .smart-suggestion-host .smart-chip button[data-action="link"] {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* --- Print styles preserve existing --- */
@media print {
    .rail-sidebar,
    .app-shell-header,
    .app-shell-mobile-header,
    #mobile-bottom-nav,
    .modal-backdrop {
        display: none !important;
    }
}

/* ==========================================================================
   DROPDOWN OVERFLOW: Allow native select dropdowns to escape parent containers
   ========================================================================== */
select,
.category-dropdown,
appearance-none select {
    position: relative;
    z-index: 1;
}

/* When a select is focused/open, raise its z-index so the dropdown menu
   appears above sibling elements and parent overflow boundaries */
select:focus,
select:active,
.category-dropdown:focus {
    z-index: 100;
}

/* For parent containers that must stay overflow-hidden for layout but
   contain dropdowns, we use a CSS trick: the select itself stays inside
   but the native OS dropdown renders above everything */

/* Ensure dropdown options are never clipped by ancestor overflow:hidden */
select > option {
    overflow: visible !important;
}

/* Mobile: ensure select dropdowns render above all content */
@media (max-width: 768px) {
    select:focus,
    select:active,
    .category-dropdown:focus {
        z-index: 9999;
    }
}

/* ==========================================================================
   SECTION: Full-height scroll restructure + sticky floating header
   ==========================================================================
   Moves the vertical scroll from each inner view up to the main shell so
   the scrollbar spans the full viewport height. The floating capsule
   header becomes sticky inside the main scroll container; when scrolled,
   its background/box disappears so only the controls remain visible.
   ========================================================================== */

:root { --sticky-under-header: 0.75rem; }
@media (min-width: 1025px) {
    :root { --sticky-under-header: 4.5rem; }
}

/* Main column is now the single vertical scroll container */
.app-shell-main {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scroll-behavior: smooth;
    /* `auto` (not `thin`) keeps Chromium on the bespoke 14px bar below: Chrome
       ignores ::-webkit-scrollbar styling as soon as scrollbar-width is thin/none. */
    scrollbar-width: auto;
    scrollbar-color: var(--primary-color) transparent;
}

/* Gecko-only: Firefox has no ::-webkit-scrollbar and its only width control is
   scrollbar-width (auto | thin | none) — `auto` is the fat native bar with
   stepper arrows, so cap it at `thin`. The @supports test is false in
   Chromium/WebKit/Safari, which keep their custom scrollbar above. */
@supports not selector(::-webkit-scrollbar) {
    .app-shell-main { scrollbar-width: thin; }
}

/* Wider, premium brand scrollbar for the main shell (Chromium/WebKit) */
/* Reserve the scrollbar lane so the header/content never shift sideways when a
   section is taller or shorter than the viewport. */
.app-shell-main {
    scrollbar-gutter: stable;
    overflow-anchor: none;
}
.app-shell-main::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}
.app-shell-main::-webkit-scrollbar-track {
    background:
        linear-gradient(180deg, rgba(151, 184, 129, 0.05), rgba(151, 184, 129, 0.02)),
        transparent;
    border-radius: 100px;
    margin: 0.25rem 0;
}
.app-shell-main::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 100px;
    border: 3px solid transparent;
    background-clip: padding-box;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.app-shell-main::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
    border-radius: 100px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

/* Views flow into the main scroll container (no inner vertical scroll),
   growing to their content so the main scrollbar spans the full height. */
.app-shell-main > .tab-content {
    overflow: visible !important;
    flex: 1 1 auto !important;
}

/* #view-history keeps its dedicated table scroller (the IntersectionObserver
   for infinite scroll relies on a bounded #historyContainer clip box), so it
   stays a bounded flex item and is not reflowed into the main scroller. */
#view-history {
    overflow-y: auto !important;
    flex: 1 1 0% !important;
    min-height: 0 !important;
}

/* The floating header sticks to the top of the main scroll container.
   Its outer canvas stays transparent; only the inner pill is visible. */
.app-shell-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 40 !important;
    background: transparent !important;
}

/* Pin the header: fixed block size on desktop, own paint/layout containment and
   compositor layer, so section switches, scroll restoration and auth/sync
   re-renders can never nudge it. Reserved widths stop the pill's contents
   (Load Profile vs client chip, Login vs avatar) from reflowing the search bar. */
@media (min-width: 1024px) {
    .app-shell-header {
        height: calc(56px + 0.75rem);
        contain: layout style;
    }
}
.app-shell-header {
    transform: translateZ(0);
    backface-visibility: hidden;
}
@media (min-width: 1280px) {
    #top-client-status { min-width: 10.5rem; }
}
#user-status-container { min-width: 2.5rem; justify-content: flex-end; }
#user-status-container .avatar { flex-shrink: 0; }

/* Reset the previously-nested sticky on the pill itself; the header now
   carries the sticky behaviour so the pill simply rides along inside it. */
.app-shell-header .capsule-pill {
    position: static !important;
    top: auto !important;
    margin: 0.75rem auto 0 !important;
    transition: background 200ms cubic-bezier(0.16, 1, 0.3, 1),
                border-color 200ms cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* The capsule pill stays around the header while scrolling — keep its
   glass background, border and shadow so it reads as a floating capsule
   over the content at all scroll positions. */
.app-shell-header.is-scrolled .capsule-pill {
    background: #ffffff !important;
    box-shadow:
        0 10px 30px -10px rgba(15, 23, 42, 0.18),
        0 2px 6px -2px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
}

/* Inner sticky section headers stick just beneath the floating pill */
.section-page-header--sticky {
    top: var(--sticky-under-header) !important;
}

/* ============================================================ */
/* AVATAR SYSTEM — User Account Management                       */
/* ============================================================ */
.avatar {
    width: 36px; height: 36px;
    border-radius: 9999px;
    display: inline-flex; align-items: center; justify-content: center;
    color: white; font-weight: 600; font-size: 0.875rem;
    flex-shrink: 0; user-select: none;
    transition: opacity 150ms ease;
    cursor: pointer;
    background: linear-gradient(135deg, #97B881, #7da066);
}
.avatar:hover { opacity: 0.85; }
/* Top bar account photo/avatar: 2px coral ring */
#user-avatar-trigger, #mobile-user-status .avatar { border: 2px solid var(--secondary-color); box-sizing: border-box; }
/* Profile photo applied by acApplyAvatar(): the photo replaces the gradient, initials hide */
.avatar.has-photo { background-size: cover; background-position: center; background-repeat: no-repeat; color: transparent; }
.avatar-sm { width: clamp(26px, 4vw, 28px); height: clamp(26px, 4vw, 28px); font-size: 0.65rem; }
.avatar-lg { width: clamp(40px, 6vw, 48px); height: clamp(40px, 6vw, 48px); font-size: 1.125rem; }
.avatar-xl { width: clamp(52px, 9vw, 64px); height: clamp(52px, 9vw, 64px); font-size: 1.5rem; }
.avatar-coral { background: linear-gradient(135deg, #E88D78, #d67560); }
.avatar-ocean { background: linear-gradient(135deg, #8FB8CA, #6D94A6); }
.avatar-sun { background: linear-gradient(135deg, #ECD489, #C5AF6B); }
.avatar-lavender { background: linear-gradient(135deg, #C4B5D4, #9E8FB0); }
.avatar-clay { background: linear-gradient(135deg, #EBA07E, #C97E5E); }

/* Account Center Tab Styles */
.ac-tab {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #9ca3af;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 150ms cubic-bezier(0.16,1,0.3,1);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: 'Poppins', sans-serif;
}
.ac-tab.active { color: #7da066; border-bottom-color: #97B881; }
.ac-tab:hover:not(.active) { color: #4b5563; }

/* Account Dropdown */
#accountDropdown {
    position: fixed;
    z-index: 120;
    background: var(--bg-card, #ffffff);
    border-radius: 1rem;
    box-shadow: 0 20px 40px -6px rgba(0,0,0,0.1), 0 8px 16px -6px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color, #f1f5f9);
    padding: 0.375rem;
    min-width: 220px;
    max-width: calc(100vw - 1rem);
    transform-origin: top right;
}

/* Account Center — form rows */
.ac-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 150ms cubic-bezier(0.16,1,0.3,1);
    font-size: 0.875rem;
    color: #4b5563;
    text-decoration: none;
    min-height: 44px;
}
.ac-row:hover { background: #f0f7ec; color: #7da066; }
.ac-row svg { width: 18px; height: 18px; flex-shrink: 0; color: #9ca3af; }
.ac-row:hover svg { color: #97B881; }
.ac-row .ac-arrow { margin-left: auto; color: #9ca3af; }
.ac-row.danger { color: #E88D78; }
.ac-row.danger:hover { background: #fdf2f0; }
.ac-row.danger svg { color: #E88D78; }
.ac-row.cursor-default { cursor: default; }
.ac-row.cursor-default:hover { background: transparent; color: #4b5563; }
.ac-row.cursor-default:hover svg { color: #9ca3af; }

/* Account Center divider */
.ac-divider { height: 1px; background: var(--border-color, #f1f5f9); margin: 0.375rem 0.75rem; }

/* Intake link row (profile menus) */
.intake-link-row { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 10px; background: #f9fafb; border: 1px solid #e5e7eb; margin: 0 0.375rem; }
.intake-link-row .link-area { flex: 3; font-size: 11px; font-family: 'Courier New', monospace; color: #6b7280; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; padding: 4px 6px; border-radius: 6px; transition: background .15s; position: relative; }
.intake-link-row .link-area:hover { background: #e5e7eb; }
.intake-link-row .link-area .short-url,
.intake-link-row .link-area .full-url { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.intake-link-row .link-area .full-url { display: none; }
.intake-link-row .icon-btn { flex: 1; max-width: 28px; height: 26px; border-radius: 6px; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s; }
.intake-link-row .copy-btn { background: #6B8F71; color: white; }
.intake-link-row .copy-btn:hover { background: #4A6E50; }
.intake-link-row .share-btn { background: #D1E8F0; color: #3D6E82; }
.intake-link-row .share-btn:hover { background: #5B8FA8; color: white; }

/* Badge for notification count */
.ac-badge {
    margin-left: auto;
    background: #fdf2f0;
    color: #d67560;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    min-width: 20px;
    text-align: center;
}

/* Toggle switch for preferences */
.ac-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
    margin-left: auto;
}
.ac-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.ac-toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #e2e8f0;
    border-radius: 9999px;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 250ms cubic-bezier(0.16,1,0.3,1);
}
.ac-toggle .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 250ms cubic-bezier(0.16,1,0.3,1);
    box-shadow: none;
}
.ac-toggle input:checked + .slider { background: #97B881; }
.ac-toggle input:checked + .slider::before { transform: translateX(18px); }

/* Responsive: mobile bottom sheet for account modal */
@media (max-width: 768px) {
    #accountCenterModal {
        align-items: flex-end;
        padding: 0;
    }
    #accountCenterModal > div {
        border-radius: 1.5rem 1.5rem 0 0;
        max-width: 100%;
        height: 92dvh;
        max-height: 92dvh;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* ==========================================================================
   ACCOUNT CENTER v2 (two-pane layout) - Flat 2.0: no shadows/transforms/gradients on controls
   Scoped to #accountCenterModal. Dark mode overrides live in dark-mode.css.
   ========================================================================== */
#accountCenterModal {
    --acx-surface: #ffffff; --acx-surface-2: #f8faf7; --acx-border: #e5e7eb;
    --acx-text: #374151; --acx-muted: #6b7280; --acx-head: #1f2937;
    --acx-sage-light: #f0f7ec; --acx-sage: #97B881; --acx-sage-dark: #7da066; --acx-ok-text: #4a7c3f;
    --acx-coral: #E88D78; --acx-coral-light: #fdf2f0; --acx-danger-text: #b4533f;
    --acx-sun: #ECD489; --acx-sun-light: #FBF7E6; --acx-warn-text: #8a7330;
    --acx-ocean: #8FB8CA; --acx-ocean-light: #E8F3F8; --acx-info-text: #4d7a8c;
    --acx-lav: #C4B5D4; --acx-lav-light: #F5F0F9; --acx-lav-text: #7d6e90;
}
#accountCenterModal .hidden { display: none !important; }
.acx-frame { width: 100%; max-width: 56rem; background: var(--acx-surface); color: var(--acx-text); border: 1px solid var(--acx-border); border-radius: 1.25rem; overflow: hidden; display: flex; flex-direction: column; height: min(44rem, 90dvh); }
.acx-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--acx-border); flex-shrink: 0; }
.acx-logo { width: 2.25rem; height: 2.25rem; border-radius: 0.625rem; background: var(--acx-sage-light); color: var(--acx-sage-dark); display: grid; place-items: center; flex-shrink: 0; }
.acx-head h3 { font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 1rem; color: var(--acx-head); line-height: 1.2; }
.acx-head p { font-size: 0.625rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--acx-muted); }
.acx-grow { flex: 1; min-width: 0; }
.acx-icon-btn { border: 1px solid transparent; background: transparent; width: 2.75rem; height: 2.75rem; border-radius: 0.625rem; display: grid; place-items: center; color: var(--acx-muted); cursor: pointer; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.acx-icon-btn:hover { background: var(--acx-surface-2); }
.acx-chip { display: inline-flex; align-items: center; gap: 0.375rem; border: 1px solid var(--acx-sun); background: var(--acx-sun-light); color: var(--acx-warn-text); border-radius: 999px; padding: 0.3rem 0.75rem; font-size: 0.75rem; font-weight: 600; min-height: 2.25rem; cursor: pointer; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.acx-chip.ok { background: var(--acx-sage-light); border-color: var(--acx-sage); color: var(--acx-ok-text); }
.acx-chip svg { width: 1rem; height: 1rem; }

.acx-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 14rem 1fr; }
.acx-nav { padding: 0.75rem; border-right: 1px solid var(--acx-border); background: var(--acx-surface-2); display: flex; flex-direction: column; gap: 0.25rem; overflow-y: auto; }
.acx-tab { position: relative; display: flex; align-items: center; gap: 0.625rem; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 0.625rem 0.75rem; border-radius: 0.625rem; font-size: 0.875rem; font-weight: 500; color: var(--acx-muted); min-height: 2.75rem; cursor: pointer; box-shadow: none; transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.acx-tab:hover { background: var(--acx-surface); color: var(--acx-head); }
.acx-tab[aria-selected="true"] { background: var(--acx-sage-light); border-color: var(--acx-sage); color: var(--acx-sage-dark); font-weight: 600; }
.acx-tab svg { width: 1.125rem; height: 1.125rem; flex-shrink: 0; }
.acx-tab .acx-dot { margin-left: auto; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--acx-coral); }
.acx-tab .ac-badge { margin-left: auto; }
.acx-sep { height: 1px; background: var(--acx-border); margin: 0.5rem 0.25rem; }

.acx-content { overflow-y: auto; padding: 1.375rem; min-width: 0; }
.acx-panel { display: none; }
.acx-panel.on { display: block; }
.acx-h2 { font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 1.25rem; color: var(--acx-head); line-height: 1.25; }
.acx-sub { font-size: 0.75rem; color: var(--acx-muted); margin-bottom: 1rem; }
.acx-card { background: var(--acx-surface); border: 1px solid var(--acx-border); border-radius: 0.875rem; padding: 1rem; margin-bottom: 0.875rem; box-shadow: none; }
.acx-card.danger { border-color: var(--acx-coral); }
.acx-card h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--acx-muted); font-weight: 700; margin-bottom: 0.625rem; display: flex; align-items: center; gap: 0.5rem; }
.acx-card.danger h4 { color: var(--acx-danger-text); }
.acx-card h4 svg { width: 1rem; height: 1rem; }

.acx-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border-top: 1px solid var(--acx-border); }
.acx-row:first-of-type { border-top: 0; padding-top: 0.125rem; }
.acx-ico { width: 2.25rem; height: 2.25rem; border-radius: 0.625rem; background: var(--acx-surface-2); color: var(--acx-muted); display: grid; place-items: center; flex-shrink: 0; }
.acx-ico svg { width: 1.125rem; height: 1.125rem; }
.acx-t { font-weight: 600; color: var(--acx-head); font-size: 0.8125rem; display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; }
.acx-d { font-size: 0.75rem; color: var(--acx-muted); }
.acx-act { flex-shrink: 0; display: flex; align-items: center; gap: 0.5rem; }

.acx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; border: 1px solid var(--acx-border); background: var(--acx-surface); color: var(--acx-head); border-radius: 0.625rem; padding: 0.5rem 0.875rem; font-weight: 600; font-size: 0.8125rem; min-height: 2.5rem; cursor: pointer; box-shadow: none; text-decoration: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.acx-btn:hover { background: var(--acx-surface-2); border-color: var(--acx-sage); }
.acx-btn.primary { background: var(--acx-sage); border-color: var(--acx-sage-dark); color: #fff; }
.acx-btn.primary:hover { background: var(--acx-sage-dark); }
.acx-btn.danger { color: var(--acx-danger-text); border-color: var(--acx-coral); }
.acx-btn.danger:hover { background: var(--acx-coral-light); }
.acx-btn.sm { padding: 0.3rem 0.625rem; min-height: 2rem; font-size: 0.75rem; }
.acx-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.acx-btn svg { width: 1rem; height: 1rem; }
.acx-pill { display: inline-flex; align-items: center; gap: 0.25rem; border-radius: 999px; padding: 0.125rem 0.5rem; font-size: 0.6875rem; font-weight: 600; border: 1px solid var(--acx-border); background: var(--acx-surface-2); color: var(--acx-muted); }
.acx-pill.ok { background: var(--acx-sage-light); border-color: var(--acx-sage); color: var(--acx-ok-text); }
.acx-pill.warn { background: var(--acx-sun-light); border-color: var(--acx-sun); color: var(--acx-warn-text); }
.acx-pill.info { background: var(--acx-ocean-light); border-color: var(--acx-ocean); color: var(--acx-info-text); }
.acx-pill.lav { background: var(--acx-lav-light); border-color: var(--acx-lav); color: var(--acx-lav-text); }
.acx-pill svg { width: 0.75rem; height: 0.75rem; }

.acx-hero { display: flex; gap: 1rem; align-items: center; }
.acx-who { min-width: 0; }
.acx-who h3 { font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 1.125rem; color: var(--acx-head); line-height: 1.25; overflow-wrap: anywhere; }
.acx-line { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; align-items: center; font-size: 0.8125rem; color: var(--acx-muted); margin-top: 0.125rem; }
.acx-meter { margin-top: 0.875rem; }
.acx-meter .top { display: flex; justify-content: space-between; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; color: var(--acx-muted); }
.acx-meter .track { height: 0.5rem; background: var(--acx-surface-2); border: 1px solid var(--acx-border); border-radius: 99px; overflow: hidden; margin-top: 0.375rem; }
.acx-meter .fill { height: 100%; background: var(--acx-sage); border-radius: 99px; transition: width 0.25s ease; }
.acx-meter summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; font-weight: 600; color: var(--acx-sage-dark); margin-top: 0.625rem; min-height: 2rem; }
.acx-meter summary::-webkit-details-marker { display: none; }
.acx-todo { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.375rem 0.875rem; }
.acx-todo li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; }
.acx-todo li.done { color: var(--acx-muted); text-decoration: line-through; }
.acx-todo .tick { width: 1rem; height: 1rem; border-radius: 50%; border: 1.5px solid var(--acx-border); display: grid; place-items: center; flex-shrink: 0; }
.acx-todo li.done .tick { background: var(--acx-sage); border-color: var(--acx-sage); color: #fff; }
.acx-todo .tick svg { width: 0.625rem; height: 0.625rem; }
.acx-todo button { border: 0; background: none; color: var(--acx-sage-dark); font-weight: 600; font-size: 0.75rem; padding: 0.125rem 0.25rem; text-decoration: underline; cursor: pointer; }

.acx-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 0.875rem; }
.acx-field label { display: block; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--acx-muted); margin-bottom: 0.25rem; }
.acx-field input { width: 100%; border: 1px solid var(--acx-border); background: var(--acx-surface-2); color: var(--acx-text); border-radius: 0.625rem; padding: 0.625rem 0.75rem; font: inherit; font-size: 0.875rem; min-height: 2.75rem; box-shadow: none; transition: border-color 0.15s ease, background-color 0.15s ease; }
.acx-field input:focus { outline: none; border-color: var(--acx-sage); background: var(--acx-surface); }
.acx-savebar { display: none; align-items: center; justify-content: space-between; gap: 0.625rem; flex-wrap: wrap; margin-top: 0.875rem; padding: 0.625rem 0.75rem; background: var(--acx-sun-light); border: 1px solid var(--acx-sun); border-radius: 0.625rem; color: var(--acx-warn-text); font-size: 0.75rem; font-weight: 600; }
.acx-savebar.on { display: flex; }
.acx-dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.875rem; margin-top: 0.875rem; padding-top: 0.875rem; border-top: 1px solid var(--acx-border); }
.acx-dl dt { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--acx-muted); }
.acx-dl dd { font-size: 0.8125rem; color: var(--acx-head); margin: 0; overflow-wrap: anywhere; }
.acx-box { margin-top: 0.625rem; padding: 0.75rem; border: 1px dashed var(--acx-border); border-radius: 0.625rem; background: var(--acx-surface-2); }
.acx-alert { display: flex; gap: 0.625rem; align-items: flex-start; padding: 0.625rem 0.75rem; border-radius: 0.625rem; font-size: 0.75rem; border: 1px solid var(--acx-border); background: var(--acx-surface-2); margin-top: 0.625rem; }
.acx-alert.info { background: var(--acx-ocean-light); border-color: var(--acx-ocean); color: var(--acx-info-text); }
.acx-alert.warn { background: var(--acx-sun-light); border-color: var(--acx-sun); color: var(--acx-warn-text); }
.acx-alert.danger { background: var(--acx-coral-light); border-color: var(--acx-coral); color: var(--acx-danger-text); }
.acx-alert svg { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: 0.125rem; }
.acx-dev { display: flex; gap: 0.75rem; align-items: center; padding: 0.75rem 0; border-top: 1px solid var(--acx-border); }
.acx-dev:first-child { border-top: 0; padding-top: 0; }
.acx-dev .acx-ico { width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; }
.acx-dev.cur .acx-ico { background: var(--acx-sage-light); color: var(--acx-sage-dark); }
.acx-more { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; font-weight: 600; color: var(--acx-sage-dark); margin-top: 0.75rem; min-height: 2rem; }
.acx-more::-webkit-details-marker { display: none; }

/* Tablet/phone: bottom-sheet modal (existing rule) + bottom tab bar */
@media (max-width: 768px) {
    .acx-frame { height: 100%; max-height: none; border-radius: 0; border: 0; }
    .acx-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .acx-nav { order: 2; flex-direction: row; border-right: 0; border-top: 1px solid var(--acx-border); padding: 0.375rem; gap: 0.125rem; overflow-x: auto; overflow-y: hidden; }
    .acx-tab { flex-direction: column; gap: 0.125rem; font-size: 0.625rem; padding: 0.375rem 0.25rem; min-width: 4rem; justify-content: center; text-align: center; min-height: 2.75rem; }
    .acx-sep { display: none; }
    .acx-tab .acx-dot, .acx-tab .ac-badge { position: absolute; top: 0.25rem; right: 0.75rem; margin: 0; }
    .acx-content { padding: 0.875rem; }
    .acx-head p { display: none; }
    .acx-fields, .acx-dl, .acx-todo { grid-template-columns: 1fr; }
    .acx-hero { flex-direction: column; text-align: center; }
    .acx-line { justify-content: center; }
    .acx-row { flex-wrap: wrap; }
    .acx-row .acx-act { width: 100%; }
    .acx-row .acx-act .acx-btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .acx-meter .fill, .acx-btn, .acx-tab, .acx-chip { transition: none; } }

/* ==========================================================================
   LOGIN PRELOADER: js/app_preloader.js
   Lightweight splash: the brand compact lockup (docs/brand/logo/horizontal-compact), a hairline progress underline (--ppl-p, 0-1, set by the script) and
   one status line. No gradients, shadows, blur or loops: only a scaleX/opacity change driven by real load
   progress. Sized in container units of the full-screen overlay so it scales from a 320px phone to a monitor.
   ========================================================================== */
.ppl { --ppl-ink-m: var(--text-secondary, #4b5563);
    position: fixed; inset: 0; z-index: 400; container-type: size; overflow: hidden; display: none; opacity: 0; transition: opacity 0.3s ease; outline: none;
    background: var(--bg-card, #ffffff); color: var(--text-primary, #1f2937); }
.ppl:not(.ppl-off) { display: block; }
.ppl.ppl-on { opacity: 1; }
.ppl.ppl-off { display: none; }
.ppl-col { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: max(12px, 2.6vh); gap: max(12px, 2.6cqh); padding: max(16px, calc(4vmin + env(safe-area-inset-top))) max(16px, 5vw) max(16px, calc(4vmin + env(safe-area-inset-bottom))); padding: max(16px, calc(4cqmin + env(safe-area-inset-top))) max(16px, 5cqw) max(16px, calc(4cqmin + env(safe-area-inset-bottom))); }
.ppl-logo { display: block; width: min(320px, 58vmin); width: clamp(180px, 58cqmin, 320px); height: auto; max-width: 80vw; max-width: 80cqw; opacity: calc(0.35 + var(--ppl-p, 0) * 0.65); }
.ppl-ul { width: min(240px, 46vmin); width: clamp(120px, 46cqmin, 240px); height: 2px; border-radius: 2px; overflow: hidden; background: var(--border-color, #e5e7eb); }
.ppl-ul i { display: block; height: 100%; background: var(--primary-color, #97B881); transform-origin: left center; transform: scaleX(var(--ppl-p, 0)); }
.ppl-below { display: flex; flex-direction: column; align-items: center; text-align: center; min-height: 1.5rem; }
.ppl-stage { font-size: max(11px, 2.4vmin); font-size: max(11px, 2.4cqmin); color: var(--ppl-ink-m); }
.ppl-err { max-width: min(86vw, 26rem); max-width: min(86cqw, 26rem); font-size: max(11px, 2.3vmin); font-size: max(11px, 2.3cqmin); color: var(--ppl-ink-m); }
.ppl-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 0.625rem; }
.ppl-acts button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: 0.5rem 0.875rem; border: 1px solid var(--border-strong, #e2e8f0); border-radius: 0.625rem; background: var(--bg-card, #ffffff); color: var(--text-primary, #1f2937); font-size: 0.8125rem; font-weight: 600; box-shadow: none; cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease; }
.ppl-acts button:hover { border-color: var(--primary-color, #97B881); }
.ppl-acts button.primary { background: var(--primary-color, #97B881); border-color: var(--primary-dark, #7da066); color: #ffffff; }
.ppl-acts button.primary:hover { background: var(--primary-dark, #7da066); }
.ppl :focus-visible { outline: 2px solid var(--primary-color, #97B881); outline-offset: 2px; }
.ppl-hide { display: none !important; }

/* Avatar in dropdown header */
.ac-dd-avatar { width: 40px; height: 40px; font-size: 1rem; }

/* Avatar print hidden */
@media print {
    .avatar, #accountDropdown, #accountCenterModal { display: none !important; }
}


/* ==========================================================================
   SOLID OPAQUE TABLE HEADERS (NO TRANSPARENCY / NO BLUR)
   ========================================================================== */
#historyTable thead,
#resultsTable thead,
#view-intelligence thead,
#view-history thead,
thead {
    background: #f8fafc !important;
    background-color: #f8fafc !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    opacity: 1 !important;
}

#historyTable thead tr,
#historyTable thead th,
#resultsTable thead tr,
#resultsTable thead th,
#view-intelligence thead tr,
#view-intelligence thead th,
#view-history thead tr,
#view-history thead th,
thead tr,
thead th {
    background-color: #f8fafc !important;
    opacity: 1 !important;
}

/* ==========================================================================
   QUICK EVENT LOGGER (MILESTONES)
   Layout: one responsive component. >=900px is the V2 split workspace
   (rail | tag pager | composer + timeline); below that it collapses to the
   V1 single column with a chip row and the composer pinned to the bottom.
   Interaction: the tag list is a native scroll-snap pager, so switching
   category is a swipe and never a 215-item scroll hunt.
   Flat 2.0: solid fills, 1px borders, no box-shadow / transform / gradient
   on any control, colour-only hover feedback.
   ========================================================================== */

#milestoneModal {
    --ms-surface: #ffffff;
    --ms-surface-2: #f7f9fb;
    --ms-surface-3: #eef2f5;
    --ms-line: #e8eef4;
    --ms-line-2: #d6dee6;
    --ms-ink: var(--text-primary);
    --ms-ink-2: var(--text-secondary);
    --ms-ink-3: var(--text-muted);
    --ms-accent: var(--primary-color);
    --ms-accent-dark: var(--primary-dark);
    --ms-accent-light: var(--primary-light);
    --ms-sun: #C5AF6B;
    --ms-sun-light: #FBF7E6;
}

.dark #milestoneModal {
    --ms-surface: #222831;
    --ms-surface-2: #1b2027;
    --ms-surface-3: #2a313b;
    --ms-line: #2f3742;
    --ms-line-2: #3b4552;
    --ms-ink: #e8edf3;
    --ms-ink-2: #b6c0cc;
    --ms-ink-3: #7f8b99;
    --ms-accent-light: rgba(151, 184, 129, 0.14);
    --ms-sun: #ECD489;
    --ms-sun-light: rgba(236, 212, 137, 0.14);
}

/* The app has a dark-mode safety net (.dark [id$="Modal"] input/textarea with
   !important) that is deliberately load-bearing for its other modals. Rather than
   remove it, the logger states its own dark values for the two fields it owns, so
   the outcome is explicit and independent of declaration order. */
.dark #milestoneModal .ms-search input,
.dark #milestoneModal .ms-notewrap textarea {
    background-color: var(--ms-surface-2) !important;
    background-image: none !important;
    border-color: var(--ms-line-2) !important;
    color: var(--ms-ink) !important;
}
.dark #milestoneModal .ms-search input::placeholder,
.dark #milestoneModal .ms-notewrap textarea::placeholder {
    color: var(--ms-ink-3) !important;
}

/* --- Lucide sizing. The class travels from <i data-lucide> onto the <svg>. --- */
#milestoneModal svg.ms-i12 { width: 0.75rem; height: 0.75rem; }
#milestoneModal svg.ms-i13 { width: 0.8125rem; height: 0.8125rem; }
#milestoneModal svg.ms-i14 { width: 0.875rem; height: 0.875rem; }
#milestoneModal svg.ms-i15 { width: 0.9375rem; height: 0.9375rem; }
#milestoneModal svg.ms-i16 { width: 1rem; height: 1rem; }
#milestoneModal svg.ms-i18 { width: 1.125rem; height: 1.125rem; }
#milestoneModal svg { flex-shrink: 0; }

/* --- shell --- */
#milestoneModal {
    padding: 0;
}
#milestoneModal .ms-shell {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--ms-surface);
}

@media (min-width: 768px) {
    #milestoneModal { padding: 1rem; }
    #milestoneModal .ms-shell {
        height: auto;
        max-height: 92dvh;
        max-width: 46rem;
        border-radius: 1rem;
        border: 1px solid var(--ms-line);
    }
}

@media (min-width: 1100px) {
    #milestoneModal .ms-shell { max-width: 62rem; }
}

@media (min-width: 1400px) {
    #milestoneModal .ms-shell { max-width: 78rem; }
}

/* --- header --- */
#milestoneModal .ms-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--ms-line);
    background-color: var(--ms-surface);
    flex-shrink: 0;
}
#milestoneModal .ms-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    background-color: var(--ms-accent-light);
    color: var(--ms-accent-dark);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
#milestoneModal .ms-headtext { min-width: 0; }
#milestoneModal .ms-headtitle {
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.15;
    color: var(--ms-ink);
}
#milestoneModal .ms-headsub {
    font-size: 0.6875rem;
    color: var(--ms-ink-3);
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#milestoneModal .ms-headctl {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}
#milestoneModal .ms-icbtn {
    height: 2.75rem;
    min-width: 2.75rem;
    padding: 0 0.5rem;
    border-radius: 0.6rem;
    border: 1px solid var(--ms-line-2);
    background-color: var(--ms-surface-2);
    color: var(--ms-ink-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    font-family: inherit;
    font-size: 0.6875rem;
    font-weight: 600;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#milestoneModal .ms-icbtn:hover {
    background-color: var(--ms-accent-light);
    border-color: var(--ms-accent);
    color: var(--ms-accent-dark);
}
#milestoneModal .ms-icbtn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
#milestoneModal .ms-icbtn:focus-visible,
#milestoneModal .ms-btn:focus-visible,
#milestoneModal .ms-tag:focus-visible,
#milestoneModal .ms-railrow:focus-visible,
#milestoneModal .ms-chip:focus-visible,
#milestoneModal .ms-pill:focus-visible,
#milestoneModal .ms-repeat:focus-visible {
    outline: 2px solid var(--ms-accent);
    outline-offset: 2px;
}
#milestoneModal .ms-agepill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    height: 2.75rem;
    padding: 0 0.7rem;
    border-radius: 0.6rem;
    font-size: 0.8125rem;
    font-weight: 700;
    background-color: var(--ms-accent-light);
    color: var(--ms-accent-dark);
    border: 1px solid var(--ms-accent);
}
#milestoneModal .ms-ageyear {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ms-ink-3);
    font-variant-numeric: tabular-nums;
    padding: 0 0.15rem;
}
#milestoneModal .ms-histbtn[aria-pressed="true"] {
    background-color: var(--ms-accent);
    border-color: var(--ms-accent-dark);
    color: #fff;
}
#milestoneModal .ms-histbtn[aria-pressed="true"]:hover { color: #fff; }

/* --- body: rail | mid | side --- */
#milestoneModal .ms-split {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#milestoneModal .ms-rail { display: none; }
#milestoneModal .ms-side {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background-color: var(--ms-surface);
}

@media (min-width: 900px) {
    #milestoneModal .ms-split {
        display: grid;
        grid-template-columns: 3.75rem minmax(0, 1fr) 19rem;
    }
    #milestoneModal .ms-rail {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        padding: 0.5rem 0.35rem;
        border-right: 1px solid var(--ms-line);
        background-color: var(--ms-surface-2);
        overflow-y: auto;
        scrollbar-width: thin;
    }
    #milestoneModal .ms-side {
        border-left: 1px solid var(--ms-line);
        min-height: 0;
    }
}

@media (min-width: 1280px) {
    #milestoneModal .ms-split { grid-template-columns: 12.5rem minmax(0, 1fr) 21rem; }
}

/* --- rail rows --- */
#milestoneModal .ms-railrow {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.4rem;
    border: 1px solid transparent;
    border-radius: 0.6rem;
    background-color: transparent;
    color: var(--ms-ink-2);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#milestoneModal .ms-railrow:hover {
    background-color: var(--ms-surface);
    border-color: var(--ms-line-2);
}
#milestoneModal .ms-railrow[aria-current="true"] {
    background-color: var(--ms-surface);
    border-color: var(--ms-accent);
    color: var(--ms-accent-dark);
}
#milestoneModal .ms-railrow[data-scope="Recent"] svg { color: var(--ms-sun); }
#milestoneModal .ms-railrow[aria-current="true"][data-scope="Recent"] svg { color: var(--ms-sun); }
#milestoneModal .ms-rail-label,
#milestoneModal .ms-rail-count { display: none; }
#milestoneModal .ms-rail-count {
    font-style: normal;
    font-size: 0.625rem;
    color: var(--ms-ink-3);
    font-variant-numeric: tabular-nums;
}
@media (min-width: 1280px) {
    #milestoneModal .ms-railrow { justify-content: flex-start; padding: 0.4rem 0.55rem; }
    #milestoneModal .ms-rail-label {
        display: block;
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #milestoneModal .ms-rail-count { display: block; }
}

/* --- mid column --- */
#milestoneModal .ms-mid {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#milestoneModal .ms-midhead { padding: 0.7rem 0.9rem 0.35rem; flex-shrink: 0; }
#milestoneModal .ms-midtitle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--ms-ink);
}
#milestoneModal .ms-midtitle svg { color: var(--ms-accent-dark); }
#milestoneModal .ms-midsub { font-size: 0.6875rem; color: var(--ms-ink-3); margin-top: 0.15rem; }

/* --- chips (narrow only) --- */
#milestoneModal .ms-chips {
    position: relative;   /* so a chip's offsetLeft is relative to the row */
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--ms-line);
    background-color: var(--ms-surface-2);
    flex-shrink: 0;
    scrollbar-width: none;
}
#milestoneModal .ms-chips::-webkit-scrollbar { height: 0; }

/* The category rail replaces the chip row at >=900px.
   This block MUST sit after the base .ms-chips rule above: a media query declared
   earlier loses to a later base rule of equal specificity — the exact trap that
   shipped the chip row on desktop the first time round. */
@media (min-width: 900px) {
    #milestoneModal .ms-chips { display: none; }
}
#milestoneModal .ms-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 2.75rem;
    padding: 0 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--ms-line-2);
    background-color: var(--ms-surface);
    color: var(--ms-ink-2);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#milestoneModal .ms-chip:hover { border-color: var(--ms-accent); color: var(--ms-accent-dark); }
#milestoneModal .ms-chip[aria-current="true"] {
    background-color: var(--ms-accent);
    border-color: var(--ms-accent-dark);
    color: #fff;
}
#milestoneModal .ms-chip .ms-chip-n {
    opacity: 0.65;
    font-size: 0.625rem;
    font-variant-numeric: tabular-nums;
}

/* --- search --- */
#milestoneModal .ms-search { position: relative; padding: 0.55rem 0.9rem 0.2rem; flex-shrink: 0; }
#milestoneModal .ms-search > svg {
    position: absolute;
    left: 1.5rem;
    top: 1.45rem;
    color: var(--ms-ink-3);
    pointer-events: none;
}
#milestoneModal .ms-search input {
    width: 100%;
    font-family: inherit;
    font-size: 0.8125rem;
    height: 2.75rem;
    padding: 0 0.75rem 0 2.6rem;
    border-radius: 0.6rem;
    border: 1px solid var(--ms-line-2);
    background-color: var(--ms-surface-2);
    color: var(--ms-ink);
    outline: none;
    box-shadow: none;
    /* Opt out of the UA "field" painting entirely: without this the platform widget
       can paint its own light background and ignore ours inside a themed modal. */
    -webkit-appearance: none;
    appearance: none;
    background-image: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
#milestoneModal .ms-search input:focus {
    border-color: var(--ms-accent);
    background-color: var(--ms-surface);
}
#milestoneModal .ms-search input::placeholder { color: var(--ms-ink-3); }

/* --- swipe hint --- */
#milestoneModal .ms-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem 0;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--ms-ink-3);
    flex-shrink: 0;
}
#milestoneModal .ms-hint svg { color: var(--ms-accent); }
#milestoneModal .ms-hint .ms-pos { margin-left: auto; font-variant-numeric: tabular-nums; }
#milestoneModal .ms-hint .ms-pos b { color: var(--ms-accent-dark); }
#milestoneModal .ms-hint .ms-pos-l { display: none; }
#milestoneModal .ms-hint-swipe { display: inline-flex; align-items: center; gap: 0.35rem; }

/* On a pointer-driven machine there is no swipe (see the pager comment), so the
   swipe prompt is replaced by a plain category indicator. This block MUST come
   after the base rules above — an earlier media query loses to them. */
@media (min-width: 900px) {
    #milestoneModal .ms-hint-swipe { display: none; }
    #milestoneModal .ms-hint .ms-pos-l { display: inline; }
}

/* --- pager: native scroll-snap, no gesture JS --- */
/* The pager is swipe-only (touch). There is deliberately NO mouse drag-to-pan:
   on a pointer-driven machine the category rail / chip row is the navigation, and
   dragging a panel of buttons with a mouse felt wrong. The panes stay snap targets
   because a programmatic scrollTo() (chip tap, jump to age) still has to land on a
   pane boundary. */
#milestoneModal .ms-pager {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
    flex: 1;
    min-height: 0;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
#milestoneModal .ms-pager::-webkit-scrollbar { height: 0; display: none; }
/* On a pointer-driven machine the rail / chip row is the navigation, so the pager
   refuses user scrolling entirely — that removes trackpad and shift-wheel swiping too,
   not just mouse drag. Programmatic scrollTo() from a rail/chip tap still works, and
   the panes keep their snap points so the landing position is exact.
   This block must stay AFTER the base rule above (an earlier media query loses). */
@media (min-width: 900px) {
    #milestoneModal .ms-pager { overflow-x: hidden; }
}
#milestoneModal .ms-pane {
    flex: 0 0 100%;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    scroll-snap-align: start;
    padding: 0.5rem 0.9rem 0.9rem;
    scrollbar-width: thin;
}
#milestoneModal .ms-pane::-webkit-scrollbar { width: 0.4rem; }
#milestoneModal .ms-pane::-webkit-scrollbar-thumb {
    background-color: var(--ms-line-2);
    border-radius: 0.25rem;
}
#milestoneModal .ms-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem 0.9rem 0.9rem;
    scrollbar-width: thin;
}
#milestoneModal .ms-results::-webkit-scrollbar { width: 0.4rem; }
#milestoneModal .ms-results::-webkit-scrollbar-thumb {
    background-color: var(--ms-line-2);
    border-radius: 0.25rem;
}
/* Search replaces the category pager with one cross-category list. Tailwind's
   .hidden is 0,1,0 while the scope rules are 1,1,0, so without these the pager
   (and the swipe hint) stayed on screen under the results — which read as
   "search only finds tags from the category I am in". */
#milestoneModal .ms-pager.hidden,
#milestoneModal .ms-results.hidden,
#milestoneModal .ms-hint.hidden { display: none; }

/* --- tag grid --- */
#milestoneModal .ms-grid { display: grid; gap: 0.4rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px)  { #milestoneModal .ms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { #milestoneModal .ms-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1600px) { #milestoneModal .ms-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#milestoneModal .ms-catlabel {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0.45rem 0.15rem 0.4rem;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ms-ink-3);
}
#milestoneModal .ms-catlabel:before {
    content: '';
    width: 0.3rem;
    height: 0.3rem;
    border-radius: 50%;
    background-color: var(--ms-accent);
    flex-shrink: 0;
}

#milestoneModal .ms-tag {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.45rem 1.35rem 0.45rem 0.6rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25;
    text-align: left;
    color: var(--ms-ink-2);
    background-color: var(--ms-surface);
    border: 1px solid var(--ms-line-2);
    border-radius: 0.6rem;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#milestoneModal .ms-tag > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#milestoneModal .ms-tag:hover {
    background-color: var(--ms-accent-light);
    border-color: var(--ms-accent);
    color: var(--ms-accent-dark);
}
/* Active state is ONE attribute, not nine class toggles (see essence.js). */
#milestoneModal .ms-tag[data-active="true"] {
    background-color: var(--ms-accent);
    border-color: var(--ms-accent-dark);
    color: #ffffff;
    font-weight: 600;
}
/* Selected marker is drawn in CSS, not built as an icon node: selection changes
   on every tap, and a per-tag Lucide node would need an icon sweep per toggle. */
#milestoneModal .ms-tag[data-active="true"]:after {
    content: '';
    position: absolute;
    right: 0.6rem;
    top: 50%;
    width: 0.5rem;
    height: 0.28rem;
    border-left: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: translateY(-70%) rotate(-45deg);
    pointer-events: none;
}
#milestoneModal .ms-tag[data-active="true"] .ms-star { display: none; }
/* Frequency marker IS a Lucide star — it never changes, and panes are built lazily,
   so at most one category's worth of stars exist at a time. */
#milestoneModal svg.ms-star {
    position: absolute;
    right: 0.45rem;
    top: 0.4rem;
    width: 0.625rem;
    height: 0.625rem;
    color: var(--ms-sun);
    fill: var(--ms-sun);
    stroke-width: 1.5;
}

/* --- composer --- */
#milestoneModal .ms-composer {
    flex-shrink: 0;
    border-top: 1px solid var(--ms-line);
    background-color: var(--ms-surface);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
#milestoneModal .ms-activebox { padding: 0.6rem 0.9rem 0; }
#milestoneModal .ms-activelabel {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ms-ink-3);
}
#milestoneModal .ms-activelabel b { color: var(--ms-ink-2); }
#milestoneModal .ms-count {
    background-color: var(--ms-accent-light);
    color: var(--ms-accent-dark);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.625rem;
}
#milestoneModal .ms-repeat {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--ms-sun);
    background-color: var(--ms-sun-light);
    color: var(--ms-sun);
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
#milestoneModal .ms-repeat:hover { border-color: var(--ms-ink-3); }
#milestoneModal .ms-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-height: 1.75rem;
    align-items: flex-start;
}
#milestoneModal .ms-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.5rem 0.35rem 0.65rem;
    border-radius: 0.55rem;
    background-color: var(--ms-accent);
    border: 1px solid var(--ms-accent-dark);
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
#milestoneModal .ms-pill:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-dark);
}
#milestoneModal .ms-empty { font-size: 0.6875rem; font-style: italic; color: var(--ms-ink-3); padding: 0.3rem 0; }
#milestoneModal .ms-notewrap {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    padding: 0.6rem 0.9rem 0;
}
#milestoneModal .ms-notewrap > svg { color: var(--ms-ink-3); margin-top: 0.6rem; }
#milestoneModal .ms-notewrap textarea {
    flex: 1;
    min-height: 2.75rem;
    max-height: 6rem;
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.5;
    padding: 0.6rem 0.7rem;
    border-radius: 0.6rem;
    border: 1px solid var(--ms-line-2);
    background-color: var(--ms-surface-2);
    color: var(--ms-ink);
    outline: none;
    resize: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
#milestoneModal .ms-notewrap textarea:focus {
    border-color: var(--ms-accent);
    background-color: var(--ms-surface);
}
#milestoneModal .ms-notewrap textarea::placeholder { color: var(--ms-ink-3); }
#milestoneModal .ms-foot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem 0.75rem;
}
#milestoneModal .ms-btn {
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0 1rem;
    height: 2.75rem;
    border-radius: 0.6rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-shadow: none;
    transform: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
#milestoneModal .ms-btn-ghost {
    margin-right: auto;
    background-color: var(--btn-ghost-bg);
    border: 1px solid var(--btn-ghost-border);
    color: var(--btn-ghost-text);
}
#milestoneModal .ms-btn-ghost:hover {
    background-color: var(--ms-surface-2);
    border-color: var(--ms-ink-3);
}
#milestoneModal .ms-btn-primary {
    flex: 1;
    background-color: var(--btn-primary-bg);
    border: 1px solid var(--btn-primary-border);
    color: var(--btn-primary-text);
    font-weight: 700;
}
#milestoneModal .ms-btn-primary:hover { background-color: var(--btn-primary-hover); }

/* --- timeline --- */
#milestoneModal .ms-tlhead {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 0.9rem 0.35rem;
    border-top: 1px solid var(--ms-line);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ms-ink-3);
    flex-shrink: 0;
}
#milestoneModal .ms-tlhead .ms-tlcount { margin-left: auto; }
#milestoneModal .ms-timeline {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.4rem 0.9rem 0.9rem;
    scrollbar-width: thin;
}
#milestoneModal .ms-timeline::-webkit-scrollbar { width: 0.4rem; }
#milestoneModal .ms-timeline::-webkit-scrollbar-thumb {
    background-color: var(--ms-line-2);
    border-radius: 0.25rem;
}
#milestoneModal .ms-ev {
    position: relative;
    padding: 0 0 0.85rem 1rem;
    border-left: 2px solid var(--ms-line-2);
}
#milestoneModal .ms-ev:last-child { border-left-color: transparent; padding-bottom: 0.1rem; }
#milestoneModal .ms-ev:before {
    content: '';
    position: absolute;
    left: -0.32rem;
    top: 0.2rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: var(--ms-accent);
    border: 2px solid var(--ms-surface);
}
#milestoneModal .ms-ev-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ms-ink-3);
}
#milestoneModal .ms-ev-head > span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
#milestoneModal .ms-ev-meta {
    font-size: 0.5625rem;
    font-weight: 600;
    opacity: 0.75;
    text-transform: none;
    letter-spacing: 0;
}
#milestoneModal .ms-ev-what.ms-muted { font-style: italic; color: var(--ms-ink-3); }
#milestoneModal .ms-ev-what {
    font-size: 0.75rem;
    color: var(--ms-ink);
    margin-top: 0.2rem;
    line-height: 1.55;
    word-break: break-word;
}
#milestoneModal .ms-ev-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
#milestoneModal .ms-ev-tags span {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--ms-accent-dark);
    background-color: var(--ms-accent-light);
    padding: 0.1rem 0.4rem;
    border-radius: 0.35rem;
}
#milestoneModal .ms-ev-del {
    margin-left: auto;
    width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.4rem;
    background-color: transparent;
    color: var(--ms-ink-3);
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
#milestoneModal .ms-ev-del:hover { background-color: var(--secondary-light); color: var(--secondary-dark); }
#milestoneModal .ms-tlempty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.75rem 0.6rem;
    text-align: center;
    font-size: 0.75rem;
    font-style: italic;
    color: var(--ms-ink-3);
}
#milestoneModal .ms-tlempty svg { opacity: 0.45; }

/* --- narrow: swap the pager for the timeline instead of stacking both --- */
@media (max-width: 899px) {
    #milestoneModal .ms-tlhead,
    #milestoneModal .ms-timeline { display: none; }
    #milestoneModal.ms-hist-open .ms-mid { display: none; }
    #milestoneModal.ms-hist-open .ms-side { flex: 1; min-height: 0; }
    #milestoneModal.ms-hist-open .ms-tlhead { display: flex; }
    #milestoneModal.ms-hist-open .ms-timeline { display: block; flex: 1; min-height: 0; }
    #milestoneModal.ms-hist-open .ms-composer { border-top: 1px solid var(--ms-line); }

    /* Keep the header on ONE row once the controls stop fitting: drop the mark
       (the title already says what this is), make the secondary buttons
       icon-only, and let the subtitle carry the year. */
    #milestoneModal .ms-head { padding: 0.5rem 0.7rem; }
    #milestoneModal .ms-headtext .ms-headtitle { font-size: 0.875rem; }
    #milestoneModal .ms-mark { display: none; }
    #milestoneModal .ms-headctl { gap: 0.2rem; }
    #milestoneModal .ms-icbtn { min-width: 2.5rem; padding: 0 0.35rem; }
    #milestoneModal .ms-histbtn span,
    #milestoneModal .ms-jumpbtn span { display: none; }
    #milestoneModal .ms-ageyear { display: none; }
}

/* --- very narrow: the subtitle is the first thing to go --- */
@media (max-width: 560px) {
    #milestoneModal .ms-headsub { display: none; }
    /* Keep the header on one row at true phone widths: tighter controls and
       icon-only secondary actions. The rail/chips still carry the category names. */
    #milestoneModal .ms-headctl { gap: 0.15rem; }
    #milestoneModal .ms-icbtn { min-width: 2.25rem; padding: 0 0.25rem; }
    #milestoneModal .ms-agepill { padding: 0 0.5rem; }
    #milestoneModal .ms-repeat span { display: none; }
    #milestoneModal .ms-repeat { padding: 0.35rem 0.5rem; }
    #milestoneModal .ms-btn { padding: 0 0.75rem; }
}

/* --- search clear (X), search-hit category line, note button/sheet: base (all widths) --- */
#milestoneModal .ms-search input { padding-right: 2.25rem; }
#milestoneModal .ms-searchclear {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    margin-top: 0.1rem;
    transform: translateY(-50%);
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border-radius: 50%;
    border: none;
    background-color: var(--ms-line-2);
    color: var(--ms-ink-2);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
#milestoneModal .ms-searchclear[hidden] { display: none; }
#milestoneModal .ms-searchclear:hover { background-color: var(--ms-accent-light); color: var(--ms-accent-dark); }
#milestoneModal .ms-tag.ms-hit { flex-direction: column; align-items: flex-start; justify-content: center; }
#milestoneModal .ms-tag.ms-hit > span { max-width: 100%; }
#milestoneModal .ms-tagcat {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.5625rem;
    font-weight: 500;
    color: var(--ms-ink-3);
}
#milestoneModal .ms-tag[data-active="true"] .ms-tagcat { color: rgba(255, 255, 255, 0.8); }
#milestoneModal .ms-notebtn,
#milestoneModal .ms-notedone { display: none; }

/* --- phone/tablet: compact bar layout. One chip row, 3-column compact tags,
   selected pills in one strip, note behind a button that opens a sheet.
   Must stay after the base .ms-chips / .ms-tag / .ms-pill / .ms-foot rules. --- */
@media (max-width: 899px) {
    #milestoneModal .ms-shell { position: relative; }

    /* categories: ONE scrolling row, with a fade at the right edge as the cue */
    #milestoneModal .ms-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 0.35rem;
        padding: 0.4rem 0.7rem;
    }
    #milestoneModal .ms-chip {
        flex: 0 0 auto;
        height: 1.875rem;
        padding: 0 0.6rem;
        gap: 0.3rem;
        font-size: 0.6875rem;
    }
    #milestoneModal .ms-chip .ms-chip-n { font-size: 0.5625rem; }

    /* the swipe hint and the scope sub-line are redundant next to the chips */
    #milestoneModal .ms-hint { display: none; }
    #milestoneModal .ms-midhead { padding: 0.4rem 0.9rem 0; display: flex; align-items: baseline; gap: 0.5rem; }
    #milestoneModal .ms-midsub { margin-top: 0; margin-left: auto; }
    #milestoneModal .ms-search { padding: 0.4rem 0.7rem 0.15rem; }

    /* tags: 3 columns, compact */
    #milestoneModal .ms-pane,
    #milestoneModal .ms-results { padding: 0.25rem 0.7rem 0.6rem; }
    #milestoneModal .ms-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.3rem; }
    #milestoneModal .ms-tag {
        min-height: 1.875rem;
        padding: 0.2rem 1rem 0.2rem 0.45rem;
        font-size: 0.65625rem;
        line-height: 1.15;
        border-radius: 0.5rem;
    }
    #milestoneModal .ms-tag[data-active="true"]:after { right: 0.4rem; width: 0.4rem; height: 0.22rem; }
    #milestoneModal svg.ms-star { right: 0.3rem; top: 0.25rem; width: 0.5rem; height: 0.5rem; }

    /* selected strip: count + pills (one scrolling line) + Repeat */
    #milestoneModal .ms-activebox {
        padding: 0.4rem 0.7rem 0;
        display: flex;
        align-items: center;
        gap: 0.35rem;
    }
    #milestoneModal .ms-activelabel { display: contents; }
    #milestoneModal .ms-activelabel > span:first-child { display: none; }
    #milestoneModal .ms-count { order: 1; flex-shrink: 0; }
    #milestoneModal .ms-pills { order: 2; flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; min-height: 1.5rem; align-items: center; gap: 0.25rem; scrollbar-width: none; }
    #milestoneModal .ms-pills::-webkit-scrollbar { display: none; }
    #milestoneModal .ms-repeat { order: 3; margin-left: 0; flex-shrink: 0; }
    #milestoneModal .ms-pill {
        flex: 0 0 auto;
        padding: 0.15rem 0.4rem 0.15rem 0.5rem;
        font-size: 0.625rem;
        border-radius: 0.45rem;
        gap: 0.25rem;
    }

    /* footer: note button + Save (Close lives in the header X) */
    #milestoneModal .ms-foot { padding: 0.4rem 0.7rem 0.55rem; gap: 0.4rem; }
    #milestoneModal .ms-foot .ms-btn-ghost { display: none; }
    #milestoneModal .ms-notebtn {
        position: relative;
        display: grid;
        place-items: center;
        flex-shrink: 0;
        width: 2.75rem;
        height: 2.75rem;
        border-radius: 0.6rem;
        border: 1px solid var(--ms-line-2);
        background-color: var(--ms-surface-2);
        color: var(--ms-ink-2);
        cursor: pointer;
        box-shadow: none;
        transform: none;
        transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }
    #milestoneModal .ms-notebtn:hover,
    #milestoneModal .ms-notebtn[aria-pressed="true"] {
        border-color: var(--ms-accent);
        background-color: var(--ms-accent-light);
        color: var(--ms-accent-dark);
    }
    #milestoneModal .ms-notedot {
        position: absolute;
        top: 0.45rem;
        right: 0.55rem;
        width: 0.45rem;
        height: 0.45rem;
        border-radius: 50%;
        background-color: var(--secondary-color);
        display: none;
    }
    #milestoneModal .ms-notebtn.ms-has-note .ms-notedot { display: block; }

    /* note sheet: hidden until the note button is tapped, overlays the footer */
    #milestoneModal .ms-notewrap {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 5;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 0.9rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background-color: var(--ms-surface);
        border-top: 1px solid var(--ms-line);
        border-radius: 1rem 1rem 0 0;
    }
    #milestoneModal.ms-note-open .ms-notewrap { display: flex; }
    #milestoneModal .ms-notewrap > svg { display: none; }
    #milestoneModal .ms-notewrap textarea { flex: 1 1 100%; min-height: 6rem; }
    #milestoneModal .ms-notedone { display: inline-flex; flex: 1 1 100%; }
}

/* Print: the modal is a backdrop for the whole document, never printed. */
@media print {
    #milestoneModal { display: none !important; }
}

/* ==========================================================================
   BABY GENDER - COLLAPSIBLE CHART
   ========================================================================== */

details summary {
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::marker {
    display: none;
}

details .details-chevron {
    transition: transform 0.2s ease;
}

/* ========================================================================
   CLIENT RECORDS TABLE - RESPONSIVE CRM SURFACE
   ======================================================================== */
.history-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
    padding: 0.75rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
}
.history-summary-grid.history-summary-visible { display: grid !important; }
.history-summary-card > div { min-width: 0; }
.history-summary-label,
.history-summary-card small {
    display: block;
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-summary-card strong {
    display: block;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1.35rem;
    line-height: 1.1;
    margin: 0.2rem 0;
}
.history-summary-card small { color: var(--primary-dark); font-size: 0.5625rem; text-transform: none; letter-spacing: 0; }
.history-summary-icon {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    color: var(--primary-dark);
    background: var(--primary-light);
    border-radius: 0.625rem;
}
.history-summary-coral .history-summary-icon { color: var(--secondary-dark); background: var(--secondary-light); }
.history-summary-ocean .history-summary-icon { color: var(--ocean-dark); background: var(--ocean-light); }
.history-summary-sun .history-summary-icon { color: var(--sun-dark); background: var(--sun-light); }
.history-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.375rem 0.5rem;
    color: var(--text-muted);
    background: linear-gradient(180deg, var(--bg-card) 0%, #fcfdfb 100%);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-xs);
}
.history-filter-label,
.history-density-label,
.history-view-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0 0.25rem 0 0.35rem;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}
.history-filter-group,
.history-density-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem;
    background: #f8faf8;
    border: 1px solid #eef2ec;
    border-radius: 9999px;
}
.history-filter-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--border-color);
    margin: 0 0.15rem;
    flex-shrink: 0;
}
.history-view-toggle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    padding-left: 0.25rem;
    border-left: 1px solid var(--border-color);
}
.history-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 700;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.15s ease;
    white-space: nowrap;
}
.history-view-btn:hover { border-color: rgba(151,184,129,0.35); color: var(--primary-dark); background: var(--primary-light); }
.history-view-btn[aria-pressed="true"] { background: var(--primary-color); color: white; border-color: var(--primary-color); box-shadow: none; }
.history-filter-bar button {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 1.9rem;
    padding: 0.3rem 0.7rem;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}
.history-filter-bar button:hover {
    color: var(--text-primary);
    background: white;
    border-color: var(--border-color);
}
.history-filter-bar button.active { color: var(--primary-dark); background: var(--primary-light); border-color: rgba(151, 184, 129, 0.32); box-shadow: inset 0 1px 0 rgba(255,255,255,0.6); }
.history-filter-bar button span {
    display: inline-flex;
    min-width: 1.2rem;
    justify-content: center;
    margin-left: 0.1rem;
    padding: 0.12rem 0.35rem;
    border-radius: 999px;
    color: var(--text-muted);
    background: rgba(156, 163, 175, 0.14);
    font-size: 0.5625rem;
    font-weight: 800;
}
.history-filter-bar button.active span { color: var(--primary-dark); background: rgba(151, 184, 129, 0.22); }
/* Option B — single-sticky row (search + filters inline) */
#historyStickyBar [data-history-filter].active,
#historyStickyBar [data-history-sort].active,
#historyStickyBar [data-history-density].active,
.history-filter-bar-mobile [data-history-filter].active,
.history-filter-bar-mobile [data-history-sort].active,
.history-filter-bar-mobile [data-history-density].active { color: var(--primary-dark); background: var(--primary-light); border-color: rgba(151,184,129,0.32); box-shadow: inset 0 1px 0 rgba(255,255,255,0.6); }
#historyStickyBar [data-history-filter] span,
#historyStickyBar [data-history-density] span,
.history-filter-bar-mobile [data-history-filter] span { display:inline-flex;min-width:1.2rem;justify-content:center;margin-left:0.1rem;padding:0.12rem 0.35rem;border-radius:999px;color:var(--text-muted);background:rgba(156,163,175,0.14);font-size:0.5625rem;font-weight:800; }
#historyStickyBar [data-history-filter].active span,
.history-filter-bar-mobile [data-history-filter].active span { color:var(--primary-dark);background:rgba(151,184,129,0.22); }
.history-filter-bar-mobile { scrollbar-width:none; -ms-overflow-style:none; }
.history-filter-bar-mobile::-webkit-scrollbar{ display:none; }
#historyTable tbody tr { height: auto !important; min-height: 3.25rem; overflow: visible !important; }
#historyTable.history-density-compact tbody tr { min-height: 2.5rem; }
#historyTable.history-density-compact tbody tr td { padding-top: 0.125rem !important; padding-bottom: 0.125rem !important; }
#historyTable tbody tr td:nth-child(3) .flex.items-center.gap-2.flex-wrap { row-gap: 0.3rem; }
#historyTable .history-status-badge { min-height: 1.35rem; }
@media (min-width: 1280px) {
    #view-history > .section-page-header,
    #view-history > .history-summary-grid,
    #view-history > .history-sticky-bar,
    #view-history > .history-filter-bar,
    #view-history > #historyContainer { width: min(100%, var(--shell-content-width)); margin-right: auto; margin-left: auto; }
}
@media (max-width: 768px) {
    .history-summary-card { padding: 0.625rem 0.7rem; }
    .history-summary-card strong { font-size: 1.15rem; }
    .history-summary-icon { width: 1.75rem; height: 1.75rem; }
    #historyTable tbody tr { min-height: 0; overflow: visible !important; }
}
@media (max-width: 360px) {
    .history-summary-label, .history-summary-card small { font-size: 0.5rem; }
    .history-summary-card strong { font-size: 1.05rem; }
}

/* Final responsive overrides: one action rail per breakpoint. */
.history-summary-grid { display: none !important; }

@media (min-width: 769px) and (max-width: 1024px) {
    #historyTable .history-action-rail-desktop { display: inline-flex !important; }
    #historyTable .history-action-rail-mobile { display: none !important; }
    #historyTable .history-action-rail-desktop .history-action-pipeline { display: none; }
    #historyTable th:last-child,
    #historyTable td:last-child { width: 9rem; }
}

/* UX-01: legacy header searches hidden — single sticky source of truth */
#view-history .section-page-header .hidden.md\:flex .relative.flex-\[1_1_18rem\],
#view-history .flex.md\:hidden.order-2,
#view-history .flex.md\:hidden.order-1 { display: none !important; }
.history-sticky-bar { position: sticky; top: 0; z-index: 12; }
/* Perf 6 · CSS contain for 782+ rows — 15% paint win, no JS */
#historyTable tbody tr { contain: layout style; content-visibility: auto; contain-intrinsic-size: auto 52px; }
#historyCards { contain: layout style; }
.history-card { contain: layout style; content-visibility: auto; contain-intrinsic-size: auto 96px; }
/* UX-03: card view */
.history-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 0.875rem; padding: 0.75rem 0.875rem; box-shadow: var(--shadow-sm); transition: border-color 150ms ease, box-shadow 150ms ease; }
.history-card:hover { border-color: rgba(151,184,129,0.35); }
.history-card-active { border-color: var(--secondary-color) !important; background: var(--secondary-light) !important; }
.history-card-head { display: flex; gap: 0.625rem; align-items: flex-start; }
.history-card-meta { display: flex; gap: 0.375rem; align-items: center; justify-content: space-between; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border-color); }
.history-card .history-action-btn { display: inline-flex; align-items: center; justify-content: center; width: 1.875rem; height: 1.875rem; border-radius: 0.45rem; border: 1px solid var(--border-color); background-color: var(--history-action-bg); color: var(--history-table-text-secondary); transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 150ms ease; }
.history-card .history-action-btn:hover { background-color: var(--history-action-hover); color: var(--history-table-text); }
.history-card .history-action-btn.history-action-primary { background-color: var(--primary-color); color: #fff; border: 1px solid #84a86d; }
.history-card .history-action-btn.history-action-primary:hover { background-color: var(--primary-dark); }
.history-card .history-action-btn.history-action-intelligence { background: rgba(143, 184, 202, 0.16); color: #4f7b8f; border-color: rgba(143, 184, 202, 0.3); }
.history-card .history-action-btn.history-action-intelligence:hover { background: rgba(143, 184, 202, 0.28); color: #2f6d87; }
.history-card .history-action-btn.history-action-edit { background: rgba(232, 141, 120, 0.14); color: var(--secondary-dark); border-color: rgba(232, 141, 120, 0.3); }
.history-card .history-action-btn.history-action-edit:hover { background: rgba(232, 141, 120, 0.24); }
.history-card .history-action-btn.history-action-pipeline { background: rgba(151, 184, 129, 0.14); color: var(--primary-dark); border-color: rgba(151, 184, 129, 0.3); }
.history-card .history-action-btn.history-action-pipeline:hover { background: rgba(151, 184, 129, 0.24); }
.history-view-cards #historyScrollContainer { display:none !important; }
.history-view-cards #historyCards { display:grid !important; gap: 0.625rem; }
@media (max-width: 768px) {
    .history-filter-bar {
        gap: 0.4rem;
        padding: 0.4rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        border-radius: 0.9rem;
    }
    .history-filter-bar::-webkit-scrollbar { display: none; }
    .history-filter-label, .history-density-label, .history-view-label { display: none; }
    .history-filter-group, .history-density-group, #historyDensityToggleBtn { display: none !important; }
    .history-filter-divider { display: none; }
    .history-view-toggle-wrap { margin-left: 0.25rem; border-left: none; padding-left: 0; flex: 0 0 auto; }
    .history-sticky-bar { margin-left: -0.75rem; margin-right: -0.75rem; border-radius: 0; border-left: none; border-right: none; }
    .history-sticky-bar + .history-filter-bar { margin-left: -0.75rem; margin-right: -0.75rem; border-radius: 0; border-left: none; border-right: none; border-top: none; }
    #historyTable .history-action-rail-desktop { display: none !important; }
    #historyTable tbody td:last-child > .history-action-rail-mobile {
        display: grid !important;
    }
}

@media (max-width: 1024px) {
    input[id*="Search"],
    input[id*="search"],
    input[placeholder*="Search"],
    input[placeholder*="search"] {
        /* 44px like every other touch target — this is the first control on the screen. */
        min-height: 44px !important;
        padding-top: 0.45rem !important;
        padding-bottom: 0.45rem !important;
    }

    #historySearchInput,
    #historySearchInput-mobile,
    #pipelineSearch,
    #ciRelativeSearchInput,
    #tagSearchInput,
    #quickLoadSearchInput,
    #addClientSearch,
    #tribeRelativeSearchInput,
    #svc-search {
        padding-left: 2.75rem !important;
        padding-right: 2.5rem !important;
    }

    #view-history #historySearchInput,
    #view-history #historySearchInput-mobile {
        min-height: 36px !important;
    }

    #view-history #historySearchInput + i,
    #view-history #historySearchInput-mobile + i {
        left: 0.9rem !important;
    }

    #morning-quick-search {
        padding-left: 3rem !important;
        padding-right: 4.75rem !important;
    }

    .aurora-search-wrap > [data-lucide="search"] {
        left: 1rem !important;
    }
}

@media (max-width: 640px) {
    input[id*="Search"],
    input[id*="search"],
    input[placeholder*="Search"],
    input[placeholder*="search"] {
        font-size: 0.8125rem !important;
    }
}

/* WhatsApp Template Preset Cards */
.wa-preset-card:active { opacity: 0.8; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ==========================================================================
   FLUID MOBILE FIX — Client Records (ponytail: single gutter, not double)
   Removes p-2 + tab-content double padding that left 24px/side gap
   on mobile; cards now fill 100% of fluid gutter (0.75rem). Add when
   a design token for gutters is introduced.
   ========================================================================== */
@media (max-width: 768px) {
    #view-history,
    #view-pipeline { padding: 0 !important; }
    #view-history.tab-content,
    #view-pipeline.tab-content {
        padding: 0.75rem !important;
        padding-bottom: 5.5rem !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    #view-history > .section-page-header,
    #view-history > #historyContainer,
    #view-pipeline > .section-page-header,
    #view-pipeline > #pipeline-mobile-stages,
    #view-pipeline > #pipeline-stats-bar,
    #view-pipeline > #pipeline-today,
    #view-pipeline > #pipeline-board-container,
    #view-pipeline > #pipeline-calendar-container,
    #view-pipeline > #pipeline-calendar {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    /* The card used to be forced to 100dvh-180px here. On 640-768px the view is a fixed-height
       column, so that pushed the card's bottom edge (and its scrollbar) out of view — leave the
       height to flex. The phone page-scroll mode sets its own min-height via .plm-phone. */
    #view-pipeline > #pipeline-calendar {
        flex: 1 1 auto !important;
        min-height: 0 !important;
    }
    #view-pipeline {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    #view-pipeline #pipeline-board-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    #pipeline-board.pipeline-mobile-single .pipeline-col,
    #pipeline-board.pipeline-mobile-single .pipeline-column {
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
    }
    #historyContainer {
        width: 100% !important;
        max-width: 100% !important;
    }
    #historyTable,
    #historyTable tbody,
    #historyTable tr {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    #historyTable tr {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    /* Global fluid guard: prevents any 90vw/max-width element leaking off-screen */
    html, body { max-width: 100vw; overflow-x: hidden; overflow-x: clip; }
    .app-shell-main { overflow-x: hidden; overflow-x: clip; }
}
@media (max-width: 380px) {
    #view-history.tab-content,
    #view-pipeline.tab-content { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
}

/* === 1 · Thick Sage Scrollbar for All-Records table (fixes tiny thumb) === */
#historyScrollContainer, #historyCards {
    scrollbar-width: auto; /* Chromium: keep the custom 14px bar below */
    scrollbar-color: #97B881 #f0f7ec;
}
/* Gecko-only: slim sage bar instead of the fat native one (no width/radius API). */
@supports not selector(::-webkit-scrollbar) {
    #historyScrollContainer, #historyCards { scrollbar-width: thin; }
}
#historyScrollContainer::-webkit-scrollbar, #historyCards::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}
#historyScrollContainer::-webkit-scrollbar-track, #historyCards::-webkit-scrollbar-track {
    background: #f0f7ec;
    border-radius: 9999px;
    margin: 4px;
}
#historyScrollContainer::-webkit-scrollbar-thumb, #historyCards::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #97B881 0%, #7da066 100%);
    border-radius: 9999px;
    border: 2px solid #f0f7ec;
}
#historyScrollContainer::-webkit-scrollbar-thumb:hover, #historyCards::-webkit-scrollbar-thumb:hover {
    background: #7da066;
}
/* ensure thumb always visible on macOS overlay */
@supports (-webkit-touch-callout: none) {
    #historyScrollContainer::-webkit-scrollbar, #historyCards::-webkit-scrollbar { width: 14px; }
}

/* WhatsApp Template Popup Menu */
#wa-template-menu {
    background: white; border-radius: 0.75rem; box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    border: 1px solid #f1f5f9; width: 200px; padding: 4px 0; max-height: min(320px, 80dvh); overflow-y: auto;
}
.wa-menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 12px; text-align: left;
    font-size: 11px; font-weight: 500; color: #4b5563; cursor: pointer; transition: background 0.1s;
}
.wa-menu-item:hover { background: #f0fdf4; }
.wa-menu-default { font-weight: 700; color: #1f2937; border-bottom: 1px solid #f9fafb; }
.wa-menu-icon {
    width: 22px; height: 22px; border-radius: 6px; background: #f9fafb; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}

/* ==========================================================================
   B8 Mockup — Compact Input System (Essence Console + CRM)
   Mirrors mockups/essence-console-option-b8-variants.html .inp/.lab/.pri
   ========================================================================== */
.ess-inp{
  border:1px solid #e5e7eb !important; background:#f9fafb !important; border-radius:0.75rem !important;
  padding:0.6rem 0.75rem !important; font-size:0.875rem !important; width:100%; outline:none;
  transition:background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset .15s; color:#1f2937 !important; line-height:1.4 !important;
}
.ess-inp::placeholder{ color:#9ca3af; }
.ess-inp:focus{ background:#fff !important; border-color:#97B881 !important; box-shadow:0 0 0 3px rgba(151,184,129,.15) !important; }
.ess-inp-pri{ border-color:#cfe6c0 !important; background:#f6faf3 !important; }
.ess-inp-pri:focus{ border-color:#97B881 !important; background:#fff !important; }
.ess-lab{ font-size:10px !important; font-weight:700 !important; letter-spacing:.08em !important; text-transform:uppercase !important; color:#6b7280 !important; display:block !important; margin-bottom:4px !important; }
.ess-lab-pri{ color:#5a8a42 !important; }
textarea.ess-inp{ resize:vertical !important; min-height:96px !important; }
select.ess-inp{ appearance:auto; }
@media(max-width:768px){
  .ess-inp{ min-height:0 !important; padding:0.6rem 0.75rem !important; font-size:0.875rem !important; }
  textarea.ess-inp{ min-height:96px !important; }
}
/* Bento + Classic — exact mock match: xs breakpoint for cardsContainer (380px, missing from Tailwind build) */
.xs\:grid-cols-2{grid-template-columns:1fr}
@media(min-width:380px){.xs\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}
/* Bento + Classic — exact mock card tints (ID specificity to override #cardsContainer>div white) */
#cardsContainer>div.bento-card{border-radius:1rem !important;padding:1rem !important;display:flex !important;flex-direction:column !important;align-items:center !important;justify-content:center !important;gap:0.375rem !important;box-shadow:0 1px 2px 0 rgba(0,0,0,.05) !important;transition:background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 150ms cubic-bezier(0.16,1,0.3,1) !important;position:relative !important;overflow:hidden !important;text-align:center !important;min-width:0 !important}
/* hover removed: it only restated the base box-shadow and `transform: none`,
   so it was a no-op that also re-declared a shadow on a hovered card. */
#cardsContainer>div.bento-card-orange{background:linear-gradient(to bottom right,#fff7ed,rgba(255,247,237,0.6)) !important;border:1px solid #fed7aa !important}
.dark #cardsContainer>div.bento-card-orange{background:linear-gradient(to bottom right,rgba(67,20,7,0.3),#1e293b) !important;border-color:rgba(154,52,18,0.5) !important}
#cardsContainer>div.bento-card-orange .bento-icon{color:#ea580c !important;background:white !important}
.dark #cardsContainer>div.bento-card-orange .bento-icon{background:rgba(124,45,18,0.4) !important;color:#fb923c !important}
#cardsContainer>div.bento-card-orange .bento-num{color:#c2410c !important}
.dark #cardsContainer>div.bento-card-orange .bento-num{color:#fdba74 !important}
#cardsContainer>div.bento-card-violet{background:linear-gradient(to bottom right,#f5f3ff,rgba(245,243,255,0.6)) !important;border:1px solid #ddd6fe !important}
.dark #cardsContainer>div.bento-card-violet{background:linear-gradient(to bottom right,rgba(46,16,101,0.3),#1e293b) !important;border-color:rgba(91,33,182,0.5) !important}
#cardsContainer>div.bento-card-violet .bento-icon{color:#7c3aed !important;background:white !important}
.dark #cardsContainer>div.bento-card-violet .bento-icon{background:rgba(76,29,149,0.4) !important;color:#c4b5fd !important}
#cardsContainer>div.bento-card-violet .bento-num{color:#6d28d9 !important}
.dark #cardsContainer>div.bento-card-violet .bento-num{color:#c4b5fd !important}
#cardsContainer>div.bento-card-blue{background:linear-gradient(to bottom right,#eff6ff,rgba(239,246,255,0.6)) !important;border:1px solid #bfdbfe !important}
.dark #cardsContainer>div.bento-card-blue{background:linear-gradient(to bottom right,rgba(23,37,84,0.3),#1e293b) !important;border-color:rgba(30,64,175,0.5) !important}
#cardsContainer>div.bento-card-blue .bento-icon{color:#2563eb !important;background:white !important}
.dark #cardsContainer>div.bento-card-blue .bento-icon{background:rgba(30,58,138,0.4) !important;color:#93c5fd !important}
#cardsContainer>div.bento-card-blue .bento-num{color:#1d4ed8 !important}
.dark #cardsContainer>div.bento-card-blue .bento-num{color:#93c5fd !important}
#cardsContainer>div.bento-card-rose{background:linear-gradient(to bottom right,#fff1f2,rgba(255,241,242,0.6)) !important;border:1px solid #fecdd3 !important}
.dark #cardsContainer>div.bento-card-rose{background:linear-gradient(to bottom right,rgba(76,5,25,0.3),#1e293b) !important;border-color:rgba(159,18,57,0.5) !important}
#cardsContainer>div.bento-card-rose .bento-icon{color:#e11d48 !important;background:white !important}
.dark #cardsContainer>div.bento-card-rose .bento-icon{background:rgba(136,19,55,0.4) !important;color:#fda4af !important}
#cardsContainer>div.bento-card-rose .bento-num{color:#be123c !important}
.dark #cardsContainer>div.bento-card-rose .bento-num{color:#fda4af !important}
#cardsContainer>div.bento-card-emerald{background:linear-gradient(to bottom right,#ecfdf5,rgba(236,253,245,0.6)) !important;border:1px solid #a7f3d0 !important}
.dark #cardsContainer>div.bento-card-emerald{background:linear-gradient(to bottom right,rgba(2,44,34,0.3),#1e293b) !important;border-color:rgba(6,95,70,0.5) !important}
#cardsContainer>div.bento-card-emerald .bento-icon{color:#059669 !important;background:white !important}
.dark #cardsContainer>div.bento-card-emerald .bento-icon{background:rgba(6,78,59,0.4) !important;color:#6ee7b7 !important}
#cardsContainer>div.bento-card-emerald .bento-num{color:#047857 !important}
.dark #cardsContainer>div.bento-card-emerald .bento-num{color:#6ee7b7 !important}
#cardsContainer>div.bento-card-amber{background:linear-gradient(to bottom right,#fffbeb,rgba(255,251,235,0.6)) !important;border:1px solid #fde68a !important}
.dark #cardsContainer>div.bento-card-amber{background:linear-gradient(to bottom right,rgba(69,26,3,0.3),#1e293b) !important;border-color:rgba(146,64,14,0.5) !important}
#cardsContainer>div.bento-card-amber .bento-icon{color:#d97706 !important;background:white !important}
.dark #cardsContainer>div.bento-card-amber .bento-icon{background:rgba(120,53,15,0.4) !important;color:#fcd34d !important}
#cardsContainer>div.bento-card-amber .bento-num{color:#b45309 !important}
.dark #cardsContainer>div.bento-card-amber .bento-num{color:#fcd34d !important}
/* Option 1 strip — compact pills: override legacy 1rem padding + prevent mobile merging — force 6 inline on desktop */
#coreNumbersContainer #cardsContainer.opt1-grid{grid-template-columns:repeat(3,minmax(0,1fr)) !important}
@media(min-width:640px){#coreNumbersContainer #cardsContainer.opt1-grid{grid-template-columns:repeat(6,minmax(0,1fr)) !important}}
#coreNumbersContainer #cardsContainer.opt1-grid>div.bento-card{border-radius:0.75rem !important;padding:0.5rem 0.25rem !important;gap:0.2rem !important}
@media(min-width:640px){#coreNumbersContainer #cardsContainer.opt1-grid>div.bento-card{padding:0.625rem 0.5rem !important;gap:0.25rem !important;border-radius:0.75rem !important}}
@media(max-width:640px){
  #coreNumbersContainer .opt1-grid{padding:6px !important;gap:8px !important;background:#f8faf8 !important}
  .dark #coreNumbersContainer .opt1-grid{background:#1e293b !important}
  #coreNumbersContainer .opt1-num{font-size:18px !important;line-height:1 !important}
  #coreNumbersContainer .opt1-label{font-size:6px !important;letter-spacing:.06em !important}
  #coreNumbersContainer .opt1-sub{font-size:7px !important}
  #coreNumbersContainer .opt1-icon{width:18px !important;height:18px !important}
  #coreNumbersContainer .opt1-icon svg{width:10px !important;height:10px !important}
}
/* Fallback for arbitrary grid when Tailwind JIT misses lg:grid-cols-[1fr_280px] */
@media(min-width:1024px){#coreNumbersContainer > div > div.grid{grid-template-columns:1fr 280px !important}}

/* ============================================================
   DARK MODE SAFETY NET: All Modal input fields
   Covers Update Reading (quickEditModal), Client Intelligence,
   Ctrl+K (commandBarModal), and any future modals. Ensures
   inputs remain readable even if individual dark: classes are
   missed. Pipeline cards already handled via JS dark: classes.
   ============================================================ */
.dark [id$="Modal"] input[type="text"],
.dark [id$="Modal"] input[type="number"],
.dark [id$="Modal"] input[type="date"],
.dark [id$="Modal"] input[type="time"],
.dark [id$="Modal"] input[type="search"],
.dark [id$="Modal"] input:not([type]),
.dark [id$="Modal"] select,
.dark [id$="Modal"] textarea {
  background-color: #1e2128 !important;
  border-color: #3a3f47 !important;
  color: #e5e7eb !important;
}
.dark [id$="Modal"] input::placeholder,
.dark [id$="Modal"] textarea::placeholder {
  color: #6b7280 !important;
}
.dark [id$="Modal"] input[type="date"],
.dark [id$="Modal"] input[type="time"] {
  color-scheme: dark;
}
/* Update Reading — Reading Date/Time/Cost/Paid explicit override (native picker stays light without this) */
.dark #qe-date,
.dark #qe-time,
.dark #qe-cost,
.dark #qe-paid {
  background-color: #1e2128 !important;
  color: #e5e7eb !important;
  border-color: #3a3f47 !important;
  color-scheme: dark;
}
/* Pipeline card dark fallback for any missed pill */
.dark .pipeline-col .draggable {
  background-color: #2a2f36 !important;
  border-color: #3a3f47 !important;
}
/* Client Intelligence header/tab/footer — ensure no white/bright bleed in dark mode
   (Tailwind opacity variants bg-gray-50/80 & bg-white/50 previously left a light wash) */
.dark #clientIntelligenceModal > div > div.p-4.border-b,
.dark #clientIntelligenceModal .flex.bg-gray-50,
.dark #clientIntelligenceModal div.p-3.border-b.bg-white {
  background-color: #1e2128 !important;
}
/* Apply Service Preset & Service Type — options stay white/bright without this in dark */
.dark #qe-preset,
.dark #qe-preset option,
.dark #qe-type,
.dark #qe-type option {
  background-color: #1e2128 !important;
  color: #e5e7eb !important;
  border-color: #3a3f47 !important;
}
.dark #qe-preset { color-scheme: dark; }
.dark #qe-type { color-scheme: dark; }

/* ==========================================================================
   SECTION 59: ESSENCE CONSOLE TABS (Essence Chart / Extended Profile)
   Two sibling panels: #consolePanelEssence (chart + Current Influences) and
   #extendedProfileFrame. switchConsoleSubTab() toggles their `hidden` classes,
   keeps the segmented control (#console-subtab-control) in sync and persists
   the choice in `essenceConsoleTab`. Both panels render into their containers
   regardless of the active tab, so switching is instant.
   ========================================================================== */

/* --- Extended Profile section nav (Overview / Birth × Life Path / Forecast) ---
   Pinned to the top of the console scroll area, so a practitioner deep in
   Forecast can switch section without scrolling back up. The bar sits inside
   #extendedProfileFrame (p-4 / sm:p-6), so it is full-bleed over that padding.
   Flat 2.0: solid background-color, 1px border, no shadow, no transform. */
#extendedSectionNav {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 1rem 12px;
    margin: 0 -1rem 16px;
    background-color: var(--bg-body);
    border-bottom: 1px solid rgba(203, 213, 225, 0.6);
}
@media (min-width: 640px) {
    #extendedSectionNav { padding-inline: 1.5rem; margin-inline: -1.5rem; }
}
/* A tab switch scrolls the section start under the pinned bar — leave room for it. */
.ext-sec { scroll-margin-top: 64px; }
.dark #extendedSectionNav { border-bottom-color: rgba(71, 85, 105, 0.6); }
#extendedSectionNav::-webkit-scrollbar { display: none; }
#extendedSectionNav .ext-sec-btn {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 9999px;
    background-color: #ffffff;
    color: #6b7280;
    border: 1px solid #e2e8f0;
    box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#extendedSectionNav .ext-sec-btn:focus-visible {
    outline: 2px solid rgba(151, 184, 129, 0.55);
    outline-offset: 2px;
}
#extendedSectionNav .ext-sec-btn:hover {
    background-color: #f1f5f9;
    color: #4d6f3a;
    border-color: rgba(151, 184, 129, 0.45);
}
#extendedSectionNav .ext-sec-btn.active {
    background-color: rgba(151, 184, 129, 0.25);
    color: #4d6f3a;
    border-color: rgba(151, 184, 129, 0.55);
}
.dark #extendedSectionNav .ext-sec-btn {
    background-color: #1e293b;
    color: #94a3b8;
    border-color: #334155;
}
.dark #extendedSectionNav .ext-sec-btn:hover {
    background-color: #0f172a;
    color: #a8cc8f;
    border-color: rgba(168, 204, 143, 0.4);
}
.dark #extendedSectionNav .ext-sec-btn.active {
    background-color: rgba(168, 204, 143, 0.18);
    color: #a8cc8f;
    border-color: rgba(168, 204, 143, 0.5);
}
/* Count badge — shows how much content a section actually holds */
#extendedSectionNav .ext-sec-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 9999px;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    background-color: #f1f5f9;
    color: #64748b;
}
#extendedSectionNav .ext-sec-btn.active .ext-sec-count {
    background-color: rgba(255, 255, 255, 0.7);
    color: #4d6f3a;
}
.dark #extendedSectionNav .ext-sec-count { background-color: #0f172a; color: #94a3b8; }
.dark #extendedSectionNav .ext-sec-btn.active .ext-sec-count { background-color: rgba(168, 204, 143, 0.25); color: #a8cc8f; }

/* Prev/Next dock */
#extendedSectionFooter .ext-step-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 9999px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: none;
    color: #6b7280;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#extendedSectionFooter .ext-step-btn:hover {
    background-color: #f1f5f9;
    color: #4d6f3a;
    border-color: rgba(151, 184, 129, 0.45);
}
.dark #extendedSectionFooter .ext-step-btn {
    background-color: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
.dark #extendedSectionFooter .ext-step-btn:hover {
    background-color: #0f172a;
    color: #a8cc8f;
    border-color: rgba(168, 204, 143, 0.4);
}

/* Subtab Segmented Control compact styling inside Identity Bar */
#console-subtab-control {
    width: auto !important;
    max-width: none !important;
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
    display: inline-flex !important;
    padding: 2px !important;
    gap: 2px !important;
    border-radius: 9999px !important;
    background: rgba(241, 245, 249, 0.9) !important;
    border: 1px solid rgba(203, 213, 225, 0.6) !important;
}
.dark #console-subtab-control {
    background: rgba(30, 41, 59, 0.9) !important;
    border-color: rgba(71, 85, 105, 0.6) !important;
}
#console-subtab-control button {
    width: auto !important;
    flex: 0 0 auto !important;
    height: 26px !important;
    min-height: 26px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    border-radius: 9999px !important;
    border: 1px solid transparent !important;
    box-shadow: none !important;
    gap: 4px !important;
    white-space: nowrap !important;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease !important;
}
#console-subtab-control button.active {
    background: #ffffff !important;
    color: var(--secondary-color, #5A7341) !important;
    border: 1px solid rgba(151, 184, 129, 0.45) !important;
}
.dark #console-subtab-control button.active {
    background: #0f172a !important;
    color: #a8cc8f !important;
    border-color: rgba(168, 204, 143, 0.4) !important;
}

/* ==========================================================================
   SECTION 61: OPTION 3 DUAL-PANE ESSENCE CONSOLE
   Exact pixel-perfect mirror of mockup Option 3 styling
   ========================================================================== */
.mock-card {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 4px 20px -4px rgba(0,0,0,0.05);
    transition: border-color 0.2s;
}
.dark .mock-card {
    background: #1e293b;
    border-color: #334155;
}

.ess-input {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0.625rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    width: 100%;
    outline: none;
    transition: background-color, background-image, border-color, border-radius, color, box-shadow, opacity, transform, outline, outline-offset 0.15s ease;
    color: #0f172a;
}
.dark .ess-input {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}
.ess-input:focus {
    background: #ffffff;
    border-color: #97B881;
    box-shadow: 0 0 0 3px rgba(151, 184, 129, 0.18);
}
.dark .ess-input:focus {
    background: #1e293b;
    border-color: #97B881;
}

.ess-input-pri {
    border-color: #d1e7c5;
    background: #f7faf5;
    font-weight: 500;
}
.dark .ess-input-pri {
    border-color: rgba(151, 184, 129, 0.35);
    background: rgba(151, 184, 129, 0.08);
}
.ess-input-pri:focus {
    border-color: #7da066;
    background: #ffffff;
}
.dark .ess-input-pri:focus {
    background: #1e293b;
}

.ess-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.3rem;
}
.dark .ess-label {
    color: #94a3b8;
}
.ess-label-pri { color: #43702c; }
.dark .ess-label-pri { color: #97B881; }
.ess-label-coral { color: #c45b45; }
.dark .ess-label-coral { color: #E88D78; }

.btn-pri {
    background: #97B881;
    color: white;
    border: 1px solid #7da066;
    border-radius: 0.625rem;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.6rem 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background-color 0.15s ease;
    cursor: pointer;
}
.btn-pri:hover { background: #7da066; }

.btn-sec {
    background: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 0.625rem;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background-color 0.15s ease;
    cursor: pointer;
}
.dark .btn-sec {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}
.btn-sec:hover { background: #f8fafc; border-color: #94a3b8; }
.dark .btn-sec:hover { background: #334155; }

.btn-coral {
    background: #fff1ee;
    color: #d67560;
    border: 1px solid #fecdd3;
    border-radius: 0.625rem;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.6rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
    box-shadow: none !important;
    transform: none !important;
}
.btn-coral:hover { background: #ffe4e0; border-color: #fda4af; }
.dark .btn-coral {
    background: #451a1a;
    color: #fca5a5;
    border-color: #7f1d1d;
}
.dark .btn-coral:hover {
    background: #5c2020;
    border-color: #991b1b;
}

.btn-dark {
    background: #0f172a;
    color: white;
    border: 1px solid #0f172a;
    border-radius: 0.625rem;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.6rem 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background-color 0.15s ease;
    cursor: pointer;
}
.btn-dark:hover { background: #1e293b; }

.opt-badge {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
}

.coral-active-box {
    background: rgba(253,242,240,0.6) !important;
    border: 1px solid #E88D78 !important;
    border-radius: 0.875rem !important;
}
.dark .coral-active-box {
    background: rgba(232, 141, 120, 0.12) !important;
    border-color: rgba(232, 141, 120, 0.5) !important;
}

/* ==========================================================================
   ESSENCE TABLE SPOTLIGHT HIGHLIGHTS (Paradigm 2)
   ========================================================================== */
.spotlight-col-cell {
    position: relative;
    transition: background-color 0.2s ease;
}
.spotlight-col-cell.spotlight-master {
    background-color: rgba(196, 181, 212, 0.28) !important;
}
.spotlight-col-cell.spotlight-karmic {
    background-color: rgba(232, 141, 120, 0.25) !important;
}
.spotlight-col-cell.spotlight-match {
    background-color: rgba(236, 212, 137, 0.3) !important;
}
.spotlight-col-cell.spotlight-search {
    background-color: rgba(143, 184, 202, 0.28) !important;
}
.dark .spotlight-col-cell.spotlight-master {
    background-color: rgba(196, 181, 212, 0.2) !important;
}
.dark .spotlight-col-cell.spotlight-karmic {
    background-color: rgba(232, 141, 120, 0.2) !important;
}
.dark .spotlight-col-cell.spotlight-match {
    background-color: rgba(236, 212, 137, 0.2) !important;
}
.dark .spotlight-col-cell.spotlight-search {
    background-color: rgba(143, 184, 202, 0.2) !important;
}
#resultsTable thead th.spotlight-col-header,
#resultsTable thead th.spotlight-year-highlight,
.spotlight-col-header,
.spotlight-year-highlight {
    background-color: #E88D78 !important;
    background: #E88D78 !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    letter-spacing: 0.04em !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    border-color: #d67560 !important;
    outline: 2px solid #d67560 !important;
    outline-offset: -2px;
}
html.dark #resultsTable thead th.spotlight-col-header,
html.dark #resultsTable thead th.spotlight-year-highlight,
.dark .spotlight-col-header,
.dark .spotlight-year-highlight {
    background-color: #E88D78 !important;
    background: #E88D78 !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    letter-spacing: 0.04em !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45) !important;
    outline-color: #d67560 !important;
}

tr[data-category="personalYear"] td.spotlight-col-cell {
    background-color: rgba(232, 141, 120, 0.28) !important;
    color: #c95d46 !important;
    font-weight: 800 !important;
}
.dark tr[data-category="personalYear"] td.spotlight-col-cell {
    background-color: rgba(232, 141, 120, 0.25) !important;
    color: #fca5a5 !important;
    font-weight: 800 !important;
}

/* ==========================================================================
   SPOTLIGHT COMMAND BAR (Paradigm 2 - Seamless Single-Border Box)
   ========================================================================== */
.spotlight-command-bar {
    display: inline-flex !important;
    align-items: center !important;
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 0.75rem !important;
    padding: 0 0.65rem !important;
    gap: 0.35rem !important;
    height: 32px !important;
    box-shadow: none !important;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.spotlight-command-bar:focus-within {
    border-color: #97B881 !important;
}
.dark .spotlight-command-bar {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
.dark .spotlight-command-bar:focus-within {
    border-color: #97B881 !important;
}

/* Explicitly eliminate the global input inner border, gradient, and inner-shadow */
.spotlight-command-bar input#jumpToInput,
.spotlight-command-bar input[type="text"] {
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    font-size: 0.75rem !important;
    line-height: 1.25 !important;
    color: #334155 !important;
}
.dark .spotlight-command-bar input#jumpToInput,
.dark .spotlight-command-bar input[type="text"] {
    color: #e2e8f0 !important;
}
.spotlight-command-bar input#jumpToInput:focus,
.spotlight-command-bar input[type="text"]:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}
.spotlight-command-bar input#jumpToInput::placeholder {
    color: #94a3b8 !important;
    font-size: 0.72rem !important;
}
.dark .spotlight-command-bar input#jumpToInput::placeholder {
    color: #64748b !important;
}

.spotlight-command-bar .spotlight-go-btn {
    border: none !important;
    background: transparent !important;
    color: #7da066 !important;
    font-weight: 700 !important;
    font-size: 0.75rem !important;
    padding: 0 0.25rem !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: color 0.15s ease;
}
.spotlight-command-bar .spotlight-go-btn:hover {
    color: #5c7e47 !important;
}
.dark .spotlight-command-bar .spotlight-go-btn {
    color: #97B881 !important;
}
.dark .spotlight-command-bar .spotlight-go-btn:hover {
    color: #b5d1a2 !important;
}

.spotlight-command-bar #jumpToClearBtn {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 2px !important;
}
.spotlight-command-bar #jumpToClearBtn.hidden {
    display: none !important;
}

/* ==========================================================================
   CURRENT INFLUENCES - TAP FOR MEANING BUTTON (Consistent Bottom-Right)
   ========================================================================== */
.ci-tap-meaning-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    padding: 0.35rem 0.75rem !important;
    background-color: #0f172a !important; /* solid slate-900 */
    color: #ffffff !important;
    border: 1px solid #0f172a !important;
    border-radius: 9999px !important;
    font-size: 0.6875rem !important; /* 11px */
    font-weight: 700 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    box-shadow: none !important;
    transform: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
    text-decoration: none !important;
    user-select: none !important;
    flex-shrink: 0 !important;
}
.ci-tap-meaning-btn:hover {
    background-color: #1e293b !important; /* slate-800 */
    border-color: #E88D78 !important; /* Coral brand highlight border */
    color: #ffffff !important;
    transform: none !important;
    box-shadow: none !important;
}
.dark .ci-tap-meaning-btn {
    background-color: #f8fafc !important; /* slate-50 */
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
}
.dark .ci-tap-meaning-btn:hover {
    background-color: #ffffff !important;
    border-color: #E88D78 !important;
    color: #0f172a !important;
    transform: none !important;
    box-shadow: none !important;
}


/* ==========================================================================
   CRM Demographics 2x2 Mobile Row & Collapsible Cards
   ========================================================================== */
@media (max-width: 639px) {
    #calculatorForm #crm-demographics-row,
    #crm-demographics-row {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.625rem !important;
        width: 100% !important;
        flex-direction: unset !important;
    }
    #crm-demographics-row > div {
        width: 100% !important;
        min-width: 0 !important;
    }
}

.crm-collapse-card summary::-webkit-details-marker {
    display: none;
}
.crm-collapse-card[open] .crm-collapse-chevron {
    transform: rotate(180deg);
}

/* Desktop: Relationship & Changed Name + Contact & Metadata are always open, so the
   expand/collapse affordance is mobile-only (matches syncCrmCollapsibleState()'s
   1024px breakpoint). Arrow hidden, summary not clickable. */
@media (min-width: 1024px) {
    .crm-collapse-card > summary {
        pointer-events: none;
        cursor: default;
    }
    .crm-collapse-card .crm-collapse-chevron {
        display: none;
    }
}

/* ==========================================================================
   Mobile CRM Action Deck (Reset 40%, Calculate 60%)
   ========================================================================== */
@media (max-width: 639px) {
    #calculatorForm .crm-action-deck {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }
    #calculatorForm .crm-action-deck #clearFormBtn,
    #calculatorForm #clearFormBtn {
        flex: 0 0 calc(40% - 0.25rem) !important;
        width: calc(40% - 0.25rem) !important;
        max-width: calc(40% - 0.25rem) !important;
        min-width: 0 !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #calculatorForm .crm-action-deck button[type="submit"],
    #calculatorForm button[type="submit"].crm-calc-btn {
        flex: 0 0 calc(60% - 0.25rem) !important;
        width: calc(60% - 0.25rem) !important;
        max-width: calc(60% - 0.25rem) !important;
        min-width: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.375rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        font-size: 0.8125rem !important;
        white-space: nowrap !important;
    }
}

/* ==========================================================================
   Card View Status Badge Overrides (Referral / Referred By)
   ========================================================================== */
@media (max-width: 768px) {
    .history-card .history-status-badge:is(button, a),
    .history-card button.history-status-badge,
    .history-card a.history-status-badge,
    #historyTable .history-status-badge:is(button, a),
    #historyTable button.history-status-badge {
        height: 1.375rem !important;
        min-height: 1.375rem !important;
        max-height: 1.375rem !important;
        min-width: 0 !important;
        font-size: 0.6875rem !important;
        padding: 0 0.3125rem !important;
    }
}

@media (max-width: 480px) {
    .history-card .history-status-badge:is(button, a),
    .history-card button.history-status-badge,
    .history-card a.history-status-badge,
    #historyTable .history-status-badge:is(button, a),
    #historyTable button.history-status-badge {
        height: 1.25rem !important;
        min-height: 1.25rem !important;
        max-height: 1.25rem !important;
        min-width: 0 !important;
        font-size: 0.625rem !important;
        padding: 0 0.25rem !important;
    }
}

@media (max-width: 359px) {
    .history-card .history-status-badge:is(button, a),
    .history-card button.history-status-badge,
    .history-card a.history-status-badge,
    #historyTable .history-status-badge:is(button, a),
    #historyTable button.history-status-badge {
        height: 1.125rem !important;
        min-height: 1.125rem !important;
        max-height: 1.125rem !important;
        min-width: 0 !important;
        font-size: 0.5625rem !important;
        padding: 0 0.1875rem !important;
    }
}


/* Smart Scratchpad Placeholder */
[contenteditable]:empty:before {
    content: attr(placeholder);
    color: #9CA3AF;
    font-style: italic;
    pointer-events: none;
    display: block;
}


/* ==========================================================================
   PIPELINE PHONE STAGE NAVIGATION (< 768px, single-column board only)
   Cards are unchanged. Four equal stage tabs with the count always visible, tabs stay pinned
   while the list scrolls, swipe works anywhere on the list, and each list ends with
   previous / next stage buttons. The floating arrows (they sat on top of cards) are retired here.
   Flat 2.0: no shadow, no gradient, colour-only feedback.
   ========================================================================== */
.pl-stage-footer { display: none; }

@media (max-width: 767px) {
    #view-pipeline #pipeline-mobile-stages {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        overflow: visible;
        position: sticky;
        top: 0;
        z-index: 20;
        padding: 6px 2px;
        margin-bottom: 8px;
        background: var(--bg-body);
    }
    html.dark #view-pipeline #pipeline-mobile-stages { background: var(--bg-body); }
    #view-pipeline #pipeline-mobile-stages .pipeline-stage-pill {
        flex-direction: column;
        gap: 1px;
        min-height: 48px;
        padding: 6px 2px;
        border-radius: 12px;
        box-shadow: none !important;
        transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }
    #view-pipeline #pipeline-mobile-stages .pipeline-stage-pill .stage-dot { display: none; }
    #view-pipeline #pipeline-mobile-stages .pipeline-stage-pill > span.flex-1 { flex: 0 0 auto; font-size: 10.5px; line-height: 1.1; }
    #view-pipeline #pipeline-mobile-stages .pipeline-stage-pill .pipeline-stage-count {
        display: block !important;
        order: -1;
        padding: 0;
        background: transparent !important;
        color: inherit !important;
        font-size: 17px;
        font-weight: 800;
        line-height: 1.1;
        font-variant-numeric: tabular-nums;
    }

    /* floating arrows are replaced by the tabs, the swipe and the footer buttons */
    #pipeline-board-container #pipeline-prev,
    #pipeline-board-container #pipeline-next { display: none !important; }

    .pl-stage-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        padding: 8px 8px 4px;
    }
    .pl-stage-footer button {
        min-height: 40px;
        padding: 0 14px;
        border-radius: 10px;
        border: 1px solid var(--btn-ghost-border, #d1d5db);
        background: var(--btn-ghost-bg, transparent);
        color: var(--btn-ghost-text, #4b5563);
        font-size: 12px;
        font-weight: 700;
        box-shadow: none;
        transition: background-color 0.15s ease, border-color 0.15s ease;
    }
    .pl-stage-footer button:active { background: var(--btn-ghost-hover, #eef3ea); }
    html.dark .pl-stage-footer button { border-color: var(--dark-border); color: var(--dark-text); }
}

/* ==========================================================================
   PIPELINE FOCUS DASHBOARD (F) — phones only (< 768px), board view only.
   "What matters now": today's next readings with one-tap Start, stage tiles
   (count + collected) and a completed-but-unpaid alert. Rendered by
   renderPipelineFocus(); tapping a tile drills into that stage and collapses
   the dashboard so the list keeps the screen. Flat 2.0: no shadow, no gradient,
   colour-only feedback. Colours come from Tailwind utilities on the injected
   markup, so dark mode is handled there.
   ========================================================================== */
.pipeline-focus { display: none; }
.pl-focus-slim { display: none; }
.pipeline-focus.pl-focus-collapsed .pl-focus-full { display: none; }
.pipeline-focus.pl-focus-collapsed .pl-focus-slim { display: block; }

@media (max-width: 767px) {
    #view-pipeline #pipeline-focus:not(.hidden) {
        display: block;
        margin: 0 2px 8px;
    }
}

/* ==========================================================================
   PIPELINE PHONE UI (< 768px) — phone-only layout for the Reading Pipeline board.
   Desktop / tablet are untouched: every rule here lives inside the media query
   (the bottom sheet is only ever created by phone code).
   - Page scrolls as one (no scroll box inside the column); stage tabs stay pinned.
   - Cards (.plm-card, built by _pipelineMobileCardHtml): identity + amount, status
     chips, ONE primary action for the stage, call / WhatsApp, and a More sheet.
   - Tap targets >= 44px, body text >= 12px.
   Flat 2.0 on buttons/chips: no shadow, no gradient, no transform, colour-only feedback.
   ========================================================================== */

/* ---- focus strip (today's next readings) ---- */
.plf-card { border: 1px solid rgba(151, 184, 129, 0.3); background: var(--primary-light); border-radius: 14px; padding: 10px 12px; }
.plf-head { display: flex; align-items: center; gap: 8px; }
.plf-title { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary-dark); }
.plf-count { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--text-primary); }
.plf-toggle { width: 36px; height: 36px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid rgba(151, 184, 129, 0.35); background: transparent; color: var(--primary-dark); box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.plf-toggle:active { background: #fff; }
.plf-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.plf-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border-radius: 12px; background: #fff; border: 1px solid rgba(151, 184, 129, 0.25); }
.plf-time { min-width: 60px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--primary-dark); }
.plf-name { font-size: 14px; font-weight: 700; line-height: 1.25; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plf-type { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plf-go { flex: none; min-height: 40px; padding: 0 16px; border-radius: 10px; background: var(--btn-primary-bg); border: 1px solid var(--btn-primary-border); color: var(--btn-primary-text); font-size: 13px; font-weight: 700; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.plf-go:active { background: var(--btn-primary-hover); }
.plf-more { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.plf-alert { width: 100%; margin-top: 6px; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px; border: 1px solid rgba(232, 141, 120, 0.4); background: rgba(232, 141, 120, 0.1); color: var(--secondary-dark); font-size: 13px; text-align: left; box-shadow: none; transition: background-color 0.15s ease; }
.plf-alert b { font-weight: 700; }
.plf-alert:active { background: rgba(232, 141, 120, 0.2); }
.plf-slim { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px; border: 1px solid rgba(151, 184, 129, 0.3); background: var(--primary-light); color: var(--text-primary); font-size: 13px; font-weight: 700; text-align: left; box-shadow: none; transition: background-color 0.15s ease; }
.plf-slim:active { background: #fff; }
html.dark .plf-card, html.dark .plf-slim { background: rgba(151, 184, 129, 0.1); border-color: var(--dark-border); }
html.dark .plf-title { color: #b9d3a6; }
html.dark .plf-count, html.dark .plf-name, html.dark .plf-slim { color: var(--dark-text); }
html.dark .plf-type, html.dark .plf-more { color: var(--dark-text-muted); }
html.dark .plf-row { background: var(--dark-card); border-color: var(--dark-border); }
html.dark .plf-time, html.dark .plf-toggle { color: #b9d3a6; }
html.dark .plf-toggle { border-color: var(--dark-border); }
html.dark .plf-alert { color: #f0a999; background: rgba(232, 141, 120, 0.12); border-color: rgba(232, 141, 120, 0.35); }

/* ---- bottom action sheet (replaces the floating Move menu + 5 tiny icons) ---- */
.plm-sheet { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; }
.plm-sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.plm-sheet-panel { position: relative; width: 100%; max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; background: #fff; border-radius: 20px 20px 0 0; border-top: 1px solid var(--border-strong); padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.plm-sheet-grab { width: 40px; height: 4px; border-radius: 9999px; background: var(--border-strong); margin: 0 auto 10px; }
.plm-sheet-head { padding: 2px 2px 10px; }
.plm-sheet-title { font-size: 17px; font-weight: 700; color: var(--text-primary); font-family: 'Quicksand', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plm-sheet-sub { font-size: 13px; color: var(--text-secondary); }
.plm-sheet-label { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 4px 2px 6px; }
.plm-sheet-stages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.plm-sheet-stage { min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--btn-ghost-border); background: transparent; color: var(--text-primary); font-size: 14px; font-weight: 600; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.plm-sheet-stage:active:not(:disabled) { background: var(--btn-ghost-hover); }
.plm-sheet-stage.is-current { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-dark); }
.plm-sheet-list { margin-top: 12px; border-top: 1px solid var(--border-strong); padding-top: 4px; }
.plm-sheet-item { width: 100%; min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 4px; border: 0; background: transparent; color: var(--text-primary); font-size: 15px; font-weight: 600; text-align: left; box-shadow: none; transition: background-color 0.15s ease; }
.plm-sheet-item:active { background: var(--btn-ghost-hover); }
.plm-sheet-item.is-danger { color: var(--secondary-dark); }
html.dark .plm-sheet-panel { background: var(--dark-popover); border-top-color: var(--dark-border); }
html.dark .plm-sheet-grab { background: var(--dark-border); }
html.dark .plm-sheet-list { border-top-color: var(--dark-border); }
html.dark .plm-sheet-title, html.dark .plm-sheet-item, html.dark .plm-sheet-stage { color: var(--dark-text); }
html.dark .plm-sheet-sub { color: var(--dark-text-secondary); }
html.dark .plm-sheet-stage { border-color: var(--dark-border); }
html.dark .plm-sheet-stage.is-current { background: rgba(151, 184, 129, 0.15); border-color: var(--primary-color); color: #b9d3a6; }
html.dark .plm-sheet-item.is-danger { color: #f0a999; }
@media (prefers-reduced-motion: no-preference) {
    .plm-sheet-backdrop { animation: plm-fade 0.15s ease-out; }
    .plm-sheet-panel { animation: plm-rise 0.2s ease-out; }
}
@keyframes plm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes plm-rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

    /* ---- page header: title + add, then the icon bar. Tagline is dropped (it cost a line on every visit) ---- */
    #view-pipeline.plm-phone .section-page-header { margin-bottom: 8px; gap: 8px; }
    #view-pipeline.plm-phone .macos-title-cluster p { display: none; }
    #view-pipeline.plm-phone .macos-title-cluster h2 { font-size: 1.125rem; }
    #view-pipeline.plm-phone .macos-title-cluster button { min-height: 40px; min-width: 40px; justify-content: center; }
    #view-pipeline.plm-phone .section-page-header .md\:hidden button { min-height: 44px; align-items: center; }
    #view-pipeline.plm-phone { gap: 8px !important; }
    #view-pipeline.plm-phone #pipeline-focus:not(.hidden) { margin: 0 2px !important; }
    #view-pipeline.plm-phone #pipeline-mobile-stages { margin-bottom: 0 !important; }

    /* stage tabs belong to the Board view only: Calendar / Today hide them with .hidden, which the grid rule above would otherwise override */
    #view-pipeline.plm-phone #pipeline-mobile-stages.hidden { display: none !important; }

    /* ---- one scroll: the page, not a box inside the column ---- */
    /* the base rule (max-width:1024px) pins the view to overflow:hidden and lets each column scroll; phones have no column box any more, so the view is the scroller */
    #view-pipeline.plm-phone:not(.hidden) { overflow-x: hidden !important; overflow-y: auto !important; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; touch-action: pan-y; }
    #view-pipeline.plm-phone > #pipeline-today:not(.hidden), #view-pipeline.plm-phone > #pipeline-calendar:not(.hidden) { height: auto !important; min-height: 0 !important; overflow: visible !important; flex: 0 0 auto !important; }
    #view-pipeline.plm-phone #pipeline-board-container { flex: 0 0 auto !important; height: auto !important; min-height: 0 !important; }
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single { display: block !important; height: auto !important; overflow: visible !important; padding-bottom: 0 !important; }
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col.pipeline-col-active { display: block; height: auto !important; overflow: visible !important; background: transparent; border: 0 !important; }
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col-body { display: flex; flex-direction: column; gap: 6px; height: auto !important; min-height: 0 !important; overflow: visible !important; padding: 4px 0 8px; }
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col-body > * { margin-top: 0 !important; margin-bottom: 0; }

    /* ---- stage strip above the list: compact, with 40px buttons ---- */
    #view-pipeline.plm-phone #pipeline-board .pipeline-col > div:first-child { padding: 6px 10px; margin: 0 2px; border-radius: 12px; min-height: 44px; }
    #view-pipeline.plm-phone #pipeline-board .pipeline-col > div:first-child button { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
    #view-pipeline.plm-phone #pipeline-board .pipeline-col > div:first-child h4 { font-size: 13px; }
    #view-pipeline.plm-phone #pipeline-board .pipeline-col span[id^="count-"] { min-width: 28px; min-height: 28px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; }
    #view-pipeline.plm-phone #pipeline-board .pipeline-col [id^="rev-"] { font-size: 12px; }
    #view-pipeline.plm-phone #pipeline-board .pipeline-col [id^="rev-"]::before { content: "Collected "; font-family: inherit; }

    /* ---- layout helpers that used to live in <768px-only rules (phone portrait AND landscape / short screens) ---- */
    #view-pipeline.plm-phone #pipeline-focus:not(.hidden) { display: block; }
    #view-pipeline.plm-phone #pipeline-mobile-stages:not(.hidden) { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; overflow: visible; position: sticky; top: 0; z-index: 20; padding: 6px 2px; background: var(--bg-body); }
    #view-pipeline.plm-phone #pipeline-mobile-stages .pipeline-stage-pill { flex-direction: column; gap: 1px; min-height: 48px; padding: 6px 2px; border-radius: 12px; box-shadow: none !important; }
    #view-pipeline.plm-phone #pipeline-mobile-stages .pipeline-stage-pill .stage-dot { display: none; }
    #view-pipeline.plm-phone #pipeline-mobile-stages .pipeline-stage-pill > span.flex-1 { flex: 0 0 auto; font-size: 10.5px; line-height: 1.1; }
    #view-pipeline.plm-phone #pipeline-mobile-stages .pipeline-stage-pill .pipeline-stage-count { display: block !important; order: -1; padding: 0; background: transparent !important; color: inherit !important; font-size: 17px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
    #view-pipeline.plm-phone #pipeline-board-container #pipeline-prev, #view-pipeline.plm-phone #pipeline-board-container #pipeline-next { display: none !important; }
    #view-pipeline.plm-phone .pl-stage-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 8px 4px; grid-column: 1 / -1; }
    #view-pipeline.plm-phone .pl-stage-footer button { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--btn-ghost-border, #d1d5db); background: var(--btn-ghost-bg, transparent); color: var(--btn-ghost-text, #4b5563); font-size: 12px; font-weight: 700; box-shadow: none; }
    html.dark #view-pipeline.plm-phone .pl-stage-footer button { border-color: var(--dark-border); color: var(--dark-text); }
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col { flex: 0 0 100%; min-width: 100% !important; max-width: 100% !important; width: 100% !important; margin: 0 !important; }
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col:not(.pipeline-col-active) { display: none; }
    /* cards flow into as many columns as fit (1 on a portrait phone, 2-3 in landscape) */
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }
    #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col-body > .pipeline-col-more, #view-pipeline.plm-phone #pipeline-board.pipeline-mobile-single .pipeline-col-body > div:not(.plm-card) { grid-column: 1 / -1; }
    #view-pipeline.plm-touch .macos-title-cluster { flex: none; }
    #view-pipeline.plm-phone .macos-title-cluster button { flex: none; white-space: nowrap; }
    #view-pipeline.plm-touch .macos-title-cluster button { flex: none; white-space: nowrap; }
    /* touch tablets keep the multi-column board; give each column room for the card's button row */
    #view-pipeline.plm-touch:not(.plm-phone) #pipeline-board .pipeline-col { min-width: 340px !important; max-width: 380px !important; }
    #view-pipeline.plm-touch #pipeline-search-container { flex: 1 1 120px; min-width: 0 !important; max-width: 240px; }
    #view-pipeline.plm-touch .section-page-header { flex-wrap: wrap; }
    .plm-sheet-panel { max-width: 560px; margin: 0 auto; }
    /* landscape phones / short screens: keep the list visible, spend fewer pixels on chrome */
    @media (max-height: 500px) {
        #view-pipeline.plm-phone .macos-title-cluster .macos-proxy-badge { display: none; }
        #view-pipeline.plm-phone #pipeline-mobile-stages:not(.hidden) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
        #view-pipeline.plm-phone #pipeline-mobile-stages .pipeline-stage-pill { flex-direction: row; justify-content: center; gap: 8px; min-height: 40px; }
        #view-pipeline.plm-phone #pipeline-mobile-stages .pipeline-stage-pill .pipeline-stage-count { order: 0; font-size: 15px; }
        .plm-sheet-panel { max-height: 94vh; max-height: 94dvh; }
        .plm-sheet-stages { grid-template-columns: repeat(4, minmax(0, 1fr)); }
        .plm-sheet-item { min-height: 44px; }
    }
    /* sticky tabs sit under the app header only when it is not part of the scroller */
    #view-pipeline.plm-touch .plm-chips > * { max-width: 100%; }

    /* ---- card ---- */
    #view-pipeline .plm-card { margin: 0 2px !important; padding: 0 !important; border-radius: 10px; cursor: pointer; box-shadow: none; -webkit-tap-highlight-color: transparent; transition: border-color 0.15s ease, background-color 0.15s ease; }
    #view-pipeline .plm-card:active { border-color: var(--primary-color); }
    #view-pipeline .plm-main { display: flex; flex-direction: column; gap: 5px; padding: 7px 8px; }
    #view-pipeline .plm-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
    #view-pipeline .plm-avatar { width: 26px; height: 26px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 9999px; font-size: 11px; font-weight: 700; background: var(--primary-light); color: var(--primary-dark); border: 1px solid rgba(151, 184, 129, 0.35); }
    #view-pipeline .plm-id { flex: 1; min-width: 0; }
    #view-pipeline .plm-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
    #view-pipeline .plm-name { min-width: 0; font-size: 12.5px; font-weight: 700; line-height: 1.2; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #view-pipeline .plm-sub { margin-top: 0; font-size: 11px; line-height: 1.2; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #view-pipeline .plm-top > span { flex: none; font-size: 13px; font-weight: 800; color: var(--text-primary); }
    #view-pipeline .plm-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
    #view-pipeline .plm-chips:empty { display: none; }
    /* chips come from the desktop badge builders (9-10px); lift them to a readable size here */
    #view-pipeline .plm-chips > * { flex: 0 0 auto !important; display: inline-flex !important; align-items: center; justify-content: center; gap: 3px; min-height: 20px !important; height: auto !important; padding: 0 6px !important; border-radius: 5px; font-size: 10px !important; line-height: 1; max-width: 100%; box-shadow: none !important; }
    #view-pipeline .plm-chips > * span { font-size: inherit !important; }
    #view-pipeline .plm-chips > * svg { width: 11px !important; height: 11px !important; }
    #view-pipeline .plm-actions { display: flex; align-items: stretch; gap: 5px; }
    #view-pipeline .plm-cta { flex: 1; min-width: 0; min-height: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 8px; border-radius: 7px; border: 1px solid; font-size: 11.5px; font-weight: 700; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
    #view-pipeline .plm-cta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    @media (max-width: 359px) {
        #view-pipeline .plm-cta { font-size: 13px; padding: 0 8px; gap: 6px; }
        #view-pipeline .plm-actions { gap: 6px; }
    }
    #view-pipeline .plm-cta-sage { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
    #view-pipeline .plm-cta-sage:active { background: var(--btn-primary-hover); }
    #view-pipeline .plm-cta-coral { background: var(--btn-accent-bg); border-color: var(--btn-accent-border); color: var(--btn-accent-text); }
    #view-pipeline .plm-cta-coral:active { background: var(--btn-accent-hover); }
    #view-pipeline .plm-cta-sky { background: var(--ocean-light); border-color: var(--ocean); color: var(--ocean-dark); }
    #view-pipeline .plm-cta-ghost { background: var(--btn-ghost-bg); border-color: var(--btn-ghost-border); color: var(--btn-ghost-text); }
    #view-pipeline .plm-cta-ghost:active, #view-pipeline .plm-cta-sky:active { background: var(--btn-ghost-hover); }
    #view-pipeline .plm-icon-btn { width: 28px; height: 28px; min-width: 28px; min-height: 28px; flex: none; display: inline-flex; align-items: center; justify-content: center; padding: 0; border-radius: 8px; border: 1px solid var(--btn-ghost-border); background: transparent; color: var(--text-secondary); box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
    #view-pipeline .plm-icon-btn:active { background: var(--btn-ghost-hover); }

    html.dark #view-pipeline .plm-name, html.dark #view-pipeline .plm-top > span { color: var(--dark-text); }
    html.dark #view-pipeline .plm-sub { color: var(--dark-text-muted); }
    html.dark #view-pipeline .plm-avatar { background: rgba(151, 184, 129, 0.15); color: #b9d3a6; border-color: rgba(151, 184, 129, 0.3); }
    html.dark #view-pipeline .plm-cta-ghost, html.dark #view-pipeline .plm-icon-btn { border-color: var(--dark-border); color: var(--dark-text-secondary); }
    html.dark #view-pipeline .plm-cta-sky { background: rgba(143, 184, 202, 0.15); border-color: rgba(143, 184, 202, 0.4); color: #b4d4e2; }
    html.dark #view-pipeline .plm-cta-ghost:active, html.dark #view-pipeline .plm-icon-btn:active, html.dark #view-pipeline .plm-cta-sky:active { background: rgba(255, 255, 255, 0.06); }

/* ==========================================================================
   ANALYSIS WORKBENCH — Name + Mobile (Flat 2.0)
   Presentation only: no shadows, transforms or gradients on controls.
   ========================================================================== */
:root {
    --aw-lavender: #C4B5D4;
    --aw-lavender-dark: #9E8FB0;
    --aw-lavender-light: #F5F0F9;
    --aw-sage-soft: #f0f7ec;
}

html.dark {
    --aw-lavender: #dfcceb;
    --aw-lavender-dark: #b69fc8;
    --aw-lavender-light: rgba(196, 181, 212, 0.14);
    --aw-sage-soft: rgba(168, 204, 143, 0.14);
}

.aw-workbench {
    display: grid;
    gap: 1rem;
    align-items: start;
}

@media (min-width: 1024px) {
    .aw-workbench {
        grid-template-columns: minmax(0, 1fr) 300px;
    }
}

.aw-main,
.aw-rail,
.aw-rail-inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

@media (min-width: 1024px) {
    .aw-rail-inner {
        position: sticky;
        top: 0.75rem;
    }
}

.aw-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1rem;
    min-width: 0;
}

@media (min-width: 768px) {
    .aw-card {
        padding: 1.25rem;
    }
}

.aw-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.aw-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.aw-field-tools {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.aw-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.4;
}

.aw-chip--sage {
    background: var(--aw-sage-soft);
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.aw-chip--ocean {
    background: var(--ocean-light);
    border-color: var(--ocean);
    color: var(--ocean-dark);
}

.aw-input {
    width: 100%;
    background: var(--bg-body);
    border: 1px solid var(--border-strong);
    border-radius: 0.9rem;
    padding: 0.8rem 1rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.aw-input::placeholder {
    font-weight: 400;
    color: var(--text-muted);
}

.aw-input:focus {
    border-color: var(--primary-color);
    background: var(--bg-card);
}

.aw-input:focus-visible,
.aw-btn:focus-visible,
.aw-seg-btn:focus-visible,
.aw-deck-tab:focus-visible,
.aw-tool-btn:focus-visible,
.aw-chip-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.aw-hint {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin: 0.6rem 0 0;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
}

.aw-hint kbd {
    font-family: ui-monospace, monospace;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.3rem;
    background: var(--bg-card);
    color: var(--text-secondary);
}

/* Letter value strip */
.aw-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.8rem;
    min-height: 2.7rem;
}

.aw-tile {
    width: 2rem;
    height: 2.7rem;
    border-radius: 0.6rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
}

.aw-tile b {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    line-height: 1;
    color: var(--text-primary);
}

.aw-tile span {
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-muted);
}

.aw-tile--vowel {
    background: var(--aw-lavender-light);
    border-color: var(--aw-lavender);
}

.aw-tile--vowel b,
.aw-tile--vowel span {
    color: var(--aw-lavender-dark);
}

.aw-tile--gap {
    width: 0.4rem;
    border: 0;
    background: transparent;
}

.aw-strip-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.35rem;
    font-size: 0.6rem;
    color: var(--text-muted);
}

.aw-strip-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.aw-swatch {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 0.15rem;
    background: var(--aw-lavender-light);
    border: 1px solid var(--aw-lavender);
}

.aw-swatch--personality {
    background: var(--aw-sage-soft);
    border-color: var(--primary-color);
}

.aw-swatch--consonant {
    background: var(--bg-card);
    border-color: var(--border-strong);
}

.aw-core-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0.55rem 0 0.15rem;
}

.aw-core-row + .aw-chips {
    margin-top: 0.4rem;
}

.aw-core-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.26rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 0.55rem;
    background: var(--bg-body);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
}

.aw-core-pill b {
    font-family: var(--font-heading);
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.aw-core-pill--heart {
    background: transparent;
    border-color: var(--aw-lavender);
    color: var(--text-secondary);
}

.aw-core-pill--heart b {
    color: var(--text-primary);
}

.aw-core-pill--heart .aw-swatch {
    background: var(--aw-lavender-dark);
    border-color: var(--aw-lavender-dark);
}

.aw-strip-empty {
    font-size: 0.65rem;
    font-style: italic;
    color: var(--text-muted);
    align-self: center;
}

/* Controls */
.aw-input-foot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
}

.aw-grow {
    flex: 1;
}

.aw-segmented {
    display: inline-flex;
    gap: 0.15rem;
    padding: 0.2rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    flex-wrap: wrap;
}

.aw-seg-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.4;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.aw-seg-btn:hover {
    color: var(--text-primary);
}

.aw-seg-btn.is-active {
    background: var(--bg-card);
    border-color: var(--border-strong);
    color: var(--primary-dark);
}

.aw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.95rem;
    border-radius: 0.7rem;
    border: 1px solid transparent;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.4;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.aw-btn--primary {
    background: var(--primary-color);
    border-color: var(--primary-dark);
    color: #fff;
}

.aw-btn--primary:hover {
    background: var(--primary-dark);
}

.aw-btn--ghost {
    background: var(--bg-card);
    border-color: var(--border-strong);
    color: var(--text-secondary);
}

.aw-btn--ghost:hover {
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.aw-btn--soft {
    background: var(--aw-sage-soft);
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.aw-btn--soft:hover {
    background: var(--primary-light);
}

/* Result hero */
.aw-hero {
    display: grid;
    gap: 1.1rem;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
}

@media (max-width: 600px) {
    .aw-hero {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
}

/* Deliberate Flat 2.0 exception: the result orb is the single hero object.
   Depth, gloss and a root-progress ring are allowed here — nowhere else.
   The ring, inner tint, glow and value ink take the ruling planet's accent.
   Hex values mirror the Navagraha palette in js/yantras.js (PLANETS).
   No data-planet attribute = the original sage orb. */
.aw-orb {
    --p: 0;
    --aw-orb-accent: var(--primary-color);
    --aw-orb-ink: color-mix(in srgb, var(--aw-orb-accent) 72%, #102018);
    --aw-orb-track: color-mix(in srgb, var(--aw-orb-accent) 24%, transparent);
    --aw-orb-glow: color-mix(in srgb, var(--aw-orb-accent) 45%, transparent);
    --aw-orb-text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
    position: relative;
    isolation: isolate;
    width: 9rem;
    height: 9rem;
    border-radius: 50%;
    border: 0;
    padding: 0.55rem;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    text-align: center;
    background:
        conic-gradient(from -90deg,
            var(--aw-orb-accent) calc(var(--p) * 1%),
            var(--aw-orb-track) 0);
    box-shadow:
        0 18px 38px -22px var(--aw-orb-glow),
        0 2px 6px rgba(26, 42, 32, 0.06);
}

.aw-orb[data-planet="sun"]     { --aw-orb-accent: #C41E3A; }
.aw-orb[data-planet="moon"]    { --aw-orb-accent: #6B7280; }
.aw-orb[data-planet="jupiter"] { --aw-orb-accent: #CCB800; }
.aw-orb[data-planet="rahu"]    { --aw-orb-accent: #4A90D9; }
.aw-orb[data-planet="mercury"] { --aw-orb-accent: #2D8B57; }
.aw-orb[data-planet="venus"]   { --aw-orb-accent: #C4647A; }
.aw-orb[data-planet="ketu"]    { --aw-orb-accent: #7B2D8E; }
.aw-orb[data-planet="saturn"]  { --aw-orb-accent: #2C5F8A; }
.aw-orb[data-planet="mars"]    { --aw-orb-accent: #D97706; }

.aw-orb::before {
    content: "";
    position: absolute;
    inset: 7px;
    z-index: 0;
    border-radius: inherit;
    background:
        radial-gradient(120% 120% at 30% 16%,
            color-mix(in srgb, var(--aw-orb-accent) 4%, #ffffff) 0%,
            color-mix(in srgb, var(--aw-orb-accent) 12%, #ffffff) 58%,
            color-mix(in srgb, var(--aw-orb-accent) 20%, #ffffff) 100%);
    box-shadow:
        inset 0 2px 10px rgba(26, 42, 32, 0.08),
        inset 0 -8px 16px color-mix(in srgb, var(--aw-orb-accent) 12%, transparent);
}

.aw-orb::after {
    content: "";
    position: absolute;
    inset: 7px;
    z-index: 0;
    border-radius: inherit;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background:
        radial-gradient(circle at 28% 20%,
            rgba(255, 255, 255, 0.58),
            transparent 40%);
    pointer-events: none;
}

html.dark .aw-orb {
    --aw-orb-track: color-mix(in srgb, var(--aw-orb-accent) 26%, transparent);
    --aw-orb-ink: color-mix(in srgb, var(--aw-orb-accent) 42%, #ffffff);
    --aw-orb-glow: rgba(0, 0, 0, 0.85);
    --aw-orb-text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
    box-shadow:
        0 20px 42px -22px var(--aw-orb-glow),
        0 0 0 1px rgba(168, 204, 143, 0.08);
}

html.dark .aw-orb::before {
    background:
        radial-gradient(120% 120% at 30% 16%,
            color-mix(in srgb, var(--aw-orb-accent) 26%, #34483a) 0%,
            color-mix(in srgb, var(--aw-orb-accent) 16%, #202f26) 58%,
            color-mix(in srgb, var(--aw-orb-accent) 10%, #17211b) 100%);
    box-shadow:
        inset 0 2px 12px rgba(0, 0, 0, 0.35),
        inset 0 -8px 18px color-mix(in srgb, var(--aw-orb-accent) 8%, transparent);
}

/* No color-mix() (iOS 15, Safari <= 16.2): an invalid color-mix makes the whole
   declaration invalid at computed-value time, so the orb lost its tint and the ring its
   track. Plain colours keep the same shape. Dead in every modern browser. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
    .aw-orb {
        --aw-orb-ink: var(--aw-orb-accent);
        --aw-orb-track: rgba(15, 32, 24, 0.18);
        --aw-orb-glow: rgba(15, 32, 24, 0.28);
    }
    .aw-orb::before {
        background: radial-gradient(120% 120% at 30% 16%, #ffffff 0%, #f6f9f3 58%, #e8efe4 100%);
        box-shadow: inset 0 2px 10px rgba(26, 42, 32, 0.08);
    }
    html.dark .aw-orb { --aw-orb-ink: #f2f4ef; --aw-orb-track: rgba(255, 255, 255, 0.18); }
    html.dark .aw-orb::before {
        background: radial-gradient(120% 120% at 30% 16%, #34483a 0%, #202f26 58%, #17211b 100%);
        box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.35);
    }
}

html.dark .aw-orb::after {
    border-color: rgba(255, 255, 255, 0.08);
    background:
        radial-gradient(circle at 28% 20%,
            rgba(255, 255, 255, 0.1),
            transparent 42%);
}

.aw-orb-label {
    position: relative;
    z-index: 1;
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.aw-orb-value {
    position: relative;
    z-index: 1;
    font-family: var(--font-heading);
    font-size: 1.72rem;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--aw-orb-ink);
    text-shadow: var(--aw-orb-text-shadow);
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .aw-orb {
        width: 7.25rem;
        height: 7.25rem;
    }

    .aw-orb-value {
        font-size: 1.45rem;
    }
}

.aw-eyebrow {
    display: block;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.aw-hero-name {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.2rem 0 0.45rem;
    overflow-wrap: anywhere;
}

.aw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

@media (max-width: 600px) {
    .aw-chips {
        justify-content: center;
    }

    .aw-core-row {
        justify-content: center;
    }
}

.aw-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    margin-top: 0.8rem;
}

.aw-stat {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 0.7rem;
    background: var(--bg-body);
    min-width: 0;
}

.aw-stat span {
    display: block;
    font-size: 0.54rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.aw-stat strong {
    display: block;
    margin-top: 0.12rem;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

/* Deck */
.aw-deck {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    overflow: hidden;
}

.aw-deck-tabs {
    display: flex;
    gap: 0.1rem;
    padding: 0.25rem 0.4rem 0;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}

.aw-deck-tabs::-webkit-scrollbar {
    display: none;
}

.aw-deck-tab {
    position: relative;
    flex: none;
    padding: 0.6rem 0.7rem;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0.45rem 0.45rem 0 0;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.aw-deck-tab:hover {
    color: var(--text-primary);
}

.aw-deck-tab.is-active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary-color);
}

.aw-deck-body {
    padding: 1rem;
}

@media (min-width: 768px) {
    .aw-deck-body {
        padding: 1.25rem;
    }
}

.aw-deck-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    font-style: italic;
    color: var(--text-muted);
}

/* Rail */
.aw-rail-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.1rem;
    padding: 0.9rem;
}

.aw-rail-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.65rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.aw-rail-title svg,
.aw-rail-title i {
    width: 0.8rem;
    height: 0.8rem;
    color: var(--primary-color);
}

.aw-fit {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.aw-fit-orb {
    width: 4.2rem;
    height: 4.2rem;
    border-radius: 50%;
    border: 1px solid var(--primary-color);
    background: var(--aw-sage-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    color: var(--primary-dark);
}

.aw-fit-orb strong {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
}

.aw-fit-copy {
    min-width: 0;
}

.aw-fit-copy b {
    display: block;
    font-size: 0.78rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.aw-fit-copy span {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.62rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Digit map */
.aw-keypad-wrap {
    display: grid;
    gap: 1rem;
}

@media (min-width: 700px) {
    .aw-keypad-wrap {
        grid-template-columns: minmax(0, 19rem) minmax(0, 1fr);
        align-items: start;
    }
}

.aw-keypad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    max-width: 20rem;
}

.aw-key {
    position: relative;
    aspect-ratio: 1.15 / 1;
    border: 1px solid var(--border-color);
    border-radius: 0.7rem;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    overflow: hidden;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.aw-key b {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.aw-key .cnt {
    position: absolute;
    top: 0.28rem;
    right: 0.35rem;
    font-size: 0.52rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.aw-key .lbl {
    max-width: 100%;
    padding: 0 0.2rem;
    font-size: 0.44rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aw-key.is-on {
    background: var(--aw-sage-soft);
    border-color: var(--primary-color);
}

.aw-key.is-hot {
    background: var(--primary-light);
    border-color: var(--primary-dark);
}

.aw-key.is-zero {
    border-style: dashed;
    opacity: 0.6;
}

.aw-digits {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.aw-digit {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.aw-digit.is-hit {
    background: var(--aw-sage-soft);
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.aw-digit.is-miss {
    border-style: dashed;
    color: var(--text-muted);
}

.aw-subhead {
    display: block;
    margin: 0.7rem 0 0.35rem;
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.aw-note {
    margin: 0.6rem 0 0;
    font-size: 0.66rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.aw-segments {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
}

@media (min-width: 600px) {
    .aw-segments {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Compare table */
.aw-compare {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.aw-compare th {
    padding: 0 0 0.5rem;
    text-align: left;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: transparent !important;
}

.aw-compare thead {
    background: transparent !important;
}

.aw-compare thead tr {
    background: transparent !important;
}

html.dark .aw-compare thead tr {
    background: transparent !important;
}

html.dark .aw-compare thead th {
    background: transparent !important;
    color: var(--dark-text-muted) !important;
    border-color: var(--dark-border) !important;
}

.aw-compare td {
    padding: 0.55rem 0.25rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.aw-compare td:first-child {
    color: var(--text-primary);
    font-weight: 600;
}

.aw-compare .is-win {
    color: var(--primary-dark);
    font-weight: 700;
}

.aw-compare .is-lose {
    color: var(--text-muted);
}

/* Nested tool panels inside the workbench */
.aw-tools {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.aw-tools-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;
}

.aw-tools-bar > span {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.aw-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-strong);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 700;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.aw-tool-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-dark);
    background: var(--aw-sage-soft);
}

.aw-nested {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 0.9rem;
    padding: 0.9rem;
}

/* Compact mobile ergonomics: one scrolling row for tabs and letter tiles. */
@media (max-width: 767px) {
    #view-analysis .section-page-header .macos-segmented-control {
        justify-content: flex-start;
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%);
        mask-image: linear-gradient(to right, #000 88%, transparent 100%);
    }

    #view-analysis .section-page-header .macos-segmented-control button,
    #view-analysis .section-page-header .macos-segmented-control .segment-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    #view-analysis .section-page-header .macos-segmented-control::-webkit-scrollbar {
        display: none;
    }

    .aw-strip {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
        scrollbar-width: none;
    }

    .aw-strip::-webkit-scrollbar {
        display: none;
    }

    .aw-tile {
        flex: none;
    }
}

@media (max-width: 520px) {
    .aw-field-tools .aw-btn--ghost span {
        display: none;
    }
}

@media (max-width: 600px) {
    .aw-input-foot .aw-grow {
        display: none;
    }

    .aw-input-foot .aw-btn--primary {
        flex: 1 1 100%;
    }

    .aw-input-foot .aw-btn--ghost,
    .aw-input-foot .aw-btn--soft {
        flex: 1 1 0;
    }
}

/* ==========================================================================
   Pipeline calendar (js/pipeline_calendar.js) - Week / Month / Agenda
   Flat 2.0: buttons carry no shadow/gradient/transform. Colours come from the
   shared tokens, so dark mode follows html.dark.
   ========================================================================== */
/* The card also carries Tailwind's .overflow-y-auto, but the MacOS card-shell rule
   (.bg-white.rounded-xl.border, ~line 10491) sets overflow: hidden at a higher class
   specificity, so Month and Agenda were clipped with no scrollbar at all and Week lost
   its bottom rows. This ID rule wins: the card is the one scroller for every view. */
#pipeline-calendar { overflow-y: auto; }
.pcal { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; color: var(--text-primary); }
.pcal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-strong); }
.pcal-nav { display: flex; align-items: center; gap: 6px; }
.pcal-icon, .pcal-today, .pcal-seg { min-height: 40px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-secondary); font-size: 13px; font-weight: 600; border-radius: 10px; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.pcal-icon { width: 40px; display: inline-flex; align-items: center; justify-content: center; }
.pcal-today { padding: 0 14px; }
.pcal-icon:hover, .pcal-today:hover, .pcal-seg:hover { background: var(--primary-light); border-color: var(--primary-color); }
.pcal-title { font-family: 'Quicksand', sans-serif; font-size: 17px; font-weight: 700; margin: 0; flex: 1 1 160px; min-width: 0; }
.pcal-segs { display: inline-flex; gap: 4px; }
.pcal-seg { padding: 0 14px; }
.pcal-seg.active { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
.pcal-seg.active:hover { background: var(--btn-primary-hover); }
.pcal-body { flex: 1 1 auto; min-width: 0; }

.pcal-tray { padding: 10px 16px; border-bottom: 1px solid var(--border-strong); background: var(--primary-50); }
.pcal-tray-h { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary-dark); }
.pcal-count { margin-left: 4px; padding: 0 7px; border-radius: 999px; background: var(--primary-light); border: 1px solid var(--primary-color); font-size: 11px; }
.pcal-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pcal-chip { display: inline-flex; flex-direction: column; align-items: flex-start; min-height: 44px; padding: 4px 12px; border-radius: 10px; border: 1px solid var(--sun-dark); background: var(--sun-light); color: var(--text-primary); text-align: left; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.pcal-chip:hover { background: var(--bg-card); }
.pcal-chip-n { font-size: 13px; font-weight: 700; line-height: 1.2; }
.pcal-chip-t { font-size: 11px; color: var(--text-secondary); }
.pcal-more { align-self: center; font-size: 12px; color: var(--text-muted); }

/* events (shared by week / month / agenda) */
.pcal-ev { border: 1px solid transparent; border-left-width: 3px; text-align: left; color: var(--text-primary); box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.pcal-ev-inq { background: var(--sun-light); border-color: var(--sun-dark); }
.pcal-ev-sched { background: var(--primary-light); border-color: var(--primary-color); }
.pcal-ev-prog { background: var(--ocean-light); border-color: var(--ocean-dark); }
.pcal-ev-done { background: var(--primary-50); border-color: var(--border-strong); opacity: 0.7; }
.pcal-ev-clash { border-color: var(--secondary-color); background: var(--secondary-light); }
.pcal-ev-missed { border-color: var(--secondary-dark); background: var(--secondary-light); }
.pcal-ev:hover { border-color: var(--primary-dark); }
.pcal-flag { display: inline-block; padding: 0 6px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; background: var(--secondary-color); color: #fff; }
html.dark .pcal-ev-inq { background: rgba(236, 212, 137, 0.14); }
html.dark .pcal-ev-sched { background: rgba(151, 184, 129, 0.16); }
html.dark .pcal-ev-prog { background: rgba(143, 184, 202, 0.16); }
html.dark .pcal-ev-done { background: rgba(255, 255, 255, 0.04); }
html.dark .pcal-ev-clash, html.dark .pcal-ev-missed { background: rgba(232, 141, 120, 0.16); }
html.dark .pcal-chip { background: rgba(236, 212, 137, 0.14); }
html.dark .pcal-icon:hover, html.dark .pcal-today:hover, html.dark .pcal-seg:hover { background: rgba(151, 184, 129, 0.16); }
html.dark .pcal-tray { background: rgba(151, 184, 129, 0.08); }

/* week */
/* Below 640px the card flows in the page (no card scroll), so the grid keeps a
   viewport-based cap. From 640px up the grid takes the height left under the toolbar
   instead — a 100vh clamp was taller than the card and pushed the late hours out of it. */
.pcal-wscroll { max-height: clamp(340px, calc(100vh - 340px), 800px); overflow: auto; }
@media (min-width: 640px) {
    #pipeline-calendar { padding-bottom: 8px; }   /* pb-24 is bottom-nav room, not needed here */
    #pipeline-calendar .pcal-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
    #pipeline-calendar .pcal-wscroll { flex: 1 1 auto; min-height: 200px; max-height: none; }
}
.pcal-week { min-width: 560px; }
/* from large-phone width up the 7 day columns fit the card, so the week never needs a hidden sideways scroll (Sunday was cut off) */
@media (min-width: 640px) { .pcal-week { min-width: 0; } }
.pcal-wgrid { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); }
.pcal-whead { position: sticky; top: 0; z-index: 3; background: var(--bg-card); border-bottom: 1px solid var(--border-strong); }
.pcal-wh { padding: 8px 4px; text-align: center; font-size: 12px; color: var(--text-secondary); border-left: 1px solid var(--border-color); }
.pcal-wh b { display: block; font-size: 18px; color: var(--text-primary); }
.pcal-wh.is-today b { color: var(--primary-dark); }
.pcal-wh.is-today { background: var(--primary-light); }
.pcal-wallday { border-bottom: 1px solid var(--border-strong); }
.pcal-hr-l { padding: 6px 4px; font-size: 10px; text-align: right; color: var(--text-muted); }
.pcal-ad { padding: 4px 2px; border-left: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 2px; }
.pcal-gutter { position: relative; }
.pcal-hr { position: relative; }
.pcal-hr span { position: absolute; top: -7px; right: 6px; font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.pcal-col { position: relative; border-left: 1px solid var(--border-color); }
.pcal-col.is-today { background: var(--primary-50); }
.pcal-hl { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border-color); }
.pcal-col .pcal-ev { position: absolute; overflow: hidden; padding: 3px 6px; border-radius: 8px; display: flex; flex-direction: column; gap: 1px; font-size: 11px; line-height: 1.25; }
.pcal-ev-t { font-weight: 700; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.pcal-ev-n { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcal-ev-s { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--secondary-color); z-index: 2; pointer-events: none; }
.pcal-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--secondary-color); }
.pcal-ev-flat { padding: 2px 6px; border-radius: 6px; font-size: 11px; font-weight: 600; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* month */
.pcal-month { padding: 12px 16px; }
.pcal-mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border-strong); border-left: 1px solid var(--border-strong); }
.pcal-mh { padding: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); }
.pcal-mc { min-height: 96px; padding: 4px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); min-width: 0; }
.pcal-mc.is-out { opacity: 0.45; }
.pcal-mc.is-today { background: var(--primary-50); }
.pcal-md { align-self: flex-start; min-width: 28px; min-height: 28px; border: 0; background: transparent; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--text-secondary); box-shadow: none; }
.pcal-md:hover { background: var(--primary-light); }
.pcal-mc.is-today .pcal-md { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.pcal-more-b { border: 0; background: transparent; text-align: left; font-size: 11px; font-weight: 700; color: var(--primary-dark); padding: 2px 4px; box-shadow: none; }

/* agenda */
.pcal-agenda { padding: 8px 16px; display: flex; flex-direction: column; gap: 14px; }
.pcal-day header { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border-strong); }
.pcal-day header b { font-family: 'Quicksand', sans-serif; font-size: 22px; line-height: 1; }
.pcal-day header span { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.pcal-day.is-today header b, .pcal-day.is-today header span { color: var(--primary-dark); }
.pcal-ar { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; margin-top: 6px; padding: 8px 10px; border-radius: 12px; white-space: normal; font-size: 13px; }
.pcal-ar-t { flex: none; min-width: 104px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.pcal-ar-m { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pcal-ar-n { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcal-ar-s { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcal-ar-st { flex: none; font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.pcal-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px 16px; color: var(--text-muted); }

@media (max-width: 767px) {
    .pcal-bar { padding: 10px 12px; }
    .pcal-title { flex-basis: 100%; order: -1; }
    .pcal-segs { margin-left: auto; }
    .pcal-month { padding: 8px 4px; }
    .pcal-mc { min-height: 72px; padding: 2px; }
    .pcal-ar-t { min-width: 84px; }
    .pcal-ar-st { display: none; }
}

/* Pipeline header, tablet to small laptop: title cluster and toolbar wrap onto two rows instead of the toolbar overflowing leftwards over the title/Add Client button */
@media (min-width: 768px) and (max-width: 1199px) {
    #view-pipeline .section-page-header { flex-wrap: wrap; }
    #view-pipeline .section-page-header > .macos-title-cluster { flex: 0 1 auto; min-width: 0; }
    #view-pipeline .section-page-header > div:last-child { flex: 1 1 26rem; min-width: min(100%, 26rem); }
    #view-pipeline #pipeline-search-container { flex: 1 1 140px; min-width: 0; }
}


/* ==========================================================================
   Pipeline slot picker + calendar drag (js/pipeline_schedule.js)
   Flat 2.0 controls: no shadow / gradient / transform on buttons.
   ========================================================================== */
.pcal-chipw { display: inline-flex; align-items: stretch; gap: 4px; }
.pcal-find { width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--primary-dark); box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.pcal-find:hover { background: var(--primary-light); border-color: var(--primary-color); }
.pcal-ev[draggable="true"], .pcal-chip[draggable="true"] { cursor: grab; }
.pcal-dragging { opacity: 0.45; }
.pcal-ghost { position: absolute; left: 2px; right: 2px; z-index: 4; pointer-events: none; padding: 3px 6px; border-radius: 8px; border: 2px dashed var(--primary-dark); background: var(--primary-light); color: var(--primary-dark); font-size: 11px; font-weight: 700; overflow: hidden; }
.pcal-ghost.bad { border-color: var(--secondary-dark); background: var(--secondary-light); color: var(--secondary-dark); }
.pcal-mc.pcal-drop { background: var(--primary-light); outline: 2px dashed var(--primary-color); outline-offset: -2px; }
html.dark .pcal-ghost { background: rgba(151, 184, 129, 0.2); color: #cfe3c2; }
html.dark .pcal-ghost.bad { background: rgba(232, 141, 120, 0.2); color: #f4b8a9; }
html.dark .pcal-mc.pcal-drop { background: rgba(151, 184, 129, 0.14); }

.psp-backdrop { position: fixed; inset: 0; z-index: 160; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--backdrop-light); }
.psp { width: 100%; max-width: 672px; max-height: min(92vh, 760px); display: flex; flex-direction: column; background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-xl); overflow: hidden; }
.psp-h { display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 12px; border-bottom: 1px solid var(--border-strong); }
.psp-h > div { flex: 1 1 auto; min-width: 0; }
.psp-h h3 { margin: 0; font-family: 'Quicksand', sans-serif; font-size: 18px; font-weight: 700; }
.psp-h p { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psp-h .psp-cur { font-size: 12px; color: var(--text-muted); }
.psp-x { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-secondary); box-shadow: none; transition: background-color 0.15s ease; }
.psp-x:hover { background: var(--primary-light); }
.psp-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 14px; }
.psp-body h4 { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.psp-sugs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.psp-sug { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 52px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--primary-color); background: var(--primary-light); color: var(--text-primary); text-align: left; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.psp-sug b { font-size: 13px; }
.psp-sug span { font-size: 12px; color: var(--text-secondary); }
.psp-sug:hover { border-color: var(--primary-dark); }
.psp-sug.sel { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
.psp-sug.sel span { color: var(--btn-primary-text); }
.psp-days { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.psp-day { flex: none; position: relative; width: 52px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.psp-day span { font-size: 11px; color: var(--text-secondary); }
.psp-day b { font-size: 16px; }
.psp-day i { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--ocean-dark); }
.psp-day:hover { background: var(--primary-light); }
.psp-day.sel { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
.psp-day.sel span { color: var(--btn-primary-text); }
.psp-slots { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.psp-slot { flex: 0 0 auto; min-width: 96px; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 13px; font-weight: 600; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.psp-slot.free:hover { background: var(--primary-light); border-color: var(--primary-color); }
.psp-slot.sel { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
.psp-slot.taken { background: var(--secondary-light); border-color: var(--secondary-color); color: var(--secondary-dark); text-decoration: line-through; }
.psp-slot.past { opacity: 0.4; }
.psp-slot[disabled] { cursor: not-allowed; }
.psp-custom { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; color: var(--text-muted); }
.psp-custom input { width: 118px; min-height: 44px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); }
.psp-quick { display: flex; gap: 8px; }
.psp-quick button { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 13px; font-weight: 600; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.psp-quick button:hover { background: var(--primary-light); border-color: var(--primary-color); }
/* Client time zone + Quick postpone: one inline row at every width (they are both "when/where" shortcuts). */
.psp-inline { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; }
.psp-inline-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.psp-inline-group > h4 { margin: 0; }
.psp-inline-tz { flex: 1 1 210px; }
.psp-inline-postpone { flex: 0 0 auto; }
.psp-inline .psp-tz { margin-top: 0; }
.psp-warn { margin: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--secondary-color); background: var(--secondary-light); color: var(--secondary-dark); font-size: 13px; font-weight: 600; }
.psp-note { margin: 0; font-size: 13px; color: var(--text-muted); }
.psp-f { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-strong); }
.psp-cancel { flex: none; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-secondary); font-weight: 600; box-shadow: none; transition: background-color 0.15s ease; }
.psp-cancel:hover { background: var(--primary-light); }
.psp-ok { flex: 1 1 auto; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--btn-primary-border); background: var(--btn-primary-bg); color: var(--btn-primary-text); font-weight: 700; font-size: 13px; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.psp-ok:hover { background: var(--btn-primary-hover); }
.psp-ok.warn { background: var(--secondary-color); border-color: var(--secondary-dark); color: #fff; }
.psp-ok[disabled] { opacity: 0.45; cursor: not-allowed; }
html.dark .psp-sug { background: rgba(151, 184, 129, 0.14); }
html.dark .psp-slot.taken, html.dark .psp-warn { background: rgba(232, 141, 120, 0.16); color: #f4b8a9; }
html.dark .psp-slot.free:hover, html.dark .psp-sug:hover, html.dark .psp-day:hover, html.dark .psp-x:hover, html.dark .psp-cancel:hover, html.dark .psp-quick button:hover, html.dark .pcal-find:hover { background: rgba(151, 184, 129, 0.16); }

@media (max-width: 767px) {
    .psp-backdrop { align-items: flex-end; padding: 0; }
    .psp { max-width: none; max-height: 92vh; border-radius: 18px 18px 0 0; }
    /* Four suggestions stay on one row on a phone — they are the fastest path to a new time. */
    .psp-sugs { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
    .psp-sug { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; padding: 6px; min-height: 54px; }
    .psp-sug b { font-size: 10.5px; line-height: 1.2; }
    .psp-sug span { font-size: 10px; }
    .psp-sug small { font-size: 8.5px; }
    .psp-inline { gap: 8px; }
    .psp-inline-tz { flex: 1 1 140px; }
    .psp-inline-postpone .psp-quick button { padding: 0 10px; font-size: 12px; }
    .psp-f { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* Pipeline calendar sizing lives in the .pcal block above (card is the scroller; the week
   grid fills the card from 640px up). */


/* ==========================================================================
   Availability: hours editor, Mark unavailable, calendar time-off blocks
   (js/pipeline_availability.js). Flat 2.0 controls; colours from tokens.
   ========================================================================== */
.pcal-acts { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pcal-act { min-height: 40px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-secondary); font-size: 13px; font-weight: 600; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.pcal-act:hover { background: var(--primary-light); border-color: var(--primary-color); }
.pcal-act-off { border-color: var(--secondary-color); color: var(--secondary-dark); }
.pcal-act-off:hover { background: var(--secondary-light); border-color: var(--secondary-dark); }
.pcal-off { position: absolute; left: 0; right: 0; background: var(--border-color); opacity: 0.7; pointer-events: none; }
.pcal-block { display: flex; align-items: flex-start; position: absolute; left: 0; right: 0; z-index: 1; padding: 4px 6px; border: 1px dashed var(--secondary-color); background: var(--secondary-light); color: var(--secondary-dark); font-size: 11px; font-weight: 700; text-align: left; overflow: hidden; box-shadow: none; opacity: 0.9; }
.pcal-block span { display: block; overflow: hidden; text-overflow: ellipsis; }
.pcal-col .pcal-ev { z-index: 2; }
.pcal-mtop { display: flex; align-items: center; gap: 4px; min-width: 0; }
.pcal-offchip { padding: 0 6px; border-radius: 999px; background: var(--secondary-light); border: 1px solid var(--secondary-color); color: var(--secondary-dark); font-size: 10px; font-weight: 800; white-space: nowrap; }
.pcal-mc.is-dayoff { background: var(--border-color); }
.pcal-ar-block { background: var(--secondary-light); border: 1px dashed var(--secondary-color); color: var(--secondary-dark); text-align: left; box-shadow: none; }
html.dark .pcal-off { background: rgba(255, 255, 255, 0.05); }
html.dark .pcal-block, html.dark .pcal-ar-block, html.dark .pcal-offchip { background: rgba(232, 141, 120, 0.14); color: #f4b8a9; }
html.dark .pcal-mc.is-dayoff { background: rgba(255, 255, 255, 0.04); }
html.dark .pcal-act:hover { background: rgba(151, 184, 129, 0.16); }
html.dark .pcal-act-off:hover { background: rgba(232, 141, 120, 0.16); }

.psp-slot.blocked { background: var(--secondary-light); border-style: dashed; border-color: var(--secondary-color); color: var(--secondary-dark); }
html.dark .psp-slot.blocked { background: rgba(232, 141, 120, 0.16); color: #f4b8a9; }
.psp-slot.off { opacity: 0.55; }

.pav-steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 10px 16px 0; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.pav-steps li { flex: 1 1 0; padding-bottom: 6px; border-bottom: 3px solid var(--border-strong); }
.pav-steps li.cur { color: var(--primary-dark); border-color: var(--primary-color); }
.pav-steps li.done { color: var(--text-secondary); border-color: var(--primary-dark); }
.pav-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pav-kind { width: auto; min-height: 48px; font-size: 14px; font-weight: 600; }
.pav-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pav-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.pav-fields input, .pav-fields select, .pav-row input[type="time"], .psp-custom input[type="text"], .psp-custom input[type="number"] { min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 14px; }
.pav-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pav-chip { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 13px; font-weight: 600; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.pav-chip:hover { background: var(--primary-light); border-color: var(--primary-color); }
.pav-chip.sel { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
.pav-hits { display: flex; flex-direction: column; gap: 10px; }
.pav-hit { padding: 10px; border-radius: 12px; border: 1px solid var(--border-strong); }
.pav-hit-h { display: flex; flex-direction: column; margin-bottom: 8px; }
.pav-hit-h span { font-size: 12px; color: var(--text-secondary); }
.pav-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.pav-opt { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 13px; font-weight: 600; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.pav-opt:hover:not([disabled]) { background: var(--primary-light); border-color: var(--primary-color); }
.pav-opt.sel { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
.pav-opt[disabled] { opacity: 0.45; cursor: not-allowed; }
.pav-rows { display: flex; flex-direction: column; gap: 6px; }
.pav-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 48px; }
.pav-day { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; font-size: 14px; font-weight: 600; }
.pav-day input { width: 20px; height: 20px; }
.pav-row.off .pav-day { color: var(--text-muted); }
.pav-offtxt { font-size: 13px; color: var(--text-muted); }
.pav-to { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; margin-top: 6px; border-radius: 10px; border: 1px solid var(--border-strong); }
.pav-to > div { display: flex; flex-direction: column; min-width: 0; }
.pav-to span { font-size: 12px; color: var(--text-secondary); }
.pav-to button { flex: none; min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-secondary); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; box-shadow: none; transition: background-color 0.15s ease; }
.pav-to button:hover { background: var(--primary-light); }
.pav-send { background: var(--btn-primary-bg) !important; border-color: var(--btn-primary-border) !important; color: var(--btn-primary-text) !important; }
.pav-line { margin: 0 0 4px; font-size: 13px; }
html.dark .pav-chip:hover, html.dark .pav-opt:hover:not([disabled]), html.dark .pav-to button:hover { background: rgba(151, 184, 129, 0.16); }

@media (max-width: 767px) {
    .pcal-acts { width: 100%; }
    .pcal-act { flex: 1 1 0; justify-content: center; }
}

/* ==========================================================================
   Availability modal v2 - one tabbed modal (Working hours | Time off) opened from the
   pipeline title bar. Flat 2.0 controls; only cards/tiles carry depth.
   ========================================================================== */
.psp.pav { max-width: 560px; }
.pav .psp-h { align-items: center; }
.pav-ico { flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--primary-light); color: var(--primary-dark); }
.pav-ico.off { background: var(--secondary-light); color: var(--secondary-dark); }
.pav-tabs { display: flex; gap: 4px; margin: 12px 16px 0; padding: 4px; border-radius: 12px; background: var(--bg-secondary, var(--primary-light)); border: 1px solid var(--border-strong); }
.pav-tab { flex: 1 1 0; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text-secondary); font-size: 13px; font-weight: 700; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.pav-tab:hover:not(.sel) { background: var(--bg-card); }
.pav-tab.sel { background: var(--bg-card); border-color: var(--border-strong); color: var(--text-primary); }
.pav-badge { min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--secondary-color); color: #fff; font-size: 11px; font-weight: 800; }
.pav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sun-dark, var(--secondary-color)); }
.pav-sum { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 14px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-sm); }
.pav-sumtxt { display: flex; flex-direction: column; font-size: 13px; color: var(--text-secondary); }
.pav-sumtxt b { font-family: 'Quicksand', sans-serif; font-size: 26px; line-height: 1.1; color: var(--text-primary); }
.pav-sumtxt span { margin-top: 2px; }
.pav-bars { display: flex; align-items: flex-end; gap: 6px; height: 56px; }
.pav-bar { position: relative; width: 22px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.pav-bar i { display: block; width: 100%; border-radius: 6px 6px 3px 3px; background: var(--primary-color); transition: height 0.2s ease; }
.pav-bar.off i { background: var(--border-strong); }
.pav-bar em { margin-top: 3px; font-style: normal; font-size: 10px; font-weight: 700; color: var(--text-muted); }
.pav-bar { padding-bottom: 14px; }
.pav-bar em { position: absolute; bottom: 0; }
.pav-rows { display: flex; flex-direction: column; gap: 6px; }
.pav .pav-row { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; min-height: 56px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--bg-card); transition: border-color 0.15s ease, background-color 0.15s ease; }
.pav .pav-row.off { background: transparent; border-style: dashed; }
.pav .pav-day { min-width: 0; flex: 1 1 auto; font-size: 14px; font-weight: 700; }
.pav-row.off .pav-day { color: var(--text-muted); font-weight: 600; }
.pav-times { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 12px; color: var(--text-muted); }
.pav-times input[type="time"] { width: 112px; }
.pav-copy { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-muted); box-shadow: none; transition: background-color 0.15s ease, color 0.15s ease; }
.pav-copy:hover { background: var(--primary-light); color: var(--primary-dark); }
.pav-sw { position: relative; flex: none; display: inline-block; width: 44px; height: 44px; cursor: pointer; }
.pav-sw input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.pav-knob { position: absolute; left: 0; top: 10px; width: 44px; height: 24px; border-radius: 999px; background: var(--border-strong); transition: background-color 0.15s ease; }
.pav-knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left 0.15s ease; }
.pav-sw input:checked + .pav-knob { background: var(--primary-dark); }
.pav-sw input:checked + .pav-knob::after { left: 23px; }
.pav-sw input:focus-visible + .pav-knob { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.pav-custom { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.pav-custom input { width: 64px; min-height: 36px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 14px; }
.pav-chips { margin-bottom: 0; }
.pav-quickrow { display: flex; flex-wrap: wrap; gap: 6px; }
.pav-cards { display: flex; flex-direction: column; gap: 8px; }
.pav-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-sm); transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.pav-card:hover { border-color: var(--primary-color); box-shadow: var(--shadow-md); }
.pav-card.now { border-color: var(--secondary-color); }
.pav-cico { flex: none; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--secondary-light); color: var(--secondary-dark); }
.pav-cmain { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pav-cmain b { font-size: 14px; }
.pav-cmain span { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pav-rel { flex: none; padding: 3px 9px; border-radius: 999px; background: var(--primary-light); color: var(--primary-dark); font-size: 11px; font-weight: 800; }
.pav-rel.now { background: var(--secondary-color); color: #fff; }
.pav-del { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-muted); box-shadow: none; transition: background-color 0.15s ease, color 0.15s ease; }
.pav-del:hover { background: var(--secondary-light); color: var(--secondary-dark); }
.pav-empty, .pav-done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 22px 16px; border-radius: 14px; border: 1px dashed var(--border-strong); }
.pav-empty > span, .pav-done > span { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); }
.pav-done { border-style: solid; }
.pav-done > span { background: var(--primary-dark); color: #fff; }
.pav-empty b, .pav-done b { font-family: 'Quicksand', sans-serif; font-size: 16px; }
.pav-empty p, .pav-done p { margin: 0; max-width: 360px; font-size: 13px; color: var(--text-secondary); }
.pav-kind { flex-direction: row; gap: 8px; }
.psp-ok .lucide, .psp-ok svg { flex: none; }
.psp-ok { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.pav .pav-steps { margin: 0; padding: 12px 16px 0; }
html.dark .pav-tab:hover:not(.sel), html.dark .pav-copy:hover { background: rgba(151, 184, 129, 0.16); }
html.dark .pav-del:hover { background: rgba(232, 141, 120, 0.16); }
html.dark .pav-knob::after { background: #f5f5f5; }
@media (max-width: 640px) {
    .pav .pav-row { flex-wrap: wrap; row-gap: 0; padding: 4px 10px 8px; }
    .pav .pav-day { flex: 1 1 auto; }
    .pav-times { flex: 1 1 100%; min-width: 0; justify-content: space-between; padding-left: 0; margin-top: 0; }
    .pav-times input[type="time"] { flex: 1 1 0; width: 0; min-width: 0; padding: 0 6px; font-size: 13px; }
    .pav-rel { display: none; }
    .pav-bars { gap: 4px; }
    .pav-bar { width: 18px; }
}
@media (prefers-reduced-motion: reduce) {
    .pav-bar i, .pav-knob, .pav-knob::after { transition: none; }
}
.psp-h > .pav-ico { flex: none; }
@media (min-width: 641px) { .pav-times input[type="time"] { width: 132px; } }

/* ==========================================================================
   Pipeline Today view (js/pipeline_today.js) - day rail (tablet/desktop) and
   session cockpit (phones). Controls stay flat; cards keep --shadow-sm.
   ========================================================================== */
.ptd-wrap { display: flex; flex-direction: column; gap: 14px; padding: 2px 2px 16px; color: var(--text-primary); }

/* --- day header: date, metrics and the live/next reading in one card ------ */
.ptd-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-sm); }
.ptd-date { display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.15; }
.ptd-date > span { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.ptd-date b { font-family: 'Quicksand', sans-serif; font-size: 26px; font-weight: 700; }
.ptd-date b small { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.ptd-metrics { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.ptd-metrics b { font-family: 'Quicksand', sans-serif; font-size: 13px; color: var(--text-primary); }
.ptd-metrics small { font-size: 11px; color: var(--text-muted); }
.ptd-now { display: flex; align-items: center; gap: 12px; flex: 1 1 300px; min-width: 0; padding: 10px 12px; border-radius: 14px; background: var(--primary-light); box-shadow: inset 3px 0 0 transparent; }
.ptd-now.live { background: var(--secondary-light); box-shadow: inset 3px 0 0 var(--secondary-color); }
.ptd-now.done, .ptd-now.empty { background: var(--ocean-light); }
.ptd-nowico { flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--bg-card); color: var(--primary-dark); }
.ptd-now.live .ptd-nowico { color: var(--secondary-dark); }
.ptd-now.done .ptd-nowico, .ptd-now.empty .ptd-nowico { color: var(--ocean-dark, var(--primary-dark)); }
.ptd-nowtxt { flex: 1 1 0; min-width: 0; }
.ptd-now strong { display: block; font-family: 'Quicksand', sans-serif; font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
.ptd-now p { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); }
.ptd-now p b { color: var(--text-primary); }
.ptd-bar { height: 5px; margin-top: 8px; border-radius: 999px; background: rgba(120, 130, 120, 0.18); overflow: hidden; }
.ptd-bar i { display: block; height: 100%; border-radius: 999px; background: var(--secondary-color); }
.ptd-now .ptd-acts { margin-left: auto; display: none; }
.ptd-now .ptd-acts .ptd-act { background: var(--bg-card); border-color: transparent; }

/* --- the day, to scale (horizontal strip) --------------------------------- */
.ptd-strip { padding: 12px 14px 10px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-sm); }
.ptd-strip-h { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.ptd-strip-h h3 { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.ptd-strip-h span { margin-left: auto; font-size: 11.5px; color: var(--text-secondary); }
.ptd-track { position: relative; height: 64px; border-radius: 10px; background: var(--bg-body); }
.ptd-off { position: absolute; top: 0; bottom: 0; background: rgba(120, 130, 120, 0.12); pointer-events: none; }
.ptd-block { position: absolute; top: 0; bottom: 0; display: flex; align-items: flex-end; padding: 4px 6px; border-left: 1px dashed var(--secondary-color); border-right: 1px dashed var(--secondary-color); background: var(--secondary-light); color: var(--secondary-dark); font-size: 10px; font-weight: 700; pointer-events: none; opacity: 0.7; overflow: hidden; }
.ptd-gap { position: absolute; top: 0; bottom: 0; display: flex; align-items: flex-end; padding: 0 5px 5px; color: var(--text-muted); font-size: 10px; font-weight: 700; pointer-events: none; overflow: hidden; white-space: nowrap; }
.ptd-gap::before { content: ""; position: absolute; left: 3px; right: 3px; top: 50%; height: 1px; background: currentColor; opacity: 0.3; }
.ptd-ev { position: absolute; display: flex; flex-direction: column; justify-content: center; gap: 0; padding: 3px 8px; border-radius: 8px; border: 1px solid var(--primary-color); border-left: 3px solid var(--primary-dark); background: var(--primary-light); color: var(--text-primary); text-align: left; overflow: hidden; box-shadow: none; z-index: 1; transition: background-color 0.15s ease, border-color 0.15s ease; }
.ptd-ev:hover { border-color: var(--primary-dark); }
.ptd-ev b { font-size: 11.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptd-ev span { font-size: 10px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ptd-ev.clash { border-color: var(--secondary-color); border-left-color: var(--secondary-dark); background: var(--secondary-light); }
.ptd-ev.live { background: var(--secondary-light); border-color: var(--secondary-color); border-left-color: var(--secondary-dark); }
.ptd-ev.done { opacity: 0.55; }
.ptd-nowmark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--secondary-color); z-index: 2; pointer-events: none; }
.ptd-nowmark::before { content: ""; position: absolute; left: -3px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--secondary-color); }
.ptd-ticks { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10px; font-weight: 700; color: var(--text-muted); }

/* --- columns: list + day rail --------------------------------------------- */
.ptd-cols { display: grid; grid-template-columns: minmax(0, 1fr) clamp(264px, 26vw, 316px); gap: 14px; align-items: start; }
.ptd-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.ptd-rail { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 12px; }
.ptd-pane { border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.ptd-pane > header { display: flex; align-items: center; gap: 7px; padding: 10px 13px; border-bottom: 1px solid var(--border-color); }
.ptd-pane > header h3 { margin: 0; font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.ptd-pane > header span { margin-left: auto; font-size: 11px; color: var(--text-secondary); }
.ptd-pane-body { padding: 12px 13px; }
.ptd-free { display: flex; flex-direction: column; gap: 2px; }
.ptd-free small { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.ptd-free b { font-family: 'Quicksand', sans-serif; font-size: 21px; line-height: 1.15; }
.ptd-fit { margin-top: 10px; padding: 9px 10px; border-radius: 10px; border: 1px dashed var(--ocean); background: var(--ocean-light); font-size: 12px; color: var(--text-secondary); }
.ptd-fit b { display: block; font-size: 12.5px; color: var(--ocean-dark); }
.ptd-fit button { width: 100%; margin-top: 8px; min-height: 34px; }
.ptd-fitbtn { width: 100%; margin-top: 10px; min-height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--btn-primary-border); background: var(--btn-primary-bg); color: var(--btn-primary-text); font-size: 12.5px; font-weight: 700; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.ptd-fitbtn:hover { background: var(--btn-primary-hover, var(--primary-dark)); }
.ptd-money { font-family: 'Quicksand', sans-serif; font-size: 21px; font-weight: 700; }
.ptd-pane-body > p { margin: 2px 0 0; font-size: 11.5px; color: var(--text-secondary); }
.ptd-who { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; }
.ptd-who span { color: var(--text-secondary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptd-who b { color: var(--secondary-dark); white-space: nowrap; }
.ptd-tm { display: flex; align-items: center; gap: 9px; padding: 8px 13px; border-top: 1px solid var(--border-color); font-size: 12.5px; width: 100%; text-align: left; background: transparent; border-left: 0; border-right: 0; border-bottom: 0; color: var(--text-primary); }
.ptd-pane > .ptd-tm:first-of-type { border-top: 0; }
.ptd-tm:hover { background: var(--primary-light); }
.ptd-tm .ptd-tm-t { flex: none; width: 58px; font-weight: 700; color: var(--primary-dark); font-size: 12px; white-space: nowrap; }
.ptd-tm div { min-width: 0; }
.ptd-tm b { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptd-tm small { font-size: 11px; color: var(--text-muted); }

/* --- chips (filters + jumps to requests/overdue) -------------------------- */
.ptd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ptd-chip { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 13px; font-weight: 700; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.ptd-chip:hover { background: var(--primary-light); border-color: var(--primary-color); }
.ptd-chip.warn { border-color: var(--secondary-color); color: var(--secondary-dark); }
.ptd-chip.sel { background: var(--btn-primary-bg); border-color: var(--btn-primary-border); color: var(--btn-primary-text); }
.ptd-ok { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 13px; font-weight: 600; color: var(--primary-dark); }

/* --- sections + reading rows ---------------------------------------------- */
.ptd-sec { min-width: 0; }
.ptd-attention { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; align-items: start; }
.ptd-sec h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.ptd-sec h3 span.ptd-n { padding: 1px 8px; border-radius: 999px; background: var(--secondary-color); color: #fff; letter-spacing: 0; }
.ptd-clear { margin-left: auto; min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-secondary); font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; box-shadow: none; }
.ptd-clear:hover { background: var(--primary-light); color: var(--primary-dark); }
.ptd-list { display: flex; flex-direction: column; gap: 9px; }
.ptd-hint { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }
.ptd-card { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-sm); cursor: pointer; transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease; }
.ptd-card:hover { border-color: var(--primary-color); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.ptd-card:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.ptd-card.live { box-shadow: inset 3px 0 0 var(--secondary-color), var(--shadow-sm); background: var(--secondary-light); }
.ptd-card.clash { border-color: var(--secondary-color); }
.ptd-card.done { opacity: 0.62; }
.ptd-time { flex: none; width: 76px; display: flex; flex-direction: column; text-align: left; }
.ptd-time b { font-size: 13px; color: var(--primary-dark); }
.ptd-time span { font-size: 11px; color: var(--text-muted); }
.ptd-body { flex: 1 1 auto; min-width: 0; }
.ptd-body h4 { margin: 0; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptd-body p { margin: 1px 0 0; font-size: 12px; color: var(--text-secondary); }
.ptd-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ptd-tags:empty { display: none; }
.ptd-tag { padding: 2px 8px; border-radius: 999px; background: var(--primary-light); color: var(--primary-dark); font-size: 11px; font-weight: 700; }
.ptd-tag.warn, .ptd-tag.due, .ptd-tag.odd { background: var(--secondary-light); color: var(--secondary-dark); }
.ptd-tag.req { background: var(--sun-light, var(--primary-light)); color: var(--sun-dark, var(--primary-dark)); }
.ptd-acts { flex: none; display: flex; gap: 2px; }
.ptd-act { width: 40px; height: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-muted); box-shadow: none; transition: background-color 0.15s ease, color 0.15s ease; }
.ptd-act:hover { background: var(--primary-light); color: var(--primary-dark); }
.ptd-act.ok { color: var(--primary-dark); border-color: var(--primary-color); }

/* --- empty / peek --------------------------------------------------------- */
.ptd-peek { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--text-secondary); }
.ptd-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 28px 16px; border-radius: 14px; border: 1px dashed var(--border-strong); }
.ptd-empty > span { width: 56px; height: 56px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); }
.ptd-empty h3 { margin: 0; font-family: 'Quicksand', sans-serif; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text-primary); }
.ptd-empty p { margin: 0; font-size: 13px; color: var(--text-secondary); }

/* --- phone action sheet --------------------------------------------------- */
.ptd-sheet-body { gap: 8px; }
.ptd-sheet-row { min-height: 56px; display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); text-align: left; box-shadow: none; transition: background-color 0.15s ease, border-color 0.15s ease; }
.ptd-sheet-row:hover { background: var(--primary-light); border-color: var(--primary-color); }
.ptd-sheet-row > span { flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--primary-light); color: var(--primary-dark); }
.ptd-sheet-row.ok { border-color: var(--primary-color); }
.ptd-sheet-row b { display: block; font-size: 14px; }
.ptd-sheet-row small { font-size: 12px; color: var(--text-secondary); }
html.dark .ptd-chip:hover, html.dark .ptd-act:hover, html.dark .ptd-sheet-row:hover, html.dark .ptd-tm:hover { background: rgba(151, 184, 129, 0.16); }
html.dark .ptd-off { background: rgba(255, 255, 255, 0.05); }
html.dark .ptd-bar { background: rgba(255, 255, 255, 0.12); }

/* --- responsive: rail drops under the list, phones get the cockpit -------- */
@media (max-width: 1100px) {
    .ptd-ev span { display: none; }
}
@media (max-width: 860px) {
    .ptd-cols { grid-template-columns: minmax(0, 1fr); }
    .ptd-rail { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .ptd-pane.next-free { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
    .ptd-wrap { gap: 12px; }
    .ptd-hero { padding: 14px; gap: 12px; }
    .ptd-date b { font-size: 22px; }
    .ptd-date > span { font-size: 10px; }
    .ptd-metrics { gap: 2px 10px; font-size: 11px; }
    .ptd-metrics b { font-size: 12px; }
    .ptd-now { flex-wrap: wrap; padding: 12px; }
    .ptd-now strong { font-size: 18px; }
    .ptd-now .ptd-acts { display: flex; width: 100%; margin-left: 0; justify-content: space-between; }
    .ptd-now .ptd-act { width: 44px; height: 44px; min-height: 44px; }
    .ptd-rail { display: none; }
    .ptd-strip { padding: 10px 12px 8px; }
    .ptd-strip-h { margin-bottom: 8px; }
    .ptd-strip-h h3 { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .ptd-strip-h span { display: none; }
    .ptd-track { height: 40px; }
    .ptd-ev { padding: 0; }
    .ptd-ev b, .ptd-ev span { display: none; }
    .ptd-gap { display: none; }
    .ptd-ticks { font-size: 9px; }
    .ptd-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
    .ptd-chips::-webkit-scrollbar { display: none; }
    .ptd-chip { flex: none; min-height: 40px; font-size: 12.5px; }
    .ptd-card .ptd-acts { display: none; }
    .ptd-time { width: 62px; }
    .ptd-sec h3 { margin-bottom: 6px; }
    /* cockpit order: attention before the agenda */
    .ptd-wrap > .ptd-attention { order: 4; }
    .ptd-wrap > .ptd-cols { order: 5; }
    .ptd-wrap > .ptd-peek { order: 6; }
}
@media (prefers-reduced-motion: reduce) { .ptd-card, .ptd-card:hover { transition: none; transform: none; } }
.psp-sug small, .psp-slot small { display: block; font-size: 10px; font-weight: 600; color: var(--text-muted); line-height: 1.1; }
.psp-slot.odd, .psp-sug.odd { border-style: dashed; }
.psp-slot.odd small, .psp-sug.odd small { color: var(--secondary-dark); }
.psp-tz { display: flex; gap: 8px; margin-top: 4px; }
.psp-tz select, .psp-tz input { flex: 1 1 auto; min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 14px; }

/* Availability modal - Booking tab */
.pav-live { width: 8px; height: 8px; border-radius: 50%; background: var(--primary-dark); }
.pav-bk-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg-card); box-shadow: var(--shadow-sm); }
.pav-bk-top > div { display: flex; flex-direction: column; min-width: 0; }
.pav-bk-top b { font-size: 15px; }
.pav-bk-top span { font-size: 12px; color: var(--text-secondary); }
.pav-link { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pav-link input { flex: 1 1 100%; min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-primary); font-size: 13px; }
.pav-link .pav-chip { display: inline-flex; align-items: center; gap: 6px; }
.pav-notes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-secondary); }
@media (max-width: 420px) { .pav-tab { padding: 0 6px; font-size: 12px; gap: 4px; } }

/* Dark mode: style_essence.css paints inputs with a light gradient (!important); the app's generic html.dark rule only sets the colour. Inside the Availability / picker / Today modals use the dark input token and drop the gradient. */
html.dark .psp input:not([type="checkbox"]):not([type="radio"]),
html.dark .psp select,
html.dark .psp textarea { background: var(--dark-input, #171a1c) !important; color: var(--dark-text, #f2f4ef) !important; border-color: var(--dark-border, #3a4048) !important; color-scheme: dark; }

/* ==========================================================================
   Reading Pipeline — card right-click menu (Smart)
   Flat 2.0: solid surfaces, border + colour feedback only, no transforms,
   no gradients. Surfaces use the shared tokens so dark mode comes for free.
   ========================================================================== */
.pcm { position: fixed; z-index: 210; min-width: 252px; max-width: 292px; padding: 6px;
       border-radius: 16px; background: var(--bg-card); color: var(--text-primary);
       border: 1px solid var(--border-strong); box-shadow: var(--shadow-xl);
       max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
.pcm-head { display: flex; align-items: center; gap: 9px; padding: 7px 8px 9px; }
.pcm-av { width: 30px; height: 30px; border-radius: 9px; flex: none; display: flex; align-items: center;
          justify-content: center; font-size: 10.5px; font-weight: 700; background: var(--primary-light);
          color: var(--primary-dark); border: 1px solid var(--primary-color); }
.pcm-id { min-width: 0; }
.pcm-name { font-size: 12.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcm-meta { margin-top: 1px; font-size: 10px; color: var(--text-muted); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcm-group { padding: 7px 9px 4px; font-size: 9px; font-weight: 800; letter-spacing: .13em;
             text-transform: uppercase; color: var(--text-muted); }
.pcm-item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 6px 9px;
            border-radius: 9px; border: 1px solid transparent; background: none; color: var(--text-secondary);
            font-family: inherit; font-size: 12px; font-weight: 500; text-align: left; cursor: pointer;
            box-shadow: none; transition: background-color .12s ease, color .12s ease, border-color .12s ease; }
.pcm-item:hover, .pcm-item:focus-visible { background: var(--primary-50); color: var(--text-primary); outline: none; }
.pcm-item svg { width: 15px; height: 15px; flex: none; color: var(--text-muted); }
.pcm-item:hover svg { color: var(--text-secondary); }
.pcm-item.is-primary { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-dark); font-weight: 700; }
.pcm-item.is-primary svg { color: var(--primary-dark); }
.pcm-item.is-primary:hover { border-color: var(--primary-dark); }
.pcm-item.is-danger { color: var(--secondary-dark); }
.pcm-item.is-danger svg { color: var(--secondary-dark); }
.pcm-item.is-danger:hover { background: var(--secondary-light); }
.pcm-item[disabled] { opacity: .5; cursor: default; background: none; }
.pcm-item .pcm-kbd { margin-left: auto; font-size: 9px; color: var(--text-muted); }
.pcm-item .pcm-chev { margin-left: auto; color: var(--text-muted); opacity: .7; }
.pcm-sep { height: 1px; margin: 5px 7px; background: var(--border-strong); opacity: .6; }
.pcm-row { position: relative; }
.pcm-sub { position: fixed; z-index: 211; min-width: 186px; padding: 5px; border-radius: 12px;
           background: var(--bg-card); border: 1px solid var(--border-strong); box-shadow: var(--shadow-xl); }
.pcm-sub .pcm-item { min-height: 34px; font-size: 11.5px; }
.pcm-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.pcm-dot-inquiry { background: #818cf8; }
.pcm-dot-scheduled { background: #38bdf8; }
.pcm-dot-progress { background: #fbbf24; }
.pcm-dot-completed { background: #34d399; }
@media (max-width: 767px) { .pcm { min-width: min(280px, calc(100vw - 16px)); } }
/* ============================================================
   HC — Client Records badge system + row redesign
   Tier 1: alerts (max 2 + overflow chip) · Tier 2: numerology
   traits as captions under the number they qualify · Tier 3:
   relationship chips. Flat 2.0: chips carry no shadow and no
   transform; hover feedback is colour-only.
   ============================================================ */
:root {
    --hc-coral-bg:#fdefea; --hc-coral-bd:#f6cfc3; --hc-coral-fg:#bf5338;
    --hc-sun-bg:#fbf4de;   --hc-sun-bd:#efe0b2;   --hc-sun-fg:#94701f;
    --hc-ocean-bg:#eaf3f7; --hc-ocean-bd:#cfe2ea; --hc-ocean-fg:#3f7086;
    --hc-clay-bg:#fbf0e8;  --hc-clay-bd:#f0dac7;  --hc-clay-fg:#a2653f;
    --hc-sage-bg:#eff5ea;  --hc-sage-bd:#d6e4cb;  --hc-sage-fg:#577a45;
    --hc-lav-bg:#f4eff9;   --hc-lav-bd:#e2d7ee;   --hc-lav-fg:#7b5fa0;
    --hc-slate-bg:#f1f4f7; --hc-slate-bd:#dde4eb; --hc-slate-fg:#5d7083;
    --hc-grey-bg:#f4f4f2;  --hc-grey-bd:#e4e3df;  --hc-grey-fg:#6b7280;
    --hc-num-b:#2f6fb2; --hc-num-p:#577a45; --hc-num-d:#7b5fa0;
    --hc-karmic-fg:#a2653f;
}
html.dark {
    --hc-coral-bg:#33201b; --hc-coral-bd:#4e2e26; --hc-coral-fg:#f0a48c;
    --hc-sun-bg:#2b2415;   --hc-sun-bd:#4a3d1e;   --hc-sun-fg:#e8c97a;
    --hc-ocean-bg:#152630; --hc-ocean-bd:#28414f; --hc-ocean-fg:#9ecbdd;
    --hc-clay-bg:#2c211a;  --hc-clay-bd:#4b3427;  --hc-clay-fg:#edb08c;
    --hc-sage-bg:#1c2a22;  --hc-sage-bd:#2f4636;  --hc-sage-fg:#a9c795;
    --hc-lav-bg:#241e2e;   --hc-lav-bd:#3b3149;   --hc-lav-fg:#c5b2e0;
    --hc-slate-bg:#1e2833; --hc-slate-bd:#33404e; --hc-slate-fg:#a0b2c2;
    --hc-grey-bg:#1e242c;  --hc-grey-bd:#333a44;  --hc-grey-fg:#9aa5b4;
    --hc-num-b:#8fb7e8; --hc-num-p:#aecb98; --hc-num-d:#c3aee4;
    --hc-karmic-fg:#edb08c;
}

/* --- chips --- */
.hc-chips { display:flex; align-items:center; gap:.25rem; min-width:0; flex-shrink:0; }
.hc-chip {
    display:inline-flex; align-items:center; justify-content:center; gap:.2rem;
    height:1.25rem; padding:0 .4rem; border-radius:999px; border:1px solid transparent;
    font-size:.625rem; line-height:1; font-weight:700; letter-spacing:.035em;
    text-transform:uppercase; white-space:nowrap; box-sizing:border-box; flex-shrink:0;
    font-family:inherit; text-decoration:none;
}
.hc-chip i, .hc-chip svg { width:.6875rem; height:.6875rem; flex-shrink:0; }
.hc-chip--extra { display:none; }
.hc-chips.is-open .hc-chip--extra { display:inline-flex; }
.hc-chip--more {
    background:var(--hc-grey-bg); border-color:var(--hc-grey-bd); color:var(--hc-grey-fg);
    cursor:pointer; padding:0 .3rem; font-variant-numeric:tabular-nums; box-shadow:none; transform:none;
}
.hc-chip--more:hover { background:var(--bg-card); color:var(--text-secondary); border-color:var(--border-strong); }
.hc-chip--more:focus-visible { outline:2px solid var(--primary-color); outline-offset:2px; }
.hc-t-coral { background:var(--hc-coral-bg); border-color:var(--hc-coral-bd); color:var(--hc-coral-fg); }
.hc-t-sun   { background:var(--hc-sun-bg);   border-color:var(--hc-sun-bd);   color:var(--hc-sun-fg); }
.hc-t-ocean { background:var(--hc-ocean-bg); border-color:var(--hc-ocean-bd); color:var(--hc-ocean-fg); }
.hc-t-clay  { background:var(--hc-clay-bg);  border-color:var(--hc-clay-bd);  color:var(--hc-clay-fg); }
.hc-t-sage  { background:var(--hc-sage-bg);  border-color:var(--hc-sage-bd);  color:var(--hc-sage-fg); }
.hc-t-lav   { background:var(--hc-lav-bg);   border-color:var(--hc-lav-bd);   color:var(--hc-lav-fg); }
.hc-t-slate { background:var(--hc-slate-bg); border-color:var(--hc-slate-bd); color:var(--hc-slate-fg); }
.hc-t-grey  { background:var(--hc-grey-bg);  border-color:var(--hc-grey-bd);  color:var(--hc-grey-fg); }

/* --- row state --- */
#historyTable tbody tr.hc-row--pinned { box-shadow:inset 2px 0 0 var(--primary-color); }
#historyTable tbody tr.hc-row--active {
    background-color:var(--history-active-row-bg) !important;
    box-shadow:inset 3px 0 0 var(--secondary-color);
}
#historyTable tbody tr.hc-row--muted { opacity:.62; }
#historyTable tbody tr.hc-row--muted:hover { opacity:.92; }

/* --- client cell --- */
#historyTable td.hc-client-cell { padding:.5rem .625rem; }
#historyTable td.hc-serial {
    font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size:.6875rem; font-weight:700; text-align:center; color:var(--history-table-text-muted);
}
#historyTable td.hc-dob { color:var(--history-table-text-secondary); }
#historyTable td.hc-num-cell { text-align:center; padding:.4rem .5rem; }
#historyTable td.hc-rd-cell { text-align:right; padding:.4rem .75rem; }

.hc-cl { display:flex; align-items:center; gap:.5rem; min-width:0; }
.hc-cl-body { min-width:0; flex:1; }
#historyTable .hc-av, .hc-card .hc-av {
    width:1.75rem; height:1.75rem; font-size:.625rem; border-radius:.55rem;
    flex-shrink:0; position:relative;
}
.hc-card .hc-av { width:2.25rem; height:2.25rem; font-size:.7rem; border-radius:.7rem; }
.hc-av-pin {
    position:absolute; top:-4px; right:-4px; width:13px; height:13px; border-radius:50%;
    background:var(--bg-card); border:1px solid var(--border-color);
    display:grid; place-items:center; color:var(--primary-dark);
}
.hc-av-pin i, .hc-av-pin svg { width:7px; height:7px; }

.hc-l1 { display:flex; align-items:center; gap:.3rem; flex-wrap:wrap; min-width:0; }
.hc-name {
    font-weight:700; font-size:.8125rem; line-height:1.25; color:var(--history-table-text);
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; min-width:0;
}
@media (min-width:768px) { #historyTable .hc-name { max-width:14rem; } }
.hc-pencil { color:var(--secondary-dark); display:inline-flex; opacity:.85; flex-shrink:0; }
.hc-pencil i, .hc-pencil svg { width:10px; height:10px; }
.hc-l2 { display:flex; align-items:center; gap:.35rem; margin-top:.15rem; min-width:0; flex-wrap:wrap; }
.hc-meta {
    font-family:ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size:.6875rem; line-height:1.2; color:var(--history-table-text-muted);
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.hc-sep { color:var(--border-strong); font-size:.6875rem; }
.hc-rel {
    display:inline-flex; align-items:center; gap:.15rem; padding:0; border:0; background:none;
    font-size:.625rem; font-weight:600; color:var(--primary-dark); white-space:nowrap;
    cursor:pointer; border-radius:.25rem;
}
.hc-rel:hover { color:var(--primary-color); text-decoration:underline; }
.hc-rel:focus-visible { outline:2px solid var(--primary-color); outline-offset:2px; }
.hc-rel i, .hc-rel svg { width:.625rem; height:.625rem; }
.hc-tag {
    font-size:.5625rem; font-weight:700; letter-spacing:.03em; text-transform:uppercase;
    color:var(--history-table-text-muted); background:var(--hc-grey-bg);
    border:1px solid var(--hc-grey-bd); border-radius:.3rem; padding:.05rem .25rem; white-space:nowrap;
}

/* --- numbers + trait captions --- */
.hc-num {
    font-family:'Quicksand', sans-serif; font-weight:700; font-size:.95rem; line-height:1;
    display:inline-block;
}
.hc-num--b { color:var(--hc-num-b); }
.hc-num--p { color:var(--hc-num-p); }
.hc-num--d { color:var(--hc-num-d); }
.hc-num--master {
    background:var(--hc-lav-bg); border:1px solid var(--hc-lav-bd); color:var(--hc-lav-fg);
    border-radius:.4rem; padding:.1rem .28rem;
}
.hc-cap {
    display:block; margin-top:.12rem; font-size:.5rem; font-weight:700;
    letter-spacing:.06em; text-transform:uppercase; line-height:1;
}
.hc-cap--karmic { color:var(--hc-karmic-fg); }
.hc-cap--master { color:var(--hc-lav-fg); }
.hc-cap--match  { color:var(--history-table-text-muted); }

/* --- readings column --- */
.hc-rd {
    display:inline-flex; align-items:center; justify-content:flex-end; gap:.2rem;
    color:var(--history-table-text-secondary);
}
.hc-rd b { font-family:'Quicksand', sans-serif; font-size:.8125rem; line-height:1; }
.hc-rd i, .hc-rd svg { width:.625rem; height:.625rem; color:var(--history-table-text-muted); }
.hc-rd-time { display:block; font-size:.5625rem; color:var(--history-table-text-muted); margin-top:.1rem; }

/* --- action rail: quiet until the row is touched --- */
#historyTable tbody tr .history-action-rail-desktop { opacity:.55; transition:opacity .15s ease; }
#historyTable tbody tr:hover .history-action-rail-desktop,
#historyTable tbody tr.hc-row--active .history-action-rail-desktop,
#historyTable tbody tr:focus-within .history-action-rail-desktop { opacity:1; }

/* --- mobile trio (B · P · D) --- */
.hc-trio { display:flex; align-items:center; gap:.25rem; flex-shrink:0; margin-left:auto; }
.hc-pill {
    display:inline-flex; align-items:baseline; gap:.18rem; padding:.2rem .35rem;
    border-radius:.45rem; border:1px solid transparent;
    font-family:'Quicksand', sans-serif; font-weight:700; font-size:.75rem; line-height:1;
}
.hc-pill b {
    font-family:'Poppins', sans-serif; font-weight:800; font-size:.5rem;
    letter-spacing:.06em; text-transform:uppercase; opacity:.72;
}
.hc-pill--b { background:var(--hc-ocean-bg); border-color:var(--hc-ocean-bd); color:var(--hc-num-b); }
.hc-pill--l { background:var(--hc-sage-bg);  border-color:var(--hc-sage-bd);  color:var(--hc-num-p); }
.hc-pill--d { background:var(--hc-lav-bg);   border-color:var(--hc-lav-bd);   color:var(--hc-num-d); }
.hc-pill--master { box-shadow:inset 0 0 0 2px var(--hc-lav-bd); }

/* --- compact density --- */
#historyTable.history-density-compact td { padding-top:.2rem; padding-bottom:.2rem; }
#historyTable.history-density-compact .hc-l2 { display:none; }
#historyTable.history-density-compact .hc-chip { width:1.25rem; padding:0; }
#historyTable.history-density-compact .hc-chip span { display:none; }
#historyTable.history-density-compact .hc-chip--more { width:auto; padding:0 .25rem; }
#historyTable.history-density-compact .hc-chip--more span { display:inline; }
#historyTable.history-density-compact .hc-num { font-size:.85rem; }
#historyTable.history-density-compact .hc-cap { display:none; }

/* --- card view --- */
.hc-card { padding:.7rem .75rem; }
.hc-card .hc-name { font-size:.875rem; }
.hc-card--pinned { box-shadow:inset 2px 0 0 var(--primary-color), var(--shadow-sm); }
.hc-card--muted { opacity:.62; }
.hc-card-foot { gap:.375rem; flex-wrap:wrap; row-gap:.375rem; }
.hc-card-extra {
    display:flex; align-items:center; gap:.5rem;
    font-size:.625rem; color:var(--history-table-text-muted);
}
.hc-card-extra span { display:inline-flex; align-items:center; gap:.15rem; }
.hc-card-extra i, .hc-card-extra svg { width:.5625rem; height:.5625rem; }
.hc-card-actions { margin-left:auto; display:flex; align-items:center; gap:.2rem; }

@media (max-width:767px) {
    #historyTable td.hc-client-cell { padding:.55rem .6rem; }
    #historyTable .hc-name { max-width:11.5rem; }
    #historyTable .hc-l1 { gap:.25rem; }
    #historyTable .hc-meta { font-size:.65rem; }
}
@media (max-width:400px) { .hc-card-extra { display:none; } }

/* --- badge sheet (touch replacement for hover tooltips) --- */
#historyBadgeSheet { position:fixed; inset:0; z-index:210; display:flex; align-items:flex-end; }
#historyBadgeSheet.hidden { display:none; }
.hc-sheet-scrim { position:absolute; inset:0; background:rgba(15,23,32,.45); }
body.hc-sheet-open { overflow:hidden; }
.hc-sheet {
    position:relative; width:100%; max-height:80vh; overflow-y:auto;
    background:var(--bg-card); border-radius:1.25rem 1.25rem 0 0;
    padding:.5rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    box-shadow:0 -18px 50px -22px rgba(15,23,32,.55);
    animation:hcSheetIn .22s ease;
}
@keyframes hcSheetIn { from { transform:translateY(14px); opacity:.6; } to { transform:none; opacity:1; } }
.hc-sheet-grab { width:2.25rem; height:4px; border-radius:99px; background:var(--border-strong); margin:.15rem auto .65rem; }
.hc-sheet-head { display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
.hc-sheet-head h3 { font-family:'Quicksand', sans-serif; font-size:1rem; font-weight:700; color:var(--text-primary); }
.hc-sheet-close {
    width:2.25rem; height:2.25rem; border-radius:50%; display:grid; place-items:center;
    color:var(--text-secondary); background:var(--bg-body);
}
.hc-sheet-close i, .hc-sheet-close svg { width:1rem; height:1rem; }
.hc-sheet-who { font-size:.6875rem; color:var(--text-muted); margin:.15rem 0 .5rem; }
.hc-sheet-row {
    display:flex; align-items:center; gap:.65rem; padding:.6rem 0;
    border-bottom:1px solid var(--border-color); min-height:52px;
}
.hc-sheet-row:last-child { border-bottom:0; }
.hc-sheet-tile {
    width:2rem; height:2rem; border-radius:.65rem; display:grid; place-items:center;
    border:1px solid transparent; flex-shrink:0;
}
.hc-sheet-tile i, .hc-sheet-tile svg { width:.875rem; height:.875rem; }
.hc-sheet-txt { display:flex; flex-direction:column; min-width:0; flex:1; }
.hc-sheet-t1 { font-size:.75rem; font-weight:700; color:var(--text-primary); line-height:1.3; }
.hc-sheet-t2 { font-size:.6875rem; color:var(--text-muted); line-height:1.35; }
.hc-sheet-go {
    width:2.75rem; height:2.75rem; border-radius:.75rem; display:grid; place-items:center;
    color:var(--text-muted); flex-shrink:0;
}
.hc-sheet-go i, .hc-sheet-go svg { width:1rem; height:1rem; }
/* --- responsive helpers owned by the history module (avoid missing
       Tailwind variants such as lg:table-cell in the precompiled sheet) --- */
.hc-col-readings { display:none; }
@media (min-width:1200px) { #historyTable .hc-col-readings { display:table-cell; } }
.hc-desk-inline { display:none; }
@media (min-width:1200px) { .hc-desk-inline { display:inline; } }
.hc-desk-tag { display:none; }
@media (min-width:768px) { .hc-desk-tag { display:inline-block; } }
/* --- narrow-screen layout guards --- */
.hc-card-actions { flex-shrink:0; }
.hc-card-extra { flex-shrink:0; }
@media (max-width:480px) { .hc-card-extra { display:none; } }
@media (max-width:767px) {
    #historyTable .hc-cl { flex-wrap:wrap; row-gap:.35rem; }
    #historyTable .hc-cl-body { flex:1 1 8rem; }
}
/* --- keep the table narrow enough for 768–1023 (chips may wrap there) --- */
.hc-chips { flex-wrap:wrap; flex-shrink:1; }
.hc-name { min-width:0; }
@media (min-width:768px) and (max-width:1279px) {
    #historyTable .hc-name { max-width:9rem; }
    #historyTable td.hc-client-cell { padding:.45rem .5rem; }
    #historyTable th, #historyTable td { padding-left:.4rem; padding-right:.4rem; }
}
/* --- tablet: DOB folds into the meta line, table keeps its columns --- */
.hc-col-dob { display:none; }
@media (min-width:1200px) { #historyTable .hc-col-dob { display:table-cell; } }
.hc-meta-compact { display:inline; }
@media (min-width:1200px) { .hc-meta-compact { display:none; } }
@media (min-width:768px) and (max-width:1023px) {
    #historyTable td.hc-client-cell { padding:.45rem .4rem; }
    #historyTable .hc-name { max-width:9.5rem; }
}
/* --- breakpoint matrix: numbers are columns on desktop, a trio below --- */
.hc-col-nums { display:none; }
@media (min-width:1200px) { #historyTable .hc-col-nums { display:table-cell; } }
@media (max-width:1199px) { #historyTable .hc-trio { display:flex; } }
@media (min-width:1200px) { #historyTable .hc-trio { display:none; } }
@media (min-width:1200px) { .hc-desk-inline { display:inline; } }
/* Tablet band (768–1024) showed BOTH action rails: the desktop inline rail and
   the mobile grid. Keep one — the desktop rail — so the table fits again. */
@media (min-width:768px) {
    #historyTable tbody td:last-child > .history-action-rail-mobile { display:none; }
}
/* The history flex item defaulted to min-width:auto, so a wide row forced the
   whole column (and the page) wider instead of the table fitting its box. */
#historyContainer { min-width:0; }
#historyScrollContainer { min-width:0; }
/* The shared cell rule is white-space:nowrap; the client cell must wrap so its
   min-content stops widening the whole table. */
#historyTable td.hc-client-cell { white-space:normal; }
/* Let a too-wide table scroll inside its own card instead of clipping the
   action column (tablet band) or widening the page. */
#historyScrollContainer { overflow-x:auto; }
.hc-sheet-close { font-size:1.5rem; line-height:1; font-weight:400; }
/* --- 768-1199 band: the app forces #historyTable min-width:58rem (928px),
   which produced a hard-to-use horizontal scrollbar on tablets. The compact
   table (name + B/P/D trio + actions) fits, so drop the floor until the
   full 8-column table takes over at 1200px. --- */
@media (max-width:1199px) {
    #historyTable { min-width:0 !important; }
    #historyScrollContainer { overflow-x:hidden; }
}
/* The mobile block layout sets `#historyTable td{display:block}`; class-level
   display:none loses to it, so hidden columns still became flex items and ate
   the row gap above the client name. Hide them at ID strength instead. */
@media (max-width:1199px) {
    #historyTable .hc-col-dob,
    #historyTable .hc-col-nums,
    #historyTable .hc-col-readings { display:none; }
}
@media (max-width:767px) {
    #historyTable .hc-serial { display:none; }
}
/* --- name line: name (left) + B/L/D trio (right) on one line; alert
   chips drop to their own line when they do not fit --- */
.hc-name-wrap { display:flex; align-items:center; gap:.2rem; min-width:0; flex:0 1 auto; max-width:100%; }
/* tablet: name + chips + trio on one line, trio flush right */
@media (min-width:768px) and (max-width:1199px) {
    .hc-name-wrap { order:1; }
    .hc-chips { order:2; }
    .hc-trio { order:3; }
    #historyTable .hc-cl-body, .hc-card .hc-cl-body { min-width:0; }
}
/* phone: name + B/L/D trio share the first line (trio flush right);
   alert chips drop to their own line and can never squeeze the name */
@media (max-width:767px) {
    .hc-l1 { display:grid; grid-template-columns:minmax(0,1fr) auto; column-gap:.4rem; row-gap:.3rem; align-items:center; }
    .hc-name-wrap { grid-column:1; grid-row:1; min-width:0; overflow:hidden; }
    .hc-trio { grid-column:2; grid-row:1; margin-left:0; }
    .hc-chips { grid-column:1 / -1; grid-row:2; justify-self:start; }
    #historyTable .hc-cl-body, .hc-card .hc-cl-body { min-width:0; }
}
/* --- tighter spacing between the Client Records title block and the
   search/filter bar (header mb-4 + bar py-2 = 24px before) --- */
#view-history > .section-page-header { margin-bottom: .25rem; }
/* ==========================================================================
   EMAILS WORKSPACE — section tabs (Campaign first)
   Flat 2.0: solid surfaces, colour-only hover, no shadow / transform.
   ========================================================================== */
.em-tabbar {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border-strong);
    margin-bottom: 1.25rem;
}
.em-tabbar::-webkit-scrollbar { display: none; }
.em-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex: none;
    min-height: 2.5rem;
    padding: 0.55rem 0.8rem;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0.45rem 0.45rem 0 0;
    box-shadow: none;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.em-tab:hover { color: var(--text-primary); background: var(--primary-50); }
.em-tab:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.em-tab.is-active { color: var(--primary-dark); border-bottom-color: var(--primary-color); }
.em-tab > svg, .em-tab > i { width: 0.95rem; height: 0.95rem; flex: none; }
.em-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.3rem;
    margin-left: 0.15rem;
    border-radius: 999px;
    background: var(--primary-100);
    color: var(--primary-dark);
    font-size: 0.62rem;
    font-weight: 800;
}
.em-tab-badge.is-hot { background: rgba(232, 141, 120, 0.18); color: var(--secondary-dark); }
.em-panel[hidden] { display: none !important; }

/* Capacity strip: 1-4 SMTP accounts fill the row instead of leaving holes. */
.em-quota {
    /* One row, always: up to five sending accounts split the width evenly and
       never wrap (the strip is a status bar, not a card grid). */
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
@media (max-width: 640px) {
    /* Phones: two per row instead of five unreadable slivers. */
    .em-quota {
        grid-auto-flow: row;
        grid-auto-columns: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* The Emails workspace swaps whole panels (display:none <-> block) inside this
   scroll container. Chromium can leave that subtree unpainted after the swap
   while content-visibility:auto is on — a blank Emails section that hit-tests
   and lays out fine. Same opt-out as #view-synergy above. */
#view-email { content-visibility: visible !important; }

/* Composer header band. Token-based on purpose: bg-sage-light/60 is NOT in
   dark-mode.css's override list, so an opacity variant renders as a pale grey
   band with washed-out text in dark mode. */
.em-composer-head {
    background: var(--primary-50);
    border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   EMAILS — campaign composer fields
   Selects keep their native behaviour (keyboard, mobile pickers) but are
   restyled: solid surface, hairline border, leading icon, custom caret.
   Flat 2.0: no shadow, no transform, colour-only hover.
   ========================================================================== */
.em-field-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.em-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    min-height: 2.25rem;
    padding: 0.5rem 2.1rem 0.5rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.5rem;
    background-color: var(--bg-card);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    background-size: 0.75rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: none;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.em-select:hover { border-color: var(--primary-color); }
.em-select:focus,
.em-select:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
.em-select-lg { min-height: 2.6rem; font-size: 0.875rem; font-weight: 700; }

.em-period-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.25rem;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border-strong);
    border-radius: 0.5rem;
    background: var(--primary-50);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 700;
}

/* The app's legacy control rule (style_essence.css:10296) forces a gradient +
   inner shadow on every select/input with !important. The composer's fields are
   Flat 2.0 controls, so they opt out explicitly here (id-scoped + !important to
   win against that rule) and paint their own caret instead of overlaying one. */
#email-content .em-select {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 100%;
    min-height: 2.25rem;
    padding: 0.5rem 2.1rem 0.5rem 0.75rem !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 0.5rem !important;
    background-color: var(--bg-card) !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.65rem center !important;
    background-size: 0.75rem !important;
    box-shadow: none !important;
    color: var(--text-primary) !important;
    font-family: inherit !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease !important;
}
#email-content .em-select:hover { border-color: var(--primary-color) !important; }
#email-content .em-select:focus,
#email-content .em-select:focus-visible {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 1px !important;
    border-color: var(--primary-color) !important;
    box-shadow: none !important;
}
#email-content .em-select-lg { min-height: 2.6rem; font-size: 0.875rem !important; font-weight: 700 !important; }

/* Locked/unlocked toggle for the target period. */
#email-content .em-lock-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem !important;
    border: 1px solid var(--border-strong) !important;
    border-radius: 999px !important;
    background: var(--bg-card) !important;
    box-shadow: none !important;
    color: var(--text-muted) !important;
    font-family: inherit !important;
    font-size: 0.5625rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.6;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease !important;
}
#email-content .em-lock-btn svg { width: 0.7rem !important; height: 0.7rem !important; flex: none; }
#email-content .em-lock-btn:hover { background: var(--primary-50) !important; color: var(--primary-dark) !important; border-color: var(--primary-color) !important; }
#email-content .em-lock-btn[aria-pressed="false"] { background: var(--primary-100) !important; color: var(--primary-dark) !important; border-color: var(--primary-color) !important; }
#email-content .em-period-pill svg { width: 0.875rem !important; height: 0.875rem !important; }

/* ==========================================================================
   EMAILS — Campaign panel (composer + recipient list)
   Flat 2.0: solid surfaces, hairline borders, colour-only hover, no shadow /
   transform / gradient on any control. Hierarchy comes from type + spacing.
   Every rule is scoped to #email-content so it cannot leak into other views
   (the app's legacy control rule uses !important on bare select/input).
   ========================================================================== */

/* ---------- composer shell ---------- */
#email-content .em-composer {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
#email-content .em-composer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    background: var(--primary-50);
    border-bottom: 1px solid var(--border-color);
}
#email-content .em-composer-id { display: flex; align-items: flex-start; gap: 0.75rem; min-width: 0; }
#email-content .em-composer-badge {
    width: 2.35rem; height: 2.35rem; flex: none;
    display: grid; place-items: center;
    border-radius: 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--primary-100);
    color: var(--primary-dark);
}
#email-content .em-composer-badge svg { width: 1.05rem; height: 1.05rem; }
#email-content .em-eyebrow {
    font-size: 0.5625rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--text-muted); line-height: 1.4;
}
#email-content .em-title {
    margin: 0.05rem 0 0.1rem;
    font-family: 'Quicksand', system-ui, sans-serif;
    font-size: 1.0625rem; font-weight: 700; line-height: 1.25;
    color: var(--text-primary);
}
#email-content .em-title-sm {
    margin: 0;
    font-family: 'Quicksand', system-ui, sans-serif;
    font-size: 0.875rem; font-weight: 700; line-height: 1.3;
    color: var(--text-primary);
}
#email-content .em-sub {
    margin: 0;
    font-size: 0.6875rem; line-height: 1.5;
    color: var(--text-muted);
}

/* send summary: three quiet stats, label over value */
#email-content .em-stats { display: flex; align-items: stretch; gap: 0.5rem; flex-wrap: wrap; }
#email-content .em-stat {
    min-width: 3.6rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.55rem;
    background: var(--bg-card);
    text-align: center;
}
#email-content .em-stat-label {
    display: block; font-size: 0.5rem; font-weight: 800; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-muted); line-height: 1.6;
}
#email-content .em-stat-value {
    display: block; font-family: 'Quicksand', system-ui, sans-serif;
    font-size: 0.95rem; font-weight: 700; line-height: 1.2; color: var(--text-primary);
}
#email-content .em-stat--pending .em-stat-value { color: var(--primary-dark); }
#email-content .em-stat--sent .em-stat-value { color: var(--ocean-dark, #6D94A6); }
#email-content .em-stat--total { background: transparent; border-style: dashed; }

/* ---------- composer body ---------- */
#email-content .em-composer-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 15rem;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    align-items: start;
}
#email-content .em-field-row {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 0.75rem;
}
#email-content .em-fieldgroup { min-width: 0; }
#email-content .em-field-label {
    display: block; margin-bottom: 0.3rem;
    font-size: 0.5625rem; font-weight: 800; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-muted);
}
#email-content .em-field-head {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.3rem;
}
#email-content .em-field-head .em-field-label { margin-bottom: 0; }

/* field surface: the select inside is transparent, so the wrapper owns the
   look and the leading icon can be a background image (a native select paints
   over an absolutely-positioned icon, which is why the overlay approach failed) */
#email-content .em-field {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.6rem;
    background: var(--bg-card);
    background-repeat: no-repeat;
    background-position: left 0.8rem center;
    background-size: 0.95rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
#email-content .em-field:hover { border-color: var(--primary-color); }
#email-content .em-field:focus-within { border-color: var(--primary-color); outline: 2px solid var(--primary-color); outline-offset: 1px; }
#email-content .em-field--type,
#email-content .em-field--theme {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2397B881' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 11 18-5v12L3 14v-3z'/%3E%3Cpath d='M11.6 16.8a3 3 0 1 1-5.8-1.6'/%3E%3C/svg%3E");
}
#email-content .em-field--theme {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2397B881' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='13.5' cy='6.5' r='.5'/%3E%3Ccircle cx='17.5' cy='10.5' r='.5'/%3E%3Ccircle cx='8.5' cy='7.5' r='.5'/%3E%3Ccircle cx='6.5' cy='12.5' r='.5'/%3E%3Cpath d='M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z'/%3E%3C/svg%3E");
}
#email-content .em-field--plain { background-image: none; }
#email-content .em-field--search,
#email-content .em-field--filter,
#email-content .em-field--tag {
    background-image: none;
    min-height: 2.25rem;
}

/* the select itself: no chrome of its own, the field surface shows through */
#email-content .em-field .em-select {
    width: 100%;
    border: 0 !important;
    border-radius: inherit !important;
    background-color: transparent !important;
    background-position: right 0.65rem center !important;
    background-repeat: no-repeat !important;
    background-size: 0.75rem !important;
    min-height: 2.7rem;
    padding: 0.5rem 2rem 0.5rem 2.35rem !important;
    cursor: pointer;
    box-shadow: none !important;
}
#email-content .em-field .em-select:focus,
#email-content .em-field .em-select:focus-visible { outline: none !important; }
#email-content .em-field--plain .em-select { padding-left: 0.75rem !important; min-height: 2.7rem; }

/* search input inside a field */
#email-content .em-field input {
    width: 100%;
    border: 0 !important;
    border-radius: inherit !important;
    background: transparent !important;
    box-shadow: none !important;
    min-height: 2.2rem;
    padding: 0.35rem 0.7rem !important;
    font-family: inherit;
    font-size: 0.75rem;
    color: var(--text-primary);
}
#email-content .em-field input:focus { outline: none !important; }

/* toolbar fields are compact */
#email-content .em-field--sm .em-select { min-height: 2.2rem !important; font-size: 0.72rem !important; }
#email-content .em-field--filter .em-select,
#email-content .em-field--tag .em-select { padding-left: 0.7rem !important; }
#email-content .em-field--search { min-width: 11rem; }
#email-content .em-field--search input { padding-left: 0.7rem !important; }
#email-content .em-field--filter { min-width: 10.5rem; }
#email-content .em-field--tag { min-width: 8rem; }

/* locked target period */
#email-content .em-period-pill {
    display: flex; align-items: center; gap: 0.45rem;
    min-height: 2.75rem; padding: 0.5rem 0.8rem;
    border: 1px dashed var(--border-strong);
    border-radius: 0.6rem;
    background: var(--primary-50);
    color: var(--text-primary);
    font-family: 'Quicksand', system-ui, sans-serif;
    font-size: 0.875rem; font-weight: 700;
}
#email-content .em-period-pill svg { color: var(--primary-dark) !important; }
#email-content .em-period-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

/* ---------- actions ---------- */
#email-content .em-actions { display: flex; flex-direction: column; gap: 0.5rem; }
#email-content .em-btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
#email-content .em-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    min-height: 2.5rem; padding: 0.5rem 0.85rem;
    border: 1px solid transparent; border-radius: 0.6rem;
    background: none; box-shadow: none; transform: none;
    font-family: inherit; font-size: 0.75rem; font-weight: 700; line-height: 1.2;
    cursor: pointer; white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}
#email-content .em-btn:disabled { opacity: 0.45; cursor: not-allowed; }
#email-content .em-btn--lg { min-height: 2.9rem; font-size: 0.8125rem; }
#email-content .em-btn--sm { min-height: 2rem; padding: 0.3rem 0.65rem; font-size: 0.6875rem; }
#email-content .em-btn--primary { background-color: var(--primary-color); border-color: var(--primary-dark); color: #fff; }
#email-content .em-btn--primary:hover { background-color: var(--primary-dark); }
#email-content .em-btn--accent { background-color: var(--secondary-color); border-color: var(--secondary-dark); color: #fff; }
#email-content .em-btn--accent:hover { background-color: var(--secondary-dark); }
#email-content .em-btn--ghost { background-color: var(--bg-card); border-color: var(--border-strong); color: var(--text-secondary); }
#email-content .em-btn--ghost:hover { background-color: var(--primary-50); color: var(--primary-dark); border-color: var(--primary-color); }
#email-content .em-btn--danger { background-color: var(--bg-card); border-color: rgba(232, 141, 120, 0.45); color: var(--secondary-dark); }
#email-content .em-btn--danger:hover { background-color: var(--secondary-light); }

/* delay stepper */
#email-content .em-stepper {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    padding: 0.35rem 0.35rem 0.35rem 0.7rem;
    border: 1px solid var(--border-strong); border-radius: 0.6rem; background: var(--bg-card);
}
#email-content .em-stepper-label { font-size: 0.625rem; font-weight: 600; color: var(--text-muted); line-height: 1.3; }
#email-content .em-stepper-ctl { display: flex; align-items: center; gap: 0.15rem; }
#email-content .em-stepper-btn {
    width: 1.65rem; height: 1.65rem; flex: none;
    display: grid; place-items: center;
    border: 1px solid var(--border-strong); border-radius: 0.4rem;
    background: var(--bg-card); color: var(--text-secondary);
    font-family: inherit; font-size: 0.9rem; font-weight: 700; line-height: 1;
    cursor: pointer; box-shadow: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
#email-content .em-stepper-btn:hover { background: var(--primary-50); color: var(--primary-dark); border-color: var(--primary-color); }
#email-content .em-stepper-ctl input {
    width: 2.1rem; min-height: 0 !important;
    border: 0 !important; background: transparent !important; box-shadow: none !important;
    text-align: center; font-family: inherit; font-size: 0.8125rem; font-weight: 700; color: var(--text-primary);
    padding: 0 !important;
}
#email-content .em-stepper-ctl input:focus { outline: none !important; }
#email-content .em-stepper-ctl input::-webkit-outer-spin-button,
#email-content .em-stepper-ctl input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#email-content .em-stepper-unit { font-size: 0.625rem; color: var(--text-muted); margin-right: 0.15rem; }

/* composer footer: progress + result */
#email-content .em-composer-foot { padding: 0 1.25rem; }
#email-content .em-composer-foot:not(:empty) { padding-bottom: 1.1rem; }
#email-content .em-progress-head {
    display: flex; justify-content: space-between;
    font-size: 0.6875rem; color: var(--text-secondary); margin-bottom: 0.35rem;
}
#email-content .em-progress-track { height: 0.4rem; border-radius: 999px; background: var(--border-color); overflow: hidden; }
#email-content .em-progress-bar { height: 100%; border-radius: 999px; background: var(--primary-color); transition: width 0.2s ease; }
#email-content #em-result { border-radius: 0.6rem; padding: 0.65rem 0.8rem; font-size: 0.6875rem; }

/* ---------- recipient list ---------- */
#email-content .em-list-card {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 1rem;
    overflow: hidden;
}
#email-content .em-list-head {
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
#email-content .em-list-title { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
#email-content .em-list-badge {
    width: 1.9rem; height: 1.9rem; flex: none;
    display: grid; place-items: center; border-radius: 0.55rem;
    background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary-dark);
}
#email-content .em-list-badge svg { width: 0.95rem; height: 0.95rem; }
#email-content .em-toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

#email-content .em-bulkbar {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    margin: 0.75rem 1.25rem 0;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--primary-100);
    border-radius: 0.6rem;
    background: var(--primary-50);
}
#email-content .em-bulkbar-count { font-size: 0.6875rem; font-weight: 700; color: var(--primary-dark); }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
    #email-content .em-composer-body { grid-template-columns: minmax(0, 1fr); }
    #email-content .em-field-row { grid-template-columns: minmax(0, 1fr); }
    #email-content .em-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    #email-content .em-actions #em-send-btn { grid-column: 1 / -1; }
    #email-content .em-stepper { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    #email-content .em-actions { grid-template-columns: 1fr; }
    #email-content .em-btn-row { grid-template-columns: 1fr; }
    #email-content .em-toolbar { width: 100%; }
    #email-content .em-field--search,
    #email-content .em-field--filter,
    #email-content .em-field--tag { flex: 1 1 100%; min-width: 0; }
    #email-content .em-stats { width: 100%; }
    #email-content .em-stat { flex: 1; }
}

/* Panel rules above set display on elements that are also toggled with `.hidden`
   (the period edit block, the bulk bar, Pause/Stop, the month/year fields). Give
   the utility its usual meaning inside this view so a toggle can never be
   overridden by a more specific layout rule. */
#email-content .hidden { display: none !important; }

/* left column of the composer: fields on top, the send summary pinned to the
   bottom so the column does not leave a hole beside the taller action stack */
#email-content .em-composer-fields {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
}
#email-content .em-note {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin: auto 0 0;
    padding: 0.55rem 0.7rem;
    border: 1px dashed var(--border-color);
    border-radius: 0.55rem;
    background: var(--primary-50);
    font-size: 0.6875rem;
    line-height: 1.45;
    color: var(--text-muted);
}
#email-content .em-note svg { flex: none; margin-top: 0.1rem; color: var(--primary-dark) !important; }
@media (max-width: 1023px) {
    #email-content .em-note { margin-top: 0; }
}

/* Mobile: the recipient table scrolls sideways instead of crushing the DOB into
   three lines. The wrapper already has overflow-x-auto. */
@media (max-width: 767px) {
    #email-content .em-list-card table th,
    #email-content .em-list-card table td { white-space: nowrap; }
}
