:root {
    /* Typographic Family Tokens */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

    /* Consolidated 5-Tier Font Scale */
    --font-size-sm: calc(12px * var(--text-scale, 1));
    --font-size-base: calc(14px * var(--text-scale, 1));
    --font-size-md: calc(16px * var(--text-scale, 1));
    --font-size-lg: calc(20px * var(--text-scale, 1));
    --font-size-hero: calc(36px * var(--text-scale, 1));

    /* Font Weights */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
}

:root[data-theme="dark"] {
    --bg-color: #0f172a;
    --bg-gradient: radial-gradient(circle at top right, #1e1b4b 0%, #0f172a 60%, #090d16 100%);
    --text-color: #f8fafc;
    --panel-bg: rgba(30, 41, 59, 0.4);
    --panel-bg-start: rgba(30, 41, 59, 0.6);
    --panel-bg-end: rgba(15, 23, 42, 0.3);
    --border-color: rgba(255, 255, 255, 0.08);
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --glass-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.05);
    --glass-shadow-hover: 0 35px 60px -15px rgba(0, 0, 0, 0.7), inset 0 1px 1.5px rgba(255, 255, 255, 0.1);
    --glass-shadow-bubble: 0 4px 15px rgba(0, 0, 0, 0.2), inset 0 1px 0.5px rgba(255, 255, 255, 0.05);
    --subgoal-pending: #eab308;
    --subgoal-expired: #f43f5e;
    --task-input-bg: rgba(0, 0, 0, 0.25);
    --task-input-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    --task-grid-bg: rgba(255, 255, 255, 0.02);
    --task-priority-bg: transparent;
}

:root[data-theme="light"] {
    --bg-color: #f1f5f9;
    --bg-gradient: radial-gradient(circle at top left, #f8fafc 0%, #e2e8f0 100%);
    --text-color: #0f172a;
    --panel-bg: rgba(255, 255, 255, 0.6);
    --panel-bg-start: rgba(255, 255, 255, 0.7);
    --panel-bg-end: rgba(241, 245, 249, 0.4);
    --border-color: rgba(0, 0, 0, 0.08);
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --glass-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.08), inset 0 1px 1px rgba(255, 255, 255, 0.6);
    --glass-shadow-hover: 0 30px 60px -20px rgba(0, 0, 0, 0.12), inset 0 1px 2px rgba(255, 255, 255, 0.8);
    --glass-shadow-bubble: 0 4px 15px rgba(0, 0, 0, 0.04), inset 0 1px 0.5px rgba(255, 255, 255, 0.4);
    --subgoal-pending: #b45309;
    --subgoal-expired: #be123c;
    --task-input-bg: rgba(255, 255, 255, 0.95);
    --task-input-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
    --task-grid-bg: rgba(0, 0, 0, 0.02);
    --task-priority-bg: rgba(255, 255, 255, 0.7);
}

/* Prevent login page flicker and improve LCP/CLS when user session is being restored */
html.has-token #loginView {
    display: none !important;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    background: var(--bg-gradient);
    color: var(--text-color);
    transition: background 0.3s, color 0.3s;
    min-height: calc(100vh / var(--ui-zoom, 1));
    display: flex;
    flex-direction: column;
    /* Hard boundary: prevent any child from expanding the document canvas
       horizontally. This is the single authoritative lock against horizontal
       overflow on mobile devices. */
    overflow-x: hidden;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: calc(10px * var(--space-scale, 1)) 16px;
    font-weight: 600;
    transition: all 0.2s;
}

#themeToggleBtn {
    background: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.glass-panel {
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
    padding: calc(40px * var(--space-scale, 1)) 40px;
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover {
    transform: translateY(-4px);
    box-shadow: var(--glass-shadow-hover);
}

.login-container {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: calc(20px * var(--space-scale, 1)) 20px;
}

.hidden {
    display: none !important;
}

.logo {
    display: flex;
    align-items: center;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    margin-bottom: calc(8px * var(--space-scale, 1));
}

.app-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 242, 255, 0.3);
}

h1 {
    margin: 0;
    font-size: var(--font-size-lg);
}

.subtitle {
    margin-top: 0;
    margin-bottom: calc(30px * var(--space-scale, 1));
    opacity: 0.7;
    font-size: var(--font-size-base);
}

.input-group {
    margin-bottom: calc(20px * var(--space-scale, 1));
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--space-scale, 1)) 8px;
}

label {
    font-size: var(--font-size-base);
    font-weight: 600;
}

input {
    padding: calc(12px * var(--space-scale, 1)) 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    outline: none;
}

input:focus {
    border-color: var(--primary-color);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    padding: calc(12px * var(--space-scale, 1)) 12px;
    font-size: var(--font-size-md);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* Admin & Adaptive Shell Styles */
.app-shell {
    display: flex;
    position: relative;
    /* Use width: 100% instead of 100vw. On iOS/Android, 100vw includes the
       vertical scrollbar width (15-17px), causing the shell to be wider than
       the visible viewport and triggering horizontal scroll. width: 100%
       respects the parent's actual content box. */
    width: 100%;
    /* Use svh (Small Viewport Height) so the shell never overflows the
       visible area, even when the browser chrome (URL bar, nav bar) is visible.
       100vh is kept as a fallback for browsers that do not support svh yet. */
    height: calc(100vh / var(--ui-zoom, 1));
    height: calc(100svh / var(--ui-zoom, 1));
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 24px -4px rgba(0, 0, 0, 0.3), inset -1px 0 0 var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar-brand {
    padding: calc(24px * var(--space-scale, 1)) 24px;
    display: flex;
    align-items: center;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
}

.app-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.brand-text {
    font-size: var(--font-size-md);
    font-weight: 700;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: calc(16px * var(--space-scale, 1)) 12px;
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--space-scale, 1)) 8px;
    overflow-y: auto;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    padding: calc(12px * var(--space-scale, 1)) 12px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-color);
    opacity: 1;
}

.nav-item.active {
    border-left: 3px solid var(--primary-color);
    padding-left: 9px;
}

.sidebar-footer {
    padding: calc(16px * var(--space-scale, 1)) 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: var(--font-size-base);
    padding: calc(8px * var(--space-scale, 1)) 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Content Area Layout */
.main-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-gradient);
}

.top-bar {
    height: 64px;
    height: calc(64px + env(safe-area-inset-top, 0px));
    padding: 0 24px;
    padding: env(safe-area-inset-top, 0px) calc(24px * var(--space-scale, 1)) 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 24px -4px rgba(0, 0, 0, 0.35), inset 0 -1px 0 var(--border-color), inset 0 1px 1px rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
    z-index: 90;
    box-sizing: border-box;
}

.breadcrumbs {
    font-weight: 600;
    opacity: 0.8;
    font-size: var(--font-size-base);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: calc(16px * var(--space-scale, 1)) 16px;
}

.view-viewport {
    flex: 1;
    padding: calc(32px * var(--space-scale, 1)) 32px;
    overflow-y: auto;
    box-sizing: border-box;
    /* Prevent children from expanding beyond this container's content box */
    max-width: 100%;
    overflow-x: hidden;
}

/* Route View State */
.route-view {
    display: block;
    animation: fadeIn 0.3s ease;
}

.route-view.hidden {
    display: none !important;
}

/* Unified layout contract — same canvas as .coach-container.
   Every view (goals, habits, settings, etc.) must use this wrapper
   so the real usable width matches the coach panel exactly:
   → max-width: 860px centered with margin: 0 auto → height is NOT set here: .view-viewport owns the scroll */
.view-container {
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--space-scale, 1)) 10px;
}

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

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

