:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #f4f6f8;
  color: #17202a;
  --admin-sidebar-width: 232px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e6faf7 0%, #f8fbf7 52%, #eef3f3 100%);
}

body.authenticated {
  display: grid;
  grid-template-columns: var(--admin-sidebar-width) 1fr;
  align-items: stretch;
  justify-content: stretch;
  background: #f4f6f8;
}

body:not(.authenticated) .sidebar,
body:not(.authenticated) .main {
  display: none;
}

.admin-login {
  width: min(920px, calc(100vw - 48px));
  min-height: 520px;
  display: grid;
  grid-template-columns: 1fr 380px;
  overflow: hidden;
  border: 1px solid #dde9e6;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 28px 80px rgba(31, 122, 88, 0.12);
}

body.authenticated .admin-login {
  display: none;
}

.login-copy {
  padding: 56px;
  background: linear-gradient(160deg, #92e4db 0%, #b8eed0 50%, #f8fbf7 100%);
}

.login-copy strong {
  color: #006767;
  font-size: 18px;
}

.login-copy h1 {
  margin-top: 86px;
  color: #13251f;
  font-size: 38px;
  line-height: 1.18;
}

.login-copy p {
  width: min(420px, 100%);
  margin-top: 18px;
  color: #425049;
  font-size: 15px;
  line-height: 1.8;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 44px 38px;
  background: #fff;
}

.login-panel h2 {
  color: #13251f;
  font-size: 26px;
  margin-bottom: 22px;
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: #68766f;
  font-size: 13px;
}

.remember input {
  width: auto;
}

.login-error {
  min-height: 18px;
  margin: 10px 0 8px;
  color: #b56a00;
  font-size: 13px;
}

.login-panel p {
  margin-top: 14px;
  color: #68766f;
  font-size: 13px;
  text-align: center;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--admin-sidebar-width);
  box-sizing: border-box;
  overflow-y: auto;
  background: #13251f;
  color: #fff;
  padding: 24px 16px;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 28px;
}

.brand strong {
  font-size: 24px;
}

.brand span {
  color: #9db8ae;
  font-size: 13px;
}

.nav {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dce7e2;
  padding: 12px 14px;
  text-align: left;
  margin-bottom: 8px;
  cursor: pointer;
}

.nav.active,
.nav:hover {
  background: #1f7a58;
  color: #fff;
}

.main {
  grid-column: 2;
  min-width: 0;
  padding: 28px;
}

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

.topbar > div:first-child {
  min-width: 260px;
}

.topbar-controls {
  margin-left: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 28px;
}

.account-actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.help-guide-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #bfe3dc;
  background: #eefbf8;
  color: #16745f;
  font-weight: 700;
}

.logout-button {
  flex-shrink: 0;
  background: #eef3f1;
  color: #425049;
}

.hidden {
  display: none !important;
}

.account-menu {
  position: relative;
  flex-shrink: 0;
}

.account-button {
  min-width: 168px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  background: #fff;
  color: #13251f;
  border: 1px solid #d8e0dc;
}

.account-avatar {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #92e4db 0%, #b8eed0 100%);
  color: #006767;
  font-size: 13px;
  font-weight: 800;
}

.account-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: 150px;
  display: none;
  padding: 8px;
  border: 1px solid #d8e0dc;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(19, 37, 31, 0.12);
}

.account-dropdown.show {
  display: grid;
  gap: 4px;
}

.account-dropdown button {
  width: 100%;
  background: transparent;
  color: #425049;
  text-align: left;
}

.account-dropdown button:hover {
  background: #eef3f1;
}

h1,
h2,
p {
  margin: 0;
}

.topbar p {
  color: #68766f;
  margin-top: 8px;
}

