.ra-workbench {
  --ra-paper: #fffefa;
  --ra-paper-soft: #f7f7f2;
  --ra-ink: #17231f;
  --ra-muted: #69746e;
  --ra-line: #d8ded9;
  --ra-green: #145f49;
  --ra-green-soft: #e8f3ee;
  --ra-blue: #245b78;
  --ra-blue-soft: #e9f2f7;
  --ra-amber: #8b5b10;
  --ra-amber-soft: #fbf0d9;
  --ra-red: #a84234;
  --ra-red-soft: #faeae6;
  color: var(--ra-ink);
}

.ra-workbench *,
.ra-workbench *::before,
.ra-workbench *::after {
  box-sizing: border-box;
}

.ra-loading,
.ra-empty {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 36px;
  color: var(--ra-muted);
  background: var(--ra-paper);
  border: 1px solid var(--ra-line);
  border-radius: 12px;
  text-align: center;
}

.ra-loading strong,
.ra-empty strong {
  color: var(--ra-ink);
}

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

.ra-eyebrow {
  margin: 0 0 5px;
  color: var(--ra-green);
  font-size: 12px;
  font-weight: 760;
}

.ra-topbar h3 {
  margin: 0;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(25px, 2.3vw, 34px);
  line-height: 1.2;
}

.ra-topbar p {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--ra-muted);
  font-size: 13px;
}

.ra-role {
  min-width: 196px;
  display: grid;
  gap: 5px;
  padding: 9px 11px;
  background: var(--ra-paper);
  border: 1px solid var(--ra-line);
  border-radius: 8px;
}

.ra-role span {
  color: var(--ra-muted);
  font-size: 10px;
}

.ra-role select {
  min-height: 28px;
  color: var(--ra-ink);
  background: transparent;
  border: 0;
  font-weight: 720;
}

.ra-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ra-metric {
  min-height: 104px;
  padding: 15px;
  background: var(--ra-paper);
  border: 1px solid var(--ra-line);
  border-top: 3px solid #bdc7c0;
  border-radius: 9px;
}

.ra-metric--urgent { border-top-color: var(--ra-red); }
.ra-metric--system { border-top-color: var(--ra-blue); }
.ra-metric--done { border-top-color: var(--ra-green); }

.ra-metric-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--ra-muted);
  font-size: 11px;
}

.ra-metric-value {
  margin-top: 8px;
  font-size: 29px;
  line-height: 1;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.ra-metric-value small {
  margin-left: 4px;
  color: var(--ra-muted);
  font-size: 11px;
  font-weight: 500;
}

.ra-metric-note {
  margin-top: 8px;
  color: var(--ra-muted);
  font-size: 10px;
}

.ra-coverage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--ra-amber-soft);
  border: 1px solid #e5cfa3;
  border-left: 4px solid var(--ra-amber);
  border-radius: 9px;
}

.ra-coverage--complete {
  background: var(--ra-green-soft);
  border-color: #bdd9cc;
  border-left-color: var(--ra-green);
}

.ra-coverage--repairing {
  background: #fff6de;
  border-color: #dfbd73;
  border-left-color: #a56f12;
}

.ra-coverage--escalated {
  background: #fff0ed;
  border-color: #e1aaa1;
  border-left-color: var(--ra-red);
}

.ra-coverage-title {
  font-weight: 760;
}

.ra-coverage-copy {
  margin-top: 2px;
  color: var(--ra-muted);
  font-size: 11px;
}

.ra-sync-status {
  padding: 5px 8px;
  color: var(--ra-muted);
  background: rgb(255 255 255 / 70%);
  border: 1px solid rgb(31 54 44 / 12%);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 720;
  white-space: nowrap;
}

.ra-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  color: var(--ra-ink);
  background: var(--ra-paper);
  border: 1px solid #bbc6be;
  border-radius: 6px;
  font-weight: 680;
}

