/* ==========================================================================
   R&D Programme Dashboard — styles
   Colour roles follow a validated data-viz palette. Light values are the
   default; dark values are declared under BOTH the OS media query and the
   explicit [data-theme="dark"] stamp so the in-app toggle wins either way.
   ========================================================================== */

:root {
  color-scheme: light;

  --surface-1:   #fcfcfb;   /* cards, chart surface        */
  --surface-2:   #ffffff;   /* raised: modals, drawer      */
  --plane:       #f3f3f0;   /* page background             */
  --ink-1:       #0b0b0b;
  --ink-2:       #52514e;
  --ink-3:       #898781;
  --grid:        #e1e0d9;
  --axis:        #c3c2b7;
  --hairline:    rgba(11,11,11,0.10);
  --shadow:      0 1px 2px rgba(11,11,11,0.06), 0 8px 24px rgba(11,11,11,0.07);

  --series-1:    #2a78d6;   /* scheduled / neutral future  */
  --series-1-soft: rgba(42,120,214,0.12);

  --good:        #0ca30c;   /* done                        */
  --warning:     #fab219;   /* due this week               */
  --serious:     #ec835a;   /* due in <= 3 days            */
  --critical:    #d03b3b;   /* overdue / blocked           */
  --good-soft:     rgba(12,163,12,0.12);
  --warning-soft:  rgba(250,178,25,0.18);
  --serious-soft:  rgba(236,131,90,0.16);
  --critical-soft: rgba(208,59,59,0.12);

  --radius:      12px;
  --radius-sm:   8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #222220;
    --plane:     #0d0d0d;
    --ink-1:     #ffffff;
    --ink-2:     #c3c2b7;
    --ink-3:     #898781;
    --grid:      #2c2c2a;
    --axis:      #383835;
    --hairline:  rgba(255,255,255,0.10);
    --shadow:    0 1px 2px rgba(0,0,0,0.5), 0 12px 32px rgba(0,0,0,0.45);
    --series-1:  #3987e5;
    --series-1-soft: rgba(57,135,229,0.18);
    --good-soft:     rgba(12,163,12,0.18);
    --warning-soft:  rgba(250,178,25,0.16);
    --serious-soft:  rgba(236,131,90,0.18);
    --critical-soft: rgba(208,59,59,0.20);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --plane:     #0d0d0d;
  --ink-1:     #ffffff;
  --ink-2:     #c3c2b7;
  --ink-3:     #898781;
  --grid:      #2c2c2a;
  --axis:      #383835;
  --hairline:  rgba(255,255,255,0.10);
  --shadow:    0 1px 2px rgba(0,0,0,0.5), 0 12px 32px rgba(0,0,0,0.45);
  --series-1:  #3987e5;
  --series-1-soft: rgba(57,135,229,0.18);
  --good-soft:     rgba(12,163,12,0.18);
  --warning-soft:  rgba(250,178,25,0.16);
  --serious-soft:  rgba(236,131,90,0.18);
  --critical-soft: rgba(208,59,59,0.20);
}

* { box-sizing: border-box; }

/* The layout rules below set display on elements we also toggle with the
   [hidden] attribute, so hidden has to win explicitly. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--plane);
  color: var(--ink-1);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* A thin bar across the top whenever a call is in flight, so a click always
   produces immediate feedback even when Apps Script takes a second to answer. */
body.is-busy::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200;
  background: linear-gradient(90deg, transparent, var(--series-1), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: sweep 1s linear infinite;
}
@keyframes sweep {
  from { background-position: -40% 0; }
  to   { background-position: 140% 0; }
}
body.is-busy { cursor: progress; }

/* ---------- boot ---------- */
.boot { min-height: 60vh; display: grid; place-items: center; }
.boot-card { text-align: center; color: var(--ink-2); }
.boot-text { margin-top: 14px; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto; border-radius: 50%;
  border: 2px solid var(--grid); border-top-color: var(--series-1);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   SHELL — a fixed sidebar beside the page
   --------------------------------------------------------------------------
   The app is four pages sharing one shell. The sidebar is always there on a
   wide screen; below 900px it slides over the page rather than squeezing it,
   because the board's lanes and the calendar's week both need the width.
   ========================================================================== */

.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.page { max-width: 1400px; width: 100%; padding: 16px 20px 48px; min-width: 0; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--plane); border-right: 1px solid var(--hairline);
  padding: 16px 12px; overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 14px; }
