/* ── LAYOUT ──────────────────────────────────────────────────────── */
.layout {
  display: flex; height: 100%;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────── */
.sidebar {
  width: 200px; min-width: 140px; max-width: 280px;
  background: rgba(255,255,255,0.78); backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0;
  resize: horizontal;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 3px 8px;
  background: rgba(44,81,113,0.06);
  border-bottom: 1px solid var(--border);
}
.sidebar-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); }

.project-list { overflow-y: auto; flex: 0 0 auto; max-height: 140px; }
.project-item {
  padding: 5px 10px; cursor: pointer; font-size: 12px; line-height: 1.2;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  transition: background .1s;
}
.project-item:hover { background: rgba(70,130,180,.08); }
.project-item.active { background: rgba(70,130,180,.15); font-weight: 600; color: var(--primary); }
.project-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item-code { font-size: 9px; color: var(--text-muted); margin-right: 4px; font-family: monospace; }
.project-edit-btn { font-size: 10px; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 1px 3px; }

/* WBS TREE */
.wbs-tree { overflow-y: auto; flex: 1; }
.wbs-node {
  display: flex; align-items: center;
  padding: 4px 8px; cursor: pointer;
  border-bottom: 1px solid rgba(44,81,113,0.07);
  font-size: 12px; line-height: 1.2; transition: background .1s;
}
.wbs-node:hover { background: rgba(70,130,180,.07); }
.wbs-node.active { background: rgba(70,130,180,.14); color: var(--primary); font-weight: 600; }
.wbs-indent { display: inline-block; width: 12px; flex-shrink: 0; }
.wbs-toggle { width: 12px; flex-shrink: 0; text-align: center; font-size: 9px; color: var(--text-muted); }
.wbs-code { font-family: monospace; font-size: 9px; color: var(--primary-mid); margin-right: 4px; white-space: nowrap; }
.wbs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.wbs-edit-btn { font-size: 9px; color: var(--text-muted); background: none; border: none; cursor: pointer; padding: 1px 3px; opacity: 0; }
.wbs-node:hover .wbs-edit-btn { opacity: 1; }

/* ── GANTT AREA ───────────────────────────────────────────────────── */
.gantt-area {
  flex: 1; display: flex; flex-direction: column;
  background: rgba(255,255,255,0.55); overflow: hidden;
}
.gantt-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 3px 10px; background: rgba(255,255,255,0.7);
  border-bottom: 1px solid var(--border);
  gap: 8px; flex-shrink: 0;
}
.gantt-toolbar-left, .gantt-toolbar-right { display: flex; align-items: center; gap: 10px; }
.gantt-status { font-size: 11px; color: var(--text-muted); }

.gantt-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: rgba(255,255,255,0.7); font-size: 1.1rem; text-align: center;
}

.gantt-container {
  flex: 1; display: flex; overflow: hidden;
}

