/* ============================================================
   Projects v3 — Direction 3 visual port
   All rules are scoped under body.v3-projects so this stylesheet
   never bleeds into Home / Checklist / Lookup / Billing / etc.
   ============================================================ */

body.v3-projects {
  /* Neutrals + brand green SNAPPED to the canonical tokens (styles.css :root).
     These used to be near-but-not-equal — a warmer cream (#f7f4ed), a darker ink,
     a yellower green (#2f6b3a vs the real #2f6b4a) — which made Projects read as a
     different app. Pointing them at the real tokens fixes that with no structural
     change. The status ramp (gold/red/blue/grey) is intentionally left as-is for
     now; unifying those with --success/--warn/--info is the deferred pass. */
  --v3-cream: var(--bg);
  --v3-cream-2: var(--surface-alt);
  --v3-paper: var(--surface);
  --v3-ink: var(--ink);
  --v3-ink-2: var(--ink-soft);
  --v3-muted: var(--ink-soft);
  --v3-muted-2: var(--ink-mute);
  --v3-line: var(--line);
  --v3-line-2: var(--line-strong);
  --v3-green: var(--accent);
  --v3-green-soft: var(--accent-soft);
  --v3-green-deep: var(--accent-ink);
  --v3-gold: #b08a3e;
  --v3-gold-soft: #f0e6cc;
  --v3-red: #a83a2a;
  --v3-red-soft: #f1d8d2;
  --v3-blue: #3a5a8a;
  --v3-blue-soft: #d8e2f0;
  --v3-grey: #8a8678;
  --v3-grey-soft: #e8e4d8;
  --v3-radius: 10px;
  --v3-radius-sm: 6px;
  --v3-shadow-sm: var(--shadow-sm);
}

/* Sane defaults for any inline SVG used inside the v3 surface so a missing
   per-context size rule (or a misnamed icon id) cannot blow up the layout. */
body.v3-projects svg.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
body.v3-projects {
  --v3-shadow-md: var(--shadow-md);
}

/* When on projects route, replace the page background */
body.v3-projects #projectsView { background: var(--v3-cream); }

/* Hide the legacy head/body so v3 root can take over the projectsView container */
body.v3-projects #projectsView > section.projects-head,
body.v3-projects #projectsView > div.projects-body { display: none; }

/* ===== v3 root container ===== */
.v3-root {
  font-family: 'Satoshi', system-ui, -apple-system, sans-serif;
  color: var(--v3-ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  background: var(--v3-cream);
  min-height: calc(100vh - 60px);
}

.v3-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 60px);
}

/* ===== Sidebar ===== */
.v3-sidebar {
  background: var(--surface-alt);
  border-right: 1px solid var(--v3-line);
  padding: 24px 14px;
  overflow-y: auto;
}
.v3-side-section { margin-bottom: 22px; }
.v3-side-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--v3-muted);
  padding: 4px 10px 6px;
}
.v3-side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--v3-ink-2);
  cursor: pointer;
  transition: background 0.1s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.v3-side-item:hover { background: var(--v3-cream-2); }
.v3-side-item.active {
  background: var(--v3-cream-2);
  color: var(--v3-ink);
  font-weight: 500;
}
.v3-side-item .icon {
  width: 16px; height: 16px;
  color: var(--v3-muted);
  flex-shrink: 0;
}
.v3-side-item.active .icon { color: var(--v3-green-deep); }
.v3-side-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 3px;
  margin-right: 3px;
  display: inline-block;
}
.v3-side-dot.prospect-dot { background: var(--v3-gold); }
.v3-side-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--v3-muted);
  font-variant-numeric: tabular-nums;
  background: var(--v3-cream);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.v3-side-item.active .count {
  background: var(--v3-paper);
  color: var(--v3-ink-2);
  font-weight: 500;
}
.v3-side-divider {
  height: 1px;
  background: var(--v3-line);
  margin: 14px 6px;
}
.v3-side-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--v3-ink-2);
  cursor: pointer;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.v3-side-action .icon { width: 16px; height: 16px; flex-shrink: 0; }
