/* ===== CSS 变量 ===== */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --green: #16a34a;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --sidebar-width: 200px;
  --sidebar-collapsed-width: 56px;
  --topbar-height: 60px;
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

/* ===== 整体布局 ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  z-index: 100;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.02em;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-toggle:hover {
  background: var(--panel-soft);
  color: var(--text);
}

/* 侧边栏导航 */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.nav-group-label {
  display: block;
  padding: 6px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
}

/* 导航按钮（同时作为 tab-button） */
.nav-item {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.12s, color 0.12s;
  position: relative;
}

.nav-item:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

/* 侧边栏底部状态 */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.status-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ===== 折叠状态 ===== */
.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

/* P9：折叠后 header 改为居中，避免 toggle 偏右 */
.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

.sidebar-collapsed .sidebar-logo,
.sidebar-collapsed .nav-group-label,
.sidebar-collapsed .status-label {
  display: none;
}

.sidebar-collapsed .nav-item {
  padding: 0;
  justify-content: center;
}

.sidebar-collapsed .nav-item.active::before {
  display: none;
}

.sidebar-collapsed .toggle-icon {
  transform: rotate(180deg);
  display: inline-block;
}

/* ===== 主内容区 ===== */
.content-area {
  flex: 1;
  width: 100%; /* P6：确保充满剩余空间（Safari 兼容） */
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.sidebar-collapsed .content-area {
  margin-left: var(--sidebar-collapsed-width);
}

/* ===== 顶部配置栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-fields {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.topbar-field {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.topbar-field span {
  flex-shrink: 0;
}

.topbar-field input,
.topbar-field select {
  height: 34px;
  min-width: 0;
  width: auto;
}

/* P4：用具体类名替代脆弱的 nth-child 选择器 */
.topbar-field.topbar-token input {
  width: 220px;
}

.topbar-field.topbar-project input {
  width: 160px;
}

.topbar-checkbox {
  flex-shrink: 0;
}

.topbar-checkbox input {
  width: auto;
  height: auto;
}

.topbar-refresh {
  flex-shrink: 0;
  height: 34px;
  padding: 0 14px;
}

/* ===== 内容区内部 ===== */
.content-inner {
  padding: 20px 24px 48px;
  max-width: 1200px;
}

/* ===== 通用元素 ===== */
p {
  margin: 0;
  color: var(--muted);
}

h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

h3 {
  margin: 0;
  font-size: 15px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  align-self: end;
  gap: 8px;
  height: 40px;
}

.checkbox-label input {
  width: auto;
  height: auto;
}

.inline-select {
  min-width: 140px;
}

input,
select,
textarea,
button {
  border-radius: var(--radius);
  border: 1px solid #d0d5dd;
  font: inherit;
}

input,
select,
button {
  height: 36px;
}

input,
select,
textarea {
  width: 100%;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button {
  align-self: end;
  padding: 0 16px;
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hint {
  margin-bottom: 16px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.error {
  display: none;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #991b1b;
  white-space: pre-wrap;
}

/* ===== Tab 面板 ===== */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ===== 数据卡片 ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.card {
  padding: 14px 16px;
}

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

.card strong {
  font-size: 26px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.card .card-link {
  color: var(--primary);
  font-size: 15px;
  letter-spacing: 0;
  text-decoration: none;
}

.card .card-link:hover {
  text-decoration: underline;
}

/* ===== 布局网格 ===== */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.section {
  padding: 16px;
}

.section h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

/* ===== Agent 运行时 ===== */
.agent-runtime-layout {
  display: grid;
  gap: 14px;
}

.agent-runtime-card {
  display: grid;
  gap: 14px;
  max-width: 540px;
  padding: 16px;
}

.agent-runtime-card span {
  color: var(--muted);
  font-size: 13px;
}

.agent-runtime-card h3 {
  margin: 0;
  font-size: 16px;
}

.agent-runtime-card > strong {
  color: var(--primary);
  font-size: 36px;
  letter-spacing: -0.05em;
}

.agent-runtime-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.agent-runtime-metrics div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
}

.agent-runtime-metrics small {
  color: var(--muted);
  font-size: 12px;
}

.agent-runtime-metrics b {
  font-size: 16px;
}

.agent-runtime-breakdown,
.agent-runtime-models {
  padding: 14px;
  overflow-x: auto;
}

.agent-runtime-breakdown h3,
.agent-runtime-models h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.agent-runtime-models {
  margin-top: 14px;
}

/* ===== Agent 异常日志 ===== */
.agent-error-panel {
  margin-top: 14px;
}

.agent-error-config {
  display: grid;
  grid-template-columns: 140px minmax(280px, 1fr) 140px;
  align-items: end;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.agent-error-switch,
.agent-error-select-all {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-error-switch {
  height: 36px;
  color: var(--text);
  font-weight: 600;
}

.agent-error-switch input,
.agent-error-select-all input,
.agent-error-check-cell input {
  width: auto;
  height: auto;
}

.agent-error-version-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.agent-error-version-input button,
.agent-error-config > button {
  align-self: auto;
  white-space: nowrap;
}

.agent-error-versions {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  min-height: 28px;
}

.agent-error-version-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 5px 4px 9px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
}

.agent-error-version-chip button {
  width: 22px;
  height: 22px;
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.agent-error-version-empty {
  color: var(--muted);
  font-size: 12px;
}

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

.agent-error-cards .card strong {
  font-size: 20px;
}

.agent-error-select-all {
  width: fit-content;
  margin: 14px 0 8px;
}

.agent-error-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.agent-error-table {
  min-width: 1280px;
  table-layout: fixed;
}

.agent-error-table th:first-child,
.agent-error-check-cell {
  width: 44px;
}

.agent-error-table th:nth-child(2),
.agent-error-time-cell {
  width: 170px;
}

.agent-error-table th:nth-child(3),
.agent-error-table th:nth-child(4) {
  width: 90px;
}

.agent-error-table th:nth-child(5),
.agent-error-model-cell {
  width: 160px;
}

.agent-error-table th:nth-child(6),
.agent-error-client-cell {
  width: 150px;
}

.agent-error-model-cell code,
.agent-error-client-cell code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-error-summary-cell {
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.agent-error-table th:nth-child(8) {
  width: 110px;
}

.agent-error-table th:last-child,
.agent-error-row-actions {
  width: 150px;
}

.agent-error-row-actions button {
  height: 28px;
  padding: 0 9px;
}

.agent-error-row-actions button + button {
  margin-left: 5px;
}

.agent-error-pager {
  justify-content: flex-end;
  margin-top: 12px;
}

.agent-error-delete-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
}

.agent-error-delete-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.agent-error-delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.agent-error-delete-actions button {
  align-self: auto;
}

/* ===== section 头部 ===== */
#tab-traffic > .panel.section {
  margin-bottom: 14px;
}

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

.section-head h2 {
  margin: 0;
}

.section-head p {
  margin-top: 4px;
  line-height: 1.5;
  font-size: 13px;
}

.section-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.section-actions button {
  align-self: auto;
}

/* ===== 分页 ===== */
.pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}

.pager button {
  align-self: auto;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
}

.pager input {
  width: 64px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
}

/* ===== 筛选行 ===== */
.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

/* ===== 按钮变体 ===== */
.link-button {
  align-self: auto;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--primary);
  background: #eff6ff;
  border-color: #bfdbfe;
}

.secondary-button {
  color: var(--primary);
  background: #eff6ff;
  border-color: #bfdbfe;
}

.danger-button {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

/* ===== 客户端详情弹窗 ===== */
.client-dialog {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.client-dialog::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

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

.dialog-head h2 {
  margin: 0 0 4px;
}

.dialog-head button {
  align-self: auto;
}

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

.usage-card {
  min-width: 0;
  overflow-x: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
}

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

.usage-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

/* ===== 公告管理 ===== */
.notice-panel {
  margin-bottom: 14px;
}

.notice-form {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
  margin-top: 12px;
}

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

.notice-meta,
.notice-status {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: pre-wrap;
}

.notice-status {
  display: none;
  margin-top: 10px;
}

.notice-status.ok {
  display: block;
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.notice-status.error {
  display: block;
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

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

.notice-actions button {
  align-self: auto;
}

/* ===== 授权管理 ===== */
.license-management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.license-management-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.license-management-card h3 {
  margin: 0;
  font-size: 15px;
}

#licenseOfflineCode {
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
  word-break: break-all;
}

/* ===== 资源管理 ===== */
.resource-panel {
  margin-bottom: 14px;
}

.resource-head-actions,
.resource-actions,
.resource-row-actions {
  display: flex;
  gap: 8px;
}

.resource-head-actions {
  flex: 0 0 auto;
  margin-left: auto;
}

.resource-head-actions button,
.resource-actions button,
.resource-row-actions button {
  align-self: auto;
  white-space: nowrap;
}

.resource-head-actions button {
  min-width: 90px;
}

.resource-form {
  display: grid;
  grid-template-columns: 170px 1.2fr 1fr 150px 110px;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.resource-image-editor {
  display: grid;
  grid-row: span 4;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.resource-image-preview {
  display: grid;
  min-height: 120px;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
}

.resource-image-preview img {
  width: 100%;
  height: 120px;
  object-fit: contain;
}

.resource-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.resource-checkbox-row input {
  width: auto;
  height: auto;
}

.resource-field-wide,
.resource-actions {
  grid-column: 2 / -1;
}

.resource-actions {
  justify-content: flex-end;
}

.resource-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.resource-table {
  min-width: 960px;
  table-layout: fixed;
}

.resource-image-cell {
  width: 88px;
}

.resource-title-cell {
  width: 180px;
}

.resource-tags-cell {
  width: 90px;
}

.resource-modal-cell {
  width: 210px;
}

.resource-row-actions {
  width: 120px;
}

.resource-thumb,
.resource-thumb-placeholder {
  display: grid;
  width: 70px;
  height: 54px;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.resource-thumb {
  object-fit: contain;
}

/* P8：资源标题列去掉 nowrap，改为截断省略 */
.resource-title-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-title-cell small {
  white-space: nowrap;
}

.resource-tag-list span {
  white-space: nowrap;
}

.resource-tag-list {
  display: grid;
  align-content: start;
  gap: 4px;
}

.resource-description-cell,
.resource-modal-cell {
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: break-word;
}

.resource-row-actions button {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ===== 插件管理 ===== */
.plugin-form {
  display: grid;
  grid-template-columns: 1.5fr 160px 120px;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

.plugin-field-wide small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.plugin-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.plugin-actions button {
  align-self: auto;
}

.plugin-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.plugin-table {
  min-width: 900px;
  table-layout: fixed;
}

.plugin-icon-cell {
  width: 60px;
}

.plugin-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.plugin-icon-placeholder {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.plugin-name-cell {
  width: 200px;
}

.plugin-tags-cell {
  width: 100px;
}

.plugin-description-cell {
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: break-word;
}

.plugin-repository-cell {
  width: 100px;
}

.plugin-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.plugin-tag-list span {
  display: inline-block;
  padding: 2px 6px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

.plugin-row-actions {
  width: 120px;
}

.plugin-row-actions button,
.resource-row-actions button {
  display: inline-flex;
  align-items: center;
}

/* ===== 模型信息索引 ===== */
.model-info-index-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.model-info-index-head h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.model-info-index-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.model-info-filters {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 150px;
  gap: 10px;
  flex-shrink: 0;
}

.model-info-table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.model-info-table {
  min-width: 1080px;
  table-layout: fixed;
}

.model-info-table th:first-child,
.model-info-name-cell {
  width: 280px;
}

.model-info-table th:nth-child(2) {
  width: 230px;
}

.model-info-table th:nth-child(3),
.model-info-table th:nth-child(4),
.model-info-number-cell {
  width: 120px;
  font-variant-numeric: tabular-nums;
}

.model-info-table th:nth-child(5) {
  width: 100px;
}

.model-info-table th:nth-child(6),
.model-info-time-cell {
  width: 170px;
}

.model-info-table th:last-child,
.model-info-row-actions {
  width: 170px;
}

.model-info-name-cell code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-info-table tr.is-overridden td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}

.model-info-efforts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.model-info-efforts span,
.model-info-source {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  color: #344054;
  background: #eef2f7;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.model-info-source.is-overridden {
  color: #1d4ed8;
  background: var(--primary-soft);
  font-weight: 600;
}

.model-info-empty-value,
.model-info-time-cell {
  color: var(--muted);
}

.model-info-row-actions button {
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.model-info-row-actions button + button {
  margin-left: 4px;
}

.model-info-pager {
  justify-content: flex-end;
  margin-top: 12px;
}

.model-info-edit-dialog {
  width: min(620px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.model-info-edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.28);
}

.model-info-edit-dialog .dialog-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.model-info-edit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.model-info-edit-fields label:first-child,
.model-info-edit-fields label:nth-child(2) {
  grid-column: 1 / -1;
}

.model-info-edit-fields small {
  font-size: 12px;
}

.model-info-edit-fields input[readonly] {
  color: var(--muted);
  background: var(--panel-soft);
}

.model-info-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.model-info-edit-actions button {
  align-self: auto;
}

/* ===== 表格通用 ===== */
td small {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--panel-soft);
  font-weight: 600;
  font-size: 12px;
}

/* P7：hover 背景加在 tr 上而非 td，避免 border-collapse 下分割线消失 */
tbody tr:hover {
  background: #f8fafc;
}

tbody tr:hover td {
  background: transparent;
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #eef2f7;
  color: #344054;
  word-break: break-all;
  font-size: 12px;
}

.empty {
  padding: 24px;
  border: 1px dashed #d0d5dd;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--panel-soft);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  flex-shrink: 0;
}

.dot.ok { background: var(--green); }
.dot.error { background: var(--danger); }

/* ===== 遮罩（窄屏抽屉用） ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(15, 23, 42, 0.32);
}

.sidebar-drawer-open .sidebar-overlay {
  display: block;
}

/* P3：去掉 display:none 状态下无效的 flex 属性，改为 display:inline-flex 直接切换 */
.topbar-menu {
  display: none;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  /* 窄屏：侧栏默认完全隐藏，点菜单后以抽屉形式滑入 */
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.2s ease; /* P5：统一过渡时长 */
    box-shadow: none;
  }

  .sidebar-drawer-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  /* 窄屏下 sidebar-collapsed 对侧栏宽度无影响，只影响宽屏 */
  .sidebar-collapsed .sidebar {
    width: var(--sidebar-width);
  }

  .content-area {
    margin-left: 0;
  }

  .sidebar-collapsed .content-area {
    margin-left: 0;
  }

  /* P3：窄屏显示汉堡按钮 */
  .topbar-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-fields {
    flex-wrap: wrap;
    height: auto;
  }

  .topbar {
    height: auto;
    padding: 10px 12px;
  }

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

  .grid,
  .agent-runtime-metrics,
  .agent-error-config,
  .usage-grid,
  .filter-row,
  .notice-form,
  .resource-form,
  .plugin-form {
    grid-template-columns: 1fr;
  }

  .agent-error-versions {
    grid-column: auto;
  }

  .model-info-index-head {
    align-items: stretch;
    flex-direction: column;
  }

  .model-info-filters,
  .model-info-edit-fields {
    grid-template-columns: 1fr;
  }

  .model-info-edit-fields label:first-child,
  .model-info-edit-fields label:nth-child(2) {
    grid-column: auto;
  }

  .notice-actions,
  .resource-head-actions,
  .resource-actions,
  .plugin-actions,
  .section-actions {
    flex-wrap: wrap;
  }

  .resource-image-editor,
  .resource-field-wide,
  .resource-actions,
  .plugin-field-wide,
  .plugin-actions {
    grid-column: auto;
  }

  /* P1：只对表单操作区按钮应用全宽，排除表格/分页/顶栏/导航等控件按钮 */
  .notice-actions button,
  .resource-actions button,
  .resource-head-actions button,
  .plugin-actions button,
  .section-actions button,
  .license-management-card .notice-actions button {
    width: 100%;
  }
}
