:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dbe3ee;
  --ink: #182032;
  --primary: #1f6feb;
  --teal: #0f9f8f;
  --amber: #d97706;
  --green: #16a34a;
  --red: #dc2626;
  --sidebar: #111827;
  --shadow: 0 18px 40px rgba(22, 33, 54, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  overflow: auto;
  background: var(--sidebar);
  color: #e5edf8;
}

.admin-brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 24px;
}

.admin-brand img {
  width: 42px;
  height: 42px;
  display: block;
}

.admin-brand strong {
  display: block;
  color: #fff;
  font-size: 23px;
  line-height: 1.05;
}

.admin-brand span {
  display: block;
  margin-top: 5px;
  color: #aab7c8;
  font-size: 13px;
}

.admin-nav {
  display: grid;
  gap: 7px;
}

.admin-nav button,
.admin-link {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 8px;
  color: #d5dfed;
  background: transparent;
  text-decoration: none;
  font-weight: 700;
  text-align: left;
}

.admin-nav button.active,
.admin-nav button:hover,
.admin-link:hover {
  color: #fff;
  background: #243045;
}

.admin-nav button.active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.admin-icon,
.btn-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
}

.admin-icon svg,
.admin-link > svg,
.btn-icon svg,
.kpi-icon svg,
.empty svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-link > svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.admin-sidebar-foot {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 20px;
}

.admin-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 30px;
  border-bottom: 1px solid rgba(219, 227, 238, 0.82);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
}

.admin-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
}

.admin-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.admin-user {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #31415b;
  font-size: 14px;
  font-weight: 700;
}

.admin-user span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  font-size: 13px;
}

.admin-logout {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #4b5b73;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.admin-logout:hover {
  color: var(--red);
  border-color: #fecaca;
  background: #fff5f5;
}

.admin-login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(244, 246, 250, 0.92)),
    var(--bg);
}

.admin-login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(23, 32, 51, 0.13);
}

.admin-login-brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
}

.admin-login-brand img {
  width: 48px;
  height: 48px;
  display: block;
}

.admin-login-brand strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
}

.admin-login-brand span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

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

.admin-login-error {
  margin: -2px 0 0;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  background: #fff5f5;
  font-size: 13px;
  line-height: 1.5;
}

.admin-login-submit {
  min-height: 44px;
  justify-content: center;
}

.admin-content {
  min-width: 0;
  padding: 24px 30px 40px;
}

