:root {
    /* Colors - Deep Slate & Vibrant Purple Theme */
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: #64748b;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-navbar: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --accent: #38bdf8;

    /* GANTT Colors */
    --task-bar: #8b5cf6;
    --task-progress: #a78bfa;
    --task-hover: #c084fc;

    /* Priorities */
    --p-critical: #ef4444;
    --p-high: #f97316;
    --p-medium: #eab308;
    --p-low: #22c55e;

    /* Statuses */
    --s-not-started: #94a3b8;
    --s-in-progress: #38bdf8;
    --s-blocked: #f43f5e;
    --s-completed: #10b981;

    /* Spacing & Sizing */
    --sidebar-width: 320px;
    --header-height: 64px;
    --row-height: 48px;
    --column-width: 60px;
    /* Day zoom */

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Light Mode Tokens */
body.light-theme {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-navbar: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --accent: #0284c7;
    --task-bar: #7c3aed;
    --task-progress: #a78bfa;
}

body.light-theme .gantt-timeline-container {
    background: #fdfdfd;
}

body.light-theme .timeline-header {
    background: #f1f5f9;
}

body.light-theme .timeline-col {
    border-right-color: #f1f5f9;
}

body.light-theme .task-row {
    background: #ffffff;
}

body.light-theme .modal-body {
    background: #ffffff;
}

body.light-theme .modal-footer {
    background: #f1f5f9;
}

body.light-theme .form-group input,
body.light-theme .form-group textarea {
    background: #ffffff;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4 {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    background-color: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border);
}

.btn-secondary:hover {
    background-color: var(--border);
}

/* Dashboard */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.view {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    max-width: 1400px;
    /* Increased for better default width */
    margin: 0 auto;
    width: 100%;
    transition: max-width 0.3s;
}

/* Gantt view should take full width */
#gantt-view {
    max-width: none !important;
    padding: 0;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.chart-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Gantt Layout */
.gantt-header {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1.5rem;
    background: var(--bg-navbar);
    border-bottom: 1px solid var(--border);
    height: auto;
    min-height: 100px;
    gap: 0.75rem;
}

.gantt-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.gantt-header-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.gantt-header-bottom h2 {
    font-size: 1.5rem;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.width-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.width-control input {
    width: 60px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.width-control input:focus {
    outline: none;
    border-color: var(--primary);
}

.gantt-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.gantt-sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border);
    background: var(--bg-navbar);
    display: flex;
    flex-direction: column;
}

.gantt-timeline-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #0b1120;
}

/* Task List Items */
.task-row {
    height: var(--row-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--text-main);
    background: var(--bg-card);
}

.task-cell.name {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.task-cell.duration {
    width: 60px;
    text-align: right;
    color: var(--text-muted);
    cursor: text;
}

.task-cell.duration:focus {
    outline: none;
    color: var(--primary);
    font-weight: 600;
}

.btn-add-subtask {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    transition: opacity 0.2s;
}

.task-row:hover .btn-add-subtask {
    opacity: 1;
}

.task-title:focus {
    outline: none;
    border-bottom: 2px solid var(--primary);
}

.btn-delete-row {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 4px;
    transition: all 0.2s;
}

.task-row:hover .btn-delete-row {
    opacity: 1;
}

.btn-delete-row:hover {
    color: #ef4444;
    transform: scale(1.1);
}

.toggle-icon {
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Timeline */
.timeline-header {
    height: var(--header-height);
    display: flex;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    background: #111827;
}

.timeline-col {
    flex-shrink: 0;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0 4px;
    text-align: center;
}

.timeline-col span {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-col .day {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
}

.year-label {
    opacity: 0.7;
    font-size: 0.65rem;
}

.timeline-body {
    position: relative;
    min-height: 100%;
}

.task-bars {
    position: relative;
    padding-top: 0;
}

.task-bar {
    position: absolute;
    height: 32px;
    border-radius: 6px;
    background: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    cursor: move;
    transition: transform 0.2s;
    overflow: hidden;
}

.task-bar:hover {
    filter: brightness(1.1);
}

.task-bar .progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
}

.resize-handle {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 2;
}

.resize-handle.left {
    left: 0;
}

.resize-handle.right {
    right: 0;
}

/* Dependency Links */
.dependency-links {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Modal Improvements */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    background: #111827;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-right {
    display: flex;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea {
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.grid-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.btn-add-task {
    background: var(--primary);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.btn-add-task:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

.sidebar-header {
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    height: var(--header-height);
}

.sidebar-header .col-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.sidebar-header .col-duration {
    width: 40px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}