/* ==========================================================================
   inClick Projects - Modern Enterprise SaaS Design System
   Inspired by Linear, Supabase, Vercel & Stripe Design Language
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    /* Brand Accent Colors (Customizable via Tenant Settings) */
    --brand-primary: #3b82f6;
    --brand-secondary: #2563eb;
    --brand-accent: #38bdf8;
    --brand-glow: rgba(59, 130, 246, 0.25);
    
    /* Light Theme (Crisp Porcelain / High-End SaaS) */
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f1f5f9;
    --bg-card: #f8fafc;
    --bg-card-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --border-color-light: #cbd5e1;
    --border-highlight: rgba(255, 255, 255, 0.85);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --status-info: #0284c7;

    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 16px 36px -6px rgba(15, 23, 42, 0.08), 0 6px 14px -3px rgba(15, 23, 42, 0.03);
    --shadow-glow: 0 0 25px rgba(59, 130, 246, 0.16);
    
    --glass-bg: rgba(255, 255, 255, 0.82);
    --glass-border: rgba(226, 232, 240, 0.8);
    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;

    --table-th-bg: #f8fafc;
    --table-th-color: #475569;
    --table-td-color: #1e293b;
    --table-hover: #f8fafc;
}

/* Dark Theme (Deep Space Charcoal / Linear & Raycast Aesthetic) */
html.dark-theme, body.dark-theme {
    --bg-main: #0a0e17;
    --bg-surface: #111726;
    --bg-surface-alt: #0d1424;
    --bg-card: #151f32;
    --bg-card-hover: #1c2842;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-light: rgba(255, 255, 255, 0.15);
    --border-highlight: rgba(255, 255, 255, 0.06);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 20px -3px rgba(0, 0, 0, 0.5), 0 2px 6px -1px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 32px rgba(59, 130, 246, 0.28);

    --glass-bg: rgba(17, 23, 38, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --sidebar-bg: #0d121f;
    --sidebar-border: rgba(255, 255, 255, 0.07);

    --table-th-bg: #111827;
    --table-th-color: #94a3b8;
    --table-td-color: #e2e8f0;
    --table-hover: #162033;
}

/* Global Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    line-height: 1.5;
    position: relative;
}

/* Atmospheric Ambient Lighting Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    height: 500px;
    background: radial-gradient(circle at 50% -100px, var(--brand-glow), transparent 70%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.45;
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color-light);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Layout Container */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   SIDEBAR (Modern Enterprise Navigation)
   ========================================================================== */
.app-sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.9rem;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Brand Section */
.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.brand-wrapper a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    width: 100%;
}

.brand-logo-img {
    height: 38px;
    max-height: 42px;
    max-width: 50px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));
}

.brand-monogram {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: #ffffff;
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--brand-glow);
    flex-shrink: 0;
}

.brand-text-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.brand-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
    white-space: nowrap;
}

.brand-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(59, 130, 246, 0.1);
    color: var(--brand-primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    width: fit-content;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nav Menu */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    margin-bottom: 0.75rem;
}

/* Custom Slim Scrollbar for Nav Menu */
.nav-menu::-webkit-scrollbar {
    width: 4px;
}
.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}
.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: var(--radius-full);
}
.nav-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.45);
}

.nav-section-title {
    font-size: 0.63rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    font-weight: 700;
    margin: 0.95rem 0.5rem 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-color);
}

.nav-section-title:first-child {
    border-top: none;
    margin-top: 0.2rem;
    padding-top: 0;
}

/* Nav Item (Direct Links) */
.nav-item {
    position: relative;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.52rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.nav-item a:hover {
    color: var(--text-primary);
    background-color: var(--bg-card-hover);
    transform: translateX(2px);
}

.nav-item.active a {
    color: var(--brand-primary);
    background: rgba(59, 130, 246, 0.1);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.22);
}

.nav-item.active a::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 16px;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.nav-icon svg, 
.nav-icon i[data-lucide] {
    width: 17px;
    height: 17px;
    stroke-width: 1.9;
}

