/* detail.css — additive styles for the redesigned Project Detail view.
   Loaded AFTER app.css; reuses its tokens (--primary, --ink, --line, --pos…).
   New class prefixes: pd- (project detail shell), ll- (lifeline), ring-. */

/* ---------- Artboard root: re-assert app type/colors inside the canvas ---------- */
.pd-root {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.pd-root * { box-sizing: border-box; }
.pd-root .chip { white-space: nowrap; }
.pd-root .segmented button { white-space: nowrap; }

/* ---------- Slim topbar ---------- */
.pd-topbar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm); z-index: 6;
}
.pd-topbar .pd-back { display: inline-flex; align-items: center; gap: 5px; }
.pd-crumb { font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 600; }
.pd-topbar h1 { font-size: 15.5px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.pd-topbar .pd-titlewrap { display: flex; flex-direction: column; justify-content: center; min-width: 0; flex: none; }

/* ---------- Tab bar ---------- */
.pd-tabbar {
  flex: none;
  display: flex; align-items: stretch; gap: 2px;
  padding: 0 18px; height: 42px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.pd-tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 0 13px; letter-spacing: -.005em;
}
.pd-tab:hover { color: var(--ink); }
.pd-tab.on { color: var(--primary-strong); }
.pd-tab.on::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px;
  background: var(--primary); border-radius: 2px 2px 0 0;
}
.pd-tab .pd-tabcount {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  background: var(--surface-3); color: var(--muted);
  padding: 1px 6px; border-radius: 20px; line-height: 1.5;
}
.pd-tab.on .pd-tabcount { background: var(--primary-soft); color: var(--primary-strong); }

/* ---------- Scroll body ---------- */
.pd-scroll { flex: 1; overflow: auto; padding: 16px 18px 36px; min-height: 0; }
.pd-actions { display: flex; align-items: center; gap: 7px; }

/* ---------- KPI strip variant (4-up, tighter) ---------- */
.pd-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.pd-kpis .kpi .value { font-size: 19px; }

/* ---------- Inline editing affordances ---------- */
.inl {
  border-radius: 5px; cursor: text;
  transition: background .1s, box-shadow .1s;
  outline: none;
}
.inl:hover { background: var(--primary-tint); box-shadow: inset 0 0 0 1px var(--line-2); }
.inl-edit {
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--primary), 0 0 0 3px var(--primary-soft);
}
.inl-edit:hover { background: var(--surface); }
.inl-pen { opacity: 0; color: var(--faint); transition: opacity .1s; margin-left: 5px; }
.inl-host:hover .inl-pen { opacity: 1; }
textarea.inl-area {
  width: 100%; border: 1px solid var(--primary); border-radius: 6px; padding: 8px 10px;
  font: inherit; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); resize: vertical;
  background: var(--surface); outline: none; box-shadow: 0 0 0 3px var(--primary-soft);
}
input.inl-input {
  border: 1px solid var(--primary); border-radius: 5px; padding: 4px 7px;
  font: inherit; color: var(--ink); background: var(--surface); outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.statuspick { position: relative; display: inline-flex; }
.statuspick-menu {
  position: absolute; top: calc(100% + 5px); left: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 7px;
  box-shadow: var(--shadow-md); padding: 4px; min-width: 140px;
}
.statuspick-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 12px;
  padding: 6px 8px; border-radius: 5px; color: var(--ink-2); text-align: left;
}
.statuspick-menu button:hover { background: var(--surface-3); }

/* ---------- Overview / progress bits ---------- */
.pd-overview-desc { color: var(--ink-2); line-height: 1.6; margin: 0; }
.pd-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.progressbar { height: 8px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.progressbar > span { display: block; height: 100%; background: var(--pos); border-radius: 5px; transition: width .3s; }
.progress-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); margin-top: 9px; flex-wrap: wrap; }
.progress-legend .pl-num { font-family: var(--mono); font-weight: 600; color: var(--ink); }

