/* ==========================================================================
   Aurora Relay · 极光中转
   macOS-inspired frosted glass design system
   ========================================================================== */

/* ---------- Design tokens ---------- */

:root,
:root[data-theme='light'] {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI',
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI Variable Display',
    'Segoe UI', 'PingFang SC', 'Microsoft YaHei UI', sans-serif;
  --font-mono: 'SF Mono', ui-monospace, 'Cascadia Code', 'JetBrains Mono', Consolas, 'Courier New', monospace;

  --radius-window: 26px;
  --radius-card: 20px;
  --radius-control: 12px;

  --accent: #0a84ff;
  --accent-2: #5e5ce6;
  --accent-soft: rgba(10, 132, 255, 0.14);
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;

  --bg-0: #e8edf9;
  --blob-1: rgba(112, 164, 255, 0.55);
  --blob-2: rgba(255, 173, 214, 0.45);
  --blob-3: rgba(150, 141, 255, 0.45);
  --blob-4: rgba(121, 227, 255, 0.38);

  --glass-bg: rgba(250, 251, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.72);
  --glass-highlight: rgba(255, 255, 255, 0.95);
  --glass-highlight-weak: rgba(255, 255, 255, 0.7);
  --sidebar-bg: rgba(255, 255, 255, 0.28);
  --card-bg: rgba(255, 255, 255, 0.52);
  --card-bg-strong: rgba(255, 255, 255, 0.74);
  --card-border: rgba(255, 255, 255, 0.68);
  --sheet-bg: rgba(248, 249, 254, 0.88);
  --table-head-bg: rgba(248, 249, 253, 0.82);
  --modal-overlay: rgba(24, 30, 48, 0.24);

  --text-1: #16181d;
  --text-2: rgba(44, 48, 60, 0.62);
  --text-3: rgba(44, 48, 60, 0.38);
  --hairline: rgba(40, 48, 70, 0.11);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --fill-hover: rgba(118, 118, 128, 0.17);

  --shadow-window: 0 32px 90px rgba(30, 44, 80, 0.24), 0 6px 22px rgba(30, 44, 80, 0.1);
  --shadow-card: 0 6px 24px rgba(30, 44, 80, 0.06);
  --shadow-pop: 0 24px 70px rgba(20, 30, 55, 0.28);
  --accent-shadow: 0 6px 18px rgba(10, 132, 255, 0.32);

  --dot-glow-ok: 0 0 0 3px rgba(52, 199, 89, 0.16);
  --dot-glow-warn: 0 0 0 3px rgba(255, 159, 10, 0.16);
  --dot-glow-err: 0 0 0 3px rgba(255, 69, 58, 0.16);
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --bg-0: #07080f;
  --blob-1: rgba(30, 64, 175, 0.6);
  --blob-2: rgba(136, 46, 126, 0.5);
  --blob-3: rgba(14, 116, 144, 0.42);
  --blob-4: rgba(94, 43, 143, 0.5);

  --glass-bg: rgba(24, 25, 32, 0.56);
  --glass-border: rgba(255, 255, 255, 0.13);
  --glass-highlight: rgba(255, 255, 255, 0.16);
  --glass-highlight-weak: rgba(255, 255, 255, 0.08);
  --sidebar-bg: rgba(14, 16, 24, 0.32);
  --card-bg: rgba(255, 255, 255, 0.055);
  --card-bg-strong: rgba(255, 255, 255, 0.09);
  --card-border: rgba(255, 255, 255, 0.09);
  --sheet-bg: rgba(30, 31, 40, 0.9);
  --table-head-bg: rgba(27, 28, 36, 0.9);
  --modal-overlay: rgba(2, 4, 10, 0.55);

  --text-1: #f4f5f9;
  --text-2: rgba(235, 237, 245, 0.62);
  --text-3: rgba(235, 237, 245, 0.34);
  --hairline: rgba(255, 255, 255, 0.09);
  --fill: rgba(120, 124, 140, 0.22);
  --fill-strong: rgba(120, 124, 140, 0.32);
  --fill-hover: rgba(130, 134, 150, 0.27);

  --shadow-window: 0 40px 110px rgba(0, 0, 0, 0.66), 0 8px 28px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 10px 32px rgba(0, 0, 0, 0.24);
  --shadow-pop: 0 30px 80px rgba(0, 0, 0, 0.6);
  --accent-shadow: 0 6px 20px rgba(10, 132, 255, 0.4);

  --dot-glow-ok: 0 0 0 3px rgba(52, 199, 89, 0.2);
  --dot-glow-warn: 0 0 0 3px rgba(255, 159, 10, 0.2);
  --dot-glow-err: 0 0 0 3px rgba(255, 69, 58, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-0: #07080f;
    --text-1: #f4f5f9;
    --text-2: rgba(235, 237, 245, 0.62);
    --text-3: rgba(235, 237, 245, 0.34);
    --hairline: rgba(255, 255, 255, 0.09);
    --glass-bg: rgba(24, 25, 32, 0.56);
    --glass-border: rgba(255, 255, 255, 0.13);
    --glass-highlight: rgba(255, 255, 255, 0.16);
    --glass-highlight-weak: rgba(255, 255, 255, 0.08);
    --sidebar-bg: rgba(14, 16, 24, 0.32);
    --card-bg: rgba(255, 255, 255, 0.055);
    --card-bg-strong: rgba(255, 255, 255, 0.09);
    --card-border: rgba(255, 255, 255, 0.09);
    --fill: rgba(120, 124, 140, 0.22);
    --fill-strong: rgba(120, 124, 140, 0.32);
    --blob-1: rgba(30, 64, 175, 0.6);
    --blob-2: rgba(136, 46, 126, 0.5);
    --blob-3: rgba(14, 116, 144, 0.42);
    --blob-4: rgba(94, 43, 143, 0.5);
  }
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 20px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(10, 132, 255, 0.26);
}

