:root {
  --sanha-fg: #1f2933;
  --sanha-bg: #f8f9fb;
  --sanha-accent: #1d4ed8;

  /* Slide-deck palette tokens — referenced by the "stitch" theme (see the
     theme block at the end of this file). Defined here so DESIGN.md and any
     future theme can reuse them. They do not affect the default look. */
  --sanha-navy: #0f1e3d;
  --sanha-teal: #0fb5a6;
  --sanha-teal-dark: #0a8a80;
  --sanha-ink: #1a2238;
  --sanha-panel: #f2f5fa;
  --sanha-hairline: #dce3ef;
  --sanha-gold: #9a6b00;
  --sanha-terracotta: #b4533a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
  color: var(--sanha-fg);
  background: var(--sanha-bg);
}

.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.shell-title {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  color: var(--sanha-accent);
}

.shell-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.shell-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.shell-logout {
  border: 1px solid var(--sanha-accent);
  background: transparent;
  color: var(--sanha-accent);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

.shell-nav {
  display: flex;
  gap: 1rem;
  margin: 0 0 1.5rem;
  border-bottom: 1px solid #d9e2ec;
  padding-bottom: 0.5rem;
}

.shell-nav-link {
  color: var(--sanha-accent);
  text-decoration: none;
}

.shell-nav-link:hover {
  text-decoration: underline;
}

.lg-form {
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lg-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.lg-input {
  padding: 0.4rem 0.6rem;
  border: 1px solid #cbd2d9;
  border-radius: 4px;
  font: inherit;
}

.lg-error {
  margin: 0;
  color: #b91c1c;
}

.lg-submit {
  border: none;
  background: var(--sanha-accent);
  color: #fff;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font: inherit;
  cursor: pointer;
}

.shell-locale {
  border: 1px solid #cbd2d9;
  background: transparent;
  color: var(--sanha-fg);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

/* Demo-login quick-fill panel (login page, test convenience) */
.lg-demo {
  max-width: 30rem;
  margin-top: 1.5rem;
}

.lg-demo-title {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: #64748b;
}

.lg-demo-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.lg-demo-btn {
  text-align: left;
  border: 1px solid #cbd2d9;
  background: transparent;
  color: var(--sanha-fg);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  cursor: pointer;
}

.lg-demo-btn:hover {
  background: #eef2f8;
  border-color: var(--sanha-accent);
}

.shell-theme {
  border: 1px solid #cbd2d9;
  background: transparent;
  color: var(--sanha-fg);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

.shell-db {
  border: 1px solid #cbd2d9;
  background: transparent;
  color: var(--sanha-fg);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  text-decoration: none;
  cursor: pointer;
}

.shell-db:hover {
  background: #eef2f8;
}

.eb-host {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.eb-banner {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: #991b1b;
  padding: 0.5rem 1rem;
}

.eb-message {
  flex: 1;
}

.eb-details summary {
  cursor: pointer;
}

.eb-detail-body {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.eb-dismiss {
  border: 1px solid #fca5a5;
  background: transparent;
  color: #991b1b;
  border-radius: 4px;
  padding: 0.1rem 0.6rem;
  cursor: pointer;
}

/* Run list (story 2.4, #/runs) */

.rl-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1rem;
}

.rl-filter {
  margin-left: 0.5rem;
  padding: 0.25rem 0.5rem;
  font: inherit;
}

.rl-refresh {
  border: 1px solid var(--sanha-accent);
  background: transparent;
  color: var(--sanha-accent);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

.rl-table {
  width: 100%;
  border-collapse: collapse;
}

.rl-table th,
.rl-table td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #d9e2ec;
}

.rl-run-link {
  color: var(--sanha-accent);
  font-family: ui-monospace, monospace;
  text-decoration: none;
}

.rl-run-link:hover {
  text-decoration: underline;
}

.rl-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
  background: #e2e8f0;
  color: #334155;
}

.rl-badge-running {
  background: #dbeafe;
  color: #1d4ed8;
}

.rl-badge-waiting {
  background: #fef3c7;
  color: #92400e;
}

.rl-badge-completed {
  background: #dcfce7;
  color: #166534;
}

.rl-badge-error {
  background: #fee2e2;
  color: #b91c1c;
}

.rl-badge-cancelled {
  background: #e2e8f0;
  color: #475569;
}

.rl-role-badge {
  display: inline-block;
  margin-left: 0.5rem;
  border: 1px solid #92400e;
  border-radius: 4px;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  color: #92400e;
  background: #fffbeb;
}

.rl-attention {
  border: 1px solid #fca5a5;
  border-radius: 6px;
  background: #fef2f2;
  padding: 0.5rem 1rem;
  margin: 0 0 1rem;
}

.rl-attention-title {
  margin: 0 0 0.5rem;
  color: #991b1b;
  font-size: 1rem;
}

.rl-attention-list {
  margin: 0;
  padding-left: 1.25rem;
}

.rl-attention-item {
  margin: 0.2rem 0;
}

.rl-attention-reason {
  margin-left: 0.5rem;
  color: #991b1b;
  font-size: 0.85rem;
}

.rl-empty {
  color: #64748b;
}

/* Run detail + timeline (story 2.4, #/runs/:id) */

.rd-back {
  color: var(--sanha-accent);
  text-decoration: none;
}

.rd-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.rd-timeline {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  border-left: 2px solid #d9e2ec;
}

.rd-entry {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.35rem 0 0.35rem 1rem;
}

.rd-entry-waiting {
  background: #fffbeb;
  border-left: 2px solid #f59e0b;
  margin-left: -2px;
}

.rd-entry-at {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: #64748b;
}

.rd-entry-type {
  font-weight: 600;
}

.rd-entry-step {
  color: #334155;
}

.rd-entry-actor {
  color: var(--sanha-accent);
}

.rd-entry-reason {
  color: #991b1b;
  font-size: 0.85rem;
}

/* Task queue (story 2.5, #/tasks) */

.tq-act {
  border: 1px solid var(--sanha-accent);
  background: transparent;
  color: var(--sanha-accent);
  border-radius: 4px;
  padding: 0.2rem 0.7rem;
  cursor: pointer;
}

.tq-panel-row td {
  background: #f1f5f9;
}

.tq-panel {
  padding: 0.5rem 0.25rem;
}

/* Read-only "what you're reviewing" block above a review form's decision. */
.tq-context {
  max-width: 560px;
  margin-bottom: 0.9rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--sanha-accent);
  border-radius: 8px;
  background: #f8fafc;
}

.tq-context-title {
  font-weight: 600;
  color: var(--sanha-fg);
  margin-bottom: 0.4rem;
}

.tq-context-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 0.9rem;
  margin: 0;
}

.tq-context-key {
  color: #64748b;
}

.tq-context-val {
  margin: 0;
  color: var(--sanha-fg);
  word-break: break-word;
}

.tq-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 420px;
}

.tq-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tq-field-label {
  font-size: 0.85rem;
  color: #334155;
}

.tq-input {
  padding: 0.35rem 0.55rem;
  border: 1px solid #cbd2d9;
  border-radius: 4px;
  font: inherit;
}

.tq-submit {
  align-self: flex-start;
  border: none;
  background: var(--sanha-accent);
  color: #fff;
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font: inherit;
  cursor: pointer;
}

.tq-toast {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin: 0 0 0.75rem;
}

.tq-info {
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  color: #075985;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin: 0 0 0.75rem;
}

.tq-empty {
  color: #64748b;
}

/* Notifications menu (story 2.5, header) */

.nm-host {
  position: relative;
}

.nm-button {
  border: 1px solid #cbd2d9;
  background: transparent;
  color: var(--sanha-fg);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

.nm-badge {
  display: inline-block;
  margin-left: 0.4rem;
  background: #dc2626;
  color: #fff;
  border-radius: 999px;
  padding: 0 0.45rem;
  font-size: 0.75rem;
}

.nm-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  z-index: 20;
  min-width: 320px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d9e2ec;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(31, 41, 51, 0.15);
  padding: 0.5rem;
}

.nm-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nm-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid #eef2f6;
}