/* ---------- Progress ring ---------- */
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; flex: none; }
.ring .ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0;
}
.ring .ring-pct { font-family: var(--mono); font-weight: 600; letter-spacing: -.02em; color: var(--ink); }
.ring .ring-sub { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }

/* ---------- Lifeline (shared) ---------- */
.ll-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.ll-legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.ll-legend .lg .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ll-legend .lg .sw.sq { border-radius: 2px; }

/* horizontal lifeline */
.ll { position: relative; width: 100%; }
.ll-months { position: relative; height: 18px; margin-bottom: 6px; }
.ll-month { position: absolute; top: 0; font-size: 10px; font-family: var(--mono); color: var(--faint); transform: translateX(-1px); white-space: nowrap; }
.ll-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.ll-grid.qtr { background: var(--line-2); }
.ll-plot { position: relative; }
.ll-baseline { position: absolute; left: 0; right: 0; height: 2px; background: var(--line-2); border-radius: 2px; }
.ll-span { position: absolute; height: 6px; border-radius: 4px; background: linear-gradient(90deg, var(--primary-soft), var(--primary-tint)); box-shadow: inset 0 0 0 1px var(--line-2); }
.ll-today { position: absolute; left: 116px; right: 0; top: -2px; bottom: 0; z-index: 4; pointer-events: none; }
.ll-today::before { content: 'TODAY'; position: absolute; top: -16px; left: var(--ll-today-x); transform: translateX(-50%); font-size: 8.5px; font-weight: 700; letter-spacing: .08em; color: var(--neg); font-family: var(--mono); }
.ll-today::after { content: ''; position: absolute; top: 0; bottom: 0; left: var(--ll-today-x); width: 2px; transform: translateX(-1px); background: var(--neg); }
.ll-node {
  position: absolute; transform: translate(-50%, -50%); z-index: 3;
  width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(15,27,45,.12), var(--shadow-sm); cursor: default;
}
.ll-node.sq { border-radius: 3px; }
.ll-node.future { opacity: .5; }
.ll-node:hover { z-index: 6; transform: translate(-50%, -50%) scale(1.25); }
.ll-flag {
  position: absolute; transform: translateX(-50%); z-index: 2;
  font-size: 9.5px; font-family: var(--mono); color: var(--muted);
  white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}

/* multi-lane (gantt-ish) */
.ll-lanes { display: grid; gap: 0; position: relative; }
.ll-lane { position: relative; display: grid; grid-template-columns: 116px 1fr; align-items: center; border-top: 1px solid var(--line); }
.ll-lane:first-child { border-top: 0; }
.ll-lane-label { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); padding: 14px 12px 14px 2px; }
.ll-lane-label .lico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.ll-lane-track { position: relative; height: 100%; min-height: 48px; }

