/* XRDPilot API preview — visual language inspired by refined AI dashboard UIs (e.g. beautifului.dev) */
:root {
  --xp-bg: #f6f5f3;
  --xp-bg-dots: #e7e5e4;
  --xp-surface: #ffffff;
  --xp-surface-2: #fafaf9;
  --xp-ink: #1c1917;
  --xp-muted: #78716c;
  --xp-muted-2: #a8a29e;
  --xp-line: #e7e5e4;
  --xp-line-strong: #d6d3d1;
  --xp-accent: #4f46e5;
  --xp-accent-hover: #4338ca;
  --xp-accent-soft: #eef2ff;
  --xp-accent-ring: rgba(79, 70, 229, 0.18);
  --xp-ok: #059669;
  --xp-ok-soft: #ecfdf5;
  --xp-err-soft: #fef2f2;
  --xp-err: #dc2626;
  --xp-radius: 16px;
  --xp-radius-sm: 10px;
  --xp-radius-xs: 8px;
  --xp-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei UI",
    "Noto Sans SC", sans-serif;
  --xp-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --xp-shadow-dock: 0 1px 2px rgba(28, 25, 23, 0.04), 0 8px 24px rgba(28, 25, 23, 0.06);
  --xp-shadow-card: 0 1px 2px rgba(28, 25, 23, 0.03);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

.xp-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--xp-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--xp-ink);
  background-color: var(--xp-bg);
  background-image: radial-gradient(circle at 1px 1px, var(--xp-bg-dots) 1px, transparent 0);
  background-size: 20px 20px;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--xp-accent-hover);
}

.xp-preview-tag {
  margin: 0;
  text-align: center;
  font-size: 11px;
  padding: 7px 12px;
  color: var(--xp-muted);
  background: var(--xp-surface);
  border-bottom: 1px solid var(--xp-line);
}

.xp-preview-tag a {
  font-weight: 600;
  margin-left: 6px;
}

/* Floating dock header */
.xp-header {
  padding: 14px 20px 0;
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, var(--xp-bg) 70%, transparent);
}

.xp-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 10px 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--xp-line);
  border-radius: 999px;
  box-shadow: var(--xp-shadow-dock);
  backdrop-filter: blur(16px);
}

.xp-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
  padding-right: 8px;
  border-right: 1px solid var(--xp-line);
  margin-right: 4px;
}

.xp-brand:hover {
  text-decoration: none;
}

.xp-brand img {
  border-radius: 9px;
  border: 1px solid var(--xp-line);
}

.xp-brand b {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.xp-brand small {
  display: block;
  font-size: 10px;
  color: var(--xp-muted-2);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.xp-nav {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}

.xp-nav-link {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--xp-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.xp-nav-link:hover {
  color: var(--xp-ink);
  background: var(--xp-surface-2);
  text-decoration: none;
}

.xp-nav-link.is-on {
  color: var(--xp-ink);
  background: var(--xp-surface);
  box-shadow: inset 0 0 0 1px var(--xp-line), var(--xp-shadow-card);
}

.xp-header-end {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.xp-balance {
  display: none;
}

@media (min-width: 900px) {
  .xp-balance {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
    padding: 0 10px;
    border-right: 1px solid var(--xp-line);
    margin-right: 4px;
  }
}

.xp-balance-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--xp-muted-2);
}

.xp-balance strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.xp-main {
  padding: 22px 20px 56px;
}

.xp-main-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.xp-page-head {
  margin-bottom: 22px;
}

.xp-page-head h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.xp-page-head p {
  margin: 0;
  color: var(--xp-muted);
  font-size: 13px;
  max-width: 42rem;
}

.xp-foot {
  text-align: center;
  font-size: 11px;
  color: var(--xp-muted-2);
  padding: 20px;
}

/* Buttons */
.xp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--xp-line);
  background: var(--xp-surface);
  color: var(--xp-ink);
  cursor: pointer;
  box-shadow: var(--xp-shadow-card);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.xp-btn:hover {
  border-color: var(--xp-line-strong);
  background: var(--xp-surface-2);
}

.xp-btn:active {
  transform: scale(0.98);
}

.xp-btn-accent {
  background: var(--xp-ink);
  border-color: var(--xp-ink);
  color: #fff;
}

.xp-btn-accent:hover {
  background: #292524;
  border-color: #292524;
  color: #fff;
}

.xp-btn-ghost {
  border-color: transparent;
  box-shadow: none;
  background: transparent;
  color: var(--xp-muted);
}

.xp-btn-ghost:hover {
  background: var(--xp-surface-2);
  color: var(--xp-ink);
}

.xp-btn-sm {
  padding: 6px 11px;
  font-size: 11px;
}

/* Insight stats */
.xp-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 16px;
}

