:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1c2430;
  --ink-soft: #5b6675;
  --line: #e3e7ec;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.06), 0 1px 8px rgba(20, 30, 45, 0.04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

/* Header -- sticky so the nav stays pinned to the top as the page scrolls.
   Sticky (not fixed) keeps it in normal flow; --surface is opaque so scrolled
   content doesn't bleed through; z-index sits above page content. */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(20, 30, 45, 0.05);
}
.site-header__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.session { display: flex; align-items: center; gap: 14px; }
.session__user { color: var(--ink-soft); font-size: 14px; }
.logout { margin: 0; }
.logout__btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.logout__btn:hover { border-color: var(--ink-soft); color: var(--ink); }

/* Layout */
.content { max-width: 960px; margin: 0 auto; padding: 28px 20px 64px; }
.page-title { font-size: 24px; margin: 4px 0 18px; }
.section-title { font-size: 17px; margin: 28px 0 12px; }
.crumb { margin: 0 0 12px; font-size: 14px; }
.muted { color: var(--ink-soft); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card--narrow { max-width: 380px; margin: 48px auto; }
.card__title { font-size: 18px; margin: 0 0 12px; }

/* Matter list */
.matter-list { display: flex; flex-direction: column; gap: 16px; }
.matter-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.matter-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.matter-card__title { font-size: 17px; margin: 0; }
.matter-card__meta { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.matter-meta { color: var(--ink-soft); margin: 0 0 22px; }

/* Tables */
.wf-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wf-table th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.wf-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.wf-table tr:last-child td { border-bottom: none; }

/* Instance header + facts */
.instance-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
/* Status badge stacked over the card's control button group, top-right. */
.instance-head__aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.facts { display: flex; flex-wrap: wrap; gap: 28px; margin: 16px 0 14px; }
.facts dt { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.facts dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; }

/* Progress */
.progress {
  position: relative;
  height: 8px;
  width: 120px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.progress--lg { width: 100%; height: 10px; }
.progress__bar { height: 100%; background: var(--accent); border-radius: 999px; }
.progress__label { font-size: 12px; color: var(--ink-soft); margin-left: 8px; }

/* Phases + tasks */
.phase { margin-bottom: 18px; }
.phase__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
/* Per-phase completed/total count (e.g. "1/4"). */
.phase__count { font-size: 12px; font-weight: 600; letter-spacing: 0; }
/* A phase with any non-terminal task is in progress: accent its count. */
.phase--active .phase__count { color: var(--accent); }

/* Completed-instance treatment: green bar + a done check on "Current phase". */
.card--completed .progress__bar { background: #2e7d4f; }
.done-check {
  display: inline-block;
  color: #2e7d4f;
  font-weight: 700;
  margin-right: 2px;
}
.task-list { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.task:last-child { border-bottom: none; }
.task__title { font-size: 14px; margin-right: auto; }
/* Runner action (Start/Complete) sits at the right end of the task row. */
.task__action { margin: 0; flex: none; }
/* Skipped tasks (routed around by a decision gate) render muted. */
.task--skipped { opacity: 0.5; }
.task--skipped .task__title { text-decoration: line-through; }

/* Decision-gate prompt: the thing blocking progress, shown prominently. */
.decisions {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border: 1px solid #d9b8a0;
  border-left: 3px solid #b5651a;
  border-radius: 6px;
  background: #fdf6ef;
}
.decisions__title {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8b4a10;
}
.decision { margin-bottom: 10px; }
.decision:last-child { margin-bottom: 0; }
.decision__q { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.decision__choices { display: flex; flex-wrap: wrap; gap: 8px; }
.decision__choice { margin: 0; }

/* Badges */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge--active, .badge--in_progress { background: #e1edff; color: #1f4e79; }
.badge--completed { background: #e3f4ea; color: #1f7a45; }
.badge--ready, .badge--in_review { background: #fff2d9; color: #8a5a00; }
.badge--blocked, .badge--errored, .badge--cancelled { background: #fde5e5; color: #9b2226; }
.badge--paused, .badge--skipped, .badge--initializing, .badge--pending { background: #eef1f5; color: var(--ink-soft); }
.badge--blocking { background: #fff2d9; color: #8a5a00; }
.badge--decision { background: #e1edff; color: #1f4e79; }

/* Workflow view (cross-matter, per-process) */
.wfv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.wfv-dist { display: flex; gap: 8px; flex-wrap: wrap; }
.wfv-chip { background: #eef1f5; color: var(--ink-soft); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.wfv-chip strong { color: var(--ink); }
.wfv-chip--decision { background: #e1edff; color: #1f4e79; }
.wfv-chip--decision strong { color: #1f4e79; }
.wfv-chip--date { background: #f4c95d; color: #6b3f05; }
.wfv-chip--date strong { color: #6b3f05; }
.wfv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wfv-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-soft); padding: 6px 10px; border-bottom: 1px solid var(--line); }
.wfv-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.wfv-table tr:last-child td { border-bottom: none; }
.wfv-num { display: block; font-size: 12px; }
.wfv-progress { min-width: 140px; }
.wfv-progress .progress { display: inline-block; width: 90px; vertical-align: middle; margin-right: 8px; }

/* Forms */
.form__row { margin-bottom: 14px; }
.form__label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.form input[type="text"],
.form input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
}
.form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.12); }

.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn--primary:hover { background: #1a4368; }
/* Muted brick -- desaturated from the old strong red so it reads as destructive
   without shouting. */
.btn--danger { background: #b1564f; color: #fff; width: 100%; }
.btn--danger:hover { background: #9a4a44; }
/* Softer ghost destructive: red text on a light red border, for low-emphasis
   spots (e.g. the workflow card's Remove trigger). */
.btn--danger-soft { background: var(--surface); color: #a23b36; border: 1px solid #e6b9b6; width: auto; }
.btn--danger-soft:hover { background: #fbeeed; border-color: #d99a96; }
.btn--secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); width: auto; }
.btn--secondary:hover { background: #eef1f5; }
/* Compact variant for in-card button groups. font-size matches the status badge
   (12px) so the controls don't read larger than it. */
.btn--sm { width: auto; padding: 6px 12px; font-size: 12px; }

/* Workflow card control group: the two buttons stack vertically along the card's
   right margin, under the status badge, right-aligned. A transparent 1px border
   on every button keeps bordered and borderless variants the same width. */
.btn-group { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.btn-group .btn { width: auto; box-sizing: border-box; border: 1px solid transparent; }
.btn-group .btn--secondary { border-color: var(--line); }
.btn-group .btn--danger-soft { border-color: #e6b9b6; }

.alert { padding: 10px 12px; border-radius: 6px; font-size: 14px; margin-bottom: 14px; }
.alert--error { background: #fde5e5; color: #9b2226; }

/* Header nav */
.nav { display: flex; gap: 18px; margin-left: 24px; margin-right: auto; }
.nav a { color: var(--ink-soft); font-size: 14px; }
.nav a:hover { color: var(--ink); text-decoration: none; }
/* Firm-settings item, visually set apart from the primary sections. */
.nav__settings { padding-left: 18px; border-left: 1px solid var(--line); }

/* Page head with action button */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn--inline { width: auto; display: inline-block; }

/* Flash messages */
.messages { list-style: none; margin: 0 0 18px; padding: 0; }
.messages .alert { margin-bottom: 8px; }
.alert--success { background: #e3f4ea; color: #1f7a45; }

/* Executor-type badges (label only; no AI runs) */
.exec-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 4px;
  background: #eef1f5;
  color: var(--ink-soft);
  white-space: nowrap;
}
.exec-badge--manual { background: #eef1f5; color: #5b6675; }
.exec-badge--ai_assisted { background: #e1edff; color: #1f4e79; }
.exec-badge--ai_automated { background: #e6e1ff; color: #4733a3; }
.exec-badge--approval { background: #fff2d9; color: #8a5a00; }
.exec-badge--review { background: #fde9d2; color: #9a5414; }
.exec-badge--client_action { background: #e3f4ea; color: #1f7a45; }
.exec-badge--system { background: #e7eaee; color: #444c57; }
.exec-badge--unknown { background: #eef1f5; color: #5b6675; }

.task__tags { display: inline-flex; align-items: center; gap: 8px; }

/* Workflow authoring editor */
.editor__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.editor__pane { display: flex; flex-direction: column; min-width: 0; }
.editor__src {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: 13px/1.5 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  background: var(--surface);
  color: var(--ink);
}
.editor__src:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.12); }
.editor__preview {
  min-height: 420px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
}
.editor__preview svg { max-width: 100%; height: auto; }
.editor__actions { margin-top: 16px; }

@media (max-width: 760px) {
  .editor__grid { grid-template-columns: 1fr; }
  .nav { margin-left: 14px; }
}

/* Intake forms */
.form--narrow { max-width: 480px; }
.form input[type="email"],
.form input[type="tel"],
.form input[type="text"],
.form input[type="number"],
.form select,
.form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
  background: var(--surface);
  color: var(--ink);
}
.form select:focus,
.form input[type="email"]:focus,
.form input[type="tel"]:focus,
.form input[type="text"]:focus,
.form input[type="number"]:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.12);
}
/* Checkboxes stay intrinsic width, not stretched like text inputs. */
.form input[type="checkbox"] { width: auto; }
.form :disabled { background: #f3f5f7; color: var(--ink-soft); cursor: not-allowed; }
.form__help { margin: 4px 0 0; font-size: 12px; color: var(--ink-soft); }
.form__error { margin: 4px 0 0; font-size: 13px; color: #9b2226; }

/* Grouped field panels (task-definition detail editor) */
.fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px 14px;
  margin: 0 0 16px;
}
.fieldset__legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  padding: 0 6px;
}

/* Dashboard: compact facts + workflow summary */
.facts--compact { gap: 32px; margin: 4px 0 12px; }
.facts--compact dd { font-size: 14px; font-weight: 500; }
.wf-summary { list-style: none; margin: 0; padding: 0; }
.wf-summary__item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.wf-summary__name { font-weight: 600; }

/* Role-based dashboards (attorney overview + paralegal task feed) */
.stat-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 0 20px; }
.stat {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface, #fff);
}
.stat__n { font-size: 24px; font-weight: 700; line-height: 1; }
.stat__l { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }

.attention { border-left: 3px solid #b5651a; }
.attention-list { list-style: none; margin: 0; padding: 0; }
.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.attention-item:first-child { border-top: none; }
.attention-item__body { display: flex; flex-direction: column; gap: 2px; }
.attention-item__q { font-weight: 600; }

.dash-note { margin: -4px 0 18px; font-size: 13px; }
.count-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 4px;
}
.task-feed { list-style: none; margin: 0; padding: 0; }
.task-feed__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.task-feed__item:first-child { border-top: none; }
.task-feed__title { font-weight: 600; }
.task-feed__meta { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Task detail / work surface */
.task-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.task-actions { margin-bottom: 14px; }
.completion-label {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
}
.action-form { max-width: 420px; }
.action-note { width: 100%; resize: vertical; margin-bottom: 8px; }
.action-row { display: flex; gap: 8px; }
.deferred-completion {
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: #fafafa;
}
.deferred-completion .action-form { margin-top: 8px; }

/* Matter lifecycle status (§5.4) */
.status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.status-transition { margin: 0; }
.status-transition--reason { display: inline-flex; gap: 6px; align-items: center; }
.status-reason { width: 200px; }
.status-log { list-style: none; margin: 8px 0 0; padding: 0; }
.status-log__item {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.status-log__item:first-child { border-top: none; }

/* Deadlines (Tier 2 Deadline §3.1, v0.5 subset) -- display-only */
.deadline-disclaimer {
  font-size: 12px;
  margin: -4px 0 12px;
  padding: 6px 10px;
  border-left: 3px solid #b5851a;
  background: #fdfaf0;
  border-radius: 4px;
}
.deadline-list { list-style: none; margin: 0 0 12px; padding: 0; }
.deadline {
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 6px;
}
.deadline--overdue { border-left-color: #b3261e; background: #fdf3f2; }
.deadline--today { border-left-color: #b5651a; background: #fdf9f0; }
.deadline--soon { border-left-color: #c79a1e; }
.deadline--settled { opacity: 0.6; }
/* jurisdictional_bar surfaced prominently regardless of proximity */
.deadline--jbar { border-left-width: 5px; border-left-color: #8b1a1a; box-shadow: inset 3px 0 0 #8b1a1a33; }
.deadline__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.deadline__title { font-weight: 600; }
.deadline__tags { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.deadline__meta { display: flex; gap: 10px; align-items: baseline; margin-top: 2px; font-size: 13px; }
.deadline__date { color: var(--ink-soft); }
.deadline__prox { font-weight: 600; }
.prox--overdue { color: #b3261e; }
.prox--today { color: #b5651a; }
.prox--soon { color: #a07c2c; }
.prox--later { color: var(--ink-soft); font-weight: 500; }
.deadline__source, .deadline__desc { margin: 4px 0 0; font-size: 13px; }
.deadline__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.deadline__actions form { margin: 0; }

/* Attorney confirmation -- the liability firewall */
.badge--confirmed { background: #d6ead9; color: #1f5130; }
.badge--unverified { background: #f6e3c4; color: #7a4f12; }
/* Date-pending deadline -- the more urgent warning nag. */
.badge--datewarn { background: #f4c95d; color: #6b3f05; font-weight: 700; }
/* Unconfirmed active dates flagged prominently -- the forcing function */
.deadline--unverified { border-left-color: #b5851a; background: #fdf9ef; }
.deadline--unverified.deadline--jbar { border-left-color: #8b1a1a; background: #fbf2f0; }
.deadline__confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px dashed #d0a94a;
  border-radius: 6px;
  background: #fffaf0;
}
.deadline__needsverify { font-size: 13px; font-weight: 600; color: #7a4f12; }
.confirm-note { flex: 1 1 200px; min-width: 160px; }
.deadline__confirmed { margin: 8px 0 0; font-size: 13px; color: #1f5130; }

/* Workflow-raised deadlines */
.badge--wf { background: #e6edf6; color: #2c4a70; }
.deadline--unset { border-left-color: #8a6d3b; background: #fcf8ee; }
.prox--unset { color: #8a6d3b; font-weight: 600; }
.deadline-decl { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

/* Deadline nag on the task work surface */
.card--nag { border-left: 4px solid #b5851a; background: #fdf9ef; }

/* Run-playbook deadline date-collection step */
.deadline-collect { list-style: none; margin: 4px 0 16px; padding: 0; }
.deadline-collect__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.deadline-collect__item:first-child { border-top: none; }
.deadline-collect__info { display: flex; flex-direction: column; gap: 2px; }
.deadline-collect__title { font-weight: 600; }
.deadline-collect__meta { font-size: 13px; }
.deadline-collect__date { flex: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
/* Criticality badge colors */
.crit--critical { background: #f6d9d6; color: #7a1c14; }
.crit--jurisdictional_bar { background: #8b1a1a; color: #fff; }
.crit--important { background: #f6ecd2; color: #7a5a12; }

.add-deadline > summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
/* Reasonable input widths -- not full-viewport. */
.add-deadline .form { max-width: 560px; }
.form__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 520px) { .form__grid { grid-template-columns: 1fr; } }
.subhead {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  margin: 16px 0 6px;
}
/* Task guidance -- authored instructions shown to the worker before starting.
   Soft info panel (helpful, not a warning). */
.task-guidance {
  background: #eef4fb;
  border: 1px solid #cfe0f2;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 18px;
}
.task-guidance__title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin: 0 0 6px;
}
.task-guidance__body { margin: 0; font-size: 14px; }
.ai-decl { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.badge--internal { background: #eee; color: #555; }

.note-form { margin: 6px 0 14px; }
.note-form__content { width: 100%; resize: vertical; }
.note-form__row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.note-list { list-style: none; margin: 0; padding: 0; }
.note {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.note--pinned { background: #fdfbf3; }
.note__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; font-size: 13px; }
.note__body { font-size: 14px; white-space: normal; }

/* Parties */
.party-list { list-style: none; margin: 0 0 8px; padding: 0; }
.party {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.party:last-child { border-bottom: none; }
.party__name { font-weight: 600; }
.party__meta { font-size: 13px; }
.party__remove { margin-left: auto; }  /* push the remove action to the right */

/* Optional party section on the matter-create form. */
.form__section { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; margin: 4px 0 16px; }
.form__legend { font-weight: 600; padding: 0 6px; }

/* Collapsible disclosures (add-party form, run-playbook form) */
.add-party > summary,
.run-playbook > summary {
  cursor: pointer;
  list-style: none;            /* drop default triangle (Firefox) */
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
}
.add-party > summary::-webkit-details-marker,
.run-playbook > summary::-webkit-details-marker { display: none; }  /* Chrome/Safari */
.add-party > summary::before,
.run-playbook > summary::before {
  content: "▸";
  font-size: 11px;
  color: var(--ink-soft);
}
.add-party[open] > summary::before,
.run-playbook[open] > summary::before { content: "▾"; }
.add-party > summary:hover,
.run-playbook > summary:hover { text-decoration: underline; }

.add-party {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.add-party .form { margin-top: 14px; max-width: 480px; }

/* Run-a-playbook disclosure sits between the Workflow heading and the cards. */
.run-playbook { margin: 0 0 18px; }
.run-playbook .form { margin-top: 14px; max-width: 480px; }

/* Remove (playbook detail / instances table) confirm disclosure. The summary is
   a subdued danger link; expanding reveals the warning + the POST confirm button.
   There is no GET delete -- the only delete path is this form's submit. */
.remove-wf { margin-top: 16px; }
.remove-wf > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #9b2226;
  user-select: none;
}
.remove-wf > summary::-webkit-details-marker { display: none; }
.remove-wf > summary::before { content: "▸"; font-size: 11px; color: #9b2226; }
.remove-wf[open] > summary::before { content: "▾"; }
.remove-wf > summary:hover { text-decoration: underline; }
.remove-wf__confirm {
  margin-top: 10px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.remove-wf__confirm .btn { align-self: flex-start; }
/* Inline (in a table row): tighter, narrower confirm. */
.remove-wf--inline { margin-top: 0; }
.remove-wf--inline .remove-wf__confirm { max-width: 320px; }
.wf-table__action { text-align: right; white-space: nowrap; }

/* Workflow card "Remove" -- a danger button in the header group whose confirm
   step pops below it (absolute, so opening it doesn't grow the button row). Still
   POST + confirm: the submit inside is the only delete path. */
.wf-remove { position: relative; }
.wf-remove > summary { list-style: none; cursor: pointer; }
.wf-remove > summary::-webkit-details-marker { display: none; }
.wf-remove__pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: 260px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.wf-remove__confirm { display: flex; flex-direction: column; gap: 10px; }
.wf-remove__confirm .btn { align-self: flex-start; }

/* Tasks-by-phase panel: lives in the card body, toggled by the header button. */
.tasks-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.tasks-panel__body .phase:last-child { margin-bottom: 0; }

/* Add-party autocomplete */
.ac { position: relative; }
.ac__results {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}
.ac__item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 9px;
  border-radius: 5px;
  cursor: pointer;
}
.ac__item:hover,
.ac__item:focus { background: #eef1f5; outline: none; }
.ac__name { font-weight: 600; font-size: 14px; }
.ac__meta { font-size: 12px; }

.ac__selected {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #e1edff;
  border: 1px solid #c4dafa;
  border-radius: 6px;
  font-size: 14px;
}
.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link--danger { color: #b91c1c; }

/* Planned-feature stubs (reusable _planned_feature.html) + roadmap page.
   Muted, dashed, no shadow -- deliberately quieter than functional cards, so
   they read as "coming later", matching the console/deadline "coming soon" tone. */
.planned {
  border: 1px dashed var(--line);
  background: #fafbfc;
  box-shadow: none;
}
.planned__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.planned__head .card__title { margin: 0; color: var(--ink-soft); }
.planned__desc { margin: 0; color: var(--ink-soft); }
.planned__reason { margin: 6px 0 0; font-size: 13px; }
.badge--planned {
  background: #eceff3;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11px;
}

/* Roadmap page */
.roadmap-intro { max-width: 640px; margin: 0 0 8px; }
.roadmap-group { margin-bottom: 20px; }
.roadmap-group__note { margin: -6px 0 10px; font-size: 13px; }
.roadmap-list { list-style: none; margin: 0; padding: 0; }
.roadmap-item {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.roadmap-item:first-child { border-top: none; }
.roadmap-item__name { display: block; font-weight: 600; }
.roadmap-item__desc { display: block; color: var(--ink-soft); font-size: 14px; }

/* Shipped / in-progress markers. Only fully-done items get the struck name +
   green "Shipped" badge; partials keep their name and get an amber "In progress"
   badge plus an honest note about exactly which slice shipped. */
.roadmap-item--done .roadmap-item__name s { color: var(--ink-soft); }
.roadmap-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
}
.roadmap-badge--shipped { background: #e3f4ea; color: #1f7a45; }
.roadmap-date { font-size: 12px; color: var(--ink-soft); margin-left: 6px; vertical-align: middle; }
/* Coarse effort estimate -- subtle, it's only an estimate */
.roadmap-effort { font-size: 11px; color: var(--ink-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 7px; margin-left: 6px; vertical-align: middle; }
.roadmap-badge--progress { background: #fff2d9; color: #8a5a00; }
.roadmap-note { display: block; margin-top: 4px; font-size: 13px; font-style: italic; color: var(--ink); }

/* Footer roadmap link */
.site-footer { border-top: 1px solid var(--line); margin-top: 8px; }
.site-footer__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 20px 32px;
}
.site-footer__link { color: var(--ink-soft); font-size: 13px; }

/* ---- Playbook Design (read-only visual view) ---- */
.pd-head { margin-bottom: 12px; }
.pd-canvas {
  position: relative;
  height: 72vh;
  min-height: 440px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pd-svg { width: 100%; height: 100%; display: block; cursor: grab; }
.pd-svg--grabbing { cursor: grabbing; }

.pd-toolbar {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  display: flex; gap: 6px;
}
.pd-btn {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  border-radius: 7px; min-width: 32px; height: 32px; padding: 0 8px;
  font-size: 16px; line-height: 1; cursor: pointer; box-shadow: var(--shadow);
}
.pd-btn--wide { font-size: 13px; font-weight: 600; }
.pd-btn:hover { background: #f0f1f3; border-color: var(--ink-soft); }

.pd-legend {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  display: flex; gap: 6px; flex-wrap: wrap; max-width: 60%;
}
.pd-legend__chip {
  font-size: 11px; padding: 1px 9px; border-radius: 999px;
  border: 1.5px solid var(--line); color: #1a1a1a; text-transform: capitalize;
}
.pd-hint {
  position: absolute; bottom: 8px; left: 12px; z-index: 3;
  font-size: 12px; margin: 0; pointer-events: none;
}

/* SVG node/edge styling (attributes set inline drive fill/stroke; these are the
   text + edge defaults). */
.pd-label { font: 11px/1.3 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  fill: #1a1a1a; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.pd-edge { stroke: #7a8699; stroke-width: 1.6; fill: none; }
.pd-edge--adv { stroke: #8b2c2c; stroke-width: 1.6; stroke-dasharray: 5 4; opacity: 0.85; }
.pd-elabel { font: 10px -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  fill: #3a4657; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.pd-elabel-bg { fill: #fbfcfd; opacity: 0.92; }
.pd-shape { transition: filter .12s ease; }
.pd-node:hover .pd-shape { filter: brightness(0.97); }

/* ---- Party contact satellites: addresses + contact methods (§4.3.3/§4.3.4) ---- */
/* Real section header (unlike .planned__head, keeps the title full-strength). */
.contact-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.contact-head .card__title { margin: 0; }

.contact-group__title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-soft); margin: 14px 0 6px;
}
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 10px 0; border-top: 1px solid var(--line);
}
.contact-item:first-child { border-top: none; }
.contact-item--inactive { opacity: 0.6; }
.contact-item__main { min-width: 0; }
.contact-item__badges { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.contact-item__label { display: block; font-size: 13px; color: var(--ink-soft); }
.contact-item__value { font-size: 14px; line-height: 1.45; word-break: break-word; }
.contact-item__eff { margin: 4px 0 0; font-size: 12px; }
.contact-item__actions {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  flex-shrink: 0; justify-content: flex-end;
}
.contact-item__actions form { margin: 0; }

/* Inline POST form (e.g. Deactivate action in a table action cell) */
.inline-form { display: inline; }

/* Required-field asterisk on the custom-field values form */
.req { color: #a23b36; }

/* Grouped-form subheading (e.g. person vs organization on the party form) */
.form__group-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--ink-soft); margin: 18px 0 8px; }

/* Inline "add from a select" row (e.g. declare a field set on a playbook) */
.form--inline-add { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.form__select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--ink); }

/* A cluster of buttons on the right of a page-head */
.page-head__actions { display: inline-flex; gap: 8px; align-items: center; }

/* Matter detail: edit action + description block */
.matter-actions { margin: -4px 0 16px; }
.matter-description { margin: 0; line-height: 1.5; white-space: normal; }

/* Subtle bordered button + a compact size, for the per-row row actions. */
.btn--ghost {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); width: auto;
}
.btn--ghost:hover { background: #eef1f5; }
.btn--tiny { width: auto; padding: 4px 10px; font-size: 12px; }