.v3-side-action:hover { background: var(--v3-cream-2); }
.v3-side-action.primary {
  background: var(--accent);
  color: #fff;
}
.v3-side-action.primary:hover { background: #245a3c; }
.v3-side-action.primary .icon { color: #fff; }

/* ===== Main column ===== */
.v3-main {
  padding: 28px 36px 56px;
  max-width: 1280px;
  overflow-x: hidden;
}
.v3-crumbs {
  font-size: 12px;
  color: var(--v3-muted);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.v3-crumbs .v3-crumb-current { color: var(--v3-ink-2); }
.v3-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 4px;
}
.v3-head-title {
  font-family: 'General Sans', 'Satoshi', sans-serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--v3-ink);
}
.v3-head-meta { font-size: 12px; color: var(--v3-muted); text-align: right; }
.v3-head-meta strong { color: var(--v3-ink-2); font-weight: 500; }
.v3-head-actions { display: flex; gap: 8px; align-items: center; }
.v3-btn-primary {
  /* Green, matching Home's .btn-primary. It was dark-ink here, so "the primary
     button" was two different colors across the app. */
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.v3-btn-primary:hover { background: #245a3c; }
.v3-btn-ghost {
  background: var(--v3-paper);
  color: var(--v3-ink-2);
  border: 1px solid var(--v3-line);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}
.v3-btn-ghost:hover { background: var(--v3-cream); }

/* ===== Sync header ===== */
.v3-sync {
  font-size: 11.5px;
  color: var(--v3-muted);
  margin: 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.v3-sync .v3-sync-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--v3-green);
  display: inline-block;
}

/* ===== KPI strip ===== */
.v3-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 22px 0 24px;
}
.v3-strip-card {
  background: var(--surface-alt);
  border: 1px solid var(--v3-line);
  border-radius: 9px;
  padding: 14px 16px;
}
.v3-strip-lbl {
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--v3-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.v3-strip-val {
  font-family: 'General Sans', 'Satoshi', sans-serif;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.v3-strip-sub { font-size: 11px; color: var(--v3-muted); margin-top: 5px; }
.v3-strip-sub.up { color: var(--v3-green); }
.v3-strip-sub.down { color: var(--v3-red); }
.v3-strip-card.danger .v3-strip-val { color: var(--v3-red); }

/* ===== Needs Attention ===== */
.v3-attn-wrap {
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.v3-attn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.v3-attn-title {
  font-family: 'General Sans', 'Satoshi', sans-serif;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.v3-attn-title .icon { width: 16px; height: 16px; color: var(--v3-red); }
.v3-attn-count {
  font-size: 11px;
  color: var(--v3-muted);
  background: var(--v3-cream);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}
.v3-attn-toggle {
  font-size: 12px;
  color: var(--v3-muted);
  cursor: pointer;
  margin-left: auto;
}
.v3-attn-toggle:hover { color: var(--v3-ink-2); }
.v3-attn-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--v3-line);
  cursor: pointer;
}
.v3-attn-item:last-child { border-bottom: 0; padding-bottom: 0; }
.v3-attn-item:first-of-type { padding-top: 4px; }
.v3-attn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--v3-red);
  margin-top: 6px;
}
.v3-attn-dot.warn { background: var(--v3-gold); }
.v3-attn-dot.info { background: var(--v3-blue); }
.v3-attn-name { font-weight: 500; font-size: 13.5px; color: var(--v3-ink); }
.v3-attn-why {
  font-size: 12px;
  color: var(--v3-muted);
  margin-top: 2px;
}
.v3-attn-why .sep { color: var(--v3-line-2); margin: 0 6px; }
.v3-attn-why .stalled { color: var(--v3-red); font-weight: 500; }
.v3-attn-action {
  font-size: 12px;
  color: var(--v3-green-deep);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--v3-green-soft);
  background: var(--v3-green-soft);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease;
}
.v3-attn-action:hover { background: #c5d8be; }
.v3-attn-empty {
  font-size: 12.5px;
  color: var(--v3-muted);
  padding: 6px 0 2px;
}

/* ===== Toolbar ===== */
.v3-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.v3-vswitch {
  display: inline-flex;
  gap: 0;
  background: var(--v3-cream-2);
  border-radius: 7px;
  padding: 3px;
}
.v3-vbtn {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 5px;
  color: var(--v3-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s ease;
  border: none;
  background: transparent;
  font-family: inherit;
}
.v3-vbtn:hover { color: var(--v3-ink-2); }
.v3-vbtn .icon { width: 13px; height: 13px; }
.v3-vbtn.active {
  background: var(--v3-paper);
  color: var(--v3-ink);
  font-weight: 500;
  box-shadow: var(--v3-shadow-sm);
}
.v3-vbtn.active .icon { color: var(--v3-ink); }
.v3-tb-spacer { flex: 1; }
.v3-tb-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--v3-ink-2);
  width: 260px;
}
.v3-tb-search .icon { width: 13px; height: 13px; color: var(--v3-muted); }
.v3-tb-search input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--v3-ink);
  font-family: inherit;
  width: 100%;
}
.v3-tb-search input::placeholder { color: var(--v3-muted); }
.v3-tb-filter {
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--v3-line);
  background: var(--v3-paper);
  font-size: 12.5px;
  color: var(--v3-ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.v3-tb-filter:hover { background: var(--v3-cream); }
.v3-tb-filter .icon { width: 13px; height: 13px; color: var(--v3-muted); }
.v3-tb-filter.active { background: var(--v3-cream-2); border-color: var(--v3-line-2); }

/* ===== Filter chip drawer (hidden by default) ===== */
.v3-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  border-radius: 8px;
}
.v3-filter-bar[hidden] { display: none; }
.v3-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.v3-filter-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--v3-muted);
  margin-right: 4px;
  font-weight: 500;
}
.v3-filter-chip {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--v3-cream);
  color: var(--v3-ink-2);
  border: 1px solid var(--v3-line);
  cursor: pointer;
  font-family: inherit;
}
.v3-filter-chip:hover { background: var(--v3-cream-2); }
.v3-filter-chip.active {
  background: var(--v3-ink);
  color: var(--v3-cream);
  border-color: var(--v3-ink);
}
.v3-filter-clear {
  font-size: 11.5px;
  color: var(--v3-red);
  background: transparent;
  border: none;
  cursor: pointer;
  margin-left: auto;
  font-family: inherit;
}

