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

:root {
    --color-primary: #3B82F6;
    --color-primary-dark: #2563EB;
    --color-secondary: #6B7280;
    --color-success: #10B981;
    --color-danger: #EF4444;
    --color-warning: #F59E0B;
    --color-bg: #F9FAFB;
    --color-surface: #FFFFFF;
    --color-border: #E5E7EB;
    --color-text: #1F2937;
    --color-text-muted: #6B7280;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --row-height: 40px;
    --sidebar-width: 280px;
    --timeline-height: auto;
}

html, body {
    height: 100%;
    font-family: 'Lexend', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}

/* Header */
.header {
    height: 60px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
}

.history-controls .btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.history-controls .btn-icon:disabled:hover {
    background: transparent;
    color: var(--color-text-muted);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--color-bg);
    padding: 4px;
    border-radius: var(--radius-md);
}

.zoom-select {
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--color-text);
    cursor: pointer;
}

.export-controls {
    display: flex;
    gap: 8px;
}

.header-actions .project-name {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 600;
    font-size: 15px;
    color: var(--color-text);
    pointer-events: none;
}

.header-actions .project-duration {
    font-size: 13px;
    font-weight: 400;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Main Content */
.main {
    min-height: calc(100vh - 60px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

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

.btn-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-icon.btn-danger:hover {
    background: #FEE2E2;
    color: var(--color-danger);
}

/* Projects Page */
.projects-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.projects-header h1 {
    font-size: 28px;
    font-weight: 600;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.project-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    padding: 20px;
    transition: all 0.15s ease;
}

.project-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.project-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.project-card-header h3 {
    font-size: 18px;
    font-weight: 500;
}

.project-actions {
    display: flex;
    gap: 4px;
}

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.project-card-buttons {
    display: flex;
    gap: 8px;
}

.project-date {
    font-size: 13px;
    color: var(--color-text-muted);
}

.delete-form {
    display: inline;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--color-text-muted);
}

.empty-state svg {
    margin-bottom: 24px;
    opacity: 0.4;
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--color-text);
}

.empty-state p {
    font-size: 15px;
}

/* Dialog */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.dialog {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.dialog-wide {
    max-width: 560px;
}

.dialog-task {
    max-width: 700px;
}

/* Task Dialog - 2-column layout */
.dialog-task .dialog-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.dialog-task .form-group-full {
    grid-column: 1 / -1;
}

.dialog-task .form-row-4col {
    display: grid;
    grid-template-columns: 1fr 1fr 80px 80px;
    gap: 12px;
    grid-column: 1 / -1;
}

.dialog-task .form-row-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    grid-column: 1 / -1;
}

/* Progress in task dialog */
.dialog-task .form-group-progress {
    grid-column: 1 / -1;
}

/* Compact form group for inline elements */
.form-group-compact {
    display: flex;
    flex-direction: column;
}

.form-group-compact label {
    font-size: 12px;
    margin-bottom: 4px;
}

.form-group-compact input,
.form-group-compact select {
    padding: 8px 10px;
    font-size: 13px;
}

/* Color picker horizontal layout for task dialog */
.dialog-task .color-picker-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.dialog-task .color-picker-swatch {
    width: 24px;
    height: 24px;
}

.dialog-task .color-picker-custom {
    margin-top: 6px;
}

/* Disabled state for 4-column row */
.dialog-task .form-row-4col.disabled {
    opacity: 0.5;
}

.dialog-task .form-row-4col.disabled input,
.dialog-task .form-row-4col.disabled select {
    background: var(--color-bg);
    cursor: not-allowed;
}

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

.dialog-header h2 {
    font-size: 18px;
    font-weight: 500;
}

.dialog-body {
    padding: 24px;
}

.dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.dialog-footer-right {
    display: flex;
    gap: 12px;
}

/* Project Colors List */
.colors-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 40px;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 6px 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.color-preview {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.color-code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 12px;
    color: var(--color-text-muted);
}

.color-item .btn-icon {
    padding: 2px;
    opacity: 0.6;
}

.color-item .btn-icon:hover {
    opacity: 1;
    color: var(--color-danger);
}

.add-color-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.add-color-row input {
    flex: 1;
    padding: 8px 12px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    max-width: 120px;
}

/* CI Colors List */
.ci-colors-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.ci-color-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.ci-color-item .color-preview {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.ci-color-item .ci-color-name {
    flex: 1;
    padding: 6px 10px;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    min-width: 120px;
}

.ci-color-item .ci-color-picker {
    width: 40px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.ci-color-item .color-code {
    min-width: 70px;
    text-align: center;
}

.ci-color-item .btn-icon {
    padding: 4px;
    opacity: 0.6;
}

.ci-color-item .btn-icon:hover {
    opacity: 1;
    color: var(--color-danger);
}

.add-ci-color-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
}

.add-ci-color-row .ci-name-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.add-ci-color-row .ci-color-input {
    width: 50px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.dialog-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 16px;
}

.header-buttons {
    display: flex;
    gap: 12px;
}

.add-color-row input:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Color Picker (Gantt Dialogs) */
.color-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-picker-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-picker-swatch {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.color-picker-swatch:hover {
    transform: scale(1.1);
}

.color-picker-swatch.selected {
    border-color: var(--color-text);
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-text);
}

.color-picker-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.color-picker-input {
    flex: 1;
    padding: 6px 10px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    max-width: 100px;
}

.color-picker-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.color-picker-preview {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 0 !important;
}

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

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-group input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.form-group input[type="range"] {
    width: 100%;
    cursor: pointer;
}

/* Optional date fields with clear button */
.date-input-wrapper {
    display: flex;
    gap: 4px;
    align-items: center;
}

.date-input-wrapper input[type="date"] {
    flex: 1;
}

.date-clear-btn {
    flex-shrink: 0;
    padding: 2px 4px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.15s ease;
}

.date-clear-btn:hover {
    color: var(--color-danger);
    opacity: 1;
}

/* Date info for dependency-driven dates */
.date-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    margin-bottom: 12px;
    background: #EBF5FF;
    border: 1px solid #BFDBFE;
    border-radius: var(--radius-sm);
    color: #1E40AF;
    font-size: 12px;
}

.date-info svg {
    flex-shrink: 0;
}


.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row.disabled {
    opacity: 0.5;
}

.form-row.disabled input,
.form-row.disabled select {
    background: var(--color-bg);
    cursor: not-allowed;
}

/* Dependencies List */
.dependencies-list {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding: 0 8px;
}

.dependencies-list:empty {
    display: none;
}

/* Dependency item - matches form height */
.dependency-item {
    display: flex;
    align-items: center;
    padding: 6px 0;
    gap: 6px;
    font-size: 12px;
    border-bottom: 1px solid var(--color-border);
    min-height: 32px;
}

.dependency-item:last-child {
    border-bottom: none;
}

.dependency-item .dep-type-badge {
    background: var(--color-primary);
    color: white;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    min-width: 22px;
    text-align: center;
}

.dependency-item .dep-direction {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    font-weight: 600;
    color: var(--color-text-muted);
}

.dependency-item.dep-predecessor .dep-direction {
    color: var(--color-primary);
}

.dependency-item.dep-successor .dep-direction {
    color: var(--color-success);
}

.dependency-item.dep-successor {
    background: var(--color-bg);
    margin: 0 -8px;
    padding-left: 8px;
    padding-right: 8px;
}

.dependency-item .dep-name {
    flex: 1 1 auto;
    min-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
    font-weight: 500;
}

.dependency-item .dep-info {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 2px 6px;
    background: var(--color-bg);
    border-radius: 3px;
}


.dependency-item .dep-offset-input {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    flex-shrink: 0;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    text-align: center;
    background: var(--color-surface);
}

.dependency-item .dep-type-select,
.dependency-item .dep-unit-select {
    flex-shrink: 0;
    padding: 4px 4px;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-surface);
}

