:root {
    /* Color Palette - Vibrant Dark Mode (Default) */
    --bg-main: #0a0c10;
    --bg-secondary: #13161c;
    --bg-glass: rgba(25, 30, 42, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);

    --bg-header: rgba(10, 12, 16, 0.8);
    --bg-input: rgba(0, 0, 0, 0.2);
    --bg-hover: rgba(255, 255, 255, 0.05);

    --scrollbar-track: rgba(0, 0, 0, 0.1);
    --scrollbar-thumb: rgba(99, 102, 241, 0.3);

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --logo-primary: #e1e1e1;
    --logo-secondary: #ffbb00;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.08);

    --bg-header: rgba(255, 255, 255, 0.8);
    --bg-input: #ffffff;
    --bg-hover: rgba(99, 102, 241, 0.08);

    --scrollbar-track: rgba(0, 0, 0, 0.05);
    --scrollbar-thumb: rgba(99, 102, 241, 0.2);

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --shadow-glass: 0 8px 32px 0 rgba(15, 23, 42, 0.08);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.1);
}

[data-theme="light"] .glass-select {
    color-scheme: light;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: auto;
    min-height: 100vh;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
    font-family: 'Outfit', sans-serif;
}

/* Base Layout */
.app-container {
    display: flex;
    height: auto;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    transition: var(--transition);
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
    text-align: center;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--logo-primary), var(--logo-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    box-shadow: var(--shadow-glow);
    padding: 5px;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links li {
    padding: 1rem 1.2rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.nav-links li:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-links li.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), transparent);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.topbar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-glass);
    background-color: var(--bg-header);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.current-view-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
}

.user-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
}

/* Views */
.views-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.view-section {
    display: none;
    opacity: 1;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* Timesheet All-Time: fill available vertical space */
.views-container.ts-all-active {
    overflow: hidden;
}

.views-container.ts-all-active #timesheet-view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#tsAllView {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#tsAllView > .card.glass-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#tsAllView .table-responsive {
    flex: 1;
    max-height: none !important;
    min-height: 0;
    overflow: auto;
}

/* Grid-based views fill available height */
#planning-view.active,
#availability-view.active,
#checkcard-view.active,
#project-plan-view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Cards & Glassmorphism */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-glass);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.btn-icon {
    padding: 0.6rem;
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
}

.btn-icon:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.glass-input,
.glass-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-input);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    outline: none;
}

.glass-select {
    color-scheme: dark;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.glass-select option {
    background-color: #1a1d25;
    color: var(--text-primary);
    padding: 0.5rem;
}

.glass-select option:hover,
.glass-select option:checked {
    background-color: var(--primary);
    color: white;
}

.glass-input:focus,
.glass-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Fix for Tom Select wrappers inheriting glass-select styles */
.ts-wrapper.glass-select {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* === TOM SELECT CUSTOM DARK THEME === */
.ts-control {
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-primary) !important;
    font-family: 'Inter', sans-serif !important;
    padding: 0.75rem 2.5rem 0.75rem 1rem !important;
    transition: var(--transition) !important;
    cursor: pointer !important;
    position: relative !important;
}

/* Dropdown arrow indicator */
.ts-control::after {
    content: "\f078" !important;
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    position: absolute !important;
    right: 1rem !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--text-muted) !important;
    pointer-events: none !important;
    font-size: 0.8rem !important;
    opacity: 0.8 !important;
}

.ts-control>input {
    color: transparent !important;
    text-shadow: 0 0 0 var(--text-primary) !important;
    cursor: pointer !important;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
}

.ts-dropdown {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-glass) !important;
    color: var(--text-primary) !important;
    margin-top: 4px !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    z-index: 200 !important;
}

.ts-dropdown .option {
    padding: 0.75rem 1rem !important;
    transition: var(--transition) !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background-color: var(--primary) !important;
    color: white !important;
}

/* Dropdown input plugin styling */
.ts-dropdown .dropdown-input-wrap {
    padding: 0.5rem !important;
}

