:root {
  --ink: #132033;
  --muted: #5d6a78;
  --line: #d8d4ca;
  --paper: #f7f4ee;
  --surface: #fffdf9;
  --sidebar: #142335;
  --teal: #1f7a7a;
  --teal-soft: #e7f2f1;
  --gold: #b5822f;
  --gold-soft: #f6ecd8;
  --coral: #c45f4a;
  --coral-soft: #f5e5df;
  --green: #2f7d4e;
  --red: #aa3f35;
  --shadow: 0 18px 50px rgba(38, 31, 20, 0.08);
  color-scheme: light;
  font-family:
    "Microsoft JhengHei",
    "PingFang TC",
    "Noto Sans TC",
    "Segoe UI",
    Arial,
    sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar);
  color: #edf2f5;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: #edf2f5;
  color: var(--sidebar);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
}

.brand-sub {
  color: #aab7c3;
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 7px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(207, 160, 86, 0.7) transparent;
  padding-right: 4px;
}

.nav-list::-webkit-scrollbar {
  width: 7px;
}

.nav-list::-webkit-scrollbar-thumb {
  background: rgba(207, 160, 86, 0.7);
  border-radius: 999px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: #d8e0e7;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #20364c;
  color: #fff;
}

.nav-icon {
  color: #cfa056;
  font-size: 15px;
  text-align: center;
}

.sidebar-panel {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 14px;
  color: #c9d3dc;
}

.panel-label,
.eyebrow,
.section-kicker {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.panel-label {
  color: #d9ad63;
  margin-bottom: 8px;
}

.sidebar-panel p {
  margin: 0;
  line-height: 1.55;
  font-size: 14px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--teal);
  margin-bottom: 8px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.16;
  margin-bottom: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 21px;
  line-height: 1.25;
  margin-bottom: 12px;
}

p {
  line-height: 1.65;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button,
.primary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 40px;
  cursor: pointer;
}

.icon-button {
  width: 42px;
  font-size: 18px;
}

.primary-action {
  padding: 0 16px;
  background: var(--ink);
  color: white;
  border-color: var(--ink);
  font-weight: 800;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.knowledge-copy,
.knowledge-status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  max-width: 780px;
}

.knowledge-query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.knowledge-query-row textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  padding: 12px;
}