.nav-item.active .nav-icon {
    color: var(--brand-primary);
}

.nav-item a:hover .nav-icon {
    transform: scale(1.08);
}

/* ==========================================================================
   SUBMENUS & ACCORDION NAVIGATION
   ========================================================================== */
.nav-group {
    position: relative;
    display: flex;
    flex-direction: column;
}

.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.52rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    user-select: none;
}

.nav-group-header:hover {
    color: var(--text-primary);
    background-color: var(--bg-card-hover);
    transform: translateX(2px);
}

.nav-group-header.active,
.nav-group.has-active-child .nav-group-header {
    color: var(--text-primary);
    font-weight: 600;
}

.nav-group.has-active-child .nav-group-header .nav-icon {
    color: var(--brand-primary);
}

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

.nav-group-title span:last-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-group-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.nav-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-chevron svg,
.nav-chevron i[data-lucide] {
    width: 14px;
    height: 14px;
    stroke-width: 2.2;
}

.nav-group.open .nav-chevron {
    transform: rotate(180deg);
    color: var(--text-secondary);
}

/* Submenu container */
.nav-submenu {
    list-style: none;
    margin: 0.2rem 0 0.4rem 1.4rem;
    padding: 0.25rem 0 0.25rem 0.85rem;
    border-left: 1.5px solid rgba(148, 163, 184, 0.22);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease;
}

html.dark-theme .nav-submenu {
    border-left-color: rgba(255, 255, 255, 0.1);
}

.nav-group.open .nav-submenu {
    max-height: 400px;
    opacity: 1;
    pointer-events: auto;
}

.nav-subitem a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.42rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}

.nav-subitem a:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    transform: translateX(2px);
}

.nav-subitem.active a {
    color: var(--brand-primary);
    background: rgba(59, 130, 246, 0.1);
    font-weight: 600;
}

.nav-sub-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.45;
    transition: all 0.18s ease;
    flex-shrink: 0;
}

.nav-subitem a:hover .nav-sub-dot {
    background: var(--text-primary);
    opacity: 0.9;
    transform: scale(1.25);
}

.nav-subitem.active .nav-sub-dot {
    background: var(--brand-primary);
    opacity: 1;
    box-shadow: 0 0 7px var(--brand-primary);
    transform: scale(1.3);
}

