/* ============================================
   Mini Dashboard — Software House Management
   Design tokens + base styles
   ============================================ */

:root {
  /* Surfaces */
  --bg: #F4F5F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --surface-sunk: #EFF1F5;

  /* Ink */
  --ink-1: #0B1220;
  --ink-2: #1F2A3D;
  --ink-3: #4A5568;
  --ink-4: #6B7488;
  --ink-5: #9AA3B5;
  --line: #E4E7ED;
  --line-2: #EEF0F4;

  /* Brand */
  --brand: oklch(0.52 0.18 275);
  --brand-soft: oklch(0.95 0.03 275);
  --brand-ink: oklch(0.32 0.16 275);

  /* Status — same chroma/lightness band */
  --green: oklch(0.62 0.13 150);
  --green-soft: oklch(0.95 0.04 150);
  --amber: oklch(0.72 0.14 75);
  --amber-soft: oklch(0.96 0.05 80);
  --red: oklch(0.60 0.18 25);
  --red-soft: oklch(0.95 0.04 25);
  --blue: oklch(0.60 0.13 245);
  --blue-soft: oklch(0.95 0.03 245);
  --slate: oklch(0.62 0.02 260);
  --slate-soft: oklch(0.95 0.005 260);
  --violet: oklch(0.58 0.16 305);
  --violet-soft: oklch(0.95 0.04 305);

  /* Spacing */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(11,18,32,0.04), 0 0 0 1px rgba(11,18,32,0.04);
  --shadow-md: 0 4px 12px rgba(11,18,32,0.06), 0 0 0 1px rgba(11,18,32,0.04);
  --shadow-lg: 0 12px 32px rgba(11,18,32,0.12), 0 2px 4px rgba(11,18,32,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink-1);
  font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  direction: rtl;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

/* Latin / numeric utility */
.num, .mono {
  font-family: "IBM Plex Sans", "IBM Plex Mono", monospace;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.mono { font-family: "IBM Plex Mono", monospace; }

/* ============================================
   App shell
   ============================================ */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  margin-left: 4px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink-1);
  position: relative;
  display: grid;
  place-items: center;
  color: white;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.02em;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px 5px auto auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--ink-1);
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 1px;
}

.search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-sunk);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 12px;
  transition: all 120ms ease;
}
.search:focus-within {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
}
.search kbd {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink-4);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  border: 1px solid transparent;
  transition: all 120ms ease;
  position: relative;
}
.icon-btn:hover {
  background: var(--surface-sunk);
  color: var(--ink-1);
}
.icon-btn .dot {
  position: absolute;
  top: 7px;
  left: 7px;
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--surface);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--violet-soft);
  color: var(--violet);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink-1);
  color: white;
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 500;
  font-size: 13px;
  transition: all 120ms ease;
}
.btn-primary:hover { background: var(--ink-2); }
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9px;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all 120ms ease;
}
.btn-ghost:hover { color: var(--ink-1); border-color: var(--ink-5); }
.btn-ghost.active {
  background: var(--ink-1);
  color: white;
  border-color: var(--ink-1);
}

/* Filter chips */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px 12px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
  transition: all 120ms ease;
}
.chip:hover { border-color: var(--ink-5); color: var(--ink-1); }
.chip.active {
  background: var(--ink-1);
  border-color: var(--ink-1);
  color: white;
}
.chip .count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  opacity: 0.7;
}

/* ============================================
   Main layout
   ============================================ */
.main {
  padding: 16px 24px 80px;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 24px 0 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.section-head h2 .ar { font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--ink-2); margin-left: 8px; }
.section-head .meta { font-size: 12px; color: var(--ink-5); }