/* Task table (left column) */
.task-table-wrap {
  width: 560px; min-width: 300px; max-width: 900px;
  overflow-x: auto; overflow-y: hidden;
  border-right: 2px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.task-table-header {
  display: flex; background: rgba(44,81,113,0.08);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.task-table-header .th {
  padding: 3px 5px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px;
  color: var(--primary); white-space: nowrap; user-select: none;
  font-family: monospace;
}
.task-table-body { overflow-y: auto; flex: 1; }
.task-row {
  display: flex; align-items: center;
  height: 22px; border-bottom: 1px solid rgba(44,81,113,0.06);
  cursor: pointer; transition: background .1s;
}
.task-row:hover { background: rgba(70,130,180,.08); }
.task-row.selected { background: rgba(70,130,180,.18); font-weight: 600; }
.task-row.critical { border-left: 2px solid var(--danger); }
.task-cell {
  padding: 0 4px; font-size: 11px; font-family: monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-cell.code { color: var(--primary-mid); width: 100px; flex-shrink: 0; }
.task-cell.name { flex: 1; min-width: 120px; }
.task-cell.wbs { width: 80px; flex-shrink: 0; color: var(--primary-mid); font-size: 10px; }
.task-cell.actvcode { width: 68px; flex-shrink: 0; font-size: 10px; color: #444;
  border-left: 3px solid var(--col-color, transparent); padding-left: 5px; }
.task-cell.dur { width: 44px; text-align: right; flex-shrink: 0; color: var(--text-muted); }
.task-cell.tf { width: 40px; text-align: right; flex-shrink: 0; color: var(--text-muted); }
.task-indent { display: inline-block; flex-shrink: 0; }

/* SVG Gantt chart (right column) */
.gantt-svg-wrap {
  flex: 1; overflow: auto; position: relative;
}
.gantt-svg-wrap svg { display: block; }

/* Gantt SVG elements */
.gantt-header-row { fill: rgba(44,81,113,0.08); }
.gantt-today-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4,3; }
.gantt-bar { rx: 3; }
.gantt-bar-normal { fill: var(--primary-mid); }
.gantt-bar-critical { fill: var(--danger); }
.gantt-bar-loe { fill: #9b59b6; }
.gantt-milestone { }
.gantt-float-line { stroke: var(--primary-light); stroke-width: 1.5; stroke-dasharray: 3,2; opacity: .6; }
.gantt-link { fill: none; stroke: rgba(44,81,113,0.55); stroke-width: 1.2; }
.gantt-link-critical { stroke: var(--danger); }
.gantt-grid-line { stroke: rgba(44,81,113,0.07); }
.gantt-weekend { fill: rgba(44,81,113,0.04); }

/* Tooltip */
.gantt-tooltip {
  position: fixed; z-index: 150;
  background: rgba(26,32,44,0.95); color: #fff;
  padding: 10px 14px; border-radius: 8px;
  font-size: 12px; line-height: 1.6; pointer-events: none;
  max-width: 280px; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* Activity Codes Manager */
.actv-layout { display: flex; gap: 16px; min-height: 300px; }
.actv-types-col { width: 200px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.actv-values-col { flex: 1; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.actv-col-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: rgba(44,81,113,0.06); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--primary); }
.actv-type-item, .actv-value-item {
  padding: 8px 12px; cursor: pointer; font-size: 12px;
  border-bottom: 1px solid rgba(44,81,113,0.07);
  display: flex; align-items: center; gap: 6px;
}
.actv-type-item:hover, .actv-value-item:hover { background: rgba(70,130,180,.08); }
.actv-type-item.active, .actv-value-item.active { background: rgba(70,130,180,.15); font-weight: 600; }
.actv-scope-badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; font-weight: 700; text-transform: uppercase; }
.actv-scope-global { background: rgba(70,130,180,.2); color: var(--primary); }
.actv-scope-project { background: rgba(56,161,105,.2); color: var(--success); }
.actv-value-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.actv-value-indent { display: inline-block; width: 14px; flex-shrink: 0; }

/* Collapsible section titles */
.collapsible-title { display: flex; align-items: center; justify-content: space-between; cursor: default; }
.collapse-btn { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--text-muted); padding: 0 4px; line-height: 1; transition: transform .2s; }
.collapsible-body { overflow: hidden; transition: max-height .25s ease; max-height: 600px; }
.collapsible-body.collapsed { max-height: 0; }
.collapse-btn.collapsed { transform: rotate(-90deg); }

/* Task code assignments inline */
.task-code-assign { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.task-code-assign label { font-size: 11px; color: var(--text-muted); width: 80px; flex-shrink: 0; font-weight: 600; }
.task-code-assign select { flex: 1; padding: 3px 6px; border-radius: 6px; border: 1.5px solid var(--border); font-size: 11px; font-family: var(--font); }

/* Predecessor rows */
.pred-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.pred-row select { flex: 1; padding: 5px 8px; border-radius: 6px; border: 1.5px solid var(--border); font-size: 12px; font-family: var(--font); min-width: 0; }
.pred-row input { width: 60px; padding: 5px 6px; border-radius: 6px; border: 1.5px solid var(--border); font-size: 12px; font-family: var(--font); flex-shrink: 0; }
.pred-remove { background: none; border: none; cursor: pointer; color: var(--danger); font-size: 16px; line-height: 1; flex-shrink: 0; }
.pred-jump-btn { background: none; border: none; cursor: pointer; color: var(--primary); font-size: 14px; line-height: 1; flex-shrink: 0; padding: 2px 4px; border-radius: 4px; }
.pred-jump-btn:hover { background: rgba(70,130,180,.15); }

/* Successor navigation rows */
.dep-nav-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(44,81,113,0.08); }
.dep-nav-row:last-child { border-bottom: none; }
.dep-type-badge { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: rgba(70,130,180,.15); color: var(--primary); flex-shrink: 0; font-family: monospace; }
.dep-nav-name { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-jump-btn { background: none; border: none; cursor: pointer; color: var(--primary); font-size: 16px; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.dep-jump-btn:hover { background: rgba(70,130,180,.15); }
.dep-nav-empty { font-size: 12px; color: var(--text-muted); padding: 4px 0; }

/* Import result */
.import-result { margin-top: 16px; font-size: 13px; }
.import-result.success { color: var(--success); }
.import-result.error { color: var(--danger); }
.import-warnings { color: var(--accent); margin-top: 8px; font-size: 12px; }
