/**
 * Easyfan Design System
 * Source of truth: wins-methodology.html
 *
 * Usage: Add <link rel="stylesheet" href="/static/css/design-system.css"> to templates
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    /* Brand Colors */
    --sidebar-bg: #0A1128;
    --sidebar-active: #1282A2;
    --header-grad-start: #1282A2;
    --header-grad-end: #00ADEE;
    --accent-teal: #1282A2;
    --accent-navy: #001F54;
    --main-turquoise: #00ADEE;
    --main-dark-royal: #034078;

    /* UI Colors */
    --content-bg: #F5F7FA;
    --card-white: #FFFFFF;
    --text-dark: #001F54;
    --text-muted: #6B7280;
    --border-light: rgba(0, 31, 84, 0.1);

    /* Semantic Colors */
    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #EF4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3B82F6;
    --info-bg: rgba(59, 130, 246, 0.15);
    --auth-focus-ring: rgba(18, 130, 162, 0.15);

    /* Layout */
    --sidebar-width: 256px;
    --sidebar-width-collapsed: 64px;
    --sidebar-transition: 200ms ease;
    --header-height: 80px;

    /* Spacing */
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 31, 84, 0.06);
    --shadow-md: 0 2px 12px rgba(0, 31, 84, 0.08);
    --shadow-lg: 0 4px 20px rgba(0, 31, 84, 0.12);

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-2xl: 32px;

    /* KPI Strip Tokens (Phase 51 — Mission Control Landing Page Redesign) */
    --kpi-card-min-width: 200px;
    --kpi-card-gap: var(--space-lg);
    --kpi-card-padding: var(--space-md);
    --kpi-number-size: 30px;
    --kpi-label-size: var(--font-size-sm);

    /* Status System Tokens (Phase 51) */
    --status-healthy: var(--success);
    --status-warning: var(--warning);
    --status-critical: var(--danger);
    --status-running: var(--info);
    --status-pending: #6B7280;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;

    /* W.I.N.S. Domain Colors */
    --domain-wins: #1282A2;
    --domain-crm: #00ADEE;
    --domain-comm: #3B82F6;
    --domain-content: #8B5CF6;
    --domain-compliance: #EF4444;
    --domain-onboarding: #F59E0B;
    --domain-revenue: #10B981;
    --domain-voice: #06B6D4;
    --domain-coreoffer: #EC4899;
    --domain-reporting: #6366F1;
    --domain-community: #14B8A6;

    /* Pipeline Stage Colors */
    --stage-attract: #1282A2;
    --stage-convert: #00ADEE;
    --stage-expand: #10B981;

    /* W.I.N.S. Pillar Gradients */
    --pillar-w: linear-gradient(135deg, #1282A2, #034078);
    --pillar-i: linear-gradient(135deg, #00ADEE, #1282A2);
    --pillar-n: linear-gradient(135deg, #034078, #001F54);
    --pillar-s: linear-gradient(135deg, #001F54, #0A1128);

    /* Dashboard Design Tokens (Phase 2) */
    --card-padding: 28px;
    --section-gap: 32px;
    --stat-number-size: 28px;
    --status-dot-size: 8px;
    --progress-bar-height: 6px;
    --left-border-width: 2px;
}

[data-theme="easyfan-dark"] {
    --text-dark: #E5E7EB;
    --text-muted: #9CA3AF;
    --content-bg: #0A1128;
    --card-white: #001F54;
    --border-light: rgba(229, 231, 235, 0.12);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

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

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    color: var(--text-dark);
    background: var(--content-bg);
    line-height: 1.6;
}

/* ==========================================================================
   Layout Components
   ========================================================================== */

/* App Container - Sidebar + Main Content */
/* [MIGRATED to Tailwind — Plan 07-01] .app-container now uses the DaisyUI
   `drawer lg:drawer-open min-h-screen bg-base-100` utility classes in
   base.html; this rule is superseded (the drawer's CSS grid layout replaces
   the old flex model).
.app-container {
    display: flex;
    min-height: 100vh;
}
*/

/* Sidebar */
.sidebar {
    /* !important required: DaisyUI's compiled @media(min-width:1024px)
       .lg\:drawer-open>.drawer-toggle~.drawer-side rule (specificity 0,3,0,
       from the Plan 07-01 drawer/grid migration) sets width:auto, display:block,
       and overflow-y:auto, otherwise winning over this rule (0,1,0) at desktop
       viewports and breaking sidebar collapse/expand + flex scrolling. */
    width: var(--sidebar-width) !important;
    background: var(--sidebar-bg);
    padding: var(--space-sm) var(--space-md) var(--space-md);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow: visible;
    z-index: 100;
    transition: width var(--transition-normal), padding var(--transition-normal);
}

/* Desktop DaisyUI specificity override: keep .sidebar a true flex column with
   visible overflow (so profile flyouts are never clipped) and delegate scrolling
   exclusively to .sidebar-nav. Scoped to >=1024px so mobile drawer is untouched. */
@media (min-width: 1024px) {
    .lg\:drawer-open > .drawer-toggle ~ .drawer-side.sidebar {
        display: flex !important;
        flex-direction: column !important;
        overflow: visible !important;
    }
}

/* DaisyUI drawer-overlay is a hamburger-close label — on desktop it serves
   no purpose but DaisyUI leaves pointer-events:auto, which can block clicks
   on content if the overlay's box extends beyond the sidebar bounds. */
.sidebar .drawer-overlay {
    pointer-events: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Ensure main content creates its own stacking context so sidebar z-index
   (100) cannot interfere with content-area click targets. */
.drawer-content {
    position: relative;
    z-index: 1;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 4px 12px;
    margin-bottom: var(--space-xs);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    padding: 0;
    margin: 0;
}

.sidebar-logo-full {
    max-width: 128px;
    height: auto;
    display: block;
}

.sidebar-logo-mark {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
}

/* Mode toggle (Full View / My View) */
.sidebar-mode-toggle {
    display: flex;
    gap: 2px;
    margin: 0 var(--space-xs) var(--space-sm);
    padding: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
}

.mode-toggle-btn {
    flex: 1;
    padding: 6px 8px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.5);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.mode-toggle-btn.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.mode-toggle-btn:hover:not(.active) {
    color: rgba(255,255,255,0.8);
}

.sidebar.collapsed .sidebar-mode-toggle {
    display: none;
}

/* Client Picker (Phase 50) */
.sidebar-client-picker {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.client-picker-breadcrumb {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(18, 130, 162, 0.15);
    border-radius: var(--radius-sm, 6px);
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm, 13px);
    color: inherit;
}
.client-picker-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.client-picker-exit {
    opacity: 0.7;
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    padding: 0 0 0 var(--space-xs);
    text-decoration: none;
}
.client-picker-exit:hover {
    opacity: 1;
}
.sidebar .client-picker-select,
.sidebar .client-picker-select.select {
    width: 100%;
    background: rgba(255,255,255,0.12) !important;
    color: #f3f4f6 !important;
    border: 1.5px solid rgba(255,255,255,0.35) !important;
    border-radius: var(--radius-sm, 6px);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    min-height: 2.5rem;
    height: auto;
    line-height: 1.4;
}
.sidebar .client-picker-select option {
    background: #1f2937;
    color: #f3f4f6;
}
.sidebar.collapsed .sidebar-client-picker {
    display: none;
}

/* Hide admin sections when sidebar is in "my" mode.
   html.sidebar-mode-my fires before paint (set in <head>);
   data-attribute rule kept for JS-driven toggles post-load. */
.sidebar-mode-my .sidebar-admin-sections,
.sidebar[data-sidebar-active-mode="my"] .sidebar-admin-sections {
    display: none;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding-bottom: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

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

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

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-xs);
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    position: relative;
}

.sidebar .nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar .nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: var(--space-md) 0;
}

.sidebar .nav-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    padding: 4px 16px 4px;
    margin-top: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: color var(--transition-fast);
}

.sidebar .nav-section-label:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* Section chevron indicator */
.section-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.section-chevron.expanded {
    transform: rotate(90deg);
}

/* Collapsible section items container */
.nav-section-items {
    overflow: hidden;
    transition: max-height 0.25s ease;
    list-style: none;
    padding-left: 0;
}

.nav-section-items.collapsed {
    max-height: 0 !important;
    overflow: hidden;
}

/* Sidebar badge (notification dot / number) */
.sidebar-badge {
    display: none;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-badge.sidebar-badge-dot,
.sidebar-badge.sidebar-badge-number {
    display: inline-flex;
}

.sidebar-badge.sidebar-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger, #EF4444);
}

.sidebar-badge.sidebar-badge-number {
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--danger, #EF4444);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.sidebar-footer {
    padding-top: var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.sidebar-profile img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-profile-info {
    color: #fff;
}

.sidebar-profile-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.sidebar-profile-role {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.6);
}

.admin-badge {
    display: inline-block;
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 5px;
    border-radius: var(--radius-sm, 4px);
    margin-left: 4px;
    vertical-align: middle;
}

.admin-avatar {
    box-shadow: 0 0 0 2px #ffc107;
}

/* ==========================================================================
   Sidebar Toggle Button (Header-Integrated, Notion/Linear Style — v96.0)
   ========================================================================== */

.sidebar-toggle {
    position: relative;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    padding: 0;
    opacity: 1;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
                transform 0.15s ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
    outline: none;
}

.sidebar-toggle:active {
    transform: scale(0.94);
}

.sidebar-toggle-chevron {
    transition: transform 0.2s ease;
    transform-origin: 13.5px 12px;
}

.sidebar.collapsed .sidebar-toggle-chevron,
html.sidebar-is-collapsed .sidebar .sidebar-toggle-chevron {
    transform: rotate(180deg);
}

/* ==========================================================================
   Sidebar Collapsed State (toggle or responsive — mirrored for FOUC parity)
   ========================================================================== */

.sidebar.collapsed,
html.sidebar-is-collapsed .sidebar {
    /* !important required: see note on .sidebar base rule above — DaisyUI's
       lg:drawer-open>.drawer-toggle~.drawer-side (0,3,0) otherwise beats
       this rule (0,2,0) at desktop viewports. */
    width: var(--sidebar-width-collapsed) !important;
    padding: var(--space-xs);
}

.sidebar.collapsed .sidebar-header,
html.sidebar-is-collapsed .sidebar .sidebar-header {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 6px 0 10px;
}

.sidebar.collapsed .sidebar-logo-full,
html.sidebar-is-collapsed .sidebar .sidebar-logo-full {
    display: none;
}

.sidebar.collapsed .sidebar-logo-mark,
html.sidebar-is-collapsed .sidebar .sidebar-logo-mark {
    display: block;
}

.sidebar.collapsed .sidebar-nav,
html.sidebar-is-collapsed .sidebar .sidebar-nav {
    scrollbar-width: none;
}

.sidebar.collapsed .sidebar-nav::-webkit-scrollbar,
html.sidebar-is-collapsed .sidebar .sidebar-nav::-webkit-scrollbar {
    width: 0;
    display: none;
}

.sidebar.collapsed .nav-item,
html.sidebar-is-collapsed .sidebar .nav-item {
    justify-content: center;
    padding: 8px;
    position: relative;
}

.sidebar.collapsed .nav-item > span:not(.nav-item-icon):not(.sidebar-badge),
html.sidebar-is-collapsed .sidebar .nav-item > span:not(.nav-item-icon):not(.sidebar-badge) {
    display: none;
}

.sidebar.collapsed .sidebar-profile-info,
.sidebar.collapsed .dropdown-arrow,
html.sidebar-is-collapsed .sidebar .sidebar-profile-info,
html.sidebar-is-collapsed .sidebar .dropdown-arrow {
    display: none;
}

.sidebar.collapsed .sidebar-client-picker,
html.sidebar-is-collapsed .sidebar .sidebar-client-picker {
    display: none;
}

.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-section-items.collapsed,
html.sidebar-is-collapsed .sidebar .nav-section-label,
html.sidebar-is-collapsed .sidebar .nav-section-items.collapsed {
    display: none;
}

/* In collapsed sidebar, show all items (no section collapsing) */
.sidebar.collapsed .nav-section-items,
html.sidebar-is-collapsed .sidebar .nav-section-items {
    display: block;
}

/* Override DaisyUI .menu :where(li ul) margin/padding AND hide stray vertical
   tree-connector guide line (::before) in collapsed 64px rail */
.sidebar.collapsed .nav-section-items.menu,
html.sidebar-is-collapsed .sidebar .nav-section-items.menu {
    margin-inline-start: 0;
    padding-inline-start: 0;
}

.sidebar.collapsed .nav-section-items.menu::before,
html.sidebar-is-collapsed .sidebar .nav-section-items.menu::before {
    display: none !important;
}

.sidebar.collapsed .nav-divider,
html.sidebar-is-collapsed .sidebar .nav-divider {
    width: 24px;
    margin: 8px auto;
}

/* Compact 6px indicator dot for active badges in collapsed rail */
.sidebar.collapsed .sidebar-badge.sidebar-badge-dot,
.sidebar.collapsed .sidebar-badge.sidebar-badge-number,
html.sidebar-is-collapsed .sidebar .sidebar-badge.sidebar-badge-dot,
html.sidebar-is-collapsed .sidebar .sidebar-badge.sidebar-badge-number {
    display: block !important;
    position: absolute;
    top: 5px;
    right: 9px;
    width: 6px;
    height: 6px;
    min-width: 6px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    background: var(--danger, #EF4444);
    margin-left: 0;
}

.sidebar.collapsed .sidebar-profile,
html.sidebar-is-collapsed .sidebar .sidebar-profile {
    justify-content: center;
}

.sidebar.collapsed .sidebar-profile img,
html.sidebar-is-collapsed .sidebar .sidebar-profile img {
    width: 32px;
    height: 32px;
}

/* Profile dropdown opens as a 210px flyout to the right when collapsed */
.sidebar.collapsed .profile-dropdown,
html.sidebar-is-collapsed .sidebar .profile-dropdown {
    left: calc(100% + 10px);
    right: auto;
    bottom: 8px;
    width: 210px;
    z-index: 250;
}

/* Floating body-level tooltip for collapsed rail (unclipped by .sidebar-nav overflow) */
#sidebar-floating-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    background: var(--sidebar-bg, #0A1128);
    color: #fff;
    padding: 6px 11px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.14);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

#sidebar-floating-tooltip.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Disable clipped CSS ::after/::before tooltips when JS floating tooltip is active */
html.has-floating-sidebar-tooltip .sidebar.collapsed .nav-item::after,
html.has-floating-sidebar-tooltip .sidebar.collapsed .nav-item::before,
html.has-floating-sidebar-tooltip .sidebar.collapsed .sidebar-favorites .fav-item::after {
    display: none !important;
}

/* [MIGRATED to Tailwind — Plan 07-01] .main-content is now a CSS-grid
   `drawer-content` item (base.html); the grid track automatically reserves
   space for the sidebar column, so margin-left offsetting is obsolete and
   would double-count the gap when the sidebar is collapsed.
.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-width-collapsed);
}
*/

/* Fallback CSS Tooltips when collapsed (if JS tooltip unavailable) */
.sidebar.collapsed .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateX(8px) translateY(-50%);
    background: var(--sidebar-bg, #0A1128);
    color: #fff;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar.collapsed .nav-item::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--sidebar-bg, #0A1128);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    z-index: 1001;
}

.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-item:hover::before {
    opacity: 1;
    visibility: visible;
}

.sidebar.collapsed .nav-item:not([data-label])::after,
.sidebar.collapsed .nav-item:not([data-label])::before {
    display: none;
}

/* [MIGRATED to Tailwind — Plan 07-01] see note above .sidebar.collapsed + .main-content
html.sidebar-is-collapsed .main-content {
    margin-left: var(--sidebar-width-collapsed);
}
*/

/* Main Content Area */
/* [MIGRATED to Tailwind — Plan 07-01] .main-content now uses
   `drawer-content flex-1 overflow-x-hidden p-6 transition-all duration-300`
   Tailwind utility classes in base.html (see .app-container note above).
.main-content {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    margin-left: var(--sidebar-width);
    background: var(--content-bg);
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}
*/

/* Header Bar */
/* [MIGRATED to Tailwind — Plan 07-01] .header-bar/h1/p now use Tailwind
   utility classes (`flex items-center justify-between mb-6`,
   `text-2xl font-bold text-base-content`, `text-sm text-base-content/60`)
   applied directly in base.html and the 3 templates that override
   {% block header %} with their own .header-bar markup
   (ghl-tasks.html, customer_dashboard.html, blog-articles.html).
.header-bar {
    background: linear-gradient(135deg, var(--header-grad-start) 0%, var(--header-grad-end) 100%);
    padding: var(--space-lg) var(--space-xl);
    color: #fff;
}

.header-bar h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.header-bar p {
    font-size: var(--font-size-sm);
    opacity: 0.9;
}
*/

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-text {
    flex: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.btn-scheduled-jobs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    background: var(--card-white);
    color: #0B3D54;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}
.btn-scheduled-jobs svg { stroke: #0B3D54; }

.btn-scheduled-jobs:hover {
    background: var(--card-white);
    color: #0B3D54;
    border-color: var(--accent-teal);
}
[data-theme="easyfan-dark"] .btn-scheduled-jobs {
    background: rgba(255, 255, 255, 0.08);
    color: #E5E7EB;
    border-color: rgba(255, 255, 255, 0.15);
}
[data-theme="easyfan-dark"] .btn-scheduled-jobs svg { stroke: #E5E7EB; }
[data-theme="easyfan-dark"] .btn-scheduled-jobs:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-muted);
}

.btn-login,
.btn-logout {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-login {
    background: var(--accent-teal);
    color: #ffffff;
    border: 2px solid var(--accent-teal);
    font-weight: 600;
}

.btn-login:hover {
    background: #0e6d87;
    border-color: #0e6d87;
}

.btn-logout {
    background: var(--card-white);
    color: #0B3D54;
    border: 1px solid var(--border-light);
}

.btn-logout:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}
[data-theme="easyfan-dark"] .btn-logout {
    background: rgba(255, 255, 255, 0.08);
    color: #E5E7EB;
    border-color: rgba(255, 255, 255, 0.15);
}
[data-theme="easyfan-dark"] .btn-logout:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
    border-color: rgba(220, 38, 38, 0.3);
}

/* Dark Mode Toggle (header) */
.dark-mode-toggle {
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 6px 8px;
    cursor: pointer;
    color: var(--text-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.dark-mode-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
}
[data-theme="easyfan-dark"] .dark-mode-toggle {
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.8);
}
[data-theme="easyfan-dark"] .dark-mode-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Content Wrapper */
.content-wrapper {
    padding: var(--space-xl);
}

/* ==========================================================================
   Card Components
   ========================================================================== */

.card {
    background: var(--card-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-dark);
}

.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* Gradient Metric Cards */
.card-gradient {
    background: linear-gradient(135deg, var(--accent-teal) 0%, var(--main-dark-royal) 100%);
    color: #fff;
}

.card-gradient.teal {
    background: linear-gradient(135deg, #1282A2 0%, #034078 100%);
}

.card-gradient.turquoise {
    background: linear-gradient(135deg, #00ADEE 0%, #1282A2 100%);
}

.card-gradient.navy {
    background: linear-gradient(135deg, #034078 0%, #001F54 100%);
}

.card-gradient.dark {
    background: linear-gradient(135deg, #001F54 0%, #0A1128 100%);
}

.card-gradient .card-title,
.card-gradient .card-subtitle {
    color: #fff;
}

.card-gradient .card-subtitle {
    opacity: 0.8;
}

/* ==========================================================================
   Grid System
   ========================================================================== */

.grid {
    display: grid;
    gap: var(--space-lg);
}
/* .grid-2, .grid-3, .grid-4 removed Plan 07-05 (0 references) */

/* ==========================================================================
   Button Components
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-lg);
    border-radius: 25px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-teal), var(--main-turquoise));
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--card-white);
    color: var(--accent-teal);
    border: 1px solid var(--accent-teal);
}

.btn-secondary:hover {
    background: var(--accent-teal);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: rgba(0, 31, 84, 0.05);
    color: var(--text-dark);
}

/* Quick Action Buttons (index.html style) */
.quick-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--accent-navy);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    text-decoration: none;
    font-size: var(--font-size-xs);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.quick-btn:hover {
    background: var(--accent-teal);
    transform: translateY(-1px);
}

/* ==========================================================================
   Badge Components
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-xl);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-neutral {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

/* ==========================================================================
   Table Components
   ========================================================================== */

.table-container {
    overflow-x: auto;
}

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

.table th {
    background: var(--accent-teal);
    color: #fff;
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.table th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.table th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-size-sm);
    color: var(--text-dark);
}

.table tr:hover td {
    background: rgba(18, 130, 162, 0.05);
}

/* ==========================================================================
   Form Components
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-dark);
}

.form-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--text-dark);
    background: var(--card-white);
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 3px rgba(18, 130, 162, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

[data-theme="easyfan-dark"] .form-input:focus {
    box-shadow: 0 0 0 3px rgba(18, 130, 162, 0.25);
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.progress {
    height: 8px;
    background: rgba(0, 31, 84, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-teal), var(--main-turquoise));
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.progress-bar.success {
    background: var(--success);
}

.progress-bar.warning {
    background: var(--warning);
}

.progress-bar.danger {
    background: var(--danger);
}

/* ==========================================================================
   Metric Display
   ========================================================================== */

.metric {
    text-align: center;
}

.metric-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.metric-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.metric-trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    margin-top: var(--space-xs);
}

.metric-trend.up {
    color: var(--success);
}

.metric-trend.down {
    color: var(--danger);
}

/* ==========================================================================
   Status Indicators
   ========================================================================== */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    display: inline-block;
}

.status-dot.online {
    background: var(--success);
}

.status-dot.offline {
    background: var(--danger);
}

.status-dot.pending {
    background: var(--warning);
}

/* ==========================================================================
   KPI Strip (Phase 51 — Mission Control Landing Page Redesign)
   Stripe/Linear pattern: 4-6 cards above the fold, primary number 28-32px,
   trend indicator, semantic status shape+color+text.
   ========================================================================== */

.kpi-strip {
    display: flex;
    flex-wrap: wrap;
    gap: var(--kpi-card-gap);
    margin-bottom: var(--space-lg);
}

.kpi-card {
    flex: 1 1 var(--kpi-card-min-width);
    background: oklch(var(--b1));
    border: 1px solid oklch(var(--bc) / 0.2);
    border-radius: var(--radius-md);
    padding: var(--kpi-card-padding);
    display: flex;
    flex-direction: column;
    transition: background-color 200ms ease;
}

.kpi-card-value {
    font-size: var(--kpi-number-size);
    font-weight: 700;
    line-height: 1.2;
    color: oklch(var(--bc));
}

.kpi-card-label {
    font-size: var(--kpi-label-size);
    color: oklch(var(--bc) / 0.6);
    margin-top: 4px;
}

.kpi-card-trend {
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

.kpi-card-trend--up {
    color: var(--status-critical);
}

.kpi-card-trend--down {
    color: var(--status-healthy);
}

.kpi-card-trend--flat {
    color: oklch(var(--bc) / 0.4);
}

.kpi-card--error {
    border-color: var(--status-critical);
    opacity: 0.7;
}

.kpi-card--loading {
    align-items: center;
    justify-content: center;
    min-height: 88px;
    animation: kpi-card-pulse 1.5s ease-in-out infinite;
}

@keyframes kpi-card-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.status-shape {
    width: 10px;
    height: 10px;
    display: inline-block;
    flex-shrink: 0;
}

.status-shape--circle {
    border-radius: 50%;
}

.status-shape--diamond {
    transform: rotate(45deg);
    border-radius: 2px;
    width: 9px;
    height: 9px;
}

.status-shape--square {
    border-radius: 2px;
}

.status-indicator--inline {
    display: inline-flex;
    vertical-align: middle;
    font-size: 11px;
}

.status-indicator--sm {
    gap: 4px;
    font-size: 10px;
}

.status-indicator--sm .status-shape {
    width: 7px;
    height: 7px;
}

/* Static "pending" placeholder shown before JS populates a real status via
   createStatusIndicator()'s inline style (color is data-driven at runtime
   for the other 4 states, so this is the one state worth a fixed class). */
.status-shape--pending-default {
    background: var(--status-pending);
}

/* ==========================================================================
   Widget States (Phase 51 Plan 02 — per-widget loading/empty/error)
   Every tab panel owns its own boundary via widgetErrorBoundary() so one
   failing fetch never blanks sibling widgets or the KPI strip.
   ========================================================================== */

.widget-error {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: oklch(var(--bc) / 0.5);
    border: 1px dashed var(--status-critical);
    border-radius: var(--radius-md);
    background-color: rgba(239, 68, 68, 0.03);
}

.widget-error-icon {
    width: 32px;
    height: 32px;
    margin: 0 auto var(--space-xs);
    opacity: 0.5;
}

.widget-error-message {
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-xs);
}

.widget-error-retry {
    font-size: 12px;
    cursor: pointer;
    color: var(--sidebar-active);
    text-decoration: underline;
}

.widget-empty {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    color: oklch(var(--bc) / 0.4);
}

.widget-loading {
    text-align: center;
    padding: var(--space-xl);
    color: oklch(var(--bc) / 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    padding: var(--space-lg) var(--space-xl);
    text-align: center;
    border-top: 1px solid var(--border-light);
    margin-top: var(--space-xl);
}

.footer-logo img {
    height: 30px;
    margin-bottom: var(--space-sm);
}

.footer-text {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* ==========================================================================
   Utility Classes (survivors — referenced by non-migrated templates)
   Tailwind-duplicate utilities (.flex, .items-center, etc.) removed Plan 07-05.
   Unused spacing utilities (.gap-sm/md/lg, .p-sm/md/lg, .mt-lg, .mb-sm) removed.
   ========================================================================== */

/* Text — still referenced by 320+ templates/JS modules */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* Spacing — still referenced by non-migrated admin templates */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1024px) {
    /* Force collapsed state at narrow widths; hide toggle */
    .sidebar {
        width: var(--sidebar-width-collapsed) !important;
        padding: var(--space-xs) !important;
    }

    .sidebar-toggle,
    .sidebar-mode-toggle {
        display: none !important;
    }

    .sidebar-logo img {
        max-width: 44px;
    }

    .nav-item > span:not(.nav-item-icon),
    .sidebar-profile-info {
        display: none !important;
    }

    .nav-section-label {
        display: none !important;
    }

    .nav-section-items,
    .nav-section-items.collapsed {
        display: block !important;
    }

    .nav-section-items.menu {
        margin-inline-start: 0;
        padding-inline-start: 0;
    }

    .sidebar-badge {
        display: none !important;
    }

    .nav-item {
        justify-content: center;
        padding: var(--space-xs);
        position: relative;
    }

    .sidebar-profile {
        justify-content: center;
    }

    .dropdown-arrow {
        display: none !important;
    }

    /* Sidebar tooltip for collapsed nav items */
    .nav-item::after {
        content: attr(data-label);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateX(8px) translateY(-50%);
        background: var(--sidebar-bg, #0A1128);
        color: #fff;
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        font-size: var(--font-size-xs);
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-fast), visibility var(--transition-fast);
        z-index: 1000;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-item::before {
        content: '';
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        border: 6px solid transparent;
        border-right-color: var(--sidebar-bg, #0A1128);
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-fast), visibility var(--transition-fast);
        z-index: 1001;
    }

    .nav-item:hover::after,
    .nav-item:hover::before {
        opacity: 1;
        visibility: visible;
    }

    .nav-item:not([data-label])::after,
    .nav-item:not([data-label])::before {
        display: none;
    }

    .main-content {
        margin-left: var(--sidebar-width-collapsed) !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .header-bar {
        padding: var(--space-md);
    }

    .content-wrapper {
        padding: var(--space-md);
    }
}

/* ==========================================================================
   Loading & Spinner Components
   ========================================================================== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-xl);
    color: var(--text-muted);
}

.loading.show {
    display: flex;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(245, 247, 250, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner,
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(18, 130, 162, 0.2);
    border-top-color: var(--accent-teal);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg,
.loading-spinner.lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

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

.loading-text {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-top: var(--space-md);
}

/* ==========================================================================
   Modal Component
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.modal-overlay.active,
.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--card-white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content.wide {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: var(--space-md);
    color: var(--text-dark);
}

.modal-text {
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    font-size: var(--font-size-sm);
}

/* ==========================================================================
   Tabs Component
   ========================================================================== */

.tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.tab,
.tabs-boxed .tab.mc-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    height: 2.25rem;
    padding: 0 var(--space-md);
    line-height: 1;
    flex-wrap: nowrap;
    background: var(--card-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
    color: var(--text-dark);
    font-size: var(--font-size-sm);
}

.tab:hover {
    border-color: var(--accent-teal);
}

.tab.active {
    background: linear-gradient(135deg, var(--accent-teal), var(--main-turquoise));
    color: #fff;
    border-color: transparent;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==========================================================================
   Dashboard Grid
   ========================================================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-lg);
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Agent List Components
   ========================================================================== */

.agent-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.agent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--content-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.agent-item:hover {
    border-color: var(--accent-teal);
}

.agent-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.agent-emoji {
    font-size: 20px;
}

.agent-name {
    font-weight: 600;
    color: var(--text-dark);
}

.agent-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* ==========================================================================
   Response Box (API responses, code output)
   ========================================================================== */

.response-box {
    background: var(--content-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-md);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    white-space: pre-wrap;
    word-break: break-word;
}

.response-box.show {
    display: block;
}

.response-box.success {
    color: var(--success);
}

.response-box.error {
    color: var(--danger);
}

/* ==========================================================================
   Dark Theme Variant (for pages that need dark backgrounds)
   ========================================================================== */

.theme-dark {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #fff;
    min-height: 100vh;
}

.theme-dark .card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-dark .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.theme-dark .card-title {
    color: #fff;
}

.theme-dark .text-muted {
    color: rgba(255, 255, 255, 0.7);
}

/* Dark theme form inputs */
.theme-dark .form-group input,
.theme-dark .form-group textarea,
.theme-dark .form-group select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
}

.theme-dark .form-group input:focus,
.theme-dark .form-group textarea:focus,
.theme-dark .form-group select:focus {
    outline: none;
    border-color: var(--accent-teal);
}

.theme-dark .form-group input::placeholder,
.theme-dark .form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.theme-dark .form-group label {
    color: rgba(255, 255, 255, 0.8);
}

.theme-dark .form-group small {
    color: rgba(255, 255, 255, 0.5);
}

/* Dark theme buttons */
.theme-dark .btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.theme-dark .btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.theme-dark .btn-primary {
    background: linear-gradient(135deg, var(--accent-teal), var(--main-turquoise));
    border: none;
}

/* Dark theme status badges */
.theme-dark .status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.theme-dark .status-badge.success {
    background: rgba(46, 213, 115, 0.2);
    color: #2ed573;
}

.theme-dark .status-badge.error {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
}

.theme-dark .status-badge.pending {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

/* Dark theme log output */
.theme-dark .log-output {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.theme-dark .log-output .success { color: #2ed573; }
.theme-dark .log-output .error { color: #ff4757; }
.theme-dark .log-output .info { color: var(--accent-teal); }

/* Dark theme links */
.theme-dark a {
    color: var(--main-turquoise);
}

.theme-dark a:hover {
    text-decoration: underline;
}

/* Dark theme header/footer borders */
.theme-dark header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-dark footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
}

.theme-dark .subtitle {
    color: rgba(255, 255, 255, 0.6);
}

/* ==========================================================================
   Card Hover Lift (reusable utility)
   ========================================================================== */

.card-hover-lift {
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Accessibility Utilities
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Sidebar Profile Dropdown
   ========================================================================== */

.profile-dropdown {
    position: absolute;
    bottom: 100%;
    left: 8px;
    right: 8px;
    background: var(--sidebar-bg, #0A1128);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 0;
    margin-bottom: 8px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.profile-dropdown a {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
}

.profile-dropdown a:hover {
    background: var(--sidebar-active, #1282A2);
}

.profile-dropdown .logout-link {
    color: #ef4444;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 4px;
    padding-top: 14px;
}

.profile-dropdown .logout-link:hover {
    background: rgba(239, 68, 68, 0.2);
}

.sidebar-footer {
    position: relative;
    flex-shrink: 0;
    background: var(--sidebar-bg, #0A1128);
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-login-prompt {
    transition: all 0.3s ease;
}

.sidebar-login-prompt:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transform: translateX(4px);
}

@keyframes subtle-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.sidebar-login-prompt .login-icon {
    animation: subtle-pulse 3s ease-in-out infinite;
}

/* ==========================================================================
   Sidebar Favorites Strip
   ========================================================================== */

.sidebar-favorites {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 var(--space-xs) var(--space-sm);
    padding: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    min-height: 0;
}

.sidebar-favorites:empty {
    display: none;
}

.sidebar-favorites .fav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    position: relative;
}

.sidebar-favorites .fav-item:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.sidebar-favorites .fav-item.active {
    background: var(--sidebar-active, #1282A2);
    color: #fff;
}

.sidebar-favorites .fav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.sidebar-favorites .fav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-favorites .fav-unpin {
    display: none;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 4px;
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.sidebar-favorites .fav-item:hover .fav-unpin {
    display: flex;
}

.sidebar-favorites .fav-unpin:hover {
    background: rgba(239,68,68,0.4);
    color: #fff;
}

.sidebar .nav-item .pin-btn {
    display: none;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 4px;
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    z-index: 2;
}

.sidebar .nav-item:hover .pin-btn {
    display: flex;
}

.sidebar .nav-item .pin-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.sidebar .nav-item .pin-btn.pinned {
    color: var(--sidebar-active, #1282A2);
}

.sidebar.collapsed .sidebar-favorites {
    margin: 0 4px var(--space-xs);
    padding: 4px;
}

.sidebar.collapsed .sidebar-favorites .fav-label {
    display: none;
}

.sidebar.collapsed .sidebar-favorites .fav-unpin {
    display: none !important;
}

.sidebar.collapsed .sidebar-favorites .fav-item {
    justify-content: center;
    padding: 6px;
    position: relative;
}

.sidebar.collapsed .sidebar-favorites .fav-item::after {
    content: attr(data-label);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 12px;
    padding: 6px 12px;
    background: var(--sidebar-bg, #0A1128);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    z-index: 9999;
}

.sidebar.collapsed .sidebar-favorites .fav-item::before {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 4px;
    border: 4px solid transparent;
    border-right-color: var(--sidebar-bg, #0A1128);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    z-index: 9999;
}

.sidebar.collapsed .sidebar-favorites .fav-item:hover::after,
.sidebar.collapsed .sidebar-favorites .fav-item:hover::before {
    opacity: 1;
    visibility: visible;
}

.sidebar.collapsed .sidebar-favorites .fav-icon svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 1024px) {
    .sidebar-favorites .fav-label {
        display: none !important;
    }
    .sidebar-favorites .fav-unpin {
        display: none !important;
    }
    .sidebar-favorites .fav-item {
        justify-content: center;
        padding: 6px;
        position: relative;
    }
    .sidebar-favorites {
        margin: 0 4px var(--space-xs);
        padding: 4px;
    }
    .sidebar-favorites .fav-item::after {
        content: attr(data-label);
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 12px;
        padding: 6px 12px;
        background: var(--sidebar-bg, #0A1128);
        color: #fff;
        font-size: 12px;
        white-space: nowrap;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        border: 1px solid rgba(255,255,255,0.08);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.15s, visibility 0.15s;
        pointer-events: none;
        z-index: 9999;
    }
    .sidebar-favorites .fav-item::before {
        content: '';
        position: absolute;
        left: 100%;
        top: 50%;
        transform: translateY(-50%);
        margin-left: 4px;
        border: 4px solid transparent;
        border-right-color: var(--sidebar-bg, #0A1128);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.15s, visibility 0.15s;
        pointer-events: none;
        z-index: 9999;
    }
    .sidebar-favorites .fav-item:hover::after,
    .sidebar-favorites .fav-item:hover::before {
        opacity: 1;
        visibility: visible;
    }
    .sidebar-favorites .fav-icon svg {
        width: 16px;
        height: 16px;
    }
}

/* ==========================================================================
   Visual Polish — Transitions + Active Accent
   ========================================================================== */

.nav-section-items {
    max-height: 1000px;
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.sidebar .nav-item.active {
    border-left: 3px solid var(--color-primary, #0d8aaa);
    padding-left: calc(var(--space-md) - 3px);
}

/* ==========================================================================
   Command Palette (Cmd+K / Ctrl+K)
   ========================================================================== */

.cmd-palette {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
}

.cmd-palette-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.cmd-palette-dialog {
    position: relative;
    max-width: 520px;
    width: 90%;
    margin: 15vh auto 0;
    background: var(--card-white, #fff);
    border-radius: var(--radius-lg, 16px);
    box-shadow: 0 16px 48px rgba(0,0,0,0.25);
    overflow: hidden;
    animation: cmdPaletteIn 0.15s ease-out;
}

@keyframes cmdPaletteIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cmd-palette-input {
    width: 100%;
    padding: 16px 20px;
    border: none;
    border-bottom: 1px solid var(--border-light, rgba(0,31,84,0.1));
    font-size: 16px;
    font-family: var(--font-family);
    outline: none;
    background: transparent;
    color: var(--text-dark, #001F54);
    box-sizing: border-box;
}

.cmd-palette-input::placeholder {
    color: var(--text-muted, #6B7280);
}

.cmd-palette-results {
    max-height: 340px;
    overflow-y: auto;
    padding: 6px 0;
}

.cmd-palette-results:empty::after {
    content: 'No results';
    display: block;
    padding: 16px 20px;
    color: var(--text-muted, #6B7280);
    font-size: 14px;
}

.cmd-palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--text-dark, #001F54);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.1s;
}

.cmd-palette-item:hover,
.cmd-palette-item.selected {
    background: rgba(18,130,162,0.08);
}

.cmd-palette-item.selected {
    background: rgba(18,130,162,0.14);
}

.cmd-palette-item-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--content-bg, #F5F7FA);
    border-radius: 6px;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-teal, #1282A2);
}

.cmd-palette-item-text {
    flex: 1;
    min-width: 0;
}

.cmd-palette-item-label {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-palette-item-section {
    font-size: 11px;
    color: var(--text-muted, #6B7280);
    margin-top: 1px;
}

.cmd-palette-hint {
    padding: 8px 20px;
    font-size: 11px;
    color: var(--text-muted, #6B7280);
    border-top: 1px solid var(--border-light, rgba(0,31,84,0.1));
    display: flex;
    gap: 12px;
}

.cmd-palette-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid var(--border-light, rgba(0,31,84,0.1));
    border-radius: 3px;
    font-size: 10px;
    font-family: var(--font-family);
    background: var(--content-bg, #F5F7FA);
}

/* ══════════════════════════════════════════
   DENSITY TOGGLE (Phase 59 — POWER-02)
   Compact table rows when data-density="compact" on <html>
══════════════════════════════════════════ */
.density-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm, 8px);
    background: transparent;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.density-toggle-btn:hover {
    background: var(--hover-bg, rgba(0,0,0,0.05));
    color: var(--text-dark, #1f2937);
}

[data-density="compact"] .table-row,
[data-density="compact"] table tr {
    height: 36px !important;
    min-height: 36px !important;
    line-height: 1.2 !important;
}
[data-density="compact"] .table-row td,
[data-density="compact"] table td,
[data-density="compact"] table th {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
    font-size: 0.85rem !important;
}
[data-density="compact"] .kpi-card {
    padding: 10px 12px !important;
}
[data-density="compact"] .kpi-card-value {
    font-size: 24px !important;
}

/* ══════════════════════════════════════════
   STALENESS INDICATOR (Phase 59 — POWER-06)
   "Updated Xs ago" text in the header bar
══════════════════════════════════════════ */
.staleness-indicator {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
    margin-left: 8px;
}