/* ============================================
   KPI Strip
   ============================================ */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.kpi {
  padding: 14px 18px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.kpi:nth-child(5n) { border-left: none; }
.kpi:nth-child(n+6) { border-bottom: none; }
.kpi-label {
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 500;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-value {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "lnum" 1;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.kpi-value .unit { font-size: 13px; color: var(--ink-4); font-weight: 500; }
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 5px;
  margin-right: auto;
  font-family: "IBM Plex Mono", monospace;
}
.kpi-trend.up { color: var(--green); background: var(--green-soft); }
.kpi-trend.down { color: var(--red); background: var(--red-soft); }
.kpi-trend.flat { color: var(--ink-4); background: var(--surface-sunk); }
.kpi-sub {
  font-size: 11px;
  color: var(--ink-5);
  margin-top: 4px;
}
.kpi-spark {
  position: absolute;
  bottom: 10px;
  left: 14px;
  width: 60px;
  height: 18px;
  opacity: 0.6;
}

/* ============================================
   Grid layout below KPI
   ============================================ */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Kanban Board
   ============================================ */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
.kanban::-webkit-scrollbar { height: 8px; }
.kanban::-webkit-scrollbar-track { background: transparent; }
.kanban::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.column {
  flex: 0 0 280px;
  background: var(--surface-sunk);
  border-radius: var(--r-lg);
  padding: 10px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  max-height: 720px;
}
.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 10px;
}
.column-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.column-title {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
}
.column-count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-4);
  background: var(--surface);
  padding: 2px 7px;
  border-radius: 5px;
}
.column-add {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--ink-4);
}
.column-add:hover { background: var(--surface); color: var(--ink-1); }

.column-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding: 2px;
  margin: -2px;
}
.column-body::-webkit-scrollbar { width: 6px; }
.column-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* Project Card */
.pcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 120ms ease;
  position: relative;
}
.pcard:hover {
  border-color: var(--ink-5);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.pcard.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.pcard-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.pcard-type {
  font-size: 10px;
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 500;
}
.pcard-name {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  line-height: 1.35;
}
.pcard-client {
  font-size: 11.5px;
  color: var(--ink-4);
  margin-top: 2px;
}
.health-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px currentColor;
  opacity: 0.18;
}
.health-pip.inner {
  width: 8px;
  height: 8px;
  opacity: 1;
}
.health-wrap {
  position: relative;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  flex-shrink: 0;
}
.health-wrap::before, .health-wrap::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}
.health-wrap::before {
  inset: 0;
  background: currentColor;
  opacity: 0.18;
}
.health-wrap::after {
  inset: 3px;
  background: currentColor;
}

.priority-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.priority-tag.high { background: var(--red-soft); color: var(--red); }
.priority-tag.med { background: var(--amber-soft); color: oklch(0.45 0.14 75); }
.priority-tag.low { background: var(--slate-soft); color: var(--ink-3); }

.progress {
  height: 5px;
  background: var(--surface-sunk);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  background: var(--ink-1);
  border-radius: 99px;
  transition: width 400ms ease;
}
.progress.health-green .progress-bar { background: var(--green); }
.progress.health-amber .progress-bar { background: var(--amber); }
.progress.health-red .progress-bar { background: var(--red); }
.progress.health-blue .progress-bar { background: var(--blue); }
.progress.health-slate .progress-bar { background: var(--slate); }

.pcard-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-4);
}
.pcard-progress-row .num { color: var(--ink-2); font-weight: 600; }

.pcard-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-4);
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.pcard-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.pcard-meta .danger { color: var(--red); font-weight: 600; }
.pcard-meta .warn { color: oklch(0.50 0.14 75); font-weight: 600; }

.team-stack {
  display: inline-flex;
  margin-right: auto;
}
.team-stack .avatar-xs {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--slate-soft);
  color: var(--ink-2);
  font-size: 9px;
  font-weight: 600;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface);
  margin-right: -6px;
  font-family: "IBM Plex Sans", sans-serif;
}
.team-stack .avatar-xs:first-child { margin-right: 0; }
.team-stack .avatar-xs.more { background: var(--surface-sunk); color: var(--ink-4); }