.knowledge-result {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.knowledge-result:first-child { padding-top: 0; }
.knowledge-result:last-child { border-bottom: 0; padding-bottom: 0; }
.knowledge-result h3 { margin: 9px 0 4px; }
.knowledge-result p { color: var(--muted); line-height: 1.65; }

.knowledge-result a {
  color: var(--ink);
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.knowledge-result-meta {
  color: var(--gold);
  display: flex;
  font-size: 12px;
  font-weight: 800;
  gap: 10px;
}

.knowledge-heading { font-weight: 700; }
.empty-state { color: var(--muted); text-align: center; }

.sr-only {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  clip: rect(0, 0, 0, 0);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  min-height: 110px;
}

.metric-label,
.metric-note {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 34px;
  line-height: 1.1;
  margin: 8px 0;
}

.metric-note.positive {
  color: var(--green);
  font-weight: 700;
}

.layout-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.surface {
  padding: 20px;
  min-height: 150px;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.section-kicker {
  color: var(--gold);
  margin-bottom: 8px;
  line-height: 1.2;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: #f4f1ea;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.good {
  color: var(--green);
  background: #eaf4ee;
  border-color: #c8dfd0;
}

.status-pill.warning {
  color: #7a5315;
  background: var(--gold-soft);
  border-color: #dec28f;
}

.architecture-flow {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 26px minmax(150px, 1fr) 26px minmax(150px, 1fr) 26px minmax(150px, 1fr);
  gap: 8px;
  align-items: stretch;
}

.flow-node {
  border: 1px solid var(--line);
  background: #fff;
  padding: 16px;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flow-node.selected {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 2px rgba(31, 122, 122, 0.12);
}

.flow-node.warm {
  background: var(--gold-soft);
}

.flow-node.teal {
  background: var(--teal-soft);
}

.flow-node.coral {
  background: var(--coral-soft);
}

.flow-node strong {
  font-size: 18px;
}

.flow-node span {
  font-weight: 800;
  color: var(--teal);
}

.flow-node small {
  color: var(--muted);
  line-height: 1.55;
}

.flow-arrow {
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 22px;
  font-weight: 800;
}

.check-list {
  padding: 0;
  margin: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.check-list li {
  position: relative;
  padding-left: 24px;
  line-height: 1.55;
  color: var(--muted);
}

.check-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--green);
  font-weight: 900;
}

.gate-machine {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.gate-node {
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  min-height: 118px;
  position: relative;
}

.gate-node.done {
  background: #eaf4ee;
  border-color: #bad7c4;
}

.gate-node.current {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.gate-node.locked {
  color: #7e8790;
  background: #f2f0eb;
}

.gate-node strong {
  display: block;
  margin-bottom: 8px;
}

.gate-node small {
  color: var(--muted);
  line-height: 1.5;
}

.rule-stack {
  display: grid;
  gap: 10px;
}

.rule-item {
  border: 1px solid var(--line);
  padding: 12px;
  background: #fff;
}

.rule-item strong {
  display: block;
  margin-bottom: 4px;
}

.rule-item span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.project-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.case-search {
  display: grid;
  gap: 6px;
}

.case-search label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.case-search select {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.role-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
}

.role-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.project-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.project-detail-grid div {
  border: 1px solid var(--line);
  background: #fff;
  min-height: 74px;
  padding: 12px;
}

.project-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.project-detail-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.r5-contract-card {
  border-left: 4px solid var(--teal);
}

.r5-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 16px;
  align-items: stretch;
}

.r5-hero > div,
.r5-contract-id,
.event-card,
.payment-flow div,
.ai-boundary div,
.r5-inline-grid div {
  border: 1px solid var(--line);
  background: #fffaf2;
  padding: 16px;
}

.r5-hero strong,
.r5-contract-id strong,
.event-card strong,
.payment-flow strong,
.ai-boundary strong,
.r5-inline-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.r5-label,
.r5-contract-id span,
.r5-inline-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.r5-hero p,
.event-card span,
.ai-boundary span {
  color: var(--muted);
  line-height: 1.65;
  margin: 10px 0 0;
}

.r5-contract-id {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--teal-soft);
}

.event-grid,
.payment-flow,
.canonical-list,
.ai-boundary,
.r5-inline-grid {
  display: grid;
  gap: 12px;
}

.r5-inline-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.event-grid {
  grid-template-columns: 1fr;
}

.payment-flow {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.payment-flow div {
  min-height: 112px;
}

.payment-flow span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 14px;
  background: var(--sidebar);
  color: #fff;
  font-weight: 800;
}

.canonical-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.canonical-list code {
  display: block;
  min-height: 42px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f6f8f8;
  color: var(--teal);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.canonical-summary {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--gold-soft);
}

.canonical-summary strong {
  font-size: 34px;
  color: var(--gold);
}

.canonical-summary span {
  color: var(--ink);
  font-weight: 700;
}

.permission-panel {
  display: grid;
  gap: 14px;
}

.permission-notice {
  border-left: 3px solid var(--coral);
  padding: 10px 12px;
  background: rgba(220, 91, 75, 0.08);
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.55;
}

.permission-scope {
  border: 1px solid var(--line);
  background: var(--teal-soft);
  font-weight: 800;
  line-height: 1.6;
  padding: 14px;
}

.permission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.permission-actions span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 9px;
}

.gate-machine.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.audit-table {
  display: grid;
  border: 1px solid var(--line);
}

.audit-row {
  display: grid;
  grid-template-columns: 150px 160px minmax(0, 1fr) 160px;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  font-size: 14px;
}

.audit-row:last-child {
  border-bottom: 0;
}

.audit-row.header {
  background: #f2eee5;
  font-weight: 800;
  color: var(--ink);
}

.passport-card {
  border: 1px solid var(--line);
  background: var(--teal-soft);
}

.passport-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.passport-header span,
.passport-meta dt {
  color: var(--muted);
  font-size: 12px;
}

.passport-header strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.passport-meta {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.passport-meta div {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.passport-meta div:nth-child(2n) {
  border-right: 0;
}

.passport-meta div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.passport-meta dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.check-item {
  min-height: 76px;
  border: 1px solid var(--line);
  padding: 12px;
  background: #fff;
}

.check-item.done {
  border-color: #bad7c4;
  background: #edf6f0;
}

.check-item.risk {
  border-color: #e3b8ad;
  background: var(--coral-soft);
}

.check-item strong {
  display: block;
  margin-bottom: 6px;
}

.check-item span {
  color: var(--muted);
  font-size: 13px;
}

.risk-dial {
  min-height: 260px;
  display: grid;
  place-items: center;
}

.dial-ring {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  background:
    radial-gradient(circle at center, var(--surface) 0 57%, transparent 58%),
    conic-gradient(var(--teal) 0 31%, var(--line) 31% 100%);
}

.dial-ring strong {
  font-size: 54px;
  line-height: 1;
}

.dial-ring span {
  color: var(--muted);
  font-weight: 800;
}

.bar-list {
  display: grid;
  gap: 14px;
}

.bar-item {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 54px;
  gap: 12px;
  align-items: center;
}

.bar-track {
  height: 14px;
  background: #ebe7de;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
}

.bar-item.warning .bar-fill {
  background: var(--gold);
}

.bar-item.danger .bar-fill {
  background: var(--coral);
}

.recommendation-grid,
.business-model,
.association-grid,
.tech-stack,
.engine-grid,
.roadmap-strip,
.checklist-summary,
.field-matrix,
.upgrade-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.recommendation-grid div,
.business-model div,
.assoc-card,
.tech-stack div,
.engine-grid div,
.roadmap-strip div,
.checklist-summary div,
.field-matrix div,
.upgrade-map div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 15px;
  min-height: 112px;
  line-height: 1.55;
}

.business-model strong,
.assoc-card strong,
.tech-stack strong,
.roadmap-strip strong,
.checklist-summary strong,
.field-matrix strong,
.upgrade-map strong {
  display: block;
  margin-bottom: 10px;
  font-size: 18px;
}

.business-model span,
.assoc-card span,
.tech-stack span,
.roadmap-strip span,
.checklist-summary span,
.field-matrix span,
.upgrade-map span {
  color: var(--muted);
  line-height: 1.55;
}

.checklist-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.checklist-summary div {
  background: var(--teal-soft);
}

.registry-head p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.registry-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 14px;
}

.registry-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.registry-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 800;
}

.registry-tabs button:hover,
.registry-tabs button.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.registry-search {
  display: grid;
  gap: 6px;
  width: min(360px, 100%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.registry-search input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 11px;
}

.registry-table {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.registry-table table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

.registry-table th,
.registry-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}

.registry-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--sidebar);
  color: #fff;
  font-size: 12px;
}