.dependency-item .dep-type-select {
    width: 48px;
    min-width: 48px;
}

.dependency-item .dep-unit-select {
    width: 40px;
    min-width: 40px;
}

.dependency-item .dep-remove {
    flex-shrink: 0;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px;
    opacity: 0.6;
}

.dependency-item .dep-remove:hover {
    color: var(--color-danger);
    opacity: 1;
}

/* Inline dependency add form */
.dependency-form-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--color-border);
    min-height: 32px;
}

.dependency-form-inline .dep-direction-select {
    width: 36px;
    min-width: 36px;
    flex-shrink: 0;
    padding: 4px 4px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-surface);
    cursor: pointer;
}

.dependency-form-inline .dep-select {
    flex: 1 1 auto;
    min-width: 100px;
    padding: 4px 6px;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-surface);
}

.dependency-form-inline .dep-type-select {
    width: 48px;
    min-width: 48px;
    padding: 4px 4px;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-surface);
}

.dependency-form-inline .dep-offset {
    width: 46px;
    min-width: 46px;
    max-width: 46px;
    padding: 4px 4px;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    text-align: center;
    flex-shrink: 0;
}

.dependency-form-inline .dep-unit-select {
    width: 40px;
    min-width: 40px;
    padding: 4px 4px;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-surface);
}