/* Risk meter (mini) */
.risk-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}
.risk-mini .bar {
  width: 24px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-sunk);
  position: relative;
  overflow: hidden;
}
.risk-mini .bar > i {
  position: absolute;
  inset: 0;
  width: var(--w, 50%);
  border-radius: 2px;
  background: currentColor;
}

/* Status colors mapping */
.s-new { color: var(--blue); }
.s-progress { color: var(--brand); }
.s-waiting { color: var(--violet); }
.s-review { color: oklch(0.55 0.13 200); }
.s-delayed { color: var(--red); }
.s-support { color: var(--amber); }
.s-completed { color: var(--slate); }
.bg-s-new { background: var(--blue); }
.bg-s-progress { background: var(--brand); }
.bg-s-waiting { background: var(--violet); }
.bg-s-review { background: oklch(0.55 0.13 200); }
.bg-s-delayed { background: var(--red); }
.bg-s-support { background: var(--amber); }
.bg-s-completed { background: var(--slate); }

/* ============================================
   Right rail — alerts + follow-up
   ============================================ */
.rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 110px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
}
.card-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.card-head .badge {
  margin-right: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  background: var(--surface-sunk);
  color: var(--ink-3);
  padding: 1px 7px;
  border-radius: 5px;
}
.card-head .badge.danger { background: var(--red-soft); color: var(--red); }
.card-body {
  padding: 8px 4px;
}

.alert-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 120ms ease;
  cursor: pointer;
  align-items: flex-start;
}
.alert-item:hover { background: var(--surface-sunk); }
.alert-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.alert-icon.r { background: var(--red-soft); color: var(--red); }
.alert-icon.a { background: var(--amber-soft); color: oklch(0.48 0.14 75); }
.alert-icon.b { background: var(--blue-soft); color: var(--blue); }
.alert-icon.v { background: var(--violet-soft); color: var(--violet); }
.alert-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-1);
  line-height: 1.4;
}
.alert-sub {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 2px;
  font-family: "IBM Plex Sans Arabic", "IBM Plex Mono", monospace;
}
.alert-sub.num { font-family: "IBM Plex Mono", monospace; }
.alert-time {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--ink-5);
  margin-right: auto;
  flex-shrink: 0;
}

/* Follow-up list */
.followup-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
}
.followup-item .check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: all 120ms ease;
  display: grid;
  place-items: center;
  color: transparent;
}
.followup-item .check:hover { border-color: var(--ink-3); }
.followup-item.done .check {
  background: var(--green);
  border-color: var(--green);
  color: white;
}
.followup-item.done .title { text-decoration: line-through; color: var(--ink-4); }
.followup-item .title { font-weight: 500; line-height: 1.4; }
.followup-item .sub { font-size: 11px; color: var(--ink-4); margin-top: 2px; }
.followup-item .tag {
  margin-right: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-sunk);
  color: var(--ink-3);
  flex-shrink: 0;
}

/* ============================================
   Lower grid: team workload + support + timeline
   ============================================ */
.lower-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 1100px) {
  .lower-grid { grid-template-columns: 1fr; }
}

/* Team workload table */
.team-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.team-table th {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-5);
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line-2);
}
.team-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.team-table tr:last-child td { border-bottom: none; }
.team-table tr:hover td { background: var(--surface-2); }
.team-name {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.team-name > .avatar-sm {
  flex-shrink: 0;
}
.team-name > div { min-width: 0; }
.team-table .avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
}
.team-name .role { font-size: 11px; color: var(--ink-4); font-weight: 400; }
.team-table td:first-child { min-width: 180px; }
.overload-flag { white-space: nowrap; }
.team-table { table-layout: auto; }
.load-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.load-bar .bar {
  flex: 1;
  height: 6px;
  background: var(--surface-sunk);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  max-width: 120px;
}
.load-bar .bar > i {
  position: absolute;
  inset: 0;
  width: var(--w, 50%);
  border-radius: 4px;
  background: var(--brand);
}
.load-bar .bar.high > i { background: var(--red); }
.load-bar .bar.med > i { background: var(--amber); }
.load-bar .bar.low > i { background: var(--green); }
.load-bar .pct {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  min-width: 36px;
  text-align: left;
}
.load-bar .pct.high { color: var(--red); }
.load-bar .pct.med { color: oklch(0.48 0.14 75); }
.load-bar .pct.low { color: var(--green); }

