/* ==========================================================================
   V-NFREE Console · Obsidian & Sapphire Crystal Glass Design System
   ========================================================================== */

:root {
  --bg: #040813;
  --bg-deep: #02050c;

  /* Layered frosted obsidian glass */
  --surface: rgba(9, 16, 32, 0.58);
  --surface-hover: rgba(13, 22, 43, 0.68);
  --surface-rail: rgba(6, 11, 23, 0.72);
  --surface-elevated: rgba(8, 14, 28, 0.84);
  --surface-inset: rgba(3, 8, 18, 0.62);
  --surface-control: rgba(11, 19, 38, 0.56);

  /* Specular glass hairlines */
  --border: rgba(168, 206, 255, 0.13);
  --border-hi: rgba(168, 214, 255, 0.28);
  --border-focus: rgba(96, 175, 255, 0.72);
  --specular-top: rgba(255, 255, 255, 0.12);

  /* Blur */
  --blur: blur(22px) saturate(145%);
  --blur-strong: blur(28px) saturate(160%);

  /* Typography colors */
  --text: #f3f7ff;
  --text-dim: #bfd0ec;
  --muted: #7f94b8;

  /* Sapphire / Ice / Semantic palette */
  --accent: #5b8cff;
  --accent-2: #56d4ff;
  --accent-grad: linear-gradient(135deg, #4f7cff 0%, #2eb9f8 100%);
  --accent-grad-hi: linear-gradient(135deg, #628bff 0%, #44c8ff 100%);
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;

  /* Radii & Fonts */
  --radius: 18px;
  --radius-sm: 11px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", ui-monospace, Consolas, "Liberation Mono", monospace;

  color-scheme: dark;
  accent-color: #5b8cff;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--bg);
  background-image: url("/assets/bg.jpg?v=3");
  background-image: image-set(
    url("/assets/bg.webp?v=3") type("image/webp"),
    url("/assets/bg.jpg?v=3") type("image/jpeg")
  );
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Soft ambient atmospheric vignette so cards float over calm depth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(960px 600px at 14% 8%, rgba(45, 95, 220, 0.14), transparent 62%),
    radial-gradient(880px 580px at 88% 92%, rgba(36, 196, 245, 0.12), transparent 60%),
    linear-gradient(180deg, rgba(4, 8, 18, 0.34) 0%, rgba(4, 8, 18, 0.20) 48%, rgba(3, 6, 15, 0.42) 100%);
  pointer-events: none;
  z-index: 0;
}

/* Ultra-fine optical film grain */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.018;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}

/* Mobile vertical wallpaper */
@media (max-width: 820px) {
  body {
    background-image: none;
    background-color: var(--bg);
  }
  body::before {
    inset: auto;
    top: 0;
    left: 0;
    right: 0;
    height: 100lvh;
    background-image:
      radial-gradient(720px 460px at 15% 6%, rgba(45, 95, 220, 0.16), transparent 62%),
      linear-gradient(180deg, rgba(4, 8, 18, 0.38) 0%, rgba(4, 8, 18, 0.22) 50%, rgba(3, 6, 15, 0.48) 100%),
      image-set(
        url("/assets/bg-m.webp?v=3") type("image/webp"),
        url("/assets/bg-m.jpg?v=3") type("image/jpeg")
      );
    background-size: auto, auto, cover;
    background-position: center, center, center;
    background-repeat: no-repeat;
  }
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: rgba(130, 168, 224, 0.22) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(130, 168, 224, 0.20);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(130, 168, 224, 0.38); background-clip: content-box; }

/* Utilities */
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card-lead { margin: 0 0 12px; }
.head-right { display: flex; gap: 10px; align-items: center; }

code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(88, 148, 255, 0.12);
  border: 1px solid rgba(130, 180, 255, 0.18);
  color: #cfe6ff;
  padding: 1px 6px;
  border-radius: 6px;
}

/* ==========================================================================
   Login Screen
   ========================================================================== */

.login-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 1;
  overflow: hidden;
}

.glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(64px);
}
.glow-a {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(66, 128, 255, 0.26), transparent 68%);
  transform: translate(-18%, -12%);
  animation: driftA 9s ease-in-out infinite alternate;
}
.glow-b {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, rgba(46, 198, 248, 0.20), transparent 68%);
  transform: translate(22%, 18%);
  animation: driftB 11s ease-in-out infinite alternate;
}
@keyframes driftA {
  from { transform: translate(-20%, -14%) scale(0.96); opacity: 0.72; }
  to   { transform: translate(-10%, -6%) scale(1.08); opacity: 1; }
}
@keyframes driftB {
  from { transform: translate(22%, 18%) scale(1.04); opacity: 0.65; }
  to   { transform: translate(12%, 10%) scale(0.95); opacity: 0.95; }
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 412px;
  background: linear-gradient(165deg, rgba(13, 22, 44, 0.82) 0%, rgba(7, 13, 27, 0.88) 100%);
  border: 1px solid rgba(176, 214, 255, 0.22);
  border-radius: 26px;
  padding: 34px 30px 30px;
  box-shadow:
    0 36px 90px -28px rgba(0, 4, 14, 0.88),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
  animation: cardRise 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cardRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.login-hint {
  color: #95abc9;
  font-size: 12px;
  margin: 18px 0 0;
  line-height: 1.75;
  text-align: center;
  text-wrap: balance;
}
.login-error {
  color: var(--red);
  font-size: 12.5px;
  margin: 10px 0 0;
  min-height: 18px;
  text-align: center;
}

/* Brand Lockup */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px;
}
.brand-text { min-width: 0; }
.brand h1 {
  font-size: 16.5px;
  margin: 0;
  letter-spacing: 0.06em;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff 25%, #b5d8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-lg {
  margin-bottom: 28px;
  gap: 14px;
}
.brand-lg h1 {
  font-size: 24px;
  letter-spacing: 0.07em;
}
.brand-lg p {
  font-size: 12.5px;
  color: var(--text-dim);
  opacity: 0.8;
}

.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
}
.logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter:
    drop-shadow(0 2px 6px rgba(2, 10, 28, 0.72))
    drop-shadow(0 0 14px rgba(86, 175, 255, 0.38));
}
.brand-lg .logo { width: 56px; height: 56px; }
.brand-lg .logo img {
  filter:
    drop-shadow(0 4px 10px rgba(2, 10, 28, 0.78))
    drop-shadow(0 0 22px rgba(86, 185, 255, 0.46));
}

/* ==========================================================================
   Form Controls
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}
.field > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
}
.field > .field-hint,
p.field-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}
.field > .field-hint code,
p.field-hint code { font-size: 11px; }
.field.grow { flex: 1; min-width: 150px; }

input[type="text"],
input[type="password"],
input[type="number"],
input:not([type]),
select,
textarea {
  width: 100%;
  background: var(--surface-inset);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

input[type="text"],
input[type="password"],
input[type="number"],
input:not([type]),
select {
  height: 40px;
  line-height: normal;
}

textarea {
  padding: 10px 13px;
  resize: vertical;
  line-height: 1.6;
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--border-hi);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  background: rgba(5, 11, 24, 0.82);
  box-shadow: 0 0 0 3px rgba(82, 148, 255, 0.22);
}

input::placeholder,
textarea::placeholder {
  color: rgba(148, 172, 210, 0.45);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}

select option,
select optgroup {
  background-color: #0b1222;
  color: var(--text);
}
select option:disabled { color: #52627e; }

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.form-row > .field { flex: 1 1 175px; min-width: 0; margin-bottom: 10px; }
.form-row > .field.grow { flex: 2 1 240px; }
.form-row > .field.shrink { flex: 0 1 150px; }
.form-row > .btn { align-self: flex-end; margin-bottom: 10px; height: 40px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-control);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
}
.btn:hover {
  transform: translateY(-1px);
  background: rgba(24, 39, 72, 0.72);
  border-color: var(--border-hi);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent-grad);
  border-color: rgba(164, 214, 255, 0.35);
  color: #ffffff;
  font-weight: 600;
  box-shadow:
    0 10px 26px -10px rgba(56, 134, 255, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}
.btn-primary:hover {
  background: var(--accent-grad-hi);
  border-color: rgba(195, 232, 255, 0.50);
  box-shadow:
    0 14px 32px -10px rgba(64, 152, 255, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.btn-ghost {
  background: rgba(16, 27, 52, 0.46);
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: rgba(28, 46, 84, 0.65);
  border-color: var(--border-hi);
  color: var(--text);
}

.btn-danger-ghost {
  background: rgba(127, 29, 29, 0.28);
  border-color: rgba(248, 113, 113, 0.30);
  color: #fca5a5;
}
.btn-danger-ghost:hover {
  background: rgba(153, 27, 27, 0.44);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fee2e2;
}

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 9px; height: auto; }
.btn-block { width: 100%; margin-top: 6px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  border-radius: 9px;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border);
  color: var(--text);
}

.link-btn {
  background: none;
  border: none;
  padding: 2px 7px;
  margin-left: 6px;
  color: var(--accent-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.link-btn:hover {
  background: rgba(86, 212, 255, 0.12);
  color: #a8ecff;
}

/* ==========================================================================
   App Shell Layout
   ========================================================================== */