button {
  font-family: inherit;
}

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

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

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: -0.01em;
}

.dim {
  color: var(--text-3);
}

.num {
  font-variant-numeric: tabular-nums;
}

.ico {
  flex: none;
  display: block;
}

/* Custom scrollbars (overlay style) */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 128, 0.32);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 120, 128, 0.5);
  background-clip: content-box;
  border: 3px solid transparent;
}

/* ---------- Aurora wallpaper ---------- */

#wallpaper {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background: var(--bg-0);
}

#wallpaper::before {
  content: '';
  position: absolute;
  inset: -22%;
  background:
    radial-gradient(42% 55% at 16% 22%, var(--blob-1), transparent 70%),
    radial-gradient(36% 48% at 84% 14%, var(--blob-2), transparent 72%),
    radial-gradient(52% 62% at 72% 84%, var(--blob-3), transparent 70%),
    radial-gradient(38% 48% at 24% 88%, var(--blob-4), transparent 72%);
  filter: blur(28px) saturate(1.12);
  animation: aurora-drift 48s ease-in-out infinite alternate;
}

#wallpaper::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  opacity: 0.045;
  mix-blend-mode: overlay;
  pointer-events: none;
}

@keyframes aurora-drift {
  0% {
    transform: translate3d(-2%, -1%, 0) rotate(-1.5deg) scale(1);
  }
  50% {
    transform: translate3d(1.5%, 2%, 0) rotate(1deg) scale(1.04);
  }
  100% {
    transform: translate3d(3%, -2.5%, 0) rotate(2deg) scale(1.02);
  }
}

/* ---------- Boot ---------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.boot.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: boot-breathe 2.2s ease-in-out infinite;
}

.boot-logo {
  filter: drop-shadow(0 18px 34px rgba(30, 40, 90, 0.35));
}

.boot-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.boot-sub {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.34em;
  color: var(--text-3);
}

@keyframes boot-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-4px) scale(1.02);
    opacity: 0.86;
  }
}

/* ---------- App window ---------- */

.app-view {
  position: fixed;
  inset: 20px;
  display: flex;
  animation: window-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes window-in {
  from {
    opacity: 0;
    transform: scale(0.985) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.app-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: var(--radius-window);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(46px) saturate(180%);
  backdrop-filter: blur(46px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-window), inset 0 1px 0 var(--glass-highlight);
  overflow: hidden;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-window {
    background: var(--card-bg-strong);
  }
}

/* Titlebar */

.titlebar {
  position: relative;
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 16px;
  flex: none;
  border-bottom: 1px solid var(--hairline);
}

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

.tl {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.14), 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: filter 0.18s ease;
}

.tl-red {
  background: linear-gradient(180deg, #ff6259, #ff5f57);
}

.tl-yellow {
  background: linear-gradient(180deg, #ffc12e, #febc2e);
}

.tl-green {
  background: linear-gradient(180deg, #33d056, #28c840);
}

.traffic:hover .tl {
  filter: brightness(1.06);
}

.titlebar-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
  pointer-events: none;
}

.titlebar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--fill);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

/* Window body / sidebar */

.window-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 226px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--hairline);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 16px;
}

