/* SIR — Signal Intelligence Room
   Light triage UI. Pure white canvas; identity carried by the affiliation palette.
   See DESIGN.md for tokens and rationale. */

:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.977 0.002 343);
  --surface-2: oklch(0.955 0.003 343);
  --ink: oklch(0.21 0.015 343);
  --muted: oklch(0.45 0.02 343);
  --faint: oklch(0.58 0.015 343);
  --line: oklch(0.905 0.004 343);
  --line-strong: oklch(0.84 0.006 343);

  --primary: oklch(0.55 0.2 356);          /* rose  — brand + team */
  --primary-strong: oklch(0.48 0.19 356);
  --primary-tint: oklch(0.965 0.018 356);
  --client: oklch(0.51 0.19 264);          /* indigo — client */
  --client-tint: oklch(0.965 0.018 264);
  --third: oklch(0.6 0.13 168);            /* teal — third party */
  --third-tint: oklch(0.965 0.02 168);
  --unknown: oklch(0.52 0.01 343);         /* gray — unidentified */
  --unknown-tint: oklch(0.962 0.002 343);
  --attn: oklch(0.6 0.16 45);              /* orange — important / attention */
  --attn-strong: oklch(0.52 0.15 45);
  --attn-tint: oklch(0.965 0.025 65);

  /* HubSpot brand orange, given in hex because it is THEIR colour and the
     point of it is recognition — an oklch approximation that drifts by a
     few percent stops looking like the button people know.

     It carries INK, not white. #ff7a59 against white is 2.57:1, well under
     the 4.5:1 AA needs for text this size; against the ink below it is
     5.56:1. Darkening the orange until white worked meant going to about
     #c7391a, which no longer reads as HubSpot at all — so the text moved
     instead of the brand. */
  --hubspot: #ff7a59;
  --hubspot-strong: #ff5c35;   /* hover — 4.65:1 on ink */
  --hubspot-tint: #fff1ed;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;

  --z-sticky: 10;
  --z-tooltip: 40;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 150ms;
  --t-med: 220ms;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.875rem; /* 14px */
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum";
}

h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 600; }

button { font: inherit; color: inherit; }

a { color: var(--client); }

::selection { background: oklch(0.9 0.06 356); }

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
}

.wordmark-glyph { width: 18px; height: 18px; align-self: center; }

.wordmark-name { font-weight: 700; font-size: 1rem; letter-spacing: 0.04em; }

.wordmark-sub { color: var(--muted); font-size: 0.75rem; }

.topbar-actions { display: flex; align-items: center; gap: 0.9rem; }

.topbar-hint { color: var(--faint); font-size: 0.75rem; }

/* ------------------------------------------------------------------ layout */

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 5rem;
}

.page-head { margin-bottom: 1.5rem; }

.page-head h1 { font-size: 1.5625rem; letter-spacing: -0.015em; }

.page-head .sub { color: var(--muted); margin-top: 0.35rem; max-width: 68ch; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out);
}

.btn:hover { background: var(--surface); border-color: oklch(0.76 0.01 343); }

.btn:focus-visible,
.chip-btn:focus-visible,
.email-head:focus-visible {
  outline: 2px solid var(--client);
  outline-offset: 2px;
}

.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }

.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-small { padding: 0.28rem 0.6rem; font-size: 0.75rem; }

/* ----------------------------------------------------------- project index */

.project-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }

.project-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) auto 1fr auto;
  gap: 1.25rem;
  align-items: center;
  padding: 1.05rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast) var(--ease-out);
}

.project-row:hover { background: var(--surface); }

.project-row .name { font-weight: 600; font-size: 0.9375rem; letter-spacing: -0.005em; }

.project-row .client-line { color: var(--muted); font-size: 0.8125rem; margin-top: 0.15rem; }

.project-row .refid { color: var(--faint); font-size: 0.75rem; margin-left: 0.5rem; font-feature-settings: "tnum"; }

.project-meta {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.project-meta .stat b { color: var(--ink); font-weight: 600; }

.avatar-stack { display: inline-flex; }

.avatar-stack .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg); }

.avatar-stack .avatar:first-child { margin-left: 0; }

