/* GSD staging — light theme, plain CSS, no framework. */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e4e7eb;
  --border-strong: #cbd2d9;
  --text: #1f2933;
  --text-muted: #616e7c;
  --text-faint: #9aa5b1;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --overdue: #dc2626;
  --overdue-soft: #fee2e2;
  --today: #d97706;
  --today-soft: #fef3c7;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --action: #7c3aed;
  --effort: #0891b2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Topbar === */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand a {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.brand .tag {
  display: inline-block;
  margin-left: .4rem;
  padding: .1rem .45rem;
  background: var(--today-soft);
  color: var(--today);
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.nav {
  display: flex;
  gap: .25rem;
}
.nav a {
  padding: .45rem .9rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.mission-pill {
  margin-left: auto;
  padding: .35rem .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* === Layout === */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-faint);
  font-size: .8rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* === Page head === */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  margin-bottom: 1.5rem;
}
.page-head h1 {
  margin: 0 0 .25rem 0;
  font-size: 1.65rem;
  font-weight: 700;
}
.page-head .muted {
  margin: 0;
  color: var(--text-muted);
  font-size: .9rem;
}
.back {
  font-size: .85rem;
  color: var(--text-muted);
}

.stats {
  display: flex;
  gap: 1rem;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: .65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 80px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.stat .lbl { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; margin-top: .25rem; }

/* === Filters === */
.filters {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filters input,
.filters select {
  padding: .5rem .75rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
}
.filters .search { flex: 1; min-width: 240px; }
.filters button {
  padding: .5rem 1rem;
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.filters button:hover { filter: brightness(1.08); }
.filters .reset {
  padding: .5rem .75rem;
  color: var(--text-muted);
}

/* === Grid table === */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  box-shadow: var(--shadow);
}
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.grid-table thead th {
  text-align: left;
  padding: .4rem .6rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.grid-table th.num, .grid-table td.num { text-align: right; white-space: nowrap; }
.grid-table tbody td {
  padding: .28rem .6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.grid-table tbody tr:hover { background: var(--bg); }
.grid-table tr.is-inactive { opacity: .5; }
.w-task { width: 200px; max-width: 200px; }
.stage-cell { width: 400px; max-width: 400px; }

/* Fade-cell: caps a table cell to a fixed width, lets the user scroll the
   overflow horizontally inside the cell, and overlays a transparent->white
   gradient on the right edge so cut-off text disappears smoothly. The full
   text stays in the DOM (Cmd-F still finds it). */
.fade-cell { padding: 0 !important; position: relative; }
.fade-cell::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to right, rgba(255,255,255,0), var(--surface) 85%);
}
.grid-table tbody tr:hover .fade-cell::after {
  background: linear-gradient(to right, rgba(247,248,250,0), var(--bg) 85%);
}
.fade-cell-inner {
  overflow-x: auto;
  white-space: nowrap;
  padding: .28rem .6rem;
  scrollbar-width: thin;
}
.fade-cell-inner::-webkit-scrollbar { height: 6px; }
.fade-cell-inner::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.supplier-cell { color: var(--text-muted); font-size: .78rem; white-space: normal !important; max-width: 240px; }
.muted-cell { color: var(--text-muted); }
.muted { color: var(--text-muted); }

.stage-name { font-weight: 500; }

.stage-effort {
  display: inline-block;
  margin-left: .25rem;
  padding: .02rem .35rem;
  font-size: .68rem;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 500;
  vertical-align: middle;
}
.effort-action { background: #ede9fe; color: var(--action); }
.effort-effort { background: #cffafe; color: var(--effort); }

/* === Owner chip — per-person color === */
.owner-chip {
  display: inline-block;
  padding: .08rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  margin-right: .35rem;
  vertical-align: middle;
  border: 1px solid transparent;
  letter-spacing: .01em;
}
.owner-chip.owner-none {
  background: var(--bg);
  color: var(--text-faint);
  font-weight: 500;
}
/* Gilles — stronger blue-green (teal) */
.owner-chip.owner-gilles  { background: #0d9488; color: #ffffff; }
/* Darwin — paired with Gilles in many rows; lighter teal */
.owner-chip.owner-darwin  { background: #5eead4; color: #134e4a; }
/* Elaiza — neutral gray (china sourcing operator, dominant owner) */
.owner-chip.owner-elaiza  { background: #e5e7eb; color: #374151; }
/* Rabi — light green (on-site renovation) */
.owner-chip.owner-rabi    { background: #bbf7d0; color: #14532d; }
/* Jackie — finance, distinct purple */
.owner-chip.owner-jackie  { background: #ede9fe; color: #5b21b6; }
/* Winterplus — main fitout contractor, warmer orange */
.owner-chip.owner-wp      { background: #fed7aa; color: #9a3412; }
/* Noby — yellow-orange */
.owner-chip.owner-noby    { background: #fde68a; color: #78350f; }
/* Alaa — amber (electronics) */
.owner-chip.owner-alaa    { background: #fcd34d; color: #78350f; }
/* Eva — peach (site logistics) */
.owner-chip.owner-eva     { background: #fdba74; color: #7c2d12; }

.tags { margin-left: .35rem; }
.tag-chip {
  display: inline-block;
  padding: .05rem .4rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  font-size: .7rem;
  margin-right: .2rem;
  font-weight: 500;
}

.pill-overdue, .pill-today, .pill-ok {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
}
.pill-overdue { background: var(--overdue-soft); color: var(--overdue); }
.pill-today   { background: var(--today-soft);   color: var(--today); }
.pill-ok      { background: var(--ok-soft);      color: var(--ok); }

.tpl {
  display: inline-block;
  padding: .05rem .4rem;
  border-radius: 3px;
  font-size: .68rem;
  background: var(--bg);
  color: var(--text-muted);
  text-transform: lowercase;
  font-weight: 500;
  vertical-align: middle;
}
.tpl-sourcing   { background: #e0f2fe; color: #0369a1; }
.tpl-renovation { background: #fef3c7; color: #92400e; }
.tpl-simple     { background: #f3f4f6; color: #4b5563; }
.tpl-hiring     { background: #f3e8ff; color: #7e22ce; }

/* === Runway === */
.who-tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.who-tabs a {
  padding: .35rem .75rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 500;
}
.who-tabs a:hover { background: var(--bg); text-decoration: none; }
.who-tabs a.is-active { background: var(--accent-soft); color: var(--accent); }
.who-tabs .badge {
  display: inline-block;
  margin-left: .25rem;
  padding: 0 .35rem;
  background: var(--bg);
  border-radius: 3px;
  font-size: .65rem;
  color: var(--text-faint);
}

.runway-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .35rem;
}
.runway-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 5px;
  padding: .45rem .75rem;
  box-shadow: var(--shadow);
}
.runway-card.is-overdue { border-left-color: var(--overdue); }
.rc-head { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-bottom: .15rem; }
.rc-task { font-weight: 600; color: var(--text); font-size: .9rem; }
.rc-stage {
  font-size: .75rem;
  color: var(--text-muted);
  padding: .05rem .4rem;
  background: var(--bg);
  border-radius: 3px;
}
.rc-meta { font-size: .78rem; color: var(--text-muted); }
.rc-meta strong { color: var(--text); font-weight: 500; }
.meta-sep { color: var(--text-faint); margin: 0 .35rem; }
.rc-supplier { font-size: .75rem; color: var(--text-faint); margin-top: .2rem; }

.empty { padding: 2rem; text-align: center; color: var(--text-muted); }

/* === Mission grid === */
.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .75rem;
}
.mt-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem 1rem;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
}
.mt-card:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .08);
}
.mt-name { font-weight: 600; margin-bottom: .35rem; font-size: .92rem; }
.mt-meta { font-size: .75rem; color: var(--text-muted); display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap; }
.mt-stage { color: var(--text-muted); }
.mt-bar { width: 100%; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.mt-bar-fill { height: 100%; background: var(--accent); }
.mt-progress { font-size: .7rem; color: var(--text-faint); margin-top: .25rem; }

/* === Task detail === */
.notes-block {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: .9rem;
  margin-bottom: 1.25rem;
  color: var(--text-muted);
}

.stage-list { display: flex; flex-direction: column; gap: .4rem; }
.stage-row {
  display: flex;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 6px;
  padding: .65rem 1rem;
  box-shadow: var(--shadow);
}
.stage-row.status-active  { border-left-color: var(--accent); }
.stage-row.status-done    { border-left-color: var(--ok); opacity: .85; }
.stage-row.status-pending { border-left-color: var(--text-faint); opacity: .7; }
.stage-row.status-cancelled { opacity: .45; }
.stage-pos {
  flex: 0 0 1.5rem;
  font-weight: 700;
  color: var(--text-faint);
}
.stage-main { flex: 1; }
.stage-title { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .2rem; }
.stage-title .stage-name { font-weight: 600; }
.status-pill {
  display: inline-block;
  padding: .05rem .45rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.status-pill.status-active    { background: var(--accent-soft); color: var(--accent); }
.status-pill.status-done      { background: var(--ok-soft); color: var(--ok); }
.status-pill.status-pending   { background: var(--bg); color: var(--text-faint); }
.status-pill.status-cancelled { background: var(--bg); color: var(--text-faint); text-decoration: line-through; }
.stage-meta { font-size: .8rem; color: var(--text-muted); }
.stage-meta strong { color: var(--text); font-weight: 500; }

/* === Task drawer === */
.task-drawer[hidden] { display: none; }
.task-drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.task-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .35);
}
.task-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(60vw, 880px);
  background: var(--surface);
  box-shadow: -8px 0 24px rgba(15, 23, 42, .15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-slide-in .18s ease-out;
}
@keyframes drawer-slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.task-drawer-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.task-drawer-action {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .25rem .6rem;
  font-size: .8rem;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.task-drawer-action:hover { background: var(--surface); border-color: var(--border-strong); }
.task-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}
.task-drawer-loading,
.task-drawer-error {
  padding: 2rem 0;
  text-align: center;
}
.task-drawer-error { color: var(--overdue); }
body.drawer-open { overflow: hidden; }
.task-detail-head h2 { margin: 0 0 .25rem; font-size: 1.3rem; }