.brand-logo {
  flex: none;
  filter: drop-shadow(0 6px 14px rgba(30, 45, 100, 0.28));
}

.brand-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.brand-sub {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--text-3);
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease, transform 0.1s ease;
}

.nav-item:hover {
  background: var(--fill);
  color: var(--text-1);
}

.nav-item:active {
  transform: scale(0.985);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.nav-ico {
  display: inline-flex;
  opacity: 0.85;
}

.nav-item.active .nav-ico {
  opacity: 1;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px 11px 4px;
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--hairline);
}

.foot-text {
  white-space: nowrap;
}

/* Main content */

.content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 26px 30px 44px;
  outline: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-2);
}

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

/* ---------- Cards ---------- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-highlight-weak);
  padding: 18px 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link-btn:hover {
  background: var(--accent-soft);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  background: var(--fill);
  color: var(--text-1);
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.btn:hover {
  background: var(--fill-hover);
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: var(--accent-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2b93ff, #6f6df0);
  box-shadow: 0 8px 22px rgba(10, 132, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-ghost {
  background: transparent;
}

.btn-ghost:hover {
  background: var(--fill);
}

.btn-danger {
  background: rgba(255, 69, 58, 0.14);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(255, 69, 58, 0.22);
}

.btn-danger-solid {
  background: linear-gradient(135deg, #ff5f52, #e0342b);
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 69, 58, 0.35);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 9px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  flex: none;
}

.icon-btn:hover {
  background: var(--fill);
  color: var(--text-1);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.sm {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.danger-hover:hover {
  background: rgba(255, 69, 58, 0.14) !important;
  color: var(--red) !important;
}

/* ---------- Inputs ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label,
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: var(--fill);
  color: var(--text-1);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input::placeholder {
  color: var(--text-3);
}

.input:focus {
  border-color: rgba(10, 132, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.16);
  background: var(--card-bg-strong);
}

textarea.input {
  height: auto;
  min-height: 64px;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.5;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

.input-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-group .input {
  flex: 1;
}

.hint {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 14px;
}

.span-2 {
  grid-column: span 2;
}

/* iOS-style switch */

.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 26px;
  flex: none;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--fill-strong);
  transition: background 0.24s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.switch .track::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.26);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked + .track {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

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

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-2);
  padding: 4px 0;
}

/* Segmented control */

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--fill);
}

.seg {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

.seg:hover {
  color: var(--text-1);
}

.seg.active {
  background: var(--card-bg-strong);
  color: var(--text-1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), inset 0 1px 0 var(--glass-highlight-weak);
}

/* ---------- Badges, dots, status ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  flex: none;
}

.badge.anthropic {
  background: rgba(191, 90, 242, 0.14);
  color: #a33ee0;
}

:root[data-theme='dark'] .badge.anthropic {
  color: #d9a1ff;
}

.badge.openai {
  background: rgba(52, 199, 89, 0.14);
  color: #1c9b43;
}

:root[data-theme='dark'] .badge.openai {
  color: #6fe28f;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--text-3);
}

.dot.ok {
  background: var(--green);
  box-shadow: var(--dot-glow-ok);
}

.dot.warn {
  background: var(--orange);
  box-shadow: var(--dot-glow-warn);
}

.dot.err {
  background: var(--red);
  box-shadow: var(--dot-glow-err);
}

.dot.off {
  background: var(--text-3);
  box-shadow: none;
}

.dot.idle {
  background: rgba(120, 124, 140, 0.55);
}

.dot.pulse {
  animation: dot-pulse 2.4s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.16);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(52, 199, 89, 0.05);
  }
}

.st {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.st.ok {
  background: rgba(52, 199, 89, 0.14);
  color: #1c9b43;
}

.st.err {
  background: rgba(255, 69, 58, 0.14);
  color: #d63329;
}

.st.warn {
  background: rgba(255, 159, 10, 0.16);
  color: #b26a00;
}

.st.off {
  background: var(--fill);
  color: var(--text-2);
}

:root[data-theme='dark'] .st.ok {
  color: #6fe28f;
}

:root[data-theme='dark'] .st.err {
  color: #ff7d73;
}

:root[data-theme='dark'] .st.warn {
  color: #ffc45c;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--fill);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Stat cards ---------- */

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

.stat-card {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 17px 18px;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-highlight-weak);
}

