:root {
  color-scheme: light;
  --bg: #f7f4fb;
  --surface: rgba(255, 255, 255, .8);
  --card: rgba(255, 255, 255, .92);
  --text: #292536;
  --muted: #787184;
  --line: rgba(92, 78, 116, .13);
  --primary: #b8a7d9;
  --primary-strong: #74639a;
  --gold: #d7c8ec;
  --ink: #191522;
  --danger: #c2413d;
  --shadow: 0 24px 70px rgba(72, 55, 105, .11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 8%, rgba(196, 181, 225, .38), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(170, 150, 210, .24), transparent 26%),
    linear-gradient(135deg, #fffbff 0%, #f1edf8 48%, #faf7fd 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 22px;
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(255, 255, 255, .62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(145deg, var(--primary), var(--gold));
  box-shadow: 0 14px 30px rgba(116, 99, 154, .2);
}

.brand h1, .topbar h2, .panel-title h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.muted {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  color: #544e61;
  background: transparent;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  color: var(--primary-strong);
  background: rgba(184, 167, 217, .18);
  border-color: rgba(116, 99, 154, .14);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  gap: 8px 10px;
}

.sidebar-identity {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-top: 2px;
  padding: 1px 2px 0;
  color: rgba(84, 78, 97, .64);
  font-size: 12px;
  line-height: 1.4;
}

.sidebar-identity span,
.sidebar-identity strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-identity strong {
  color: rgba(116, 99, 154, .72);
  font-weight: 700;
}

.sidebar-footer #logoutButton {
  flex: 1;
}

.settings-nav {
  flex: none;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 16px;
  color: var(--primary-strong);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(116, 99, 154, .14);
  font-size: 20px;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 10px 20px rgba(72, 55, 105, .14);
  font-size: 22px;
  line-height: 1;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255,255,255,.82), rgba(246,241,252,.78));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card,
.card {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(520px, 100%);
  padding: 28px;
}

.mfa-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(116, 99, 154, .14);
  border-radius: 20px;
  background: rgba(255, 255, 255, .62);
}

.mfa-panel h3 {
  margin: 0;
}