.side-mark {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  background: var(--series-1); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.side-wordmark { font-size: 13.5px; font-weight: 640; letter-spacing: -0.01em; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 550;
  transition: background .12s, color .12s;
}
.side-link:hover { background: var(--surface-1); color: var(--ink-1); }
.side-link.is-here { background: var(--series-1-soft); color: var(--series-1); font-weight: 640; }
.side-ico { width: 16px; text-align: center; font-size: 13px; opacity: .85; flex-shrink: 0; }
.side-label { flex: 1; min-width: 0; }
.side-count {
  min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--series-1); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
}
.side-count.warn { background: var(--warning); color: #1a1a19; }

.side-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.side-foot .user-chip { width: 100%; }
.side-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.side-actions .btn { flex: 1 1 auto; padding: 5px 9px; font-size: 11.5px; }

.side-toggle { display: none; }
.side-scrim { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 70; width: 248px;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow);
  }
  body.side-open .sidebar { transform: none; }
  .side-toggle {
    display: grid; place-items: center;
    position: fixed; top: 10px; left: 10px; z-index: 71;
    width: 34px; height: 34px; border-radius: 8px;
    background: var(--surface-1); border: 1px solid var(--hairline);
    color: var(--ink-1); font-size: 15px; cursor: pointer;
  }
  .side-scrim {
    display: block; position: fixed; inset: 0; z-index: 69;
    background: rgba(11,11,11,.4);
  }
  .side-scrim[hidden] { display: none; }
  .page { padding: 12px 14px 48px; }
  .topbar { padding-left: 42px; }
}

/* ---------- sharing a resource ---------- */
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 0; }
.check-row input { margin: 0; }
fieldset.field { border: 1px solid var(--hairline); border-radius: 8px; padding: 10px 12px 12px; }
fieldset.field legend { padding: 0 5px; }
.data-table .pill { margin-left: 7px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding: 4px 0 14px;
}
.app-title { font-size: 19px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.app-sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 4px 12px 4px 4px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--series-1); color: #fff; font-size: 12px; font-weight: 650;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-size: 13px; font-weight: 550;
  border-radius: var(--radius-sm); padding: 7px 13px; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface-1); color: var(--ink-1);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover { border-color: var(--axis); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--critical); border-color: var(--critical-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { font-size: 14px; line-height: 1; }
.icon-btn {
  background: none; border: 0; color: var(--ink-2); font-size: 15px;
  cursor: pointer; padding: 6px 8px; border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--plane); color: var(--ink-1); }
.chip-btn {
  font: inherit; font-size: 12px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--hairline); background: transparent; color: var(--ink-2); cursor: pointer;
}
.chip-btn.is-active { background: var(--series-1-soft); border-color: var(--series-1); color: var(--ink-1); font-weight: 600; }

/* ---------- KPIs ---------- */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.kpi {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 12px 14px;
}
.kpi-label { font-size: 11.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.kpi-note { font-size: 11px; color: var(--ink-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.critical { background: var(--critical); }
.dot.serious  { background: var(--serious); }
.dot.warning  { background: var(--warning); }
.dot.good     { background: var(--good); }
.dot.series   { background: var(--series-1); }

/* ---------- controls ---------- */
.controls { margin-bottom: 14px; }
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--grid); margin-bottom: 12px;
  overflow-x: auto;
}
.tab {
  font: inherit; font-size: 13.5px; font-weight: 550; color: var(--ink-2);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 9px 14px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink-1); }