.stat-ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex: none;
  color: #fff;
}

.tint-blue {
  background: linear-gradient(135deg, #3d9bff, #0a6cff);
  box-shadow: 0 5px 14px rgba(10, 108, 255, 0.3);
}

.tint-purple {
  background: linear-gradient(135deg, #a06bff, #6d4aff);
  box-shadow: 0 5px 14px rgba(120, 80, 255, 0.3);
}

.tint-green {
  background: linear-gradient(135deg, #47d97a, #1fb457);
  box-shadow: 0 5px 14px rgba(31, 180, 87, 0.3);
}

.tint-orange {
  background: linear-gradient(135deg, #ffb340, #ff8a00);
  box-shadow: 0 5px 14px rgba(255, 138, 0, 0.3);
}

.stat-meta {
  min-width: 0;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.stat-foot {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Overview layout / chart ---------- */

.overview-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.overview-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.chart-card {
  min-width: 0;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-3);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.legend-dot.red {
  background: var(--red);
}

.chart-wrap {
  position: relative;
  width: 100%;
}

.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-tip {
  position: absolute;
  z-index: 3;
  min-width: 128px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--card-bg-strong);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  font-size: 11px;
  color: var(--text-1);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.12s ease;
}

.chart-tip-head {
  font-weight: 650;
  margin-bottom: 4px;
  color: var(--text-2);
}

.chart-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  line-height: 1.55;
}

.chart-tip-row span:last-child {
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.chart-empty-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--text-3);
  pointer-events: none;
}

.mini-list {
  display: flex;
  flex-direction: column;
}

.mini-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 2px;
  font-size: 12px;
  border-top: 1px solid var(--hairline);
  min-width: 0;
}

.mini-row:first-child {
  border-top: 0;
}

.mini-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.mini-meta {
  flex: none;
  color: var(--text-3);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.mini-empty {
  padding: 18px 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
}

/* ---------- Upstreams ---------- */

.up-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(316px, 1fr));
  gap: 14px;
}

.up-card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 17px 18px 15px;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease;
}

.up-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-highlight-weak);
}

.up-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.up-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.up-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-url {
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-models {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 22px;
}

.up-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-3);
}

.up-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 11px;
  border-top: 1px solid var(--hairline);
}

/* ---------- Tables ---------- */

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
}