.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.stage-badge.stage-negotiation { background: var(--client-tint); color: var(--client); border-color: color-mix(in oklab, var(--client) 25%, white); }
.stage-badge.stage-pilot { background: var(--third-tint); color: oklch(0.45 0.11 168); border-color: color-mix(in oklab, var(--third) 30%, white); }
.stage-badge.stage-closed-won { background: var(--primary-tint); color: var(--primary); border-color: color-mix(in oklab, var(--primary) 22%, white); }
.stage-badge.stage-discovery { background: var(--attn-tint); color: var(--attn-strong); border-color: color-mix(in oklab, var(--attn) 28%, white); }

/* Being on the sales pipeline. Derived from config/pipelines.json rather than
   typed by hand (see lib/routes/projects.js), and given the primary tint so it
   carries more weight than the free-text stages around it — on the projects
   overview it is the one badge that says "this is live revenue", and it should
   be findable by colour in a list where most rows are discovery noise. */
.stage-badge.stage-now-selling {
  background: var(--primary-tint);
  color: var(--primary);
  border-color: color-mix(in oklab, var(--primary) 35%, white);
  font-weight: 700;
}

.attn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--attn-tint);
  color: var(--attn-strong);
  border: 1px dashed color-mix(in oklab, var(--attn) 45%, white);
  white-space: nowrap;
}

.attn-pill.clear {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ---------------------------------------------------------------- avatars */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.625rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  user-select: none;
}

.avatar.lg { width: 34px; height: 34px; font-size: 0.75rem; }

.avatar.aff-team { background: var(--primary); }
.avatar.aff-client { background: var(--client); }
.avatar.aff-third-party { background: var(--third); }
.avatar.aff-unknown {
  background: var(--unknown-tint);
  color: var(--unknown);
  border: 1.5px dashed var(--unknown);
}

/* ------------------------------------------------------------ project view */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
  margin-bottom: 0.9rem;
}

.back-link:hover { color: var(--ink); }

.proj-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }

.proj-head h1 { font-size: 1.5625rem; letter-spacing: -0.015em; }

.proj-head .title-line { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

.proj-head .desc { color: var(--muted); margin: 0.5rem 0 0; max-width: 68ch; }

.refchip {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0.14rem 0.5rem;
  border-radius: var(--radius-s);
  font-feature-settings: "tnum";
}

/* ---------------------------------------------------------------- overview */

.overview {
  margin-top: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  overflow: hidden;
}

.overview-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0;
}

@media (max-width: 820px) {
  .overview-grid { grid-template-columns: 1fr; }
  .overview-cell + .overview-cell { border-left: none !important; border-top: 1px solid var(--line); }
}

.overview-cell { padding: 1.1rem 1.3rem; min-width: 0; }

.overview-cell + .overview-cell { border-left: 1px solid var(--line); }

.overview-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  margin: 0 0 1.1rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.facts div { display: flex; gap: 0.45rem; align-items: baseline; }

.facts b { color: var(--ink); font-weight: 600; font-size: 0.9375rem; }

/* participants */

.party-groups { display: flex; flex-direction: column; gap: 0.85rem; }

.party-group .group-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.71875rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.group-dot { width: 8px; height: 8px; border-radius: 50%; }
.group-dot.aff-team { background: var(--primary); }
.group-dot.aff-client { background: var(--client); }
.group-dot.aff-third-party { background: var(--third); }
.group-dot.aff-unknown { background: transparent; border: 1.5px dashed var(--unknown); }

.party-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.party-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.6rem 0.25rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
  max-width: 100%;
}

.party-chip:hover { border-color: var(--line-strong); background: var(--surface-2); }

.party-chip.active { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }

.party-chip .p-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.party-chip .p-role { color: var(--muted); white-space: nowrap; }

.party-chip.is-unknown { border-style: dashed; }

.party-chip .p-identify {
  color: var(--attn-strong);
  font-weight: 600;
}

/* activity strip */

.activity-wrap { margin-top: 0.2rem; }

.activity {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 64px;
}

.activity .col {
  flex: 1;
  max-width: 56px;
  min-width: 4px;
  display: flex;
  align-items: flex-end;
  height: 100%;
  cursor: default;
}

.activity .bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: oklch(0.68 0.14 356);
  transition: background var(--t-fast) var(--ease-out);
}

.activity .col:hover .bar { background: var(--primary-strong); }

.activity .col.empty .bar { background: var(--line); min-height: 2px; }

.activity-axis {
  display: flex;
  justify-content: space-between;
  color: var(--faint);
  font-size: 0.6875rem;
  margin-top: 0.35rem;
  border-top: 1px solid var(--line);
  padding-top: 0.3rem;
}