.ra-button:hover { border-color: #788d81; }
.ra-button:disabled { cursor: not-allowed; opacity: .45; }
.ra-button--primary { color: #fff; background: var(--ra-green); border-color: var(--ra-green); }
.ra-button--readonly { color: var(--ra-blue); background: var(--ra-blue-soft); border-color: #b9d2de; }
.ra-button--danger { color: #fff; background: var(--ra-red); border-color: var(--ra-red); }
.ra-button--small { min-height: 32px; padding: 5px 9px; font-size: 11px; }

.ra-workgrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.ra-panel,
.ra-rail-card,
.ra-diagnostics {
  background: var(--ra-paper);
  border: 1px solid var(--ra-line);
  border-radius: 9px;
}

.ra-panel {
  min-width: 0;
  overflow: hidden;
}

.ra-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ra-line);
}

.ra-tabs {
  display: flex;
  overflow-x: auto;
}

.ra-tab {
  position: relative;
  min-height: 38px;
  padding: 7px 11px;
  color: var(--ra-muted);
  background: transparent;
  border: 0;
  white-space: nowrap;
  font-weight: 680;
}

.ra-tab.is-active { color: var(--ra-ink); }
.ra-tab.is-active::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: -10px;
  left: 10px;
  height: 2px;
  background: var(--ra-green);
}

.ra-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  margin-left: 4px;
  padding: 0 5px;
  color: var(--ra-muted);
  background: var(--ra-paper-soft);
  border-radius: 8px;
  font-size: 9px;
}

.ra-panel-help {
  color: var(--ra-muted);
  font-size: 10px;
}

.ra-filters {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--ra-paper-soft);
  border-bottom: 1px solid var(--ra-line);
}

.ra-search,
.ra-filter,
.ra-field input,
.ra-field textarea {
  min-height: 34px;
  padding: 7px 9px;
  color: var(--ra-ink);
  background: #fff;
  border: 1px solid var(--ra-line);
  border-radius: 5px;
}

.ra-search { min-width: 0; flex: 1; }

.ra-case-row {
  display: grid;
  grid-template-columns: 48px minmax(130px, 1fr) minmax(125px, .9fr) minmax(155px, 1.15fr) 96px;
  gap: 11px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--ra-line);
}

.ra-case-row:last-child { border-bottom: 0; }
.ra-case-row:hover { background: #fbfbf7; }
.ra-case-row > * { min-width: 0; }

.ra-thumb {
  width: 45px;
  height: 56px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #315044;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 760;
  text-align: center;
}

.ra-case-name {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 3px;
  font-weight: 760;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ra-case-meta,
.ra-reason-detail,
.ra-state-next {
  color: var(--ra-muted);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.ra-reason {
  display: -webkit-box;
  overflow: hidden;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 680;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ra-state {
  min-width: 0;
  padding-left: 10px;
  border-left: 2px solid var(--ra-line);
}

.ra-state--red { border-left-color: var(--ra-red); }
.ra-state--blue { border-left-color: var(--ra-blue); }
.ra-state--green { border-left-color: var(--ra-green); }
.ra-state--amber { border-left-color: var(--ra-amber); }

.ra-state-title {
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.ra-row-action { text-align: right; }

.ra-rail {
  display: grid;
  gap: 11px;
}

.ra-rail-card {
  padding: 14px;
}

.ra-rail-card h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

.ra-rail-card > p {
  margin: 0;
  color: var(--ra-muted);
  font-size: 10px;
}

.ra-journey {
  display: grid;
  margin-top: 12px;
}

.ra-journey-step {
  position: relative;
  min-height: 45px;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
}

.ra-journey-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 0;
  left: 7px;
  width: 1px;
  background: #c2ccc5;
}

.ra-journey-dot {
  position: relative;
  z-index: 1;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ra-blue);
  border-radius: 50%;
  font-size: 8px;
}

.ra-journey-step strong,
.ra-legend strong {
  display: block;
  font-size: 10px;
}

.ra-journey-step span,
.ra-legend span {
  color: var(--ra-muted);
  font-size: 9px;
}

.ra-legend {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.ra-legend > div {
  padding-top: 7px;
  border-top: 1px solid var(--ra-line);
}

.ra-diagnostics summary {
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 11px 13px;
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  font-weight: 720;
}

.ra-diagnostics summary::-webkit-details-marker { display: none; }
.ra-diag-count { color: var(--ra-amber); font-size: 9px; }
.ra-diag-list { padding: 0 13px 12px; }
.ra-diag-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--ra-line);
  font-size: 10px;
}
.ra-diag-row span { color: var(--ra-muted); }

.ra-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  background: rgba(12, 24, 19, .48);
}

.ra-overlay.is-open { display: block; }
.ra-overlay--modal.is-open { display: grid; place-items: center; padding: 16px; }

.ra-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(580px, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--ra-paper);
  box-shadow: -22px 0 46px rgba(9, 25, 18, .2);
}

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