.logs-scroll {
  max-height: calc(100vh - 330px);
  min-height: 220px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 11px 14px;
  background: var(--table-head-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
  color: var(--text-1);
  white-space: nowrap;
}

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

.data-table tbody tr {
  transition: background 0.12s ease;
}

.data-table tbody tr:hover {
  background: var(--fill);
}

.data-table .row-actions {
  text-align: right;
}

.data-table .row-actions .icon-btn {
  display: inline-flex;
}

.log-row {
  cursor: pointer;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .spacer {
  flex: 1;
}

.toolbar-label {
  font-size: 11.5px;
  color: var(--text-3);
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.search-box {
  position: relative;
  width: 218px;
}

.search-box .ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-box .input {
  padding-left: 32px;
  height: 32px;
  font-size: 12.5px;
}

.empty-inline {
  padding: 34px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
}

/* Keys */

.key-name {
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-note {
  font-size: 10.5px;
  color: var(--text-3);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-code {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 4px 3px 8px;
  border-radius: 8px;
  background: var(--fill);
}

.key-masked {
  cursor: default;
  font-size: 11px;
  color: var(--text-2);
  user-select: all;
}

.quota {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 132px;
}

.progress {
  height: 5px;
  width: 100%;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress.warn span {
  background: linear-gradient(90deg, #ffb340, #ff8a00);
}

.progress.danger span {
  background: linear-gradient(90deg, #ff6a60, #e0342b);
}

.quota-text {
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Empty state ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 58px 24px;
  gap: 4px;
}

.empty-art {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.16), rgba(94, 92, 230, 0.16));
  color: var(--accent);
  margin-bottom: 12px;
  box-shadow: inset 0 1px 0 var(--glass-highlight-weak);
}

.empty-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 650;
}

.empty-text {
  font-size: 12px;
  color: var(--text-3);
  max-width: 330px;
  line-height: 1.6;
}

.empty .btn {
  margin-top: 14px;
}

/* ---------- Skeleton ---------- */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--fill);
  border-radius: 10px;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}

:root[data-theme='dark'] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.skeleton-card {
  height: 148px;
  border-radius: var(--radius-card);
}

.skeleton-stat {
  height: 92px;
  border-radius: var(--radius-card);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--modal-overlay);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
}

.modal {
  width: min(560px, 100%);
  max-height: min(86vh, 860px);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: var(--sheet-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-highlight);
  transform: scale(0.96) translateY(8px);
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
  overflow: hidden;
}

.modal.wide {
  width: min(660px, 100%);
}

.modal-backdrop.show .modal {
  transform: none;
  opacity: 1;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px 22px;
  flex: none;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.modal-close {
  background: var(--fill);
  border-radius: 50%;
  width: 28px;
  height: 28px;
}

.modal-body {
  padding: 8px 22px 12px;
  overflow-y: auto;
  min-height: 0;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 22px 18px;
  flex: none;
}

.modal-foot .btn {
  min-width: 74px;
}

.confirm-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
  padding: 4px 0 10px;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border-radius: 12px;
  background: var(--fill);
  border: 1px solid var(--hairline);
  font-size: 12px;
  word-break: break-all;
  margin-top: 6px;
}

.secret-box code {
  flex: 1;
  color: var(--text-1);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.advanced {
  border-top: 1px solid var(--hairline);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.advanced summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  margin-bottom: 2px;
}

.advanced summary:hover {
  color: var(--text-1);
}

/* ---------- Toast ---------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 13px;
  border-radius: 999px;
  background: var(--card-bg-strong);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-pop);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-1);
  animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  max-width: min(480px, calc(100vw - 48px));
}

.toast.out {
  animation: toast-out 0.2s ease forwards;
}

.toast-ico {
  display: inline-flex;
}

.toast.success .toast-ico {
  color: var(--green);
}

.toast.error .toast-ico {
  color: var(--red);
}

.toast.info .toast-ico {
  color: var(--accent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
}

/* ---------- Login ---------- */

.login-view {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(372px, 100%);
  padding: 34px 30px 24px;
  text-align: center;
  border-radius: 28px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-highlight);
  -webkit-backdrop-filter: blur(48px) saturate(185%);
  backdrop-filter: blur(48px) saturate(185%);
  animation: login-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes login-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.login-card.shake {
  animation: shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(2px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  filter: drop-shadow(0 14px 28px rgba(30, 45, 100, 0.32));
}

.login-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.login-sub {
  margin-top: 3px;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.32em;
  color: var(--text-3);
}

.login-form {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-input {
  height: 40px;
  text-align: center;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  background: var(--fill);
}

.login-input:focus {
  text-align: center;
}

.login-btn {
  height: 40px;
  border-radius: 12px;
  font-size: 13px;
  letter-spacing: 0.12em;
}

.login-error {
  min-height: 17px;
  font-size: 11.5px;
  color: var(--red);
}

.login-hint {
  margin-top: 16px;
  font-size: 10.5px;
  color: var(--text-3);
  line-height: 1.5;
}

.login-footer {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---------- Settings ---------- */

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 720px;
}

.settings-card .card-head {
  margin-bottom: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 159, 10, 0.1);
  color: #9a6400;
  font-size: 11px;
  line-height: 1.55;
}

:root[data-theme='dark'] .notice {
  color: #ffc45c;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
}

.kv:first-child {
  border-top: 0;
}

.kv-k {
  color: var(--text-3);
  flex: none;
}

.kv-v {
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  word-break: break-all;
}

.code-block {
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--fill);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px 7px 12px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--hairline);
}

.code-block pre {
  margin: 0;
  padding: 11px 13px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.65;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre;
}

/* Detail (log inspector) */

.detail-grid {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 7px 14px;
  font-size: 12px;
  padding: 2px 0 6px;
}

.detail-k {
  color: var(--text-3);
}

.detail-v {
  color: var(--text-1);
  word-break: break-word;
}

.error-block {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 69, 58, 0.1);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- User portal ---------- */

.balance-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.14), rgba(94, 92, 230, 0.12));
  border-color: rgba(10, 132, 255, 0.22);
}

.balance-value {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.balance-unit {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-2);
  margin-right: 6px;
}

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

.auth-switch {
  margin: 16px auto 0;
}

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

/* ---------- Keys page channel bar ---------- */

