:root {
  color-scheme: light;
  --canvas: #f5f7f8;
  --surface: #ffffff;
  --ink: #17324d;
  --muted: #5c6f82;
  --line: #d7dee5;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-pale: #e1f2ef;
  --red: #b42318;
  --red-pale: #fce8e6;
  --shadow: 0 12px 30px rgba(23, 50, 77, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 27px; line-height: 1.2; }
h2 { margin-bottom: 0; font-size: 21px; }
h3 { margin-bottom: 4px; font-size: 17px; }
h4 { margin-bottom: 4px; font-size: 14px; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.app-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-inner { display: flex; min-height: 94px; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow, .section-kicker { margin-bottom: 4px; color: var(--teal-dark); font-size: 12px; font-weight: 700; letter-spacing: 0; }
.identity { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 700; }
.main-content { padding: 34px 0 56px; }

.login-surface, .admin-section {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-surface { width: min(520px, 100%); margin: 40px auto; }
.surface-heading { padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.login-form { display: grid; gap: 17px; padding: 22px 24px; }

.field { display: grid; min-width: 0; gap: 7px; }
.field > span { color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #b9c6d2;
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}
input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14); }
textarea { min-height: 96px; resize: vertical; }

.primary-button, .secondary-button, .icon-button, .text-button {
  border-radius: 4px;
  font-weight: 700;
}
.primary-button { min-height: 40px; border: 1px solid var(--teal-dark); padding: 8px 16px; color: #fff; background: var(--teal); }
.primary-button:hover { background: var(--teal-dark); }
.primary-button:disabled { cursor: wait; opacity: .7; }
.secondary-button { border: 1px solid var(--line); padding: 6px 10px; color: var(--ink); background: var(--surface); }
.icon-button { min-height: 34px; border: 1px solid #8bb6b1; padding: 5px 10px; color: var(--teal-dark); background: #f5fbfa; }
.text-button { border: 0; padding: 3px 0; color: var(--teal-dark); background: transparent; }
.text-button:hover { text-decoration: underline; }
.text-button.is-danger { color: var(--red); }
.message { min-height: 1.5em; margin: 0; padding: 0 24px 18px; color: var(--teal-dark); font-size: 13px; }
.message.is-error { color: var(--red); }

.dashboard { display: grid; gap: 22px; }
.overview { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.overview-note { max-width: 480px; margin-bottom: 0; color: var(--muted); text-align: right; }
.admin-section { padding: 20px 22px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.account-form, .license-form { display: grid; gap: 14px; align-items: end; }
.account-form { grid-template-columns: minmax(160px, .8fr) minmax(180px, 1fr) minmax(190px, 1fr) minmax(200px, 1.3fr) auto; }
.license-form { grid-template-columns: 110px minmax(190px, .9fr) minmax(220px, 1.4fr) auto; }
.model-config-form { display: grid; gap: 14px; }
.model-config-grid { display: grid; grid-template-columns: minmax(160px, .65fr) minmax(220px, 1.1fr) minmax(170px, .8fr) minmax(240px, 1.15fr); gap: 14px; align-items: end; }
.model-config-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.model-key-status { margin: 0; color: var(--muted); font-size: 13px; }
.toggle-field { display: flex; min-height: 40px; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 700; }
.toggle-field input[type="checkbox"] {
  width: 42px;
  min-width: 42px;
  min-height: 24px;
  height: 24px;
  margin: 0;
  appearance: none;
  border: 1px solid #9baaba;
  border-radius: 999px;
  padding: 2px;
  background: #d8e0e7;
  box-shadow: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.toggle-field input[type="checkbox"]::after { display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; content: ""; transition: transform .15s ease; }
.toggle-field input[type="checkbox"]:checked { border-color: var(--teal); background: var(--teal); }
.toggle-field input[type="checkbox"]:checked::after { transform: translateX(16px); }
.toggle-field input[type="checkbox"]:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18); }
.compact { max-width: 110px; }
.generated-codes { margin-top: 16px; border: 1px solid #9dcec8; border-radius: 4px; padding: 13px; background: var(--teal-pale); }
.generated-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.generated-heading span { color: var(--muted); font-size: 12px; }
.generated-codes textarea { margin-top: 8px; background: #fff; font-family: Consolas, "Courier New", monospace; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; }
table { width: 100%; min-width: 700px; border-collapse: collapse; text-align: left; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); background: #f0f4f7; font-size: 12px; font-weight: 750; }
td { font-size: 13px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 780px) {
  .shell { width: min(100% - 28px, 1180px); }
  .header-inner, .overview { align-items: flex-start; flex-direction: column; }
  .overview-note { text-align: left; }
  .account-form, .license-form, .model-config-grid { grid-template-columns: 1fr; }
  .model-config-actions { align-items: flex-start; flex-direction: column; }
  .compact { max-width: none; }
  .admin-section { padding: 17px; }
}