.tab.is-active { color: var(--ink-1); border-bottom-color: var(--series-1); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: inline-flex; align-items: center; gap: 6px; }
.field.block { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.field-label { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.hint { color: var(--ink-3); font-weight: 400; }
input[type="text"], input[type="search"], input[type="date"], select, textarea {
  font: inherit; font-size: 13px; color: var(--ink-1);
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius-sm); padding: 6px 9px; min-width: 0;
}
textarea { resize: vertical; width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 1px;
}
.search input { min-width: 240px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }

/* ---------- views ---------- */
.view { display: none; }
.view.is-active { display: block; }
.empty { color: var(--ink-3); text-align: center; padding: 40px 0; }

/* ---------- board: one horizontal lane per R&D ---------- */
.board-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.scope { display: inline-flex; gap: 4px; }
.board-note { font-size: 11.5px; color: var(--ink-3); }

.lane-idle {
  align-self: center; display: flex; flex-direction: column; gap: 1px;
  font-size: 12.5px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--warning-soft); color: var(--ink-1);
}
.lane-idle.stalled { background: var(--critical-soft); }
.lane-idle-head { font-weight: 600; }
.lane-idle-sub { font-size: 11.5px; color: var(--ink-2); }

.lanes {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden;
}
.lane {
  display: grid; grid-template-columns: 260px 1fr;
  border-bottom: 1px solid var(--grid);
}
.lane:last-child { border-bottom: 0; }
.lane:hover .lane-rail { background: var(--plane); }

.lane-rail {
  padding: 10px 12px; border-right: 1px solid var(--grid);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  transition: background .12s ease;
}
.lane-name {
  font-size: 13.5px; font-weight: 640; letter-spacing: -0.01em; text-align: left;
  background: none; border: 0; padding: 0; color: inherit; font-family: inherit; cursor: pointer;
}
.lane-name:hover { text-decoration: underline; }
.lane-meta { font-size: 11px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 2px 8px; }
.lane-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 1px; }
.lane-deadline { font-size: 11px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }

.lane-strip {
  display: flex; gap: 8px; align-items: stretch;
  padding: 10px 12px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
}
.lane-strip::-webkit-scrollbar { height: 8px; }
.lane-strip::-webkit-scrollbar-thumb { background: var(--axis); border-radius: 999px; }
.lane-strip::-webkit-scrollbar-track { background: transparent; }

.mcard {
  flex: 0 0 auto; width: 188px; text-align: left; font: inherit; color: inherit;
  background: var(--plane); border: 1px solid var(--hairline); border-top: 3px solid var(--axis);
  border-radius: var(--radius-sm); padding: 7px 9px 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color .12s ease, background .12s ease;
}
.mcard:hover { background: var(--series-1-soft); }
.mcard.u-critical { border-top-color: var(--critical); }
.mcard.u-serious  { border-top-color: var(--serious); }
.mcard.u-warning  { border-top-color: var(--warning); }
.mcard.u-future   { border-top-color: var(--series-1); }
.mcard.u-done     { border-top-color: var(--good); opacity: .7; }

.mcard-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.mcard-date { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.mcard-when { font-size: 10.5px; color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.mcard-name {
  font-size: 12.5px; font-weight: 560; line-height: 1.28;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.56em;
}
.mcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; padding-top: 2px; }
.mcard-owner { font-size: 11px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard-dep { font-size: 10.5px; color: var(--ink-3); }

.mcard.add {
  border: 1px dashed var(--axis); border-top: 1px dashed var(--axis); background: transparent;
  width: 116px; align-items: center; justify-content: center; color: var(--ink-3); font-size: 12px;
}
.mcard.add:hover { color: var(--series-1); border-color: var(--series-1); background: transparent; }

.lane-none {
  align-self: center; font-size: 12.5px; color: var(--critical);
  background: var(--critical-soft); border-radius: var(--radius-sm); padding: 8px 12px;
}
.card {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title {
  font-size: 14.5px; font-weight: 640; margin: 0; letter-spacing: -0.01em;
  cursor: pointer; text-align: left; background: none; border: 0; color: inherit; padding: 0; font-family: inherit;
}
.card-title:hover { text-decoration: underline; }
.card-meta { font-size: 11.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 10px; }

.pill {
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--hairline);
  color: var(--ink-2); background: var(--plane); white-space: nowrap;
}
.pill.good     { color: var(--good);     background: var(--good-soft);     border-color: transparent; }
.pill.warning  { color: var(--ink-1);    background: var(--warning-soft);  border-color: transparent; }
.pill.serious  { color: var(--ink-1);    background: var(--serious-soft);  border-color: transparent; }
.pill.critical { color: var(--critical); background: var(--critical-soft); border-color: transparent; }
.pill.series   { color: var(--series-1); background: var(--series-1-soft); border-color: transparent; }

.deadline-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); }