.xp-stat {
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius);
  padding: 14px 16px;
  box-shadow: var(--xp-shadow-card);
}

.xp-stat span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--xp-muted-2);
  margin-bottom: 6px;
}

.xp-stat strong {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.xp-stat em {
  display: block;
  font-size: 11px;
  color: var(--xp-muted);
  font-style: normal;
  margin-top: 8px;
}

.xp-stat-accent {
  background: linear-gradient(145deg, #312e81 0%, #4f46e5 55%, #6366f1 100%);
  border-color: transparent;
  color: #fff;
}

.xp-stat-accent span,
.xp-stat-accent em {
  color: rgba(255, 255, 255, 0.75);
}

.xp-stat-accent strong {
  color: #fff;
}

.xp-stat-balance {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
}

.xp-stat-balance .xp-stat-balance-label {
  display: block;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.78);
}

.xp-stat-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 2px;
}

.xp-stat-balance-amount {
  flex: 1;
  min-width: 0;
  font-size: 26px;
  line-height: 1;
}

.xp-stat-recharge {
  flex-shrink: 0;
  margin-left: auto;
  margin-right: -2px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: #fff;
  color: #312e81;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
  white-space: nowrap;
}

.xp-stat-recharge:hover {
  background: #f8fafc;
  color: #1e1b4b;
  border-color: transparent;
}

@media (min-width: 720px) {
  .xp-stats-overview {
    grid-template-columns: 1.35fr repeat(2, 1fr);
  }

  .xp-stat-balance {
    padding: 16px 18px 16px 20px;
  }
}

.xp-overview-usage {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.xp-section-head {
  margin-bottom: 16px;
}

.xp-section-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

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

.xp-usage-filters-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 14px;
}

.xp-usage-filter-sep {
  width: 1px;
  height: 22px;
  background: var(--xp-line-strong);
  flex-shrink: 0;
}

.xp-stats-usage-summary .xp-stat strong {
  margin-bottom: 0;
}

.xp-stats-usage-summary .xp-stat span {
  margin-bottom: 4px;
}

.xp-overview-usage > .xp-stats {
  margin-bottom: 16px;
}

.xp-overview-logs {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--xp-line);
}

.xp-logs-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--xp-line);
  background: var(--xp-surface-2);
}

.xp-logs-pager-start,
.xp-logs-pager-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.xp-logs-page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--xp-muted);
}

.xp-logs-page-size .xp-select {
  padding: 5px 8px;
  font-size: 12px;
  min-width: 4.5em;
}

.xp-logs-range {
  font-size: 12px;
  color: var(--xp-muted-2);
  font-variant-numeric: tabular-nums;
}

.xp-logs-page-info {
  font-size: 12px;
  font-weight: 650;
  color: var(--xp-ink);
  min-width: 3.5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.xp-logs-pager .xp-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.xp-panel-flush {
  padding: 0;
  overflow: hidden;
}

.xp-panel-flush .xp-table-wrap {
  border-radius: inherit;
}

.xp-panel-flush .xp-table th:first-child,
.xp-panel-flush .xp-table td:first-child {
  padding-left: 18px;
}

.xp-panel-flush .xp-table th:last-child,
.xp-panel-flush .xp-table td:last-child {
  padding-right: 18px;
}

/* Panels */
.xp-panel {
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius);
  padding: 16px 18px;
  box-shadow: var(--xp-shadow-card);
}