.mfa-panel input[readonly] {
  color: #4d4560;
  background: rgba(247, 244, 251, .9);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.card {
  padding: 20px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 8px 0 16px;
}

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

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

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

.toolbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.order-workbench {
  display: grid;
  grid-template-columns: minmax(320px, .82fr) minmax(0, 1.45fr);
  gap: 16px;
  margin-top: 16px;
}

.split-workbench {
  display: grid;
  grid-template-columns: minmax(320px, .82fr) minmax(0, 1.45fr);
  gap: 16px;
}

.settings-workbench {
  display: grid;
  grid-template-columns: minmax(220px, .34fr) minmax(0, 1.66fr);
  gap: 16px;
}

.knowledge-workbench {
  display: grid;
  grid-template-columns: minmax(230px, .36fr) minmax(0, 1.64fr);
  gap: 16px;
}

.knowledge-space-card,
.knowledge-content-card {
  min-height: 640px;
}

.knowledge-space-list,
.knowledge-document-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.knowledge-space-item,
.knowledge-document-row {
  width: 100%;
  border: 1px solid rgba(92, 78, 116, .1);
  background: rgba(255,255,255,.56);
  color: var(--text);
  text-align: left;
  border-radius: 15px;
  cursor: pointer;
}

.knowledge-space-item {
  display: grid;
  gap: 4px;
  padding: 13px;
}

.knowledge-space-item.active,
.knowledge-space-item:hover,
.knowledge-document-row:hover {
  background: rgba(184, 167, 217, .16);
  border-color: rgba(116, 99, 154, .24);
}

.knowledge-space-item span,
.knowledge-space-item em,
.knowledge-document-main small {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.knowledge-document-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.knowledge-document-icon {
  color: var(--primary-strong);
  font-size: 20px;
}

.knowledge-document-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.knowledge-document-main strong,
.knowledge-document-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-document-row .status-draft { color: #8a6d1d; background: #fff6d8; }
.knowledge-document-row .status-published { color: #277a55; background: #e6f7ed; }
.knowledge-document-row .status-retired { color: #6d6576; background: #efedf2; }

.file-button {
  cursor: pointer;
}

.knowledge-document-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.knowledge-meta-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.knowledge-release-note {
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(116, 99, 154, .08);
  font-size: 13px;
}

.knowledge-media-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.knowledge-media-list {
  display: grid;
  gap: 8px;
}

.knowledge-media-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(116, 99, 154, .07);
}

.knowledge-media-row span {
  display: grid;
  gap: 2px;
}

.knowledge-media-row small {
  color: var(--muted);
}

.knowledge-markdown-editor {
  min-height: 430px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.6;
}

.settings-menu-card {
  display: grid;
  align-content: start;
  gap: 10px;
}

.settings-menu-item {
  width: 100%;
  display: grid;
  gap: 4px;
  justify-items: start;
  align-items: start;
  justify-content: stretch;
  padding: 14px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255,255,255,.56);
  text-align: left;
}

.settings-menu-item.active,
.settings-menu-item:hover {
  color: var(--primary-strong);
  background: rgba(184, 167, 217, .16);
  border-color: rgba(116, 99, 154, .2);
}

.settings-menu-item strong,
.settings-menu-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-menu-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.settings-content-card {
  min-height: 640px;
}

.settings-content {
  margin-top: 14px;
}

.agent-workbench {
  grid-template-columns: minmax(236px, .36fr) minmax(0, 1.64fr);
  gap: 18px;
}

.agent-menu-card,
.agent-content-card {
  min-height: 650px;
}

.agent-menu-card {
  position: relative;
  overflow: hidden;
  padding: 14px;
  border-color: rgba(116, 99, 154, .14);
  background:
    radial-gradient(circle at 12% 0, rgba(196, 181, 225, .24), transparent 43%),
    rgba(255, 255, 255, .74);
}

.agent-menu-card::after {
  content: '';
  position: absolute;
  right: -34px;
  bottom: -48px;
  width: 138px;
  height: 138px;
  border: 1px solid rgba(116, 99, 154, .14);
  border-radius: 50%;
  pointer-events: none;
}

.agent-menu-card .settings-menu-item {
  position: relative;
  z-index: 1;
  min-height: 92px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,.46);
}

.agent-menu-card .settings-menu-item.active {
  box-shadow: 0 14px 28px rgba(89, 71, 121, .09);
}

.agent-menu-card .settings-menu-item span {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.agent-section-head {
  padding: 5px 4px 17px;
  border-bottom: 1px solid rgba(92, 78, 116, .09);
}

.agent-content-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border-color: rgba(116, 99, 154, .15);
  background:
    radial-gradient(circle at 100% 0, rgba(196, 181, 225, .18), transparent 34%),
    linear-gradient(145deg, rgba(255,255,255,.96), rgba(250,248,253,.82));
}

.agent-run-content {
  margin-top: 20px;
}

.agent-run-content .entity-field:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agent-run-content .entity-field:has(input[type="checkbox"]) span {
  margin-bottom: 0;
}

.agent-run-content input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

.agent-list-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.agent-access-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(116, 99, 154, .13);
  border-radius: 22px;
  background: linear-gradient(135deg, #f5f1fb, #fffdfd 78%);
}

.agent-access-hero::after {
  content: '';
  position: absolute;
  top: -58px;
  right: -42px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(184, 167, 217, .2);
}

.agent-access-hero > * {
  position: relative;
  z-index: 1;
}

.agent-access-kicker {
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.agent-access-hero h4 {
  max-width: 520px;
  margin: 8px 0 6px;
  color: #41394f;
  font-size: 20px;
  letter-spacing: -.02em;
}

.agent-access-hero p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.agent-access-metrics {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.agent-access-metrics span {
  display: grid;
  gap: 2px;
  min-width: 68px;
  padding: 10px 12px;
  border: 1px solid rgba(116, 99, 154, .12);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255,255,255,.68);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.agent-access-metrics strong {
  color: #554868;
  font-size: 18px;
}

.agent-access-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.agent-access-card {
  padding: 18px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 20px;
  background: rgba(255,255,255,.66);
  box-shadow: 0 10px 22px rgba(79, 63, 105, .035);
}

.agent-access-card-head,
.agent-access-card-foot,
.agent-client-identity,
.agent-client-status {
  display: flex;
  align-items: center;
}

.agent-access-card-head {
  justify-content: space-between;
  gap: 14px;
}

.agent-client-identity {
  min-width: 0;
  gap: 11px;
}

.agent-client-mark {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #c2b1e1, #8370aa);
  box-shadow: 0 8px 16px rgba(100, 82, 137, .17);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
}

.agent-client-identity > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.agent-client-identity strong {
  overflow: hidden;
  color: #443a51;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-client-identity small,
.agent-access-description,
.agent-access-card-foot > small,
.agent-readonly-note,
.agent-permission-message {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.agent-client-status {
  gap: 6px;
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.agent-client-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.agent-client-status.active {
  color: #287457;
  background: #e8f6ef;
}

.agent-client-status.disabled {
  color: #786f82;
  background: #f0eef3;
}

.agent-access-description {
  max-width: 720px;
  margin: 14px 0;
}

.agent-model-access-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.agent-model-toggle {
  min-width: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid rgba(92, 78, 116, .09);
  border-radius: 15px;
  background: rgba(249,247,252,.72);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.agent-model-toggle:hover {
  border-color: rgba(116, 99, 154, .25);
  background: rgba(246,242,252,.92);
}

.agent-run-content .agent-model-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.agent-model-switch {
  width: 32px;
  height: 19px;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
  background: #d8d3df;
  transition: background .18s ease;
}

.agent-model-switch i {
  width: 15px;
  height: 15px;
  display: block;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(67, 57, 79, .22);
  transition: transform .18s ease;
}

.agent-model-toggle input:checked + .agent-model-switch {
  background: linear-gradient(135deg, #aa95d1, #75639c);
}

.agent-model-toggle input:checked + .agent-model-switch i {
  transform: translateX(13px);
}

.agent-model-toggle input:focus-visible + .agent-model-switch {
  outline: 3px solid rgba(116, 99, 154, .24);
  outline-offset: 2px;
}

.agent-model-toggle:has(input:checked) {
  border-color: rgba(116, 99, 154, .22);
  background: linear-gradient(135deg, rgba(243,239,251,.92), rgba(255,255,255,.88));
}

.agent-model-toggle:has(input:disabled) {
  cursor: default;
  opacity: .78;
}

.agent-model-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.agent-model-copy strong,
.agent-model-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-model-copy strong {
  color: #504558;
  font-size: 13px;
}

.agent-model-copy small {
  color: #8a8293;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
}

.agent-access-card-foot {
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(92, 78, 116, .08);
}

.agent-access-card-foot .toolbar {
  gap: 8px;
  flex-wrap: nowrap;
}

.agent-access-card-foot .button {
  min-height: 36px;
  padding: 8px 11px;
  font-size: 12px;
}

.agent-readonly-note,
.agent-permission-message {
  display: block;
  min-height: 1.55em;
  margin: 12px 0 0;
}

.agent-permission-message:not(:empty) {
  color: var(--primary-strong);
  font-weight: 700;
}

.agent-matrix-hero {
  align-items: center;
}

.agent-matrix-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.agent-import-button {
  min-height: 42px;
  white-space: nowrap;
}

.agent-matrix-scroll {
  overflow-x: auto;
  margin-top: 15px;
  padding-bottom: 4px;
  border: 1px solid rgba(92, 78, 116, .09);
  border-radius: 19px;
  background: rgba(255,255,255,.6);
}

.agent-permission-matrix {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

.agent-permission-matrix th,
.agent-permission-matrix td {
  min-width: 146px;
  padding: 13px 11px;
  border-right: 1px solid rgba(92, 78, 116, .075);
  border-bottom: 1px solid rgba(92, 78, 116, .075);
  vertical-align: middle;
}

.agent-permission-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-top: 14px;
  padding-bottom: 14px;
  background: rgba(249,247,252,.97);
}

.agent-permission-matrix tr > :last-child {
  border-right: 0;
}

.agent-permission-matrix tbody tr:last-child > * {
  border-bottom: 0;
}

.agent-matrix-model-head,
.agent-permission-matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 174px;
  text-align: left;
  background: rgba(255,255,255,.97);
}

.agent-matrix-model-head {
  z-index: 3 !important;
  color: #625576;
  font-size: 12px;
}

.agent-matrix-agent-head {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
}

.agent-matrix-agent-head .agent-client-mark {
  width: 31px;
  height: 31px;
  border-radius: 10px;
  box-shadow: none;
  font-size: 9px;
}

.agent-matrix-agent-head strong {
  overflow: hidden;
  color: #4b4157;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-matrix-agent-status {
  display: inline-grid;
  grid-column: 2;
  width: fit-content;
  margin-top: -3px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #f0eef3;
  color: #786f82;
  font-size: 10px;
  font-weight: 800;
}

.agent-matrix-agent-status.active {
  border-color: rgba(40,116,87,.12);
  background: #e8f6ef;
  color: #287457;
}

.agent-matrix-agent-status:disabled {
  cursor: default;
}

.agent-matrix-model-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.agent-matrix-model-copy strong {
  overflow: hidden;
  color: #463d51;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-matrix-model-copy small {
  overflow: hidden;
  color: #8c8395;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-model-status {
  width: fit-content;
  padding: 2px 6px;
  border-radius: 999px;
  color: #6f6380;
  background: #f1eef4;
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
}

.agent-model-status.active {
  color: #287457;
  background: #e8f6ef;
}

.agent-matrix-model-row.inactive-model > * {
  background: rgba(247,245,248,.78);
}

.agent-operation-bubbles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 30px;
}

.agent-operation-bubble,
.agent-field-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 27px;
  padding: 5px 8px;
  border: 1px solid #dfdbe3;
  border-radius: 999px;
  background: #f8f7f9;
  color: #746e7b;
  font-size: 10px;
  font-weight: 800;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

.agent-operation-bubble:hover:not(:disabled),
.agent-field-bubble:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(40,116,87,.3);
}

.agent-operation-bubble.granted,
.agent-field-bubble.granted {
  border-color: rgba(40,116,87,.28);
  background: linear-gradient(135deg, #e7f5ed, #f8fffb);
  color: #247153;
}

.agent-operation-bubble.edit i {
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(40,116,87,.12);
  color: inherit;
  font-size: 10px;
  font-style: normal;
  line-height: 1;
}

.agent-operation-bubble:disabled,
.agent-field-bubble:disabled {
  cursor: default;
  opacity: .72;
}

.agent-no-operation {
  color: #aaa3af;
  font-size: 11px;
  font-weight: 700;
}

.agent-edit-fields-row td {
  padding: 0;
  background: rgba(248,252,249,.88);
}

.agent-edit-fields-panel {
  display: grid;
  grid-template-columns: minmax(210px, .9fr) minmax(260px, 1.4fr);
  align-items: center;
  gap: 18px;
  padding: 17px 20px;
  border-left: 3px solid rgba(40,116,87,.35);
}

.agent-field-kicker {
  color: #287457;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.agent-edit-fields-panel h4 {
  margin: 5px 0;
  color: #3d5147;
  font-size: 15px;
}

.agent-edit-fields-panel h4 i {
  color: #86a093;
  font-style: normal;
}

.agent-edit-fields-panel p {
  margin: 0;
  color: #748178;
  font-size: 11px;
  line-height: 1.55;
}

.agent-field-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.agent-field-empty {
  color: #8d978f;
  font-size: 12px;
}

.agent-matrix-note {
  margin: 11px 3px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.agent-import-shell {
  display: grid;
  gap: 14px;
}

.agent-import-card {
  display: grid;
  gap: 13px;
}

.agent-import-card label {
  display: grid;
  gap: 7px;
  color: #5c5368;
  font-size: 12px;
  font-weight: 800;
}

.agent-import-result {
  display: grid;
  gap: 5px;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px dashed rgba(116,99,154,.2);
  border-radius: 14px;
  color: #776f81;
  background: rgba(249,247,252,.62);
  font-size: 12px;
  line-height: 1.5;
}

.agent-import-result.success {
  border-style: solid;
  border-color: rgba(40,116,87,.2);
  color: #317258;
  background: rgba(235,248,240,.7);
}

.agent-import-result.error {
  border-style: solid;
  border-color: rgba(181,83,103,.22);
  color: #985264;
  background: rgba(252,240,243,.74);
}

.agent-import-result strong {
  font-size: 12px;
}

.agent-import-result small {
  color: inherit;
}

.agent-import-result ul {
  margin: 0;
  padding-left: 18px;
}

.agent-list-intro strong {
  color: var(--text);
  font-size: 13px;
}

.agent-run-list {
  display: grid;
  gap: 9px;
}

.agent-run-card {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  color: var(--text);
  text-align: left;
  background: linear-gradient(135deg, rgba(255,255,255,.8), rgba(248,246,252,.66));
  border: 1px solid rgba(92, 78, 116, .09);
  border-radius: 17px;
  box-shadow: 0 8px 20px rgba(87, 72, 112, .045);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.agent-run-card:hover {
  transform: translateY(-1px);
  border-color: rgba(116, 99, 154, .22);
  box-shadow: 0 12px 26px rgba(87, 72, 112, .09);
}

.agent-run-symbol {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #6e5d92;
  background: linear-gradient(145deg, #eee8f8, #ddd2f0);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.agent-run-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.agent-run-topline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-run-topline strong,
.agent-run-agent,
.agent-run-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-run-agent {
  color: #756b82;
  font-size: 12px;
  font-weight: 700;
}

.agent-run-main small,
.agent-run-card time {
  color: var(--muted);
  font-size: 11px;
}

.agent-run-card time {
  white-space: nowrap;
}

.agent-result {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.agent-result.success {
  color: #287457;
  background: #e8f6ef;
}

.agent-result.failed {
  color: #9a4f5e;
  background: #fbecef;
}

.agent-back-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 16px;
  padding: 0;
  color: #6f6380;
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 800;
}

.agent-back-button:hover {
  color: var(--primary-strong);
}

.agent-back-button span {
  font-size: 17px;
}

.agent-run-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 25px;
  border-radius: 23px;
  border: 1px solid rgba(116, 99, 154, .11);
  background: linear-gradient(135deg, rgba(244,240,251,.96), rgba(255,255,255,.82));
}

.agent-run-hero::after {
  content: '';
  position: absolute;
  width: 180px;
  height: 180px;
  right: -70px;
  top: -95px;
  border-radius: 50%;
  background: rgba(177, 157, 216, .18);
  filter: blur(2px);
}

.agent-run-hero.failed::after {
  background: rgba(220, 151, 166, .15);
}

.agent-run-kicker {
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.agent-run-hero h4 {
  margin: 7px 0 6px;
  font-size: 24px;
}

.agent-run-hero p {
  margin: 0;
  color: var(--muted);
}

.agent-run-outcome {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  color: #287457;
  background: rgba(232, 246, 239, .9);
  font-size: 12px;
  font-weight: 900;
}

.agent-run-hero.failed .agent-run-outcome {
  color: #9a4f5e;
  background: rgba(251, 236, 239, .92);
}

.agent-run-outcome i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(40, 116, 87, .1);
}

.agent-run-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.agent-detail-block {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 17px;
  border-radius: 17px;
  border: 1px solid rgba(92, 78, 116, .08);
  background: rgba(255,255,255,.58);
}

.agent-detail-block span,
.agent-context-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.agent-detail-block strong {
  overflow: hidden;
  color: #4f475c;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-detail-block small,
.agent-context-strip small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.agent-context-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 17px;
  border-radius: 15px;
  background: rgba(116, 99, 154, .06);
}

.agent-context-strip strong {
  overflow: hidden;
  color: #5f536f;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-head {
  align-items: flex-start;
}

.compact-head .muted {
  margin-top: 4px;
}

.diy-filter-row {
  grid-template-columns: minmax(180px, 320px);
  margin-top: 12px;
}

.diy-application-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
  min-height: 220px;
}

.diy-application-grid.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(92, 78, 116, .16);
  border-radius: 18px;
  color: var(--muted);
}

.diy-application-card {
  min-height: 178px;
  border: 1px solid rgba(116, 99, 154, .12);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.88), rgba(250,248,255,.72)),
    radial-gradient(circle at 100% 0, rgba(184,167,217,.16), transparent 48%);
  color: var(--text);
  padding: 14px 14px 13px;
  display: grid;
  align-content: start;
  gap: 9px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(31, 26, 48, .06);
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.diy-application-card:hover {
  border-color: rgba(116, 99, 154, .28);
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(251,249,255,.86)),
    radial-gradient(circle at 100% 0, rgba(184,167,217,.2), transparent 50%);
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(31, 26, 48, .09);
}

.diy-card-accent {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, rgba(116,99,154,.62), rgba(231,188,111,.55));
}

.diy-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.diy-card-icon {
  width: 38px;
  height: 28px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #5e4e87;
  background: rgba(184, 167, 217, .18);
  border: 1px solid rgba(116, 99, 154, .13);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .4px;
}

.diy-application-card strong {
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.diy-card-desc {
  min-height: 38px;
  color: #4f5870;
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.diy-card-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.diy-card-meta small {
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(92, 78, 116, .07);
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.diy-card-time {
  font-size: 12px;
  color: #8b93a5;
  margin-top: 2px;
}

.diy-detail-view {
  max-width: 860px;
}

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

.material-description {
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hardware-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.hardware-image-grid.empty-state {
  min-height: 90px;
  place-items: center;
  color: var(--muted);
}

.hardware-image-grid.image-load-error {
  grid-template-columns: 1fr;
}

.hardware-image-error {
  border: 1px dashed rgba(138, 76, 8, .24);
  border-radius: 16px;
  background: rgba(245, 158, 11, .08);
  color: #7a4a12;
  padding: 16px;
  display: grid;
  gap: 6px;
}

.hardware-image-error span {
  color: var(--muted);
  font-size: 13px;
}

.hardware-image-thumb {
  min-height: 150px;
  border: 1px solid rgba(92, 78, 116, .12);
  border-radius: 16px;
  background: rgba(255,255,255,.68);
  overflow: hidden;
  display: grid;
  align-content: stretch;
  text-decoration: none;
  color: var(--text);
}

.hardware-image-thumb.unavailable {
  pointer-events: none;
}

.hardware-image-thumb img {
  width: 100%;
  height: 124px;
  object-fit: cover;
  display: block;
  background: rgba(92, 78, 116, .06);
}

.hardware-image-thumb span {
  min-height: 112px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.hardware-image-thumb small {
  padding: 8px 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.settings-card-list {
  max-height: none;
}

.admin-user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.admin-user-card {
  width: 100%;
  min-height: 132px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(116, 99, 154, .1);
  border-radius: 18px;
  color: var(--text);
  background: linear-gradient(160deg, rgba(255,255,255,.78), rgba(249,246,253,.58));
  box-shadow: 0 12px 30px rgba(72, 55, 105, .055);
  text-align: left;
}

.admin-user-card:hover {
  border-color: rgba(116, 99, 154, .2);
  box-shadow: 0 16px 34px rgba(72, 55, 105, .09);
}

.admin-user-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, rgba(184, 167, 217, .95), rgba(116, 99, 154, .88));
  box-shadow: 0 12px 24px rgba(72, 55, 105, .14);
  font-size: 17px;
  font-weight: 900;
}

.admin-user-body {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.admin-user-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.admin-user-card strong,
.admin-user-line b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-card strong {
  color: var(--ink);
  font-size: 15px;
}

.admin-user-card em {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  color: rgba(116, 99, 154, .86);
  background: rgba(184, 167, 217, .15);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.admin-user-line {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.admin-user-line small {
  color: rgba(120, 113, 132, .78);
  font-weight: 700;
}

.admin-user-line b {
  color: #4f485e;
  font-weight: 750;
}

.activation-console {
  margin-top: 14px;
}

.serial-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.serial-select-row .button {
  min-height: 42px;
  padding-inline: 14px;
}

.danger-text {
  color: var(--danger) !important;
}

.todo-workbench {
  display: grid;
  grid-template-columns: minmax(300px, .72fr) minmax(0, 1.5fr);
  gap: 20px;
}

.todo-list-card,
.todo-detail-card {
  min-height: 640px;
}

.todo-list-card {
  padding: 14px;
}

.todo-detail-card {
  padding: 20px;
  background: rgba(255, 255, 255, .7);
}

.todo-row {
  position: relative;
  min-height: 78px;
  padding: 15px 16px;
  border: 1px solid rgba(92, 78, 116, .08);
  border-radius: 16px;
  background: rgba(255, 255, 255, .44);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.todo-row:hover {
  transform: translateY(-1px);
  border-color: rgba(116, 99, 154, .24);
  box-shadow: 0 12px 24px rgba(72, 55, 105, .08);
}

.todo-row em {
  align-self: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: #5e4e87;
  background: rgba(184, 167, 217, .2);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.todo-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(116, 99, 154, .14);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(250, 248, 255, .96), rgba(237, 231, 248, .68));
}

.todo-hero.after-sale {
  border-color: rgba(71, 119, 111, .18);
  background: linear-gradient(135deg, rgba(245, 252, 249, .96), rgba(227, 242, 235, .76));
}

.todo-hero h3 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -.02em;
}

.todo-hero p:not(.eyebrow) {
  max-width: 680px;
  margin: 10px 0 0;
  color: #524c5e;
  line-height: 1.7;
}

.todo-status {
  flex: none;
  padding: 6px 11px;
  border-radius: 999px;
  color: #175c45;
  background: rgba(52, 168, 127, .13);
  font-size: 12px;
  font-weight: 800;
}

.todo-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 13px 2px 18px;
}

.todo-meta-pills span {
  padding: 5px 9px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .62);
  font-size: 12px;
}

.todo-focus-card,
.todo-form-card,
.todo-action-card,
.todo-media-card {
  margin-top: 14px;
  padding: 17px 18px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 18px;
  background: rgba(255, 255, 255, .58);
}

.todo-focus-card p,
.todo-action-card p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.todo-description-card p {
  white-space: pre-wrap;
  color: #474151;
}

.todo-media-card {
  background: rgba(255, 255, 255, .48);
}

.todo-media-card .image-strip {
  grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
}

.todo-media-card .event-image-link {
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 8px 18px rgba(72, 55, 105, .05);
}

.todo-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 800;
}

.todo-section-heading small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.todo-history-empty {
  color: var(--muted);
  font-size: 13px;
}

.todo-task-history {
  display: grid;
  gap: 9px;
}

.todo-history-entry {
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 12px;
  background: rgba(255, 255, 255, .64);
  overflow: hidden;
}

.todo-history-entry summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.todo-history-entry summary small {
  color: var(--muted);
  font-weight: 600;
}

.todo-history-entry p {
  margin: 0 12px 8px;
  color: var(--muted);
  font-size: 12px;
}

.todo-history-entry pre {
  max-height: 320px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-top: 1px solid rgba(92, 78, 116, .08);
  background: rgba(48, 39, 72, .04);
  color: #3f384b;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.todo-form-grid {
  display: grid;
  gap: 10px;
}

.todo-textarea-field textarea,
.todo-action-card textarea {
  min-height: 88px;
  resize: vertical;
}

.workflow-output-json {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.workflow-checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.todo-action-card {
  border-color: rgba(116, 99, 154, .18);
  background: linear-gradient(135deg, rgba(255, 255, 255, .84), rgba(248, 245, 253, .78));
}

.todo-action-card h4 {
  margin: 0;
}

.todo-action-card textarea {
  width: 100%;
  margin-top: 14px;
}

.todo-action-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.todo-decision-buttons {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.todo-primary-action,
.todo-reject-action,
.todo-claim-button {
  min-height: 42px;
  padding: 10px 15px;
  border-radius: 14px;
}

.todo-primary-action {
  color: #fff;
  background: linear-gradient(135deg, #74639a, #9c87c2);
  box-shadow: 0 12px 22px rgba(86, 69, 124, .2);
}

.todo-primary-action span,
.todo-reject-action span {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  font-size: 14px;
  line-height: 1;
}

.todo-primary-action:hover {
  box-shadow: 0 16px 28px rgba(86, 69, 124, .27);
}

.todo-reject-action {
  color: #a63838;
  border: 1px solid rgba(194, 65, 61, .18);
  background: rgba(255, 247, 247, .86);
}

.todo-reject-action span {
  color: #fff;
  background: #c2413d;
}

.todo-claim-button {
  color: #64567f;
  border: 1px solid rgba(116, 99, 154, .16);
  background: rgba(255, 255, 255, .74);
}

.todo-action-message {
  display: block;
  min-height: 20px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 13px;
}

.full-width {
  width: 100%;
  margin-top: 10px;
}

.order-list-card,
.order-detail-card {
  min-height: 620px;
}

.order-list {
  display: grid;
  gap: 10px;
  max-height: 720px;
  overflow: auto;
  padding-right: 4px;
}

.order-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(92, 78, 116, .12);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, .62);
  text-align: left;
  box-shadow: none;
}

.order-row.active {
  border-color: rgba(116, 99, 154, .3);
  background: rgba(249, 246, 253, .94);
  box-shadow: 0 12px 28px rgba(72, 55, 105, .09);
}

.order-row-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.order-row-main strong,
.order-row-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row-main small {
  color: var(--muted);
}

.order-row-amount {
  grid-column: 2;
  color: var(--primary-strong);
  font-weight: 900;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  color: #5e4e87;
  background: rgba(184, 167, 217, .2);
  font-size: 12px;
  font-weight: 900;
}

.status-paid,
.status-shipped,
.status-delivered {
  color: #175c45;
  background: rgba(52, 168, 127, .16);
}

.status-completed {
  color: #31537a;
  background: rgba(79, 132, 196, .16);
}

.status-exception,
.status-refunding {
  color: #8a4c08;
  background: rgba(245, 158, 11, .18);
}

.status-canceled,
.status-refunded {
  color: #8b2b2b;
  background: rgba(220, 65, 61, .15);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--muted);
  border: 1px dashed rgba(92, 78, 116, .18);
  border-radius: 20px;
  background: rgba(255, 255, 255, .42);
}

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

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.detail-header h3 {
  margin: 0;
  font-size: 24px;
}

.detail-copy {
  margin: -4px 0 14px;
  color: var(--muted);
  line-height: 1.7;
}

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

.detail-line {
  padding: 12px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 16px;
  background: rgba(255,255,255,.58);
}

.detail-line span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.detail-line strong {
  display: block;
  overflow-wrap: anywhere;
}

.sub-card {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 20px;
  background: rgba(255,255,255,.52);
}

.sub-card h4 {
  margin: 0 0 10px;
}

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

.form-grid label,
.checkbox-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  margin: 14px 0;
  color: var(--text);
}

.inline-result.error {
  color: #b42318;
}

.item-list {
  display: grid;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(92, 78, 116, .08);
}

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

.image-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}

.event-image-link {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255,255,255,.58);
  text-decoration: none;
}

.event-image-link img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}

.event-image-link span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-video-link {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 16px;
  background: rgba(255,255,255,.58);
}

.event-video-link video {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 12px;
  background: #111;
}

.event-video-link span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-list a,
.file-list span {
  padding: 10px 12px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 14px;
  color: var(--primary-strong);
  background: rgba(255,255,255,.58);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.raw-json {
  margin-top: 14px;
}

.raw-json summary {
  cursor: pointer;
  color: var(--primary-strong);
  font-weight: 800;
}

.span-2 {
  grid-column: 1 / -1;
}

.metric-grid {
  display: block;
  margin-bottom: 16px;
}

.overview-modern {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  gap: 16px;
}

.overview-hero {
  min-height: 300px;
  display: grid;
  align-content: space-between;
  padding: 28px;
  border: 1px solid rgba(116, 99, 154, .16);
  border-radius: 30px;
  color: #fffaff;
  background:
    radial-gradient(circle at 82% 16%, rgba(215, 200, 236, .48), transparent 28%),
    linear-gradient(135deg, #2d263b 0%, #74639a 58%, #b8a7d9 100%);
  box-shadow: 0 28px 70px rgba(72, 55, 105, .16);
  overflow: hidden;
  position: relative;
}

.overview-hero::after {
  content: "";
  position: absolute;
  right: -54px;
  bottom: -70px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}

.overview-hero > * {
  position: relative;
  z-index: 1;
}

.overview-hero h3 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  letter-spacing: -.04em;
}

.overview-hero p {
  max-width: 560px;
  margin: 10px 0 0;
  color: rgba(255, 250, 255, .76);
  line-height: 1.7;
}

.overview-hero strong {
  display: block;
  margin: 28px 0;
  font-size: clamp(54px, 9vw, 96px);
  line-height: .9;
  letter-spacing: -.07em;
}

.overview-hero-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.overview-hero-footer span {
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(8px);
  font-weight: 800;
}

.overview-side {
  display: grid;
  gap: 12px;
}

.overview-card {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 92px;
  padding: 18px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 24px;
  background: rgba(255,255,255,.78);
  box-shadow: 0 18px 45px rgba(72, 55, 105, .07);
}

.overview-card span,
.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.overview-card strong {
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
}

.overview-card small,
.metric-card small {
  color: var(--muted);
  line-height: 1.5;
}

.overview-card.warm {
  background: linear-gradient(150deg, rgba(255,255,255,.9), rgba(247,239,255,.8));
}

.overview-card.alert {
  background: linear-gradient(150deg, rgba(255,255,255,.9), rgba(241,235,251,.8));
}

.overview-card.calm {
  background: linear-gradient(150deg, rgba(255,255,255,.9), rgba(235,231,247,.82));
}

.overview-secondary-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 132px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(116, 99, 154, .12);
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(255,255,255,.92), rgba(249,246,253,.76));
  box-shadow: 0 14px 34px rgba(72, 55, 105, .06);
}

.metric-card strong {
  display: block;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: #514a60;
  font-size: 14px;
  font-weight: 650;
}

input, textarea, select {
  width: 100%;
  border: 1px solid rgba(92, 78, 116, .15);
  border-radius: 15px;
  padding: 11px 13px;
  font: inherit;
  color: var(--text);
  background: rgba(255,255,255,.82);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(116, 99, 154, .34);
  box-shadow: 0 0 0 4px rgba(184, 167, 217, .16);
  background: #fff;
}

.scan-input-row {
  position: relative;
  display: block;
}

.scan-input-row input {
  padding-right: 52px;
}

.scan-icon-button {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 36px;
  height: 36px;
  padding: 0;
  color: rgba(116, 99, 154, .52);
  background: transparent;
  border: 0;
  transform: translateY(-50%);
}

.scan-icon-button:hover {
  color: rgba(116, 99, 154, .78);
  transform: translateY(calc(-50% - 1px));
}

.scan-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(25, 21, 34, .52);
  backdrop-filter: blur(10px);
}

.scan-modal {
  width: min(520px, 100%);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, .36);
  border-radius: 28px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 28px 70px rgba(25, 21, 34, .28);
}

.scan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.scan-header h3 {
  margin: 0;
}

.scan-video-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  background: #191522;
}