.act-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.act {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: start;
  padding: 7px 8px; border-radius: var(--radius-sm); background: var(--plane);
  border-left: 3px solid var(--axis); cursor: pointer; text-align: left;
  border-top: 0; border-right: 0; border-bottom: 0; font: inherit; color: inherit; width: 100%;
}
.act:hover { background: var(--series-1-soft); }
.act.u-critical { border-left-color: var(--critical); }
.act.u-serious  { border-left-color: var(--serious); }
.act.u-warning  { border-left-color: var(--warning); }
.act.u-future   { border-left-color: var(--series-1); }
.act.u-done     { border-left-color: var(--good); opacity: .72; }
.act-date { font-size: 11px; font-weight: 640; color: var(--ink-1); font-variant-numeric: tabular-nums; }
.act-when { font-size: 10.5px; color: var(--ink-2); display: block; font-weight: 500; }
.act-name { font-size: 12.8px; font-weight: 550; }
.act-sub  { font-size: 11px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 1px; }
.act-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.link-btn {
  font: inherit; font-size: 12px; background: none; border: 0; padding: 0;
  color: var(--series-1); cursor: pointer; font-weight: 550;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- timeline ---------- */
.timeline-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--ink-2); }
.legend span.item { display: inline-flex; align-items: center; gap: 6px; }
.zoom { display: flex; align-items: center; gap: 6px; }

.gantt-wrap {
  display: flex; background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden;
}
.gantt-names { flex: none; width: 210px; border-right: 1px solid var(--grid); background: var(--surface-1); }
.gantt-names .gn-head { height: 40px; border-bottom: 1px solid var(--grid); }
.gantt-names .gn-row {
  height: 46px; display: flex; flex-direction: column; justify-content: center;
  padding: 0 12px; border-bottom: 1px solid var(--grid); overflow: hidden;
}
.gantt-names .gn-row:last-child { border-bottom: 0; }
.gn-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gn-sub { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-scroll { overflow-x: auto; flex: 1 1 auto; }
#gantt { display: block; }
.g-marker { cursor: pointer; }
.g-marker:hover .g-pill { stroke: var(--ink-1); stroke-width: 1.5; }

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface-2); color: var(--ink-1);
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; max-width: 280px;
}
.tooltip b { display: block; font-size: 12.5px; margin-bottom: 2px; }
.tooltip .t-sub { color: var(--ink-2); font-size: 11.5px; }

/* ---------- my work ---------- */
.mine { display: flex; flex-direction: column; gap: 10px; }
.mine-group {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 12px 14px;
}
.mine-group h3 { margin: 0 0 8px; font-size: 13px; font-weight: 640; display: flex; align-items: center; gap: 8px; }

/* ---------- table ---------- */
.table-actions { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.table-wrap {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: auto; max-height: 70vh;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  position: sticky; top: 0; background: var(--surface-1); text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3);
  padding: 9px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap; z-index: 1;
}
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.data-table tbody tr:hover { background: var(--plane); }
.data-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- admin ---------- */
.panels { display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 16px 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.panel-title { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; }
.panel-note { margin: 6px 0 12px; font-size: 12px; color: var(--ink-2); max-width: 70ch; }
.panel .table-wrap { max-height: none; }
.panel .dl { margin-top: 12px; }

.data-table tr.is-inactive td { opacity: .55; }
.role-help {
  margin: 0; font-size: 11.5px; color: var(--ink-2); line-height: 1.6;
  background: var(--plane); border-radius: var(--radius-sm); padding: 9px 11px;
}
.role-help b { color: var(--ink-1); }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--plane); border: 1px solid var(--hairline);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 12px;
}
.chip b { font-weight: 620; }
.chip span { color: var(--ink-2); }
.chip-x {
  border: 0; background: none; color: var(--ink-3); cursor: pointer;
  font-size: 11px; line-height: 1; padding: 3px 5px; border-radius: 50%;
}
.chip-x:hover { color: var(--critical); background: var(--critical-soft); }