.page {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  min-height: 122px;
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.kpi-card strong {
  color: var(--ink);
  font-size: 31px;
  line-height: 1;
}

.kpi-card em {
  color: #78869a;
  font-size: 12px;
  font-style: normal;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.kpi-icon.blue {
  color: var(--primary);
  background: #edf4ff;
}

.kpi-icon.green {
  color: var(--green);
  background: #eaf8f0;
}

.kpi-icon.teal {
  color: var(--teal);
  background: #e7f7f5;
}

.kpi-icon.amber {
  color: var(--amber);
  background: #fff3df;
}

.kpi-icon.red {
  color: var(--red);
  background: #fff0f0;
}

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

.panel-head {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  border-bottom: 1px solid #edf1f6;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 18px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.filter-panel {
  padding: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(150px, 0.7fr)) auto;
  gap: 12px;
  align-items: end;
}

.filter-grid.prompt-filter-grid {
  grid-template-columns: minmax(180px, 260px) auto;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field > span {
  color: #26364f;
  font-size: 13px;
  font-weight: 800;
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: 0;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input,
.select {
  height: 40px;
  padding: 0 11px;
}

.textarea {
  min-height: 116px;
  padding: 11px;
  resize: vertical;
  line-height: 1.65;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.input[readonly] {
  color: #637086;
  background: #f7f9fc;
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #24324a;
  background: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn.small svg {
  width: 14px;
  height: 14px;
  flex-basis: 14px;
}

.btn.primary {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.btn.teal {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.btn.warning {
  border-color: var(--amber);
  color: #fff;
  background: var(--amber);
}

.btn.danger {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.small {
  min-height: 32px;
  padding: 0 9px;
  font-size: 13px;
}

.actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

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

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: #667085;
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 900;
}

td {
  color: #29364d;
}

tbody tr:hover {
  background: #fbfcfe;
}

.title-cell {
  display: grid;
  gap: 5px;
}

.title-cell strong {
  color: #172033;
  font-size: 14px;
}

.title-cell span {
  color: #738197;
  font-size: 12px;
  word-break: break-all;
}

.tag {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: #536176;
  background: #eef2f7;
  font-size: 12px;
  font-weight: 800;
}

.tag.success {
  color: #118047;
  background: #e6f7ed;
}

.tag.warning {
  color: #b35c00;
  background: #fff1da;
}

.tag.danger {
  color: #bd2430;
  background: #ffecee;
}

.tag.info {
  color: #1556c0;
  background: #eaf2ff;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  color: #31415b;
  background: #eef3f8;
  font-size: 12px;
  font-weight: 700;
}

.package-preview {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #dce8f5;
  border-radius: 8px;
  background: #f8fbff;
}

.package-preview.full {
  grid-column: 1 / -1;
}

.package-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.package-preview-grid article {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #e5edf6;
  border-radius: 6px;
  background: #fff;
}

.package-preview-grid span {
  color: #667085;
  font-size: 12px;
  font-weight: 800;
}

.package-preview-grid strong {
  color: #16233a;
  font-size: 18px;
}

.prompt-suite {
  border: 1px solid #d9e4ef;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 159, 143, 0.1), rgba(31, 111, 235, 0.08)),
    #fff;
  box-shadow: var(--shadow);
}

.prompt-suite-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.prompt-suite-head span {
  color: #0f766e;
  font-size: 13px;
  font-weight: 900;
}

.prompt-suite-head strong {
  display: block;
  margin-top: 4px;
  color: #132033;
  font-size: 28px;
  line-height: 1.15;
}

.prompt-suite-head p {
  margin: 8px 0 0;
  color: #5d6b81;
  font-size: 14px;
}

.prompt-scene-tabs {
  min-width: 560px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.prompt-scene-tabs button {
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 40px;
  border: 1px solid #cfdbea;
  border-radius: 6px;
  color: #31415b;
  background: #fff;
  font-weight: 900;
}

.prompt-scene-tabs button small {
  color: #667085;
  font-size: 11px;
  font-weight: 800;
}

.prompt-scene-tabs button.active {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.prompt-scene-panel {
  scroll-margin-top: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #e6edf5;
  border-radius: 6px;
  background: #fbfcfe;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-item span {
  color: #6b788c;
  font-size: 12px;
  font-weight: 800;
}

.detail-item strong,
.detail-item p,
.detail-item a {
  margin: 0;
  color: #172033;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.detail-item a {
  color: var(--primary);
}

.empty {
  min-height: 150px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 30px;
  color: #7a879a;
  text-align: center;
}

.empty svg {
  width: 34px;
  height: 34px;
}

.loader {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: #6f7f94;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 19, 31, 0.55);
}

.modal {
  width: min(860px, 100%);
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 26px 80px rgba(10, 19, 32, 0.28);
}

.modal.wide {
  width: min(1120px, 100%);
}

.modal-head {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid #edf1f6;
}

.modal-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
}

.modal-body {
  min-height: 0;
  overflow: auto;
  padding: 18px 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #edf1f6;
  background: #fbfcfe;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.prompt-editor {
  min-height: 300px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 48px));
  padding: 13px 16px;
  border: 1px solid #cde1ff;
  border-radius: 8px;
  color: #172033;
  background: #fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}

@media (max-width: 1240px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .filter-grid.prompt-filter-grid,
  .package-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid .actions {
    grid-column: 1 / -1;
  }

  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-sidebar-foot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .admin-content {
    padding: 18px;
  }

  .kpi-grid,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .prompt-suite-head {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-scene-tabs {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .admin-nav,
  .admin-sidebar-foot,
  .filter-grid,
  .filter-grid.prompt-filter-grid,
  .prompt-scene-tabs,
  .package-preview-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .actions,
  .modal-actions {
    width: 100%;
  }

  .actions .btn,
  .modal-actions .btn {
    flex: 1;
  }
}