/* Mobile Bottom Tab Bar */
.mobile-tab-bar {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(64px + max(env(safe-area-inset-bottom), 12px));
    padding-bottom: max(env(safe-area-inset-bottom), 12px);
    box-sizing: border-box;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 24px -4px rgba(0, 0, 0, 0.35), inset 0 1px 0 var(--border-color), inset 0 -1px 1px rgba(255, 255, 255, 0.04);
    justify-content: space-around;
    align-items: center;
    z-index: 101;
}

.mobile-tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    text-decoration: none;
    font-size: var(--font-size-sm);
    opacity: 0.75;
    flex: 1;
    min-width: 0;
    height: calc(100% - 10px);
    margin: calc(5px * var(--space-scale, 1)) 2px;
    gap: calc(4px * var(--space-scale, 1)) 4px;
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-tab-item span:not(.mobile-tab-icon) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 2px;
}

.mobile-tab-item.active {
    color: var(--primary-color);
    opacity: 1;
    background: rgba(0, 0, 0, 0.22);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.04);
}

.mobile-tab-icon {
    font-size: var(--font-size-md);
}

/* Specific utilities */
.mb-2 {
    margin-bottom: calc(24px * var(--space-scale, 1));
}

.mb-4 {
    margin-bottom: calc(32px * var(--space-scale, 1));
}

.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: calc(12px * var(--space-scale, 1)) 12px;
    border-bottom: 1px solid var(--border-color);
}

th {
    opacity: 0.7;
    font-weight: 600;
}

/* ==========================================================================
   RESPONSIVE ENGINE (Standard Media Queries)
   ========================================================================== */

/* Mobile Devices */
@media (max-width: 768px) {

    .sidebar,
    .desktop-only {
        display: none !important;
    }

    .mobile-tab-bar {
        display: flex;
    }

    .view-viewport {
        padding: calc(12px * var(--space-scale, 1)) 12px;
        /* Dynamic padding: 64px for the fixed tab bar height +
           env(safe-area-inset-bottom) covers the iOS home indicator / Android
           gesture zone. Falls back to 12px on environments without safe areas. */
        padding-bottom: calc(64px + max(env(safe-area-inset-bottom), 12px));
        /* Critical: ensure padding is subtracted from 100% width, not added.
           Without this the effective content width exceeds the viewport. */
        box-sizing: border-box;
        width: 100%;
    }

    .top-bar {
        padding: 0 16px;
        padding: env(safe-area-inset-top, 0px) calc(16px * var(--space-scale, 1)) 0 16px;
    }

    .coach-view-wrapper {
        height: calc((100vh / var(--ui-zoom, 1)) - 156px - max(env(safe-area-inset-bottom), 12px));
        height: calc((100dvh / var(--ui-zoom, 1)) - 156px - max(env(safe-area-inset-bottom), 12px));
    }

    .coach-response-area {
        max-height: none !important;
        flex: 1 !important;
        min-height: 0 !important;
    }

    /* Reduce spacing and paddings on mobile views to maximize real estate */
    .view-container {
        gap: calc(8px * var(--space-scale, 1)) !important;
    }

    .mb-2 {
        margin-bottom: 8px !important;
    }

    .glass-panel {
        padding: calc(12px * var(--space-scale, 1)) !important;
    }

    .goals-metrics-grid {
        margin-bottom: 8px !important;
        gap: calc(6px * var(--space-scale, 1)) !important;
    }

    .goals-filters-container {
        margin-bottom: 8px !important;
    }

    .goals-grid {
        gap: calc(8px * var(--space-scale, 1)) !important;
    }
}

/* Tablet and PC Devices */
@media (min-width: 769px) {
    .sidebar {
        display: flex;
    }

    .mobile-tab-bar {
        display: none !important;
    }
}

/* Modal Overlays & Premium Glass Dialogs */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: calc(100vw / var(--ui-zoom, 1));
    /* dvh shrinks when the virtual keyboard appears, preventing modals
       from being clipped on mobile (critical UX fix for iOS Safari). */
    height: calc(100vh / var(--ui-zoom, 1));
    height: calc(100dvh / var(--ui-zoom, 1));
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-content {
    max-width: 500px;
    width: 90%;
    animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
    from {
        transform: scale(0.9) translateY(12px);
        opacity: 0;
    }

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(16px * var(--space-scale, 1));
    margin-bottom: calc(20px * var(--space-scale, 1));
}

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
}

.permissions-grid {
    display: flex;
    flex-direction: column;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: calc(16px * var(--space-scale, 1)) 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: calc(8px * var(--space-scale, 1));
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    font-size: var(--font-size-base);
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Button sizing and actions */
.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: calc(6px * var(--space-scale, 1)) 12px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: 6px;
}

.btn-sm-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-sm-danger:hover {
    background: #ef4444;
    color: white;
}

.actions-cell {
    display: flex;
    gap: calc(8px * var(--space-scale, 1)) 8px;
}

/* Role Badges for User Management */
.role-badge {
    padding: calc(4px * var(--space-scale, 1)) 8px;
    border-radius: 4px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background: rgba(14, 165, 233, 0.15);
    color: #0ea5e9;
}

.role-user {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    opacity: 0.8;
}

/* ==========================================================================
   COACH AI INTERFACE
   ========================================================================== */

@media (min-width: 769px) {
    .coach-view-wrapper {
        /* Fallback for older browsers, then dynamic viewport for modern ones.
           110px = top-bar (64px) + coach header padding + viewport padding. */
        height: calc((100vh / var(--ui-zoom, 1)) - 110px);
        height: calc((100dvh / var(--ui-zoom, 1)) - 110px);
        box-sizing: border-box;
    }

    .coach-container {
        max-width: 1400px !important;
        width: 100%;
        padding: 0 calc(16px * var(--space-scale, 1));
        box-sizing: border-box;
    }

    .coach-response-area {
        max-height: none !important;
        padding-right: calc(16px * var(--space-scale, 1));
    }

    .coach-input-panel {
        max-width: 65% !important;
        width: 100%;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box;
    }
}

.coach-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 920px;
    margin: 0 auto;
    gap: 0;
}

/* Coach Header */
.coach-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 calc(16px * var(--space-scale, 1)) 0;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: calc(10px * var(--space-scale, 1)) 10px;
}

.coach-title-group {
    display: flex;
    align-items: center;
    gap: calc(12px * var(--space-scale, 1)) 12px;
}