/* ---------- trial calendar ---------- */
.cal-app { max-width: 1600px; }
.dot.muted { background: var(--ink-3); }

.approvals {
  background: var(--warning-soft); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.approvals-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.approval-list { display: flex; flex-direction: column; gap: 6px; }
.approval {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-1); border-radius: var(--radius-sm); padding: 8px 11px; flex-wrap: wrap;
}
.approval-title { font-size: 12.8px; font-weight: 600; }
.approval-sub { font-size: 11.5px; color: var(--ink-2); }
.approval-actions { display: flex; gap: 6px; }

.cal-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-label { font-size: 13px; font-weight: 600; margin-left: 6px; }

.cal-wrap {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow-x: auto;
}
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th, .cal td { border: 1px solid var(--grid); vertical-align: top; }
.cal-corner {
  width: 170px; min-width: 170px; text-align: left; padding: 8px 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3);
  position: sticky; left: 0; background: var(--surface-1); z-index: 2;
}
.cal-day { padding: 7px 8px; text-align: center; background: var(--surface-1); }
.cal-dow { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.cal-date { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-off-label { font-size: 10px; color: var(--ink-3); margin-top: 1px; }
.cal-day.is-off { background: var(--plane); }
.cal-day.is-today .cal-date { color: var(--critical); }

.cal-res {
  width: 170px; min-width: 170px; text-align: left; padding: 7px 10px;
  position: sticky; left: 0; background: var(--surface-1); z-index: 1;
}
.res-name { font-size: 12.5px; font-weight: 640; }
.res-sub { font-size: 10.5px; color: var(--ink-3); margin-bottom: 3px; }
.res-slot { font-size: 11.5px; color: var(--ink-2); font-weight: 550; font-variant-numeric: tabular-nums; }
.cal tr.res-start > * { border-top: 2px solid var(--axis); }

.cal-cell { padding: 4px; min-width: 132px; height: 74px; }
.cal-cell.is-off { background: var(--plane); }
.cal-cell.is-past { background: var(--plane); opacity: .6; }
.cal-cell.is-dim { opacity: .35; }

.slot-free {
  width: 100%; height: 100%; min-height: 62px; font: inherit; font-size: 12px;
  color: var(--ink-3); background: transparent; cursor: pointer;
  border: 1px dashed var(--axis); border-radius: var(--radius-sm);
}
.slot-free:hover { color: var(--series-1); border-color: var(--series-1); background: var(--series-1-soft); }

.slot-card {
  width: 100%; height: 100%; min-height: 62px; text-align: left; font: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  border: 1px solid var(--hairline); border-left: 3px solid var(--axis);
  border-radius: var(--radius-sm); padding: 6px 7px; background: var(--plane);
}
.slot-card:hover { background: var(--series-1-soft); }
.slot-card.ok { border-left-color: var(--good); }
.slot-card.wait { border-left-color: var(--warning); }
.slot-rnd {
  font-size: 11.5px; font-weight: 620; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.slot-purpose {
  font-size: 10.5px; color: var(--ink-2); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.slot-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px; margin-top: auto; padding-top: 2px;
}
.slot-who { font-size: 10px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-foot .pill { font-size: 9.5px; padding: 1px 6px; }

.cal-legend { margin-top: 10px; }
/* ---- month grid ---- */
.month-wrap {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden;
}
/* minmax(0,…) stops a long booking label from stealing width from the other
   days — without it the Sunday column collapses. */
.month-head, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-head { border-bottom: 1px solid var(--grid); }
.month-dow {
  padding: 7px 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); text-align: left;
}
.month-cell {
  min-height: 116px; border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid);
  padding: 6px 7px; display: flex; flex-direction: column; gap: 3px;
}
.month-cell:nth-child(7n) { border-right: 0; }
.month-cell.is-clickable { cursor: pointer; }
.month-cell.is-clickable:hover { background: var(--plane); }
.month-cell.is-out { opacity: .4; }
.month-cell.is-off { background: var(--plane); }
.month-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.month-num { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.month-cell.is-today .month-num { color: var(--critical); }
.month-off { font-size: 9.5px; color: var(--ink-3); text-align: right; line-height: 1.2; }

.month-book {
  display: flex; align-items: baseline; gap: 5px; width: 100%; text-align: left;
  font: inherit; font-size: 10.5px; cursor: pointer;
  border: 0; border-left: 3px solid var(--axis); border-radius: 3px;
  background: var(--plane); color: var(--ink-1); padding: 3px 5px;
}
.month-book:hover { background: var(--series-1-soft); }
.month-book.ok { border-left-color: var(--good); }
.month-book.wait { border-left-color: var(--warning); }
.month-time { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.month-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month-more { font-size: 10px; color: var(--ink-3); padding-left: 5px; }
.month-free {
  margin-top: auto; align-self: flex-start; font: inherit; font-size: 10px;
  color: var(--ink-3); background: none; border: 0; padding: 2px 0; cursor: pointer;
}
.month-free:hover { color: var(--series-1); text-decoration: underline; }

.day-list { display: flex; flex-direction: column; gap: 6px; }
.day-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--plane); border-left: 3px solid var(--axis);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.day-row.ok { border-left-color: var(--good); }
.day-row.wait { border-left-color: var(--warning); }
.day-res { font-size: 12.5px; font-weight: 600; }
.day-sub { font-size: 11.5px; color: var(--ink-2); }

.cal-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 60px 0; color: var(--ink-2); font-size: 13px;
}
.empty-state {
  background: var(--surface-1); border: 1px dashed var(--axis);
  border-radius: var(--radius); padding: 34px 26px; text-align: center;
}
.empty-title { margin: 0 0 6px; font-size: 14.5px; font-weight: 650; }
.empty-note { margin: 0 auto 14px; font-size: 12.5px; color: var(--ink-2); max-width: 58ch; line-height: 1.5; }
.slot-banner {
  margin: 0; font-size: 12.5px; font-weight: 600;
  background: var(--series-1-soft); color: var(--ink-1);
  border-radius: var(--radius-sm); padding: 8px 11px;
}

/* trial marks on the milestone board */
.mcard.is-trial { background: var(--surface-2); }
.trial-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 650; letter-spacing: .03em;
  color: var(--series-1); background: var(--series-1-soft);
  border-radius: 999px; padding: 1px 7px;
}
.trial-tag.pending { color: var(--ink-1); background: var(--warning-soft); }
.mcard-slot { font-size: 10.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(11,11,11,0.42); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface-2); border-left: 1px solid var(--hairline);
  box-shadow: var(--shadow); z-index: 50; display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--grid);
}
.drawer-eyebrow { margin: 0 0 2px; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.drawer-title { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.drawer-body { padding: 16px 18px 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 12.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); margin: 6px 0 0;
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: rgba(11,11,11,0.45); overflow-y: auto; }
.modal-card {
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow); width: min(680px, 100%); max-height: 92vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--grid);
}
.modal-head h2 { margin: 0; font-size: 15.5px; font-weight: 640; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot {
  display: flex; align-items: center; gap: 8px; padding-top: 6px;
  border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 12px;
}
.spacer { flex: 1 1 auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-error {
  margin: 0; font-size: 12.5px; color: var(--critical);
  background: var(--critical-soft); border-radius: var(--radius-sm); padding: 8px 10px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--surface-2); color: var(--ink-1); border: 1px solid var(--hairline);
  box-shadow: var(--shadow); border-radius: 999px; padding: 9px 18px; font-size: 13px; z-index: 80;
}
.toast.err { color: var(--critical); }

.foot { margin-top: 22px; font-size: 11.5px; color: var(--ink-3); text-align: center; }

@media (max-width: 860px) {
  .lane { grid-template-columns: 1fr; }
  .lane-rail { border-right: 0; border-bottom: 1px solid var(--grid); }
}
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .search input { min-width: 100%; }
  .gantt-names { width: 130px; }
  .btn-label { display: none; }
  .dl { grid-template-columns: 1fr; }
}
@media print {
  .controls, .topbar-right, .table-actions { display: none; }
  .view { display: block !important; }
}

