:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --soft: #f2f4f7;
  --blue: #2563eb;
  --danger-bg: #fee4e2;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

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

a {
  color: var(--blue);
  text-decoration: none;
}

.nav {
  height: 72px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 48px;
  gap: 42px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.nav-user {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.brand {
  font-size: 22px;
  font-weight: 700;
}

.tab {
  height: 72px;
  display: inline-flex;
  align-items: center;
  color: #475467;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--blue);
}

.wrap {
  width: min(1120px, calc(100vw - 48px));
  margin: 56px auto 80px;
}

.query-wrap {
  width: min(940px, calc(100vw - 48px));
}

.hero {
  text-align: center;
  margin-top: 52px;
}

.hero h1,
.page-title h1 {
  font-size: 44px;
  line-height: 1.1;
  margin: 0 0 14px;
  letter-spacing: 0;
}

.hero p,
.page-title p {
  margin: 0;
  color: var(--muted);
}

.need-box {
  margin-top: 34px;
  width: 100%;
  min-height: 180px;
  border: 1px solid #d0d5dd;
  border-radius: 14px;
  background: var(--panel);
  padding: 22px;
  color: var(--text);
  resize: vertical;
  outline: none;
}

.need-box:focus,
.search-input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin: 24px 0 12px;
}

.btn {
  border: 1px solid #d0d5dd;
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 22px;
  cursor: pointer;
}

.btn.primary {
  background: #111827;
  border-color: #111827;
  color: #fff;
}

.btn.secondary {
  background: var(--panel);
  border-color: #98a2b3;
  color: #344054;
}

.btn.link {
  border-color: transparent;
  background: transparent;
  color: var(--blue);
  padding-left: 8px;
  padding-right: 8px;
}

.btn.small {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 14px;
}

.btn.full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.file-note,
.status-line {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.mode-line {
  min-height: 22px;
  color: #475467;
  font-size: 13px;
  text-align: center;
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 56px 0 24px;
}

.section-title h2 {
  margin: 0;
  font-size: 24px;
}

.section-title::after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}

.empty-panel,
.card,
.toolbar,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.empty-panel {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.empty-panel p {
  margin: 0 0 18px;
}

.card {
  padding: 26px;
  margin-bottom: 18px;
}

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

.card h3 {
  margin: 0 0 6px;
  font-size: 24px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: #475467;
  padding: 5px 11px;
  font-size: 13px;
  white-space: nowrap;
}

.pill.pending {
  background: var(--danger-bg);
  color: var(--danger);
}

.detail-row {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 24px;
  margin-top: 16px;
  line-height: 1.7;
}

.detail-label {
  color: var(--muted);
}

.notice {
  border-radius: 10px;
  background: var(--soft);
  color: #344054;
  padding: 14px 16px;
}

.submit-new {
  text-align: center;
  color: var(--muted);
  margin: 28px 0;
}

.need-submit-inline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.back-link {
  display: inline-flex;
  margin-bottom: 24px;
  color: var(--blue);
  font-size: 14px;
}

.login-title {
  margin-bottom: 26px;
  text-align: center;
}

.login-title h1 {
  margin: 0 0 10px;
  font-size: 28px;
}

.login-title p {
  margin: 0;
  color: var(--muted);
}

.form-error {
  min-height: 22px;
  margin: 8px 0 14px;
  color: var(--danger);
  font-size: 14px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.head-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar {
  margin-top: 34px;
  padding: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.search-input {
  width: min(520px, 100%);
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
}

.count {
  color: var(--muted);
  white-space: nowrap;
}

.table-wrap {
  margin-top: 22px;
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

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

th {
  color: #475467;
  background: #fcfcfd;
  font-weight: 600;
}

td {
  color: #344054;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.admin-models-page.modal-open {
  overflow: hidden;
}

.admin-models-page .wrap {
  width: min(1280px, calc(100vw - 48px));
}

.admin-models-page .table-wrap {
  border-radius: 12px;
}

.admin-model-table {
  min-width: 1180px;
  table-layout: fixed;
}

.admin-model-table .col-name {
  width: 180px;
}

.admin-model-table .col-model-type {
  width: 120px;
}

.admin-model-table .col-business-type {
  width: 100px;
}

.admin-model-table .col-scene {
  width: 240px;
}

.admin-model-table .col-model-code {
  width: 180px;
}

.admin-model-table .col-short-code {
  width: 100px;
}

.admin-model-table .col-detail {
  width: 110px;
}

.admin-model-table .col-actions {
  width: 100px;
}

.admin-model-table th,
.admin-model-table td {
  padding: 15px 16px;
  font-size: 14px;
  line-height: 1.55;
}

.admin-model-table th {
  color: #344054;
  font-weight: 650;
  white-space: nowrap;
}

.admin-model-table tbody tr:hover td {
  background: #f9fafb;
}

.admin-model-table .name-cell,
.admin-model-table .scene-cell {
  word-break: break-word;
}

.admin-model-table .table-tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.admin-model-table .code-cell {
  color: #344054;
}

.admin-model-table .code-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #344054;
  background: #f9fafb;
  border: 1px solid #eaecf0;
  border-radius: 7px;
  padding: 4px 7px;
}

.admin-model-table .actions-cell {
  white-space: nowrap;
}

.admin-model-table th:last-child,
.admin-model-table td:last-child {
  position: sticky;
  right: 0;
  background: var(--panel);
  box-shadow: -8px 0 14px rgba(16, 24, 40, 0.04);
}

.admin-model-table th:last-child {
  background: #fcfcfd;
}

.admin-model-table tbody tr:hover td:last-child {
  background: #f9fafb;
}

.table-action {
  min-width: 58px;
  padding: 7px 12px;
  border-radius: 8px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
}

.empty-state {
  padding: 42px 18px !important;
  color: var(--muted);
  text-align: center;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.32);
  display: none;
  z-index: 20;
}

.drawer-backdrop.open {
  display: grid;
  place-items: center;
  padding: 24px;
}

.drawer {
  width: min(820px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.24);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.3;
}

.drawer-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.model-form {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.form-scroll {
  overflow-y: auto;
  padding: 24px 28px 10px;
}

.form-section {
  margin-bottom: 24px;
}

.form-section h3 {
  margin: 0 0 16px;
  color: #101828;
  font-size: 15px;
  font-weight: 650;
}

.form-section + .form-section {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  color: #475467;
  margin-bottom: 7px;
  font-size: 14px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}

.model-form .field input,
.model-form .field textarea,
.model-form .field select {
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.model-form .field input,
.model-form .field select {
  height: 42px;
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.model-form .field textarea {
  min-height: 104px;
}

.model-form .field textarea.compact-textarea {
  min-height: 72px;
}

.model-form .field input.code {
  letter-spacing: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.model-form .field-grid {
  gap: 16px;
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 0;
  padding: 16px 28px 22px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

@media (max-width: 760px) {
  .nav {
    padding: 0 22px;
    gap: 18px;
    overflow-x: auto;
  }

  .nav-user {
    margin-left: 0;
  }

  .brand {
    font-size: 18px;
    min-width: max-content;
  }

  .hero h1,
  .page-title h1 {
    font-size: 32px;
  }

  .card-head,
  .page-head,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .pills {
    justify-content: flex-start;
  }

  .detail-row,
  .field-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
