:root {
  color-scheme: light;
  --page: #f3f6f4;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --surface-strong: #edf2ef;
  --ink: #17231e;
  --text: #28352f;
  --muted: #66736d;
  --subtle: #8b9691;
  --border: #dce4df;
  --border-strong: #c8d3cd;
  --primary: #167553;
  --primary-dark: #0f5e42;
  --primary-soft: #e5f3ec;
  --blue: #2f67af;
  --blue-soft: #eaf1fa;
  --amber: #a85f16;
  --amber-soft: #fff2de;
  --red: #ae3f3f;
  --red-dark: #8f3030;
  --red-soft: #faeaea;
  --violet: #6655a4;
  --violet-soft: #f0edfa;
  --sidebar: #17231e;
  --sidebar-muted: #9eafa6;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(20, 36, 28, 0.08);
  --sidebar-width: 252px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
dialog:focus-visible {
  outline: 3px solid rgba(47, 103, 175, 0.24);
  outline-offset: 2px;
}

a {
  color: inherit;
}

img {
  display: block;
}

[hidden] {
  display: none !important;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-direction: column;
  overflow-y: auto;
  background: var(--sidebar);
  color: #f7faf8;
  border-right: 1px solid #26362f;
}

.brand {
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  color: #ffffff;
  text-decoration: none;
  border-bottom: 1px solid #2a3b33;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  background: #d7efe3;
  border-radius: var(--radius-sm);
}

.brand-mark img {
  width: 21px;
  height: 21px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.3;
}

.brand small {
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 11px;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  padding: 16px 12px;
}

.nav-label {
  margin: 14px 10px 5px;
  color: var(--sidebar-muted);
  font-size: 11px;
}

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

.sidebar-nav a {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: #d5dfda;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}

.sidebar-nav a:hover {
  background: #22332b;
  color: #ffffff;
}

.sidebar-nav a.active {
  background: #293c33;
  color: #ffffff;
  border-color: #3b5147;
}

.sidebar-nav img {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  filter: invert(91%) sepia(8%) saturate(140%) hue-rotate(95deg) brightness(96%);
}

.sidebar-nav .nav-trailing {
  width: 14px;
  height: 14px;
  margin-left: auto;
  opacity: 0.65;
}

.sidebar-foot {
  margin: 12px;
  padding: 14px;
  background: #1e2e27;
  border: 1px solid #31443b;
  border-radius: var(--radius);
}

.sidebar-foot p {
  margin: 10px 0 0;
  color: var(--sidebar-muted);
  font-size: 11px;
  line-height: 1.6;
}

.sidebar-fact {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  font-size: 12px;
}

.signal {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--subtle);
}

.signal-green {
  background: #4fb987;
}

.signal-amber {
  background: #e2a64f;
}

.signal-red {
  background: #dd6666;
}

.signal-blue {
  background: #5d91d5;
}

.signal-gray {
  background: var(--subtle);
}

.app-shell {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 24;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px clamp(20px, 3vw, 42px);
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 1px 0 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.3;
}

.eyebrow {
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
}

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

.connection-state {
  display: flex;
  min-width: 92px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button {
  min-height: 38px;
  gap: 8px;
  padding: 8px 13px;
  font-weight: 650;
}

.button img,
.icon-button img {
  width: 17px;
  height: 17px;
}

.button:hover,
.icon-button:hover {
  background: var(--surface-muted);
  border-color: #aebdb5;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.button-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.button-danger {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

.button-danger:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.button-primary img,
.button-danger img {
  filter: brightness(0) invert(1);
}

.button-secondary {
  background: var(--surface);
}

.button-full {
  width: 100%;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  padding: 0;
}

.mobile-menu {
  display: none;
}

.disclosure-bar {
  position: sticky;
  top: 76px;
  z-index: 22;
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 8px clamp(20px, 3vw, 42px);
  background: #fff7e8;
  color: #694310;
  border-bottom: 1px solid #efd9af;
  font-size: 12px;
}

.disclosure-bar > img {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.disclosure-bar > span:not(.disclosure-facts) {
  min-width: 0;
}

.disclosure-facts {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  margin-left: auto;
}

.disclosure-facts span {
  padding: 2px 6px;
  background: #ffffff;
  color: #72501d;
  border: 1px solid #e7c98e;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.main-content {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 10px clamp(20px, 3vw, 42px) 60px;
}

.section-block {
  scroll-margin-top: 142px;
  padding: 30px 0;
  border-bottom: 1px solid var(--border);
}

.section-block:last-child {
  border-bottom: 0;
}

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

.section-heading.compact {
  align-items: center;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 3px 0 5px;
  color: var(--ink);
  font-size: 21px;
  line-height: 1.35;
}

.section-heading p,
.panel-heading p {
  margin: 0;
  color: var(--muted);
}

.task-identity {
  display: grid;
  min-width: 270px;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.task-identity strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 650;
}

.task-identity > span:only-child {
  grid-column: 1 / -1;
  align-self: center;
}

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

.metric-card {
  min-height: 116px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.metric-card .metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.metric-card .metric-head img {
  width: 17px;
  height: 17px;
  opacity: 0.62;
}

.metric-card strong {
  display: block;
  margin-top: 12px;
  color: var(--ink);
  font-size: 27px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.metric-card small {
  color: var(--muted);
}

.skeleton-card {
  background: var(--surface-strong);
  border-color: transparent;
}

.workspace-grid,
.safety-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-heading {
  display: flex;
  min-height: 68px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h3 {
  margin: 0 0 2px;
  color: var(--ink);
  font-size: 14px;
}

.panel-heading p {
  font-size: 11px;
}

.status-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.status-neutral {
  background: var(--surface-muted);
  color: var(--muted);
}

.status-running,
.status-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-pending,
.status-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-approved,
.status-low,
.status-allow {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.status-rejected,
.status-high,
.status-block,
.status-failed {
  background: var(--red-soft);
  color: var(--red-dark);
}

.status-medium {
  background: var(--violet-soft);
  color: var(--violet);
}

.data-list {
  padding: 2px 16px;
}

.data-row {
  display: grid;
  min-height: 58px;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

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

.file-icon,
.human-review-icon,
.login-icon {
  display: grid;
  place-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.file-icon {
  width: 34px;
  height: 34px;
}

.file-icon img {
  width: 17px;
  height: 17px;
}

.data-name {
  min-width: 0;
}

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

.data-name strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-name small,
.data-meta {
  color: var(--muted);
  font-size: 11px;
}

.empty-inline {
  padding: 25px 0;
  color: var(--muted);
  text-align: center;
}

.task-summary {
  min-height: 176px;
  padding: 16px;
}

.empty-task {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

.empty-task > img {
  width: 34px;
  height: 34px;
  opacity: 0.56;
}

.empty-task strong {
  color: var(--text);
}

.empty-task p {
  margin: 3px 0 0;
}

.summary-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.summary-stat {
  min-height: 62px;
  padding: 9px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.summary-stat small,
.summary-stat strong {
  display: block;
}

.summary-stat small {
  color: var(--muted);
  font-size: 10px;
}

.summary-stat strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 13px;
}

.summary-prompt {
  margin: 0;
  padding-top: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.execution-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.85fr);
  gap: 16px;
}

.agent-panel,
.pipeline-panel {
  min-height: 590px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.live-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--subtle);
}

.live-indicator.connected {
  color: var(--primary-dark);
}

.live-indicator.connected span {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(22, 117, 83, 0.12);
}

.message-feed {
  height: 520px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}

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

.message-row.user-message {
  background: #f8f6ef;
}

.message-avatar {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  background: var(--primary-soft);
  border: 1px solid #c6e0d3;
  border-radius: var(--radius-sm);
}

.user-message .message-avatar {
  background: var(--amber-soft);
  border-color: #edd2a3;
}

.message-avatar img {
  width: 18px;
  height: 18px;
}

.message-body {
  min-width: 0;
}

.message-author {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.message-body p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
}

.message-row time {
  color: var(--subtle);
  font-size: 10px;
  white-space: nowrap;
}

.pipeline {
  margin: 0;
  padding: 7px 16px 12px;
  list-style: none;
}

.pipeline-step {
  position: relative;
  display: grid;
  min-height: 61px;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 10px 0;
}

.pipeline-step::after {
  position: absolute;
  top: 39px;
  bottom: -10px;
  left: 13px;
  width: 1px;
  background: var(--border);
  content: "";
}

.pipeline-step:last-child::after {
  display: none;
}

.pipeline-step > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  background: var(--surface-muted);
  color: var(--subtle);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
}

.pipeline-step strong,
.pipeline-step small {
  display: block;
}

.pipeline-step strong {
  color: var(--text);
  font-size: 12px;
}

.pipeline-step small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.pipeline-step.complete > span {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.pipeline-step.active > span {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(47, 103, 175, 0.12);
}

.pipeline-step.pending > span {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #ddbd84;
}

.pipeline-step.failed > span {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

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

.review-card .review-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.review-card .review-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.rule-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.rule-table th,
.rule-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.rule-table tr:last-child td {
  border-bottom: 0;
}

.rule-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.rule-result {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

.rule-result.hit {
  color: var(--red-dark);
  font-weight: 700;
}

.rule-result img {
  width: 14px;
  height: 14px;
}

.empty-panel,
.empty-state {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-panel {
  grid-column: 1 / -1;
}

.empty-panel > img,
.empty-state > img {
  width: 30px;
  height: 30px;
  margin-bottom: 10px;
  opacity: 0.52;
}

.empty-panel strong,
.empty-state strong {
  color: var(--text);
}

.empty-panel p,
.empty-state p {
  max-width: 460px;
  margin: 4px 0 0;
}

.compact-empty {
  min-height: 150px;
}

.artifact-panel {
  overflow: hidden;
}

.artifact-row {
  display: grid;
  min-height: 60px;
  grid-template-columns: minmax(230px, 1.4fr) minmax(150px, 0.7fr) 80px minmax(150px, 0.9fr) 84px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

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

.artifact-header {
  min-height: 38px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.artifact-name {
  display: grid;
  min-width: 0;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.artifact-name strong,
.artifact-name small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-name strong {
  color: var(--ink);
  font-size: 12px;
}

.artifact-name small,
.artifact-size,
.artifact-hash {
  color: var(--muted);
  font-size: 10px;
}

.artifact-hash {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.artifact-labels span {
  padding: 2px 5px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid #bddccc;
  border-radius: 4px;
  font-size: 9px;
}

.artifact-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.artifact-actions .icon-button {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.human-review-band {
  display: grid;
  min-height: 112px;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 18px 20px;
  background: #f6f2e9;
  border-top: 1px solid #dfd4bd;
  border-bottom: 1px solid #dfd4bd;
}

.human-review-icon {
  width: 46px;
  height: 46px;
  background: #ffffff;
  border-color: #dfd4bd;
}

.human-review-icon img {
  width: 22px;
  height: 22px;
}

.human-review-band h3 {
  margin: 2px 0 2px;
  color: var(--ink);
  font-size: 15px;
}

.human-review-band p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.safety-form {
  padding: 16px;
}

label {
  display: block;
  margin: 0 0 7px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

input {
  height: 42px;
  padding: 8px 11px;
}

textarea {
  min-height: 120px;
  padding: 10px 11px;
  line-height: 1.65;
  resize: vertical;
}

input:hover,
textarea:hover {
  border-color: #a8b7af;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.safety-result {
  min-height: 236px;
}

.safety-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.safety-result-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.safety-result-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.site-footer {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(20px, 3vw, 42px);
  background: var(--surface);
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.metadata-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 40px));
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metadata-dialog::backdrop {
  background: rgba(13, 23, 18, 0.58);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.dialog-heading h2 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 18px;
}

.metadata-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.metadata-summary span {
  padding: 3px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
}

.metadata-dialog pre {
  max-height: 520px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #24312b;
  background: #f7f9f8;
  font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  gap: 8px;
}

.toast {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  padding: 12px 13px;
  background: var(--ink);
  color: #ffffff;
  border: 1px solid #35443d;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 12px;
}

.toast img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.toast button {
  padding: 0;
  background: transparent;
  color: #ffffff;
  border: 0;
  cursor: pointer;
}

.toast.error {
  background: #742f2f;
  border-color: #934242;
}

/* Review workspace */
.review-content {
  min-height: calc(100vh - 184px);
}

.login-section {
  display: grid;
  min-height: calc(100vh - 250px);
  place-items: center;
  padding: 32px 0;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  background: var(--primary-soft);
  border-color: #c1ddcf;
}

.login-icon img {
  width: 21px;
  height: 21px;
}

.login-panel h2 {
  margin: 3px 0 5px;
  color: var(--ink);
  font-size: 22px;
}

.login-panel > p {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-panel form > .button {
  margin-top: 14px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-field .icon-button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 38px;
  height: 38px;
  border-color: transparent;
}

.form-error {
  min-height: 20px;
  margin: 9px 0 0;
  color: var(--red-dark);
  font-size: 11px;
}

.review-workspace {
  padding-top: 20px;
}

.review-heading {
  align-items: flex-end;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.segmented-control button {
  min-width: 68px;
  min-height: 30px;
  padding: 4px 9px;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(24, 41, 32, 0.1);
  font-weight: 700;
}

.review-layout {
  display: grid;
  min-height: 660px;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
}

.review-queue,
.review-detail {
  min-height: 660px;
  overflow: hidden;
}

.task-list {
  max-height: 590px;
  overflow-y: auto;
}

.task-list-item {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 18px;
  gap: 10px;
  padding: 14px 15px;
  background: transparent;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
}

.task-list-item:hover {
  background: var(--surface-muted);
}

.task-list-item.selected {
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.task-list-item > img {
  width: 17px;
  height: 17px;
  align-self: center;
  opacity: 0.52;
}

.task-list-item strong,
.task-list-item small {
  display: block;
}

.task-list-item strong {
  overflow: hidden;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-list-item small {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 10px;
}

.task-list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.review-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.review-detail-head h2 {
  margin: 2px 0 4px;
  color: var(--ink);
  font-size: 18px;
}

.review-detail-head p {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

.review-evidence-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.evidence-cell {
  min-height: 78px;
  padding: 13px 15px;
  border-right: 1px solid var(--border);
}

.evidence-cell:last-child {
  border-right: 0;
}

.evidence-cell small,
.evidence-cell strong {
  display: block;
}

.evidence-cell small {
  color: var(--muted);
  font-size: 10px;
}

.evidence-cell strong {
  margin-top: 5px;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.review-section {
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}

.review-section:last-child {
  border-bottom: 0;
}

.review-section h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
}

.review-section > p {
  margin: 0;
  color: var(--muted);
}

.evidence-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
}

.evidence-row {
  display: grid;
  min-height: 44px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

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

.evidence-row small {
  color: var(--muted);
  font-size: 9px;
}

.review-form {
  padding: 18px 20px 20px;
  background: #f8f6ef;
}

.review-form h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 14px;
}

.review-form > p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
}

.review-form-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.65fr) minmax(0, 1.35fr);
  gap: 14px;
}

.decision-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.decision-button {
  min-height: 43px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
}

.decision-button[data-decision="approve"][aria-pressed="true"] {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: var(--primary);
}

.decision-button[data-decision="reject"][aria-pressed="true"] {
  background: var(--red-soft);
  color: var(--red-dark);
  border-color: var(--red);
}

.review-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.review-submit-row p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.completed-review {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 13px;
  padding: 17px 20px;
  background: var(--primary-soft);
  border-top: 1px solid #c6dfd2;
}

.completed-review.rejected {
  background: var(--red-soft);
  border-color: #e2bcbc;
}

.completed-review > img {
  width: 32px;
  height: 32px;
}

.completed-review h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 14px;
}

.completed-review p {
  margin: 2px 0;
  color: var(--text);
  font-size: 11px;
}

.completed-review small {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .connection-state {
    display: none;
  }

  .artifact-row {
    grid-template-columns: minmax(210px, 1.3fr) minmax(130px, 0.7fr) 70px minmax(110px, 0.7fr) 82px;
  }

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

  .evidence-cell:nth-child(2) {
    border-right: 0;
  }

  .evidence-cell:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 980px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 16px 0 40px rgba(10, 20, 15, 0.24);
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(13, 23, 18, 0.5);
  }

  body.sidebar-open .sidebar-scrim {
    display: block !important;
  }

  .app-shell {
    margin-left: 0;
  }

  .mobile-menu {
    position: fixed;
    top: 18px;
    left: 14px;
    z-index: 32;
    display: inline-flex;
  }

  .topbar {
    padding-left: 64px;
  }

  .disclosure-bar {
    padding-left: 20px;
  }

  .execution-grid,
  .workspace-grid,
  .safety-grid {
    grid-template-columns: 1fr;
  }

  .agent-panel,
  .pipeline-panel {
    min-height: auto;
  }

  .message-feed {
    height: 440px;
  }

  .review-layout {
    grid-template-columns: 290px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 70px;
    padding-top: 10px;
    padding-right: 14px;
    padding-bottom: 10px;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .button-secondary {
    width: 38px;
    padding: 0;
  }

  .topbar-actions .button-secondary span {
    display: none;
  }

  .topbar-actions .button-primary {
    min-height: 38px;
    padding: 8px 10px;
  }

  .disclosure-bar {
    top: 70px;
    align-items: flex-start;
    padding: 8px 14px;
  }

  .disclosure-bar > span:not(.disclosure-facts) {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .disclosure-facts {
    display: none;
  }

  .main-content {
    padding-right: 14px;
    padding-left: 14px;
  }

  .section-block {
    scroll-margin-top: 132px;
    padding: 24px 0;
  }

  .section-heading,
  .section-heading.compact,
  .review-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .task-identity {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

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

  .metric-card {
    min-height: 104px;
    padding: 13px;
  }

  .metric-card strong {
    font-size: 23px;
  }

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

  .artifact-header {
    display: none;
  }

  .artifact-row:not(.artifact-header) {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 13px;
  }

  .artifact-name {
    grid-column: 1;
  }

  .artifact-labels {
    grid-column: 1;
  }

  .artifact-size,
  .artifact-hash {
    display: none;
  }

  .artifact-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .human-review-band {
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 16px;
  }

  .human-review-band .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .button {
    width: 100%;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    padding: 16px 14px;
  }

  .review-layout {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .review-queue,
  .review-detail {
    min-height: auto;
  }

  .task-list {
    max-height: 320px;
  }

  .review-form-grid {
    grid-template-columns: 1fr;
  }

  .review-submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .review-submit-row .button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .topbar .eyebrow {
    display: none;
  }

  .topbar-actions .button-primary span {
    display: none;
  }

  .topbar-actions .button-primary {
    width: 38px;
    padding: 0;
  }

  .disclosure-bar strong {
    display: none;
  }

  .data-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
  }

  .data-row .data-meta:first-of-type {
    display: none;
  }

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

  .message-row {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 9px;
    padding: 13px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
  }

  .message-row time {
    grid-column: 2;
  }

  .rule-table th:nth-child(2),
  .rule-table td:nth-child(2) {
    display: none;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    min-width: 0;
  }

  .review-evidence-grid {
    grid-template-columns: 1fr;
  }

  .evidence-cell,
  .evidence-cell:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .evidence-cell:last-child {
    border-bottom: 0;
  }

  .decision-control {
    grid-template-columns: 1fr;
  }
}

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