.ra-drawer-head h4,
.ra-modal h4 {
  margin: 0;
  font-size: 18px;
}

.ra-drawer-head p,
.ra-modal-head p {
  margin: 4px 0 0;
  color: var(--ra-muted);
  font-size: 10px;
}

.ra-close {
  width: 34px;
  height: 34px;
  color: var(--ra-muted);
  background: transparent;
  border: 1px solid var(--ra-line);
  border-radius: 6px;
  font-size: 20px;
}

.ra-drawer-body {
  flex: 1;
  padding: 16px 18px 90px;
  overflow-y: auto;
}

.ra-drawer-footer {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  background: rgba(255, 254, 250, .96);
  border-top: 1px solid var(--ra-line);
}

.ra-identity {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ra-line);
}

.ra-identity .ra-thumb {
  width: 60px;
  height: 74px;
}

.ra-identity h5 {
  margin: 0 0 7px;
  font-size: 15px;
}

.ra-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.ra-chip {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 6px;
  color: var(--ra-muted);
  background: var(--ra-paper-soft);
  border: 1px solid var(--ra-line);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 680;
}
.ra-chip--red { color: var(--ra-red); background: var(--ra-red-soft); border-color: #ecc3bb; }
.ra-chip--blue { color: var(--ra-blue); background: var(--ra-blue-soft); border-color: #c5dbe5; }
.ra-chip--green { color: var(--ra-green); background: var(--ra-green-soft); border-color: #bcd8cc; }
.ra-chip--amber { color: var(--ra-amber); background: var(--ra-amber-soft); border-color: #e6cea0; }

.ra-detail-section {
  margin-top: 16px;
}

.ra-detail-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 760;
}

.ra-evidence,
.ra-decision {
  padding: 11px;
  background: var(--ra-paper-soft);
  border: 1px solid var(--ra-line);
  border-radius: 6px;
}

.ra-evidence dl {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 7px;
  margin: 0;
  font-size: 10px;
}

.ra-evidence dt { color: var(--ra-muted); }
.ra-evidence dd { margin: 0; overflow-wrap: anywhere; }

.ra-decision {
  border-left: 4px solid var(--ra-blue);
}
.ra-decision--red { background: var(--ra-red-soft); border-color: #e9c5be; border-left-color: var(--ra-red); }
.ra-decision--blue { background: var(--ra-blue-soft); border-color: #c8dce6; border-left-color: var(--ra-blue); }
.ra-decision--green { background: var(--ra-green-soft); border-color: #c4dbd1; border-left-color: var(--ra-green); }
.ra-decision--amber { background: var(--ra-amber-soft); border-color: #ead6ad; border-left-color: var(--ra-amber); }
.ra-decision strong { display: block; margin-bottom: 3px; font-size: 11px; }
.ra-decision p { margin: 0; color: var(--ra-muted); font-size: 10px; }

.ra-field {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}
.ra-field label { font-size: 10px; font-weight: 720; }
.ra-field textarea { width: 100%; min-height: 84px; resize: vertical; }
.ra-field-help { color: var(--ra-muted); font-size: 9px; }

.ra-timeline {
  display: grid;
}

.ra-timeline-item {
  position: relative;
  min-height: 52px;
  display: grid;
  grid-template-columns: 17px 1fr;
  gap: 8px;
}

.ra-timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 0;
  left: 7px;
  width: 1px;
  background: #c5cec8;
}

.ra-timeline-dot {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  background: var(--ra-paper);
  border: 3px solid #bfc9c2;
  border-radius: 50%;
}
.ra-timeline-item.is-done .ra-timeline-dot { border-color: var(--ra-green); }
.ra-timeline-item.is-active .ra-timeline-dot { border-color: var(--ra-blue); }
.ra-timeline-item strong { display: block; font-size: 10px; }
.ra-timeline-item span { color: var(--ra-muted); font-size: 9px; }

.ra-modal {
  width: min(540px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--ra-paper);
  border: 1px solid var(--ra-line);
  border-radius: 9px;
  box-shadow: 0 18px 55px rgba(8, 22, 16, .24);
}

.ra-modal-head,
.ra-modal-body,
.ra-modal-actions {
  padding: 15px 18px;
}

.ra-modal-head { border-bottom: 1px solid var(--ra-line); }
.ra-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--ra-line);
}

.ra-target-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--ra-line);
  border-radius: 6px;
}

.ra-target-list li {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--ra-line);
  font-size: 10px;
}
.ra-target-list li:last-child { border-bottom: 0; }
.ra-target-list span { color: var(--ra-muted); }

.ra-confirm {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  background: var(--ra-red-soft);
  border: 1px solid #e9c7c0;
  border-radius: 6px;
  font-size: 10px;
}

.ra-confirm input { width: 17px; height: 17px; margin: 0; }

.ra-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: none;
  max-width: 360px;
  padding: 11px 13px;
  color: #fff;
  background: #1b2923;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(7, 20, 14, .22);
  font-size: 11px;
}
.ra-toast.is-showing { display: block; }