.mini-activity { display: flex; align-items: flex-end; gap: 2px; height: 26px; width: 120px; }

.mini-activity span { flex: 1; max-width: 12px; min-height: 2px; border-radius: 1.5px 1.5px 0 0; background: oklch(0.78 0.09 356); }

.mini-activity span.zero { background: var(--line); }

/* attention banner */

.attention {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1.3rem 1rem;
  background: var(--attn-tint);
}

.attention.all-clear { background: var(--surface); }

.attention-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--attn-strong);
  margin-bottom: 0.5rem;
}

.attention.all-clear .attention-head { color: oklch(0.45 0.11 168); margin-bottom: 0; }

.attention-items { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.attention-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px dashed color-mix(in oklab, var(--attn) 45%, white);
  background: var(--bg);
  border-radius: var(--radius-s);
  padding: 0.32rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out);
  text-align: left;
}

.attention-item:hover { border-color: var(--attn); }

.attention-item .kind { color: var(--attn-strong); font-weight: 600; }

/* ------------------------------------------------------------- filter bar */

.filterbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 1.1rem;
}

.chip-btn {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  transition: all var(--t-fast) var(--ease-out);
}

.chip-btn:hover { border-color: oklch(0.7 0.01 343); color: var(--ink); }

.chip-btn.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.chip-btn .count { opacity: 0.65; margin-left: 0.25rem; font-feature-settings: "tnum"; }

.filterbar .spacer { flex: 1; }

.filterbar .filter-note { color: var(--faint); font-size: 0.75rem; }

.filter-person {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.7rem 0.22rem 0.28rem;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-person .x { color: var(--muted); }

/* ---------------------------------------------------------------- timeline */

.timeline { position: relative; padding-left: 2.6rem; }

.timeline::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--line);
  border-radius: 1px;
}

.month-sep {
  position: relative;
  margin: 1.6rem 0 0.9rem;
  font-size: 0.71875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.month-sep::before {
  content: "";
  position: absolute;
  left: calc(-2.6rem + 12px);
  top: 50%;
  width: 10px;
  height: 2px;
  background: var(--line);
}

.email {
  position: relative;
  margin-bottom: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--bg);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}

.email:hover { border-color: var(--line-strong); }

.email.open {
  border-color: var(--line-strong);
  box-shadow: 0 6px 24px -12px oklch(0.3 0.02 343 / 0.25);
}

.email.is-ignored { opacity: 0.55; }

.email.is-ignored .email-head { text-decoration: none; }

.email.is-important { border-color: color-mix(in oklab, var(--attn) 45%, white); }

.email.flash { animation: flash 1.2s var(--ease-out); }

@keyframes flash {
  0% { box-shadow: 0 0 0 3px color-mix(in oklab, var(--attn) 45%, white); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.email .node {
  position: absolute;
  left: calc(-2.6rem + 4px);
  top: 14px;
}

.email .node .avatar { box-shadow: 0 0 0 3px var(--bg); }

.email-head {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.75rem 1rem 0.7rem;
  cursor: pointer;
  border-radius: var(--radius-m);
}

.email-head .row1 {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.email-head .sender { font-weight: 600; font-size: 0.8125rem; }

.email-head .sender.unknown-sender { color: var(--attn-strong); }

.dir {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0.08rem 0.4rem;
  white-space: nowrap;
}

.dir.sent { color: var(--primary); background: var(--primary-tint); }

.email-head .when { margin-left: auto; color: var(--faint); font-size: 0.75rem; white-space: nowrap; font-feature-settings: "tnum"; }

.email-head .subject { font-weight: 600; font-size: 0.875rem; margin-top: 0.28rem; letter-spacing: -0.005em; }

.email-head .summary {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 0.18rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.email-flags { display: flex; gap: 0.4rem; margin-top: 0.45rem; flex-wrap: wrap; }

.flag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
}

.flag-important { background: var(--attn-tint); color: var(--attn-strong); }

.flag-ignored { background: var(--surface-2); color: var(--muted); }

.flag-review {
  background: var(--bg);
  color: var(--attn-strong);
  border: 1px dashed color-mix(in oklab, var(--attn) 50%, white);
}

.flag-class { background: var(--surface-2); color: var(--muted); font-weight: 500; }

.flag-notes { background: var(--client-tint); color: var(--client); }

/* expanded body */

.email-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-med) var(--ease-out);
}

.email.open .email-detail { grid-template-rows: 1fr; }

.email-detail > .inner { overflow: hidden; min-height: 0; }

.detail-pad { padding: 0 1rem 1rem; border-top: 1px solid var(--line); }

.addr-block { margin-top: 0.8rem; font-size: 0.78125rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.25rem; }

.addr-block .addr-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.addr-row .lbl { width: 34px; color: var(--faint); flex-shrink: 0; }

.addr-person {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.06rem 0.5rem 0.06rem 0.2rem;
  color: var(--ink);
}

.addr-person .mini-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.mini-dot.aff-team { background: var(--primary); }
.mini-dot.aff-client { background: var(--client); }
.mini-dot.aff-third-party { background: var(--third); }
.mini-dot.aff-unknown { background: transparent; border: 1.2px dashed var(--unknown); }

.email-body {
  margin-top: 0.9rem;
  white-space: pre-wrap;
  font-size: 0.84375rem;
  line-height: 1.65;
  max-width: 72ch;
  color: var(--ink);
}

/* detail sections */

.detail-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-top: 1.1rem;
}