/* vertical rail */
.ll-rail { position: relative; padding-left: 4px; }
.ll-rail::before { content: ''; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.ll-revt { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 8px 0; align-items: start; }
.ll-revt-dot { position: relative; z-index: 2; width: 13px; height: 13px; margin: 3px auto 0; border-radius: 50%; border: 2.5px solid var(--surface); box-shadow: 0 0 0 1px rgba(15,27,45,.12); }
.ll-revt-dot.sq { border-radius: 3px; }
.ll-revt-dot.future { opacity: .55; }
.ll-revt-body { min-width: 0; }
.ll-revt-top { display: flex; align-items: baseline; gap: 8px; }
.ll-revt-title { font-size: 12.5px; font-weight: 600; color: var(--ink); min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-revt.is-future .ll-revt-title { color: var(--muted); font-weight: 500; }
.ll-revt-date { font-size: 10.5px; font-family: var(--mono); color: var(--faint); flex: 0 0 auto; white-space: nowrap; }
.ll-revt-sub { font-size: 11px; color: var(--muted); margin-top: 1px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ll-todaymark { position: relative; display: flex; align-items: center; gap: 8px; padding: 7px 0 7px 38px; }
.ll-todaymark::before { content: ''; position: absolute; left: 13px; top: 50%; width: 13px; height: 13px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); z-index: 3; }
.ll-todaymark .lbl { font-size: 9.5px; font-weight: 700; letter-spacing: .1em; color: var(--neg); font-family: var(--mono); }
.ll-todaymark .ln { flex: 1; height: 1px; background: var(--neg); opacity: .35; }

/* milestone inline rows (planning) */
.ms-row { display: grid; gap: 7px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: var(--surface); transition: border-color .1s; }
.ms-row-tools { display: inline-flex; align-items: center; gap: 1px; }
.ms-hours { display: inline-block; width: 110px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; vertical-align: middle; }
.ms-hours > span { display: block; height: 100%; border-radius: 3px; transition: width .3s; }

/* collapsible disclosures + section bar (planning) */
.pd-chev { transition: transform .15s ease; }
.pd-chev.open { transform: rotate(90deg); }
.pd-disc { background: transparent; border: 0; padding: 2px; cursor: pointer; color: var(--faint); display: grid; place-items: center; border-radius: 4px; flex: none; }
.pd-disc:hover { background: var(--surface-3); color: var(--ink); }
.pd-disc-row { display: flex; align-items: center; gap: 8px; width: 100%; background: transparent; border: 0; cursor: pointer; font: inherit; padding: 4px 0; text-align: left; }
.pd-disc-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pd-panelhead-btn { cursor: pointer; user-select: none; }
.pd-panelhead-btn:hover h2 { color: var(--primary-strong); }
.pd-section-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.pd-section-rename { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); margin-left: auto; }
.pd-plan-cols { grid-template-columns: 1fr 1fr; align-items: start; }
.pd-docs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.todo-cluster-prog { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; }
.todo-cluster.collapsed { background: var(--surface-2); }
.pd-root input.pd-check[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  margin: 0;
  border: 1.5px solid var(--line-2);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75), 0 1px 2px rgba(15,27,45,.08);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.pd-root input.pd-check[type="checkbox"]::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  opacity: 0;
  transform: rotate(45deg) translate(-1px, -1px) scale(.8);
  transition: opacity .12s ease, transform .12s ease;
}
.pd-root input.pd-check[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 0 0 3px var(--primary-soft), 0 1px 2px rgba(15,27,45,.08);
}
.pd-root input.pd-check[type="checkbox"]:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.pd-root input.pd-check[type="checkbox"]:checked {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), 0 2px 5px rgba(42,115,217,.24);
}
.pd-root input.pd-check[type="checkbox"]:checked::after {
  opacity: 1;
  transform: rotate(45deg) translate(-1px, -1px) scale(1);
}
.pd-root input.pd-check[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: .45;
  background: var(--surface-3);
  box-shadow: none;
}
.pd-root .todo-line {
  grid-template-columns: 20px minmax(120px, 1fr) minmax(118px, 150px) auto;
  gap: 9px;
}
.pd-root .todo-line-full {
  grid-template-columns: 20px minmax(120px, 1fr) minmax(118px, 145px) minmax(130px, 170px) auto;
}
.pd-root .todo-line .pd-check {
  align-self: center;
}
.ms-row:hover { border-color: var(--line-2); }
.ms-row.done { background: var(--surface-2); border-color: rgba(31,154,100,.28); }
.ms-row.doc-over,
.ptd-card.doc-over,
.kb-card.doc-over { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ptd-card.doc-over:hover,
.kb-card.doc-over:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ms-row-top { display: flex; align-items: center; gap: 10px; }
.pd-root input.ms-row-check[type="checkbox"] { width: 22px; height: 22px; border-radius: 7px; }
.ms-row-effort { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-left: 32px; }
.ms-row-todos { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-left: 32px; }
.ms-add { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--line-2); border-radius: 8px; padding: 8px 11px; background: var(--surface-2); }