/* ---------- added for the PHP build ---------- */
/* A wider minimum, because "Milestones  Download Upload" needs the room —
   below it the two links were being clipped at the edge of the tile. */
.csv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.csv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--plane); border-radius: var(--radius-sm); padding: 8px 10px;
  min-width: 0;
}
.csv-name { font-size: 12.5px; font-weight: 550; min-width: 0; }
.csv-actions { display: flex; gap: 8px; flex-shrink: 0; }
.import-note { font-size: 11.5px; color: var(--ink-2); margin: 10px 0 0; }
.pending-pill { font-size: 9.5px; }

/* ==========================================================================
   TASKS
   ========================================================================== */

.tab-count {
  display: inline-block; min-width: 17px; margin-left: 6px; padding: 0 5px;
  border-radius: 9px; background: var(--series-1-soft); color: var(--series-1);
  font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center;
}
.tab-count.warn { background: var(--warning-soft); color: var(--ink-1); }

.day-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.day-title { margin: 0; font-size: 16px; font-weight: 640; }
.day-note  { margin: 3px 0 0; font-size: 12px; color: var(--ink-2); max-width: 70ch; }

.task-list { display: flex; flex-direction: column; gap: 9px; }

.task-card {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-left: 3px solid var(--hairline); border-radius: var(--radius);
  padding: 11px 13px; cursor: pointer; transition: border-color .12s, transform .06s;
}
.task-card:hover  { border-color: var(--axis); }
.task-card:active { transform: translateY(1px); }
.task-card:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.task-card.u-critical { border-left-color: var(--critical); }
.task-card.u-serious  { border-left-color: var(--serious); }
.task-card.u-warning  { border-left-color: var(--warning); }
.task-card.u-future   { border-left-color: var(--series-1); }
.task-card.u-done     { border-left-color: var(--good); opacity: .62; }