.xp-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.xp-panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.xp-panel-head a {
  font-size: 12px;
  font-weight: 600;
}

.xp-split {
  display: grid;
  gap: 12px;
}

@media (min-width: 900px) {
  .xp-split-2-1 {
    grid-template-columns: 1.35fr 1fr;
  }

  .xp-split-usage {
    grid-template-columns: 1.45fr 1fr;
    align-items: stretch;
  }
}

.xp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

/* Toolbar — filter bar */
.xp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius);
  box-shadow: var(--xp-shadow-card);
}

.xp-input,
.xp-select {
  padding: 8px 11px;
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius-xs);
  font-size: 12px;
  background: var(--xp-surface-2);
  color: var(--xp-ink);
  min-height: 34px;
}

.xp-input:focus,
.xp-select:focus {
  outline: 2px solid var(--xp-accent-ring);
  border-color: #a5b4fc;
  background: #fff;
}

.xp-input {
  flex: 1;
  min-width: 180px;
}

/* Chips */
.xp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.xp-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--xp-line);
  background: var(--xp-surface);
  color: var(--xp-muted);
  cursor: pointer;
  box-shadow: var(--xp-shadow-card);
}

.xp-chip.is-on {
  background: var(--xp-accent-soft);
  border-color: #c7d2fe;
  color: var(--xp-accent-hover);
}

/* Table — records style */
.xp-table-wrap {
  overflow: auto;
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius-sm);
  background: var(--xp-surface);
}

table.xp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.xp-table th,
table.xp-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f5f5f4;
}

table.xp-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--xp-muted-2);
  background: var(--xp-surface-2);
}

table.xp-table tbody tr:hover td {
  background: #fafaf9;
}

table.xp-table tr:last-child td {
  border-bottom: none;
}

.xp-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid transparent;
}

.xp-pill-btn {
  cursor: pointer;
  border: none;
  font: inherit;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.xp-pill-btn:hover {
  opacity: 0.88;
}

.xp-pill-btn:active {
  transform: scale(0.97);
}

.xp-pill-btn:focus-visible {
  outline: 2px solid var(--xp-accent-ring);
  outline-offset: 2px;
}

.xp-pill-ok {
  background: var(--xp-ok-soft);
  color: var(--xp-ok);
  border-color: #a7f3d0;
}

.xp-pill-off {
  background: #f5f5f4;
  color: var(--xp-muted);
  border-color: var(--xp-line);
}

.xp-pill-err {
  background: var(--xp-err-soft);
  color: var(--xp-err);
  border-color: #fecaca;
}

/* Model cards — recommendation style */
.xp-model-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.xp-model {
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius);
  padding: 16px 17px;
  box-shadow: var(--xp-shadow-card);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.xp-model:hover {
  border-color: #c7d2fe;
  box-shadow: 0 8px 28px rgba(79, 70, 229, 0.08);
}

.xp-model-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.xp-model h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-family: var(--xp-mono);
}

.xp-model p {
  margin: 0;
  font-size: 12px;
  color: var(--xp-muted);
  line-height: 1.45;
}

.xp-model-price {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--xp-line);
  font-size: 11px;
  font-weight: 600;
  color: var(--xp-ink);
  font-variant-numeric: tabular-nums;
}

/* Key / task rows */
.xp-key-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius-sm);
  box-shadow: var(--xp-shadow-card);
}

@media (min-width: 720px) {
  .xp-key-card {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }
}

.xp-keys-toolbar {
  margin-bottom: 14px;
}

.xp-key-card-muted {
  opacity: 0.78;
}

.xp-key-main strong {
  display: block;
}

.xp-key-main .xp-mono {
  margin: 4px 0 0;
}

.xp-key-meta {
  text-align: right;
}

.xp-key-meta strong {
  display: block;
  font-variant-numeric: tabular-nums;
}

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

