:root {
  color-scheme: light;
  --comments-drawer-width: 360px;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #dfe4ea;
  --brand: #c44f2f;
  --brand-dark: #9f3f25;
  --blue: #2563a8;
  --green: #287a5b;
  --amber: #a66a12;
  --shadow: 0 12px 30px rgba(26, 32, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  min-height: 84px;
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.section-title h2 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.user-chip {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 32px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  background: transparent;
  padding: 12px 4px;
  margin-right: 20px;
  color: var(--muted);
  font-weight: 700;
  position: relative;
  white-space: nowrap;
}

.tab.active {
  color: var(--brand);
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--brand);
  border-radius: 3px 3px 0 0;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric-card {
  padding: 18px;
  border-radius: 8px;
}

.metric-card strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
  color: var(--brand);
}

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: 180px 180px 180px minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 18px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(196, 79, 47, 0.12);
}

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

.asset-card {
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 12px;
}

.asset-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.asset-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
}

.asset-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.tag.status {
  background: #fff4e5;
  color: var(--amber);
}

.tag.line {
  background: #eaf1fb;
  color: var(--blue);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.upload-row input[type="file"] {
  flex: 1;
  min-width: 180px;
}

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

.publish-panel {
  max-width: none;
  margin-top: 0;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.publish-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.publish-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 148px;
  padding: 28px 24px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.publish-upload-zone:hover,
.publish-upload-zone.is-dragover {
  border-color: var(--blue);
  background: #eef4fd;
}

.publish-upload-zone.is-uploading {
  border-color: var(--blue);
  background: #eef4fd;
  pointer-events: none;
}

.publish-upload-zone.is-done {
  border-color: #16a34a;
  background: #f0fdf4;
}

.publish-upload-zone.is-error {
  border-color: #dc2626;
  background: #fef2f2;
}

.publish-upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #eaf1fb;
  color: var(--blue);
  font-size: 22px;
  font-weight: 700;
}

.publish-upload-desc,
.publish-upload-file,
.publish-upload-status {
  color: var(--muted);
  font-size: 13px;
}

.publish-upload-file {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}

.publish-upload-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.publish-upload-status.is-error {
  color: #dc2626;
}

.publish-basic,
.publish-settings,
.publish-advanced-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.publish-advanced summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
  padding: 4px 0 8px;
  list-style: none;
}

.publish-advanced summary::-webkit-details-marker {
  display: none;
}

.publish-advanced summary::before {
  content: "▸ ";
}

.publish-advanced[open] summary::before {
  content: "▾ ";
}

.publish-advanced-body {
  padding-top: 4px;
}

.checkbox-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: end;
  color: var(--muted);
}

.asset-card.is-deleted {
  opacity: 0.72;
  border: 1px dashed var(--line);
}

.version-tag {
  background: #f3f4f6;
  color: var(--muted);
}

.version-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.version-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.version-list li:last-child {
  border-bottom: 0;
}

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

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  border: 0;
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--brand);
  color: #fff;
}

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

.ghost-button {
  background: #edf2f7;
  color: var(--text);
}

.danger-button {
  background: #fbe9e7;
  color: #b42318;
}

.icon-button {
  width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #edf2f7;
  color: var(--text);
  font-size: 20px;
}

.panel {
  border-radius: 8px;
  padding: 22px;
}

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

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  max-width: 420px;
}

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

.wide {
  grid-column: 1 / -1;
}

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

.governance-card,
.component-card {
  border-radius: 8px;
  padding: 18px;
}

.governance-card h3,
.component-card h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.governance-card ul,
.component-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.dialog-card {
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--surface);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  position: relative;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 16px;
  margin-top: 18px;
}

.detail-list dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.viewer-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.viewer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  z-index: 20;
}

.viewer-topbar h1 {
  margin: 4px 0 0;
  font-size: 20px;
}

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

.viewer-main {
  flex: 1;
  min-height: 0;
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.viewer-frame-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #fff;
}

.viewer-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.comments-backdrop {
  position: fixed;
  inset: 64px 0 0 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 30;
  backdrop-filter: blur(1px);
}

.comments-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 35;
  border: 0;
  border-radius: 10px 0 0 10px;
  padding: 14px 10px;
  background: var(--brand);
  color: #fff;
  box-shadow: -4px 0 18px rgba(196, 79, 47, 0.28);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, right 0.25s ease;
}

.comments-tab:hover {
  transform: translateY(-50%) translateX(-2px);
}

.comments-tab-label {
  writing-mode: vertical-rl;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
}

.comments-tab-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

.comments-tab.has-comments .comments-tab-count {
  background: #fff;
  color: var(--brand);
}

.comments-drawer {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: var(--comments-drawer-width);
  max-width: calc(100vw - 48px);
  z-index: 40;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.16);
  display: flex;
  flex-direction: column;
  padding: 16px 16px 18px 12px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.comments-drawer.is-open {
  transform: translateX(0);
}

body.comments-drawer-open .comments-tab {
  opacity: 0;
  pointer-events: none;
}

.comments-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 2;
}

.comments-resize-handle::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 2px;
  height: 48px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--line);
}

.comments-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-left: 8px;
}

.comments-drawer-header h2 {
  margin: 0;
  font-size: 18px;
}