.ts-dropdown .dropdown-input {
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-primary) !important;
    font-family: 'Inter', sans-serif !important;
    padding: 0.5rem 0.75rem !important;
    width: 100% !important;
    box-shadow: none !important;
    outline: none !important;
}

.ts-dropdown .dropdown-input:focus {
    border-color: var(--primary) !important;
}

#planProjectSelect+.ts-wrapper,
#tsProjectFilter+.ts-wrapper {
    width: 320px !important;
    min-width: 320px !important;
}

#planYearSelect+.ts-wrapper,
#ccYearSelect+.ts-wrapper,
#availabilityYearSelect+.ts-wrapper {
    width: 120px !important;
    min-width: 120px !important;
}

#progressStatusFilter+.ts-wrapper {
    width: 160px !important;
    min-width: 160px !important;
}

#ccMonthSelect+.ts-wrapper {
    width: 140px !important;
    min-width: 140px !important;
}

.form-group .ts-wrapper {
    width: 100% !important;
}

/* --- Toggle Switch --- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    transition: var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
    border-color: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

/* --- Timesheet Tag Selector Custom Styling --- */
.ts-tag-placeholder {
    padding: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.ts-tag-option {
    padding: 0.5rem;
}

.ts-tag-resource {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 2px;
}

.ts-tag-resource i {
    font-size: 0.75rem;
    margin-right: 0.4rem;
}

.ts-tag-desc {
    font-size: 0.85rem;
    margin: 0.2rem 0;
}

.ts-tag-dates {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Adapt colors when option is active/hovered for legibility */
.ts-dropdown .option:hover .ts-tag-resource,
.ts-dropdown .option.active .ts-tag-resource,
.ts-dropdown .option:hover .ts-tag-dates,
.ts-dropdown .option.active .ts-tag-dates {
    color: rgba(255, 255, 255, 0.9) !important;
}

.ts-tag-item strong {
    color: var(--primary);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.data-table td:first-child,
.data-table th:first-child {
    white-space: nowrap;
}

.text-nowrap {
    white-space: nowrap !important;
}

/* Glass Table - Specialized for Modals/Refined Views */
.glass-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text-primary);
}

.glass-table th {
    position: sticky;
    top: 0;
    background: rgba(19, 22, 28, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 1rem 1.2rem;
    text-align: left;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    z-index: 10;
}

.glass-table td {
    padding: 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
    transition: var(--transition);
}

.glass-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.glass-table tr:last-child td {
    border-bottom: none;
}

/* Custom Scrollbar for Containers */
.table-container::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
#checkcardGrid::-webkit-scrollbar,
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-container::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track,
#checkcardGrid::-webkit-scrollbar-track,
.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
#checkcardGrid::-webkit-scrollbar-thumb,
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
    transition: var(--transition);
}

.table-container::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover,
#checkcardGrid::-webkit-scrollbar-thumb:hover,
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Person Pill Component */
.person-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.person-pill i {
    color: var(--primary);
    font-size: 0.8rem;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Gantt/Planning specific */
.planning-grid th {
    min-width: 52px;
    text-align: center;
    padding: 0.4rem 0.2rem !important;
    vertical-align: bottom;
    font-size: 0.75rem;
}

.planning-grid td {
    min-width: 90px;
    width: 90px;
    text-align: center;
    padding: 0 !important;
    /* Let cell-content handle internal padding */
}

.planning-grid th:not(:first-child) {
    min-width: 90px;
    width: 90px;
}

.planning-grid .week-header-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
    line-height: 1.2;
}

.planning-grid .week-header-dates {
    font-size: 0.6rem;
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
}

.planning-grid td:first-child {
    text-align: left;
    min-width: 280px;
    max-width: 280px;
    padding-left: 1.5rem !important;
    padding-right: 1rem !important;
    position: sticky;
    left: 0;
    background-color: var(--bg-secondary);
    z-index: 2;
    border-right: 1px solid var(--border-glass);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.planning-grid th:first-child {
    text-align: left;
    min-width: 280px;
    max-width: 280px;
    padding-left: 1.5rem !important;
    padding-right: 1rem !important;
    position: sticky;
    left: 0;
    background-color: var(--bg-secondary);
    z-index: 4;
    border-right: 1px solid var(--border-glass);
}

.planning-grid-container {
    overflow: auto !important;
    flex: 1;
    min-height: 0;
    position: relative;
}

table.planning-grid {
    width: max-content !important;
    border-collapse: separate !important;
    border-spacing: 0;
}

.planning-grid thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 5;
    border-bottom: 1px solid var(--border-glass);
}

.planning-grid thead th:first-child,
.planning-grid thead th.col-total {
    z-index: 6 !important;
}

.planning-grid .col-total {
    position: sticky;
    left: 280px;
    background-color: var(--bg-secondary);
    min-width: 70px;
    max-width: 70px;
    border-right: 1px solid var(--border-glass);
    text-align: center;
    z-index: 3;
}

.planning-grid th:not(:first-child),
.planning-grid td:not(:first-child) {
    width: 52px;
    max-width: 70px;
}

/* The glass-card wrapping a planning grid must constrain width and fill height */
#planning-view .glass-card,
#availability-view .glass-card {
    overflow: hidden;
    min-width: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#project-plan-view .glass-card {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg-secondary);
    overflow: hidden;
    min-width: 0;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cc-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
}