.app {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 248px;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  background: var(--surface-rail);
  border-right: 1px solid var(--border);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
}

/* Unified Proxy Switcher (Vertex / PG) */
.proxy-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 16px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(3, 7, 16, 0.72);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 4px rgba(0, 4, 14, 0.5);
}
.proxy-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 8.5px;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.proxy-tab:hover {
  color: var(--text);
  background: rgba(168, 206, 255, 0.08);
}
.proxy-tab.active {
  background: var(--accent-grad);
  color: #ffffff;
  box-shadow:
    0 6px 18px -6px rgba(56, 134, 255, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

/* PG Tier & YAML Editor helpers */
.tag-tier-pro {
  background: rgba(91, 140, 255, 0.18);
  color: #a5c4ff;
  border-color: rgba(124, 176, 255, 0.36);
}
.tag-tier-ultra {
  background: rgba(168, 85, 247, 0.20);
  color: #e9d5ff;
  border-color: rgba(192, 132, 252, 0.42);
}
.tag-tier-plus {
  background: rgba(14, 165, 233, 0.18);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.38);
}
.yaml-editor {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  min-height: 360px;
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
}
.modal-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(3, 7, 16, 0.72);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.modal-tabs button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.modal-tabs button.active {
  background: var(--accent-grad);
  color: #fff;
  font-weight: 600;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9.5px 12px;
  border-radius: 11px;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.nav-item i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted);
  transition: color 0.16s ease;
}
.nav-item i svg { width: 16px; height: 16px; }

.nav-item:hover {
  background: rgba(140, 184, 255, 0.08);
  color: var(--text);
}
.nav-item:hover i { color: var(--text-dim); }

.nav-item.active {
  background: linear-gradient(100deg, rgba(79, 124, 255, 0.22) 0%, rgba(46, 185, 248, 0.08) 100%);
  border-color: rgba(124, 176, 255, 0.28);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-grad);
  box-shadow: 0 0 10px rgba(86, 212, 255, 0.8);
}
.nav-item.active i { color: var(--accent-2); }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 4px 0;
  border-top: 1px solid var(--border);
}

.mini-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.9);
  animation: beacon 2.4s ease-in-out infinite;
}
@keyframes beacon {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.85); }
}

.endpoint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-2);
  word-break: break-all;
  margin-bottom: 12px;
  line-height: 1.5;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(5, 12, 26, 0.55);
  border: 1px solid rgba(86, 212, 255, 0.14);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.endpoint:hover {
  border-color: rgba(86, 212, 255, 0.38);
  background: rgba(12, 26, 52, 0.72);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(6, 11, 23, 0.66);
  backdrop-filter: var(--blur-strong);
  -webkit-backdrop-filter: var(--blur-strong);
}
.topbar h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
.topbar p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.view-wrap {
  padding: 24px 32px 32px;
  max-width: 1220px;
  width: 100%;
  min-width: 0;
}
.view {
  display: none;
  animation: fadeUp 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   Cards & KPI Stats
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  min-width: 0;
  box-shadow:
    0 20px 50px -28px rgba(0, 4, 14, 0.78),
    inset 0 1px 0 var(--specular-top);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: border-color 0.2s ease;
}
.card:hover { border-color: rgba(168, 210, 255, 0.19); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}
.card-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text);
}

.note {
  display: flex;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.7;
  flex-wrap: wrap;
  background: linear-gradient(120deg, rgba(44, 86, 180, 0.16), rgba(9, 16, 32, 0.62));
  border-color: rgba(114, 168, 255, 0.22);
}
.note b { color: #ffffff; flex: none; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.12fr 1fr;
  gap: 18px;
}
.grid-2 > * { min-width: 0; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* KPI Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stats > * { min-width: 0; }
@media (max-width: 920px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  box-shadow:
    0 18px 42px -26px rgba(0, 4, 14, 0.8),
    inset 0 1px 0 var(--specular-top);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, background-color 0.2s ease;
}
.stat::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.25s ease;
}
.stat:nth-child(1)::after { background: radial-gradient(circle, rgba(91, 140, 255, 0.26), transparent 68%); }
.stat:nth-child(2)::after { background: radial-gradient(circle, rgba(86, 212, 255, 0.24), transparent 68%); }
.stat:nth-child(3)::after { background: radial-gradient(circle, rgba(52, 211, 153, 0.24), transparent 68%); }
.stat:nth-child(4)::after { background: radial-gradient(circle, rgba(167, 139, 250, 0.24), transparent 68%); }