.task-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.task-title { margin: 0; font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.task-pills { display: flex; gap: 5px; flex-wrap: wrap; flex-shrink: 0; }
.pill.muted { color: var(--ink-2); background: var(--grid); border-color: transparent; }

.task-meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px;
  font-size: 11.5px; color: var(--ink-2);
}
.task-who  { font-weight: 600; color: var(--ink-1); }
.task-when.is-late { color: var(--critical); font-weight: 600; }

.task-update {
  margin: 7px 0 0; padding-top: 7px; border-top: 1px solid var(--grid);
  font-size: 12px; color: var(--ink-2); line-height: 1.45;
}
.task-update-when { font-variant-numeric: tabular-nums; opacity: .75; margin-right: 6px; }

.task-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.btn.small { padding: 4px 10px; font-size: 11.5px; }

/* ---------- the detail card ---------- */
.modal-card.wide { width: min(780px, 100%); }

.detail-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 16px; padding-bottom: 12px; border-bottom: 1px solid var(--grid);
}
.detail-fact  { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.detail-value { font-size: 13px; font-weight: 600; }
.detail-desc  { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-2); white-space: pre-wrap; }

.detail-block { display: flex; flex-direction: column; gap: 8px;
  padding-top: 12px; border-top: 1px solid var(--grid); }