.channel-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.channel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.channel-label {
  width: 64px;
  flex: none;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.channel-row code {
  font-size: 11.5px;
  color: var(--text-1);
}

.channel-note {
  font-size: 10.5px;
  color: var(--text-3);
}

.channel-hint {
  padding-top: 8px;
  border-top: 1px dashed var(--hairline);
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.6;
}

/* ---------- Usage log page (portal) ---------- */

.usage-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
}

.usage-toolbar .input {
  width: 230px;
}

.usage-summary {
  padding: 9px 14px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-3);
  border-bottom: 1px solid var(--hairline);
}

/* ==========================================================================
   Subscription (plans, dashboards, reset cards)
   ========================================================================== */

/* Tier palettes: shared by plan cards, dashboards and dots. */
.tier-aurora {
  --tier-a: #46a4ff;
  --tier-b: #5e5ce6;
  --tier-glow: rgba(70, 164, 255, 0.35);
}
.tier-violet {
  --tier-a: #b06bff;
  --tier-b: #7b5cff;
  --tier-glow: rgba(176, 107, 255, 0.4);
}
.tier-gold {
  --tier-a: #ffd76a;
  --tier-b: #d9973b;
  --tier-glow: rgba(255, 199, 90, 0.45);
}
.tier-platinum {
  --tier-a: #eef1f7;
  --tier-b: #93a1ba;
  --tier-glow: rgba(214, 224, 240, 0.5);
}
.tier-rose {
  --tier-a: #ffb3c7;
  --tier-b: #c8557a;
  --tier-glow: rgba(255, 143, 173, 0.42);
}
.tier-holo {
  --tier-a: #7ef3ff;
  --tier-b: #c86bff;
  --tier-glow: rgba(150, 200, 255, 0.5);
}

.plan-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 7px;
  background: linear-gradient(135deg, var(--tier-a), var(--tier-b));
  vertical-align: 0;
}

/* ---------- Plan cards (portal) ---------- */

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

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px 19px 17px;
  border-radius: var(--radius-card);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-highlight-weak);
  -webkit-backdrop-filter: blur(30px) saturate(165%);
  backdrop-filter: blur(30px) saturate(165%);
  overflow: hidden;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease,
    border-color 0.28s ease;
}

.plan-card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(130% 95% at 100% 0%, var(--tier-glow), transparent 56%);
  opacity: 0.5;
}

.plan-card:hover {
  transform: translateY(-3px);
  border-color: var(--tier-a);
  box-shadow: var(--shadow-card), 0 16px 44px -18px var(--tier-glow);
}

.plan-card.is-current {
  border-color: var(--tier-a);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--tier-a), 0 18px 50px -20px var(--tier-glow);
}

.plan-card > * {
  position: relative;
  z-index: 1;
}

/* Escalating luxury: gold+ get a moving gradient border. */
.plan-card.tier-gold::after,
.plan-card.tier-platinum::after,
.plan-card.tier-rose::after,
.plan-card.tier-holo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 20%, var(--tier-a) 42%, var(--tier-b) 58%, transparent 80%);
  background-size: 240% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0.65;
  animation: tier-sweep 6.5s linear infinite;
}

/* Top tier: animated holographic wash. */
.plan-card.tier-holo::before {
  background: conic-gradient(
    from 210deg at 75% 15%,
    rgba(126, 243, 255, 0.3),
    rgba(200, 107, 255, 0.26),
    rgba(255, 215, 106, 0.2),
    rgba(126, 243, 255, 0.3)
  );
  opacity: 0.6;
  animation: holo-flow 9s ease-in-out infinite;
}

@keyframes tier-sweep {
  0% {
    background-position: 210% 0;
  }
  100% {
    background-position: -90% 0;
  }
}

@keyframes holo-flow {
  0%,
  100% {
    filter: hue-rotate(0deg);
  }
  50% {
    filter: hue-rotate(30deg);
  }
}