/* ===== Bulk bar ===== */
.v3-bulkbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--v3-ink);
  color: var(--v3-cream);
  border-radius: 8px;
  padding: 9px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
}
.v3-bulkbar[hidden] { display: none; }
.v3-bulkbar .v3-bulkbar-count { font-weight: 600; }
.v3-bulkbar button {
  background: rgba(255,255,255,0.10);
  color: var(--v3-cream);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}
.v3-bulkbar button:hover { background: rgba(255,255,255,0.18); }
.v3-bulkbar button.danger { color: #ffd6cf; }

/* ===== Table ===== */
.v3-table {
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  /* overflow-x:auto, NOT hidden. The fixed ~982px row grid is wider than the
     available column whenever the 240px sidebar is shown and the viewport is
     under ~1230px — a common laptop/tablet band. With `hidden` the right-hand
     columns were clipped with no way to reach them (measured: at 1000px the box
     was 646px, the row 1000px, the 'updated' column gone). Scrolling the table
     within its own box beats silently hiding data; the root guard keeps this off
     the page level. */
  overflow-x: auto;
}
.v3-row {
  display: grid;
  /* checkbox · name · status&milestones · contractor · paid/total · updated
     Status&milestones needs ~200px (pill) + 12px gap + 152px (7 cells + divider) = ~364px
     to display cleanly. We give it minmax(360px, 1fr) so it never gets squeezed
     under that floor; the layout grows the whole row before sacrificing legibility. */
  grid-template-columns: 36px 220px minmax(360px, 1fr) 120px 100px 76px;
  gap: 14px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--v3-line);
  font-size: 13px;
  transition: background 0.1s ease;
}
.v3-row:last-child { border-bottom: 0; }
/* Retuned off the old warm cream (#fcfaf4 / #f7f3e6) now that the palette is
   canonical: neutral hover, soft-green selected. */