.coach-specialist-badge {
    font-size: var(--font-size-sm);
    font-weight: 700;
    padding: calc(4px * var(--space-scale, 1)) 10px;
    border-radius: 20px;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coach-header-actions {
    display: flex;
    gap: calc(8px * var(--space-scale, 1)) 8px;
    align-items: center;
}

.coach-toggle-btn {
    display: flex;
    align-items: center;
    gap: calc(6px * var(--space-scale, 1)) 6px;
    padding: calc(7px * var(--space-scale, 1)) 14px;
    border-radius: 8px;
    font-size: var(--font-size-md);
    /* Icon size */
    font-weight: 600;
    background: color-mix(in srgb, var(--primary-color) 8%, var(--panel-bg));
    /* Tinted with panel background */
    color: var(--text-color);
    border: 1px solid color-mix(in srgb, var(--primary-color) 20%, var(--border-color));
    cursor: pointer;
    transition: all 0.2s;
}

.coach-toggle-btn span {
    font-size: var(--font-size-sm);
    /* Keep text standard size */
}

.coach-toggle-btn:hover {
    background: color-mix(in srgb, var(--primary-color) 15%, var(--panel-bg));
    border-color: color-mix(in srgb, var(--primary-color) 40%, var(--border-color));
}

.coach-toggle-btn.active {
    background: color-mix(in srgb, var(--primary-color) 22%, var(--panel-bg));
    color: var(--primary-color);
    border-color: color-mix(in srgb, var(--primary-color) 55%, var(--border-color));
}

.coach-clear-btn {
    display: flex;
    align-items: center;
    gap: calc(5px * var(--space-scale, 1)) 5px;
    padding: calc(7px * var(--space-scale, 1)) 12px;
    border-radius: 8px;
    font-size: var(--font-size-base);
    /* Icon size */
    font-weight: 600;
    background: color-mix(in srgb, #ef4444 6%, var(--panel-bg));
    /* Tinted with panel background */
    color: var(--text-color);
    border: 1px solid color-mix(in srgb, #ef4444 15%, var(--border-color));
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.85;
}

.coach-clear-btn span {
    font-size: var(--font-size-sm);
    /* Keep text standard size */
}

.coach-clear-btn:hover {
    opacity: 1;
    background: color-mix(in srgb, #ef4444 14%, var(--panel-bg));
    border-color: color-mix(in srgb, #ef4444 40%, var(--border-color));
    color: #ef4444;
}

.input-clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-color);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s, opacity 0.2s;
    opacity: 0.7;
    z-index: 2;
}

.input-clear-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-color);
}

/* Response Area */
.coach-response-area {
    position: relative;
    flex: 1;
    overflow-y: auto;
    padding: calc(4px * var(--space-scale, 1)) 2px;
    display: flex;
    flex-direction: column;
    gap: calc(16px * var(--space-scale, 1)) 16px;
    min-height: 200px;
    /* dvh adjusts dynamically when the virtual keyboard appears or the
       browser chrome resizes — prevents the response area from being cut off. */
    max-height: calc((100vh / var(--ui-zoom, 1)) - 340px);
    max-height: calc((100dvh / var(--ui-zoom, 1)) - 340px);
}

.coach-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 180px;
    opacity: 0.45;
    gap: calc(10px * var(--space-scale, 1)) 10px;
    text-align: center;
}

.coach-empty-icon {
    font-size: var(--font-size-hero);
    filter: grayscale(0.3);
}

.coach-empty-state p {
    font-size: var(--font-size-base);
    line-height: 1.5;
    max-width: 300px;
    margin: 0;
}

/* Chat Bubbles */
.chat-bubble {
    display: flex;
    width: 100%;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
}

/* Usuario: alineado a la derecha de la pantalla, con el avatar a la izquierda de la burbuja */
.chat-bubble.user {
    flex-direction: row;
    justify-content: flex-end;
    /* Arrecostada a la derecha */
}

/* AI y Proactive: alineadas a la izquierda de la pantalla, con el avatar/tts a la derecha de la burbuja */
.chat-bubble.ai,
.chat-bubble.proactive {
    flex-direction: row-reverse;
    justify-content: flex-end;
    /* Arrecostada a la izquierda */
}

.chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-md);
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
}

.chat-bubble.user .chat-avatar {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
}

.chat-content {
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--space-scale, 1)) 8px;
    max-width: 82%;
    min-width: 0;
    /* CRITICAL: prevents flex item from overflowing when containing scrollable elements like tables or long code blocks */
}

/* El contenido de usuario se alinea a la derecha */
.chat-bubble.user .chat-content {
    align-items: flex-end;
}

/* El contenido de la IA se alinea a la izquierda */
.chat-bubble.ai .chat-content,
.chat-bubble.proactive .chat-content {
    align-items: flex-start;
}

.chat-text-bubble {
    box-sizing: border-box;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    /* Redondeado uniforme ultra-premium */
    padding: calc(12px * var(--space-scale, 1)) 18px;
    font-size: var(--font-size-base);
    line-height: 1.6;
    box-shadow: var(--glass-shadow-bubble);
    word-break: break-word;
    overflow-wrap: break-word;
}

.chat-bubble.user .chat-text-bubble {
    background: color-mix(in srgb, var(--primary-color) 14%, rgba(0, 0, 0, 0.35));
    border-color: color-mix(in srgb, var(--primary-color) 30%, rgba(255, 255, 255, 0.05));
    border-radius: 16px 4px 16px 16px;
    /* Punta en la esquina superior derecha */
}

.chat-bubble.ai .chat-text-bubble,
.chat-bubble.proactive .chat-text-bubble {
    border-radius: 4px 16px 16px 16px;
    /* Punta en la esquina superior izquierda */
}

/* Light theme: user bubble is a soft, barely-tinted white —
   closer to the AI bubble tone but still distinguishable by its blue tint */
:root[data-theme="light"] .chat-bubble.user .chat-text-bubble {
    background: color-mix(in srgb, var(--primary-color) 10%, #eef2f6);
    border-color: color-mix(in srgb, var(--primary-color) 22%, rgba(0, 0, 0, 0.08));
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   CHAT META BAR — Discrete badges and context labels below AI bubbles
   ========================================================================== */

.chat-meta-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 4px 0 4px;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.chat-bubble.ai:hover .chat-meta-bar {
    opacity: 0.85;
}

.chat-meta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: var(--font-size-sm);
    cursor: default;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.2s ease;
    user-select: none;
}

.chat-meta-badge.crud {
    cursor: help;
}

.chat-meta-badge.reasoning {
    cursor: pointer;
}

.chat-meta-badge.reasoning.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.35);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.15);
}

.chat-meta-badge.model-badge {
    cursor: help;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.chat-meta-badge.model-badge:hover {
    transform: scale(1.12) rotate(6deg);
}

.chat-meta-badge.model-badge.fast:hover {
    border-color: rgba(234, 179, 8, 0.7);
    background: rgba(234, 179, 8, 0.15);
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.25);
}

.chat-meta-badge.model-badge.medium:hover {
    border-color: rgba(168, 85, 247, 0.7);
    background: rgba(168, 85, 247, 0.15);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.25);
}

.chat-meta-badge.model-badge.analytical:hover {
    border-color: rgba(6, 182, 212, 0.7);
    background: rgba(6, 182, 212, 0.15);
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.25);
}

:root[data-theme="light"] .chat-meta-badge {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}

.chat-meta-context {
    font-size: var(--font-size-sm);
    color: var(--text-secondary, rgba(255, 255, 255, 0.4));
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.03);
    line-height: 1.4;
}

/* Reasoning expandable block */
.chat-reasoning-block {
    display: none;
    width: 100%;
    margin-top: 4px;
    padding: calc(8px * var(--space-scale, 1)) 14px;
    border-left: 2px solid rgba(168, 85, 247, 0.3);
    border-radius: 4px;
    background: rgba(168, 85, 247, 0.04);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    color: var(--text-secondary, rgba(255, 255, 255, 0.6));
    animation: fadeIn 0.25s ease;
}

.chat-reasoning-block.chat-reasoning-visible {
    display: block;
}

.chat-reasoning-block p {
    margin: 0 0 6px 0;
}

.chat-reasoning-block p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   PROACTIVE INSIGHT BUBBLE — Special visual treatment for AI-initiated messages
   ========================================================================== */

@keyframes proactiveFadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

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

@keyframes proactiveShimmer {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

@keyframes proactivePulseGlow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.12), 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    50% {
        box-shadow: 0 0 32px rgba(16, 185, 129, 0.22), 0 8px 30px rgba(0, 0, 0, 0.25);
    }
}

.chat-bubble.proactive {
    animation: proactiveFadeInUp 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    position: relative;
}

.chat-bubble.proactive .chat-avatar {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(59, 130, 246, 0.2) 100%);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
    font-size: var(--font-size-md);
}

