:root {
  --bg: #f0fafb;
  --surface: #ffffff;
  --surface2: #f5fdfe;
  --border: #cdf0f4;
  --border2: #9de4eb;
  --text: #0d2b2e;
  --text2: #2d6b72;
  --text3: #5a9ea6;
  --accent: #1fcfe1;
  --accent-dark: #0fa8b8;
  --accent-text: #0d2b2e;
  --green: #0f766e;
  --green-bg: #ccfbf1;
  --amber: #b45309;
  --amber-bg: #fef9c3;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --blue: #1d4ed8;
  --blue-bg: #eff6ff;
  --purple: #6d28d9;
  --purple-bg: #f5f3ff;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 13px; }

/* ── Heatmap ───────────────────────────────────────────────────── */
.heatmap-toolbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface);
}
.heatmap-title { font-weight: 600; font-size: 13px; }
.year-switcher { display: flex; gap: 4px; }
.year-btn {
  padding: 4px 10px; border: 1px solid var(--border2); border-radius: 5px;
  background: var(--surface); font-size: 11px; font-family: var(--mono);
  cursor: pointer; color: var(--text2); transition: all .15s;
}
.year-btn:hover { border-color: var(--accent); color: var(--text); }
.year-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.heatmap-legend { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.legend-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text2); }
.legend-box { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }

.heatmap-wrap { flex: 1; overflow: auto; }

.heatmap-table {
  border-collapse: collapse; font-size: 11px; min-width: max-content;
}
.heatmap-table th { background: var(--surface); position: sticky; top: 0; z-index: 2; }
.heatmap-table th.eng-col { left: 0; z-index: 3; min-width: 200px; }
.heatmap-table td.eng-col {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
  border-right: 2px solid var(--border2);
}