.registry-table td {
  color: var(--ink);
  font-size: 13px;
}

.registry-table tbody tr:nth-child(even) {
  background: #f6f8f8;
}

.registry-table tbody tr:hover {
  background: var(--gold-soft);
}

.registry-empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.field-matrix {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-matrix div {
  min-height: 104px;
}

.upgrade-map div {
  background: #fff;
  border-top: 4px solid var(--teal);
}

.priority-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  counter-reset: priority;
}

.priority-list li {
  counter-increment: priority;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.priority-list li::before {
  content: counter(priority);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 900;
}

.priority-list strong,
.priority-list span {
  grid-column: 2;
}

.priority-list strong {
  margin-bottom: 4px;
}

.priority-list span {
  color: var(--muted);
  line-height: 1.5;
}

.engine-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.engine-grid div {
  min-height: 68px;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 800;
  background: var(--teal-soft);
}

.api-list {
  display: grid;
  gap: 10px;
}

.api-list code {
  display: block;
  padding: 12px;
  background: #172538;
  color: #eef5f6;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.kpi-table {
  display: grid;
  border: 1px solid var(--line);
}

.kpi-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 120px;
  border-bottom: 1px solid var(--line);
}

.kpi-row:last-child {
  border-bottom: 0;
}

.kpi-row span {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.kpi-row span:last-child {
  border-right: 0;
  font-weight: 800;
  color: var(--teal);
}

.kpi-row.header {
  background: #f2eee5;
  font-weight: 800;
}

.roadmap-strip {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.roadmap-strip div {
  min-height: 124px;
  background: var(--gold-soft);
}

.level-ladder {
  display: grid;
  gap: 10px;
}

.level-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 86px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.level-row.current {
  background: var(--teal-soft);
  border-color: var(--teal);
}

.level-row strong {
  font-size: 18px;
}

.level-row span {
  color: var(--muted);
  line-height: 1.45;
}

.split-list {
  display: grid;
  gap: 14px;
}

.split-list div {
  border: 1px solid var(--line);
  background: #fff;
  padding: 18px;
  min-height: 130px;
}

.split-list strong {
  display: block;
  font-size: 21px;
  margin-bottom: 10px;
}

.split-list span {
  color: var(--muted);
  line-height: 1.6;
}

.operations-surface {
  padding: 0;
  overflow: hidden;
}

.operations-head {
  padding: 20px 22px 12px;
  margin: 0;
}

.operations-summary {
  color: var(--muted);
  font-size: 13px;
}

.operations-tabs {
  display: flex;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f3f0e9;
}

.operations-tab {
  min-width: 132px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.operations-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--teal);
}

.operations-panel {
  padding: 20px 22px 24px;
  min-height: 220px;
}

.operations-panel.is-busy {
  opacity: 0.62;
  pointer-events: none;
}

.operations-loading,
.operations-error,
.empty-state {
  padding: 22px;
  color: var(--muted);
  background: #f5f2ec;
}

.operations-error {
  color: var(--red);
  border-left: 3px solid var(--red);
}

.current-stage-display {
  display: grid;
  gap: 4px;
  min-width: min(100%, 360px);
}

.current-stage-display span,
.current-stage-display small {
  color: var(--muted);
}

.current-stage-display strong {
  font-size: 1rem;
}
.operations-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 360px) 130px minmax(180px, 1fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.operations-toolbar label,
.form-grid label,
.inline-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.operations-panel input,
.operations-panel select,
.operations-panel textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
}