.scan-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-video-wrap::before {
  content: "";
  position: absolute;
  inset: 16%;
  border: 2px solid rgba(255, 255, 255, .86);
  border-radius: 20px;
  box-shadow: 0 0 0 999px rgba(25, 21, 34, .22);
}

.scan-line {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 24%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: scanLine 1.8s ease-in-out infinite;
}

@keyframes scanLine {
  0%, 100% { transform: translateY(0); opacity: .34; }
  50% { transform: translateY(190px); opacity: .92; }
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.button:hover,
button:hover {
  transform: translateY(-1px);
}

.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 12px 24px rgba(72, 55, 105, .18);
}

.secondary {
  color: var(--primary-strong);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(116, 99, 154, .14);
}

.danger {
  color: #fff;
  background: linear-gradient(135deg, #d85b55, var(--danger));
}

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

.buttons {
  align-items: end;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.result-panel {
  display: grid;
  gap: 10px;
  min-height: 120px;
  max-height: 460px;
  overflow: auto;
  margin-top: 12px;
}

.result-list {
  display: grid;
  gap: 10px;
  min-height: 240px;
  max-height: 680px;
  overflow: auto;
  margin-top: 12px;
}

.settings-list-card .result-list {
  min-height: 120px;
  max-height: 440px;
  gap: 7px;
}

.settings-list-card .entity-row {
  min-height: 58px;
  padding: 9px 11px;
  border-radius: 14px;
}

.settings-list-card .entity-row small {
  font-size: 12px;
}

.settings-list-card .entity-row em {
  padding: 3px 8px;
  font-size: 11px;
}

.settings-users-head {
  margin-top: 18px;
}

.settings-users-head h3 {
  margin: 0;
}

.settings-detail-card .result-panel {
  min-height: auto;
}

.profile-summary {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,.84), rgba(249,246,253,.76));
}

