/* ============================================================================
   智研网 · 全量 UI 审查与布局收口 v14
   设计范围：平台首页 / 工具中心 / 账户与算力 / 任务记录 / 管理后台。
   这是一层最后加载的“布局合同”，只修正结构、可用性与响应式边界，
   不改变任务、账户、算力和后台接口逻辑。
   ============================================================================ */

:root {
  --zy-audit-edge: clamp(16px, 3vw, 48px);
  --zy-audit-content: min(1280px, calc(100% - var(--zy-audit-edge) - var(--zy-audit-edge)));
  --zy-audit-line: #e4e8f1;
  --zy-audit-focus: rgba(91, 106, 241, .18);
}

html, body, #app {
  width: 100%;
  min-width: 0;
}
body { overflow-x: clip; }
.shell { overflow: visible; }
.page-main,
.api-page,
.task-page,
.admin-content,
.admin-panel,
.api-grid,
.api-card,
.provider-form,
.compute-balance-card,
.task-filters,
.task-searches,
.task-table,
.admin-table,
.admin-card,
.admin-overview-grid,
.admin-usage-summary,
.admin-metric-grid,
.compute-admin-list,
.compute-account-list,
.compute-code-list,
.compute-ledger-list {
  min-width: 0;
}

/* ---- Unified custom select: removes the browser-default menus everywhere in platform ---- */
.zy-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
.zy-select > select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.zy-select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 15px;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid #7d879f;
  border-bottom: 2px solid #7d879f;
  transform: rotate(45deg);
  pointer-events: none;
  transition: transform .16s ease, border-color .16s ease;
}
.zy-select.open::after {
  margin-top: -1px;
  transform: rotate(-135deg);
  border-color: #5869e8;
}
.zy-select-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 40px 10px 13px;
  border: 1px solid #dfe4ee;
  border-radius: 12px;
  background: #fff;
  color: #2c3548;
  box-shadow: 0 6px 16px rgba(27, 35, 72, .025);
  text-align: left;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.zy-select-trigger:hover { border-color: #cfd7ed; background: #fcfcff; }
.zy-select.open .zy-select-trigger,
.zy-select-trigger:focus-visible {
  border-color: #7381f2;
  box-shadow: 0 0 0 4px var(--zy-audit-focus);
  outline: 0;
}
.zy-select.is-disabled::after { opacity: .42; }
.zy-select.is-disabled .zy-select-trigger {
  background: #f7f8fb;
  color: #9aa2b2;
  cursor: not-allowed;
  box-shadow: none;
}
.zy-select-trigger-label {
  display: block;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.zy-select-menu {
  position: absolute;
  z-index: 160;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  display: none;
  max-height: min(300px, 42vh);
  overflow: auto;
  padding: 8px;
  border: 1px solid #dce2ef;
  border-radius: 14px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 48px rgba(28, 36, 79, .16);
  backdrop-filter: blur(14px);
}
.zy-select.open .zy-select-menu { display: grid; gap: 4px; }
.zy-select-group { display: grid; gap: 4px; }
.zy-select-group + .zy-select-group {
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid #eff2f7;
}
.zy-select-group-label {
  padding: 5px 8px 2px;
  color: #8a94aa;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
}
.zy-select-option {
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #344057;
  padding: 10px 11px;
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}
.zy-select-option:hover,
.zy-select-option:focus-visible {
  background: #f2f4ff;
  color: #485ade;
  outline: 0;
}
.zy-select-option.is-selected {
  background: #eef1ff;
  color: #4f62e5;
  font-weight: 760;
}
.zy-select-option:disabled { opacity: .45; cursor: not-allowed; }
.task-control .zy-select { flex: 1; }
.task-control .zy-select-trigger { min-height: 42px; border: 0; box-shadow: none; background: transparent; }
.page-size .zy-select { min-width: 112px; }
.page-size .zy-select-trigger { min-height: 34px; padding-top: 7px; padding-bottom: 7px; border: 0; box-shadow: none; background: transparent; }
.admin-service-form-grid .zy-select-trigger { min-height: 38px; padding-top: 8px; padding-bottom: 8px; font-size: 11px; border-radius: 10px; }
.admin-modal .zy-select-trigger { min-height: 42px; }

/* ---- Shared header: never clip primary navigation on medium desktop widths ---- */
.site-head .nav-shell { min-width: 0; }
.top-nav { min-width: 0; }
@media (max-width: 1060px) {
  .site-head .nav-shell { grid-template-columns: minmax(0,1fr) auto; }
  .site-head .top-nav { display: none; }
}
@media (max-width: 760px) {
  .site-head .nav-shell { width: calc(100% - 32px); }
}

/* ---- Account & compute: stable title safety zone, no compressed grid children ---- */
.api-shell .page-main {
  width: var(--zy-audit-content);
  padding-top: clamp(46px, 5vw, 72px);
}
.api-shell .api-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  margin-bottom: 26px;
}
.api-shell .api-heading > div { min-width: 0; }
.api-shell .api-heading h1 { margin-top: 16px; }
.api-shell .api-heading p { max-width: 760px; }
.api-shell .compute-balance-card,
.api-shell .api-grid,
.api-shell .api-info { width: 100%; }
.api-shell .provider-row,
.api-shell .inline-field,
.api-shell .provider-bottom,
.api-shell .platform-model-note { min-width: 0; }
.api-shell .platform-model-note { margin-left: 0; }
.api-shell .usage-metrics > div,
.api-shell .compute-rule-grid > div { min-width: 0; }

/* ---- Admin: content never overlays title areas and navigation remains reachable ---- */
.admin-shell .admin-sidebar {
  overflow: visible;
}
.admin-shell .admin-sidebar nav {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.admin-shell .admin-sidebar nav::-webkit-scrollbar { display: none; }
.admin-shell .admin-nav-item { flex: 0 0 auto; min-width: max-content; }
.admin-shell .admin-content > .admin-panel {
  display: grid;
  gap: 16px;
}
.admin-shell .admin-page-title,
.admin-shell .admin-section-head {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: start;
  gap: 18px;
  min-height: 0;
  margin: 0 !important;
  padding: 26px 28px;
}
.admin-shell .admin-page-title > div,
.admin-shell .admin-section-head > div { min-width: 0; }
.admin-shell .admin-section-head p,
.admin-shell .admin-page-title p { max-width: 720px; }
.admin-shell .admin-inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.admin-shell .admin-metric-grid,
.admin-shell .admin-overview-grid,
.admin-shell .admin-usage-summary { margin-top: 0; }
.admin-shell .compute-code-audit,
.admin-shell .compute-admin-ledger { margin-top: 0; }
.admin-shell .admin-table {
  overscroll-behavior-inline: contain;
}
/* Six columns fit cleanly on standard desktop; scroll begins only when actual space runs out. */
.admin-shell .api-admin-table .admin-table-head,
.admin-shell .api-admin-table .admin-api-row {
  min-width: 0 !important;
  grid-template-columns: minmax(178px,1.3fr) minmax(92px,.72fr) minmax(82px,.62fr) minmax(150px,1.05fr) minmax(88px,.68fr) minmax(118px,.84fr);
}
.admin-shell .admin-api-row > * { min-width: 0; }
.admin-shell .admin-api-row b,
.admin-shell .admin-api-row small,
.admin-shell .admin-api-row time,
.admin-shell .admin-api-row > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.admin-shell .compute-admin-list,
.admin-shell .compute-account-list,
.admin-shell .compute-code-list { scrollbar-gutter: stable; }

/* ---- Tool catalog: artwork supports content; it no longer consumes a quarter of every card ---- */
.tools-shell .page-main { width: var(--zy-audit-content); }
.tools-shell .catalog-grid { grid-template-columns: repeat(2, minmax(0,1fr)) !important; gap: 18px; }
.tools-shell .catalog-card {
  grid-template-columns: 144px minmax(0,1fr) auto !important;
  grid-template-rows: auto !important;
  min-height: 242px;
  gap: 16px 18px;
  padding: 20px 22px;
}
.tools-shell .catalog-art {
  width: 144px;
  min-width: 144px;
  min-height: 0;
  grid-row: auto !important;
}
.tools-shell .catalog-card .tool-visual { width: 118px; height: 118px; }
.tools-shell .catalog-card .orbital { width: 104px; height: 104px; }
.tools-shell .catalog-main { min-width: 0; }
.tools-shell .catalog-main p { margin: 8px 0 10px; }
.tools-shell .catalog-main ul { gap: 8px 12px; }
.tools-shell .catalog-action { min-width: 104px; padding-left: 0; }

/* ---- Intentional table scrolling only where columns cannot remain readable ---- */
.task-shell .task-table,
.admin-shell .users-table,
.admin-shell .admin-task-table,
.admin-shell .admin-audit-table { scrollbar-gutter: stable both-edges; }
.task-shell .task-table::-webkit-scrollbar,
.admin-shell .admin-table::-webkit-scrollbar { height: 9px; }
.task-shell .task-table::-webkit-scrollbar-thumb,
.admin-shell .admin-table::-webkit-scrollbar-thumb { background: #bcc3d2; border-radius: 999px; }

@media (max-width: 1180px) {
  .tools-shell .catalog-grid { grid-template-columns: minmax(0,1fr) !important; }
  .admin-shell .api-admin-table .admin-table-head,
  .admin-shell .api-admin-table .admin-api-row { min-width: 760px !important; }
}
@media (max-width: 900px) {
  .api-shell .api-heading { grid-template-columns: 1fr; }
  .api-shell .api-heading-actions { justify-content: flex-start; }
  .admin-shell .admin-page-title,
  .admin-shell .admin-section-head { grid-template-columns: 1fr; }
  .admin-shell .admin-inline-actions { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .api-shell .page-main,
  .tools-shell .page-main { width: calc(100% - 32px); }
  .api-shell .page-main { padding-top: 34px; }
  .api-shell .api-heading { margin-bottom: 20px; }
  .admin-shell .admin-page-title,
  .admin-shell .admin-section-head { padding: 22px 18px; border-radius: 18px; }
  .admin-shell .admin-inline-actions .button { flex: 1 1 auto; }
  .tools-shell .catalog-card { grid-template-columns: 1fr !important; min-height: 0; }
  .tools-shell .catalog-art { width: auto; min-width: 0; justify-self: start; }
  .tools-shell .catalog-card .tool-visual { width: 104px; height: 104px; }
  .tools-shell .catalog-card .orbital { width: 90px; height: 90px; }
  .tools-shell .catalog-action { width: 100%; }
  .tools-shell .catalog-action .button { width: 100%; }
  .zy-select-menu { max-height: 230px; }
}

/* Keep the existing compact row rhythm where a select sits inside a dense inline form. */
.inline-field .zy-select-trigger,
.mode-field .zy-select-trigger,
.admin-feedback-form .zy-select-trigger {
  min-height: 38px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 11px;
}
.task-control .zy-select {
  flex: 1 1 auto;
  min-width: 0;
}
.task-control .zy-select-trigger {
  min-height: 40px;
  border: 0;
  padding: 8px 28px 8px 0;
  box-shadow: none;
  background: transparent;
  font-size: 11px;
}
.task-control .zy-select::after { right: 3px; }
.provider-form,
.admin-service-create,
.admin-provider-config-card,
.admin-feedback-card,
.feedback-modal,
.admin-modal,
.api-card { overflow: visible; }
.provider-form .zy-select-menu,
.admin-service-create .zy-select-menu,
.admin-provider-config-card .zy-select-menu,
.admin-feedback-card .zy-select-menu,
.feedback-modal .zy-select-menu,
.admin-modal .zy-select-menu { z-index: 240; }

.admin-section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.admin-section-actions .admin-search { min-width: min(360px, 70vw); }
@media (max-width: 760px) {
  .admin-section-actions { width: 100%; justify-content: flex-start; }
  .admin-section-actions .button,
  .admin-section-actions .admin-search { width: 100%; min-width: 0; }
}