.dependency-form-inline .dep-add-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 18px;
    font-weight: 500;
    line-height: 1;
    color: white;
    background: var(--color-primary);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
}

.dependency-form-inline .dep-add-btn:hover {
    background: var(--color-primary-dark);
}

/* Gantt Container */
.gantt-container {
    display: flex;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* Gantt Sidebar */
.gantt-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    font-weight: 500;
    font-size: 13px;
    color: var(--color-text-muted);
    /* Height will be set by JavaScript to match timeline */
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-list {
    flex: 1;
    overflow-y: scroll;
    overflow-x: hidden;
    position: relative;
    /* Hide scrollbar but allow programmatic scrolling */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.sidebar-list::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

.sidebar-spacer {
    flex-shrink: 0;
    pointer-events: none;
}

.sidebar-item {
    height: var(--row-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.1s ease;
    gap: 8px;
}

.sidebar-item:hover {
    background: var(--color-bg);
}

.sidebar-item.is-group {
    background: var(--color-bg);
    font-weight: 500;
}

.sidebar-item.is-milestone {
    font-style: italic;
}

.sidebar-item .color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.sidebar-item .item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.sidebar-item .item-actions {
    display: none;
    gap: 4px;
}

.sidebar-item:hover .item-actions {
    display: flex;
}

.sidebar-item .drag-handle {
    cursor: grab;
    color: var(--color-text-muted);
    opacity: 0.3;
    padding: 6px;
    margin: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
}

.sidebar-item .drag-handle:hover {
    opacity: 1;
    color: var(--color-primary);
}

.sidebar-item .drag-handle:active {
    cursor: grabbing;
}

.sidebar-item:hover .drag-handle {
    opacity: 0.7;
}

/* Collapse toggle for groups */
.sidebar-item .collapse-toggle {
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
    margin: -4px 0 -4px -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.sidebar-item .collapse-toggle:hover {
    color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Child tasks (tasks with group_id) - indented */
.sidebar-item.is-child {
    padding-left: 48px;
}

.sidebar-item.is-child .item-title {
    font-weight: 400;
}

/* Gantt Main Area */
.gantt-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.gantt-timeline {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    overflow-y: hidden;
}

.timeline-row {
    display: flex;
    min-width: fit-content;
}

.timeline-row.timeline-years {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.timeline-row.timeline-months {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.timeline-row.timeline-weeks {
    background: var(--color-surface);
}

.timeline-cell {
    min-width: 40px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--color-border);
    font-size: 11px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.timeline-cell.timeline-year-cell {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
    background: var(--color-surface);
}

.timeline-cell.timeline-month-cell {
    font-weight: 500;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.timeline-cell.is-weekend {
    background: #F3F4F6;
}

.timeline-cell.is-today {
    background: #DBEAFE;
    color: var(--color-primary);
    font-weight: 500;
}

.timeline-cell .day-name {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timeline-cell .day-number {
    font-size: 14px;
    font-weight: 500;
}

.timeline-cell .month-name {
    font-size: 12px;
    font-weight: 500;
}

/* Week view timeline cells */
.timeline-cell.timeline-week-cell {
    min-width: auto;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* Day view timeline cells */
.timeline-cell.timeline-day-cell {
    flex-direction: column;
    gap: 1px;
    min-width: 40px;
}

.timeline-cell.timeline-day-cell .day-name {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--color-text-muted);
}

.timeline-cell.timeline-day-cell .day-number {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
}

.timeline-row.timeline-days {
    background: var(--color-surface);
}

/* Gantt Chart */
.gantt-chart {
    flex: 1;
    position: relative;
    overflow: auto;
}

#ganttCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
}

.gantt-rows {
    position: relative;
    min-width: fit-content;
    overflow: visible; /* Allow labels to overflow */
}

.gantt-row {
    height: var(--row-height);
    position: relative;
    border-bottom: 1px solid var(--color-border);
}

.gantt-row.is-group {
    background: var(--color-bg);
}

/* Task Bars */
.task-bar {
    position: absolute;
    height: 24px;
    top: 8px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 11px;
    color: white;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.1s ease;
    z-index: 20;
}

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

.task-bar.is-dragging {
    opacity: 0.8;
    z-index: 100;
}

.task-bar .progress-overlay {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    border-radius: 4px 0 0 4px;
}

.task-bar .resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
}

.task-bar .resize-handle.left {
    left: 0;
}

.task-bar .resize-handle.right {
    right: 0;
}

/* Narrow task bars - hide internal text */
.task-bar.narrow {
    padding: 0;
}

.task-bar.narrow span {
    display: none;
}

/* Recurring task bars */
.task-bar.recurring {
    cursor: default;
}

.task-bar.recurring .resize-handle {
    display: none;
}

.gantt-row.is-recurring {
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.02) 10px,
        rgba(0, 0, 0, 0.02) 20px
    );
}

/* Recurring indicator in sidebar - now rendered inline after title */
.sidebar-item .recurring-icon {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-left: 4px;
    flex-shrink: 0;
}

/* External label for narrow task bars */
.task-label-outside {
    position: absolute;
    top: 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 2px var(--color-surface), 0 0 2px var(--color-surface);
    z-index: 30;
}

.milestone-label {
    position: absolute;
    top: 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 2px var(--color-surface), 0 0 2px var(--color-surface);
    z-index: 30;
}

/* Group Bar */
.group-bar {
    position: absolute;
    height: 6px;
    top: 6px;
    border-radius: 0;
    cursor: pointer;
    z-index: 20;
}

/* Brackets extending downward - simple rectangles */
.group-bar::before,
.group-bar::after {
    content: '';
    position: absolute;
    top: 0;
    width: 4px;
    height: 22px;
    background: inherit;
}

.group-bar::before {
    left: 0;
}

.group-bar::after {
    right: 0;
}

/* Group bar title - positioned to the right of the bracket */
.group-bar-title {
    position: absolute;
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    color: var(--color-text);
    text-shadow: 0 0 2px var(--color-surface), 0 0 2px var(--color-surface);
}

/* Milestone */
.milestone-marker {
    position: absolute;
    width: 16px;
    height: 16px;
    top: 12px;
    transform: translateX(-50%) rotate(45deg);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 20;
}

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

/* Smaller milestone markers for zoomed-out views */
.milestone-marker.zoom-quarter,
.milestone-marker.zoom-halfyear {
    width: 12px;
    height: 12px;
    top: 14px;
}

.milestone-marker.zoom-year,
.milestone-marker.zoom-compact {
    width: 8px;
    height: 8px;
    top: 16px;
}

/* Dependency Lines */
.dependency-line {
    stroke: var(--color-text-muted);
    stroke-width: 1.5;
    fill: none;
    marker-end: url(#arrowhead);
}

/* Today Line */
.today-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        var(--color-danger) 0,
        var(--color-danger) 6px,
        transparent 6px,
        transparent 12px
    );
    z-index: 50;
    pointer-events: none;
}

.today-line::before {
    content: 'Heute';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--color-danger);
    font-weight: 500;
    white-space: nowrap;
}

/* Cursor Line */
.cursor-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        #1F2937 0,
        #1F2937 4px,
        transparent 4px,
        transparent 8px
    );
    z-index: 200;
    pointer-events: none;
}

.cursor-line-label {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #1F2937;
    font-weight: 500;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #1F2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Drag & Drop */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.9;
    background: var(--color-surface);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow: hidden;
}

.drag-ghost .sidebar-item {
    border-bottom: 1px solid var(--color-border);
}

.drag-ghost .sidebar-item:last-child {
    border-bottom: none;
}

.drop-indicator {
    position: absolute;
    left: 8px;
    right: 8px;
    height: 3px;
    background: var(--color-primary);
    pointer-events: none;
    z-index: 100;
    border-radius: 2px;
    box-shadow: 0 0 4px var(--color-primary);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--color-text-muted);
}