.profile-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  font-weight: 900;
}

.profile-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.profile-main strong,
.profile-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-main span,
.profile-meta span {
  color: var(--muted);
  font-size: 12px;
}

.profile-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-meta span {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(184, 167, 217, .16);
  color: var(--primary-strong);
  font-weight: 800;
}

.entity-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255,255,255,.58);
  text-align: left;
}

.entity-row span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.entity-row strong,
.entity-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-row small {
  color: var(--muted);
}

.entity-row em {
  flex: none;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--primary-strong);
  background: rgba(184, 167, 217, .16);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

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

.check-card {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 16px;
  background: rgba(255,255,255,.58);
}

.check-card input {
  width: auto;
}

.check-card span {
  display: grid;
}

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

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

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

.entity-card {
  padding: 14px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 18px;
  background: rgba(255, 255, 255, .58);
}

.entity-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.entity-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.entity-field {
  min-width: 0;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .56);
}

.entity-field span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.entity-field strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.success-state {
  padding: 14px;
  border: 1px solid rgba(52, 168, 127, .18);
  border-radius: 18px;
  color: #175c45;
  background: rgba(52, 168, 127, .1);
  font-weight: 800;
}

.json-preview {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid rgba(92, 78, 116, .1);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255,255,255,.58);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.workflow-list {
  margin-top: 12px;
}