.pd-docarea { display: grid; gap: 8px; border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px; background: var(--surface-2); transition: border-color .12s, box-shadow .12s, background .12s; }
.pd-docarea.over { border-color: var(--primary); background: var(--primary-tint); box-shadow: 0 0 0 3px var(--primary-soft); }
.pd-docarea.compact { padding: 9px; }
.pd-docarea-head { display: flex; align-items: center; gap: 8px; }
.pd-docarea-head label:first-child { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pd-docarea-head .btn { margin-left: auto; }
.pd-docarea-list { display: grid; gap: 6px; min-width: 0; }
.pd-docarea-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pd-docarea-row .pd-docchip { flex: 1; min-width: 0; }
.pd-docarea-drop { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; border-radius: 7px; background: var(--surface); border: 1px solid var(--line); color: var(--faint); font-size: 12px; font-weight: 600; }
.pd-docchip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; border: 1px solid var(--line); cursor: pointer; font: inherit; }
.pd-docchip svg { flex: none; }
.kb-chip[type="button"] { cursor: pointer; font-family: var(--font); }

/* small stat tiles used around rings */
.pd-tiles { display: grid; gap: 9px; }
.pd-tile { border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; background: var(--surface-2); }
.pd-tile .k { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.pd-tile .v { font-family: var(--mono); font-size: 16px; font-weight: 600; margin-top: 2px; color: var(--ink); letter-spacing: -.02em; }

.pd-customer-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.pd-customer-row:first-child { border-top: 0; }
.pd-customer-row .meta { min-width: 0; flex: 1; }
.pd-customer-row .nm { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-customer-row .em { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-customer-row .owe { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--warn); white-space: nowrap; }

.req-summary {
  width: 100%; min-width: 0; text-align: left; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface-2); padding: 11px 13px;
  cursor: pointer; display: grid; gap: 8px; font: inherit; color: inherit;
}
.req-summary:hover { border-color: var(--primary-soft); background: var(--surface); }
.req-summary-title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; font-weight: 650; color: var(--ink);
}
.req-summary-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.req-drawer-list { display: grid; gap: 10px; }
.req-drawer-item {
  display: grid; gap: 9px; padding: 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface-2);
}
.req-drawer-item textarea.inp { resize: vertical; min-height: 72px; line-height: 1.45; }

/* deliverable/offer + invoice section headers within financials */
.fin-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }

/* testing tab */
.pd-test-layout { display: grid; grid-template-columns: minmax(360px, 1.15fr) minmax(360px, .85fr); gap: 14px; align-items: start; }
.pd-test-layout tr.selected td { background: var(--primary-tint); }
.pd-test-stack { display: grid; gap: 14px; }
.pd-test-empty { padding: 18px; color: var(--muted); font-size: 12.5px; }
.pd-test-tags {
  display: inline-block;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.pd-test-form { display: grid; gap: 12px; }
.pd-test-form-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; }
.pd-test-form textarea.inp { min-height: 0; resize: vertical; line-height: 1.45; }
.pd-test-runbox { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--surface-2); display: grid; gap: 9px; }
.pd-test-runs { display: grid; gap: 8px; }
.pd-test-run-notes {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.pd-test-run-actions,
.pd-test-form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }

@media (max-width: 800px) {
  .pd-test-layout,
  .pd-test-form-row {
    grid-template-columns: 1fr;
  }
  .pd-root .todo-line,
  .pd-root .todo-line-full {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }
  .pd-root .todo-line .todo-status,
  .pd-root .todo-line .todo-milestone {
    grid-column: 2 / 4;
  }
  .pd-root .todo-line .icon-btn {
    grid-column: 3;
    grid-row: 1;
  }
}

/* planning save bar (appears when there are unsaved planning edits) */
.pd-savebar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 8px 11px; border: 1px solid #f0d9b8; background: var(--warn-soft); color: var(--warn); border-radius: 8px; font-size: 12px; font-weight: 600; }

/* in-frame toast (one per artboard; absolute, not fixed) */
.pd-toast {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500;
  padding: 9px 15px; border-radius: 7px; box-shadow: var(--shadow-pop);
  animation: pd-toast-in .16s ease;
}
@keyframes pd-toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