.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 12px;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Options Menu (3-dot menu) */
.options-menu {
    position: relative;
    margin-left: auto;
}

.options-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.options-dropdown.show {
    display: block;
}

.options-section {
    padding: 8px;
}

.options-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    margin-bottom: 4px;
}

.options-divider {
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
}

.options-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text);
    transition: background 0.15s;
}

.options-checkbox:hover {
    background: var(--color-bg);
}

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

.options-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.15s;
}

.options-item:hover {
    background: var(--color-bg);
}

.options-item svg {
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.options-badge {
    margin-left: auto;
    background: var(--color-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    display: none;
}

.options-badge.has-selection {
    display: block;
}

/* Bundesland list in dialog */
.bundesland-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 400px;
    overflow-y: auto;
}

/* View Toggles (legacy, can be removed) */
.view-toggles {
    display: none;
    gap: 16px;
    align-items: center;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--color-border);
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.toggle-switch {
    position: relative;
    width: 32px;
    height: 18px;
    background: var(--color-border);
    border-radius: 9px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-switch input {
    display: none;
}

.toggle-switch:has(input:checked) {
    background: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider {
    transform: translateX(14px);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Bundesland Selector */
.bundesland-selector {
    position: relative;
    margin-left: 8px;
}

.bundesland-selector #bundeslandBtn {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bundesland-selector #bundeslandCount {
    min-width: 18px;
    height: 18px;
    background: var(--color-primary);
    color: white;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.bundesland-selector #bundeslandCount.has-selection {
    display: flex;
}

.bundesland-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 220px;
    display: none;
}

.bundesland-dropdown.show {
    display: block;
}

.bundesland-header {
    padding: 8px 12px;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bundesland-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 4px 0;
}

.bundesland-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s;
}

.bundesland-list label:hover {
    background: var(--color-bg);
}

.bundesland-list input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

.bundesland-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.bundesland-footer .btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.bundesland-footer .btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.bundesland-footer .btn.loading svg {
    animation: spin 1s linear infinite;
}

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

/* Holiday/Vacation hatching pattern */
/* IMPORTANT: When changing these styles, also update SVG patterns in export.js (vacationPattern, holidayPattern) */
.holiday-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    pointer-events: none;
    /* Vacation: 45deg gray stripes */
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3px,
        rgba(156, 163, 175, 0.15) 3px,
        rgba(156, 163, 175, 0.15) 6px
    );
    z-index: 5;
}