.plan-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.plan-multi {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: linear-gradient(120deg, var(--tier-a), var(--tier-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.plan-current-tag {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--text-1);
  background: var(--fill-strong);
  border: 1px solid var(--hairline);
}

.plan-tier-name {
  margin-top: 12px;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.3em;
  background: linear-gradient(120deg, var(--tier-a), var(--tier-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.plan-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 780;
  letter-spacing: -0.01em;
  margin-top: 3px;
}

.plan-tagline {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin: 12px 0 4px;
}

.plan-currency {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 650;
  color: var(--text-2);
}

.plan-amount {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(120deg, var(--tier-a), var(--tier-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}

.plan-per {
  font-size: 11px;
  color: var(--text-3);
  margin-left: 3px;
}

.plan-quota {
  list-style: none;
  margin: 8px 0 14px;
  padding: 10px 0 0;
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plan-quota li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  color: var(--text-3);
}

.plan-quota b {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
}

.plan-cta {
  margin-top: auto;
  width: 100%;
  justify-content: center;
}

/* ---------- Portal subscription shell ---------- */

.sub-intro {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 15px 17px;
  margin-bottom: 16px;
  border-radius: var(--radius-card);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.65;
  box-shadow: var(--shadow-card);
}

.sub-intro b {
  color: var(--text-1);
}

.sub-intro-art {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--accent-2);
  background: linear-gradient(135deg, rgba(70, 164, 255, 0.2), rgba(94, 92, 230, 0.18));
  border: 1px solid var(--hairline);
}

.sub-order-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px 15px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: rgba(255, 159, 10, 0.1);
  border: 1px solid rgba(255, 159, 10, 0.32);
  font-size: 12px;
  color: var(--text-2);
}

.sub-order-banner b {
  color: var(--text-1);
}

.sub-order-banner .dot {
  flex: none;
}

.sub-section-title {
  margin: 22px 2px 12px;
}

.sub-section-title h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.sub-section-title p {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ---------- Subscription dashboard (tier-specific) ---------- */

.sub-hero {
  position: relative;
  border-radius: var(--radius-card);
  padding: 22px 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-card), inset 0 1px 0 var(--glass-highlight-weak);
  -webkit-backdrop-filter: blur(34px) saturate(170%);
  backdrop-filter: blur(34px) saturate(170%);
  overflow: hidden;
}

.sub-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 110% at 88% -10%, var(--tier-glow), transparent 60%);
  opacity: 0.55;
}

.sub-hero-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.tier-gold .sub-hero-shine,
.tier-platinum .sub-hero-shine,
.tier-rose .sub-hero-shine {
  opacity: 1;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.16) 46%, transparent 60%);
  background-size: 260% 100%;
  animation: sub-shine 7.5s ease-in-out infinite;
}

.tier-holo .sub-hero-shine {
  opacity: 0.85;
  background: conic-gradient(
    from 200deg at 62% -5%,
    rgba(126, 243, 255, 0.18),
    rgba(200, 107, 255, 0.18),
    rgba(255, 215, 106, 0.14),
    rgba(126, 243, 255, 0.18)
  );
  animation: holo-breathe 8s ease-in-out infinite alternate;
}

@keyframes sub-shine {
  0% {
    background-position: 230% 0;
  }
  55%,
  100% {
    background-position: -110% 0;
  }
}

@keyframes holo-breathe {
  from {
    opacity: 0.5;
    transform: rotate(0deg) scale(1);
  }
  to {
    opacity: 0.95;
    transform: rotate(5deg) scale(1.1);
  }
}

.sub-hero-head {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.sub-hero-info {
  min-width: 0;
}

.sub-tier-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.14em;
  padding: 4px 11px;
  border-radius: 999px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--hairline);
}

.sub-hero-name {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 10px 0 2px;
  background: linear-gradient(120deg, var(--tier-a), var(--tier-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub-hero-tag {
  font-size: 12px;
  color: var(--text-3);
}

.sub-hero-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 11px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

.sub-hero-meta i {
  font-style: normal;
  color: var(--text-3);
}

.sub-hero-rings {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.sub-ring {
  position: relative;
  width: 88px;
  text-align: center;
}

.sub-ring svg {
  display: block;
  margin: 0 auto;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--hairline);
  stroke-width: 7;
}

.ring-fg {
  fill: none;
  stroke: var(--tier-a);
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--tier-glow));
  transition: stroke-dashoffset 0.6s ease;
}

.ring-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ring-label b {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ring-label span {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.ring-meta {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-2);
}

.ring-reset {
  margin-top: 2px;
  font-size: 9px;
  color: var(--text-3);
}

.sub-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.sub-tile {
  padding: 13px 15px;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-card);
}

.sub-tile-label {
  font-size: 11px;
  color: var(--text-3);
}

.sub-tile-value {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -0.01em;
  margin: 4px 0 3px;
  font-variant-numeric: tabular-nums;
}

.sub-tile-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-3);
}

.sub-tile-pct {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--tier-a);
  background: var(--fill);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 1px 7px;
}

.sub-chart-card {
  margin-bottom: 14px;
}

.sub-bars {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 4px;
}