.chat-bubble.proactive .chat-text-bubble {
    border-radius: 4px 16px 16px 16px;
    /* Punta en la esquina superior izquierda */
    border: 1px solid transparent;
    background:
        linear-gradient(var(--bg-color, #0f172a), var(--bg-color, #0f172a)) padding-box,
        linear-gradient(135deg, rgba(16, 185, 129, 0.5) 0%, rgba(59, 130, 246, 0.4) 50%, rgba(168, 85, 247, 0.35) 100%) border-box;
    box-shadow: 0 4px 24px rgba(16, 185, 129, 0.1), 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: proactivePulseGlow 4s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

/* Shimmer sweep overlay */
.chat-bubble.proactive .chat-text-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg,
            transparent 30%,
            rgba(255, 255, 255, 0.04) 45%,
            rgba(255, 255, 255, 0.07) 50%,
            rgba(255, 255, 255, 0.04) 55%,
            transparent 70%);
    background-size: 200% 100%;
    animation: proactiveShimmer 3.5s ease-in-out infinite;
    pointer-events: none;
}

/* Proactive type badge */
.proactive-type-badge {
    display: inline-flex;
    align-items: center;
    gap: calc(5px * var(--space-scale, 1)) 5px;
    font-size: var(--font-size-sm);
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    padding: calc(3px * var(--space-scale, 1)) 9px;
    border-radius: 20px;
    margin-bottom: calc(6px * var(--space-scale, 1));
}

.proactive-type-badge.north_star {
    background: rgba(251, 191, 36, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.proactive-type-badge.weak_point {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.proactive-type-badge.motivation {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.proactive-type-badge.focus {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.proactive-type-badge.reflection {
    background: rgba(168, 85, 247, 0.12);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.25);
}

.proactive-type-badge.base {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-color);
    opacity: 0.7;
    border: 1px solid var(--border-color);
}

/* Proactive loading placeholder (skeleton state) */
.proactive-skeleton {
    display: flex;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    align-items: flex-start;
    animation: proactiveFadeInUp 0.35s ease forwards;
}

.proactive-skeleton-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(90deg,
            rgba(16, 185, 129, 0.1) 25%,
            rgba(16, 185, 129, 0.2) 50%,
            rgba(16, 185, 129, 0.1) 75%);
    background-size: 200% 100%;
    animation: proactiveShimmer 1.5s infinite;
    flex-shrink: 0;
}

.proactive-skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--space-scale, 1)) 8px;
    padding: calc(14px * var(--space-scale, 1)) 16px;
    background: var(--panel-bg);
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: 4px 12px 12px 12px;
}

.proactive-skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: proactiveShimmer 1.5s infinite;
}

.proactive-skeleton-line:nth-child(1) {
    width: 55%;
    animation-delay: 0s;
}

.proactive-skeleton-line:nth-child(2) {
    width: 90%;
    animation-delay: 0.1s;
}

.proactive-skeleton-line:nth-child(3) {
    width: 80%;
    animation-delay: 0.2s;
}

.proactive-skeleton-line:nth-child(4) {
    width: 65%;
    animation-delay: 0.3s;
}

/* Markdown rendering inside chat */
.chat-text-bubble h1,
.chat-text-bubble h2,
.chat-text-bubble h3 {
    margin: calc(12px * var(--space-scale, 1)) 0 calc(6px * var(--space-scale, 1)) 0;
    font-size: var(--font-size-base);
}

.chat-text-bubble p {
    margin: 0 0 calc(8px * var(--space-scale, 1)) 0;
}

.chat-text-bubble p:last-child {
    margin-bottom: 0;
}

.chat-text-bubble ul,
.chat-text-bubble ol {
    padding-left: 18px;
    margin: calc(6px * var(--space-scale, 1)) 0;
}

.chat-text-bubble li {
    margin-bottom: calc(4px * var(--space-scale, 1));
}

.chat-text-bubble strong {
    color: var(--primary-color);
}

.chat-text-bubble code {
    background: rgba(255, 255, 255, 0.08);
    padding: calc(2px * var(--space-scale, 1)) 6px;
    border-radius: 4px;
    font-size: var(--font-size-sm);
    font-family: var(--font-mono);
}

/* AI Code Blocks styling with safe overflow scrolling */
.chat-text-bubble pre {
    background: rgba(0, 0, 0, 0.22);
    padding: calc(12px * var(--space-scale, 1)) 12px;
    border-radius: 12px;
    overflow-x: auto;
    max-width: 100%;
    margin: calc(8px * var(--space-scale, 1)) 0;
    border: 1px solid var(--border-color);
}

.chat-text-bubble pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: var(--font-size-sm);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Response Table */
.coach-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.coach-table-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.coach-table-container th {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: calc(10px * var(--space-scale, 1)) 12px;
}

.coach-table-container td {
    padding: calc(10px * var(--space-scale, 1)) 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--font-size-sm);
}

.coach-table-container tr:last-child td {
    border-bottom: none;
}

/* Chat meta info (model badge) */
.chat-meta {
    display: flex;
    align-items: center;
    gap: calc(6px * var(--space-scale, 1)) 6px;
    font-size: var(--font-size-sm);
    opacity: 0.45;
    padding: 0 4px;
}

.model-badge {
    padding: calc(2px * var(--space-scale, 1)) 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-start;
    gap: calc(12px * var(--space-scale, 1)) 12px;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.typing-dots {
    display: flex;
    gap: calc(5px * var(--space-scale, 1)) 5px;
    padding: calc(14px * var(--space-scale, 1)) 18px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px 16px 16px 16px;
    /* Punta en la esquina superior izquierda */
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-color);
    opacity: 0.5;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* Input Panel */
.coach-input-panel {
    flex-shrink: 0;
    padding: calc(12px * var(--space-scale, 1)) 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    margin-top: calc(10px * var(--space-scale, 1));
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--glass-shadow-bubble);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--space-scale, 1)) 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Image preview */
.coach-image-preview {
    display: none;
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.coach-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.coach-image-preview-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.8);
    color: white;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* Textarea Wrap (Inner Capsule) */
.coach-textarea-wrap {
    display: flex;
    gap: calc(10px * var(--space-scale, 1)) 10px;
    align-items: center;
    background: var(--input-wrap-bg, rgba(0, 0, 0, 0.15));
    border: 1px solid var(--input-wrap-border, var(--border-color));
    border-radius: 24px;
    padding: calc(6px * var(--space-scale, 1)) 14px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.coach-textarea-wrap:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

#coachTextarea {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    resize: none;
    padding: calc(8px * var(--space-scale, 1)) 4px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.4;
    outline: none;
    overflow-y: auto;
    box-sizing: border-box;
}

#coachTextarea::placeholder {
    opacity: 0.45;
}

.coach-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: var(--font-size-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.coach-send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.coach-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Input Toolbar */
.coach-toolbar {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--space-scale, 1)) 8px;
}

.coach-tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: var(--font-size-md);
    background: transparent;
    color: var(--text-color);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.65;
    flex-shrink: 0;
    padding: 0;
}

.coach-tool-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.coach-tool-btn.recording {
    background: var(--primary-color);
    color: white !important;
    opacity: 1;
    animation: recordingPulse 1.5s infinite;
}

@keyframes recordingPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 var(--recording-pulse-start, rgba(255, 255, 255, 0.5));
    }

    50% {
        box-shadow: 0 0 0 10px var(--recording-pulse-end, rgba(255, 255, 255, 0));
    }
}

.coach-char-count {
    margin-left: auto;
    font-size: var(--font-size-sm);
    opacity: 0.4;
}

/* Phone optimizations */
@media (max-width: 600px) {
    .coach-response-area {
        max-height: calc((100vh / var(--ui-zoom, 1)) - 320px);
    }

    .chat-content {
        max-width: 90%;
    }

    .coach-header {
        gap: calc(8px * var(--space-scale, 1)) 8px;
    }
}

/* Sidebar Version Control */
.sidebar-version {
    font-size: var(--font-size-sm);
    opacity: 0.4;
    font-weight: 600;
    transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-version {
    display: none;
}

/* Premium Stop button state during active AI text generation */
.coach-send-btn.sending {
    background: transparent !important;
    border: 2px solid #ef4444;
    color: #ef4444;
    animation: pulseStop 2s infinite;
}

@keyframes pulseStop {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
    }
}