.holiday-overlay.is-holiday {
    /* Holiday: -45deg red stripes */
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 3px,
        rgba(239, 68, 68, 0.1) 3px,
        rgba(239, 68, 68, 0.1) 6px
    );
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 1000;
    padding: 4px 0;
}

.context-menu-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background: var(--color-bg);
}

.context-menu-item.danger {
    color: var(--color-danger);
}

.context-menu-separator {
    height: 1px;
    background: var(--color-border);
    margin: 4px 0;
}

/* Tooltip */
.tooltip {
    position: fixed;
    z-index: 2000;
    max-width: 320px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    pointer-events: none;
    font-size: 13px;
}

.tooltip-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--color-text);
}

.tooltip-content {
    color: var(--color-text-muted);
    line-height: 1.5;
}

.tooltip-content .tooltip-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.tooltip-content .tooltip-row:last-child {
    margin-bottom: 0;
}

.tooltip-content .tooltip-label {
    color: var(--color-text-muted);
}

.tooltip-content .tooltip-value {
    color: var(--color-text);
    font-weight: 500;
}

.tooltip-content .tooltip-notes {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border);
    white-space: pre-wrap;
}

.tooltip-content .tooltip-progress {
    margin-top: 8px;
    height: 6px;
    background: var(--color-bg);
    border-radius: 3px;
    overflow: hidden;
}

.tooltip-content .tooltip-progress-bar {
    height: 100%;
    background: var(--color-success);
    border-radius: 3px;
}

/* Textarea in forms */
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.15s ease;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

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

/* Responsive */
@media (max-width: 768px) {
    .gantt-sidebar {
        width: 200px;
        min-width: 200px;
    }

    .header-actions {
        gap: 8px;
    }

    .export-controls .btn span {
        display: none;
    }
}
