:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --bg-soft: #eef6f4;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-strong: #0f172a;
  --text: #172033;
  --text-soft: #5d6b82;
  --text-muted: #8290a3;
  --line: #dfe7f1;
  --line-soft: #edf1f6;
  --primary: #176b87;
  --primary-strong: #0f5369;
  --primary-soft: #e5f4f5;
  --accent: #d97706;
  --success: #157347;
  --warning: #a15c00;
  --danger: #b42318;
  --focus: #22a3b5;
  --shadow-sm: 0 1px 2px rgba(23, 32, 51, 0.06);
  --shadow-md: 0 12px 32px rgba(23, 32, 51, 0.08);
  --radius: 8px;
  --sidebar-width: 248px;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background:
    linear-gradient(135deg, rgba(23, 107, 135, 0.08), transparent 34rem),
    linear-gradient(315deg, rgba(217, 119, 6, 0.08), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--primary-strong);
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.nav-link:focus-visible {
  outline: 3px solid rgba(34, 163, 181, 0.22);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.35;
}

.login-page {
  grid-template-columns: 1fr;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 15% 15%, rgba(23, 107, 135, 0.16), transparent 28rem),
    radial-gradient(circle at 85% 85%, rgba(217, 119, 6, 0.14), transparent 26rem),
    linear-gradient(135deg, #f7fbfb 0%, #eef3f8 48%, #f8f4ee 100%);
}

.login-shell {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(223, 231, 241, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-md);
}

.login-hero {
  display: grid;
  align-content: space-between;
  gap: 48px;
  padding: 34px;
  background:
    linear-gradient(145deg, rgba(15, 83, 105, 0.96), rgba(15, 23, 42, 0.94)),
    var(--surface-strong);
  color: #ffffff;
}

.login-hero .brand span {
  color: #9fd3dc;
}

.login-copy {
  display: grid;
  gap: 14px;
  max-width: 430px;
}

.login-copy h1 {
  font-size: 34px;
}

.login-copy p {
  color: #c7d7e4;
  line-height: 1.7;
}

.login-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.login-stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.login-stats strong,
.login-stats span {
  display: block;
}

.login-stats strong {
  font-size: 18px;
}

.login-stats span {
  margin-top: 4px;
  color: #bad0dc;
  font-size: 12px;
}

.login-panel {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 34px;
  background: var(--surface);
}

.login-brand {
  margin-bottom: 2px;
}

.login-panel h1 {
  font-size: 26px;
}