.month-header {
  background: var(--surface2); border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border); font-weight: 600; font-size: 10px;
  text-align: center; padding: 4px 0; color: var(--text2); letter-spacing: .3px;
}
.week-th {
  border-bottom: 1px solid var(--border); border-right: 1px solid var(--border2);
  padding: 3px 2px; font-family: var(--mono); font-size: 9px; color: var(--text3);
  text-align: center; min-width: 30px; max-width: 30px;
}
.week-th.has-holiday { background: #fef9c3; color: var(--amber); font-weight: 600; }
.week-th.cur-week { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.heat-cell.cur-week { box-shadow: inset 1px 0 0 var(--accent), inset -1px 0 0 var(--accent); }
.eng-th {
  border-bottom: 1px solid var(--border); border-right: 2px solid var(--border2);
  padding: 4px 10px; font-weight: 600; color: var(--text3); font-size: 9px;
  text-transform: uppercase; letter-spacing: .6px; text-align: left;
  background: var(--surface2);
}

.eng-cell {
  padding: 4px 10px; border-right: 2px solid var(--border2); white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.eng-cell-inner {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  cursor: pointer; color: var(--text2); font-size: 12px; font-weight: 500;
}
.eng-cell-inner:hover { color: var(--accent-dark); }
.eng-role-tag {
  font-size: 9px; font-weight: 400; color: var(--text3);
  font-family: var(--mono);
}

.heat-cell {
  border-right: 1px solid rgba(0,0,0,.05);
  border-bottom: 1px solid rgba(0,0,0,.05);
  text-align: center; cursor: default; position: relative;
  width: 30px; max-width: 30px; height: 28px;
}
.heat-cell:hover { outline: 2px solid var(--accent); z-index: 4; }
.heat-cell.selecting { background: rgba(31,207,225,.25) !important; outline: 1px solid var(--accent); z-index: 4; }
.heat-cell.admin-editable { cursor: pointer; }
.heat-val {
  font-family: var(--mono); font-size: 9px; line-height: 28px;
  user-select: none; display: block;
}
.heat-input {
  width: 100%; height: 28px; border: none; text-align: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: white; padding: 0; outline: 2px solid var(--accent);
}

/* Cell colours */
.c-free         { background: #f8fffe; }
.c-low          { background: #dcfce7; }   /* 1–100% external */
.c-mid          { background: #fef9c3; }   /* 101–150% */
.c-high         { background: #fee2e2; }   /* >150% */
.c-hol          { background: #fef9c3; }   /* holiday header */
.c-internal-low { background: #dbeafe; }   /* 1–100% internal only */
.c-mixed {                                 /* external + internal */
  background: repeating-linear-gradient(
    135deg, #dcfce7 0px, #dcfce7 5px, #dbeafe 5px, #dbeafe 10px
  );
}
.c-unavail {
  background: repeating-linear-gradient(
    135deg, #e5e7eb 0px, #e5e7eb 3px, #f3f4f6 3px, #f3f4f6 8px
  );
  color: var(--text3);
}
.c-unavail-conflict {
  background: repeating-linear-gradient(
    135deg, #fca5a5 0px, #fca5a5 3px, #fee2e2 3px, #fee2e2 8px
  );
  color: #dc2626;
  font-weight: 600;
}

/* Row separator between engineers */
tr.eng-row td { border-top: 2px solid var(--border); }

/* ── Projects view ─────────────────────────────────────────────── */
.view-toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface); flex-wrap: wrap;
}
.view-title { font-weight: 600; font-size: 13px; margin-right: 4px; }
.filter-group { display: flex; gap: 3px; }
.filter-btn {
  padding: 4px 10px; border: 1px solid var(--border2); border-radius: 5px;
  background: var(--surface); font-size: 11px; cursor: pointer; color: var(--text2);
  font-family: var(--sans); transition: all .15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.filter-sep { width: 1px; background: var(--border2); margin: 2px 4px; }
.btn-add {
  margin-left: auto; padding: 5px 14px; background: var(--accent); color: var(--accent-text);
  border: none; border-radius: 6px; font-size: 12px; font-weight: 600; font-family: var(--sans); cursor: pointer;
}
.btn-add:hover { background: var(--accent-dark); }

.projects-sections { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 24px; }
.projects-section-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  color: var(--text3); padding-bottom: 8px; border-bottom: 2px solid var(--border2); margin-bottom: 12px;
}
.projects-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-content: start;
}
.proj-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; cursor: default; transition: border-color .15s;
}
.proj-card:hover { border-color: var(--border2); }
.proj-card.admin-click { cursor: pointer; }
.proj-card-header { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.proj-name { font-weight: 600; font-size: 13px; flex: 1; line-height: 1.3; }
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px;
  font-size: 10px; font-weight: 600; white-space: nowrap; flex-shrink: 0;
}
.badge-External  { background: var(--blue-bg);   color: var(--blue); }
.badge-Internal  { background: var(--green-bg);  color: var(--green); }
.badge-Backlog   { background: var(--blue-bg);   color: var(--blue); }
.badge-Prospect  { background: var(--purple-bg); color: var(--purple); }
.badge-Active    { background: var(--green-bg);  color: var(--green); }
.badge-Archived  { background: #f1f5f9;          color: #64748b; }
.proj-badges { display: flex; gap: 4px; margin-bottom: 10px; }
.proj-team { display: flex; flex-wrap: wrap; gap: 4px; }
.team-chip {
  padding: 2px 8px; background: var(--bg); border-radius: 4px; font-size: 11px;
  color: var(--text2); border: 1px solid var(--border); display: flex; align-items: center; gap: 4px;
}
.chip-role { font-size: 9px; font-weight: 700; color: var(--text3); font-family: var(--mono); }

/* ── Engineer Detail ─────────────────────────────────────────────── */
.detail-wrap { flex: 1; overflow: auto; padding: 24px 28px; }
.detail-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.detail-avatar {
  width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 15px; font-weight: 700;
  background: var(--accent); color: var(--accent-text); flex-shrink: 0;
}
.detail-name { font-size: 18px; font-weight: 600; }
.detail-role { font-size: 12px; color: var(--text3); font-family: var(--mono); margin-top: 2px; }
.detail-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px;
}
.stat-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
.stat-val { font-size: 24px; font-weight: 600; font-family: var(--mono); color: var(--text); }
.stat-val.warn { color: var(--amber); }
.stat-val.danger { color: var(--red); }

.detail-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text3); margin-bottom: 10px; }

.mini-heatmap-wrap { margin-bottom: 24px; }
.mini-year-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.mini-year-label { font-family: var(--mono); font-size: 10px; color: var(--text3); width: 32px; flex-shrink: 0; }
.mini-cells { display: flex; gap: 2px; flex-wrap: nowrap; }
.mini-cell {
  width: 12px; height: 14px; border-radius: 2px; flex-shrink: 0;
}

.proj-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 24px; }
.proj-table th {
  text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text3); padding: 6px 10px;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.proj-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.proj-table tr:last-child td { border-bottom: none; }
.proj-table tr:hover td { background: var(--bg); }

/* ── Settings ───────────────────────────────────────────────────── */
.settings-wrap {
  flex: 1; min-height: 0; overflow: auto; padding: 24px 28px;
  display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: min-content; gap: 24px; align-content: start;
}
.settings-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.settings-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.settings-panel-title { font-weight: 600; font-size: 13px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text3); padding: 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface2);
}
.data-table td { padding: 9px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600;
}
.pill-active   { background: var(--green-bg); color: var(--green); }
.pill-inactive { background: #f1f5f9; color: #94a3b8; }
.pill-admin    { background: var(--accent); color: var(--accent-text); }
.pill-viewer   { background: var(--blue-bg); color: var(--blue); }
.row-actions { display: flex; gap: 4px; }

/* ── Tooltip ───────────────────────────────────────────────────── */
.tooltip {
  position: fixed; pointer-events: none; z-index: 999;
  background: var(--text); color: #fff; border-radius: 6px;
  padding: 6px 10px; font-size: 11px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.2); display: none;
}
.tooltip.visible { display: block; }