.plan-input {
    width: 46px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    text-align: center;
    border-radius: 4px;
    padding: 4px 2px;
    font-size: 0.8rem;
    transition: var(--transition);
}

.plan-input:hover,
.plan-input:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

.cell-saved {
    animation: flashSuccess 1s ease;
}

@keyframes flashSuccess {
    0% {
        background-color: rgba(16, 185, 129, 0.3);
    }

    100% {
        background-color: transparent;
    }
}

/* Capacity Indicators */
td.cell-over-capacity {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

td.cell-under-capacity {
    background-color: rgba(16, 185, 129, 0.1) !important;
}

.plan-input {
    background: transparent !important;
    border-color: transparent !important;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.plan-input:focus {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--primary) !important;
}

input.plan-input.cell-over-capacity,
input.plan-input.cell-under-capacity {
    /* Remove background from input as it's now on TD */
    background-color: transparent !important;
    border-color: transparent !important;
}


.clickable-project {
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    white-space: nowrap;
}

.clickable-project:hover {
    color: var(--primary) !important;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
    transform: translateX(4px);
}

.timesheet-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
}

.timesheet-form-container h3,
.timesheet-summary h3 {
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.daily-total {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.total-value {
    font-size: 2.5rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logged-hour-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border-glass);
}

.logged-hour-item:last-child {
    border-bottom: none;
}

.modal-sub-header {
    margin-bottom: 1.5rem;
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-input-wrapper input {
    padding-left: 2.8rem !important;
    min-width: 250px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    padding: 2rem;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.glass-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    position: relative;
    overflow: hidden;
}

.glass-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--primary));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal {
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.92) translateY(20px);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 2rem 2.5rem 2rem;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

/* Custom scrollbar inside modal */
.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
}

.modal::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-glass);
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-modal {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    transform: rotate(90deg);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 1.5rem;
}

.span-2 {
    grid-column: span 2;
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.modal-tab {
    flex: 1;
    padding: 0.8rem 1.2rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.modal-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.modal-tab.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Custom Attribute Rows */
.custom-attr-row {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.custom-attr-row:last-child {
    border-bottom: none;
}

.custom-attr-label {
    min-width: 160px;
    max-width: 160px;
    padding-top: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: right;
}

.custom-attr-field {
    flex: 1;
}

.custom-attr-field .glass-input,
.custom-attr-field .glass-select {
    width: 100%;
}

.custom-attrs-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

/* Changes List (Historization Modal) */
.changes-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.5rem;
}

.change-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.85rem;
}

.change-item:last-child {
    border-bottom: none;
}

.change-field-name {
    min-width: 120px;
    font-weight: 600;
    color: var(--primary);
}

.change-values {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.change-old {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: line-through;
}

.change-new {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.change-arrow {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-glass);
}

#changeNoteModal {
    z-index: 110;
}

#changeNoteModal .modal-footer {
    margin-top: 2rem;
    padding-top: 2.5rem;
    /* Increased margin and padding specifically for the change note modal per user request */
}