/* Speaker toggle button within AI bubbles */
.chat-avatar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(8px * var(--space-scale, 1)) 8px;
    flex-shrink: 0;
}

.coach-bubble-speak-btn {
    background: color-mix(in srgb, var(--primary-color) 12%, var(--panel-bg));
    /* Tinted with panel background */
    border: 1px solid color-mix(in srgb, var(--primary-color) 30%, var(--border-color));
    cursor: pointer;
    font-size: var(--font-size-md);
    /* Slightly larger icon size */
    padding: 0;
    border-radius: 50%;
    transition: all 0.2s ease;
    opacity: 0.85;
    /* Make more visible by default */
    color: var(--primary-color);
    /* Premium accent color */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    /* Marginally larger button container */
    height: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.coach-bubble-speak-btn:hover {
    opacity: 1;
    background: color-mix(in srgb, var(--primary-color) 22%, var(--panel-bg));
    border-color: color-mix(in srgb, var(--primary-color) 50%, var(--border-color));
    transform: scale(1.1);
}


/* Chat Input Hand-Orientation Styles (Flex Order Mapping) */
#coachImageBtn {
    order: 1;
}

#coachTextarea {
    order: 2;
}

#coachVoiceBtn {
    order: 3;
    font-size: var(--font-size-lg);
}

#coachSendBtn {
    order: 4;
}

/* Left-handed (Zurdo) ordering override */
.coach-textarea-wrap.left-handed #coachSendBtn {
    order: 1;
}

.coach-textarea-wrap.left-handed #coachVoiceBtn {
    order: 2;
}

.coach-textarea-wrap.left-handed #coachTextarea {
    order: 3;
}

.coach-textarea-wrap.left-handed #coachImageBtn {
    order: 4;
}

/* Responsive User Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(16px * var(--space-scale, 1)) 16px;
}

@media (max-width: 768px) {

    /* Hide settings tab header row on mobile views */
    .settings-tabs {
        display: none !important;
    }



    /* Collapse inputs to single column grid */
    .settings-grid {
        grid-template-columns: 1fr !important;
    }

    /* Optimize card paddings on phone views */
    #view-user-config .glass-panel {
        padding: calc(16px * var(--space-scale, 1)) !important;
    }

    #view-user-config {
        padding: calc(8px * var(--space-scale, 1)) !important;
    }
}

/* ==========================================================================
   GOALS & TARGETS DASHBOARD STYLING
   ========================================================================== */

/* Area specific color tokens */
.area-health {
    --area-accent: #10b981;
}

.area-career {
    --area-accent: #ef4444;
}

.area-finances {
    --area-accent: #f59e0b;
}

.area-relationships {
    --area-accent: #ec4899;
}

.area-growth {
    --area-accent: #3b82f6;
}

.area-recreation {
    --area-accent: #a855f7;
}

.area-spiritual {
    --area-accent: #06b6d4;
}

.area-environment {
    --area-accent: #84cc16;
}

/* Goal cards hover animations and glowing highlights */
.goal-card {
    border-top: 4px solid var(--area-accent) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
    max-width: 100%;
}

.goal-card {
    cursor: pointer;
}

.goal-card:hover {
    transform: translateY(-4px) scale(1.01) !important;
    box-shadow: var(--glass-shadow-hover) !important;
    border-color: var(--accent-color) !important;
}

.goal-card:active {
    transform: translateY(-2px) scale(1.0) !important;
}

/* Light theme overrides for hovering cards to look crisp */
:root[data-theme="light"] .goal-card:hover {
    box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.1), 0 0 15px -3px rgba(0, 0, 0, 0.05), inset 0 1px 1.5px rgba(255, 255, 255, 0.7) !important;
}

/* Expandable goal card styling */
.goal-card-expandable-content {
    display: none;
    margin-top: calc(14px * var(--space-scale, 1));
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    padding-top: calc(14px * var(--space-scale, 1));
}

.goal-card.expanded .goal-card-expandable-content {
    display: block !important;
}

.goal-card-header {
    cursor: default;
    user-select: none;
    transition: opacity 0.2s ease;
}

.goal-expand-chevron {
    display: inline-block;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotate(0deg);
}

.goal-card.expanded .goal-expand-chevron {
    transform: rotate(90deg);
}

/* Goal badges (horizon & status) */
.goal-badge {
    padding: calc(4px * var(--space-scale, 1)) 10px;
    border-radius: 12px;
    font-size: var(--font-size-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-horizon {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.badge-status.status-active {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-status.status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-status.status-paused {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-status.status-abandoned {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    opacity: 0.5;
    border: 1px solid var(--border-color);
}

/* Filter Chips with animated state changes */
.goals-filter-btn {
    background: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: calc(8px * var(--space-scale, 1)) 16px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.goals-filter-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.04);
}

.goals-filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* Slide action thumb custom styling on modern browsers */
.goal-progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color) !important;
    border: 2px solid var(--text-color) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s;
}

.goal-progress-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
}

/* Responsive grid layouts and phone adaptation */
@media (max-width: 580px) {

    .goals-grid,
    .habits-grid {
        grid-template-columns: 1fr !important;
    }

    .goals-metrics-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   PARENT-CHILD-GRANDCHILD (TREE HIERARCHY) GOALS SCREEN modern styling
   ========================================================================== */

/* Area Block (Parent) */
.area-block {
    position: relative;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: calc(14px * var(--space-scale, 1)) calc(18px * var(--space-scale, 1));
    margin-bottom: calc(16px * var(--space-scale, 1));
    box-shadow: var(--glass-shadow-bubble);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: box-shadow 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
    border-left: 5px solid var(--area-accent, var(--primary-color)) !important;
    overflow: hidden;
}

/* Subtle ambient backdrop aura for each Life Area matching its accent color */
.area-block::after {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 120px;
    height: 120px;
    background: var(--area-accent, var(--primary-color));
    opacity: 0.04;
    filter: blur(40px);
    border-radius: 50%;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.area-block:hover {
    border-color: color-mix(in srgb, var(--area-accent, var(--primary-color)) 40%, var(--border-color));
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 1px 1px color-mix(in srgb, var(--area-accent, var(--primary-color)) 15%, transparent);
}

.area-block:hover::after {
    opacity: 0.08;
}

/* Premium menu card styles for drill-down navigation view */
.area-card-menu {
    cursor: grab;
    border-left: 1px solid var(--border-color) !important;
    /* Strips out the 5px border-left strip */
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%) !important;
    /* Identical to glass-panel */
    box-shadow: var(--glass-shadow) !important;
    /* Identical to glass-panel */
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.2s ease !important;
}

.area-card-menu:hover {
    transform: translateY(-4px) scale(1.01) !important;
    box-shadow: var(--glass-shadow-hover) !important;
    border-color: var(--accent-color) !important;
}

.area-card-menu:active {
    transform: translateY(-2px) scale(1.0) !important;
    cursor: grabbing;
}

/* Area Header */
.area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: calc(6px * var(--space-scale, 1)) 0;
    gap: 12px;
}

.area-title-wrap {
    display: flex;
    align-items: center;
    gap: calc(10px * var(--space-scale, 1));
}

.area-icon-container {
    font-size: var(--font-size-lg);
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.area-header:hover .area-icon-container {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.08);
}

.area-title {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-color);
}

.area-meta {
    display: flex;
    align-items: center;
    gap: calc(10px * var(--space-scale, 1));
    flex-wrap: wrap;
}