/* ── Org Chart ─────────────────────────────────────────────────── */
#view-orgchart { overflow: auto; padding: 24px; }

.org-chart { display: flex; flex-direction: column; align-items: flex-start; }
.org-chart-title { font-size: 16px; font-weight: 600; margin-bottom: 24px; color: var(--text); }

/* Tree UL/LI structure */
.org-tree, .org-tree ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; justify-content: center;
}
.org-tree { flex-direction: column; align-items: center; }
.org-tree ul { padding-top: 20px; position: relative; flex-wrap: nowrap; }

/* Vertical line down from parent row */
.org-tree ul::before {
  content: ''; position: absolute; top: 0; left: 50%;
  border-left: 1px solid var(--border); height: 20px;
}
.org-tree li {
  display: flex; flex-direction: column; align-items: center;
  padding: 0 16px; position: relative;
}
/* Horizontal connector */
.org-tree li::before, .org-tree li::after {
  content: ''; position: absolute; top: 0;
  border-top: 1px solid var(--border); width: 50%;
}
.org-tree li::before { right: 50%; }
.org-tree li::after  { left: 50%; }
.org-tree li:only-child::before,
.org-tree li:only-child::after  { border: none; }
.org-tree li:first-child::before { border: none; }
.org-tree li:last-child::after   { border: none; }

/* Vertical drop from horizontal bar to node */
.org-node-wrap { position: relative; padding-top: 20px; }
.org-node-wrap::before {
  content: ''; position: absolute; top: 0; left: 50%;
  border-left: 1px solid var(--border); height: 20px;
}
.org-tree > li > .org-node-wrap::before { display: none; }

/* Node card */
.org-node {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 18px; text-align: center; cursor: pointer; min-width: 130px;
  transition: border-color .15s, box-shadow .15s;
}
.org-node:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.org-avatar-sm {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; margin: 0 auto 6px;
}
.org-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }
.org-role { font-size: 10px; color: var(--text3); margin-top: 2px; font-family: var(--mono); }