.xp-keys-hint {
  margin-top: 20px;
}

.xp-keys-hint-inline {
  margin: 12px 0 0;
}

.xp-page-block-models {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--xp-line);
}

.xp-section-head-tight {
  margin-bottom: 12px;
}

.xp-model-table-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--xp-muted-2);
  font-weight: 500;
}

.xp-model-table-wrap {
  overflow-x: auto;
}

.xp-model-table {
  min-width: 720px;
}

.xp-model-table th,
.xp-model-table td {
  white-space: nowrap;
}

.xp-model-table th {
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}

.xp-model-table .xp-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.xp-model-name {
  font-family: var(--xp-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--xp-ink);
}

.xp-model-table tbody tr:hover td {
  background: var(--xp-surface-2);
}

.xp-keys-hint h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 650;
}

/* Key dialogs */
.xp-dialog {
  border: none;
  padding: 0;
  margin: auto;
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border-radius: 20px;
  background: var(--xp-surface);
  box-shadow:
    0 0 0 1px rgba(28, 25, 23, 0.06),
    0 24px 64px rgba(28, 25, 23, 0.2);
}

.xp-dialog::backdrop {
  background: rgba(28, 25, 23, 0.42);
  backdrop-filter: blur(6px);
}

.xp-dialog-form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}

.xp-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--xp-line);
  background: linear-gradient(180deg, var(--xp-surface) 0%, var(--xp-surface-2) 100%);
}

.xp-dialog-eyebrow {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--xp-muted-2);
}

.xp-dialog-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.xp-dialog-close {
  flex-shrink: 0;
  border: 1px solid var(--xp-line);
  background: var(--xp-surface);
  font-size: 18px;
  line-height: 1;
  color: var(--xp-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
}

.xp-dialog-close:hover {
  background: var(--xp-surface-2);
  color: var(--xp-ink);
  border-color: var(--xp-line-strong);
}

.xp-dialog-body {
  padding: 14px 16px 6px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.xp-dialog-panel {
  padding: 12px 14px;
  background: var(--xp-surface-2);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius-sm);
}

.xp-dialog-panel-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--xp-muted-2);
}

.xp-dialog-panel-warn {
  background: #fffbeb;
  border-color: #fde68a;
}

.xp-dialog-panel-warn p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #92400e;
}

.xp-field-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.xp-field-block + .xp-field-block,
.xp-quota-amount {
  margin-top: 10px;
}

.xp-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--xp-muted);
}

.xp-input-dialog {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border-radius: var(--xp-radius-xs);
  border: 1px solid var(--xp-line-strong);
  background: var(--xp-surface);
  color: var(--xp-ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.xp-input-dialog:focus {
  outline: none;
  border-color: var(--xp-accent);
  box-shadow: 0 0 0 3px var(--xp-accent-ring);
}

.xp-input-dialog::placeholder {
  color: var(--xp-muted-2);
}

.xp-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.xp-switch-copy strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--xp-ink);
  margin-bottom: 2px;
}

.xp-switch-copy span {
  display: block;
  font-size: 11px;
  line-height: 1.35;
  color: var(--xp-muted);
  max-width: 16rem;
}

.xp-switch {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  cursor: pointer;
}

.xp-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.xp-switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d6d3d1;
  transition: background 0.2s ease;
}

.xp-switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.18);
  transition: transform 0.2s ease;
}

.xp-switch input:checked + i {
  background: var(--xp-accent);
}

.xp-switch input:checked + i::after {
  transform: translateX(18px);
}

.xp-switch input:focus-visible + i {
  box-shadow: 0 0 0 3px var(--xp-accent-ring);
}

.xp-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--xp-line);
  background: var(--xp-surface);
}

.xp-dialog-foot-split {
  justify-content: stretch;
}

.xp-dialog-foot-split .xp-btn {
  flex: 1;
}

.xp-btn-dialog-primary {
  min-width: 7rem;
  font-weight: 650;
}

/* Legacy field helpers (other pages) */
.xp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--xp-muted);
}