.overload-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--red-soft);
  color: var(--red);
  font-family: "IBM Plex Mono", monospace;
}

/* Support / SLA */
.sla-list {
  display: flex;
  flex-direction: column;
}
.sla-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
  align-items: center;
  cursor: pointer;
  transition: background 120ms ease;
}
.sla-row:hover { background: var(--surface-2); }
.sla-row:last-child { border-bottom: none; }
.ticket-id {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-4);
  background: var(--surface-sunk);
  padding: 2px 7px;
  border-radius: 5px;
}
.sla-title {
  font-size: 12.5px;
  font-weight: 500;
}
.sla-sub {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 2px;
}
.sla-meter {
  width: 80px;
  height: 22px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}
.sla-meter .ring {
  width: 22px;
  height: 22px;
}
.sla-meter .label {
  font-weight: 600;
}
.sla-meter.ok .label { color: var(--green); }
.sla-meter.warn .label { color: oklch(0.48 0.14 75); }
.sla-meter.breach .label { color: var(--red); }

/* Donut */
.donut-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  padding: 16px;
  align-items: center;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.legend-item .sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-item .name { flex: 1; color: var(--ink-3); }
.legend-item .val {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  color: var(--ink-1);
}

/* ============================================
   Timeline / Calendar
   ============================================ */
.timeline {
  padding: 14px;
}
.timeline-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  font-size: 12px;
}
.timeline-header {
  display: grid;
  grid-template-columns: repeat(var(--days, 30), 1fr);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  position: relative;
}
.timeline-week-marker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--ink-5);
  text-align: center;
  border-right: 1px dashed var(--line-2);
  padding: 4px 0;
}
.timeline-week-marker:last-child { border-right: none; }
.timeline-row {
  display: contents;
}
.timeline-label {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
}
.timeline-label .sub { font-size: 11px; color: var(--ink-4); font-weight: 400; }
.timeline-track {
  position: relative;
  border-bottom: 1px solid var(--line-2);
  height: 38px;
  background: linear-gradient(to left, transparent calc(100% / 4 - 1px), var(--line-2) calc(100% / 4 - 1px), var(--line-2) calc(100% / 4), transparent calc(100% / 4));
  background-size: 25% 100%;
}
.timeline-bar {
  position: absolute;
  top: 8px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 600;
  color: white;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
  transition: transform 120ms ease;
}
.timeline-bar:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.timeline-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--red);
  z-index: 2;
}
.timeline-today::before {
  content: "TODAY";
  position: absolute;
  top: -16px;
  right: -22px;
  font-size: 9px;
  font-family: "IBM Plex Mono", monospace;
  color: var(--red);
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ============================================
   Project Drawer
   ============================================ */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11,18,32,0.4);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 520px;
  max-width: 95vw;
  background: var(--surface);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 32px rgba(11,18,32,0.18);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer-head .row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.drawer-head .pcard-type {
  font-size: 10px;
}
.drawer-close {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  margin-right: auto;
  color: var(--ink-4);
}
.drawer-close:hover { background: var(--surface-sunk); color: var(--ink-1); }
.drawer-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.drawer-head .client {
  font-size: 13px;
  color: var(--ink-4);
  margin-top: 4px;
}

.drawer-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
}
.drawer-stat {
  padding: 14px 16px;
  border-left: 1px solid var(--line-2);
}
.drawer-stat:last-child { border-left: none; }
.drawer-stat .l { font-size: 10px; color: var(--ink-4); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.drawer-stat .v {
  font-family: "IBM Plex Sans", system-ui;
  font-feature-settings: "tnum" 1;
  font-size: 18px;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: -0.01em;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}
.drawer-body::-webkit-scrollbar { width: 6px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.drawer-section {
  margin-bottom: 22px;
}
.drawer-section h4 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.phase-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 12.5px;
}
.phase-row:last-child { border-bottom: none; }
.phase-num {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-sunk);
  color: var(--ink-3);
  display: grid;
  place-items: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}