.detail-h { margin: 0; font-size: 12px; font-weight: 640; text-transform: uppercase; letter-spacing: .04em; }
.detail-note { margin: 0; font-size: 12px; color: var(--ink-2); line-height: 1.5; }
.detail-actions { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.detail-textarea, .inline-text, .inline-date, .inline-select {
  border: 1px solid var(--hairline); border-radius: 7px; background: var(--surface-1);
  color: var(--ink-1); font: inherit; font-size: 12.5px; padding: 7px 9px;
}
.detail-textarea { width: 100%; resize: vertical; }
.inline-text { flex: 1 1 180px; min-width: 0; }
.detail-pre {
  margin: 0; padding: 9px 11px; background: var(--grid); border-radius: 7px;
  font: inherit; font-size: 12px; color: var(--ink-2); white-space: pre-wrap;
  max-height: 180px; overflow-y: auto;
}
.routing-note {
  margin: 0; padding: 8px 11px; border-left: 3px solid var(--series-1);
  background: var(--series-1-soft); border-radius: 0 7px 7px 0;
  font-size: 12px; line-height: 1.5;
}

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.checklist-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.checklist-item.is-done .checklist-text { text-decoration: line-through; color: var(--ink-2); }
.checklist-text { flex: 1; }
.icon-btn.small { font-size: 11px; padding: 2px 5px; }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px;
  max-height: 220px; overflow-y: auto; }
.history-item { display: grid; grid-template-columns: 86px 96px 1fr; gap: 8px;
  font-size: 11.5px; color: var(--ink-2); align-items: baseline; }
.history-when  { font-variant-numeric: tabular-nums; opacity: .8; }
.history-actor { font-weight: 600; color: var(--ink-1); }

/* ---------- what the team has been doing ---------- */
.activity-person {
  background: var(--surface-1); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 9px;
}
.activity-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; flex-wrap: wrap; }
.activity-name { margin: 0; font-size: 13.5px; font-weight: 640; }
.activity-count { font-size: 11.5px; color: var(--ink-2); margin-left: auto; }
.activity-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.activity-item { display: grid; grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 10px; font-size: 11.5px; color: var(--ink-2); align-items: baseline; }
.activity-when { font-variant-numeric: tabular-nums; opacity: .8; }
.activity-task { font-weight: 600; color: var(--ink-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 680px) {
  .history-item, .activity-item { grid-template-columns: 1fr; gap: 1px; }
  .task-card-head { flex-direction: column; gap: 6px; }
}

.settings-form { display: flex; flex-direction: column; gap: 11px; }
.settings-form textarea {
  width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
}
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- the push popup ---------- */
.modal-card.narrow { width: min(460px, 100%); }
.push-task {
  margin: 0; font-size: 13.5px; font-weight: 620; line-height: 1.4;
  padding-bottom: 10px; border-bottom: 1px solid var(--grid);
}
.push-effect {
  margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-2);
  padding: 8px 11px; background: var(--grid); border-radius: 7px;
}
.push-effect.is-counting {
  color: var(--ink-1); background: var(--warning-soft);
  border-left: 3px solid var(--warning); border-radius: 0 7px 7px 0;
}


/* ---------- deleting ---------- */
.link-btn.danger { color: var(--critical); }
.link-btn.danger:hover { text-decoration: underline; }
.del-what { margin: 0 0 4px; font-size: 14px; font-weight: 640; }
.del-lead { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.del-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.del-list li { margin-bottom: 3px; }
.del-list b { color: var(--ink-1); }
.del-hint {
  margin: 0; font-size: 12px; line-height: 1.5;
  padding: 8px 11px; border-left: 3px solid var(--warning);
  background: var(--warning-soft); border-radius: 0 7px 7px 0;
}

/* ---------- grouped task lists ---------- */
.list-chrome {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 10px;
}
.list-chrome .day-note { margin: 0; flex: 1 1 320px; }
.inline-field { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.inline-field .field-label { margin: 0; white-space: nowrap; }
.inline-field select {
  border: 1px solid var(--hairline); border-radius: 7px; background: var(--surface-1);
  color: var(--ink-1); font: inherit; font-size: 12.5px; padding: 6px 9px; cursor: pointer;
}
.group-head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 18px 0 7px; padding-bottom: 5px; border-bottom: 1px solid var(--grid);
}
.group-head:first-child { margin-top: 2px; }
.group-title {
  margin: 0; font-size: 11.5px; font-weight: 680;
  text-transform: uppercase; letter-spacing: .05em;
}
.group-head.is-late .group-title { color: var(--critical); }
.group-count { font-size: 11.5px; color: var(--ink-2); margin-left: auto; }