.xp-field .xp-input,
.xp-field .xp-select {
  width: 100%;
  font-weight: 500;
  color: var(--xp-ink);
}

.xp-field-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--xp-ink);
  font-weight: 550;
}

.xp-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--xp-ink);
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: 999px;
  box-shadow: var(--xp-shadow-dock);
}

.xp-toast[hidden] {
  display: none;
}

.xp-key-reveal-box {
  margin: 0;
  padding: 14px 16px;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius-xs);
  color: var(--xp-ink);
  box-shadow: inset 0 1px 2px rgba(28, 25, 23, 0.04);
}

.xp-mono {
  font-family: var(--xp-mono);
  font-size: 11px;
  color: var(--xp-muted);
}

.xp-empty-hint {
  font-size: 12px;
  color: var(--xp-muted-2);
  margin: 0;
  line-height: 1.45;
}

.xp-progress {
  height: 4px;
  background: #e7e5e4;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
  max-width: 120px;
}

.xp-progress > i {
  display: block;
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, #6366f1, #4f46e5);
}

/* Usage charts */
.xp-panel-chart {
  display: flex;
  flex-direction: column;
}

.xp-chart-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--xp-muted-2);
  font-weight: 500;
}

.xp-panel-head .xp-chart-sub {
  margin: 0;
}

.xp-chart {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px 10px;
  margin-top: 4px;
  flex: 1;
}

.xp-chart-axis-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 0 22px;
  font-size: 10px;
  font-weight: 600;
  color: var(--xp-muted-2);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.xp-chart-body {
  min-width: 0;
}

.xp-chart-body-interactive {
  position: relative;
}

.xp-chart-hit {
  cursor: crosshair;
}

.xp-chart-vline {
  stroke: var(--xp-accent);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  opacity: 0.55;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.xp-chart-tooltip {
  position: absolute;
  z-index: 20;
  min-width: 168px;
  max-width: 260px;
  padding: 10px 12px;
  background: var(--xp-surface);
  border: 1px solid var(--xp-line);
  border-radius: var(--xp-radius-sm);
  box-shadow: var(--xp-shadow-dock);
  pointer-events: none;
  transform: translateY(-100%);
}

.xp-chart-tooltip[hidden] {
  display: none;
}

.xp-chart-tooltip-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--xp-ink);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--xp-line);
}

.xp-chart-tooltip ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.xp-chart-tooltip li {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--xp-muted);
}

.xp-chart-tooltip li i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.xp-chart-tooltip li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xp-chart-tooltip li b {
  font-size: 12px;
  font-weight: 700;
  color: var(--xp-ink);
  font-variant-numeric: tabular-nums;
}

.xp-chart-tooltip-total {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--xp-line);
  font-size: 11px;
  font-weight: 600;
  color: var(--xp-muted);
  text-align: right;
}

.xp-chart-tooltip-total b {
  color: var(--xp-ink);
  font-variant-numeric: tabular-nums;
}

.xp-chart-svg {
  display: block;
  width: 100%;
  height: 148px;
  overflow: visible;
}

.xp-chart-grid line {
  stroke: var(--xp-line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.xp-chart-line-total {
  filter: drop-shadow(0 1px 2px rgba(79, 70, 229, 0.2));
}

.xp-chart-line-series {
  opacity: 0.95;
}

.xp-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  padding: 0 2px;
}

.xp-chart-legend[hidden] {
  display: none;
}

.xp-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--xp-muted);
}

.xp-chart-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(28, 25, 23, 0.12);
}

.xp-chart-dots circle.xp-chart-dot-series {
  fill: inherit;
}

.xp-chart-dots circle {
  fill: var(--xp-surface);
  stroke: #4f46e5;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.xp-chart-dots circle.is-peak {
  fill: #4f46e5;
  stroke: #fff;
  stroke-width: 2.5;
}

.xp-chart-axis-x {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--xp-muted-2);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.xp-chart-axis-x span:last-child {
  color: var(--xp-accent);
}