.phase-row.done .phase-num { background: var(--green); color: white; }
.phase-row.active .phase-num { background: var(--brand); color: white; }
.phase-name { flex: 1; font-weight: 500; }
.phase-row.done .phase-name { color: var(--ink-4); text-decoration: line-through; }
.phase-pct {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 600;
}
.phase-bar {
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-sunk);
  overflow: hidden;
}
.phase-bar > i {
  display: block;
  height: 100%;
  background: var(--brand);
  width: var(--w, 50%);
}
.phase-row.done .phase-bar > i { background: var(--green); }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  font-size: 12px;
  position: relative;
}
.activity-item::before {
  content: "";
  position: absolute;
  right: 5px;
  top: 18px;
  bottom: -8px;
  width: 1px;
  background: var(--line);
}
.activity-item:last-child::before { display: none; }
.activity-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--brand);
  flex-shrink: 0;
  margin-top: 4px;
  z-index: 1;
}
.activity-dot.g { border-color: var(--green); }
.activity-dot.r { border-color: var(--red); }
.activity-text { flex: 1; line-height: 1.45; }
.activity-text .who { font-weight: 600; }
.activity-time {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--ink-5);
  white-space: nowrap;
  margin-right: auto;
}

.drawer-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  background: var(--surface-2);
}
.drawer-foot .btn-primary,
.drawer-foot .btn-ghost { flex: 1; justify-content: center; }
.drawer-foot .btn-ghost.escalate { color: var(--red); border-color: var(--red-soft); }
.drawer-foot .btn-ghost.escalate:hover { background: var(--red-soft); }

.risk-gauge {
  display: flex;
  align-items: center;
  gap: 12px;
}
.risk-gauge .score {
  font-family: "IBM Plex Sans", system-ui;
  font-feature-settings: "tnum" 1;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.risk-gauge.r-low .score { color: var(--green); }
.risk-gauge.r-med .score { color: oklch(0.48 0.14 75); }
.risk-gauge.r-high .score { color: var(--red); }
.risk-gauge .label-stack { display: flex; flex-direction: column; gap: 2px; }
.risk-gauge .label-stack .l { font-size: 11px; color: var(--ink-4); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.risk-gauge .label-stack .v { font-size: 13px; font-weight: 600; }

.risk-bars {
  display: flex;
  gap: 3px;
  align-items: flex-end;
}
.risk-bars i {
  width: 5px;
  background: var(--line);
  border-radius: 1px;
}
.risk-bars i.on { background: currentColor; }

/* Tag pills */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-sunk);
  color: var(--ink-3);
}
.tag.client-dep { background: var(--violet-soft); color: var(--violet); }
.tag.internal-dep { background: var(--amber-soft); color: oklch(0.48 0.14 75); }
.tag.mgmt { background: var(--red-soft); color: var(--red); }

/* Empty / completed column visual treatment */
.column.completed .pcard { opacity: 0.85; }

/* ============================================
   Capacity Planner
   ============================================ */
.capacity {
  display: flex;
  flex-direction: column;
}
.cap-group {
  border-bottom: 1px solid var(--line);
}
.cap-group:last-child { border-bottom: none; }

.cap-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-2);
}
.cap-group-tag {
  width: 4px;
  height: 18px;
  border-radius: 2px;
}
.cap-group-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.cap-group-head .en {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--ink-5);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cap-group-head .count {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-3);
  padding: 2px 7px;
  border-radius: 5px;
}
.cap-group-head .agg {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--ink-4);
}
.cap-group-head .agg .num {
  font-weight: 600;
  color: var(--ink-2);
}

.cap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 0;
}