.nm-item-read {
  opacity: 0.55;
}

.nm-item-title {
  font-weight: 600;
  color: var(--sanha-fg);
  text-decoration: none;
}

a.nm-item-title {
  color: var(--sanha-accent);
}

.nm-item-body {
  font-size: 0.8rem;
  color: #64748b;
  word-break: break-all;
}

.nm-read {
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--sanha-accent);
  padding: 0;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

.nm-empty {
  margin: 0.25rem;
  color: #64748b;
}

/* SLA escalation (story 2.6) */

.tq-overdue td {
  background: #fff7ed;
}

.tq-overdue-badge {
  display: inline-block;
  margin-left: 0.5rem;
  background: #dc2626;
  color: #fff;
  border-radius: 999px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
}

.rl-escalated-due {
  margin-left: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: #92400e;
}

/* Audit view (story 3.3, #/audit) */

.au-section-title {
  margin: 1.25rem 0 0.5rem;
}

.au-verify-btn,
.au-refresh,
.au-export-btn {
  border: 1px solid var(--sanha-accent);
  background: #fff;
  color: var(--sanha-accent);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  font: inherit;
  cursor: pointer;
}

.au-export-btn {
  margin-right: 0.35rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
}

.au-verify-ok {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin: 0.75rem 0 0;
}