.operations-panel textarea {
  min-height: 90px;
  resize: vertical;
}

.progress-copy strong,
.progress-copy span {
  display: block;
}

.progress-copy strong {
  font-size: 22px;
}

.progress-copy span {
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  background: #dfddd6;
  margin-bottom: 6px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.checklist-execution {
  border-top: 1px solid var(--line);
  overflow-x: auto;
}

.execution-row {
  display: grid;
  grid-template-columns: 34px minmax(240px, 1fr) minmax(150px, 190px) minmax(150px, 190px);
  gap: 12px;
  align-items: center;
  min-height: 62px;
  min-width: 760px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.execution-row.is-locked {
  background: #f5f2ec;
}

.confirmation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #f3f0e9;
  color: var(--muted);
  font-size: 12px;
}

.confirmation-legend b {
  color: var(--ink);
}

.party-confirmation {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.party-confirmation select {
  min-height: 38px;
}

.execution-marker {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid #aaa69d;
  color: #fff;
  font-weight: 800;
}

.status-completed .execution-marker {
  background: var(--green);
  border-color: var(--green);
}

.status-exception .execution-marker {
  background: var(--coral);
  border-color: var(--coral);
}

.status-not_applicable .execution-marker {
  background: var(--muted);
  border-color: var(--muted);
}

.execution-row strong,
.execution-row small {
  display: block;
}

.execution-row small {
  margin-top: 4px;
  color: var(--muted);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 18px;
}

.planning-phase {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-subtle, #f8faf9);
}

.planning-step {
  margin-top: .75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.planning-step > summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1rem;
  cursor: pointer;
}

.planning-step > summary span {
  color: var(--muted);
  font-size: .82rem;
}

.planning-step .checklist-execution,
.planning-step .inline-form {
  margin: 0 1rem 1rem;
}

.planning-editor-list { margin: 0 1rem 1rem; display: grid; gap: .65rem; }
.planning-item-form { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(280px, 1.2fr) auto; gap: .75rem; align-items: end; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; }
.planning-item-form label { display: grid; gap: .35rem; font-size: .76rem; color: var(--muted); }
.planning-item-form input, .planning-item-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; font: inherit; color: var(--ink); background: #fff; }
.planning-item-form textarea { min-height: 4.2rem; resize: vertical; }
.planning-item-actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; justify-content: flex-end; }
.planning-item-actions small { width: 100%; text-align: right; color: var(--muted); }
.danger-action { border: 1px solid #fecaca; border-radius: 8px; padding: .55rem .75rem; color: #b91c1c; background: #fff7f7; cursor: pointer; }
.planning-confirmation-panel { display: grid; grid-template-columns: 1fr 1fr auto; gap: .75rem; align-items: center; margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.planning-confirmation-panel > div { display: grid; gap: .25rem; }
.planning-confirmation-panel span { color: var(--muted); font-size: .8rem; }

.bilateral-checklist {
  margin: 0 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.bilateral-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 150px 150px;
  align-items: stretch;
  border-top: 1px solid var(--line);
}

.bilateral-row:first-child { border-top: 0; }
.bilateral-row > * { padding: .75rem; }
.bilateral-row > * + * { border-left: 1px solid var(--line); }
.bilateral-header { background: #eef3f1; font-size: .78rem; font-weight: 700; }
.bilateral-header span:not(:first-child) { text-align: center; }
.bilateral-row.is-locked { opacity: .68; background: #f4f4f3; }

.bilateral-check {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  cursor: pointer;
  font-size: .75rem;
  color: var(--muted);
}

.bilateral-check input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: #0f766e;
}

@media (max-width: 760px) {
  .planning-item-form, .planning-confirmation-panel { grid-template-columns: 1fr; }
  .planning-item-actions, .planning-item-actions small { justify-content: flex-start; text-align: left; }
  .bilateral-row { grid-template-columns: minmax(180px, 1fr) 92px 92px; }
  .bilateral-row > * { padding: .6rem; }
}

.secondary-action,
.icon-action {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.icon-action {
  width: 36px;
  min-height: 34px;
  padding: 0;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
  padding-bottom: 20px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.form-grid .wide-field {
  grid-column: span 2;
}

.file-field input {
  padding: 6px;
}

.baseline-version-banner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-left: 4px solid var(--teal);
  background: var(--teal-soft);
}

.read-only-banner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-left: 4px solid var(--gold);
  background: var(--gold-soft);
}

.read-only-banner span {
  color: var(--muted);
  font-size: 12px;
}

.operations-panel :disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.baseline-version-banner span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.data-table {
  width: 100%;
  overflow-x: auto;
}

.data-row {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1fr) 150px minmax(160px, 0.7fr) 66px;
  min-width: 820px;
  border-bottom: 1px solid var(--line);
}

.data-row.header {
  background: #f3f0e9;
  font-weight: 800;
}

.data-row > span {
  padding: 11px 10px;
  overflow-wrap: anywhere;
}

.data-row strong,
.data-row small {
  display: block;
}

.data-row small {
  margin-top: 4px;
  color: var(--muted);
}

.milestone-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-bottom: 20px;
}

.milestone-item {
  min-height: 138px;
  padding: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.milestone-item span,
.milestone-item strong,
.milestone-item b,
.milestone-item small {
  display: block;
}

.milestone-item span,
.milestone-item small {
  color: var(--muted);
  font-size: 12px;
}

.milestone-item strong {
  margin: 7px 0;
}

.milestone-item b {
  color: var(--teal);
  font-size: 20px;
  margin-bottom: 8px;
}

.compact-list {
  border-top: 1px solid var(--line);
}

.compact-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, auto) 44px;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.compact-list span {
  color: var(--muted);
  font-size: 13px;
}

.change-table .data-row {
  grid-template-columns: 110px 150px minmax(240px, 1fr) 130px 90px 90px;
}

.baseline-history-table {
  margin-bottom: 20px;
}

.baseline-history-table .data-row {
  grid-template-columns: 150px 170px 160px minmax(230px, 0.8fr) minmax(260px, 1fr);
  min-width: 970px;
}

.message-compose {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.timeline-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px;
  margin-top: 20px;
}

.timeline-columns h3 {
  font-size: 16px;
  margin: 0 0 10px;
}

.timeline-list {
  border-top: 1px solid var(--line);
}

.timeline-list > div {
  padding: 13px 0 13px 18px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.timeline-list > div::before {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  left: 0;
  top: 19px;
  background: var(--teal);
}

.timeline-list span,
.timeline-list strong,
.timeline-list time {
  display: block;
}

.timeline-list span,
.timeline-list time {
  color: var(--muted);
  font-size: 12px;
}

.timeline-list p {
  margin: 5px 0;
  color: var(--ink);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-y: visible;
    padding-right: 0;
  }

  .status-strip,
  .architecture-flow,
  .r5-hero,
  .project-detail-grid,
  .recommendation-grid,
  .business-model,
  .association-grid,
  .tech-stack,
  .engine-grid,
  .roadmap-strip,
  .checklist-summary,
  .field-matrix,
  .upgrade-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .payment-flow,
  .canonical-list,
  .form-grid,
  .milestone-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flow-arrow {
    display: none;
  }

  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }
}

@media (max-width: 680px) {
  .sidebar {
    padding: 12px;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
  }

  .brand {
    min-height: 40px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-name {
    font-size: 18px;
  }

  .nav-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(132px, 42vw);
    grid-template-columns: none;
    width: calc(100vw - 24px);
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    padding-bottom: 4px;
    padding-right: 28px;
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 28px), transparent 100%);
  }

  .nav-item {
    min-height: 40px;
    white-space: nowrap;
  }

  .sidebar-panel {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
  }

  h1 {
    font-size: 26px;
  }

  .status-strip,
  .architecture-flow,
  .project-toolbar,
  .r5-hero,
  .event-grid,
  .payment-flow,
  .canonical-list,
  .r5-inline-grid,
  .project-detail-grid,
  .gate-machine.compact,
  .recommendation-grid,
  .business-model,
  .association-grid,
  .tech-stack,
  .engine-grid,
  .roadmap-strip,
  .checklist-summary,
  .field-matrix,
  .upgrade-map,
  .checklist-grid,
  .passport-meta,
  .operations-toolbar,
  .form-grid,
  .milestone-grid,
  .message-compose,
  .timeline-columns,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .operations-panel {
    padding: 16px;
  }

  .registry-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .registry-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .registry-search {
    width: 100%;
  }

  .baseline-version-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .read-only-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .execution-row {
    grid-template-columns: 30px minmax(210px, 1fr) minmax(140px, 170px) minmax(140px, 170px);
    padding: 10px 0;
  }

  .confirmation-legend {
    display: grid;
    gap: 6px;
  }

  .form-grid .wide-field {
    grid-column: auto;
  }

  .compact-list > div {
    grid-template-columns: 1fr 44px;
    padding: 10px 0;
  }

  .compact-list > div span {
    grid-column: 1;
  }

  .kpi-row {
    grid-template-columns: 1fr;
  }

  .kpi-row span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .kpi-row span:last-child {
    border-bottom: 0;
  }

  .audit-row {
    grid-template-columns: 1fr;
  }

  .passport-meta div,
  .passport-meta div:nth-child(2n),
  .passport-meta div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .passport-meta div:last-child {
    border-bottom: 0;
  }
}

