:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --radius: 8px;
    --row-height: 40px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
}

.gantt-container {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.table-section {
    flex-shrink: 0;
    width: 580px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    max-height: 70vh;
    background: #fff;
}

.chart-section {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    background: #fff;
}

.table-section::-webkit-scrollbar,
.chart-section::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.table-section::-webkit-scrollbar-thumb,
.chart-section::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.table-section::-webkit-scrollbar-track,
.chart-section::-webkit-scrollbar-track {
    background: transparent;
}

table { border-collapse: collapse; width: 100%; }

th, td {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}

tbody td:not(.empty-state) {
    height: var(--row-height);
    padding: 0 12px;
    vertical-align: middle;
}

tbody td.empty-state { height: auto; }

tbody td.editable { padding: 4px 8px; }

td { border-right: 1px dashed var(--gray-100); }
td:last-child { border-right: none; }

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.editable {
    cursor: pointer;
    min-width: 60px;
    transition: all 0.2s;
    border-radius: 4px;
    padding: 4px 8px;
}

.editable:hover { background: var(--gray-50); color: var(--primary); }

.editable:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    background: #fff;
}

.task-row {
    background: #fff;
    transition: background 0.1s;
    height: var(--row-height);
}
.task-row:hover { background: var(--gray-50); }

.plan-label {
    display: inline-block;
    padding: 2px 8px;
    background: #eff6ff;
    color: var(--primary);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.actual-label {
    display: inline-block;
    padding: 2px 8px;
    background: #ecfdf5;
    color: var(--success);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.gantt-header {
    display: flex;
    background: var(--gray-50);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.gantt-header-cell {
    flex-shrink: 0;
    width: 80px;
    padding: 10px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    border-right: 1px dashed var(--gray-200);
    background: var(--gray-50);
}

.gantt-body { position: relative; }

.gantt-row {
    display: flex;
    height: var(--row-height);
    border-bottom: 1px solid var(--gray-100);
    position: relative;
    align-items: center;
}

.gantt-row.plan-row { background: rgba(59, 130, 246, 0.01); }
.gantt-row.actual-row { background: rgba(16, 185, 129, 0.01); }

.gantt-cell {
    flex-shrink: 0;
    width: 80px;
    height: 100%;
    border-right: 1px dashed var(--gray-100);
    position: relative;
}

.gantt-bar {
    position: absolute;
    height: 24px;
    top: calc((var(--row-height) - 24px) / 2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 11px;
    color: #fff;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
}

.gantt-bar:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 5;
    filter: brightness(1.05);
}

.bar-plan { background: var(--primary); }
.bar-actual-normal { background: var(--success); }
.bar-actual-delayed { background: var(--danger); }
.bar-actual-early { background: #8b5cf6; }

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}

.btn:active { transform: translateY(1px); }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(0.9); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }

.btn-outline {
    background: #fff;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    box-shadow: var(--shadow-sm);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-800); }

.btn-sm { padding: 4px 8px; font-size: 11px; }

.toggle-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
}

.toggle-btn:first-child { border-radius: 6px 0 0 6px; }
.toggle-btn:last-child { border-radius: 0 6px 6px 0; border-left: none; }

.toggle-btn:hover { background: var(--gray-50); }

.toggle-btn.active {
    background: var(--gray-100);
    color: var(--gray-800);
    font-weight: 600;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.section-header {
    background: var(--gray-800);
    color: #fff;
    padding: 4px 8px;
    font-weight: 600;
    font-size: 13px;
}

input[type="date"] {
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    width: 110px;
    height: 28px;
    background: transparent;
    font-family: inherit;
    color: var(--gray-700);
    cursor: pointer;
}

input[type="date"]:hover {
    background: var(--gray-50);
    border-color: var(--gray-200);
}

input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.legend {
    display: flex;
    gap: 20px;
    font-size: 13px;
    align-items: center;
    color: var(--gray-600);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-bar {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--gray-600);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    border: 1px solid var(--gray-100);
}

.delete-btn {
    opacity: 0;
    transition: all 0.2s;
    background: transparent;
    color: var(--gray-400);
    border: 1px solid transparent;
}

.delete-btn:hover {
    background: #fef2f2;
    color: var(--danger);
    border-color: #fee2e2;
}

tr:hover .delete-btn { opacity: 1; }

/* PWA 全屏适配与美化 */
@media all and (display-mode: fullscreen) {
    body {
        /* 安全区域适配 */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        background-color: var(--gray-50);
    }

    /* 全屏模式下，增强容器质感 */
    .gantt-container {
        box-shadow: 0 8px 30px rgba(0,0,0,0.08);
        border: 1px solid rgba(0,0,0,0.06);
    }

    /* 标题栏也可以稍微增强一点 */
    #app-container > div:first-child {
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    }
}

