:root {
  --bg: #f5f7f2;
  --bg-strong: #e9efe6;
  --surface: #ffffff;
  --surface-soft: #f9fbf7;
  --panel: rgba(255, 255, 255, 0.94);
  --ink: #15171a;
  --text: #20242a;
  --muted: #5d6673;
  --subtle: #7c8794;
  --line: #dfe5dc;
  --line-strong: #c7d1c4;
  --primary: #176a4d;
  --primary-dark: #0f4f3a;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --success: #15803d;
  --warning: #b7791f;
  --danger: #dc2626;
  --good-bg: #dcfce7;
  --warn-bg: #fef3c7;
  --bad-bg: #fee2e2;
  --radius: 8px;
  --shadow: 0 18px 44px rgba(22, 28, 36, 0.09);
  --shadow-soft: 0 10px 24px rgba(22, 28, 36, 0.07);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  font-size: 16px;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(233, 239, 230, 0.88) 0%, rgba(245, 247, 242, 0.92) 42%, rgba(238, 242, 247, 0.9) 100%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(23, 106, 77, 0.08), transparent 36%),
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 340px);
  pointer-events: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { color: #1d4ed8; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

code,
pre {
  font-family: "Fira Code", Consolas, "SFMono-Regular", monospace;
}

.wrap {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.no-top-wrap { padding-top: 42px; }

.top {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid rgba(223, 229, 220, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #b8d8c9;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e6f7ef, #dbeafe);
  color: var(--primary);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.nav a,
.pill,
.btn-light {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.nav a:hover,
.btn-light:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1e40af;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.1);
}

.panel,
.endpoint-card,
.auth-copy,
.api-hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel,
.endpoint-card {
  margin-bottom: 16px;
  padding: 18px;
}

.panel h2,
.endpoint-card h3 {
  margin: 0 0 12px;
  color: var(--ink);
  letter-spacing: 0;
}

.panel h2 { font-size: 17px; }
.endpoint-card h3 { font-size: 18px; }
.endpoint-card p,
.panel p { color: var(--muted); }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.full { grid-column: 1 / -1; }
.sticky-aside { position: sticky; top: 88px; }

.api-landing {
  display: grid;
  gap: 16px;
}

.api-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) 420px;
  gap: 18px;
  align-items: stretch;
  padding: 30px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(240, 249, 244, 0.96) 58%, rgba(235, 245, 255, 0.94) 100%);
}

.api-hero h1,
.api-hero h2 {
  max-width: 760px;
  margin: 10px 0 12px;
  color: var(--ink);
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1.04;
  letter-spacing: 0;
}