.r9-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-top: 18px;
}

.r9-toolbar label {
  display: grid;
  gap: 6px;
  min-width: min(520px, 100%);
  color: var(--muted);
  font-size: 13px;
}

.r9-toolbar select {
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
}

.r9-boundary-note {
  margin: 16px 0 0;
  border-left: 3px solid #b7791f;
  background: #fff8e7;
  padding: 12px 14px;
  color: #61430f;
}

#r9GovernanceStatus {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: right;
  white-space: normal;
}

.r9-case-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--line);
}

.r9-case-summary > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  background: #fff;
  padding: 12px;
}

.r9-case-summary span,
.r9-object-row span {
  color: var(--muted);
  font-size: 12px;
}

.r9-case-summary strong {
  overflow-wrap: anywhere;
}

.r9-object-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.r9-object-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.r9-object-head,
.r9-object-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.r9-object-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.r9-object-head span {
  color: #8a5b0a;
  font-size: 12px;
  text-transform: uppercase;
}

.r9-object-row {
  align-items: start;
  padding-top: 8px;
}

.r9-object-row code {
  max-width: 72%;
  overflow-wrap: anywhere;
  text-align: right;
  white-space: normal;
}

@media (max-width: 760px) {
  .r9-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .r9-case-summary {
    grid-template-columns: 1fr;
  }

  #r9GovernanceStatus {
    text-align: left;
  }
}