.workflow-card .entity-desc {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.inline-result {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}

.message {
  min-height: 1.5em;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: relative;
    top: 0;
    height: auto;
  }

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

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

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

  .agent-run-detail-grid {
    grid-template-columns: 1fr;
  }

  .agent-access-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-matrix-hero-actions {
    width: 100%;
    justify-content: space-between;
  }

  .agent-edit-fields-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 14px, 1440px);
    padding-top: 7px;
    gap: 12px;
  }

  .sidebar,
  .topbar,
  .login-card,
  .card {
    border-radius: 20px;
    padding: 16px;
  }

  .topbar,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .grid,
  .row,
  .filter-grid,
  .compact-filter,
  .order-workbench,
  .split-workbench,
  .settings-workbench,
  .todo-workbench,
  .detail-grid,
  .entity-fields,
  .checkbox-grid,
  .metric-grid,
  .overview-modern,
  .overview-secondary-grid {
    grid-template-columns: 1fr;
  }

  .todo-hero,
  .todo-action-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .todo-decision-buttons {
    width: 100%;
  }

  .todo-decision-buttons .button,
  .todo-claim-button {
    flex: 1;
  }

  .agent-run-card {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .agent-run-symbol {
    width: 38px;
    height: 38px;
  }

  .agent-run-card time {
    grid-column: 2;
  }

  .agent-run-hero {
    flex-direction: column;
    padding: 20px;
  }

  .agent-content-card {
    padding: 18px;
  }

  .agent-section-head {
    align-items: flex-start;
  }

  .agent-access-hero {
    padding: 19px;
  }

  .agent-access-metrics {
    width: 100%;
  }

  .agent-access-metrics span {
    flex: 1;
  }

  .agent-model-access-list {
    grid-template-columns: 1fr;
  }

  .agent-access-card-foot {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-access-card-foot .toolbar {
    width: 100%;
  }

  .agent-access-card-foot .button {
    flex: 1;
  }

  .agent-matrix-hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-import-button {
    width: 100%;
  }

  .agent-permission-matrix {
    min-width: 670px;
  }

  .agent-permission-matrix th,
  .agent-permission-matrix td {
    min-width: 128px;
    padding: 11px 9px;
  }

  .agent-matrix-model-head,
  .agent-permission-matrix tbody th {
    min-width: 148px;
  }

  .agent-edit-fields-panel {
    padding: 15px;
  }

  .agent-context-strip {
    grid-template-columns: 1fr;
    gap: 5px;
  }

}

/* Agent permission matrix: compact control surface, intentionally sized by content. */
.agent-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-height: 32px;
}