@media (max-width: 760px) { .detail-sections { grid-template-columns: 1fr; } }

.dsection {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  padding: 0.8rem 0.95rem;
  min-width: 0;
}

.dsection.span2 { grid-column: 1 / -1; }

.dsection h3 {
  font-size: 0.71875rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.hdr-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }

.hdr-table td { padding: 0.22rem 0; vertical-align: top; }

.hdr-table td.k { color: var(--muted); white-space: nowrap; padding-right: 0.9rem; font-feature-settings: normal; }

.hdr-table td.v { color: var(--ink); word-break: break-word; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.71875rem; }

.xmeta {
  margin-top: 0.6rem;
  border-top: 1px dashed var(--line-strong);
  padding-top: 0.55rem;
}

.xmeta .xmeta-title { font-size: 0.6875rem; color: var(--muted); font-weight: 600; margin-bottom: 0.4rem; }

.xmeta-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.xmeta-chip {
  display: inline-flex;
  gap: 0.3rem;
  font-size: 0.71875rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.xmeta-chip .xk { color: var(--muted); }

.xmeta-chip .xv { color: var(--primary-strong); font-weight: 600; }

/* llm box */

.llm-line { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-size: 0.75rem; }

.conf-meter {
  position: relative;
  width: 90px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.conf-meter i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 3px;
  background: var(--third);
}

.conf-meter.low i { background: var(--attn); }

.llm-summary { margin-top: 0.55rem; font-size: 0.78125rem; color: var(--ink); }

.review-callout {
  margin-top: 0.6rem;
  border: 1px dashed color-mix(in oklab, var(--attn) 50%, white);
  background: var(--attn-tint);
  border-radius: var(--radius-s);
  padding: 0.55rem 0.7rem;
  font-size: 0.75rem;
  color: var(--attn-strong);
}

.review-callout b { display: block; margin-bottom: 0.15rem; }

/* context notes */

.note-list { display: flex; flex-direction: column; gap: 0.5rem; }

.note {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 0.5rem 0.7rem;
  font-size: 0.78125rem;
}

.note .note-meta { color: var(--faint); font-size: 0.6875rem; margin-top: 0.3rem; display: flex; justify-content: space-between; gap: 0.5rem; }

.note .note-del { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 0.6875rem; padding: 0; }

.note .note-del:hover { color: var(--attn-strong); }

.note-form { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

.note-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 38px;
  font: inherit;
  font-size: 0.78125rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
}

.note-form textarea::placeholder { color: var(--faint); }

.note-form textarea:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

/* actions row */

.email-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  align-items: center;
}

.email-actions .hintlbl { color: var(--faint); font-size: 0.71875rem; margin-left: auto; }

.btn-important.on {
  background: var(--attn-tint);
  border-color: color-mix(in oklab, var(--attn) 40%, white);
  color: var(--attn-strong);
}

/* identify form */

.identify-wrap {
  margin-top: 0.9rem;
  border: 1px dashed color-mix(in oklab, var(--attn) 45%, white);
  border-radius: var(--radius-m);
  background: var(--bg);
  padding: 0.85rem 0.95rem;
}

.identify-wrap h3 { font-size: 0.78125rem; margin-bottom: 0.2rem; }

.identify-wrap .who { color: var(--muted); font-size: 0.75rem; margin-bottom: 0.7rem; }

