/* ============================================================
   Twind by CTAIMA - Application Stylesheet
   Brand Design System
   Loads AFTER Bootstrap 5.3 — overrides Bootstrap defaults
   with platform-specific styles during migration period.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Override Bootstrap's default font to maintain platform identity */
body, .btn, .form-control, .form-select, .nav-link, .dropdown-item,
.card, .modal, .table, h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* --- Custom Properties / Theme --- */
:root {
    --color-primary:        #7B61FF;
    --color-primary-dark:   #6344FF;
    --color-primary-light:  #EDE9FF;
    --color-green:          #00D68F;
    --color-green-dark:     #00B87A;

    --color-success:        #00D68F;
    --color-success-light:  #D1FAE5;
    --color-danger:         #EF4444;
    --color-danger-light:   #FEE2E2;
    --color-warning:        #FBBF24;
    --color-warning-light:  #FEF3C7;
    --color-info:           #7B61FF;
    --color-info-light:     #EDE9FF;
    --color-orange:         #F97316;

    --color-text:           #1A3037;
    --color-text-secondary: #6B7280;
    --color-text-muted:     #6B7280;
    --color-border:         #E5E7EB;
    --color-bg:             #F5F5F7;
    --color-bg-white:       #FFFFFF;

    --color-nav-bg:         #FFFFFF;
    --color-nav-text:       #1A3037;
    --color-nav-active:     #7B61FF;
    --color-nav-hover:      #F5F5F7;

    /* Status badge colors */
    --status-not-started:         #6B7280;
    --status-not-started-bg:      #E5E7EB;
    --status-in-progress:         #2563EB;
    --status-in-progress-bg:      #DBEAFE;
    --status-blocked:             #DC2626;
    --status-blocked-bg:          #FEE2E2;
    --status-done-requested:      #D97706;
    --status-done-requested-bg:   #FEF3C7;
    --status-done:                #059669;
    --status-done-bg:             #D1FAE5;
    --status-cancelled-requested: #EA580C;
    --status-cancelled-requested-bg: #FFEDD5;
    --status-cancelled:           #4B5563;
    --status-cancelled-bg:        #F3F4F6;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:  0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.04);
    --radius:     8px;
    --radius-lg:  12px;
    --radius-xl:  20px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:  'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
    --color-primary:        #9B85FF;
    --color-primary-dark:   #7B61FF;
    --color-primary-light:  #6C5CE7;

    --color-success-light:  #064E3B;
    --color-danger-light:   #7F1D1D;
    --color-warning-light:  #78350F;
    --color-info-light:     #2D2654;

    --color-text:           #E5E7EB;
    --color-text-secondary: #9CA3AF;
    --color-text-muted:     #9CA3AF;
    --color-border:         #374151;
    --color-bg:             #111827;
    --color-bg-white:       #1F2937;

    --color-nav-bg:         #1F2937;
    --color-nav-text:       #E5E7EB;
    --color-nav-active:     #9B85FF;
    --color-nav-hover:      #374151;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md:  0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    --shadow-lg:  0 10px 15px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.2);

    --status-not-started-bg:      #374151;
    --status-in-progress-bg:      #1E3A5F;
    --status-blocked-bg:          #7F1D1D;
    --status-done-requested-bg:   #78350F;
    --status-done-bg:             #064E3B;
    --status-cancelled-requested-bg: #7C2D12;
    --status-cancelled-bg:        #374151;
}
[data-theme="dark"] .table tbody tr:hover { background: #374151; }
[data-theme="dark"] .table th { background: #111827; }
[data-theme="dark"] .table-scroll .table th:first-child { background: #111827; }
[data-theme="dark"] .table-scroll .table td:first-child { background: #1F2937; }
[data-theme="dark"] .table-scroll .table tbody tr:hover td:first-child { background: #374151; }
[data-theme="dark"] .approval-section { background: #2D2200; border-color: #78350F; }
[data-theme="dark"] .approval-header { color: #FBBF24; }
[data-theme="dark"] .approval-header h2 { color: #FBBF24; }
[data-theme="dark"] .approval-details { background: #1F2937; border-color: #78350F; }
[data-theme="dark"] .btn-microsoft { background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%); }
[data-theme="dark"] a { color: #9B85FF; }
[data-theme="dark"] a:hover { color: #B8A4FF; }
/* Ensure button text stays white/readable in dark mode (don't change button backgrounds) */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] a.btn-primary,
[data-theme="dark"] .btn-danger,
[data-theme="dark"] a.btn-danger,
[data-theme="dark"] .btn-success,
[data-theme="dark"] a.btn-success,
[data-theme="dark"] .btn-warning,
[data-theme="dark"] a.btn-warning,
[data-theme="dark"] .btn-info,
[data-theme="dark"] a.btn-info,
[data-theme="dark"] .btn-microsoft,
[data-theme="dark"] a.btn-microsoft {
    color: #FFFFFF !important;
}
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] a.btn-secondary {
    color: #E5E7EB !important;
    border-color: #4B5563;
}
[data-theme="dark"] .btn-link { color: #9B85FF !important; }
[data-theme="dark"] code { background: #374151; color: #E5E7EB; }
[data-theme="dark"] .mini-card { background: #1F2937; }
[data-theme="dark"] .filter-btn { background: #1F2937; color: #E5E7EB; }
[data-theme="dark"] .dropdown-menu { background: #1F2937; border-color: #374151; }
[data-theme="dark"] .dropdown-item:hover { background: #374151; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
    background: #374151 !important; color: #E5E7EB !important; border-color: #4B5563 !important;
}
[data-theme="dark"] .login-card { background: #1F2937; }
[data-theme="dark"] .brand-link { color: #E5E7EB !important; }
/* Logo swap for dark mode */
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: inline-block !important; }

/* Dashboard hardcoded backgrounds */
[data-theme="dark"] .section[style*="background:#FFFBEB"] { background: #2D2200 !important; border-color: #78350F !important; }
[data-theme="dark"] div[style*="border-bottom:2px solid #FDE68A"] { border-color: #78350F !important; }
[data-theme="dark"] div[style*="background:#fff;"],
[data-theme="dark"] div[style*="background:#F9FAFB"],
[data-theme="dark"] [style*="background:#fff;"],
[data-theme="dark"] [style*="background:#F9FAFB"] {
    background: var(--color-bg-white) !important;
}
[data-theme="dark"] [style*="border:1px solid #E5E7EB"],
[data-theme="dark"] [style*="border: 1px solid #E5E7EB"] {
    border-color: var(--color-border) !important;
}
[data-theme="dark"] [style*="background:#E5E7EB"] {
    background: #374151 !important;
}
[data-theme="dark"] [style*="border-bottom:1px solid #F3F4F6"],
[data-theme="dark"] [style*="border-bottom: 1px solid #F3F4F6"] {
    border-color: #374151 !important;
}
[data-theme="dark"] h2[style*="color:#B45309"],
[data-theme="dark"] a[style*="color:#B45309"] {
    color: #FBBF24 !important;
}
[data-theme="dark"] [style*="color:#92400E"] {
    color: #FDE68A !important;
}
[data-theme="dark"] [style*="color:#6B7280"] {
    color: var(--color-text-muted) !important;
}

/* AI Generator cards — soften the gradient in dark mode */
[data-theme="dark"] .ai-smart-generator,
[data-theme="dark"] [style*="linear-gradient(135deg, #F5F3FF"] {
    background: linear-gradient(135deg, #1E1B2E 0%, #2D2654 100%) !important;
    border-color: #4C3D99 !important;
}
[data-theme="dark"] .ai-smart-generator strong[style*="color:#7B61FF"] {
    color: #B8A4FF !important;
}
/* AI Vector Generator card */
[data-theme="dark"] [style*="border:1px solid var(--color-primary-light"] {
    border-color: #4C3D99 !important;
    background: #1E1B2E !important;
}

/* Dashboard subsection cards (My Actions, My Vectors, My KPIs, etc.) */
[data-theme="dark"] div[style*="background:var(--color-bg-white"] {
    background: var(--color-bg-white) !important;
    border-color: var(--color-border) !important;
}
/* Nested cards inside dashboard (individual vector cards, etc.) */
[data-theme="dark"] div[style*="background:var(--color-bg-secondary"] {
    background: #111827 !important;
    border-color: var(--color-border) !important;
}
/* KPI chart container */
[data-theme="dark"] div[style*="border-radius:12px; padding:1.25rem; overflow:hidden"] {
    background: var(--color-bg-white) !important;
    border-color: var(--color-border) !important;
}
/* At-risk consequences section */
[data-theme="dark"] div[style*="background:#FFFBEB"] {
    background: #2D2200 !important;
    border-color: #78350F !important;
}
/* Collapsible body inner backgrounds */
[data-theme="dark"] .collapsible-body [style*="background:var(--color-bg-secondary"] {
    background: #111827 !important;
}
/* KPI form inline sections */
[data-theme="dark"] div[style*="background:var(--color-bg-white, #fff); border:1px solid var(--color-border"] {
    background: var(--color-bg-white) !important;
    border-color: var(--color-border) !important;
}
/* Progress bars background */
[data-theme="dark"] div[style*="background:#E5E7EB; border-radius"] {
    background: #374151 !important;
}
/* Section borders in dark mode */
[data-theme="dark"] .section {
    border-color: var(--color-border);
}
/* Fix hover text visibility on links/buttons in dark mode */
[data-theme="dark"] a:hover,
[data-theme="dark"] .topbar-user:hover,
[data-theme="dark"] .topbar-icon:hover,
[data-theme="dark"] .notification-bell:hover {
    color: #B8A4FF !important;
}
[data-theme="dark"] .sidebar-link:hover {
    color: var(--color-text) !important;
}
[data-theme="dark"] [onmouseover*="color='var(--color-primary)'"]:hover {
    color: #B8A4FF !important;
}
/* Gate cards in gateway */
[data-theme="dark"] .gate-card {
    border-color: var(--color-border) !important;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    padding-bottom: 48px;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

img { max-width: 100%; height: auto; }

/* Touch-friendly tap targets */
@media (pointer: coarse) {
    .btn, button, .filter-btn, .dropdown-item, .navbar-links a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    .form-control, select {
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom on input focus */
    }
}

/* --- Container --- */
.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}
h1 { font-size: 1.875rem; font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 700; }
h4 { font-size: 1.1rem; font-weight: 600; }

p { margin-bottom: 1rem; }

/* --- Top Bar --- */
.topbar {
    background: var(--color-nav-bg);
    border-bottom: 1px solid var(--color-border);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1010;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 1rem;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    color: var(--color-text-muted);
    border-radius: 6px;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    font-family: var(--font-family);
}
.topbar-icon:hover {
    background: #F3F4F6;
    color: var(--color-text);
}
.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    padding: 2px 8px;
    transition: background 0.15s;
}
.topbar-user:hover { background: #F3F4F6; }
.topbar-username { font-weight: 500; font-size: 0.875rem; color: var(--color-text); }
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: var(--color-text-muted);
    transition: background 0.15s;
}
.sidebar-toggle:hover { background: #F3F4F6; color: var(--color-text); }
/* Desktop: show panel icon, hide hamburger */
.toggle-icon-mobile { display: none; }
.toggle-icon-desktop { display: block; transition: transform 0.2s; }
/* Flip arrow when sidebar is collapsed */
body.sidebar-collapsed .toggle-icon-desktop { transform: scaleX(-1); }

/* User avatar circle */
.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}
.logout-form { display: inline; }

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--color-nav-bg);
    border-right: 1px solid var(--color-border);
    z-index: 1005;
    overflow-y: auto;
    transition: width 0.2s ease, transform 0.2s ease;
    padding: 0.75rem 0;
}
.sidebar.collapsed {
    width: 60px;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.5rem;
    height: 100%;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--color-nav-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover {
    background: var(--color-nav-hover);
    color: var(--color-nav-active);
}
.sidebar-link svg {
    flex-shrink: 0;
}
.sidebar-label {
    transition: opacity 0.15s;
}
.sidebar.collapsed .sidebar-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}
.sidebar-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.5rem 0.75rem;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 52px; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1004;
}

/* --- Layout offsets --- */
body {
    padding-top: 52px;
    padding-left: 220px;
    transition: padding-left 0.2s ease;
}
body.sidebar-collapsed {
    padding-left: 60px;
}
.topbar { left: 0; } /* topbar always full width */
/* footer left offset managed by .site-footer rule */

/* --- Main Content --- */
main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 2.5rem;
}

/* --- Footer --- */
.site-footer {
    background: var(--color-nav-bg);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -1px 3px rgba(0,0,0,0.04);
    padding: 0;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    position: fixed;
    bottom: 0;
    left: 220px;
    right: 0;
    z-index: 1000;
    transition: left 0.2s ease;
}
body.sidebar-collapsed .site-footer {
    left: 60px;
}
/* Prevent content from being hidden behind fixed footer */
/* padding-bottom for fixed footer, padding-top/left set in layout section */
.site-footer .container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}
.site-footer p {
    margin: 0;
}

/* --- Flash Messages / Alerts --- */
.flash-messages {
    margin-bottom: 1.25rem;
}

.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    border: none;
    font-weight: 500;
}
.alert-success {
    background: var(--color-success-light);
    color: #059669;
}
.alert-error {
    background: var(--color-danger-light);
    color: #DC2626;
}
.alert-warning {
    background: var(--color-warning-light);
    color: #D97706;
}
.alert-info {
    background: var(--color-info-light);
    color: var(--color-primary);
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 0 0.25rem;
    line-height: 1;
    transition: opacity 0.15s;
}
.alert-close:hover { opacity: 1; }

/* --- Cards --- */
.card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}
.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0;
    color: var(--color-text);
}
.card-body { padding: 0; }

/* --- Dashboard Summary Cards --- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.summary-card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}
.summary-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--color-primary);
    border-radius: 0 2px 2px 0;
}
.summary-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.summary-card .summary-count {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.2;
}
.summary-card .summary-label {
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.35rem;
    font-weight: 500;
}
.summary-card.summary-success::before { background: var(--color-success); }
.summary-card.summary-success .summary-count { color: var(--color-success); }
.summary-card.summary-danger::before  { background: var(--color-danger); }
.summary-card.summary-danger .summary-count  { color: var(--color-danger); }
.summary-card.summary-warning::before { background: var(--color-warning); }
.summary-card.summary-warning .summary-count { color: var(--color-warning); }
.summary-card.summary-primary::before { background: var(--color-primary); }
.summary-card.summary-primary .summary-count { color: var(--color-primary); }
.summary-card.summary-green::before { background: var(--color-green); }
.summary-card.summary-green .summary-count { color: var(--color-green); }
.summary-card.summary-orange::before { background: var(--color-orange); }
.summary-card.summary-orange .summary-count { color: var(--color-orange); }

/* --- Tables --- */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
    border: 1px solid var(--color-border);
}

/* Scrollable table wrapper for busy tables */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}
.table-scroll .table {
    margin-bottom: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    min-width: 800px;
    overflow: visible;
}
/* Cells: normal wrapping, sensible min widths, max 5-line height */
.table-scroll .table th {
    white-space: nowrap;
    min-width: 100px;
}
.table-scroll .table td {
    white-space: normal;
    min-width: 100px;
    line-height: 1.4;
    vertical-align: middle;
}
/* First column wider */
.table-scroll .table th:first-child,
.table-scroll .table td:first-child {
    min-width: 200px;
}
/* Inner clamp for long cell text */
.table-scroll .table td > a,
.table-scroll .table td > span,
.table-scroll .table td > div {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* Frozen first column */
.table-scroll .table th:first-child,
.table-scroll .table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--color-bg-white);
    box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}
.table-scroll .table thead th:first-child {
    background: #F9FAFB;
    z-index: 3;
}
.table-scroll .table tbody tr:hover td:first-child {
    background: #F5F3FF;
}
.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
    vertical-align: middle;
}
.table th {
    background: #F9FAFB;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}
.table tbody tr:last-child td {
    border-bottom: none;
}
.table-striped tbody tr:nth-child(even) {
    background: #FAFBFC;
}
.table tbody tr:hover {
    background: #F5F3FF;
}
.table .row-deleted {
    opacity: 0.5;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
    color: var(--color-text);
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9rem;
    font-family: var(--font-family);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(123,97,255,0.15);
}
.form-control::placeholder {
    color: #9CA3AF;
}
.form-control.is-invalid {
    border-color: var(--color-danger);
}
.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239,68,68,0.15);
}

.form-control-file {
    font-size: 0.875rem;
}

.form-text {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.35rem;
}
.form-error {
    font-size: 0.8rem;
    color: var(--color-danger);
    margin-top: 0.35rem;
    font-weight: 500;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-family);
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.1s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(0);
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #FFFFFF;
    border-color: var(--color-primary);
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(123,97,255,0.3);
}

.btn-danger {
    background: var(--color-danger);
    color: #FFFFFF;
    border-color: var(--color-danger);
}
.btn-danger:hover {
    background: #DC2626;
    border-color: #DC2626;
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

.btn-success {
    background: var(--color-success);
    color: #FFFFFF;
    border-color: var(--color-success);
}
.btn-success:hover {
    background: var(--color-green-dark);
    border-color: var(--color-green-dark);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(0,214,143,0.3);
}

.btn-secondary {
    background: var(--color-bg-white);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
}

.btn-warning {
    background: var(--color-warning);
    color: #78350F;
    border-color: var(--color-warning);
}
.btn-warning:hover {
    background: #F59E0B;
    box-shadow: 0 4px 12px rgba(251,191,36,0.3);
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-primary);
    padding: 0.25rem 0.5rem;
    font-weight: 500;
}
.btn-link:hover {
    text-decoration: underline;
    color: var(--color-primary-dark);
    transform: none;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}
.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 999px;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-not-started {
    background: var(--status-not-started-bg);
    color: var(--status-not-started);
}
.badge-in-progress {
    background: var(--status-in-progress-bg);
    color: var(--status-in-progress);
}
.badge-blocked {
    background: var(--status-blocked-bg);
    color: var(--status-blocked);
}
.badge-done-requested {
    background: var(--status-done-requested-bg);
    color: var(--status-done-requested);
}
.badge-done {
    background: var(--status-done-bg);
    color: var(--status-done);
}
.badge-cancelled-requested {
    background: var(--status-cancelled-requested-bg);
    color: var(--status-cancelled-requested);
}
.badge-cancelled {
    background: var(--status-cancelled-bg);
    color: var(--status-cancelled);
}
.badge-muted {
    background: #F3F4F6;
    color: var(--color-text-muted);
}
.badge-success {
    background: var(--color-success-light);
    color: #059669;
}
.badge-danger {
    background: var(--color-danger-light);
    color: #DC2626;
}
.badge-info {
    background: var(--color-info-light);
    color: var(--color-primary);
}
.badge-warning {
    background: var(--color-warning-light);
    color: #D97706;
}

/* --- Comments --- */
.comments-section {
    margin-top: 2rem;
}

.comment-list {
    margin-bottom: 1.25rem;
}

.comment {
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    background: var(--color-bg-white);
    transition: box-shadow 0.15s;
}
.comment:hover {
    box-shadow: var(--shadow-sm);
}
.comment-hidden {
    opacity: 0.5;
    background: #F9FAFB;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.comment-author {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}
.comment-timestamp {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
.comment-edited {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.comment-body {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}
.comment-body-hidden {
    font-style: italic;
    color: var(--color-text-muted);
}

.comment-actions {
    padding-top: 0.35rem;
}

.comment-replies {
    margin-left: 1.5rem;
    margin-top: 0.75rem;
}
.comment-reply {
    border-left: 3px solid var(--color-primary-light);
}

.reply-form-container {
    margin-top: 0.75rem;
    margin-left: 1.5rem;
}

.comment-add-form {
    border-top: 1px solid var(--color-border);
    padding-top: 1.25rem;
}

/* Mention styling within comments */
.mention-user {
    color: var(--color-primary);
    font-weight: 600;
    background: var(--color-primary-light);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}
.mention-action {
    color: var(--color-primary);
    font-weight: 500;
}

/* --- Attachments --- */
.attachments-section {
    margin-top: 2rem;
}
.attachment-link {
    font-weight: 500;
    color: var(--color-primary);
}
.attachment-link:hover {
    color: var(--color-primary-dark);
}
.attachment-upload-form {
    border-top: 1px solid var(--color-border);
    padding-top: 1.25rem;
}

/* --- Audit --- */
.audit-section {
    margin-top: 1.25rem;
}
.audit-old-value {
    background: var(--color-danger-light);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8125rem;
}
.audit-new-value {
    background: var(--color-success-light);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8125rem;
}

/* --- Pagination --- */
.pagination-nav {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}
.pagination {
    display: flex;
    list-style: none;
    gap: 0.35rem;
}
.pagination li a,
.pagination li span {
    display: inline-block;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.pagination li a:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
    text-decoration: none;
}
.pagination li.active a,
.pagination li.active span {
    background: var(--color-primary);
    color: #FFFFFF;
    border-color: var(--color-primary);
}
.pagination li.disabled span {
    color: var(--color-text-muted);
    cursor: default;
    background: #F9FAFB;
}

/* --- Sections as Cards --- */
.section {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.section h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary-light);
}
.section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin: 0.75rem 0 0.5rem;
}

/* Detail metadata card */
.detail-meta {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Attributes row - flat when inside a section, card when standalone */
.attrs-card {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem 2rem;
    align-items: start;
    width: 100%;
    font-family: var(--font-family);
}
/* Standalone attrs-card (not inside .section) gets card styling */
.attrs-card:not(.section .attrs-card) {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.attrs-card .attr-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.attrs-card .attr-label {
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.2px;
    color: var(--color-text-muted);
}
.attrs-card .attr-value {
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--color-text);
}
.attrs-card .attr-value a,
.attrs-card a.attr-value {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 400;
}
.attrs-card .attr-value a:hover,
.attrs-card a.attr-value:hover {
    text-decoration: underline;
}

/* Status button (dropdown trigger) */
.status-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    color: var(--color-text);
}
.status-btn:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}
.status-btn-NOT_STARTED { color: var(--status-not-started); border-color: var(--status-not-started-bg); background: var(--status-not-started-bg); }
.status-btn-IN_PROGRESS { color: var(--status-in-progress); border-color: var(--status-in-progress-bg); background: var(--status-in-progress-bg); }
.status-btn-BLOCKED { color: var(--status-blocked); border-color: var(--status-blocked-bg); background: var(--status-blocked-bg); }
.status-btn-DONE_REQUESTED { color: #D97706; border-color: #FEF3C7; background: #FEF3C7; }
.status-btn-DONE { color: #059669; border-color: #D1FAE5; background: #D1FAE5; }
.status-btn-CANCELLED_REQUESTED { color: #EA580C; border-color: #FFEDD5; background: #FFEDD5; }
.status-btn-CANCELLED { color: #4B5563; border-color: #F3F4F6; background: #F3F4F6; }

/* Section headers with right-aligned button */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary-light);
}
.section-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}

/* Page header card for top-level screens */
.page-header-card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* Remove inline border-top on sections now that they're cards */
.section[style*="border-top"] {
    border-top: 1px solid var(--color-border) !important;
    padding-top: 1.25rem !important;
}

/* --- Section Titles (legacy) --- */
.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary-light);
    color: var(--color-text);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
/* Detail page header with action buttons */
.detail-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    flex-shrink: 0;
    position: relative;
}
.detail-actions-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0;
    color: var(--color-text);
}