.au-verify-broken {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin: 0.75rem 0 0;
  font-weight: 600;
}

.au-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
}

.au-filter-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.au-filter {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-family: ui-monospace, monospace;
}

.au-table {
  width: 100%;
  border-collapse: collapse;
}

.au-table th,
.au-table td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #d9e2ec;
}

.au-run-link {
  color: var(--sanha-accent);
  font-family: ui-monospace, monospace;
  text-decoration: none;
}

.au-run-link:hover {
  text-decoration: underline;
}

.au-decision {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
  background: #e2e8f0;
  color: #334155;
}

.au-decision-approved {
  background: #dcfce7;
  color: #166534;
}

.au-decision-rejected {
  background: #fee2e2;
  color: #b91c1c;
}

.au-versions {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: #475569;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.au-at {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
}

.au-empty {
  color: #64748b;
}

/* Story 4.1: person registry list (pl-) + detail/profile (pd-). */
.pl-controls {
  margin: 0.75rem 0;
}

.pl-search {
  padding: 0.4rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  min-width: 16rem;
}

.pl-table {
  width: 100%;
  border-collapse: collapse;
}

.pl-table th,
.pl-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.pl-person-link {
  color: #1d4ed8;
  text-decoration: none;
}

.pl-delete {
  margin-left: 0.5rem;
  border: 1px solid #e7c3b6;
  background: transparent;
  color: #b4533a;
  border-radius: 4px;
  padding: 0.2rem 0.7rem;
  cursor: pointer;
}

.pl-delete:hover {
  background: #fbeee9;
}

.pl-empty,
.pd-empty {
  color: #64748b;
}

/* Muted "view only" hint shown in place of Start on non-startable rows. */
.pl-view-only {
  color: #64748b;
  font-size: 0.85em;
  font-style: italic;
}

/* KPI review-cycle launcher (#/kpi, M6b): unit picker + period + open button. */
.kpi-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.kpi-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--sanha-fg);
}

.kpi-select,
.kpi-input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--sanha-accent);
  border-radius: 6px;
  font: inherit;
}

.kpi-status {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
}

.kpi-cal-header {
  font-weight: 600;
  color: var(--sanha-fg);
  margin: 0.5rem 0;
}

.kpi-reviews {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sanha-accent);
}

.kpi-review-line {
  margin: 0.25rem 0;
  color: var(--sanha-fg);
}

/* Employee self-service launcher (SS-M3): a grid of friendly process cards. */
.ss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.ss-card {
  border: 1px solid var(--sanha-accent);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ss-card-title {
  margin: 0;
  color: var(--sanha-fg);
  font-size: 1.05rem;
}

.ss-card-desc {
  margin: 0;
  color: #64748b;
  flex: 1;
}

.ss-card .tq-act {
  align-self: flex-start;
}

.ss-field-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--sanha-fg);
}

.ss-field-input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--sanha-accent);
  border-radius: 6px;
  font: inherit;
}