.identify-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.7rem;
}

@media (max-width: 640px) { .identify-grid { grid-template-columns: 1fr; } }

.identify-grid label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.71875rem; font-weight: 600; color: var(--muted); }

.identify-grid input,
.identify-grid select,
.identify-grid textarea {
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.42rem 0.6rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
}

.identify-grid input::placeholder { color: var(--faint); }

.identify-grid input:focus-visible,
.identify-grid select:focus-visible,
.identify-grid textarea:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

.identify-grid .full { grid-column: 1 / -1; }

.identify-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* ---------------------------------------------------------------- tooltip */

.tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.71875rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-s);
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
}

/* ---------------------------------------------------------------- states */

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

.loading { padding: 3rem; text-align: center; color: var(--faint); }

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-m);
  font-size: 0.8125rem;
  z-index: var(--z-tooltip);
  animation: toast-in var(--t-med) var(--ease-out);
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ------------------------------------------------------------- inbox import */

.stepper {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  list-style: none;
  margin: 0 0 1.4rem;
  padding: 0;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--faint);
  font-size: 0.8125rem;
  font-weight: 500;
}

.step:not(:first-child)::before {
  content: "";
  width: 2rem;
  height: 1px;
  background: var(--line-strong);
  margin-right: 1.1rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 0.6875rem;
  font-weight: 600;
}

.step.current { color: var(--ink); font-weight: 600; }

.step.current .step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.step.done { color: var(--muted); }

.step.done .step-num {
  background: var(--primary-tint);
  border-color: color-mix(in oklab, var(--primary) 40%, white);
  color: var(--primary-strong);
}

.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-l);
  background: var(--surface);
  padding: 2.6rem 1.5rem;
  text-align: center;
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}

.dropzone.over {
  border-color: var(--primary);
  background: var(--primary-tint);
}

.dz-icon { font-size: 1.5625rem; color: var(--faint); }

.dz-title { margin: 0.5rem 0 0.2rem; font-weight: 600; font-size: 0.9375rem; }

.dz-sub { margin: 0 0 1rem; color: var(--muted); font-size: 0.8125rem; }

.dz-browse { position: relative; overflow: hidden; }

.dz-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dz-browse:focus-within {
  outline: 2px solid var(--client);
  outline-offset: 2px;
}

.import-file-list {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
}

.import-file {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.55rem 0.9rem;
  font-size: 0.8125rem;
}

.import-file + .import-file { border-top: 1px solid var(--line); }

.if-name { font-weight: 600; }

.if-meta { color: var(--faint); font-size: 0.75rem; }

.if-error { color: var(--attn-strong); font-size: 0.75rem; }

.inbox-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.inbox-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  margin-bottom: 1rem;
}

.inbox-project-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.inbox-project-label select {
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--bg);
  padding: 0.3rem 0.5rem;
}

.inbox-project-label select:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

.inbox-scan-summary { color: var(--muted); font-size: 0.8125rem; }

.inbox-bulk { display: inline-flex; gap: 0.4rem; margin-left: auto; }

.inbox-msgs {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
}

.inbox-msg {
  display: flex;
  gap: 0.8rem;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid transparent;
}

.inbox-msg + .inbox-msg { border-top: 1px solid var(--line); }

.inbox-msg.flagged { border-left-color: var(--attn); }

.inbox-msg.excluded { opacity: 0.55; }

.inbox-msg.excluded .inbox-msg-main { filter: grayscale(0.6); }

.inbox-check { display: flex; align-items: flex-start; padding-top: 0.15rem; }

.inbox-check input { width: 1rem; height: 1rem; accent-color: var(--primary); cursor: pointer; }

.inbox-check input:focus-visible { outline: 2px solid var(--client); outline-offset: 2px; }

.inbox-msg-main { flex: 1; min-width: 0; }

.inbox-msg-row1 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.inbox-msg-row1 .sender { font-weight: 600; font-size: 0.8125rem; }

.inbox-msg-row1 .when { color: var(--faint); font-size: 0.75rem; }

.inbox-msg-subject { font-weight: 600; margin-top: 0.15rem; }

.inbox-msg-meta { color: var(--faint); font-size: 0.75rem; margin-top: 0.1rem; }

