    :root {
      --primary: #4f6ef7;
      --primary-dark: #3651d8;
      --bg: #f4f6fb;
      --card-bg: #ffffff;
      --text: #2d3748;
      --text-secondary: #718096;
      --border: #e6eaf2;
      --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 6px 18px rgba(0,0,0,0.04);
      --shadow-lg: 0 4px 20px rgba(0,0,0,0.09), 0 10px 40px rgba(0,0,0,0.06);
      --radius: 14px;
      --radius-sm: 9px;
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
      background: var(--bg); color: var(--text);
      padding: 24px; min-height: 100vh;
    }
    ::-webkit-scrollbar { height: 10px; width: 10px; }
    ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
    ::-webkit-scrollbar-track { background: transparent; }

    .app-header { text-align: center; margin-bottom: 24px; }
    .app-header h1 {
      font-size: 27px; font-weight: 800;
      background: linear-gradient(135deg, var(--primary), #a78bfa);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    }
    .app-header p { color: var(--text-secondary); font-size: 13.5px; margin-top: 6px; }

    /* ===== UI/UX 专家布局：左=设置块(紧凑侧栏)  右=数据表(上)+甘特图(下/全宽) =====
       设计原则（专业数据工具最佳实践）：
       ① 「输入→输出」自上而下流：用户先编辑数据表（上方）→ 图表自动渲染在下（下方全宽展示）
       ② 设置区独立左栏成块，调整即时联动图表；
       ③ 数据表区域紧凑不占过多空间，让图表获得最大可视面积；
       ④ 视口窄时整体堆叠，顺序保持 表→图 的自然阅读流。 */
    .layout { display: flex; gap: 16px; align-items: flex-start; }
    .settings-sidebar { flex: 0 0 230px; position: sticky; top: 16px; align-self: flex-start; max-height: calc(100vh - 32px); overflow-y: auto; padding-right: 4px; }
    .main-area { flex: 1 1 760px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
    @media (max-width: 960px) {
      .layout { flex-direction: column; }
      .settings-sidebar { position: static; flex-basis: auto; width: 100%; max-height: none; padding-right: 0; }
    }

    /* ===== 控制面板（拆为多个独立卡片块） ===== */
    .control-panel { margin-bottom: 18px; display: flex; flex-direction: column; gap: 14px; }
    .ctrl-card {
      background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow);
      padding: 16px 18px;
    }
    .ctrl-card-title {
      font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 12px;
      display: flex; align-items: center; gap: 7px;
    }

    /* 视图控制：单列紧凑行，每行=标签+控件 */
    .view-ctrl-list { display: flex; flex-direction: column; gap: 10px; }
    .view-input-row {
      display: flex; align-items: center; justify-content: space-between;
      gap: 10px;
    }
    .control-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; }
    .control-input {
      width: 62px; height: 30px; border: 2px solid var(--border); border-radius: var(--radius-sm);
      font-size: 14px; font-weight: 700; text-align: center; color: var(--primary);
      transition: all .2s; outline: none; flex-shrink: 0;
    }
    .control-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.14); }
    .control-input:disabled { background: #f1f5f9; color: var(--text-secondary); cursor: not-allowed; }
    /* 小格宽度的"自动"勾选框（紧凑内联样式） */
    .auto-chk { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--text-secondary); cursor: pointer; user-select: none; flex-shrink: 0; }
    .auto-chk input { width: 14px; height: 14px; accent-color: var(--primary); cursor: pointer; }

    /* 版式切换行：标签左 + 按钮组右 */
    .mode-row {
      display: flex; align-items: center; justify-content: space-between;
      gap: 8px; flex-wrap: nowrap;
    }
    .mode-row-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
    .mode-toggle { display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 2px; gap: 1px; flex-shrink: 0; }
    .mode-btn {
      padding: 6px 12px; border: none; background: transparent; border-radius: 6px;
      font-size: 11.5px; font-weight: 600; cursor: pointer; color: var(--text-secondary); transition: all .2s;
      white-space: nowrap; flex-shrink: 0;
    }
    .mode-btn.active { background: var(--card-bg); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
    .mode-btn:hover:not(.active) { color: var(--text); }

    /* 颜色设置 */
    .color-set { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; align-items: center; }
    .color-item { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
    .color-item input[type=color] {
      width: 30px; height: 30px; border: 2px solid var(--border); border-radius: 8px;
      background: none; cursor: pointer; padding: 2px;
    }
    .color-item input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
    .color-item input[type=color]::-webkit-color-swatch { border: none; border-radius: 5px; }

    /* ===== 显示设置（块状卡片内） ===== */
    .display-set { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; }
    .ds-label { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; }
    .ds-field { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); font-weight: 500; }
    .ds-field select {
      font-size: 12.5px; padding: 6px 10px; border: 2px solid var(--border); border-radius: 7px;
      background: var(--card-bg); color: var(--text); cursor: pointer; outline: none; font-weight: 600;
    }
    .ds-field select:focus { border-color: var(--primary); }

    .total-days {
      display: inline-flex; align-items: center; gap: 6px;
      background: linear-gradient(135deg, #eef2ff, #e0e7ff);
      padding: 7px 16px; border-radius: 20px; font-size: 12.5px; font-weight: 700; color: var(--primary-dark);
    }
    .total-days .num { font-size: 20px; }

    /* 所有设置均实时联动图表，已无"刷新图表"按钮 */

    /* ===== 数据表格 ===== */
    .data-section { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; flex-shrink: 0; display: flex; flex-direction: column; }
    .section-title {
      display: flex; align-items: center; justify-content: space-between;
      padding: 13px 20px; background: linear-gradient(to right, rgba(79,110,247,.06), transparent);
      border-bottom: 1px solid var(--border); font-size: 14.5px; font-weight: 700;
    }
    .section-title .actions { display: flex; gap: 8px; }
    .btn-icon {
      padding: 6px 13px; border: 1.5px solid var(--border); background: var(--card-bg);
      border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text-secondary); transition: all .2s;
    }
    .btn-icon:hover { border-color: var(--primary); color: var(--primary); background: rgba(79,110,247,.04); }
    .btn-icon.danger:hover { border-color: var(--danger,#ef4444); color: var(--danger,#ef4444); background: rgba(239,68,68,.05); }

    .data-table-wrapper { overflow: auto; flex: 1; min-height: 0; }
    /* 可拖拽分割条：数据表与甘特图之间 */
    .split-handle {
      height: 7px; cursor: ns-resize; display: flex; align-items: center; justify-content: center;
      user-select: none; flex-shrink: 0; transition: background .15s;
    }
    .split-handle::before {
      content:''; width: 40px; height: 3px; background: #c8d0e0; border-radius: 2px; opacity: .6;
    }
    .split-handle:hover { background: rgba(79,110,247,.06); }
    .split-handle:hover::before, .split-handle.active::before { background: var(--primary); opacity: 1; }
    .data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
    .data-table thead th {
      position: sticky; top: 0; z-index: 5; background: #f8fafc; padding: 9px 10px; text-align: left;
      font-weight: 700; font-size: 11.5px; color: var(--text-secondary); border-bottom: 2px solid var(--border); white-space: nowrap;
    }
    .data-table tbody td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
    .data-table tbody tr:hover { background: rgba(79,110,247,.03); }
    .data-table input, .data-table select {
      width: 100%; min-width: 90px; padding: 6px 9px; border: 1.5px solid var(--border);
      border-radius: 6px; font-size: 12.5px; outline: none; transition: all .2s; background: var(--card-bg);
    }
    .data-table input:focus, .data-table select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.1); }
    .col-num { width: 42px; text-align: center; color: var(--text-secondary); font-weight: 600; font-size: 12px; }
    .col-type { width: 88px; }
    .col-type select { min-width: 78px; }
    .col-del { width: 42px; text-align: center; }
    .btn-del-row {
      width: 26px; height: 26px; border: none; background: #fef2f2; color: var(--danger,#ef4444);
      border-radius: 6px; cursor: pointer; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; transition: all .2s;
    }
    .btn-del-row:hover { background: var(--danger,#ef4444); color: #fff; }
    .type-badge { font-size: 11px; padding: 1px 0; }

    /* ===== 甘特图 ===== */
    .gantt-section { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 26px; overflow-x: auto; }
    .gantt-title { text-align: center; font-size: 19px; font-weight: 700; margin-bottom: 6px; }
    .legend { display: flex; justify-content: center; gap: 22px; margin-bottom: 20px; flex-wrap: wrap; }
    .legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
    .legend-swatch { width: 22px; height: 12px; border-radius: 3px; }
    .legend-diamond { width: 13px; height: 13px; background: var(--ms-color, #dc2626); transform: rotate(45deg); border-radius: 2px; }

    .gantt-container { position: relative; min-width: 760px; }
    .gantt-header { display: flex; align-items: stretch; position: sticky; top: 0; z-index: 4; background: var(--card-bg); border-bottom: 2px solid var(--border); min-height: 40px; }
    .header-spacer { width: 240px; min-width: 240px; flex-shrink: 0; border-right: 2px solid var(--border); background: #f8fafc; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text-secondary); position: sticky; left: 0; z-index: 6; }
    .header-timeline { flex: 1; position: relative; display: flex; background: #f8fafc; }
    .header-col { display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600; color: var(--text-secondary); border-left: 1px solid var(--border); user-select: none; overflow: hidden; flex: 0 0 auto; }
    .header-col.major { background: rgba(79,110,247,.08); color: var(--primary-dark); font-weight: 700; border-left: 2px solid #c3cde8; }
    /* 窄列时大格标签缩小字号，密集但不缺失 */
    .header-col.compact { font-size: 9px; }
    .header-col.major.compact { font-size: 9.5px; }
    .header-col.ultra-compact { font-size: 7.5px; }
    .header-col.major.ultra-compact { font-size: 8px; }

    .gantt-row { display: flex; align-items: stretch; position: relative; min-height: 40px; border-bottom: 1px solid #eef1f6; }
    .gantt-row:nth-child(even) { background: rgba(79,110,247,.022); }
    .task-name-cell { width: 240px; min-width: 240px; padding: 7px 13px; font-size: 12.5px; font-weight: 500; color: var(--text); flex-shrink: 0; border-right: 2px solid var(--border); position: sticky; left: 0; background: inherit; z-index: 3; display: flex; align-items: center; }
    .name-inner { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* 任务右对齐时用空格缩进（空两格区分于阶段） */
    .task-num { font-size: inherit; font-weight: 600; color: var(--primary); margin-right: 5px; }
    .gantt-row:nth-child(even) .task-name-cell { background: #fafbff; }
    .timeline-area { flex: 1; position: relative; min-height: 40px; }

    .grid-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid #eef1f6; pointer-events: none; z-index: 1; }
    .grid-line.major { border-left: 2px solid #c3cde8; z-index: 1; }
    /* 总工期 ≤ 大格时，整个时间轴视为一个大格：终点也画粗线 */
    .grid-line.major-end { border-left: 2px solid #c3cde8; z-index: 1; }

    .task-bar { position: absolute; height: 24px; top: 50%; transform: translateY(-50%); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: var(--bar-text-color,#fff); z-index: 2; box-shadow: 0 2px 5px rgba(0,0,0,.15); transition: filter .15s; min-width: 16px; }
    .task-bar:hover { filter: brightness(1.08); }
    .task-bar .bar-text { padding: 0 3px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

    .phase-bar { position: absolute; height: 16px; top: 50%; transform: translateY(-50%); border-radius: 4px; z-index: 2; display: flex; align-items: center; justify-content: center; opacity: .9; }
    .phase-bar .phase-cap { position: absolute; top: -4px; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid; }
    .phase-bar .phase-cap.left { left: -3px; }
    .phase-bar .phase-cap.right { right: -3px; transform: rotate(180deg); }
    .phase-bar .bar-text { font-size: 9px; font-weight: 700; color: var(--bar-text-color,#fff); white-space: nowrap; padding: 0 4px; text-shadow: 0 1px 2px rgba(0,0,0,.3); }

    .milestone { position: absolute; top: 50%; transform: translate(-50%,-50%) rotate(45deg); width: 14px; height: 14px; border-radius: 3px; z-index: 4; box-shadow: 0 2px 6px rgba(0,0,0,.28); }
    .milestone-label { position: absolute; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; z-index: 2; pointer-events: none; padding: 2px 9px; border-radius: 10px; line-height: 1.4; }
    .milestone-line { position: absolute; top: 50%; height: 0; border-top: 1.5px dashed rgba(128,128,140,.5); transform: translateY(-50%); z-index: 1; pointer-events: none; }
    .milestone-vline { position: absolute; left: 0; bottom: 30px; width: 0; border-left: 1.5px dashed rgba(128,128,140,.55); z-index: 2; pointer-events: none; }

    .gantt-footer { margin-top: 16px; font-size: 12.5px; color: var(--text-secondary); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
    .empty-state { text-align: center; padding: 56px 20px; color: var(--text-secondary); }
    .empty-state .icon { font-size: 44px; margin-bottom: 10px; opacity: .4; }
    .empty-state p { font-size: 14px; }

    /* ===== 粘贴弹窗 ===== */
    .modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
    .modal { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 24px; width: min(560px, 92vw); }
    .modal h3 { font-size: 17px; margin-bottom: 6px; }
    .modal p { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.6; }
    .modal p code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 11.5px; color: var(--primary); }
    .modal textarea { width: 100%; height: 180px; border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-size: 12.5px; font-family: ui-monospace, Menlo, Consolas, monospace; resize: vertical; outline: none; }
    .modal textarea:focus { border-color: var(--primary); }
    .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
    .modal-actions button { padding: 9px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; border: none; }
    .btn-cancel { background: var(--bg); color: var(--text-secondary); }
    .btn-cancel:hover { background: #e9edf5; }
    .btn-confirm { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 2px 8px rgba(79,110,247,.35); }

    .toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 11px 22px; border-radius: 24px; font-size: 13px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 200; animation: toastIn .3s ease; }
    @keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

    @keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
    .gantt-row { animation: fadeInUp .28s ease-out both; }

    @media (max-width: 920px) {
      body { padding: 12px; }
      .control-panel { padding: 12px; gap: 12px; }
      .color-set { border-left: none; padding-left: 0; }
      .task-name-cell, .header-spacer { width: 170px; min-width: 170px; }
      .gantt-section { padding: 14px; }
    }

    /* 版权标识 */
    .copyright { text-align: center; font-size: 12px; color: var(--text-secondary); margin-top: 22px; opacity: .85; }
    .copyright a { color: var(--primary); text-decoration: none; font-weight: 600; }
    .copyright a:hover { text-decoration: underline; }