@media (max-width: 1180px) {
  .ra-workgrid { grid-template-columns: 1fr; }
  .ra-rail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ra-case-row { grid-template-columns: 44px minmax(150px, 1fr) minmax(190px, 1.2fr) 98px; }
  .ra-reason-col { display: none; }
}

@media (max-width: 760px) {
  .ra-topbar { display: block; }
  .ra-role { width: 100%; margin-top: 12px; }
  .ra-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ra-metric { min-height: 96px; padding: 12px; }
  .ra-coverage { grid-template-columns: 1fr; }
  .ra-sync-status { width: max-content; }
  .ra-rail { display: none; }
  .ra-panel-head { display: block; padding: 8px 9px 0; }
  .ra-tabs { width: 100%; }
  .ra-tab { min-width: max-content; flex: 1; padding: 9px 7px; }
  .ra-tab.is-active::after { bottom: 0; }
  .ra-panel-help { padding: 5px 2px 8px; }
  .ra-filters { padding: 8px 9px; }
  .ra-filter { width: 106px; }
  .ra-case-row {
    grid-template-columns: 43px minmax(0, 1fr);
    gap: 9px;
    padding: 12px 9px;
  }
  .ra-reason-col { display: block; grid-column: 2; }
  .ra-state { grid-column: 2; }
  .ra-row-action { grid-column: 2; text-align: left; }
  .ra-row-action .ra-button { width: 100%; min-height: 42px; }
  .ra-drawer { width: 100%; }
  .ra-drawer-head { padding: 13px; }
  .ra-drawer-body { padding: 13px 13px 94px; }
  .ra-drawer-footer { padding: 10px 13px; }
  .ra-drawer-footer .ra-button { flex: 1; min-height: 42px; }
  .ra-overlay--modal { padding: 9px; }
  .ra-modal { max-height: calc(100vh - 18px); }
  .ra-modal-actions { flex-direction: column-reverse; }
  .ra-modal-actions .ra-button { width: 100%; min-height: 42px; }
  .ra-toast { right: 12px; bottom: 82px; left: 12px; max-width: none; }
}