/* Comments Tab Styles */
.comments-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 250px;
    max-height: 400px;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
    padding-right: 0.5rem;
}

.comment-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.comment-author {
    font-weight: 600;
    color: var(--primary);
}

.comment-date {
    color: var(--text-muted);
}

.comment-body {
    font-size: 0.95rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.comment-input-area {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
}

/* History Modal Styles */
#historyModal .modal {
    overflow-y: hidden;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    padding: 1.2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-meta {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.history-version {
    font-weight: 700;
    color: var(--text-base);
    font-size: 1.1rem;
}

.history-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.history-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.history-note {
    background: var(--bg-base);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-style: italic;
    color: var(--text-muted);
    border-left: 3px solid var(--text-secondary);
    margin-bottom: 1rem;
}

.history-changes-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-changes-list {
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.history-changes-list .change-item {
    padding: 0.5rem 0;
}

.badge {
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}

.badge-new {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.badge-progress {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.badge-completed {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.badge-cancelled {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.badge-on-hold {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.type-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.type-project {
    color: var(--primary);
}

.type-task {
    color: var(--secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 1rem;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
    }

    .nav-links {
        flex-direction: row;
        overflow-x: auto;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .timesheet-layout {
        grid-template-columns: 1fr;
    }
}

/* === FLATPICKR CUSTOMIZATION === */
.flatpickr-calendar {
    background: var(--glass-bg) !important;
    border: 1px solid var(--border-glass) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4) !important;
    color: var(--text-primary) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

.flatpickr-day.has-logged-hours {
    position: relative;
    font-weight: bold;
}

.flatpickr-day.has-logged-hours::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 4px var(--primary);
}


@media (min-width: 1024px) {
    .main-content {
        overflow: hidden;
        display: flex;
        flex-direction: column;
        height: 100vh;
    }
}

/* ===== CHECK CARD MATRIX ===== */
.cc-matrix {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    width: max-content;
    min-width: 100%;
}

.cc-matrix thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
    padding: 10px 6px;
}

.cc-matrix tfoot td {
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.cc-sticky-col {
    position: sticky;
    left: 0;
    background: var(--bg-secondary);
    z-index: 11;
    min-width: 160px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    border-right: 1px solid var(--border-glass);
    padding: 8px 12px;
}

.cc-matrix thead th.cc-sticky-col {
    z-index: 12;
    top: 0;
    left: 0;
}

.cc-matrix tfoot td.cc-sticky-col {
    z-index: 12;
    bottom: 0;
    left: 0;
}

.cc-matrix tbody tr:hover td {
    background: rgba(99, 102, 241, 0.06);
}

.cc-matrix tbody tr:hover .cc-sticky-col {
    background: rgba(99, 102, 241, 0.12);
}

/* Sticky header for simple tables */
.sticky-header thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 2;
    border-bottom: 1px solid var(--border-glass);
}

/* Loading Animation */
@keyframes loading-bar {
    0% {
        transform: scaleX(0);
        transform-origin: left;
    }

    50% {
        transform: scaleX(1);
        transform-origin: left;
    }

    50.1% {
        transform: scaleX(1);
        transform-origin: right;
    }

    100% {
        transform: scaleX(0);
        transform-origin: right;
    }
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#login-view-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-main);
    display: none;
    /* JS will toggle this to flex */
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 2.5rem;
    box-sizing: border-box;
    overflow: hidden;
}

.login-container {
    display: none;
}

.login-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 3.5rem 3rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUpFade 0.6s ease-out;
}

.login-card .logo-icon {
    margin: 0 auto 1.5rem;
    width: 120px;
    height: 60px;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: none;
    box-shadow: none;
    padding: 0;
}

.login-card h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

/* === PROJECT PROGRESS SPECIFIC === */
.delayed-row td {
    background-color: rgba(239, 68, 68, 0.05) !important;
}

.badge-delayed {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.70rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 0.5rem;
}

.sparkline-container {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    height: 24px;
    width: 100px;
    position: relative;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.sparkline-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 5px;
    min-width: 4px;
    /* Ensure 0% has at least a dot or keep width 0 */
}

.sparkline-text {
    position: absolute;
    width: 100%;
    text-align: center;
    line-height: 24px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 2;
}

/* === FLATPICKR THEME OVERRIDES === */
[data-theme="light"] .flatpickr-calendar {
    background: #ffffff !important;
    box-shadow: var(--shadow-glass) !important;
    border: 1px solid var(--border-glass) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-months,
[data-theme="light"] .flatpickr-month,
[data-theme="light"] .flatpickr-current-month,
[data-theme="light"] .flatpickr-monthDropdown-months,
[data-theme="light"] .cur-month,
[data-theme="light"] .cur-year,
[data-theme="light"] .flatpickr-weekday {
    background: #ffffff !important;
    color: var(--text-primary) !important;
    fill: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-monthDropdown-month {
    background: #ffffff !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-prev-month,
[data-theme="light"] .flatpickr-next-month {
    color: var(--text-primary) !important;
    fill: var(--text-primary) !important;
    background: transparent !important;
}

[data-theme="light"] .flatpickr-prev-month:hover,
[data-theme="light"] .flatpickr-next-month:hover {
    background: var(--bg-hover) !important;
}

[data-theme="light"] .flatpickr-prev-month svg,
[data-theme="light"] .flatpickr-next-month svg {
    fill: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-day {
    color: var(--text-primary) !important;
}

[data-theme="light"] .flatpickr-day.nextMonthDay,
[data-theme="light"] .flatpickr-day.prevMonthDay {
    color: var(--text-muted) !important;
}

[data-theme="light"] .flatpickr-day:hover {
    background: var(--bg-hover) !important;
}

[data-theme="light"] .flatpickr-day.selected {
    background: var(--primary) !important;
    color: white !important;
}

[data-theme="light"] .flatpickr-time {
    border-top: 1px solid var(--border-glass) !important;
}

[data-theme="light"] .flatpickr-time input,
[data-theme="light"] .flatpickr-time .flatpickr-am-pm {
    color: var(--text-primary) !important;
}

[data-theme="light"] .numInputWrapper span.arrowUp:after {
    border-bottom-color: var(--text-primary) !important;
}

[data-theme="light"] .numInputWrapper span.arrowDown:after {
    border-top-color: var(--text-primary) !important;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-glass);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 250px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
}

.toast.active {
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-error .toast-icon {
    color: var(--danger);
}

.toast-info .toast-icon {
    color: var(--primary);
}

.rollout-btn:hover {
    opacity: 1 !important;
    transform: translateX(2px);
    color: var(--secondary) !important;
}

#availability-view .planning-grid td {
    padding: 0;
}

.availability-input {
    width: 100%;
    height: 100%;
    border: 1px solid transparent !important;
    background: transparent;
    text-align: center;
    padding: 0.8rem 0;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
    cursor: text;
}

.availability-input:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(99, 102, 241, 0.2) !important;
}

.availability-input:focus {
    background: rgba(99, 102, 241, 0.05);
    border-color: var(--primary) !important;
    box-shadow: inset 0 0 0 1px var(--primary);
}

/* Chrome, Safari, Edge, Opera */
.availability-input::-webkit-outer-spin-button,
.availability-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Firefox */
.availability-input[type=number] {
    -moz-appearance: textfield;
}

/* Tom Select Clear Button & Empty Option Styling */
.ts-wrapper.single .clear-button {
    position: absolute !important;
    right: 35px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--text-primary) !important;
    opacity: 0.8 !important;
    transition: opacity 0.2s, color 0.2s;
    font-size: 1.1rem !important;
}

.ts-wrapper.single .clear-button:hover {
    opacity: 1 !important;
    color: var(--secondary) !important;
}

/* Fix overlap: ensure text doesn't go under the clear button */
.ts-wrapper.single.has-items .ts-control {
    padding-right: 60px !important;
}

/* Emphasize the Global View option in the dropdown */
.ts-dropdown .option[data-value=""] {
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 4px;
    padding-bottom: 8px;
    color: var(--primary) !important;
    font-weight: 700 !important;
    background: rgba(99, 102, 241, 0.05) !important;
}

.ts-dropdown .option[data-value=""]:hover {
    background: rgba(99, 102, 241, 0.15) !important;
}

/* Expandable Resource Rows in Global View */
.resource-row-expandable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.resource-row-expandable:hover {
    background: rgba(99, 102, 241, 0.04) !important;
}

.resource-row-expandable.expanded {
    background: rgba(99, 102, 241, 0.06) !important;
}

.detail-row {
    background: rgba(99, 102, 241, 0.02) !important;
    border-left: 3px solid var(--primary) !important;
}

.detail-row td:first-child {
    background: var(--bg-main);
}

.detail-row td {
    padding: 0.5rem 0.8rem !important;
}

.detail-row:hover {
    background: rgba(99, 102, 241, 0.06) !important;
}

.expand-chevron {
    color: var(--primary);
    transition: transform 0.25s ease;
}

/* Activity Tag Integrated Styling */
.cell-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 60px;
    /* Increased for breathing room */
    padding: 10px 6px;
}

.btn-add-tag-cell {
    display: none;
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
    margin-top: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}
.btn-add-tag-cell.visible {
    display: block;
    opacity: 0.5;
}
.btn-add-tag-cell:hover {
    opacity: 1 !important;
}

.tag-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 20px;
    flex: 1;
}

.tag-bar {
    position: relative;
    min-height: 20px;
    height: auto;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: flex-start;
    padding: 3px 6px;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}

.tag-label {
    position: relative;
    z-index: 1;
    word-break: break-all;
    line-height: 1.3;
}

.progress-hours-summary {
    font-size: 0.7rem;
    text-align: center;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
}

.progress-hours-sep {
    opacity: 0.4;
    margin: 0 1px;
}

.tag-res-icon {
    margin-right: 2px;
    font-size: 0.7em;
    opacity: 0.7;
}

.tag-bar:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Drag & Drop */
.tag-bar[draggable="true"] {
    cursor: grab;
}

.tag-bar.tag-dragging {
    opacity: 0.35;
    transform: scale(0.95);
    box-shadow: 0 0 0 2px var(--primary);
}

.tag-drop-placeholder {
    min-height: 22px;
    border: 2px dashed var(--primary);
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    margin: 2px 0;
    transition: opacity 0.15s;
}

.tag-container.drag-over {
    background: rgba(99, 102, 241, 0.06);
    border-radius: 4px;
}

.tag-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 0;
    transition: width 0.4s ease-out;
    opacity: 0.3;
    /* Subtle background fill */
}

/* Colors for tag status */

/* OPEN: neutral/white background (dark theme default) */
.tag-bar.open {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.tag-bar.open .tag-fill {
    background: rgba(255, 255, 255, 0.2);
}

.tag-bar.open .tag-label {
    color: rgba(255, 255, 255, 0.9) !important;
    text-shadow: none !important;
}

/* CLOSED: green background (dark theme default) */
.tag-bar.closed {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.5);
    opacity: 1;
}

.tag-bar.closed .tag-fill {
    background: #22c55e;
    opacity: 0.4;
}

.tag-bar.closed .tag-label {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.9) !important;
    text-shadow: none !important;
}

/* Light theme overrides */
[data-theme="light"] .tag-bar.open {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .tag-bar.open .tag-fill {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tag-bar.open .tag-label {
    color: #333 !important;
}

[data-theme="light"] .tag-bar.closed {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
}

[data-theme="light"] .tag-bar.closed .tag-label {
    color: #1a5c2e !important;
}

.tag-label {
    position: relative;
    z-index: 1;
    color: #fff !important;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .tag-label {
    color: #333 !important;
    text-shadow: none;
}

/* === TAG COLOR OVERRIDE === */

/* Orange override */
.tag-bar.color-orange {
    background: rgba(245, 158, 11, 0.25) !important;
    border-color: rgba(245, 158, 11, 0.5) !important;
}
.tag-bar.color-orange .tag-fill {
    background: #f59e0b !important;
}
.tag-bar.color-orange .tag-label {
    color: #fff !important;
}
[data-theme="light"] .tag-bar.color-orange .tag-label {
    color: #78350f !important;
}

/* Purple override */
.tag-bar.color-purple {
    background: rgba(139, 92, 246, 0.25) !important;
    border-color: rgba(139, 92, 246, 0.5) !important;
}
.tag-bar.color-purple .tag-fill {
    background: #8b5cf6 !important;
}
.tag-bar.color-purple .tag-label {
    color: #fff !important;
}
[data-theme="light"] .tag-bar.color-purple .tag-label {
    color: #3b0764 !important;
}

/* Red override */
.tag-bar.color-red {
    background: rgba(239, 68, 68, 0.25) !important;
    border-color: rgba(239, 68, 68, 0.5) !important;
}
.tag-bar.color-red .tag-fill {
    background: #ef4444 !important;
}
.tag-bar.color-red .tag-label {
    color: #fff !important;
}
[data-theme="light"] .tag-bar.color-red .tag-label {
    color: #7f1d1d !important;
}

/* Black override */
.tag-bar.color-black {
    background: rgba(0, 0, 0, 0.6) !important;
    border-color: rgba(0, 0, 0, 0.8) !important;
}
.tag-bar.color-black .tag-fill {
    background: #000 !important;
}
.tag-bar.color-black .tag-label {
    color: #fff !important;
}
[data-theme="light"] .tag-bar.color-black {
    background: rgba(0, 0, 0, 0.7) !important;
}
[data-theme="light"] .tag-bar.color-black .tag-label {
    color: #fff !important;
}

/* === TAG COLOR PICKER (modal) === */
.tag-color-picker {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.25rem;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.selected {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4);
}

.color-swatch.none {
    background: rgba(255, 255, 255, 0.1);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

[data-theme="light"] .color-swatch.none {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.2);
    color: rgba(0, 0, 0, 0.4);
}

.color-swatch.orange { background: #f59e0b; }
.color-swatch.purple { background: #8b5cf6; }
.color-swatch.red    { background: #ef4444; }
.color-swatch.black  { background: #1a1a1a; }

[data-theme="light"] .color-swatch.black { background: #000; }

#availabilityTable tbody tr td {
    height: 48px;
    vertical-align: middle;
}

/* Button to add tag next to resource name */
.btn-add-tag {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--primary);
    opacity: 0;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    transition: opacity 0.2s, transform 0.2s;
}

tr:hover .btn-add-tag {
    opacity: 0.7;
}

.btn-add-tag:hover {
    opacity: 1 !important;
    transform: translateY(-50%) scale(1.1);
}

/* ===== DASHBOARD ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.dashboard-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    min-height: 280px;
}

/* Span classes — applied by JS based on config */
.dashboard-panel.span-2 { grid-column: span 2; }
.dashboard-panel.span-3 { grid-column: span 3; }
.dashboard-panel.span-full { grid-column: 1 / -1; }

.dashboard-panel .panel-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    letter-spacing: 0.3px;
}

.dashboard-panel .panel-body {
    flex: 1;
    position: relative;
    min-height: 0;
}

.dashboard-panel.kpi-panel {
    min-height: 180px;
}

.kpi-value {
    font-size: 3rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.kpi-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}

.dashboard-panel .data-table {
    font-size: 0.85rem;
}

@media (max-width: 1400px) {
    .dashboard-grid { grid-template-columns: repeat(3, 1fr); }
    .dashboard-panel.span-full { grid-column: 1 / -1; }
    .dashboard-panel.span-3 { grid-column: span 3; }
    .dashboard-panel.span-2 { grid-column: span 2; }
}

@media (max-width: 1050px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-panel.span-full { grid-column: 1 / -1; }
    .dashboard-panel.span-2,
    .dashboard-panel.span-3 { grid-column: span 2; }
}

@media (max-width: 700px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-panel,
    .dashboard-panel.span-2,
    .dashboard-panel.span-3,
    .dashboard-panel.span-full { grid-column: auto; }
}
/* ===================== Virtual Assistant ===================== */
.assistant-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), var(--shadow-glow);
    cursor: pointer;
    font-size: 1.4rem;
    z-index: 1100;
    transition: var(--transition);
}
.assistant-fab:hover {
    background: var(--primary-hover);
    transform: scale(1.06);
}
.assistant-fab.has-unseen::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--secondary);
    box-shadow: 0 0 0 2px var(--bg-main);
}

.assistant-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 440px;
    max-width: 92vw;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-glass);
    box-shadow: -12px 0 36px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1101;
}
.assistant-panel.open { transform: translateX(0); }

.assistant-resizer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
    z-index: 2;
    transition: background 0.15s ease;
}
.assistant-resizer:hover,
.assistant-resizer.dragging {
    background: var(--primary);
    opacity: 0.55;
}
body.assistant-resizing {
    cursor: ew-resize !important;
    user-select: none;
}
body.assistant-resizing .assistant-panel {
    transition: none;
}
body.assistant-resizing iframe { pointer-events: none; }