.api-base {
  display: grid;
  gap: 6px;
  color: #68766f;
  font-size: 13px;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.help-tip {
  position: relative;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #6daea2;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

.help-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 50;
  width: 320px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 9px 11px;
  border-radius: 5px;
  background: #252b2f;
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.55;
  white-space: normal;
  box-shadow: 0 10px 24px rgba(19, 37, 31, 0.18);
  transform: translateY(-4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.help-tip::before {
  content: "";
  position: absolute;
  left: 7px;
  top: calc(100% + 4px);
  z-index: 51;
  border: 6px solid transparent;
  border-bottom-color: #252b2f;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.help-tip:hover::after,
.help-tip:hover::before {
  opacity: 1;
  transform: translateY(0);
}

input,
textarea,
select {
  border: 1px solid #d8e0dc;
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 160px;
  resize: vertical;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: #1f7a58;
  color: #fff;
  cursor: pointer;
}

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

.secondary-button {
  border: 1px solid #b8d9d1;
  background: #eefaf7;
  color: #0f6f58;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.metric,
.flag-item,
.integration-card,
.log-grid > div {
  background: #fff;
  border: 1px solid #e1e7e4;
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  color: #68766f;
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 10px;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.user-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 150px 88px 104px;
  gap: 10px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #e1e7e4;
  border-radius: 8px;
  background: #fff;
}

.compact-toolbar {
  grid-template-columns: minmax(220px, 320px) 88px 104px;
}

.admin-toolbar,
.admin-create {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid #e1e7e4;
  border-radius: 8px;
  background: #fff;
}

.admin-toolbar {
  grid-template-columns: minmax(220px, 320px) 150px 150px 88px;
}

.admin-create {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) 180px 120px;
  background: #fbfdfc;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.content-table {
  min-width: 980px;
}

.content-editor {
  position: sticky;
  top: 28px;
  padding: 18px;
  border: 1px solid #e1e7e4;
  border-radius: 8px;
  background: #fff;
}

.content-editor h2 {
  margin-bottom: 14px;
  color: #13251f;
  font-size: 18px;
}

.content-body-input {
  min-height: 220px;
}

.content-options {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  color: #425049;
  font-size: 13px;
}

.content-options label {
  display: grid;
  gap: 6px;
}

.content-options label:first-child {
  display: flex;
  gap: 8px;
}

.muted-line {
  margin-top: 6px;
  color: #68766f;
  font-size: 12px;
  line-height: 1.4;
}

.ghost-button {
  background: #eef3f1;
  color: #425049;
}

.user-table-wrap {
  overflow-x: auto;
  border: 1px solid #e1e7e4;
  border-radius: 8px;
  background: #fff;
}

.user-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.user-table th {
  padding: 14px 18px;
  background: #f2f7f6;
  color: #13251f;
  font-size: 13px;
  text-align: left;
}

.user-table td {
  padding: 18px;
  border-top: 1px solid #e7eeeb;
  vertical-align: middle;
}

.user-table tbody tr:nth-child(even) {
  background: #f8faf9;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 170px;
}

.avatar {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #dff5f3 0%, #b8eed0 100%);
  color: #006767;
  font-weight: 800;
}

.user-profile strong {
  display: block;
  margin-bottom: 6px;
}

.role-tag {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eaf7f6;
  color: #006767;
  font-size: 12px;
}

.info-lines {
  display: grid;
  gap: 6px;
  color: #425049;
  font-size: 13px;
  line-height: 1.35;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 10px;
  min-width: 230px;
}

.usage-grid span {
  display: grid;
  gap: 4px;
  color: #68766f;
  font-size: 12px;
}

.usage-grid strong {
  color: #13251f;
  font-size: 18px;
}

.status-switch {
  min-width: 74px;
  border-radius: 999px;
  background: #1f9d68;
}

.status-switch.off {
  background: #aebbb7;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 8px;
  min-width: 174px;
}

.mini-button {
  border: 1px solid #b9d9d5;
  background: #eefaf8;
  color: #006767;
  font-size: 13px;
}

.mini-button.warn {
  border-color: #ffd7a8;
  background: #fff5e6;
  color: #b56a00;
}

.role-table td,
.admin-table td {
  font-size: 13px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(19, 37, 31, 0.28);
}

.modal-mask.show {
  display: flex;
}

.permission-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 80px);
  overflow: auto;
  padding: 24px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(19, 37, 31, 0.18);
}

.permission-panel h2 {
  font-size: 22px;
}

.permission-panel p {
  margin-top: 8px;
  color: #68766f;
}

.permission-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.permission-group {
  padding: 16px;
  border: 1px solid #e1e7e4;
  border-radius: 8px;
  background: #f8faf9;
}

.permission-group h3 {
  margin: 0 0 10px;
  color: #13251f;
  font-size: 15px;
}

.permission-options {
  display: grid;
  gap: 8px;
}

.permission-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #425049;
  font-size: 13px;
}

.permission-options input {
  width: auto;
}

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

.empty {
  color: #68766f;
  text-align: center;
}

.table-footer {
  margin-top: 12px;
  color: #68766f;
  font-size: 13px;
}

[hidden] {
  display: none !important;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: #425049;
}

.list {
  display: grid;
  gap: 12px;
}

.flag-item {
  display: grid;
  grid-template-columns: 1fr 120px 120px;
  gap: 12px;
  align-items: center;
}

.flag-copy {
  display: grid;
  gap: 6px;
}

.flag-copy strong {
  color: #17202a;
  font-size: 20px;
  line-height: 1.35;
}

.flag-copy p {
  color: #425049;
  font-size: 14px;
  line-height: 1.6;
}

.flag-copy span {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef3f1;
  color: #87928d;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.compact-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  align-items: center;
}

.compact-field input {
  grid-column: 1 / -1;
}

.integration-list {
  display: grid;
  gap: 14px;
}

.integration-card {
  display: grid;
  gap: 16px;
}

.integration-head,
.integration-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.integration-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.integration-head h2 {
  margin-bottom: 6px;
  color: #13251f;
  font-size: 18px;
}

.integration-head p,
.integration-footer span {
  color: #68766f;
  font-size: 13px;
}

.switch-line,
.clear-secret {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #425049;
  font-size: 13px;
}

.switch-line input,
.clear-secret input {
  width: auto;
}

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

.integration-grid .field.wide {
  grid-column: 1 / -1;
}

.help-guide-panel {
  max-width: 680px;
}

.help-guide-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.help-guide-list section {
  padding: 14px;
  border: 1px solid #e1e7e4;
  border-radius: 8px;
  background: #f8faf9;
}

.help-guide-list h3 {
  margin: 0 0 6px;
  color: #13251f;
  font-size: 15px;
}

.help-guide-list p {
  margin: 0;
  color: #425049;
  font-size: 13px;
  line-height: 1.7;
}

.log-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 620px;
  overflow: auto;
  background: #f8faf9;
  border-radius: 6px;
  padding: 12px;
}

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

  .admin-login {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .login-copy {
    padding: 32px;
  }

  .login-copy h1 {
    margin-top: 32px;
    font-size: 30px;
  }

  .sidebar {
    position: static;
    inset: auto;
    width: auto;
    overflow-y: visible;
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }

  .main {
    grid-column: auto;
  }

  .brand {
    min-width: 140px;
    margin-bottom: 0;
  }

  .nav {
    min-width: 110px;
  }

  .metrics,
  .log-grid,
  .user-toolbar,
  .compact-toolbar,
  .admin-toolbar,
  .admin-create,
  .integration-grid,
  .permission-groups {
    grid-template-columns: 1fr;
  }
}