.api-hero p {
  max-width: 740px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.api-summary {
  display: grid;
  gap: 10px;
}

.api-summary .metric { min-height: 0; }

.api-visual {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 290px;
  padding: 16px;
  border: 1px solid rgba(23, 106, 77, 0.18);
  border-radius: var(--radius);
  background: #101820;
  color: #eef7f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.api-visual-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.api-visual-row strong,
.api-visual-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-visual-row span { color: #b8c4d2; }

.api-visual-row em {
  justify-self: end;
  min-width: 42px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

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

.endpoint-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.endpoint-head code {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.method {
  min-width: 52px;
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.method.get { background: #dbeafe; color: #1d4ed8; }

.endpoint-card pre,
.log {
  overflow: auto;
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  background: #101820;
  color: #d8f3dc;
}

.endpoint-card pre {
  margin: 12px 0 0;
  padding: 12px;
}

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

.doc-list h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.doc-list p { margin: 0; }

.api-notice {
  max-width: 720px;
  margin: 96px auto 0;
  text-align: center;
}

.api-notice h1,
.api-notice h2 {
  margin: 0 0 10px;
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: 0;
}

.api-notice p {
  margin: 0;
  font-size: 17px;
}

.eyebrow {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid #bdd7c7;
  border-radius: 999px;
  background: #effaf3;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.metric {
  min-height: 88px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  box-shadow: var(--shadow-soft);
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 27px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: center;
  min-height: 520px;
}

.auth-copy {
  padding: 26px;
  background: linear-gradient(135deg, #ffffff, #f0f9f4 56%, #eef5ff);
}

.auth-copy h2 {
  margin: 10px 0;
  color: var(--ink);
  font-size: clamp(32px, 4vw, 50px);
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-copy p {
  color: var(--muted);
  font-size: 17px;
}

.auth-panel { margin-bottom: 0; }

label {
  display: block;
  margin: 0 0 6px;
  color: #2b343f;
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 15px;
}

input[type="file"] {
  padding: 8px;
  cursor: pointer;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.check {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  cursor: pointer;
}

.check input {
  width: 17px;
  height: 17px;
  min-height: auto;
  flex: 0 0 auto;
}

button,
.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

button:hover,
.btn:hover {
  background: var(--primary-dark);
  color: #ffffff;
  box-shadow: 0 9px 18px rgba(23, 106, 77, 0.2);
}

button.secondary,
.btn.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

button.secondary:hover,
.btn.secondary:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1e40af;
}

button.danger {
  background: var(--danger);
  color: #ffffff;
}

button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

button:disabled:hover,
.btn:disabled:hover {
  background: var(--primary);
  color: #ffffff;
  box-shadow: none;
}

button.danger:hover { background: #b91c1c; }

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

.actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
}

.submit-row { margin-top: 16px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

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

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f1f5ef;
  color: #4b5563;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover td { background: #f0fdf4; }

.tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
}

.good { color: var(--success); background: var(--good-bg); }
.warn { color: var(--warning); background: var(--warn-bg); }
.bad { color: var(--danger); background: var(--bad-bg); }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }

.inline-note {
  padding: 10px 12px;
  border-radius: 6px;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 13px;
  border-left: 4px solid var(--success);
  border-radius: 6px;
  background: #ecfdf5;
  color: #14532d;
  white-space: pre-line;
  box-shadow: var(--shadow-soft);
}

.flash.bad {
  border-left-color: var(--danger);
  background: var(--bad-bg);
  color: #7f1d1d;
}

/* Loading spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Smooth page transitions */
.page-enter-active,
.page-leave-active {
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.page-enter-from {
  opacity: 0;
  transform: translateY(8px);
}
.page-leave-to {
  opacity: 0;
  transform: translateY(-8px);
}

/* Better scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Improved touch targets */
@media (max-width: 768px) {
  button, .btn, .nav a {
    min-height: 48px;
  }
  .metric {
    min-height: 96px;
  }
}

/* User nav */
.user-nav {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}
.logout-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  transition: all 0.2s ease;
}
.logout-link:hover {
  color: var(--danger);
  background: var(--bad-bg);
}

/* Alert styles */
.alert-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--warn-bg);
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  color: #92400e;
}
.alert-warning svg {
  flex-shrink: 0;
  margin-top: 2px;
}
.alert-warning p {
  margin: 0;
  color: #92400e;
}

/* Required field indicator */
.required {
  color: var(--danger);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--muted);
}

/* Fieldset reset */
fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.log-head strong {
  color: var(--ink);
}

.log-head span {
  color: var(--muted);
  font-size: 13px;
}

.live-log {
  margin-top: 10px;
  border: 1px solid #263244;
  border-radius: 8px;
  background: #0b1220;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
  overflow: auto;
}

.ico svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-cell {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  box-shadow: var(--shadow-soft);
}

.status-cell strong {
  display: block;
  color: var(--ink);
}

.status-cell span {
  color: var(--muted);
  font-size: 13px;
}

.form-section {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf5;
}

.form-section h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media (max-width: 980px) {
  .wrap { width: min(100% - 20px, 1360px); }
  .top,
  .grid,
  .api-hero,
  .auth-shell {
    display: block;
  }
  .top {
    position: static;
  }
  .nav {
    justify-content: flex-start;
    margin-top: 12px;
  }
  .form-grid,
  .metric-grid,
  .status-strip,
  .endpoint-grid,
  .doc-list {
    grid-template-columns: 1fr;
  }
  .brand { margin-bottom: 12px; }
  .api-summary,
  .api-visual,
  .auth-copy {
    margin-top: 16px;
  }
  .sticky-aside { position: static; }
}

@media (max-width: 520px) {
  .wrap {
    width: min(100% - 16px, 1360px);
    padding-top: 12px;
  }
  .top,
  .api-hero,
  .auth-copy,
  .panel,
  .endpoint-card {
    padding: 12px;
  }
  .brand {
    align-items: flex-start;
  }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 12px; }
  .nav a,
  .pill,
  .btn-light,
  button,
  .btn {
    width: 100%;
  }
  .api-hero h1,
  .api-hero h2,
  .auth-copy h2 {
    font-size: 31px;
  }
  .api-hero p,
  .auth-copy p {
    font-size: 16px;
  }
  .api-visual-row {
    grid-template-columns: 1fr;
  }
  .api-visual-row em {
    justify-self: start;
  }
}