.stat:hover {
  transform: translateY(-2px);
  border-color: var(--border-hi);
  background: var(--surface-hover);
}
.stat:hover::after { opacity: 0.85; transform: scale(1.1); }

.stat .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.stat .value {
  font-size: 27px;
  font-weight: 700;
  margin-top: 6px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: #ffffff;
  line-height: 1.2;
}
.stat .sub {
  font-size: 11.5px;
  color: var(--text-dim);
  opacity: 0.82;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Key-Value Lists, Steps & Code Blocks
   ========================================================================== */

.kv-list { display: flex; flex-direction: column; gap: 11px; }
.kv { display: flex; align-items: baseline; gap: 14px; font-size: 13px; }
.kv > span:first-child { color: var(--muted); flex: none; width: 84px; font-size: 12.5px; }
.kv-val { color: var(--text-dim); word-break: break-all; flex: 1; }
.kv-val.mono { color: var(--accent-2); font-size: 12.5px; }
.copyable { cursor: pointer; transition: color 0.15s ease; }
.copyable:hover { color: #a8ecff; text-decoration: underline; text-underline-offset: 3px; }

.steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed rgba(168, 206, 255, 0.16);
}
.step {
  display: flex;
  gap: 11px;
  font-size: 12.5px;
  color: var(--text-dim);
  align-items: flex-start;
}
.step div b { color: var(--text); font-weight: 600; }
.step > b {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-family: var(--mono);
  background: rgba(79, 124, 255, 0.22);
  border: 1px solid rgba(114, 168, 255, 0.36);
  color: #c8dcff;
}

pre.code {
  background: var(--surface-inset);
  border: 1px solid rgba(168, 206, 255, 0.11);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.75;
  color: #c9defc;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  box-shadow: inset 0 2px 10px rgba(0, 4, 14, 0.45);
}

/* ==========================================================================
   Tables & Tags
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(168, 206, 255, 0.10);
  background: rgba(4, 9, 20, 0.42);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 13px;
  background: rgba(8, 15, 31, 0.72);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10.5px 13px;
  border-bottom: 1px solid rgba(168, 206, 255, 0.07);
  vertical-align: middle;
  color: var(--text-dim);
}

tbody tr { transition: background-color 0.14s ease; }
tbody tr:nth-child(even) { background: rgba(140, 180, 255, 0.022); }
tbody tr:hover { background: rgba(86, 148, 255, 0.085); }
tbody tr:last-child td { border-bottom: none; }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 34px 14px;
  line-height: 1.8;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8.5px;
  border-radius: 99px;
  background: rgba(148, 178, 224, 0.12);
  color: var(--text-dim);
  border: 1px solid rgba(168, 206, 255, 0.22);
  white-space: nowrap;
  vertical-align: middle;
}
.tag + .tag { margin-left: 4px; }

.tag-live {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.34);
}
.tag-live::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.9);
}

.tag-mock {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.36);
}
.tag-err {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.36);
}
.tag-off {
  background: rgba(100, 116, 139, 0.16);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.22);
}

/* ==========================================================================
   Credential Cards
   ========================================================================== */

.cred-list { display: flex; flex-direction: column; gap: 12px; }

.cred {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 20px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow:
    0 18px 42px -28px rgba(0, 4, 14, 0.8),
    inset 0 1px 0 var(--specular-top);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}
.cred:hover {
  transform: translateY(-1px);
  border-color: var(--border-hi);
  background: var(--surface-hover);
}
.cred-main { flex: 1; min-width: 240px; }
.cred-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 650;
  font-size: 14px;
  color: var(--text);
}
.cred-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 7px;
  font-size: 12px;
  color: var(--muted);
}
.cred-meta span b {
  color: var(--text-dim);
  font-weight: 500;
  font-family: var(--mono);
  margin-left: 3px;
}
.cred-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: none;
  align-items: center;
}
.cred-actions .btn { width: auto; }
.cred-actions select {
  width: auto;
  height: 31px;
  font-size: 12px;
  border-radius: 9px;
}

/* ==========================================================================
   Key Reveal Box
   ========================================================================== */