.sub-bars rect {
  fill: var(--tier-a, var(--accent));
  opacity: 0.82;
  transition: opacity 0.15s ease;
}

.sub-bars rect:hover {
  opacity: 1;
}

.bar-baseline {
  stroke: var(--hairline);
  stroke-width: 1;
}

.bar-label {
  font-size: 8.5px;
  fill: var(--text-3);
  font-family: var(--font-mono);
}

.sub-reset-card .card-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Client access card ---------- */

.sub-access-card {
  margin-top: 14px;
}

.sub-access-card .card-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.access-pricing {
  font-size: 11px;
  line-height: 1.65;
  color: var(--text-3);
  padding: 9px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--fill);
  border: 1px dashed var(--hairline);
}

.access-endpoint {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--fill);
  border: 1px solid var(--hairline);
  margin-bottom: 10px;
}

.access-label {
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: 0.1em;
  color: var(--text-3);
  flex: none;
}

.access-endpoint code {
  flex: 1;
  font-size: 11.5px;
  color: var(--text-1);
  overflow-x: auto;
  white-space: nowrap;
}

.access-keys {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.access-key-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--card-bg-strong);
  border: 1px solid var(--card-border);
}

.access-key-name {
  font-size: 12px;
  font-weight: 600;
  min-width: 108px;
  flex: none;
}

.access-key-val {
  flex: 1;
  font-size: 11px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.access-snippets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.access-snippet {
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--fill);
  overflow: hidden;
}

.access-snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 12px;
  font-size: 10.5px;
  font-weight: 650;
  color: var(--text-3);
  border-bottom: 1px solid var(--hairline);
}

.access-snippet pre {
  margin: 0;
  padding: 10px 12px;
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--text-2);
  overflow-x: auto;
  white-space: pre;
}

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

/* ---------- Subscribe confirmation modal ---------- */

.sub-confirm-head {
  text-align: center;
  padding: 4px 0 14px;
}

.sub-confirm-name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-top: 9px;
  background: linear-gradient(120deg, var(--tier-a), var(--tier-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub-confirm-price {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  margin-top: 3px;
}

.sub-confirm-price span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}

.sub-confirm-quota {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.sub-confirm-quota div {
  text-align: center;
  padding: 10px 8px;
  border-radius: 12px;
  background: var(--fill);
  border: 1px solid var(--hairline);
}

.sub-confirm-quota span {
  display: block;
  font-size: 10px;
  color: var(--text-3);
}

.sub-confirm-quota b {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- Admin subscription page ---------- */

.sub-pct {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 108px;
}

.sub-pct-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
}

.sub-pct-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.sub-pct.warm .sub-pct-track span {
  background: linear-gradient(90deg, var(--orange), #ff6b3d);
}

.sub-pct.hot .sub-pct-track span {
  background: linear-gradient(90deg, var(--red), #ff2d55);
}

.sub-pct-num {
  width: 38px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-2);
}

.sub-history {
  margin-top: 10px;
}

.sub-history summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 8px 2px;
  user-select: none;
}

.sub-history summary:hover {
  color: var(--text-2);
}

.sub-overview-card .card-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 1180px) {
  .plan-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sub-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }
  .sub-tiles {
    grid-template-columns: 1fr;
  }
  .sub-hero-head {
    gap: 16px;
  }
  .sub-hero-rings {
    gap: 8px;
  }
}

/* ---------- Animations & helpers ---------- */

.fade-in {
  animation: fade-in 0.28s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

:focus-visible {
  outline: 2px solid rgba(10, 132, 255, 0.75);
  outline-offset: 2px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1040px) {
  .overview-cols {
    grid-template-columns: minmax(0, 1fr);
  }
  .overview-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  body {
    padding: 12px;
  }
  .app-view {
    inset: 12px;
  }
  .sidebar {
    width: 72px;
    padding: 14px 10px 10px;
    align-items: center;
  }
  .brand {
    padding: 2px 0 16px;
  }
  .brand-text,
  .nav-label,
  .foot-text {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 10px;
  }
  .sidebar-foot {
    justify-content: center;
    padding: 12px 0 4px;
  }
  .content {
    padding: 20px 20px 36px;
  }
  .up-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .overview-side {
    grid-template-columns: 1fr;
  }
  .conn-pill span:last-child {
    display: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: span 1;
  }
  .search-box {
    width: 100%;
  }
  .titlebar-title {
    display: none;
  }
}

/* ---------- Reduced motion ---------- */

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