@media print {
  .sidebar,
  .topbar-actions {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .view {
    display: block;
    page-break-after: always;
  }
}

.field-evidence-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.field-evidence-form { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
.field-evidence-list { display: grid; gap: 10px; }
.field-evidence-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 1fr) minmax(120px, .7fr) auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.field-evidence-row:last-child { border-bottom: 0; }
.field-evidence-row strong, .field-evidence-row span { display: block; overflow-wrap: anywhere; }
.field-evidence-row small { color: var(--muted); }
.field-evidence-row .review-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.field-evidence-row button { min-height: 36px; }
.field-evidence-boundary { color: var(--muted); font-size: 12px; }
@media (max-width: 780px) { .field-evidence-form { grid-template-columns: 1fr; } .field-evidence-row { grid-template-columns: 1fr; } .field-evidence-row .review-actions { justify-content: flex-start; } }
.field-file-picker { display: grid; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.field-file-picker input { min-height: 46px; border: 1px dashed var(--line); background: #fff; padding: 10px; }
.field-media-grid { display: grid; gap: 8px; margin-top: 16px; }
.field-media-card { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start; border-top: 1px solid var(--line); padding: 12px 0; }
.field-media-card input { width: 18px; height: 18px; margin-top: 2px; }
.field-media-card span, .field-media-card strong, .field-media-card small { display: block; min-width: 0; overflow-wrap: anywhere; }
.field-media-card small { margin-top: 4px; color: var(--muted); }
.construction-log { border-left: 3px solid #b7791f; padding: 4px 0 4px 12px; }
.construction-log p { margin: 8px 0; color: var(--muted); }
.ncr-capa-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px; margin-top: 20px; }
.ncr-item { border-top: 1px solid var(--line); padding: 12px 0; }
.ncr-item p { margin: 6px 0; color: var(--muted); }
.ncr-item small { display: block; margin-bottom: 8px; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 780px) { .ncr-capa-grid { grid-template-columns: 1fr; } }

/* Case-first workspace preview */
.global-role-control {
  display: grid;
  gap: 4px;
  min-width: 170px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.global-role-control select {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 34px 0 10px;
}

.workbench-intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 6px 0 24px;
}

.workbench-intro h2 {
  font-size: 28px;
  margin-bottom: 6px;
}

.workbench-intro p:last-child {
  margin-bottom: 0;
}

.case-creator {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.case-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.case-mode-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 5px 12px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 16px;
  text-align: left;
  cursor: pointer;
}

.case-mode-option:hover,
.case-mode-option.selected {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.case-mode-option .mode-number {
  grid-row: span 2;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 800;
}

.case-mode-option:nth-child(2) .mode-number {
  background: var(--gold-soft);
  color: #805b1f;
}

.case-mode-option:nth-child(3) .mode-number {
  background: var(--coral-soft);
  color: var(--coral);
}

.case-mode-option strong,
.case-mode-option small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.case-mode-option strong {
  font-size: 17px;
}

.case-mode-option small {
  grid-column: 2;
  color: var(--muted);
  line-height: 1.55;
}

.case-mode-result {
  display: grid;
  gap: 5px;
  margin-top: 14px;
  border-left: 3px solid var(--teal);
  background: var(--teal-soft);
  padding: 12px 14px;
  color: var(--muted);
}

.case-mode-result strong,
.case-mode-result span,
.case-mode-result small {
  display: block;
}

.case-mode-result strong {
  color: var(--ink);
}

.case-creator-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.8fr);
  gap: 28px;
  margin-top: 28px;
}

.workbench-main,
.workbench-side {
  min-width: 0;
}

.workbench-projects,
.workbench-tasks {
  display: grid;
  gap: 12px;
}

.workbench-project {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 18px;
}

.workbench-project.current {
  border-left: 4px solid var(--teal);
}

.project-card-head,
.project-card-footer,
.project-stage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.project-card-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.project-card-head strong {
  overflow-wrap: anywhere;
}

.project-id,
.project-card-footer small,
.project-stage-row span {
  color: var(--muted);
  font-size: 12px;
}

.case-mode-tag {
  flex: 0 0 auto;
  border-radius: 4px;
  background: var(--teal-soft);
  color: var(--teal);
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 800;
}

.case-mode-tag.design_only {
  background: var(--gold-soft);
  color: #805b1f;
}

.case-mode-tag.construction_only {
  background: var(--coral-soft);
  color: var(--coral);
}

.project-stage-row {
  margin-top: 18px;
}

.project-progress {
  height: 7px;
  margin: 10px 0 16px;
  overflow: hidden;
  background: #e8e5de;
}

.project-progress span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.project-card-footer .secondary-action {
  min-height: 36px;
  white-space: nowrap;
}

.task-count {
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  font-weight: 800;
}

.workbench-tasks button {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 18px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 66px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 8px 2px;
  text-align: left;
  cursor: pointer;
}

.workbench-tasks button:hover {
  background: rgba(255, 255, 255, 0.65);
}

.workbench-tasks strong,
.workbench-tasks small {
  display: block;
  overflow-wrap: anywhere;
}

.workbench-tasks small {
  margin-top: 4px;
  color: var(--muted);
}

.task-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}

.task-status.urgent {
  background: var(--coral);
}

.workbench-quick {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 2fr);
  gap: 24px;
  align-items: center;
  margin-top: 32px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.quick-action-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-action-list button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 3px 10px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.quick-action-list button > span {
  grid-row: span 2;
  color: var(--gold);
  font-size: 21px;
}

.quick-action-list button small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
  .workbench-grid,
  .workbench-quick {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .global-role-control {
    flex: 1 1 190px;
  }

  .workbench-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .case-mode-grid,
  .quick-action-list {
    grid-template-columns: 1fr;
  }

  .case-mode-option {
    min-height: 108px;
  }

  .project-card-head,
  .project-card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .project-card-head > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .project-card-footer .secondary-action {
    width: 100%;
  }

  .case-creator-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .workspace {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .global-role-control,
  .global-role-control select {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions .icon-button {
    display: none;
  }

  .project-stage-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  body,
  .app-shell,
  .workspace {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
  }

  .workbench-intro p {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

.guide-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.guide-list article,
.case-basic-grid > div {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
}

.guide-list h3,
.help-heading {
  margin: 0 0 8px;
}

.guide-list p,
.case-basic-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.guide-file-link {
  display: inline-flex;
  margin: 0 0 18px;
  color: var(--accent);
  font-weight: 700;
}

.responsibility-note,
.case-basic-intro {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  line-height: 1.65;
}

.case-basic-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.case-basic-grid strong {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

@media (max-width: 900px) {
  .guide-list,
  .case-basic-grid {
    grid-template-columns: 1fr;
  }

  .change-table .data-row {
    grid-template-columns: 1fr;
  }
}
.stage-readiness-banner {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: var(--surface);
}

.stage-readiness-banner.is-blocked { border-left-color: #c74f3d; }
.stage-readiness-banner.is-ready { border-left-color: #15805f; }
.stage-readiness-banner span,
.stage-readiness-banner small { color: var(--muted); line-height: 1.55; }

.payment-party-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  font-size: .78rem;
  color: var(--muted);
}

.milestone-item.is-locked { background: var(--surface-muted); }
.milestone-item em { display: block; margin-top: 8px; color: var(--muted); font-size: .76rem; font-style: normal; }
.payment-confirmation-action { margin-top: 10px; width: 100%; }
/* iSAFE public introduction and direct-intake entry */
.isafe-home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 32px;
  align-items: stretch;
  padding: clamp(28px, 5vw, 64px);
  border: 1px solid #d8ddd9;
  background: #f7f9f7;
}
.isafe-home-copy { align-self: center; }
.isafe-home-copy h2 { max-width: 760px; margin: 8px 0 18px; font-size: clamp(32px, 4vw, 56px); line-height: 1.12; }
.isafe-home-copy > p:not(.section-kicker) { max-width: 720px; color: #4c5550; font-size: 18px; line-height: 1.8; }
.isafe-home-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.isafe-home-principles { display: grid; align-content: center; gap: 1px; background: #ccd4cf; border: 1px solid #ccd4cf; }
.isafe-home-principles div { display: grid; gap: 7px; min-height: 112px; align-content: center; padding: 22px; background: #17201b; color: #fff; }
.isafe-home-principles strong { font-size: 18px; }
.isafe-home-principles span { color: #cbd6cf; line-height: 1.6; }
.home-explainer-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 24px; border: 1px solid #d8ddd9; background: #d8ddd9; gap: 1px; }
.home-explainer-grid article { min-height: 190px; padding: 28px; background: #fff; }
.home-explainer-grid article > span { color: #08735b; font-weight: 800; }
.home-explainer-grid h3 { margin: 28px 0 10px; font-size: 20px; }
.home-explainer-grid p { color: #626a66; line-height: 1.7; }
.direct-intake-panel { margin-top: 24px; padding: clamp(22px, 4vw, 40px); border: 1px solid #bfc8c2; background: #fff; }
.direct-intake-panel[hidden] { display: none; }
.direct-intake-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 24px; }
.direct-intake-form label { display: grid; gap: 8px; color: #28302b; font-size: 14px; font-weight: 700; }
.direct-intake-form input, .direct-intake-form select, .direct-intake-form textarea { width: 100%; min-height: 46px; border: 1px solid #c7ceca; background: #fff; padding: 10px 12px; color: #18201b; font: inherit; }
.direct-intake-form textarea { min-height: 112px; resize: vertical; }
.direct-intake-form .wide { grid-column: 1 / -1; }
.direct-intake-consent { grid-template-columns: 20px 1fr !important; align-items: start; font-weight: 500 !important; line-height: 1.6; }
.direct-intake-consent input { width: 18px; min-height: 18px; margin-top: 3px; }
.direct-intake-actions { display: flex !important; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; padding-top: 8px; }
#directIntakeStatus { color: #08735b; font-weight: 600; }
#directIntakeStatus.error { color: #a12622; }
body.public-home #globalRoleSelect, body.public-home .global-role-control, body.public-home #demoCycleBtn, body.public-home #printBtn { display: none; }
@media (max-width: 900px) {
  .isafe-home-hero { grid-template-columns: 1fr; }
  .home-explainer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .direct-intake-form { grid-template-columns: 1fr; }
  .direct-intake-form .wide { grid-column: auto; }
  .direct-intake-actions { align-items: stretch; flex-direction: column; }
  .isafe-home-copy h2 { font-size: 34px; }
}

.change-order-list { display: grid; gap: 12px; margin-top: 16px; }
.change-order-card { border: 1px solid #d9d7d2; padding: 16px; background: #fff; }
.change-order-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.change-order-card h4 { margin: 4px 0 0; font-size: 17px; }
.change-order-card header > strong { font-size: 13px; color: #996000; }
.change-order-card.is-locked { background: #f3f5f2; border-color: #b9c8ba; }
.change-order-card.is-locked header > strong { color: #286139; }
.change-order-facts, .change-order-files { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 10px 0; }
.change-order-facts span { font-weight: 700; }
.change-order-card .change-payment-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid #e3e1dc; }
@media (max-width: 720px) { .change-order-card header { flex-direction: column; } }
.payment-checklist-section { margin-top: 18px; }
.payment-checklist-section h3 { margin: 0 0 10px; font-size: 18px; }
.payment-execution-row { grid-template-columns: 36px minmax(220px, 1fr) minmax(110px, auto) minmax(110px, auto) auto; }
.proof-icon-list { display: grid; gap: 10px; margin-top: 14px; }
.proof-icon-item { display: grid; grid-template-columns: 36px 1fr 40px; align-items: center; gap: 12px; padding: 12px; border: 1px solid #d9d7d2; background: #fff; }
.proof-icon-item div { display: grid; gap: 3px; }
.proof-status-icon { display: grid; place-items: center; width: 30px; height: 30px; background: #e8f3ea; color: #286139; font-weight: 800; }
@media (max-width: 760px) { .payment-execution-row { grid-template-columns: 32px 1fr; } .payment-execution-row .party-confirmation, .payment-execution-row button { grid-column: 2; } }