/* Mini progress pill */
.area-progress-pill {
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--area-accent, var(--primary-color));
    background: color-mix(in srgb, var(--area-accent, var(--primary-color)) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--area-accent, var(--primary-color)) 25%, transparent);
    padding: calc(2px * var(--space-scale, 1)) calc(8px * var(--space-scale, 1));
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.area-count-badge {
    font-size: var(--font-size-sm);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-color);
    padding: calc(2px * var(--space-scale, 1)) calc(8px * var(--space-scale, 1));
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.area-toggle-arrow {
    font-size: var(--font-size-sm);
    opacity: 0.5;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.area-block.expanded .area-toggle-arrow {
    transform: rotate(180deg);
    opacity: 0.95;
    color: var(--area-accent);
}

/* Area Collapsible Grid Section */
.area-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.area-block.expanded .area-content {
    grid-template-rows: 1fr;
}

.area-content-inner {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: calc(14px * var(--space-scale, 1));
    padding-top: calc(14px * var(--space-scale, 1));
}

/* CSS Guide Connector Lines for Desktop Tree hierarchy */
@media (min-width: 769px) {
    .area-content-inner {
        position: relative;
        padding-left: calc(26px * var(--space-scale, 1));
        margin-left: calc(14px * var(--space-scale, 1));
        border-left: 1.5px dashed rgba(255, 255, 255, 0.08);
    }
}

/* Goal Tree Node (Child Card) */
.goal-tree-node {
    position: relative;
    background: rgba(255, 255, 255, 0.012);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: calc(18px * var(--space-scale, 1));
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
}

.goal-tree-node:hover {
    background: rgba(255, 255, 255, 0.025);
    border-color: color-mix(in srgb, var(--area-accent, var(--primary-color)) 30%, rgba(255, 255, 255, 0.15));
    box-shadow: 0 10px 20px -8px rgba(0, 0, 0, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

/* Connector branch node on desktop */
@media (min-width: 769px) {
    .goal-tree-node::before {
        content: '';
        position: absolute;
        top: calc(34px * var(--space-scale, 1));
        /* Align with header/icon height */
        left: calc(-26px * var(--space-scale, 1) - 1.5px);
        width: calc(26px * var(--space-scale, 1));
        height: 1.5px;
        background: rgba(255, 255, 255, 0.08);
        transition: background-color 0.25s ease;
    }

    .goal-tree-node:hover::before {
        background: var(--area-accent, var(--primary-color));
    }
}

/* Subgoals Grid / List Container (Grandchildren) */
.subgoals-list {
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--space-scale, 1));
    margin-top: calc(14px * var(--space-scale, 1));
    padding-top: calc(12px * var(--space-scale, 1));
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.subgoal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-sm);
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: calc(8px * var(--space-scale, 1)) calc(12px * var(--space-scale, 1));
    transition: all 0.2s ease;
    flex-wrap: wrap;
    gap: calc(8px * var(--space-scale, 1));
}

.subgoal-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

/* Grandchild completion visual styling */
.subgoal-item.completed {
    opacity: 0.55;
    background: color-mix(in srgb, var(--area-accent, var(--primary-color)) 4%, rgba(0, 0, 0, 0.15));
    border-color: color-mix(in srgb, var(--area-accent, var(--primary-color)) 12%, rgba(255, 255, 255, 0.02));
}

.subgoal-item.completed .subgoal-title {
    text-decoration: line-through;
    opacity: 0.8;
}

/* Empty Life Area indicator card style */
.empty-area-placeholder {
    border: 1.5px dashed rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: calc(16px * var(--space-scale, 1));
    text-align: center;
    opacity: 0.6;
    font-size: var(--font-size-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(8px * var(--space-scale, 1));
}

.empty-area-placeholder button {
    font-size: var(--font-size-sm);
    padding: calc(4px * var(--space-scale, 1)) calc(10px * var(--space-scale, 1));
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.empty-area-placeholder button:hover {
    background: var(--area-accent);
    color: white;
    border-color: var(--area-accent);
}

/* Goals Roadmap Animations */
@keyframes roadmap-flow {
    to {
        stroke-dashoffset: -12;
    }
}

.roadmap-flow-path {
    animation: roadmap-flow 1.2s linear infinite;
}

/* Green Pulse Animation at 1Hz */
@keyframes green-pulse-1hz {

    0%,
    100% {
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25), 0 0 8px rgba(16, 185, 129, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
        border-color: rgba(16, 185, 129, 0.45);
        background-color: rgba(255, 255, 255, 0.04);
    }

    50% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 16px rgba(16, 185, 129, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
        border-color: rgba(16, 185, 129, 0.9);
        background-color: rgba(255, 255, 255, 0.04);
    }
}

/* Custom premium checkboxes for subgoals checklist */
.custom-subgoal-checkbox {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.25);
    transition: all 0.2s ease;
}

.custom-subgoal-checkbox.checked {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 2px solid #10b981 !important;
    background: #10b981 !important;
    color: white !important;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

/* Hover feedback on the parent button */
button:hover .custom-subgoal-checkbox:not(.checked) {
    border-color: var(--accent-color) !important;
}

/* Light theme checkbox overrides */
:root[data-theme="light"] .custom-subgoal-checkbox {
    border: 2px solid rgba(0, 0, 0, 0.22) !important;
    background: rgba(0, 0, 0, 0.05) !important;
}

.green-pulse-active {
    animation: green-pulse-1hz 1.0s infinite ease-in-out !important;
}

/* Sticky Goals Navigation Map Flowchart */
#goalsAreaRoadmap,
#tasksRoadmap {
    position: sticky !important;
    top: calc(-20px * var(--space-scale, 1)) !important;
    z-index: 100 !important;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-radius: 16px !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--glass-shadow) !important;
    padding: calc(14px * var(--space-scale, 1)) calc(18px * var(--space-scale, 1)) !important;
    margin-bottom: calc(20px * var(--space-scale, 1)) !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
}