.cap-card {
  padding: 14px 16px;
  border-left: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.cap-card:hover { background: var(--surface-2); }

.cap-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cap-card-name {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
}
.cap-card-role {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 1px;
  font-family: "IBM Plex Sans", "IBM Plex Sans Arabic", sans-serif;
}
.cap-card-cap {
  margin-right: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.cap-card-cap .pct {
  font-family: "IBM Plex Sans", system-ui;
  font-feature-settings: "tnum" 1;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.cap-card-cap.high .pct { color: var(--red); }
.cap-card-cap.med .pct { color: oklch(0.50 0.14 75); }
.cap-card-cap.low .pct { color: var(--green); }
.cap-card-cap .pct-sub {
  font-size: 10px;
  color: var(--ink-5);
  font-family: "IBM Plex Mono", monospace;
}
.cap-card-bar {
  height: 5px;
  background: var(--surface-sunk);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.cap-card-bar > i {
  display: block;
  height: 100%;
  width: var(--w, 50%);
  border-radius: 99px;
  background: var(--brand);
  transition: width 240ms ease;
}
.cap-card-bar.high > i { background: var(--red); }
.cap-card-bar.med > i { background: var(--amber); }
.cap-card-bar.low > i { background: var(--green); }
.cap-card-bar .overage {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,0.5) 0 3px, transparent 3px 6px);
  width: var(--over, 0);
}

/* timeline strip — 3 weeks */
.cap-timeline {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 11px;
}
.cap-timeline-label {
  font-size: 10px;
  color: var(--ink-5);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.cap-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  position: relative;
}
.cap-week {
  height: 26px;
  border-radius: 6px;
  background: var(--surface-sunk);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 0 6px;
  border: 1px solid transparent;
}
.cap-week.this {
  background: var(--brand-soft);
  border-color: color-mix(in oklab, var(--brand) 20%, transparent);
}
.cap-week .wk-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  z-index: 0;
}
.cap-week.this .wk-label { color: var(--brand-ink, var(--brand)); }
.cap-week .wk-fill {
  position: absolute;
  inset: 0;
  height: 100%;
  width: var(--w, 0%);
  background: linear-gradient(90deg, var(--brand) 0%, color-mix(in oklab, var(--brand) 70%, white) 100%);
  opacity: 0.85;
  border-radius: 5px;
  z-index: 1;
}
.cap-week .wk-fill.high { background: var(--red); opacity: 0.9; }
.cap-week .wk-fill.med  { background: var(--amber); opacity: 0.9; }
.cap-week .wk-fill.low  { background: var(--green); opacity: 0.85; }
.cap-week .wk-pct {
  position: relative;
  z-index: 2;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  color: white;
  margin-right: auto;
  mix-blend-mode: difference;
}

/* tasks list */
.cap-tasks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.cap-tasks-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cap-tasks-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 2px;
}
.cap-tasks-head .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.cap-tasks-head .dot.doing { background: var(--brand); }
.cap-tasks-head .dot.todo  { background: var(--blue); }

.cap-task {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1.4;
  padding: 2px 0;
}
.cap-task .marker {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--surface-sunk);
  display: grid;
  place-items: center;
  margin-top: 1px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-3);
}
.cap-task.doing .marker { background: var(--brand-soft); color: var(--brand); }
.cap-task.todo  .marker { background: var(--blue-soft); color: var(--blue); }
.cap-task .ttitle {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cap-task .test {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--ink-5);
  white-space: nowrap;
  flex-shrink: 0;
}
.cap-task .pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-top: 6px;
  flex-shrink: 0;
}

.cap-card.overload::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid var(--red);
  border-radius: 0;
  opacity: 0.25;
}
.cap-card.overload .overload-flag {
  position: absolute;
  top: 12px;
  left: 14px;
}

/* Toolbar above capacity */
.cap-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}
.cap-toolbar .legend {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--ink-4);
}
.cap-toolbar .legend .sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-left: 6px;
  vertical-align: middle;
}

/* Tweaks panel z-index */
[data-tweaks-panel] { z-index: 80 !important; }