.nav-badge-pill {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    border-radius: var(--radius-full);
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

html.dark-theme .nav-badge-pill {
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

/* Sidebar Footer (User Capsule) */
.sidebar-user {
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.user-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.user-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid var(--sidebar-bg);
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-details h4 {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-details span {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-sidebar-logout:hover {
    color: var(--status-danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Sidebar Toggle Collapsed */
body.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .app-main {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
}

/* ==========================================================================
   APP MAIN & TOPBAR
   ========================================================================== */
.app-main {
    flex: 1 1 0%;
    min-width: 0;
    width: calc(100% - 260px);
    max-width: calc(100vw - 260px);
    margin-left: 260px;
    padding: 0 2rem 2.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.3s ease, width 0.3s ease;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
}

/* Sticky Frosted Glass Top Navigation Bar */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 850;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 2rem;
    margin: 0 -2rem 1.75rem -2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    gap: 1rem;
    width: calc(100% + 4rem);
    max-width: calc(100% + 4rem);
    box-sizing: border-box;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Toggle Menu Button */
.btn-toggle-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-toggle-menu:hover {
    background: var(--bg-card-hover);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    transform: scale(1.03);
}

.btn-toggle-menu svg {
    width: 18px;
    height: 18px;
}

/* Breadcrumbs */
.header-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.84rem;
}

.breadcrumb-root {
    font-weight: 600;
    color: var(--text-muted);
}

.breadcrumb-sep {
    color: var(--text-muted);
    opacity: 0.5;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
}

.breadcrumb-sep svg {
    width: 14px;
    height: 14px;
}

.breadcrumb-active {
    font-weight: 700;
    color: var(--text-primary);
}

/* Command Palette Trigger Button (Spotlight Search) */
.search-command-btn {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0.38rem 0.95rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 250px;
    font-family: inherit;
}

.search-command-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--brand-primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.search-command-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.search-command-btn kbd {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
}

/* Live Timer Capsule */
.live-timer-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.28);
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.live-timer-chip:hover {
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}

.radar-ping-wrap {
    position: relative;
    width: 8px;
    height: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.radar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.radar-ping {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.4);
    animation: ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

.live-timer-clock {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    font-weight: 700;
    color: #10b981;
}

.btn-stop-timer {
    background: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: var(--radius-full);
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-stop-timer:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.btn-stop-timer svg {
    width: 12px;
    height: 12px;
}

/* Theme Toggle Button */
.btn-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.38rem 0.8rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.btn-theme-toggle:hover {
    background: var(--bg-card-hover);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-theme-toggle svg {
    width: 15px;
    height: 15px;
    transition: transform 0.3s ease;
}

.btn-theme-toggle:hover svg {
    transform: rotate(20deg);
}

/* Tenant Pill */
.tenant-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.35rem 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-weight: 500;
}

.tenant-pill svg {
    width: 13px;
    height: 13px;
    color: var(--brand-primary);
}

/* ==========================================================================
   HEADINGS & PAGE HEADERS
   ========================================================================== */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1.25rem;
}

.page-title h1 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   BUTTONS (Modern Linear / SaaS Depth)
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.58rem 1.15rem;
    border-radius: var(--radius-md);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
}

.btn svg, .btn i[data-lucide] {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--brand-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-primary:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--brand-glow);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--border-color-light);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-card);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.38rem 0.75rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: 0.75rem 1.6rem;
    font-size: 0.95rem;
    border-radius: var(--radius-lg);
}

/* ==========================================================================
   STAT CARDS & KPI GRID
   ========================================================================== */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.15rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.35rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--brand-primary), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-color-light);
    box-shadow: var(--shadow-md);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-info h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.stat-info .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0.25rem;
    letter-spacing: -0.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.1);
    color: var(--brand-primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.stat-icon svg, .stat-icon i[data-lucide] {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.stat-card:hover .stat-icon {
    transform: scale(1.08);
}

/* ==========================================================================
   CARDS & PANELS
   ========================================================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.card-header {
    padding: 1.15rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-body {
    padding: 1.4rem;
}

.report-date-box {
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    margin-bottom: 1.25rem;
    transition: all 0.2s ease;
}

.report-date-box:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.report-date-box-title {
    font-weight: 600;
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.report-date-box-title svg,
.report-date-box-title i[data-lucide] {
    width: 14px;
    height: 14px;
    color: var(--brand-primary);
}

/* ==========================================================================
   TABLES (High-End Enterprise SaaS Table)
   ========================================================================== */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}

.sticky-action-col {
    position: sticky;
    right: 0;
    background: var(--bg-surface);
    z-index: 4;
    box-shadow: -4px 0 8px rgba(0, 0, 0, 0.06);
}

html.dark-theme .sticky-action-col {
    background: var(--bg-surface);
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.35);
}

.custom-table tr:hover .sticky-action-col {
    background: var(--table-hover) !important;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.custom-table th {
    padding: 0.85rem 1.25rem;
    background-color: var(--table-th-bg);
    color: var(--table-th-color);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.custom-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--table-td-color);
    font-size: 0.88rem;
    vertical-align: middle;
}

.custom-table tbody tr {
    transition: background-color 0.15s ease;
}

.custom-table tbody tr:hover td {
    background-color: var(--table-hover);
    color: var(--text-primary);
}

.custom-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==========================================================================
   BADGES & STATUS PILLS
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    background-color: currentColor;
}

.status-dot.pulse {
    animation: statusPulse 1.5s infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.2); }
}