.comments-drawer-actions {
  display: flex;
  gap: 6px;
}

.comments-drawer.is-wide {
  --comments-drawer-width: 480px;
}

body.is-resizing-comments {
  cursor: col-resize;
  user-select: none;
}

.comment-count {
  color: var(--muted);
  font-size: 13px;
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg);
}

.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.comment-meta strong {
  font-size: 14px;
}

.comment-meta time,
.comment-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.comment-item p {
  color: var(--text);
  margin-bottom: 8px;
}

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

.comment-replies {
  list-style: none;
  margin: 10px 0 0;
  padding: 0 0 0 12px;
  border-left: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-item-reply {
  background: var(--surface);
  border-style: dashed;
}

.comment-reply-bar {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.comment-reply-bar strong {
  color: var(--text);
}

.comment-empty {
  color: var(--muted);
  text-align: center;
  padding: 20px 8px;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.comment-form textarea {
  resize: vertical;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.comment-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-comments {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.detail-comments-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.detail-comments-header h3 {
  margin: 0;
}

.permission-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.permission-rule-card {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.permission-rule-card strong {
  font-size: 14px;
}

.permission-rule-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.permission-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  min-height: 420px;
}

.permission-sidebar,
.permission-main {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
}

.permission-sidebar-head,
.permission-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.permission-sidebar-head h3,
.permission-main-head h3 {
  margin: 0;
  font-size: 16px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-weight: 700;
}

.dept-tree {
  max-height: 520px;
  overflow: auto;
}

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

.dept-tree-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dept-tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dept-tree-toggle,
.dept-tree-spacer {
  flex: 0 0 24px;
  width: 24px;
  height: 32px;
}

.dept-tree-toggle {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  line-height: 1;
}

.dept-tree-toggle:hover {
  background: rgba(37, 99, 168, 0.12);
  color: var(--blue);
}

.dept-tree-item {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
}

.dept-tree-item:hover,
.dept-tree-item.active {
  background: rgba(37, 99, 168, 0.12);
  color: var(--blue);
}

.empty-tree {
  margin: 0;
  color: var(--muted);
}

.permission-search {
  flex: 1;
  min-width: 220px;
}

.permission-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.permission-table-wrap {
  overflow: auto;
  max-height: 520px;
  background: var(--surface);
  border-radius: 8px;
}

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

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

.permission-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  font-size: 13px;
  color: var(--muted);
}

.permission-table code {
  font-size: 12px;
  word-break: break-all;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
}

.system-subtabs {
  float: left;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 22px 0 0;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 8px;
}

.system-subtab {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.system-subtab:hover {
  background: rgba(37, 99, 168, 0.08);
}

.system-subtab.active {
  background: var(--surface);
  color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.system-panel {
  margin-left: 202px;
  min-width: 0;
}

.system-panel[hidden] {
  display: none;
}

.rbac-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.rbac-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

#rbacDialogForm label:has(input[name="code"]) {
  display: none;
}

.rbac-dialog-card {
  width: min(640px, calc(100vw - 32px));
}

.publish-dialog-card {
  width: min(820px, calc(100vw - 32px));
}

.publish-dialog-card .publish-panel {
  background: transparent;
}

.skill-dialog-card {
  width: min(860px, calc(100vw - 32px));
}

.skill-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.skill-form textarea,
#skillRunInput {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.skill-db-permissions {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.skill-db-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.skill-db-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.skill-db-option:first-of-type {
  border-top: 0;
}

.skill-db-option input {
  margin-top: 3px;
}

.skill-db-option span {
  display: grid;
  gap: 3px;
}

.skill-db-option small {
  color: var(--muted);
}

.skill-output {
  margin-top: 14px;
}

.skill-output pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
}

.skill-runs {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.skill-runs h4 {
  margin: 0 0 8px;
}

.skill-run-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.settings-form {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
}

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

.settings-grid label:last-child {
  grid-column: 1 / -1;
}

.llm-settings {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
}

.llm-config-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.llm-config-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.llm-config-head,
.llm-config-options {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.llm-config-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.llm-config-options {
  margin-top: 12px;
}

.rbac-dialog-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.rbac-menu-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.rbac-menu-option {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.rbac-menu-option:hover {
  background: #eef4fd;
}

.rbac-menu-checkbox {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  justify-self: center;
}

.rbac-menu-name {
  min-width: 0;
  line-height: 1.4;
  word-break: break-word;
}

.rbac-menu-code {
  justify-self: end;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 980px) {
  .metrics,
  .asset-grid,
  .asset-form,
  .governance-grid,
  .component-grid,
  .permission-rules {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .permission-layout {
    grid-template-columns: 1fr;
  }

  .system-subtabs {
    float: none;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    margin: 0 0 16px;
  }

  .system-subtab {
    width: auto;
  }

  .system-panel {
    margin-left: 0;
  }

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

@media (max-width: 640px) {
  .topbar,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .publish-inline {
    grid-template-columns: 1fr;
  }

  .topbar,
  .tabs,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .metrics,
  .asset-grid,
  .asset-form,
  .governance-grid,
  .component-grid,
  .permission-rules,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .card-actions {
    flex-wrap: wrap;
  }

  .comments-drawer {
    max-width: calc(100vw - 16px);
  }

  .comments-tab {
    padding: 12px 8px;
  }
}