/* Custom premium date input for subgoals */
.custom-subgoal-date {
    width: 125px;
    padding: calc(4px * var(--space-scale, 1)) calc(8px * var(--space-scale, 1));
    font-size: calc(11.5px * var(--text-scale, 1));
    background: rgba(0, 0, 0, 0.25) !important;
    color: var(--text-color) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.custom-subgoal-date:focus {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Light theme overrides for date inputs */
:root[data-theme="light"] .custom-subgoal-date {
    background: rgba(255, 255, 255, 0.8) !important;
    color: #0f172a !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS FOR AI CHAT BUBBLES
   ========================================================================== */
@media (max-width: 768px) {

    /* Only apply vertical stacking to AI and proactive bubbles to maximize available width */
    .chat-bubble.ai,
    .chat-bubble.proactive {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: calc(8px * var(--space-scale, 1)) !important;
    }

    /* Force the AI chat content container to span 100% of the available area */
    .chat-bubble.ai .chat-content,
    .chat-bubble.proactive .chat-content {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Arrange the AI avatar and speak button side-by-side horizontally when stacked */
    .chat-bubble.ai .chat-avatar-wrap,
    .chat-bubble.proactive .chat-avatar-wrap {
        flex-direction: row !important;
        align-items: center !important;
        gap: calc(8px * var(--space-scale, 1)) 8px !important;
        margin-bottom: calc(2px * var(--space-scale, 1)) !important;
    }

    /* Keep table rendering inside AI bubbles extremely responsive and readable */
    .chat-bubble.ai .coach-table-container,
    .chat-bubble.proactive .coach-table-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Skeleton loader for proactive messages is also optimized to prevent narrow squeezing */
    .proactive-skeleton {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: calc(8px * var(--space-scale, 1)) !important;
    }

    .proactive-skeleton-avatar {
        margin-bottom: calc(2px * var(--space-scale, 1)) !important;
    }
}

/* ==========================================================================
   FINANCES MODULE STYLES (Glassmorphism & Responsive Dashboard)
   ========================================================================== */
.finances-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: calc(24px * var(--space-scale, 1));
}

.finances-container.view-container {
    max-width: 100% !important;
}

.finances-section.glass-panel,
.finances-ledger.glass-panel {
    max-width: 100%;
}

.finances-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: calc(16px * var(--space-scale, 1));
}

.finance-card {
    padding: calc(16px * var(--space-scale, 1));
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.finance-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.finance-card-header {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-base);
    opacity: 0.8;
}

.finance-card-balance {
    font-size: var(--font-size-lg);
    font-weight: 800;
}

.text-income {
    color: #10b981 !important;
    /* Emerald */
}

.text-expense {
    color: #ef4444 !important;
    /* Red */
}

.finances-budgets-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.budget-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.budget-progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.4s ease;
}

.budget-progress-fill.danger {
    background: #ef4444;
}

.finances-table {
    width: 100%;
    border-collapse: collapse;
}

.finances-table th,
.finances-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.finances-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.loading-state {
    text-align: center;
    padding: 20px;
    opacity: 0.6;
    font-size: var(--font-size-base);
}

/* ── Mobile: Convert transactions table to compact cards ── */
@media (max-width: 600px) {
    .finances-table thead {
        display: none;
    }

    .finances-table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 2px 8px;
        background: var(--panel-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 8px 24px 8px 10px;
        margin-bottom: 6px;
        cursor: pointer;
        color: var(--text-color);
        position: relative;
    }

    /* Chevron indicator */
    .finances-table tr::after {
        content: "▾";
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 10px;
        opacity: 0.3;
        transition: transform 0.2s;
    }

    .finances-table tr.expanded::after {
        transform: translateY(-50%) rotate(180deg);
    }

    /* Description */
    .finances-table td:nth-child(2) {
        grid-column: 1;
        grid-row: 1;
        font-size: var(--font-size-sm);
        padding: 0;
        border: none;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .finances-table td:nth-child(2)::before {
        content: none;
    }

    /* Amount */
    .finances-table td:nth-child(4) {
        grid-column: 2;
        grid-row: 1;
        font-size: var(--font-size-sm);
        padding: 0;
        border: none;
        display: block;
        text-align: right;
        white-space: nowrap;
    }

    .finances-table td:nth-child(4)::before {
        content: none;
    }

    /* Status */
    .finances-table td:nth-child(6) {
        grid-column: 2;
        grid-row: 2;
        font-size: var(--font-size-sm);
        padding: 0;
        border: none;
        display: block;
        text-align: right;
        opacity: 0.7;
    }

    .finances-table td:nth-child(6)::before {
        content: none;
    }

    /* Actions */
    .finances-table td:nth-child(7) {
        grid-column: 1;
        grid-row: 2;
        padding: 0;
        border: none;
        display: flex;
        gap: 4px;
        align-items: center;
    }

    .finances-table td:nth-child(7)::before {
        content: none;
    }

    .finances-table td:nth-child(7) button {
        font-size: calc(12px * var(--text-scale, 1)) !important;
        padding: 0 4px !important;
    }

    /* Hide non-essential fields (date, category, account) */
    .finances-table td:nth-child(1),
    .finances-table td:nth-child(3),
    .finances-table td:nth-child(5) {
        display: none;
    }

    /* Expanded state */
    .finances-table tr.expanded {
        grid-template-columns: 1fr;
        grid-template-rows: none;
    }

    .finances-table tr.expanded td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none;
        font-size: var(--font-size-sm);
        color: var(--text-color);
    }

    .finances-table tr.expanded td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: var(--font-size-sm);
        text-transform: uppercase;
        letter-spacing: 0.03em;
        opacity: 0.5;
        margin-right: 8px;
        white-space: nowrap;
        color: var(--text-color);
    }

    .finances-table tr.expanded td:not(:last-child) {
        border-bottom: 1px solid var(--border-color);
    }

    .finances-table tr.expanded td:last-child {
        justify-content: flex-end;
        gap: 8px;
        padding-top: 6px;
        border-top: 1px solid var(--border-color);
    }

    .finances-table tr.expanded td:last-child::before {
        content: none;
    }

    .finances-table td {
        font-family: inherit;
    }
}

/* ─── Recurring Transaction Utilities ─────────────────────────────────────── */

/* Amber badge — recurring-generated pending transactions */
.text-recurring {
    color: #f59e0b;
    font-weight: 600;
}

/* Grey badge — manual pending transactions */
.text-pending {
    color: #94a3b8;
    font-weight: 500;
}

/* Small danger outline button used in recurring deactivate action */
.btn-danger-outline {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ==========================================================================
   QUICK COACH GLOBAL FAB & MODAL STYLES
   ========================================================================== */

/* Quick Coach Floating Action Button */
.quick-coach-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(59, 130, 246, 0.25) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 250;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: floatFab 3s ease-in-out infinite;
}

.quick-coach-fab:hover {
    transform: scale(1.15) translateY(-2px);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 0 12px 40px rgba(59, 130, 246, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.quick-coach-fab:active {
    transform: scale(0.95);
}

.quick-coach-fab.hidden {
    display: none !important;
}

.fab-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes floatFab {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-8px) rotate(2deg);
    }
}

/* Quick Coach Bottom Bar Adaptations */
#modalQuickCoach.modal-overlay {
    background: transparent !important; /* Completely transparent background so user can see CRUD updates in real-time */
    backdrop-filter: none !important; /* No blur overlay so that background list elements are perfectly sharp */
    -webkit-backdrop-filter: none !important;
    pointer-events: none !important; /* Let clicks pass through overlay wrapper to allow interaction with background */
    display: flex;
    align-items: flex-end; /* Align the dock to the bottom */
    justify-content: center;
    padding: 0;
}

#modalQuickCoach.modal-overlay:not(.hidden) {
    display: flex !important;
}

.quick-coach-modal {
    pointer-events: auto !important; /* Capture pointer events for modal content */
    width: calc(100% - 32px) !important;
    max-width: 800px !important;
    margin: 0 auto 20px auto !important;
    border-radius: 16px !important;
    border: 1px solid var(--border-color) !important; /* Exact border style matching .glass-panel */
    border-top: 4px solid var(--primary-color) !important; /* Accent color matching current theme */
    background: linear-gradient(135deg, 
        color-mix(in srgb, var(--panel-bg-start) 80%, var(--primary-color)), 
        var(--panel-bg-end), 
        color-mix(in srgb, var(--panel-bg-start) 65%, var(--primary-color)), 
        var(--panel-bg-end)
    ) !important;
    background-size: 400% 400% !important;
    backdrop-filter: blur(16px) !important; /* Glassmorphism background blur matching .glass-panel */
    -webkit-backdrop-filter: blur(16px) !important;
    box-shadow: var(--glass-shadow) !important; /* Glassmorphism shadow matching .glass-panel */
    padding: 12px 18px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
    animation: quickCoachGlow 6s ease infinite !important;
}

#modalQuickCoach.hidden .quick-coach-modal {
    transform: translateY(100px);
    opacity: 0;
}

#quickCoachInput {
    background: rgba(0, 0, 0, 0.25) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-color) !important;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#quickCoachInput:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.15);
}

#quickCoachVoiceBtn.recording {
    background: #ef4444 !important;
    color: white !important;
    animation: recordingPulse 1.5s infinite;
}

/* Adjust FAB position on mobile so it doesn't overlap mobile tab bar */
@media (max-width: 768px) {
    .quick-coach-fab {
        bottom: 100px;
        /* shift up to avoid mobile tab bar */
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .fab-icon {
        font-size: 20px;
    }

    .quick-coach-modal {
        margin: 0 auto 10px auto !important;
        width: calc(100% - 16px) !important;
    }
}

/* Sleek Quick Coach Toast response alert styling */
.quick-coach-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    z-index: 400;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%) !important; /* Theme card gradient background */
    color: var(--text-color) !important; /* Theme text color */
    border: 1px solid var(--border-color) !important; /* Theme border */
    border-top: 4px solid var(--primary-color) !important; /* Default themed top border */
    padding: 14px 44px 14px 24px; /* More padding on the right for close button */
    border-radius: 12px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(16px) !important; /* Matches glass panel */
    -webkit-backdrop-filter: blur(16px) !important;
    font-weight: 600;
    font-size: 14.5px;
    max-width: 90%;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto !important; /* Allow interactions with the toast response */
    text-align: center;
    opacity: 1;
}