/* --- Login Page --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: 2rem !important;
    flex-direction: column;
}
.login-page .site-footer {
    background: transparent;
    border-top: none;
    box-shadow: none;
    left: 0;
}

.login-card {
    background: var(--color-bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-card .login-logo {
    margin-bottom: 2rem;
}

.login-card .login-logo img {
    max-height: 48px;
}

.login-card h1,
.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.login-card .login-subtitle {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.login-card .form-group {
    text-align: left;
}

.login-card .btn-primary,
.login-card .btn-microsoft {
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.btn-microsoft {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0078D4 0%, #005A9E 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    text-decoration: none;
}
.btn-microsoft:hover {
    background: linear-gradient(135deg, #1A8AE0 0%, #0078D4 100%);
    box-shadow: 0 2px 8px rgba(0,120,212,0.35);
    color: #fff;
    transform: translateY(-1px);
}
.btn-microsoft:active {
    transform: translateY(0);
}

/* --- HTMX Indicators --- */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline;
}
.htmx-request.htmx-indicator {
    display: inline;
}

/* --- Loading Spinner --- */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-secondary);
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.empty-state-text {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.empty-state-subtext {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* --- Utility Classes --- */
.text-muted    { color: var(--color-text-muted) !important; }
.text-danger   { color: var(--color-danger) !important; }
.text-success  { color: var(--color-success) !important; }
.text-warning  { color: #D97706 !important; }
.text-primary  { color: var(--color-primary) !important; }
.text-secondary{ color: var(--color-text-secondary) !important; }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-sm       { font-size: 0.8125rem; }
.text-xs       { font-size: 0.75rem; }

.fw-bold   { font-weight: 700; }
.fw-medium { font-weight: 500; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }

.mr-1 { margin-right: 0.5rem !important; }
.ml-1 { margin-left: 0.5rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.5rem !important; }
.p-2 { padding: 1rem !important; }
.p-3 { padding: 1.5rem !important; }

.d-none  { display: none !important; }
.d-flex  { display: flex !important; }
.d-block { display: block !important; }
.d-inline{ display: inline !important; }
.d-inline-flex { display: inline-flex !important; }

.align-items-center   { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

.w-100 { width: 100%; }

.border-top    { border-top: 1px solid var(--color-border); }
.border-bottom { border-bottom: 1px solid var(--color-border); }

.rounded    { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Hide username in topbar */
    .topbar-username {
        display: none;
    }
}

@media (max-width: 768px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Sidebar becomes offscreen drawer on mobile */
    body {
        padding-left: 0 !important;
    }
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        box-shadow: none;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    }
    .sidebar-overlay.active {
        display: block;
    }

    /* Hide brand text on small screens */
    .brand-text {
        display: none;
    }
    /* Mobile: show hamburger, hide panel icon */
    .toggle-icon-desktop { display: none !important; }
    .toggle-icon-mobile { display: block !important; }

    .topbar-username {
        display: none;
    }

    .page-header {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    .page-header h1 {
        font-size: 1.3rem;
        white-space: nowrap;
    }
    /* Hide button text, keep icon only */
    .page-header .btn-label {
        display: none;
    }
    .page-header .btn svg {
        margin-right: 0 !important;
    }

    .comment-replies {
        margin-left: 0.75rem;
    }

    .card {
        padding: 1.25rem;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    /* Mini dashboard cards stack on mobile */
    .mini-dashboard {
        flex-wrap: wrap !important;
    }
    .mini-card {
        min-width: calc(50% - 0.5rem) !important;
        flex: 1 1 calc(50% - 0.5rem) !important;
    }

    /* Filter rows: search input full width on top, buttons wrap below */
    .filter-row {
        gap: 0.5rem !important;
    }
    .filter-row .filter-group {
        flex: 0 0 100% !important;
        width: 100% !important;
    }
    .filter-row > div[style*="margin-left:auto"] {
        margin-left: 0 !important;
        flex-wrap: wrap !important;
        width: 100%;
        gap: 0.5rem !important;
    }

    /* Attrs card grids collapse */
    .attrs-card {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Approval section */
    .approval-actions {
        flex-direction: column;
    }
    .approval-actions .inline-form:last-child {
        min-width: 100% !important;
    }

    /* Alert items */
    .alert-item {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Profile dashboard */
    .profile-dashboard {
        gap: 0.5rem !important;
    }
    .profile-metric-card {
        min-width: calc(50% - 0.5rem) !important;
        flex: 1 1 calc(50% - 0.5rem) !important;
    }

    /* Footer - full width on mobile (sidebar is a drawer) */
    .site-footer {
        left: 0 !important;
    }
    .site-footer .container {
        flex-direction: column !important;
        gap: 0.35rem;
        padding: 0.5rem 1rem;
        min-height: auto !important;
    }

    /* Main content spacing */
    main.container {
        padding-top: 1rem;
        padding-bottom: 1.5rem;
    }

    /* Section padding */
    .section {
        padding: 0.75rem !important;
    }
}

@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 0 0.75rem;
    }
    .summary-card .summary-count {
        font-size: 2rem;
    }
    .login-card {
        padding: 1.5rem 1.25rem;
        border-radius: var(--radius-lg);
    }

    /* Single column on very small screens */
    .mini-card {
        min-width: 100% !important;
        flex: 1 1 100% !important;
    }
    .attrs-card {
        grid-template-columns: 1fr !important;
    }
    .profile-metric-card {
        min-width: 100% !important;
        flex: 1 1 100% !important;
    }

    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.1rem; }

    /* Smaller nav */
    .navbar-inner {
        min-height: 48px;
    }
    .brand-link {
        font-size: 1.1rem !important;
    }
}

/* --- Action Type Badges --- */
.badge-strategic { background: #00D68F; color: #fff; }
.badge-tactical { background: #DBEAFE; color: #2563EB; }

/* --- Entity ID column --- */
.entity-id {
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    padding: 0.25rem 0.4rem;
}
a.entity-id:hover { text-decoration: underline; }
th.col-id, td.col-id { white-space: nowrap; padding: 0.4rem 0.3rem; }

/* --- Sortable Table Headers --- */
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { background: #F0EEFF; }
th .sort-arrow { font-size: 0.7em; margin-left: 4px; }

/* --- User Profile Mini Dashboard --- */
.profile-dashboard {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.profile-metric-card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    min-width: 120px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.profile-metric-card .metric-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-secondary);
    font-weight: 500;
    margin-bottom: 0.15rem;
}
.profile-metric-card .metric-value {
    font-size: 1.2rem;
    font-weight: 700;
}
.metric-green { color: #059669; }
.metric-red { color: #EF4444; }
.metric-blue { color: #2563EB; }
.metric-orange { color: #F97316; }

/* --- Mini Dashboard (Vector Detail) --- */
.mini-dashboard { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.mini-card { background: #fff; border: 1px solid var(--color-border); border-radius: 8px; padding: 0.5rem 0.75rem; text-align: center; min-width: 100px; flex: 1; }
.mini-label { display: block; font-size: 0.65rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.mini-value { display: block; font-size: 1.1rem; font-weight: 700; color: var(--color-dark); }
.mini-pct { font-size: 0.65rem; font-weight: 400; font-style: italic; color: var(--color-text-muted); }

/* --- Checkbox Filter Dropdowns --- */
.filter-dropdown { position: relative; display: inline-block; }
.filter-btn { background: #fff; border: 1px solid var(--color-border); border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 0.85rem; font-family: var(--font-family); font-weight: 500; color: var(--color-text); transition: border-color 0.15s; height: 34px; box-sizing: border-box; }
/* Match search input height to filter buttons */
.filter-row .form-control { padding: 5px 0.875rem; font-size: 0.85rem; height: 34px; box-sizing: border-box; }
.filter-btn:hover { border-color: var(--color-primary); }
.dropdown-menu { position: absolute; top: 100%; left: 0; z-index: 100; background: #fff; border: 1px solid var(--color-border); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-height: 250px; overflow-y: auto; min-width: 200px; padding: 4px 0; margin-top: 4px; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 0.85rem; }
.dropdown-item:hover { background: #F5F3FF; }
.dropdown-item input[type="checkbox"],
.dropdown-item input[type="radio"] { accent-color: var(--color-primary); }
.filter-count { background: var(--color-primary); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 0.7rem; margin-left: 4px; display: none; }

/* --- Collapsible Sections --- */
.collapsible .collapsible-body { display: none; }
.collapsible.open .collapsible-body { display: block; }
.collapsible.open .collapse-indicator { transform: rotate(90deg); }
.collapsible-header { cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; }
.collapse-indicator { display: inline-block; transition: transform 0.2s; font-size: 1.1em; margin-left: auto; color: var(--color-text-muted); }
/* Hide border-bottom on collapsed section headers */
.collapsible:not(.open) > .collapsible-header { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

/* --- Attachment Preview Modal --- */
.attachment-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.attachment-modal-content {
    background: #fff; border-radius: 16px; width: 90%; max-width: 900px;
    max-height: 90vh; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
}
.attachment-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--color-border);
}
.attachment-modal-body {
    padding: 1.5rem; overflow: auto; flex: 1;
}
.attachment-link { cursor: pointer; color: var(--color-primary); text-decoration: underline; }
.attachment-link:hover { color: var(--color-primary-hover, #6B4FE0); }

/* --- Dashboard Count Badges --- */
.count-badge { display:inline-block; min-width:24px; text-align:center; font-weight:600; font-size:0.85rem; padding:2px 6px; border-radius:6px; }
.count-gray { background:#F3F4F6; color:#6B7280; }
.count-blue { background:#DBEAFE; color:#2563EB; }
.count-red { background:#FEE2E2; color:#DC2626; }
.count-green { background:#D1FAE5; color:#059669; }

/* --- Custom Tooltip --- */
#vectoros-tooltip {
    position: fixed;
    z-index: 2000;
    background: #1A3037;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.5;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
    display: none;
}
#vectoros-tooltip strong {
    display: block;
    margin-bottom: 2px;
}

/* --- Approval Section --- */
.approval-section {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
}
.approval-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #B45309;
}
.approval-header h2 {
    color: #B45309;
    border: none;
    padding: 0;
}
.approval-details {
    background: #FFF;
    border: 1px solid #FDE68A;
    border-radius: 8px;
    padding: 1rem;
    margin: 0.75rem 0 1rem;
}
.approval-details .form-group {
    margin-bottom: 0.75rem;
}
.approval-details .form-group:last-child {
    margin-bottom: 0;
}
.approval-details label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.15rem;
}
.form-control-plaintext {
    font-size: 0.9rem;
    color: var(--color-text);
    padding: 0.25rem 0;
}
.approval-actions {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}
.approval-actions .inline-form:last-child {
    flex: 1;
    min-width: 280px;
}
.form-control.is-invalid {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

/* --- Notification Bell --- */
.notification-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    color: var(--color-text-muted);
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.15s;
}
.notification-bell:hover {
    background: #F3F4F6;
    color: var(--color-text);
}
.notification-badge {
    position: absolute;
    top: 0;
    right: 2px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}
.notification-badge.hidden {
    display: none;
}

/* --- Alerts Page --- */
.alert-item {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    background: #fff;
    transition: background 0.15s;
}
.alert-item:hover {
    background: #F9FAFB;
}
.alert-item-unread {
    background: #FFFBEB;
    border-color: #FDE68A;
}
.alert-item-unread:hover {
    background: #FEF9C3;
}
.alert-item-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FEF3C7;
    color: #B45309;
}
.alert-item-content {
    flex: 1;
    min-width: 0;
}
.alert-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
}
.alert-item-title a {
    color: var(--color-text);
    text-decoration: none;
}
.alert-item-title a:hover {
    color: var(--color-primary);
}
.alert-item-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