.xp-chart-foot {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--xp-line);
  font-size: 11px;
  color: var(--xp-muted);
}

.xp-share {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 8px 0 4px;
}

@media (min-width: 520px) {
  .xp-share {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 28px;
  }
}

.xp-donut {
  position: relative;
  width: 132px;
  height: 132px;
  flex-shrink: 0;
}

.xp-donut-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    #4f46e5 0deg 259deg,
    #6366f1 259deg 342deg,
    #c7d2fe 342deg 360deg
  );
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.xp-donut-ring::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: var(--xp-surface);
  box-shadow: 0 0 0 1px var(--xp-line);
}

.xp-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}

.xp-donut-center strong {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.xp-donut-center span {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--xp-muted-2);
}

.xp-share-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.xp-share-list li {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  gap: 8px 10px;
  align-items: center;
  font-size: 12px;
}

.xp-share-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--xp-share, var(--xp-accent));
}

.xp-share-name {
  color: var(--xp-ink);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xp-share-val {
  font-variant-numeric: tabular-nums;
  color: var(--xp-muted);
  font-weight: 600;
}

.xp-share-pct {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  color: var(--xp-muted-2);
  min-width: 2.2em;
  text-align: right;
}

.xp-spark {
  height: 28px;
  margin-top: 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--xp-accent-soft), transparent);
  opacity: 0.9;
}

@media (max-width: 720px) {
  .xp-header-inner {
    border-radius: 18px;
    flex-wrap: wrap;
  }
  .xp-brand {
    border-right: none;
  }
  .xp-nav {
    order: 3;
    width: 100%;
  }
}

/* Preview role: user vs admin */
html:not(.xp-role-admin) .xp-col-admin {
  display: none !important;
}

html.xp-role-admin .xp-col-user-only {
  display: none !important;
}

.xp-role-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 999px;
  background: var(--xp-surface-2);
  border: 1px solid var(--xp-line);
}

.xp-role-switch-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--xp-muted-2);
  padding: 0 4px 0 6px;
}

.xp-role-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--xp-muted);
  cursor: pointer;
}

.xp-role-btn:hover {
  color: var(--xp-ink);
  background: var(--xp-surface);
}

.xp-role-btn.is-on {
  background: var(--xp-surface);
  color: var(--xp-accent);
  box-shadow: var(--xp-shadow-card);
}

.xp-admin-users {
  margin-bottom: 28px;
}

.xp-section-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--xp-muted);
}

.xp-key-owner {
  margin: 0 0 6px;
  font-size: 12px;
}

.xp-table-compact th,
.xp-table-compact td {
  padding-top: 10px;
  padding-bottom: 10px;
}

.xp-section-head-split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.xp-section-head-split > h2 {
  margin: 0;
}

.xp-admin-logs-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.xp-admin-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--xp-muted);
}

.xp-admin-filter-label .xp-select {
  min-width: 12rem;
}

.xp-admin-filter-hint {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--xp-radius-sm);
  background: var(--xp-accent-soft);
  border: 1px solid var(--xp-accent-ring);
  font-size: 13px;
  color: var(--xp-ink);
}

.xp-link-btn {
  font: inherit;
  font-weight: 600;
  color: var(--xp-accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.xp-link-btn:hover {
  color: var(--xp-accent-hover);
  text-decoration: underline;
}

.xp-admin-user-row.is-active {
  background: var(--xp-accent-soft);
}

.xp-td-actions {
  white-space: nowrap;
}

.xp-td-actions .xp-btn {
  margin-right: 4px;
}

.xp-detail-dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px 20px;
  margin: 0 0 16px;
}

.xp-detail-dl > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.xp-detail-dl dt {
  font-size: 12px;
  color: var(--xp-muted);
  margin: 0;
}

.xp-detail-dl dd {
  margin: 0;
  font-size: 14px;
}

.xp-detail-keys {
  margin: 0;
  padding-left: 1.2em;
  color: var(--xp-ink);
}

.xp-dialog-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.xp-dialog-foot-end {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