.ss-status {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.ss-status-warn {
  color: #92400e;
  background: #fffbeb;
  border-color: #fcd34d;
}

.ss-status a {
  color: var(--sanha-accent);
}

.pd-back {
  display: inline-block;
  margin-bottom: 0.75rem;
  color: #1d4ed8;
  text-decoration: none;
}

.pd-card {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.pd-field {
  display: flex;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.pd-field-label {
  min-width: 12rem;
  color: #475569;
}

.pd-section-title {
  margin: 0.5rem 0;
}

.pd-identifiers {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.pd-identifier {
  display: flex;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

.pd-identifier-type {
  min-width: 12rem;
  color: #475569;
}

/* Story 4.2: career timeline + skills (pd-event / pd-skill / pd-learning). */
.pd-timeline {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.pd-event {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.pd-event-corrected .pd-event-title {
  text-decoration: line-through;
  color: #94a3b8;
}

.pd-event-type {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 0.75rem;
  background: #e0e7ff;
  color: #3730a3;
}

.pd-event-type-correction {
  background: #fee2e2;
  color: #991b1b;
}

.pd-event-date {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  color: #475569;
}

.pd-event-source,
.pd-skill-source {
  font-size: 0.72rem;
  color: #64748b;
}

.pd-event-corrected-link {
  font-size: 0.72rem;
  color: #b91c1c;
  text-decoration: none;
}

.pd-skills,
.pd-learning {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.pd-skill,
.pd-learning-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  padding: 0.35rem 0;
}

.pd-skill-name,
.pd-learning-name {
  min-width: 12rem;
}

.pd-dots {
  display: inline-flex;
  gap: 0.2rem;
}

.pd-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1px solid #94a3b8;
  display: inline-block;
}

.pd-dot-filled {
  background: #4f46e5;
  border-color: #4f46e5;
}

.pd-learning-provider,
.pd-learning-date {
  font-size: 0.8rem;
  color: #64748b;
}

/* Story 4.3: ownership badges on person fields (lock = READ_ONLY, sync). */
.pd-own-badge {
  margin-left: 0.6rem;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 0.75rem;
  white-space: nowrap;
}

.pd-own-readonly {
  background: #fef3c7;
  color: #92400e;
}

.pd-own-sync {
  background: #dbeafe;
  color: #1e40af;
}

/* Story 4.4: masked sensitive fields + purpose prompt + person export. */
.pd-field-masked {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.15rem;
  color: #b91c1c;
  cursor: help;
}

.pd-purpose {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0 1rem 0;
}

.pd-purpose-select {
  margin-left: 0.4rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
}

.pd-purpose-reveal {
  padding: 0.3rem 0.7rem;
  border: 1px solid #4f46e5;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 0.375rem;
  cursor: pointer;
}

.au-person-export {
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.au-person-input {
  margin-left: 0.4rem;
  width: 6rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
}

/* Story 4.5: duplicate-review panel (dr-) + new-person form (pn-). */
.pl-new-link {
  margin-left: 0.8rem;
  color: #1d4ed8;
  text-decoration: none;
}

.dr-intro {
  color: #92400e;
}

.dr-grid {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.dr-candidate {
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.75rem;
  min-width: 16rem;
}

.dr-candidate-name {
  margin: 0 0 0.25rem 0;
}

.dr-candidate-upid {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.dr-factors {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.dr-factors th,
.dr-factors td {
  text-align: left;
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid #f1f5f9;
}

.dr-reason {
  display: block;
  width: 100%;
  margin: 0.75rem 0;
  min-height: 3rem;
}

.dr-actions {
  display: flex;
  gap: 0.6rem;
}

.dr-create-new {
  padding: 0.3rem 0.8rem;
  border: 1px solid #16a34a;
  background: #f0fdf4;
  color: #166534;
  border-radius: 0.375rem;
  cursor: pointer;
}

.dr-merge[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.pn-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 28rem;
}

.pn-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.pn-input {
  padding: 0.35rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
}

.pn-submit {
  margin-top: 0.5rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid #4f46e5;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 0.375rem;
  cursor: pointer;
}

.pn-status {
  margin-top: 0.6rem;
  color: #166534;
}

/* Pipeline builder (#/pipelines/new) */
.pb-note {
  color: #64748b;
  font-size: 0.85rem;
  margin: 0.25rem 0 1rem;
}

.pb-step {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eef2f7;
}

.pb-step-num {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sanha-accent);
  color: #fff;
  font-size: 0.8rem;
}

.pb-step-title {
  flex: 1;
  min-width: 8rem;
}

.pb-step-role,
.pb-step-person,
.pb-step-type {
  padding: 0.35rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  font: inherit;
}

.pb-step-type {
  font-weight: 600;
  color: var(--sanha-accent);
}

.pb-step-config {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pb-step-config-label {
  font-size: 0.72rem;
  color: #64748b;
}

.pb-step-config-input {
  min-width: 12rem;
}

.pb-step-btn {
  border: 1px solid #cbd5e1;
  background: transparent;
  border-radius: 0.375rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.pb-step-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pb-step-remove {
  color: #b4533a;
  border-color: #e7c3b6;
}

.pb-add-step {
  margin: 0.5rem 0;
  border: 1px dashed var(--sanha-accent);
  background: transparent;
  color: var(--sanha-accent);
  border-radius: 0.375rem;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

.pb-save {
  display: block;
  margin-top: 1rem;
}

/* Pipeline flow diagram (pf-): the inline work-process view a pipeline name
   expands on #/pipelines. Neutral tokens so both themes inherit the accent. */
.pf-name-toggle {
  border: none;
  background: transparent;
  color: var(--sanha-accent);
  font: inherit;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.pf-flow-row td {
  background: #f1f5f9;
  padding: 0.75rem 1rem;
}

.pf-start {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: #334155;
}

.pf-start strong {
  color: #1e293b;
}

.pf-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pf-step {
  position: relative;
  display: flex;
  gap: 0.6rem;
  padding: 0 0 1.2rem 0;
}

/* The connector arrow between steps, drawn in CSS (no JS glyph literal). */
.pf-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 0.7rem;
  top: 1.5rem;
  bottom: 0.2rem;
  width: 2px;
  background: #cbd5e1;
}

.pf-step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0.45rem;
  bottom: 0.3rem;
  width: 0;
  height: 0;
  border-left: 0.35rem solid transparent;
  border-right: 0.35rem solid transparent;
  border-top: 0.4rem solid #cbd5e1;
}

.pf-step-num {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--sanha-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 1;
}

.pf-step-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.15rem;
}

.pf-step-label {
  font-weight: 600;
  color: #1e293b;
  width: 100%;
}

.pf-step-action {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  background: #e2e8f0;
  color: #475569;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

.pf-badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

.pf-badge-role {
  background: #dbeafe;
  color: #1e40af;
}

.pf-badge-assignee {
  background: #ede9fe;
  color: #5b21b6;
}

.pf-branch {
  width: 100%;
  display: flex;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: #64748b;
  padding-left: 0.2rem;
}

.pf-branch-kind {
  font-weight: 600;
}

/* Stitch theme: warm the flow surface + step accents to the deck palette. */
[data-theme="stitch"] .pf-flow-row td {
  background: var(--sanha-panel);
}
[data-theme="stitch"] .pf-step-num {
  background: var(--sanha-teal-dark);
}
[data-theme="stitch"] .pf-badge-role {
  background: #e2f4f1;
  color: var(--sanha-teal-dark);
}
[data-theme="stitch"] .pf-badge-assignee {
  background: #fbf1da;
  color: var(--sanha-gold);
}

/* Document-review panel (doc-): the document_review KIND_VIEWS renderer —
   editable AI draft + "Use LLM assistant" button + approve/reject. */
.doc-title {
  margin: 0 0 0.5rem;
  color: #1e293b;
}

.doc-field-label {
  display: block;
  margin: 0.6rem 0 0.2rem;
  font-size: 0.85rem;
  color: #334155;
}

.doc-draft {
  display: block;
  width: 100%;
  min-height: 11rem;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.6rem 0.7rem;
  border: 1px solid #cbd2d9;
  border-radius: 4px;
  white-space: pre-wrap;
}

.doc-assist {
  margin: 0.4rem 0 0.2rem;
  border: 1px dashed var(--sanha-accent);
  background: transparent;
  color: var(--sanha-accent);
  border-radius: 0.375rem;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
}

.doc-assist:hover {
  background: rgba(29, 78, 216, 0.06);
}

.doc-decision,
.doc-reason {
  display: block;
  padding: 0.35rem 0.55rem;
  border: 1px solid #cbd2d9;
  border-radius: 4px;
}

.doc-reason {
  width: 100%;
  box-sizing: border-box;
  min-height: 3rem;
  margin-top: 0.4rem;
}

.doc-submit {
  display: block;
  margin-top: 0.8rem;
  border: 1px solid var(--sanha-accent);
  background: var(--sanha-accent);
  color: #fff;
  border-radius: 0.375rem;
  padding: 0.4rem 1rem;
  cursor: pointer;
}

[data-theme="stitch"] .doc-assist:hover {
  background: #e2f4f1;
}

/* KPI review panels (kpi-ctx-): read-only context above the review form. */
.kpi-ctx {
  margin-bottom: 0.8rem;
  padding: 0.6rem 0.7rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.kpi-ctx-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  margin-top: 0.5rem;
}

.kpi-ctx-label:first-child {
  margin-top: 0;
}

.kpi-ctx-summary {
  margin: 0.2rem 0 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  color: #334155;
}

.kpi-ctx-text {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: #1e293b;
}

/* Executive dashboard (ex-): read-only aggregate stat cards (#/exec). */
.ex-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0.6rem 0 1.2rem;
}
.ex-card {
  flex: 1 1 8rem;
  min-width: 8rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}
.ex-card-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--sanha-accent);
}
.ex-card-label {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: #475569;
}
.ex-status {
  max-width: 24rem;
}
.ex-status-count {
  text-align: right;
  font-weight: 600;
}
[data-theme="stitch"] .ex-card-num {
  color: var(--sanha-teal-dark);
}

/* Access matrix (am-): the #/access "who can do what" reference page. */
.am-caps td.am-mark {
  text-align: center;
  font-weight: 600;
}
.am-yes {
  color: #15803d;
}
.am-limited {
  color: #b45309;
}
.am-no {
  color: #94a3b8;
}
.am-legend {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0.4rem 0 1.2rem;
}
.am-tpl {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}
.am-self-serve {
  margin-left: 0.5rem;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  background: #dcfce7;
  color: #15803d;
}
[data-theme="stitch"] .am-self-serve {
  background: #e2f4f1;
  color: var(--sanha-teal-dark);
}

/* ───────────────────────────────────────────────────────────────────────────
   THEME: "stitch" — the slide-deck design system (docs/design/DESIGN.md).
   Applied via <html data-theme="stitch"> (set by the header theme switcher in
   app.js). Everything here is scoped under [data-theme="stitch"], so the
   default ("original") look is unchanged. A third theme can be added the same
   way without touching base rules.
   ─────────────────────────────────────────────────────────────────────────── */
:root[data-theme="stitch"] {
  --sanha-fg: var(--sanha-ink);     /* #1a2238 */
  --sanha-bg: var(--sanha-panel);   /* #f2f5fa */
  --sanha-accent: var(--sanha-teal-dark); /* #0a8a80 — recolors links/buttons */
}

/* Navy, document-of-record headings */
[data-theme="stitch"] .shell-title,
[data-theme="stitch"] .au-section-title,
[data-theme="stitch"] .pd-section-title,
[data-theme="stitch"] .rl-attention-title {
  color: var(--sanha-navy);
}
[data-theme="stitch"] .shell-title {
  letter-spacing: 0.02em;
}

/* Signature teal left edge on cards/panels */
[data-theme="stitch"] .pd-card,
[data-theme="stitch"] .dr-candidate {
  border-left: 4px solid var(--sanha-teal);
}

/* Hairlines toward the deck tone */
[data-theme="stitch"] .shell-nav {
  border-bottom-color: var(--sanha-hairline);
}

/* Primary actions: indigo → teal, on-brand with the deck */
[data-theme="stitch"] .pn-submit,
[data-theme="stitch"] .pd-purpose-reveal,
[data-theme="stitch"] .dr-create-new {
  border-color: var(--sanha-teal-dark);
  background: #e2f4f1;
  color: var(--sanha-teal-dark);
}

/* Proficiency dots → teal */
[data-theme="stitch"] .pd-dot-filled {
  background: var(--sanha-teal);
  border-color: var(--sanha-teal);
}

/* Ownership badges → deck colors (SYNC amber, READ-ONLY terracotta) */
[data-theme="stitch"] .pd-own-readonly {
  background: #fbeee9;
  color: var(--sanha-terracotta);
}
[data-theme="stitch"] .pd-own-sync {
  background: #fbf1da;
  color: var(--sanha-gold);
}
[data-theme="stitch"] .pd-field-masked {
  color: var(--sanha-terracotta);
}