/* Light Theme Badges */
.badge-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-danger  { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-primary { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-muted   { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }

/* Dark Theme Badges */
html.dark-theme .badge-success, body.dark-theme .badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border-color: rgba(16, 185, 129, 0.3); }
html.dark-theme .badge-warning, body.dark-theme .badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
html.dark-theme .badge-danger, body.dark-theme .badge-danger   { background: rgba(239, 68, 68, 0.15); color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
html.dark-theme .badge-info, body.dark-theme .badge-info       { background: rgba(2, 132, 199, 0.15); color: #38bdf8; border-color: rgba(2, 132, 199, 0.3); }
html.dark-theme .badge-primary, body.dark-theme .badge-primary { background: rgba(59, 130, 246, 0.18); color: #60a5fa; border-color: rgba(59, 130, 246, 0.3); }
html.dark-theme .badge-muted, body.dark-theme .badge-muted     { background: rgba(255, 255, 255, 0.06); color: #94a3b8; border-color: rgba(255, 255, 255, 0.1); }

/* ==========================================================================
   KANBAN BOARD
   ========================================================================== */
.kanban-board {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    padding-bottom: 1.5rem;
    align-items: flex-start;
}

.kanban-column {
    flex: 0 0 310px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: 82vh;
    box-shadow: var(--shadow-sm);
}

.kanban-column-header {
    padding: 0.95rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.kanban-cards {
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow-y: auto;
    flex: 1;
    min-height: 160px;
}

.kanban-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.95rem;
    cursor: grab;
    transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
    box-shadow: var(--shadow-sm);
}

.kanban-card:hover {
    border-color: var(--brand-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kanban-card.dragging {
    opacity: 0.45;
    cursor: grabbing;
}

.kanban-card h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.45rem;
    line-height: 1.3;
}

.kanban-card p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kanban-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */
.form-group {
    margin-bottom: 1.15rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.62rem 0.9rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus {
    outline: none;
    background-color: var(--bg-surface);
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

/* ==========================================================================
   ALERTS & FLASH MESSAGES
   ========================================================================== */
.alert {
    padding: 0.95rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}

.alert svg, .alert i[data-lucide] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.28);
    color: #10b981;
}

.alert-error {
    background-color: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.28);
    color: #ef4444;
}

/* ==========================================================================
   MODALS & SPOTLIGHT COMMAND PALETTE
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 620px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 1.75rem 2rem;
    box-shadow: var(--shadow-lg), 0 0 50px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transform: scale(0.96);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.35rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Spotlight Command Palette Modal */
.command-palette-modal {
    max-width: 580px !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.command-search-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1.15rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
}

.command-search-header svg {
    width: 20px;
    height: 20px;
    color: var(--brand-primary);
    flex-shrink: 0;
}

.command-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-family: inherit;
}

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

.command-results-list {
    max-height: 360px;
    overflow-y: auto;
    padding: 0.6rem;
    list-style: none;
}

.command-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.command-item:hover, .command-item.selected {
    background: rgba(59, 130, 246, 0.12);
    color: var(--brand-primary);
}

.command-item-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.command-item-left svg {
    width: 17px;
    height: 17px;
}

.command-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1.4rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Backdrop Mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
}

.sidebar-backdrop.active {
    display: block;
}

/* ==========================================================================
   RESPONSIVENESS (Mobile & Tablet)
   ========================================================================== */
@media (max-width: 900px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.45);
    }

    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 1rem 2rem;
    }

    .app-topbar {
        margin: 0 -1rem 1.25rem -1rem;
        padding: 0.75rem 1rem;
        width: calc(100% + 2rem);
        max-width: calc(100% + 2rem);
    }

    .search-command-btn {
        min-width: unset;
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        border-radius: var(--radius-md);
    }

    .search-command-btn span,
    .search-command-btn kbd {
        display: none;
    }

    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .grid-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .header-breadcrumbs .breadcrumb-root,
    .header-breadcrumbs .breadcrumb-sep {
        display: none;
    }
}

/* Global Support Modal Backdrop */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-backdrop .modal {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-height: 92vh;
    overflow-y: auto;
}
.modal-backdrop .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-backdrop .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    padding-top: 1rem;
    margin-top: 1.15rem;
    border-top: 1px solid var(--border-color);
}
