:root {
  --navy: #061a33;
  --navy-2: #0a2d58;
  --blue: #0f67d8;
  --blue-2: #2593ff;
  --blue-3: #dcecff;
  --ice: #f4f9ff;
  --paper: #ffffff;
  --ink: #132033;
  --muted: #64758b;
  --line: #dbe8f6;
  --danger: #d93a3a;
  --success: #0b946d;
  --shadow-lg: 0 30px 90px rgba(6, 26, 51, 0.18);
  --shadow-md: 0 18px 48px rgba(15, 103, 216, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% -4%, rgba(37, 147, 255, 0.24), transparent 28rem),
    radial-gradient(circle at 86% 12%, rgba(15, 103, 216, 0.13), transparent 30rem),
    linear-gradient(135deg, #f7fbff 0%, #edf5ff 46%, #ffffff 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

code,
pre {
  font-family: "Cascadia Mono", "Consolas", monospace;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand-mark {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: var(--navy);
  background: linear-gradient(145deg, #ffffff, #dbeeff);
  font-size: 20px;
  font-weight: 950;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
}

.brand-mark.small {
  width: 50px;
  height: 50px;
  border-radius: 17px;
  color: var(--paper);
  background: linear-gradient(145deg, var(--blue), var(--blue-2));
  font-size: 15px;
  box-shadow: 0 12px 28px rgba(37, 147, 255, 0.24);
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: rgba(255, 255, 255, 0.94);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  padding: 13px 15px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-2);
  box-shadow: 0 0 0 4px rgba(37, 147, 255, 0.14);
}

.primary-btn,
.ghost-btn,
.text-btn,
.danger-btn {
  min-height: 46px;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.text-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  color: var(--paper);
  border: 0;
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  box-shadow: 0 14px 30px rgba(15, 103, 216, 0.28);
}

.ghost-btn {
  display: inline-grid;
  place-items: center;
  padding: 0 20px;
  color: var(--blue);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.text-btn {
  min-height: 38px;
  padding: 0 13px;
  color: var(--blue);
  border: 1px solid var(--blue-3);
  background: #eef7ff;
  display: inline-grid;
  place-items: center;
}

.danger-btn {
  min-height: 38px;
  padding: 0 13px;
  color: #a82020;
  border: 1px solid #ffd1d1;
  background: #fff2f2;
}

.ghost-btn.disabled {
  color: #9aabba;
  cursor: not-allowed;
  background: #f4f7fa;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 13px 15px;
  border-radius: 16px;
  font-weight: 800;
  background: #eff7ff;
  border: 1px solid var(--blue-3);
}

.flash.error {
  color: #9d2020;
  border-color: #ffd4d4;
  background: #fff4f4;
}

.flash.success {
  color: #087152;
  border-color: #c5efe4;
  background: #effff9;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px;
  overflow: hidden;
}

.login-shell {
  position: relative;
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  min-height: 700px;
  border: 1px solid rgba(219, 232, 246, 0.9);
  border-radius: 36px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 28px;
  pointer-events: none;
  z-index: 2;
}

.intro-panel {
  position: relative;
  padding: 68px;
  color: var(--paper);
  background:
    linear-gradient(135deg, rgba(6, 26, 51, 0.98), rgba(15, 103, 216, 0.86)),
    radial-gradient(circle at 78% 18%, rgba(255, 255, 255, 0.24), transparent 18rem);
  overflow: hidden;
}

.intro-panel::before {
  content: "";
  position: absolute;
  right: -110px;
  top: -110px;
  width: 330px;
  height: 330px;
  border: 54px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.intro-panel .eyebrow {
  margin-top: 86px;
  color: #b9ddff;
}

.intro-panel h1 {
  max-width: 560px;
  margin: 0;
  font-size: clamp(44px, 6vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.intro-copy {
  max-width: 540px;
  margin: 30px 0 52px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 17px;
  line-height: 1.9;
}

.intro-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.intro-grid div {
  min-height: 140px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
}

.intro-grid strong,
.intro-grid span {
  display: block;
}

.intro-grid strong {
  font-size: 18px;
}

.intro-grid span {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.6;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 62px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 251, 255, 0.96));
}

.card-heading {
  margin-bottom: 30px;
}

.card-heading h2 {
  margin: 0;
  font-size: 36px;
  letter-spacing: -0.04em;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.form-stack label,
.modal-label {
  display: grid;
  gap: 9px;
  font-weight: 800;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px;
  align-items: center;
}

.captcha-row img {
  width: 180px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  background: var(--ice);
}

/* Admin */
.admin-page {
  min-height: 100vh;
}

.admin-main {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.admin-header {
  position: sticky;
  top: 14px;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid rgba(219, 232, 246, 0.92);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 46px rgba(6, 26, 51, 0.08);
  backdrop-filter: blur(20px);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-brand strong,
.admin-brand span {
  display: block;
}

.admin-brand strong {
  font-size: 18px;
}

.admin-brand span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f4f9ff;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tab-btn {
  min-width: 112px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.tab-btn.active {
  color: var(--paper);
  background: linear-gradient(135deg, var(--blue), var(--blue-2));
  box-shadow: 0 10px 22px rgba(15, 103, 216, 0.24);
}

.workspace-switch {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  width: fit-content;
  margin: 0 0 22px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 34px rgba(6, 26, 51, 0.07);
}

.switch-btn {
  min-width: 126px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 950;
}

.switch-btn.active {
  color: var(--paper);
  background: linear-gradient(135deg, var(--navy-2), var(--blue));
  box-shadow: 0 10px 24px rgba(10, 45, 88, 0.2);
}

.list-panel {
  display: none;
}

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

.logout-link {
  display: grid;
  place-items: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.9);
  font-weight: 900;
}

button.logout-link {
  cursor: pointer;
}

.tab-panel {
  display: none;
}

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

.generate-panel {
  position: relative;
  display: block;
  margin-bottom: 22px;
  padding: 0;
  min-height: 260px;
  border: 1px solid rgba(219, 232, 246, 0.94);
  border-radius: 0;
  background:
    linear-gradient(115deg, transparent 0 58%, rgba(15, 103, 216, 0.07) 58% 64%, transparent 64%),
    radial-gradient(circle at 82% 40%, rgba(37, 147, 255, 0.16), transparent 20rem),
    linear-gradient(135deg, #f3f9ff 0%, #eaf4ff 100%);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.generate-panel::after {
  content: "";
  position: absolute;
  right: -58px;
  bottom: -168px;
  width: 390px;
  height: 390px;
  border: 58px solid rgba(15, 103, 216, 0.06);
  border-radius: 999px;
}

.generate-copy {
  position: relative;
  z-index: 1;
}

.generate-copy h1 {
  margin: 0;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1;
  letter-spacing: -0.06em;
}

.generate-copy p:last-child {
  max-width: 560px;
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.generate-form {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto;
  gap: 24px;
  align-items: end;
  width: calc(100% - 68px);
  margin: 48px 34px 0;
  padding: 32px 34px;
  border: 1px solid #cfe3fa;
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 24px 70px rgba(6, 26, 51, 0.08);
  backdrop-filter: blur(12px);
}

.generate-form label {
  display: grid;
  gap: 14px;
  font-weight: 900;
}

.generate-form label span {
  color: #061a33;
  font-size: 18px;
  font-weight: 950;
}

.generate-form input {
  min-height: 72px;
  border-radius: 22px;
  color: #061a33;
  font-size: 24px;
  font-weight: 900;
}

.generate-form .primary-btn {
  min-height: 72px;
  padding: 0 18px;
  border-radius: 22px;
  font-size: 18px;
}

.generated-ribbon {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 22px;
  border: 1px solid #b9dcff;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(15, 103, 216, 0.1), rgba(255, 255, 255, 0.88));
}

.generated-ribbon h2 {
  margin: 0;
  font-size: 22px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.task-card,
.empty-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.task-card.active {
  border-color: #8cc7ff;
  box-shadow: 0 0 0 4px rgba(37, 147, 255, 0.12);
}

.task-topline,
.task-stats,
.task-actions,
.pagination-bar,
.pager-actions {
  display: flex;
  align-items: center;
}

.task-topline,
.pagination-bar {
  justify-content: space-between;
}

.task-topline span,
.task-main span,
.task-note,
.pagination-bar span,
.muted-text {
  color: var(--muted);
}

.task-main {
  margin: 18px 0 12px;
}

.task-main strong {
  color: var(--navy-2);
  font-size: 38px;
  letter-spacing: -0.05em;
}

.task-main span {
  display: block;
  margin-top: 6px;
}

.task-stats {
  flex-wrap: wrap;
  gap: 8px;
}

.task-stats span {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--blue);
  background: #edf7ff;
  font-size: 12px;
  font-weight: 900;
}

.task-note {
  min-height: 42px;
  margin: 14px 0;
  line-height: 1.6;
}

.task-actions,
.pager-actions {
  gap: 10px;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 42px rgba(6, 26, 51, 0.08);
}

.metric-card {
  position: relative;
  padding: 24px;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -38px;
  width: 110px;
  height: 110px;
  border-radius: 999px;
  background: rgba(37, 147, 255, 0.12);
}

.metric-card span,
.panel-title span {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  color: var(--navy-2);
  font-size: 36px;
  letter-spacing: -0.05em;
}

.panel {
  padding: 24px;
  margin-bottom: 22px;
}

.elevated-panel {
  box-shadow: var(--shadow-md);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.panel-title h1,
.panel-title h2 {
  margin: 0;
  letter-spacing: -0.04em;
}

.panel-title h1 {
  font-size: 42px;
}

.panel-title h2 {
  font-size: 26px;
}

.filter-form {
  display: grid;
  grid-template-columns: 240px 150px 88px;
  gap: 12px;
  align-items: end;
}

.filter-form input,
.filter-form select,
.filter-form .ghost-btn {
  min-height: 44px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: var(--paper);
}

.task-table {
  min-width: 1180px;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: -8px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f7fbff;
}

.bulk-toolbar span {
  margin-right: auto;
  color: var(--muted);
}

.bulk-toolbar strong {
  color: var(--blue);
}

.row-check {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
}

.selected-row {
  background: #eef7ff;
}

th,
td {
  padding: 17px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(180deg, #f7fbff, #edf6ff);
}

tbody tr:hover {
  background: #f8fbff;
}

.card-key {
  color: var(--navy-2);
  font-weight: 900;
}

.task-link {
  color: var(--blue);
  font-weight: 900;
}

.note-preview {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  vertical-align: middle;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status-pill.active {
  color: var(--success);
  background: #e7fff6;
}

.status-pill.disabled {
  color: #6e7886;
  background: #edf2f7;
}

.status-pill.expired,
.status-pill.invalid {
  color: var(--danger);
  background: #fff0f0;
}

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

.action-row form {
  margin: 0;
}

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

.pagination-bar {
  gap: 14px;
  margin-top: 18px;
  justify-content: center;
  text-align: center;
}

.per-page-form {
  margin: 0;
}

.per-page-form select {
  min-width: 132px;
  min-height: 46px;
  border-color: #8cc7ff;
  background: #ffffff;
}

.api-doc-panel {
  min-height: 660px;
  padding: 30px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(244, 249, 255, 0.92)),
    radial-gradient(circle at 88% 8%, rgba(37, 147, 255, 0.16), transparent 20rem);
}

.api-doc-grid {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 16px;
}

.api-code-table {
  display: grid;
  grid-template-columns: 90px 190px 1fr 80px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.api-code-table > * {
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.api-code-table > *:nth-child(-n+4) {
  color: var(--muted);
  background: #edf6ff;
  font-weight: 900;
}

.api-code-table > *:nth-child(4n) {
  border-right: 0;
}

.doc-block {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff, #f6fbff);
}

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

.doc-block strong {
  display: block;
  margin-bottom: 12px;
}

.doc-block code,
.doc-block pre {
  white-space: pre-wrap;
  word-break: break-word;
}

.doc-block pre {
  margin: 0;
  padding: 18px;
  border-radius: 16px;
  color: #d8ebff;
  background: var(--navy);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(6, 26, 51, 0.48);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.modal-backdrop.show {
  display: grid;
}

.modal-card {
  width: min(540px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 28px;
  letter-spacing: -0.04em;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

@media (max-width: 1120px) {
  .login-shell,
  .generate-panel {
    grid-template-columns: 1fr;
  }

  .intro-grid,
  .metric-grid,
  .generated-ribbon,
  .api-doc-grid,
  .api-code-table {
    grid-template-columns: 1fr 1fr;
  }

  .admin-header {
    grid-template-columns: 1fr;
  }

  .admin-tabs,
  .admin-actions,
  .logout-link {
    width: fit-content;
  }
}

@media (max-width: 760px) {
  .login-page {
    padding: 18px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    border-radius: 24px;
  }

  .intro-panel,
  .login-card,
  .generate-panel,
  .panel {
    padding: 24px;
  }

  .intro-grid,
  .metric-grid,
  .generated-ribbon,
  .api-doc-grid,
  .api-code-table,
  .generate-form,
  .filter-form {
    grid-template-columns: 1fr;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .captcha-row {
    grid-template-columns: 1fr;
  }

  .admin-main {
    width: min(100% - 28px, 1480px);
    padding-top: 14px;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-tabs {
    width: 100%;
  }

  .tab-btn {
    flex: 1;
  }
}