.pii-flags {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.pii-hit {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pii-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 0.1rem 0.45rem;
  background: var(--attn-tint);
  color: var(--attn-strong);
  white-space: nowrap;
}

.pii-snippet {
  color: var(--muted);
  font-size: 0.75rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.pii-mark {
  background: var(--attn-tint);
  color: var(--attn-strong);
  text-decoration: underline;
  padding: 0 0.1rem;
  border-radius: 2px;
}

/* Low-severity findings: shown, but visually quiet — they do not withhold the
   message, so they must not read like a warning. */
.pii-flag.pii-low {
  background: var(--surface-2);
  color: var(--muted);
}

.pii-mark.pii-mark-low {
  background: var(--surface-2);
  color: var(--muted);
  text-decoration: none;
}

.inbox-body-preview {
  margin: 0.5rem 0 0;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  font-size: 0.78125rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 16rem;
  overflow-y: auto;
}

.import-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  padding: 1.2rem 1.4rem;
  max-width: 44rem;
}

.summary-title { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.8rem; }

.summary-facts { display: grid; gap: 0.35rem; }

.sf-row { display: flex; gap: 1rem; font-size: 0.8125rem; }

.sf-k { color: var(--muted); width: 9.5rem; flex-shrink: 0; }

.sf-v { font-weight: 600; }

.summary-warning {
  margin: 0.9rem 0 0;
  color: var(--attn-strong);
  background: var(--attn-tint);
  border-radius: var(--radius-s);
  padding: 0.5rem 0.7rem;
  font-size: 0.8125rem;
}

.summary-note { margin: 0.9rem 0 0; color: var(--faint); font-size: 0.75rem; }

.summary-line { margin: 0; font-size: 0.8125rem; color: var(--muted); }

.flag-imported {
  background: var(--bg);
  color: var(--muted);
  border: 1px dashed var(--line-strong);
}

/* ---- import source tabs + gmail panel */

.source-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.source-tab {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.8rem;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}

.source-tab:hover:not(:disabled) { color: var(--ink); }

.source-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.source-tab:disabled { opacity: 0.45; cursor: default; }

.source-tab:focus-visible { outline: 2px solid var(--client); outline-offset: -2px; }

.gmail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  padding: 1.1rem 1.2rem;
}

.gmail-controls {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.gmail-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.gmail-field select,
.gmail-field input {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--bg);
  padding: 0.32rem 0.5rem;
}

.gmail-field input[type="number"] { width: 4.5rem; font-feature-settings: "tnum"; }

.gmail-field select:focus-visible,
.gmail-field input:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

.gmail-note {
  margin: 0.8rem 0 0;
  color: var(--faint);
  font-size: 0.75rem;
}

.gmail-note code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--surface-2);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
}

.gmail-result {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--muted);
}

.gmail-capped, .gmail-error-count { color: var(--attn-strong); }

.gmail-tally { margin-top: 0.35rem; font-size: 0.75rem; color: var(--faint); }

.gmail-error {
  margin: 0.8rem 0 0;
  color: var(--attn-strong);
  background: var(--attn-tint);
  border-radius: var(--radius-s);
  padding: 0.5rem 0.7rem;
  font-size: 0.8125rem;
}

.inbox-msg-route {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.route-select {
  font: inherit;
  font-size: 0.75rem;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--bg);
  padding: 0.15rem 0.35rem;
}

.route-select:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

.route-why { font-size: 0.6875rem; color: var(--faint); }

.route-why.route-none { color: var(--attn-strong); }

.summary-split {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.split-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.split-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.8125rem;
  padding: 0.18rem 0;
}

.split-name { min-width: 10rem; }

.split-count { font-weight: 600; font-feature-settings: "tnum"; }

.split-row.split-held .split-name,
.split-row.split-held .split-count { color: var(--attn-strong); }

.split-note { font-size: 0.6875rem; color: var(--faint); }

.email-move {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

.move-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.move-label select {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--bg);
  padding: 0.25rem 0.45rem;
}

.move-label select:focus-visible { outline: 2px solid var(--client); outline-offset: 1px; }

.src-chip {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  white-space: nowrap;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 720px) {
  .project-row { grid-template-columns: 1fr auto; row-gap: 0.5rem; }
  .project-row .mini-activity { display: none; }
  .project-meta { justify-content: flex-start; flex-wrap: wrap; gap: 0.8rem; }
  .topbar-hint { display: none; }
  .email-head .when { margin-left: 0; width: 100%; }
  .step:not(:first-child)::before { width: 0.8rem; margin-right: 0.5rem; }
  .inbox-bulk { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