.login-panel input,
.login-panel button {
  width: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  padding: 24px 16px;
  background:
    linear-gradient(180deg, #0f5369 0%, #0f172a 100%);
  color: #ffffff;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 28px;
}

.brand strong {
  font-size: 22px;
  line-height: 1;
}

.brand span,
.eyebrow {
  color: var(--text-muted);
  font-size: 12px;
}

.sidebar .brand {
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .brand span,
.sidebar .eyebrow {
  color: #9fb2c6;
}

nav {
  display: grid;
  gap: 6px;
}

nav a,
.nav-link {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 7px;
  color: #d8e3f1;
  text-align: left;
  text-decoration: none;
  background: transparent;
  box-shadow: none;
  font-weight: 700;
}

nav a:hover,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

nav a:focus-visible,
.nav-link:focus-visible,
.nav-link.active {
  background: #ffffff;
  color: #0f5369;
  outline: none;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.panel-header,
.actions,
.item-line,
.health-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 56px;
}

.eyebrow {
  margin-bottom: 5px;
}

.actions {
  flex-wrap: wrap;
}

.token-box {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 40px;
  width: 260px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:hover,
select:hover {
  border-color: #c8d5e4;
}

input:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(34, 163, 181, 0.12);
}

input::placeholder {
  color: #a1adbc;
}

.health-strip {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid #cfe2dc;
  border-left: 5px solid var(--success);
  border-radius: var(--radius);
  background: linear-gradient(90deg, #f2fbf7, #ffffff);
  box-shadow: var(--shadow-sm);
}

body[data-health="pending"] .health-strip {
  border-color: #f1d79f;
  border-left-color: var(--warning);
  background: linear-gradient(90deg, #fff8e7, #ffffff);
}

body[data-health="danger"] .health-strip {
  border-color: #f0c4bd;
  border-left-color: var(--danger);
  background: linear-gradient(90deg, #fff4f2, #ffffff);
}

.label,
.metrics span,
.summary {
  color: var(--text-soft);
  font-size: 13px;
}

.health-strip strong {
  display: block;
  margin-top: 4px;
}

.metrics {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.page-section {
  display: none;
}

.page-section.active {
  display: block;
}

.profile-grid,
.test-pay-grid,
.app-create-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
  align-items: end;
}

.profile-grid input,
.test-pay-grid input,
.app-create-grid input {
  width: 100%;
}

.wide-field {
  grid-column: span 2;
}

.compact-table {
  margin-top: 16px;
}

.callback-note {
  min-height: 40px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-muted);
}

.callback-note span {
  color: var(--text-soft);
  font-size: 12px;
}

.callback-note strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.login-shell-compact {
  width: min(420px, 100%);
  grid-template-columns: 1fr;
}

.qr-box {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.qr-box[hidden] {
  display: none;
}

.qr-box img {
  width: 132px;
  height: 132px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.qr-box strong,
.qr-box span,
.qr-box a {
  display: block;
}

.qr-box span {
  margin-top: 5px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}

.qr-box a {
  margin-top: 8px;
  color: var(--primary);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.secret-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #f0ce83;
  border-radius: var(--radius);
  background: #fff9eb;
}

.secret-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.secret-grid div {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.secret-grid dt {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.secret-grid dd {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.secret-grid code {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: Consolas, "SFMono-Regular", monospace;
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #8f1d14;
}

.metrics article,
.panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.metrics article {
  position: relative;
  min-height: 104px;
  overflow: hidden;
}

.metrics article::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--primary-soft);
}

.metrics article.watch {
  border-color: #efc5bd;
  background: #fffafa;
}

.metrics article.watch::after {
  background: #f6c7bf;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.1;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.panel {
  margin-top: 18px;
}

.panel-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-header .summary {
  max-width: 64ch;
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  border-top: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--text-soft);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

tbody tr {
  transition: background-color 140ms ease;
}

tbody tr:hover {
  background: #f8fbfc;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.wide {
  grid-column: 1 / -1;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.item {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #ffffff;
}

.item.pending {
  border-color: #f0d18a;
  background: #fffaf0;
}

.item.danger {
  border-color: #efb1aa;
  background: #fffafa;
}

.item strong {
  display: block;
}

.item span {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.danger-text {
  color: var(--danger) !important;
}

.badge {
  display: inline-flex;
  min-width: 56px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: #e8f8ef;
  color: var(--success);
}

.badge.pending {
  background: #fff4d6;
  color: #8a5a00;
}

.badge.danger {
  background: #fde8e8;
  color: var(--danger);
}

.badge.neutral {
  background: #edf1f6;
  color: var(--text-soft);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 1100px) {
  .metrics,
  .profile-grid,
  .test-pay-grid,
  .app-create-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .login-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  body {
    grid-template-columns: 1fr;
  }

  .login-page {
    padding: 18px;
  }

  .login-hero {
    padding: 24px;
  }

  .login-copy h1 {
    font-size: 28px;
  }

  .login-stats {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 24px;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .health-strip,
  .grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .actions,
  .panel-header,
  .health-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-header .summary {
    max-width: none;
    text-align: left;
  }

  .metrics,
  .profile-grid,
  .test-pay-grid,
  .app-create-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  input {
    width: 100%;
  }

  .secret-grid div {
    grid-template-columns: 1fr;
  }

  .qr-box {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .main {
    padding: 20px 14px;
  }

  nav {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }
}