.reveal {
  margin-top: 16px;
  border: 1px solid rgba(52, 211, 153, 0.36);
  background: rgba(6, 78, 59, 0.30);
  border-radius: 13px;
  padding: 14px 16px;
  animation: fadeUp 0.25s ease;
}
.reveal-head {
  font-size: 12px;
  color: #6ee7b7;
  margin-bottom: 10px;
  font-weight: 500;
}
.reveal-body {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.reveal-body code {
  flex: 1;
  min-width: 200px;
  background: rgba(2, 10, 18, 0.68);
  border-color: rgba(52, 211, 153, 0.25);
  padding: 9px 12px;
  font-size: 12.5px;
  color: #a7f3d0;
  word-break: break-all;
}

/* ==========================================================================
   Playground Chat Console
   ========================================================================== */

.chat-log {
  background: var(--surface-inset);
  color: var(--text-dim);
  border: 1px solid rgba(168, 206, 255, 0.11);
  border-radius: 14px;
  padding: 16px;
  min-height: 240px;
  max-height: 480px;
  overflow-y: auto;
  margin: 8px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: inset 0 2px 12px rgba(0, 4, 14, 0.45);
}

.msg {
  display: flex;
  gap: 11px;
  font-size: 13.5px;
  line-height: 1.72;
  align-items: flex-start;
}
.msg .who {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 650;
}
.msg.user .who {
  background: rgba(46, 185, 248, 0.18);
  border: 1px solid rgba(86, 212, 255, 0.30);
  color: #7dd3fc;
}
.msg.assistant .who {
  background: rgba(91, 140, 255, 0.22);
  border: 1px solid rgba(130, 168, 255, 0.34);
  color: #c7d9ff;
}
.msg .body {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 3px 0;
  color: var(--text);
}
.chat-log .msg.err .body { color: #fca5a5; }

.pg-input { display: flex; gap: 10px; align-items: flex-end; }
.pg-input textarea { flex: 1; }
.pg-input .btn { height: 42px; padding: 0 20px; }
.pg-meta { margin-top: 9px; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* ==========================================================================
   Settings: Tier Boxes, Segmented Controls, Switches & Model Chips
   ========================================================================== */

.tier-box {
  border: 1px solid var(--border);
  background: rgba(5, 11, 24, 0.44);
  border-radius: 15px;
  padding: 16px 18px;
  margin: 6px 0 16px;
}
.tier-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.tier-title {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tier-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8.5px;
  border-radius: 99px;
  background: rgba(91, 140, 255, 0.22);
  border: 1px solid rgba(130, 174, 255, 0.32);
  color: #c7dcff;
}
.tier-badge.flex {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}
.tier-badge.priority {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(251, 191, 36, 0.38);
  color: #fcd34d;
}
.tier-desc { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tier-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.75;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(168, 206, 255, 0.14);
}
.tier-note b { color: var(--text-dim); font-weight: 600; }

.segmented {
  display: inline-flex;
  gap: 4px;
  background: rgba(3, 7, 16, 0.68);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
}
.segmented button {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6.5px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}
.segmented button:hover {
  color: var(--text);
  background: rgba(168, 206, 255, 0.08);
}
.segmented button.active {
  background: var(--accent-grad);
  color: #ffffff;
  font-weight: 600;
  box-shadow:
    0 6px 18px -6px rgba(56, 134, 255, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Model Suggestion Chips */
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.chip-label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.chip {
  background: rgba(12, 22, 46, 0.62);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover {
  background: rgba(66, 124, 255, 0.22);
  border-color: rgba(124, 180, 255, 0.52);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Switches */
.switch-row { display: flex; flex-direction: column; gap: 12px; margin: 4px 0 16px; }
.switch {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  user-select: none;
}
.switch input { display: none; }
.slider {
  width: 40px;
  height: 22px;
  border-radius: 99px;
  background: rgba(15, 26, 52, 0.85);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
  flex: none;
}
.slider::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #dbe8ff;
  top: 2px;
  left: 2px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease;
}
.switch input:checked + .slider {
  background: var(--accent-grad);
  border-color: rgba(164, 214, 255, 0.45);
}
.switch input:checked + .slider::after {
  transform: translateX(18px);
  background: #ffffff;
}
.switch-label { font-size: 12.5px; color: var(--text-dim); }

/* ==========================================================================
   Log Detail, Pagination & Dropzone
   ========================================================================== */

.log-err-cell { max-width: 300px; }
.err-link {
  all: unset;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  color: #fca5a5;
  border-bottom: 1px dashed rgba(248, 113, 113, 0.42);
  word-break: break-word;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.err-link:hover { color: #fee2e2; border-bottom-color: #fca5a5; }
.err-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.err-block-title { font-size: 12px; color: var(--muted); margin: 16px 0 8px; }
.err-pre {
  margin: 0;
  padding: 14px 15px;
  background: var(--surface-inset);
  border: 1px solid rgba(248, 113, 113, 0.24);
  border-radius: 11px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: #fecaca;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 52vh;
  overflow: auto;
  user-select: text;
  cursor: text;
}
.err-none { font-size: 12.5px; color: var(--muted); margin-top: 14px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pager-info { font-size: 12px; color: var(--muted); }
.pager-btns { display: flex; align-items: center; gap: 8px; }
.pager-num {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  min-width: 58px;
  text-align: center;
}
.pager .btn { padding: 5px 12px; font-size: 12px; }

#view-logs .card, #view-pg-logs .card { margin-bottom: 0; }
.view-wrap:has(#view-logs.active), .view-wrap:has(#view-pg-logs.active) { padding-bottom: 14px; }
#logTable .table-wrap, #pgLogTable .table-wrap { max-height: calc(100vh - 260px); overflow: auto; }

.drop {
  border: 1.5px dashed rgba(130, 176, 255, 0.34);
  background: rgba(6, 13, 28, 0.45);
  border-radius: 13px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.16s ease;
  margin-bottom: 14px;
}
.drop:hover, .drop.over {
  border-color: var(--accent-2);
  background: rgba(56, 134, 255, 0.10);
  color: var(--text);
}

.detect {
  font-size: 12px;
  font-family: var(--mono);
  background: rgba(6, 78, 59, 0.32);
  border: 1px solid rgba(52, 211, 153, 0.38);
  color: #a7f3d0;
  border-radius: 10px;
  padding: 10px 13px;
  margin-bottom: 12px;
  line-height: 1.7;
  word-break: break-all;
}
.detect.bad {
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(248, 113, 113, 0.40);
  color: #fecaca;
}

/* ==========================================================================
   Modal & Toast
   ========================================================================== */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 5, 14, 0.64);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: maskFade 0.18s ease;
}
@keyframes maskFade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 560px;
  background: linear-gradient(170deg, rgba(13, 22, 44, 0.94), rgba(7, 13, 27, 0.96));
  border: 1px solid rgba(176, 214, 255, 0.22);
  border-radius: 22px;
  box-shadow:
    0 40px 100px -24px rgba(0, 4, 14, 0.92),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.modal-wide { max-width: 780px; }
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
}
.toast {
  background: rgba(10, 18, 36, 0.92);
  border: 1px solid rgba(176, 214, 255, 0.24);
  border-radius: 99px;
  padding: 9px 18px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  box-shadow:
    0 18px 46px -14px rgba(0, 4, 14, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  animation: toastIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: min(520px, calc(100vw - 32px));
}
.toast.ok {
  border-color: rgba(52, 211, 153, 0.45);
  color: #d1fae5;
}
.toast.err {
  border-color: rgba(248, 113, 113, 0.48);
  color: #fee2e2;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   Responsive Mobile
   ========================================================================== */

@media (max-width: 780px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand .logo { width: 32px; height: 32px; }
  .sidebar .brand p { display: none; }
  .sidebar .brand h1 { white-space: nowrap; font-size: 14.5px; }
  .proxy-switch { margin-top: 0; flex: none; padding: 3px; }
  .proxy-tab { padding: 5px 9px; font-size: 12px; }
  .login-card .brand-lg .logo { width: 48px; height: 48px; }
  .login-card .brand-lg h1 { font-size: 21px; }
  .nav { flex-direction: row; margin-top: 0; gap: 4px; }
  .nav-item { padding: 7px 11px; font-size: 12.5px; white-space: nowrap; }
  .nav-item i { display: none; }
  .nav-item.active::before { display: none; }
  .sidebar-foot { display: none; }

  .topbar { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .topbar h2 { font-size: 16.5px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .view-wrap { padding: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 22px; }
  .card { padding: 16px; border-radius: 15px; }
  .login-card { padding: 28px 22px 24px; }
}

/* Shared navigation section (Unified Keys) */
.nav-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 4px 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-sep::before,
.nav-sep::after {
  content: "";
  height: 1px;
  background: var(--border);
  flex: 1;
}
.nav-sep::before { flex: 0 0 10px; }
.nav-shared { margin-top: 2px; }