.v3-row:not(.head):hover { background: var(--surface-alt); cursor: pointer; }
.v3-row.is-selected { background: var(--accent-soft); }
.v3-row.head {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--v3-muted);
  font-weight: 500;
  padding: 10px 18px;
  background: var(--surface-alt);
}
.v3-row.head .sortable { cursor: pointer; }
.v3-row.head .sortable.active { color: var(--v3-ink); }
.v3-row.head .sortable.active::after {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  margin-left: 5px;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}
.v3-row.head .sortable.asc::after { border-bottom: 4px solid var(--v3-ink); }
.v3-row.head .sortable.desc::after { border-top: 4px solid var(--v3-ink); }
.v3-row-cb { display: flex; align-items: center; }
.v3-row-cb input { cursor: pointer; }

.v3-row-name {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
}
.v3-row-icon {
  width: 28px; height: 28px;
  background: var(--v3-cream-2);
  border-radius: 7px;
  color: var(--v3-ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.v3-row-icon .icon { width: 15px; height: 15px; }
.v3-row-icon.favor { background: var(--v3-gold-soft); color: #6b5320; }
.v3-row-icon.paused { background: var(--v3-red-soft); color: #6a2418; }
.v3-row-name-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.v3-row-name-text .label {
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v3-row-sub {
  font-size: 11px;
  color: var(--v3-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v3-favor-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #6b5320;
  background: var(--v3-gold-soft);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex-shrink: 0;
  align-self: flex-start;
}
.v3-favor-tag .icon {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

/* ===== Status pill ===== */
.v3-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  /* Graceful fallback if a status label is ever longer than the column allows;
     prevents the pill from pushing into the milestone strip / contractor cell. */
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.v3-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.v3-status.cd { background: var(--v3-green-soft); color: var(--v3-green-deep); }
.v3-status.cd::before { background: var(--v3-green); }
.v3-status.pc { background: var(--v3-gold-soft); color: #6b5320; }
.v3-status.pc::before { background: var(--v3-gold); }
.v3-status.cdoc { background: var(--v3-blue-soft); color: #2a3f60; }
.v3-status.cdoc::before { background: var(--v3-blue); }
.v3-status.pause { background: var(--v3-red-soft); color: #6a2418; }
.v3-status.pause::before { background: var(--v3-red); }
.v3-status.lead { background: var(--v3-grey-soft); color: #4a4634; }
.v3-status.lead::before { background: var(--v3-grey); }
.v3-status.constr { background: var(--v3-blue-soft); color: #2a3f60; }
.v3-status.constr::before { background: var(--v3-blue); }
.v3-status.archived { background: var(--v3-grey-soft); color: var(--v3-muted); }
.v3-status.archived::before { background: var(--v3-muted-2); }
.v3-status.done { background: var(--v3-green-soft); color: var(--v3-green-deep); }
.v3-status.done::before { background: var(--v3-green); }
.v3-status.neutral { background: var(--v3-cream-2); color: var(--v3-ink-2); }
.v3-status.neutral::before { background: var(--v3-muted); }

/* ===== Milestone strip ===== */
.v3-ms-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden; /* never let contents spill into the contractor column */
}
.v3-ms-strip {
  display: flex;
  gap: 3px;
  flex-shrink: 0; /* the 7 milestone cells are sacred — keep their full width */
}

/* Generic safety: any direct cell in a row should clip rather than push siblings.
   Targets the bare <div>s used for contractor and paid/total. */
.v3-row > div {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Name cell uses a nested column layout, exempt from the nowrap rule above. */
.v3-row > .v3-row-name { white-space: normal; overflow: visible; }
.v3-ms-cell {
  width: 18px; height: 18px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  position: relative;
  cursor: default;
}
.v3-ms-cell.fin {
  background: #ebf2e8;
  color: transparent;
  border: 1px solid #d6e2d0;
}
.v3-ms-cell.fin.done { background: var(--v3-green); color: var(--v3-paper); }
.v3-ms-cell.fin.done::after { content: '$'; }
.v3-ms-cell.des {
  background: #e6ecf3;
  color: transparent;
  border: 1px solid #d1dbea;
}
.v3-ms-cell.des.done { background: var(--v3-blue); color: var(--v3-paper); }
.v3-ms-cell.des.done::after {
  content: '';
  width: 8px; height: 5px;
  border-left: 1.6px solid var(--v3-paper);
  border-bottom: 1.6px solid var(--v3-paper);
  transform: rotate(-45deg) translateY(-1px);
}
.v3-ms-cell.na { background: var(--v3-grey-soft); border: 1px solid #d4cdb8; }
.v3-ms-cell.na::after {
  content: '';
  position: absolute;
  left: 3px; right: 3px;
  top: 50%;
  height: 1px;
  background: var(--v3-grey);
  transform: rotate(-22deg);
}
.v3-ms-divider {
  width: 1px;
  height: 14px;
  background: var(--v3-line-2);
  margin: 0 2px;
}

/* ===== Money + updated ===== */
.v3-row-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.v3-row-money .total { font-weight: 500; color: var(--v3-ink-2); }
.v3-row-money .paid { font-size: 11px; color: var(--v3-muted); }
.v3-row-money.no-charge { color: var(--v3-muted); font-style: italic; font-size: 12px; }
.v3-row-updated {
  text-align: right;
  font-size: 12px;
  color: var(--v3-muted);
}
.v3-row-updated.stale { color: var(--v3-red); font-weight: 500; }

/* Favor row tint */
.v3-row.is-favor { background: linear-gradient(180deg, #fcf9f1 0%, #fbf6e8 100%); }
.v3-row.is-favor:hover { background: #faf3df; }
.v3-row.is-archived { opacity: 0.65; }

/* Footer of table */
.v3-table-foot {
  padding: 12px 18px;
  font-size: 12px;
  color: var(--v3-muted);
  background: var(--surface-alt);
  border-top: 1px solid var(--v3-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.v3-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--v3-muted);
  font-size: 13px;
}

/* Legend */
.v3-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 12px 4px;
  font-size: 11.5px;
  color: var(--v3-muted);
  margin-top: 8px;
}
.v3-legend-item { display: inline-flex; align-items: center; gap: 7px; }
.v3-legend-sw {
  width: 14px; height: 14px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--v3-paper);
  font-size: 9px;
  font-weight: 600;
}
.v3-legend-sw.fin { background: var(--v3-green); }
.v3-legend-sw.fin::after { content: '$'; }
.v3-legend-sw.des { background: var(--v3-blue); }
.v3-legend-sw.des::after {
  content: '';
  width: 6px; height: 4px;
  border-left: 1.4px solid var(--v3-paper);
  border-bottom: 1.4px solid var(--v3-paper);
  transform: rotate(-45deg);
}
.v3-legend-sw.empty { background: #ebf2e8; border: 1px solid #d6e2d0; }
.v3-legend-sw.na {
  background: var(--v3-grey-soft);
  position: relative;
  border: 1px solid #d4cdb8;
}
.v3-legend-sw.na::after {
  content: '';
  position: absolute;
  left: 2px; right: 2px;
  top: 50%;
  height: 1px;
  background: var(--v3-grey);
  transform: rotate(-22deg);
}

/* Hide the sidebar earlier so the table gets full width and mostly fits before
   it would have to scroll — decoupled from row stacking below. */
@media (max-width: 1024px) {
  .v3-shell { grid-template-columns: 1fr; }
  .v3-sidebar { display: none; }
  .v3-strip { grid-template-columns: 1fr 1fr; }
}
/* Stack rows into cards only on genuinely narrow screens (phones), matching the
   bottom-bar breakpoint. Between 721–1024 the table stays tabular (scrolling if
   needed) rather than prematurely becoming a card stack on a tablet. */
@media (max-width: 720px) {
  .v3-row, .v3-row.head { grid-template-columns: 1fr; gap: 6px; padding: 14px; }
  .v3-row.head { display: none; }
  .v3-row-money, .v3-row-updated { text-align: left; }
}

/* ===== Action Items panel ===== */
.v3-actions-wrap {
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

/* ===== Action Items REPORT (dedicated Tasks page) =====
   Full-page variant used when the sidebar 'Action items' entry is active.
   Same visual language as the compact panel, but with more breathing room,
   a sticky-ish header, and no bottom margin (it's the sole content). */
.v3-actions-report {
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  border-radius: 12px;
  padding: 22px 26px 8px;
  margin: 0 0 16px;
}
.v3-actions-report .v3-actions-report-head {
  margin-bottom: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--v3-line);
}
.v3-actions-report .v3-actions-title { font-size: 15px; }
.v3-actions-report .v3-actions-item { padding: 12px 0; }
.v3-actions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.v3-actions-title {
  font-family: 'General Sans', 'Satoshi', sans-serif;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.v3-actions-title .icon { width: 16px; height: 16px; color: var(--v3-green-deep); }
.v3-actions-count {
  font-size: 11px;
  color: var(--v3-ink-2);
  background: var(--v3-green-soft);
  padding: 2px 9px;
  border-radius: 999px;
  margin-left: 4px;
  font-weight: 600;
}
.v3-actions-tools {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.v3-actions-link {
  font-size: 12px;
  color: var(--v3-muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.v3-actions-link:hover { color: var(--v3-ink-2); text-decoration: underline; }
.v3-actions-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--v3-line);
  cursor: pointer;
}
.v3-actions-item:last-child { border-bottom: 0; padding-bottom: 0; }
.v3-actions-item:first-of-type { padding-top: 2px; }
.v3-actions-item:hover { background: rgba(0,0,0,0.015); }
.v3-actions-cb {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
}
.v3-actions-cb input { cursor: pointer; width: 15px; height: 15px; }
.v3-actions-body { min-width: 0; }
.v3-actions-text {
  font-size: 13.5px;
  color: var(--v3-ink);
  line-height: 1.4;
  word-wrap: break-word;
}
.v3-actions-meta {
  font-size: 12px;
  color: var(--v3-muted);
  margin-top: 2px;
}
.v3-actions-meta .sep { color: var(--v3-line-2); margin: 0 6px; }
.v3-actions-project {
  color: var(--v3-ink-2);
  font-weight: 500;
}
.v3-actions-item.is-done .v3-actions-text {
  text-decoration: line-through;
  color: var(--v3-muted);
}
.v3-actions-empty {
  font-size: 12.5px;
  color: var(--v3-muted);
  padding: 2px 0 2px 0;
}
.v3-actions-empty code {
  font-family: ui-monospace, monospace;
  background: var(--v3-cream);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* Open action-items count badge on project rows */
.v3-action-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: #6b5800;
  background: #fff3c4;
  border: 1px solid #f1d97a;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
  line-height: 1;
}

/* Sidebar 'show more / fewer' contractor button */
.v3-side-more {
  cursor: pointer;
  background: none;
  border: 0;
  font-family: inherit;
  text-align: left;
}
.v3-side-more:hover span:last-child { color: var(--v3-ink-2); text-decoration: underline; }

/* Drawer subsection (Shop drawings groupings) */
.drawer-subsection {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--v3-line);
}
.drawer-subsection:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.drawer-subsection h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--v3-ink-2);
  font-family: 'General Sans', 'Satoshi', sans-serif;
}

/* ===== Add-action-item popover ===== */
.v3-add-pop {
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  box-shadow: 0 10px 28px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.05);
  border-radius: 10px;
  padding: 14px;
  font-family: 'General Sans', 'Satoshi', sans-serif;
}
.v3-add-pop-row {
  margin-bottom: 10px;
  position: relative;
}
.v3-add-pop-row label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--v3-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.v3-add-pop-row input[type=text] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--v3-line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}
.v3-add-pop-row input[type=text]:focus {
  outline: none;
  border-color: var(--v3-green-deep);
  box-shadow: 0 0 0 2px var(--v3-green-soft);
}
.v3-add-pop-picker {
  position: absolute;
  left: 0; right: 0; top: 100%;
  margin-top: 4px;
  background: var(--v3-paper);
  border: 1px solid var(--v3-line);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1;
}
.v3-add-pop-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--v3-line);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.v3-add-pop-picker-row:last-child { border-bottom: 0; }
.v3-add-pop-picker-row:hover { background: var(--v3-cream); }
.v3-add-pop-picker-row .name { color: var(--v3-ink); font-weight: 500; }
.v3-add-pop-picker-row .meta { color: var(--v3-muted); font-size: 11.5px; }
.v3-add-pop-picker-empty {
  padding: 10px;
  font-size: 12px;
  color: var(--v3-muted);
  text-align: center;
}
.v3-add-pop-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.v3-add-pop-cancel,
.v3-add-pop-save {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--v3-line);
  background: var(--v3-paper);
}
.v3-add-pop-cancel { color: var(--v3-ink-2); }
.v3-add-pop-cancel:hover { background: var(--v3-cream); }
.v3-add-pop-save {
  background: var(--v3-ink);
  color: var(--v3-paper);
  border-color: var(--v3-ink);
}
.v3-add-pop-save:disabled {
  background: var(--v3-line-2);
  border-color: var(--v3-line-2);
  color: var(--v3-muted);
  cursor: not-allowed;
}

/* ===== Per-row '+' add-action button & panel-header Add button ===== */
.v3-row-add-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  border-radius: 4px;
  border: 0;
  background: transparent;
  color: var(--v3-muted);
  cursor: pointer;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.v3-row-add-action .icon { width: 12px; height: 12px; }
.v3-row:hover .v3-row-add-action { opacity: 0.7; }
.v3-row-add-action:hover { opacity: 1; background: var(--v3-cream); color: var(--v3-ink-2); }
.v3-row-add-action:focus {
  opacity: 1;
  outline: 2px solid var(--v3-green-deep);
  outline-offset: 1px;
}

.v3-actions-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--v3-paper);
  background: var(--v3-ink);
  border: 0;
  padding: 5px 10px 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.v3-actions-add .icon { width: 11px; height: 11px; }
.v3-actions-add:hover { background: var(--v3-ink-2); }

/* ===== Drawer review-history inline line ===== */
.drawer-review-history {
  font-size: 11.5px;
  color: var(--v3-muted);
  margin: -8px 0 12px 0;
  padding: 6px 10px;
  background: var(--v3-cream);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.drawer-review-history strong {
  color: var(--v3-ink-2);
  font-weight: 600;
  margin-right: 4px;
}
.drawer-review-history .sep {
  color: var(--v3-line-2);
  margin: 0 4px;
}