.assistant-header {
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
}
.assistant-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    color: var(--text-primary);
}
.assistant-title i { color: var(--primary); }
.assistant-actions {
    display: flex;
    gap: 0.2rem;
}
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1;
}
.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.assistant-empty {
    color: var(--text-muted);
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.88rem;
}
.assistant-empty .empty-title {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.assistant-empty .suggestions {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0 0.25rem;
}
.assistant-empty .suggestions button {
    background: var(--bg-input);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}
.assistant-empty .suggestions button:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.msg-bubble {
    max-width: 90%;
    padding: 0.65rem 0.9rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.msg-user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}
.msg-assistant {
    align-self: flex-start;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    border-bottom-left-radius: 4px;
}
.msg-assistant p { margin: 0.25rem 0; }
.msg-assistant ul, .msg-assistant ol {
    margin: 0.35rem 0 0.35rem 1.2rem;
    padding: 0;
}
.msg-assistant li { margin: 0.15rem 0; }
.msg-assistant h3, .msg-assistant h4 {
    margin: 0.5rem 0 0.3rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}
.msg-assistant code {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
}
.msg-assistant pre {
    background: rgba(0, 0, 0, 0.25);
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.4rem 0;
}
.msg-assistant pre code {
    background: transparent;
    color: var(--text-primary);
    padding: 0;
}
.msg-assistant table {
    border-collapse: collapse;
    margin: 0.4rem 0;
    font-size: 0.82rem;
    width: 100%;
}
.msg-assistant th, .msg-assistant td {
    border: 1px solid var(--border-glass);
    padding: 0.3rem 0.5rem;
    text-align: left;
}
.msg-assistant th {
    background: var(--bg-hover);
    font-weight: 600;
}
.msg-assistant a {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: rgba(99, 102, 241, 0.4);
}
.msg-error {
    align-self: flex-start;
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 0.6rem 0.85rem;
    font-size: 0.88rem;
}
.msg-thinking {
    align-self: flex-start;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.5rem 0.85rem;
    font-size: 0.88rem;
}
.msg-thinking::after {
    content: '';
    display: inline-block;
    width: 1ch;
    text-align: left;
    animation: assistantDots 1.5s steps(4, end) infinite;
}
@keyframes assistantDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

.assistant-form {
    padding: 0.8rem 0.9rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: var(--bg-secondary);
}
.assistant-form textarea {
    flex: 1;
    resize: none;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    max-height: 140px;
    line-height: 1.4;
}
.assistant-form textarea:focus { border-color: var(--primary); }
.assistant-form button {
    padding: 0.55rem 0.85rem;
    flex-shrink: 0;
}
.assistant-form button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
