:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-muted: #f0f5f2;
  --text: #18231d;
  --text-muted: #5d6b63;
  --border: #d9e2dc;
  --brand: #147d4f;
  --brand-hover: #0f663f;
  --brand-on: #ffffff;
  --error: #a12828;
  --error-bg: #fff3f2;
  --error-border: #efc8c4;
  --focus: #8b5cf6;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(24, 35, 29, 0.06);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

h2 {
  margin-bottom: 20px;
  font-size: 1.35rem;
  line-height: 1.3;
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  gap: 20px;
}

.brand,
.header-session {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-size: 1.08rem;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-on);
  font-size: 1.1rem;
}

.header-session {
  gap: 16px;
}

.header-user {
  max-width: 260px;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  padding: 48px 0 64px;
}

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

.loading-view {
  max-width: 560px;
  margin: 64px auto;
  padding: 32px;
  text-align: center;
}

.loading-view p {
  margin-bottom: 0;
  color: var(--text-muted);
}

.hero {
  max-width: 780px;
  padding: clamp(48px, 10vw, 104px) 0;
}

.hero-copy {
  max-width: 640px;
  margin-bottom: 32px;
  color: var(--text-muted);
  font-size: 1.12rem;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.security-note {
  margin-top: 20px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.button {
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 650;
  line-height: 1.4;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button-primary {
  background: var(--brand);
  color: var(--brand-on);
}

.button-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.button-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
}

.button-compact {
  padding: 8px 16px;
  font-size: 0.9rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 32px;
}

.section-heading h1,
.section-heading h2,
.section-heading .eyebrow {
  margin-bottom: 0;
}

.section-heading h1 {
  font-size: clamp(2rem, 4vw, 2.65rem);
}

.section-description {
  max-width: 440px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.94rem;
}

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

.apps-panel,
.account-panel,
.address-panel {
  padding: 28px;
}

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

.app-card {
  display: flex;
  min-height: 190px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  flex-direction: column;
  align-items: flex-start;
}

.app-card-active {
  border-color: #a7cbb7;
  background: #f4faf6;
}

.app-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 12px;
  gap: 12px;
}

.app-card p {
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.app-card .button {
  margin-top: auto;
}

.badge {
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.badge-active {
  border-color: #b5d6c3;
  background: #e5f3ea;
  color: #17633f;
}

.account-details {
  margin: 0;
}

.account-details div {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.account-details dt {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.account-details dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.break-all {
  word-break: break-all;
}

.address-panel {
  margin-top: 24px;
  scroll-margin-top: 24px;
}

.section-heading-compact {
  align-items: center;
}

.section-heading-compact h2 {
  font-size: 1.65rem;
}

.query-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 650;
}

.query-controls {
  display: flex;
  gap: 12px;
}

.query-controls input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #b8c5bd;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

.query-controls .button {
  min-width: 96px;
}

.query-status {
  min-height: 28px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.alert {
  margin-bottom: 24px;
  padding: 14px 16px;
  border: 1px solid;
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.alert-error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error);
}

#query-error {
  margin-top: 8px;
  margin-bottom: 16px;
}

.results-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

td:last-child {
  min-width: 260px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.site-footer {
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

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

  .account-panel {
    order: -1;
  }

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

@media (max-width: 640px) {
  .header-inner,
  .page-shell {
    width: min(100% - 28px, 1180px);
  }

  .header-inner {
    min-height: 64px;
  }

  .brand {
    font-size: 0.96rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .header-user {
    display: none;
  }

  .page-shell {
    padding: 32px 0 44px;
  }

  .hero {
    padding: 56px 4px;
  }

  .section-heading {
    display: block;
  }

  .section-description {
    margin-top: 12px;
  }

  .apps-panel,
  .account-panel,
  .address-panel {
    padding: 20px;
  }

  .app-grid,
  .account-details {
    grid-template-columns: 1fr;
  }

  .app-card {
    min-height: 0;
  }

  .query-controls {
    flex-direction: column;
  }

  .query-controls .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button {
    transition: none;
  }
}