.agent-icon-button {
  position: relative;
  display: block;
  width: 32px;
  height: 32px;
  padding: 0 !important;
  place-items: center;
  border: 1px solid rgba(94, 78, 122, .17);
  border-radius: 11px;
  background: linear-gradient(145deg, #fff, #f4f0f8);
  color: #675584;
  box-shadow: 0 4px 12px rgba(74, 58, 93, .08), inset 0 1px 0 rgba(255,255,255,.9);
  font-size: 0;
  font-weight: 400;
  line-height: 1;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.agent-icon-button:hover {
  border-color: rgba(94, 78, 122, .35);
  box-shadow: 0 7px 16px rgba(74, 58, 93, .13), inset 0 1px 0 #fff;
  transform: translateY(-1px);
}

.agent-icon-button span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
  transform: translateY(-.5px);
}

.agent-compact-button {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 11px;
}

.agent-ui-message {
  max-width: 210px;
  overflow: hidden;
  color: #6d6575;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-ui-message.success { color: #287457; }
.agent-ui-message.error { color: #a14c61; }

.agent-matrix-scroll {
  width: fit-content;
  max-width: 100%;
  max-height: min(560px, calc(100vh - 290px));
  margin-top: 0;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.agent-permission-canvas {
  width: calc(126px + var(--agent-count) * 142px);
  padding: 2px 0 0;
}

.agent-agent-rail {
  position: sticky;
  z-index: 3;
  top: 0;
  display: grid;
  grid-template-columns: repeat(var(--agent-count), 142px);
  margin-left: 126px;
  padding-bottom: 10px;
  background: rgba(252,251,253,.96);
  backdrop-filter: blur(5px);
}

.agent-agent-card {
  position: relative;
  width: 126px;
  min-height: 58px;
  margin: 0 8px;
  padding: 12px 30px 10px 12px;
  border: 1px solid rgba(98, 88, 111, .16);
  border-radius: 15px;
  background: linear-gradient(145deg, #fff, #f6f3f8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.94), 0 5px 13px rgba(72, 59, 87, .05);
}

.agent-agent-card.active {
  border-color: rgba(40, 126, 89, .48);
  background: linear-gradient(145deg, #fafffc, #ecf8f0);
}

.agent-agent-card.disabled {
  color: #88808e;
  background: linear-gradient(145deg, #fcfbfc, #f4f2f5);
}

.agent-agent-card .agent-name-display {
  display: grid;
  min-width: 0;
  gap: 3px;
}

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

.agent-agent-card .agent-name-display strong {
  color: #443a50;
  font-size: 13px;
  letter-spacing: -.02em;
}

.agent-agent-card .agent-name-display small {
  color: #99909f;
  font-size: 9px;
  font-weight: 600;
}

.agent-status-direction {
  position: absolute;
  top: 10px;
  right: 9px;
  display: grid;
  width: 20px;
  height: 20px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: #7f7589;
  background: rgba(116, 99, 154, .08);
  font-size: 13px;
  line-height: 1;
}

.agent-agent-card.active .agent-status-direction {
  color: #287457;
  background: rgba(40, 126, 89, .1);
}

.agent-status-direction:hover:not(:disabled) {
  background: rgba(116, 99, 154, .17);
  transform: translateX(1px);
}

.agent-model-list { display: grid; }

.agent-model-band {
  display: grid;
  grid-template-columns: 126px repeat(var(--agent-count), 142px);
  align-items: center;
  min-height: 76px;
  border-top: 1px solid rgba(92, 78, 116, .11);
}

.agent-model-band.inactive-model { opacity: .65; }

.agent-model-band .agent-matrix-model-copy {
  padding: 0 12px;
}

.agent-model-capability {
  display: grid;
  width: 142px;
  place-items: center;
}

.agent-permission-matrix {
  width: max-content;
  min-width: 0;
  table-layout: fixed;
}

.agent-permission-matrix th,
.agent-permission-matrix td {
  width: 142px;
  min-width: 142px;
  max-width: 142px;
  padding: 10px 12px;
}

.agent-permission-matrix thead th {
  padding-top: 11px;
  padding-bottom: 10px;
  background: rgba(250,249,251,.98);
}

.agent-matrix-model-head,
.agent-permission-matrix tbody th {
  width: 126px;
  min-width: 126px;
  max-width: 126px;
  background: rgba(255,255,255,.98);
}

.agent-matrix-agent-head {
  grid-template-columns: 25px minmax(0, 1fr) 18px;
  align-items: start;
  gap: 6px;
}

.agent-matrix-agent-head .agent-client-mark {
  width: 25px;
  height: 25px;
  border-radius: 8px;
  color: #625079;
  background: linear-gradient(145deg, #eee8f5, #faf8fc);
  font-size: 8px;
}

.agent-matrix-agent-head strong {
  color: #443a50;
  font-size: 12px;
  letter-spacing: -.01em;
}

.agent-name-display {
  grid-column: 2;
  display: grid;
  min-width: 0;
  gap: 1px;
}

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

.agent-name-display small {
  color: #9a92a2;
  font-size: 9px;
  font-weight: 600;
}

.agent-matrix-agent-status {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  place-items: center;
  border-radius: 50%;
  background: #f0eef3;
}

.agent-matrix-agent-status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.agent-matrix-agent-status.active {
  color: #2b8964;
  background: #e8f6ef;
}

.agent-matrix-model-copy { gap: 1px; }

.agent-matrix-model-copy strong { font-size: 12px; }
.agent-matrix-model-copy small { font-size: 9px; }

.agent-operation-bubbles {
  display: grid;
  grid-template-columns: repeat(2, 50px);
  grid-template-rows: repeat(2, 25px);
  width: 105px;
  height: 55px;
  min-height: 55px;
  gap: 5px;
}

.agent-operation-bubble,
.agent-field-bubble {
  min-height: 25px;
  padding: 4px 8px;
  border-color: rgba(99, 91, 109, .18);
  background: linear-gradient(145deg, #fcfbfd, #f3f1f5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 2px 4px rgba(80, 68, 94, .035);
  color: #857d8c;
  font-size: 10px;
  letter-spacing: .01em;
}

.agent-operation-bubble:hover:not(:disabled),
.agent-field-bubble:hover:not(:disabled) {
  border-color: rgba(65, 122, 91, .38);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 5px 10px rgba(48, 104, 74, .09);
  transform: translateY(-1px);
}

.agent-operation-bubble.granted,
.agent-field-bubble.granted {
  border-color: rgba(44, 127, 91, .34);
  background: linear-gradient(145deg, #f5fff9, #dff3e7);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 3px 8px rgba(42, 116, 82, .1);
  color: #247454;
}

.agent-operation-bubble.edit i {
  width: 14px;
  height: 14px;
  background: rgba(35, 111, 80, .12);
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1;
}

.agent-operation-bubble {
  width: 50px;
  min-width: 50px;
  padding: 4px;
}

.agent-operation-bubble.operation-read { grid-column: 1; grid-row: 1; }
.agent-operation-bubble.operation-add { grid-column: 2; grid-row: 1; }
.agent-operation-bubble.operation-edit { grid-column: 1; grid-row: 2; }
.agent-operation-bubble.operation-delete { grid-column: 2; grid-row: 2; }

.agent-operation-bubbles .agent-no-operation {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  align-self: center;
  justify-self: center;
}

.agent-matrix-note {
  width: fit-content;
  max-width: 100%;
  margin: 8px 2px 0;
  font-size: 10px;
}

.agent-field-overlay {
  position: fixed;
  z-index: 40;
  inset: 0;
  background: transparent;
}

.agent-field-pill {
  position: fixed;
  top: var(--agent-field-top);
  left: var(--agent-field-left);
  display: flex;
  max-width: min(760px, calc(100vw - 32px));
  gap: 7px;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid rgba(116, 99, 154, .2);
  border-radius: 17px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 14px 34px rgba(63, 48, 79, .18), inset 0 1px 0 #fff;
  scrollbar-width: thin;
  transform: translateX(-50%);
}

.agent-field-pill::before {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 11px;
  height: 11px;
  border-top: 1px solid rgba(116, 99, 154, .2);
  border-left: 1px solid rgba(116, 99, 154, .2);
  background: #fff;
  content: '';
  transform: translateX(-50%) rotate(45deg);
}

.agent-field-pill .agent-field-bubble {
  flex: 0 0 auto;
  min-height: 31px;
  padding: 6px 13px;
  white-space: nowrap;
}

.agent-import-overlay {
  position: fixed;
  z-index: 41;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(39, 31, 48, .18);
  backdrop-filter: blur(4px);
}

.agent-import-review {
  display: grid;
  width: min(440px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  gap: 12px;
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(116, 99, 154, .16);
  border-radius: 19px;
  background: linear-gradient(145deg, #fff, #faf8fc);
  box-shadow: 0 24px 70px rgba(50, 39, 62, .22), inset 0 1px 0 #fff;
}

.agent-import-review-kicker {
  color: #6c5a88;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
}

.agent-import-review-copy,
.agent-import-review-error {
  display: grid;
  gap: 6px;
  color: #6c6474;
  font-size: 12px;
  line-height: 1.55;
}

.agent-import-review-copy strong { color: #2c7958; }
.agent-import-review-copy small { color: #847b8b; }
.agent-import-review-copy small { overflow-wrap: anywhere; }
.agent-import-review-error { color: #a14f63; }
.agent-import-review-error ul { margin: 0; padding-left: 18px; }

.agent-import-review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.agent-profile-kicker {
  display: block;
  color: #765d98;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .13em;
}

.agent-profile-studio-head h4 {
  margin: 6px 0 5px;
  color: #40334d;
  font-size: 20px;
  letter-spacing: -.035em;
}

.agent-profile-studio-head p {
  max-width: 680px;
  margin: 0;
  color: #766d7d;
  font-size: 12px;
  line-height: 1.65;
}

.agent-profile-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.agent-profile-card {
  display: grid;
  min-height: 134px;
  padding: 15px;
  text-align: left;
  border: 1px solid rgba(96, 84, 111, .14);
  border-radius: 17px;
  background: linear-gradient(145deg, #fff, #f8f6fa);
  box-shadow: inset 0 1px 0 #fff, 0 4px 12px rgba(67, 51, 82, .035);
  color: #40344d;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.agent-profile-card:hover {
  border-color: rgba(112, 89, 153, .3);
  box-shadow: inset 0 1px 0 #fff, 0 10px 22px rgba(67, 51, 82, .09);
  transform: translateY(-2px);
}

.agent-profile-card.selected {
  border-color: rgba(102, 77, 147, .48);
  background: linear-gradient(145deg, #fbf9ff, #eee8f8);
  box-shadow: inset 0 1px 0 #fff, 0 10px 24px rgba(83, 60, 123, .12);
}

.agent-profile-card-top {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #847a8e;
  font-size: 10px;
  font-weight: 800;
}

.agent-profile-card-top i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a59da9;
}

.agent-profile-card.active .agent-profile-card-top { color: #287457; }
.agent-profile-card.active .agent-profile-card-top i { background: #34a273; box-shadow: 0 0 0 4px rgba(52, 162, 115, .1); }
.agent-profile-card.draft .agent-profile-card-top { color: #9a7741; }
.agent-profile-card.draft .agent-profile-card-top i { background: #c59545; }

.agent-profile-card > strong {
  align-self: end;
  margin-top: 17px;
  overflow: hidden;
  font-size: 14px;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-profile-card > small {
  overflow: hidden;
  margin-top: 3px;
  color: #918899;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-profile-card-meta {
  margin-top: 12px;
  color: #73677f;
  font-size: 10px;
}

.agent-profile-studio {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid rgba(96, 84, 111, .13);
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(255,255,255,.98), rgba(250,248,252,.92));
  box-shadow: inset 0 1px 0 #fff, 0 10px 30px rgba(62, 49, 77, .05);
}

.agent-profile-studio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.agent-profile-section {
  min-width: 0;
  padding: 15px;
  border: 1px solid rgba(99, 86, 115, .12);
  border-radius: 16px;
  background: rgba(255,255,255,.68);
}

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

.agent-profile-section-head > div { display: grid; gap: 2px; }
.agent-profile-section-head span { color: #84788f; font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.agent-profile-section-head strong { color: #463951; font-size: 13px; }
.agent-profile-section-head small { max-width: 230px; color: #8b8290; font-size: 10px; line-height: 1.45; text-align: right; }

.agent-catalog-section {
  margin-bottom: 14px;
  padding: 17px 18px 15px;
  overflow: hidden;
  border: 1px solid rgba(110, 93, 142, .14);
  border-radius: 20px;
  background: linear-gradient(145deg, #fff, #f8f6fb);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), 0 7px 20px rgba(68, 53, 85, .045);
}

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

.agent-catalog-head h4 {
  margin: 5px 0 3px;
  color: #40334d;
  font-size: 16px;
  letter-spacing: -.02em;
}

.agent-catalog-head p {
  margin: 0;
  color: #847a8c;
  font-size: 11px;
}

.agent-rail-controls {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.agent-rail-button {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid rgba(104, 88, 124, .16);
  border-radius: 9px;
  background: #fff;
  color: #725d8c;
  font-size: 18px;
  line-height: 1;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.agent-rail-button:hover { border-color: rgba(102, 77, 147, .45); background: #f6f1fc; transform: translateY(-1px); }

.agent-profile-rail,
.agent-feature-grid {
  display: grid;
  grid-auto-columns: 196px;
  grid-auto-flow: column;
  grid-template-columns: none;
  gap: 10px;
  overflow-x: auto;
  padding: 1px 1px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(114, 93, 140, .32) transparent;
  scroll-snap-type: x proximity;
}

.agent-profile-rail { margin-bottom: -2px; }
.agent-profile-rail::-webkit-scrollbar,
.agent-feature-grid::-webkit-scrollbar { height: 5px; }
.agent-profile-rail::-webkit-scrollbar-thumb,
.agent-feature-grid::-webkit-scrollbar-thumb { border-radius: 9px; background: rgba(114, 93, 140, .26); }

.agent-profile-card {
  width: 196px;
  min-height: 122px;
  height: 122px;
  box-sizing: border-box;
  scroll-snap-align: start;
}

.agent-profile-card > strong { margin-top: 12px; }
.agent-profile-card-meta { margin-top: 8px; }

.agent-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.agent-overview-item {
  display: grid;
  min-width: 0;
  height: 58px;
  box-sizing: border-box;
  align-content: center;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid rgba(103, 91, 119, .11);
  border-radius: 11px;
  background: linear-gradient(145deg, #fefeff, #f6f4f8);
}

.agent-overview-item > span,
.agent-overview-item.agent-overview-status {
  color: #84788f;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .06em;
}

/* Neutralize the global form-label margin so this editable item occupies the
   exact same grid cell as the read-only overview items. */
.agent-overview-status { margin: 0; }

.agent-overview-item strong {
  display: flex;
  min-height: 28px;
  align-items: center;
  overflow: hidden;
  color: #51455a;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-overview-status select {
  min-height: 28px;
  padding: 2px 7px;
  border-color: rgba(105, 91, 124, .16);
  border-radius: 7px;
  background: #fff;
  color: #463951;
  font-size: 11px;
}

.agent-section-actions { display: flex; align-items: center; gap: 9px; }
.agent-section-actions .agent-rail-controls { margin-top: -3px; }

.agent-feature-grid {
  grid-auto-columns: 238px;
  margin: 0 -2px -4px;
}

.agent-feature-card {
  width: 238px;
  min-height: 118px;
  height: 118px;
  box-sizing: border-box;
  scroll-snap-align: start;
}

.agent-profile-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.agent-data-permission-link {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: baseline;
  gap: 8px;
  padding: 5px 2px;
  border: 0;
  background: transparent;
  color: #776b82;
  text-align: left;
}

.agent-data-permission-link span { color: #4c4056; font-size: 12px; font-weight: 850; }
.agent-data-permission-link small { color: #908795; font-size: 10px; }
.agent-data-permission-link b { color: #70578e; font-size: 10px; }
.agent-data-permission-link:hover span, .agent-data-permission-link:hover b { color: #513878; }
.agent-profile-readonly { color: #847b8a; font-size: 10px; }

.agent-feature-grid {
  grid-template-columns: none;
  gap: 10px;
}

.agent-feature-card {
  display: grid;
  min-height: 118px;
  padding: 13px;
  border: 1px solid rgba(102, 89, 119, .14);
  border-radius: 14px;
  background: linear-gradient(145deg, #fefeff, #f6f4f8);
  color: #53465d;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.agent-feature-card:hover:not(:disabled) {
  border-color: rgba(110, 81, 158, .34);
  box-shadow: 0 7px 16px rgba(76, 56, 101, .08);
  transform: translateY(-1px);
}

.agent-feature-card.selected {
  border-color: rgba(48, 126, 88, .38);
  background: linear-gradient(145deg, #fbfffc, #e7f5ec);
  box-shadow: inset 0 1px 0 #fff, 0 5px 12px rgba(42, 111, 78, .07);
}

.agent-feature-card.risk-high.selected { border-color: rgba(161, 79, 99, .42); }
.agent-feature-card:disabled { cursor: default; }
.agent-feature-card > span { color: #8d8395; font-size: 9px; font-weight: 900; letter-spacing: .05em; }
.agent-feature-card.selected > span { color: #287457; }
.agent-feature-card.risk-high.selected > span { color: #a14f63; }
.agent-feature-card > strong { margin-top: 12px; color: #4d4056; font-size: 13px; }
.agent-feature-card > small { margin-top: 5px; color: #837988; font-size: 10px; line-height: 1.55; }

@media (max-width: 900px) {
  .agent-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .agent-profile-studio-head { align-items: flex-start; flex-direction: column; }
  .agent-catalog-head, .agent-profile-actions { align-items: flex-start; flex-direction: column; }
  .agent-section-actions { width: 100%; justify-content: space-between; }
  .agent-section-actions small { max-width: 210px; }
  .agent-overview-grid { grid-template-columns: 1fr; }
  .agent-data-permission-link { grid-template-columns: auto auto; }
  .agent-data-permission-link b { grid-column: 1 / -1; }
  .agent-profile-section-head { display: grid; }
  .agent-profile-section-head small { max-width: none; text-align: left; }
  .agent-ui-message { max-width: 150px; }
  .agent-permission-matrix { min-width: 0; }
  .agent-matrix-scroll { max-height: min(520px, calc(100vh - 250px)); }
  .agent-permission-matrix th,
  .agent-permission-matrix td { width: 124px; min-width: 124px; max-width: 124px; padding: 9px; }
  .agent-matrix-model-head,
  .agent-permission-matrix tbody th { width: 112px; min-width: 112px; max-width: 112px; }
  .agent-permission-canvas { width: calc(112px + var(--agent-count) * 124px); }
  .agent-agent-rail { grid-template-columns: repeat(var(--agent-count), 124px); margin-left: 112px; }
  .agent-agent-card { width: 108px; margin: 0 8px; }
  .agent-model-band { grid-template-columns: 112px repeat(var(--agent-count), 124px); }
  .agent-model-capability { width: 124px; }
  .agent-field-pill { justify-content: flex-start; border-radius: 18px; }
}