.quick-coach-toast.hidden {
    display: block !important;
    transform: translateX(-50%) translateY(-50px);
    opacity: 0;
}

/* Close button inside Quick Coach Toast */
.quick-coach-toast-close {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    padding: 6px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-coach-toast-close:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}


/* Custom themed scrollbar for Quick Coach Input box */
#quickCoachInput::-webkit-scrollbar {
    width: 6px;
}
#quickCoachInput::-webkit-scrollbar-track {
    background: transparent;
}
#quickCoachInput::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}
#quickCoachInput {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

/* Dynamic Shift/Breathing Aura Glow keyframes */
@keyframes quickCoachGlow {
    0% {
        background-position: 0% 50%;
        box-shadow: var(--glass-shadow) !important;
    }
    50% {
        background-position: 100% 50%;
        box-shadow: 0 15px 45px -5px color-mix(in srgb, var(--primary-color) 25%, rgba(0, 0, 0, 0.4)), inset 0 1px 1px rgba(255, 255, 255, 0.08) !important;
    }
    100% {
        background-position: 0% 50%;
        box-shadow: var(--glass-shadow) !important;
    }
}

/* Styled select options and optgroups to match light and dark themes */
select option,
select optgroup {
    background-color: var(--bg-color, #0f172a);
    color: var(--text-color, #f8fafc);
}

/* Premium Glassmorphic Dropdowns (Select tags) */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    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='%23f8fafc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    padding-right: 40px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--glass-shadow-bubble);
}

:root[data-theme="light"] select {
    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='%230f172a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

select:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

:root[data-theme="light"] select:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
}

select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 25%, transparent) !important;
    outline: none;
}

/* ==========================================================================
   TRANSACTIONS DRAWER (DRILL-DOWN)
   ========================================================================== */
.tx-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.tx-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.tx-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 480px;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid var(--border-color);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.tx-drawer.open {
    transform: translateX(0);
}

.tx-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.tx-drawer-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.tx-drawer-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-drawer-period-select-wrap {
    margin-top: 12px;
    position: relative;
}

.tx-drawer-period-select {
    width: 100%;
    padding: 8px 36px 8px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 13px;
    font-weight: 600;
}

.tx-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Transaction List Item styles */
.tx-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.tx-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transition: background-color 0.2s;
}

.tx-item.tx-income::before {
    background: #10b981;
}

.tx-item.tx-expense::before {
    background: #ef4444;
}

.tx-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tx-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.tx-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tx-item-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.tx-item-desc {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-item-amount {
    font-weight: 700;
    font-size: var(--font-size-base);
    white-space: nowrap;
}

.tx-item-sub-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    opacity: 0.6;
}

.tx-item-meta {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-item-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.tx-item:hover .tx-item-actions {
    opacity: 1;
}

.tx-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.tx-badge-executed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.tx-badge-pending-manual {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.tx-badge-pending-rec {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

/* Balance Projection Styles */
.text-projected {
    font-style: italic;
    color: #f59e0b !important; /* Elegant Amber/Orange highlight */
    position: relative;
}

:root[data-theme="light"] .text-projected {
    color: #d97706 !important; /* Slightly darker amber for light theme readability */
}

.projection-badge {
    display: inline-block;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    margin-left: 6px;
    font-weight: 700;
    vertical-align: middle;
    text-transform: uppercase;
    font-style: normal;
}

:root[data-theme="light"] .projection-badge {
    background: rgba(217, 119, 6, 0.1);
    color: #d97706;
}

/* Calendar View */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: calc(8px * var(--space-scale, 1));
}

.cal-day-header {
    text-align: center;
    font-weight: 600;
    font-size: var(--font-size-base);
    opacity: 0.7;
    margin-bottom: calc(8px * var(--space-scale, 1));
}

.calendar-day {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: calc(8px * var(--space-scale, 1));
    min-height: 80px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.calendar-day.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.day-number {
    font-weight: bold;
    font-size: var(--font-size-base);
    margin-bottom: auto;
}

.day-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.calendar-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

@keyframes pulse-today {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); border-color: rgba(59, 130, 246, 0.8); }
    70% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); border-color: rgba(59, 130, 246, 0.3); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); border-color: var(--border-color); }
}

.calendar-day.today {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary-color);
    animation: pulse-today 2.5s infinite;
}

.calendar-day.today .day-number {
    color: var(--primary-color);
}

.calendar-event-block {
    font-size: var(--font-size-sm);
    padding: 2px 4px;
    border-radius: 4px;
    margin-top: 4px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    color: #fff;
    opacity: 0.9;
}

/* ==========================================================================
   CUSTOM HIERARCHICAL TREE SELECTOR (Folder selector in Task Modal)
   ========================================================================== */
.custom-tree-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-tree-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: var(--task-input-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: calc(12px * var(--space-scale, 1)) 14px;
    border-radius: 12px;
    font-size: var(--font-size-base);
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-tree-trigger:hover {
    border-color: var(--primary-color);
}

.custom-tree-select.open .custom-tree-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.custom-tree-trigger-text {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    min-width: 0;
}

.custom-tree-trigger-text > * {
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-tree-trigger-arrow {
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.25s ease;
    margin-left: 8px;
}

.custom-tree-select.open .custom-tree-trigger-arrow {
    transform: rotate(180deg);
}

.custom-tree-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    background: linear-gradient(135deg, var(--panel-bg-start) 0%, var(--panel-bg-end) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
    z-index: 1000;
    padding: 6px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-tree-select.open .custom-tree-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.custom-tree-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-size: calc(13.5px * var(--text-scale, 1));
    color: var(--text-color);
}

.custom-tree-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.custom-tree-option.selected {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    font-weight: 700;
}

.custom-tree-option-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-grow: 1;
    min-width: 0;
}

.custom-tree-option-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-tree-option-right {
    display: none;
    font-size: var(--font-size-sm);
    color: #10b981;
    font-weight: bold;
    margin-left: 8px;
}

.selected .custom-tree-option-right,
.custom-tree-node-row.selected .custom-tree-option-right {
    display: block;
}

/* Tree specific styles */
.custom-tree-node {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.custom-tree-node-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    border-radius: 8px;
    transition: background 0.2s;
    padding-right: 12px;
    box-sizing: border-box;
}

.custom-tree-node-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.custom-tree-node-row.selected {
    background: rgba(59, 130, 246, 0.15);
}

.custom-tree-node-row.selected .custom-tree-option-left {
    color: var(--primary-color);
    font-weight: 700;
}

.custom-tree-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 8px;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.25s ease;
}

.custom-tree-toggle:hover {
    opacity: 1;
}

.custom-tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.custom-tree-children {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 12px;
    border-left: 1px dashed rgba(255, 255, 255, 0.06);
    margin-left: 14px;
    transition: all 0.3s ease;
}

.custom-tree-children.collapsed {
    display: none;
}

/* ==========================================================================
   RADIO POC HYTERA LINK (Settings & Status Badges)
   ========================================================================== */
.radio-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    margin: 0;
}
.radio-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.radio-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.18);
    transition: all 0.25s ease;
    border-radius: 26px;
    border: 1px solid var(--border-color);
}
.radio-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.radio-switch input:checked + .radio-slider {
    background-color: #10b981;
    border-color: #10b981;
}
.radio-switch input:checked + .radio-slider:before {
    transform: translateX(22px);
}