:root {
  --bg: #08090f;
  --bg-top: #0d0f1a;
  --surface: rgba(14, 16, 28, 0.72);
  --surface-strong: rgba(20, 22, 38, 0.92);
  --border: rgba(255, 255, 255, 0.07);
  --border-bright: rgba(255, 255, 255, 0.14);
  --text: #f4f2ff;
  --muted: #8f93b8;
  --accent: #a78bfa;
  --accent-2: #38bdf8;
  --accent-hot: #fb7185;
  --success: #4ade80;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 20px;
}

* { box-sizing: border-box; }

html {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(167, 139, 250, 0.18), transparent),
    linear-gradient(180deg, var(--bg-top) 0%, #0d0f1a 50%, var(--bg) 100%);
  background-color: var(--bg-top);
  height: -webkit-fill-available;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: transparent;
  overflow-x: hidden;
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(167, 139, 250, 0.18), transparent),
    linear-gradient(180deg, var(--bg-top) 0%, #0d0f1a 50%, var(--bg) 100%);
  background-color: var(--bg-top);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite;
}

.orb-1 {
  width: 420px;
  height: 420px;
  top: -120px;
  left: -80px;
  background: rgba(167, 139, 250, 0.35);
}

.orb-2 {
  width: 360px;
  height: 360px;
  top: 30%;
  right: -100px;
  background: rgba(56, 189, 248, 0.22);
  animation-delay: -6s;
}

.orb-3 {
  width: 280px;
  height: 280px;
  bottom: -60px;
  left: 35%;
  background: rgba(251, 113, 133, 0.18);
  animation-delay: -12s;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black, transparent);
}

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 25px) scale(0.95); }
}

.container {
  width: min(1020px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 56px;
  position: relative;
  z-index: 1;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  margin-bottom: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.35), rgba(56, 189, 248, 0.2));
  border: 1px solid var(--border-bright);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark span {
  display: block;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0.85;
}

.brand-mark span:nth-child(2) { opacity: 0.55; height: 70%; align-self: end; }
.brand-mark span:nth-child(3) { opacity: 1; }

.brand-name {
  font-family: "Syne", sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #fff 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-top: 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.auth-card {
  max-width: 520px;
  margin: 0 auto;
}

.auth-hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-weight: 600;
}

.auth-hero h1,
.dashboard-intro h2,
.stat-card h3,
.guide-card h3,
.modal-content h2 {
  margin: 0;
  font-family: "Syne", sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.auth-hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.1;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tab.active {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.25), rgba(56, 189, 248, 0.12));
  color: var(--text);
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.15);
}

.form, .inline-form {
  display: grid;
  gap: 16px;
}

.inline-form {
  grid-template-columns: 1fr auto;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 500;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 16px;
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder, textarea::placeholder {
  color: rgba(143, 147, 184, 0.6);
}

input:focus, textarea:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}

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

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6366f1 50%, #38bdf8);
  color: white;
  box-shadow: 0 8px 28px rgba(139, 92, 246, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 12px 36px rgba(139, 92, 246, 0.45);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-bright);
}

.btn-small {
  padding: 9px 14px;
  font-size: 0.84rem;
}

.message {
  min-height: 1.2em;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.message.error { color: var(--danger); }
.message.success { color: var(--success); }

.hidden { display: none !important; }

.pending-card {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.pending-icon {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 12px;
  animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

.pending-card h2 {
  font-family: "Syne", sans-serif;
  margin: 0 0 10px;
}

.pending-card p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 24px;
}

.dashboard-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.dashboard-intro h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.status-badge {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.status-badge.active {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.08);
}

.status-badge.inactive {
  color: var(--danger);
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.08);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 20px;
  margin-bottom: 20px;
}

.card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  margin-bottom: 8px;
  font-weight: 600;
}

.stat-card h3,
.guide-card h3 {
  font-size: 1.25rem;
  margin-bottom: 18px;
}

.profile-list {
  margin: 0;
  display: grid;
  gap: 0;
}

.profile-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.profile-list div:last-child { border-bottom: none; }

.profile-list dt {
  color: var(--muted);
  font-size: 0.88rem;
}

.profile-list dd {
  margin: 0;
  text-align: right;
  font-weight: 500;
  font-size: 0.92rem;
}

.devices-list {
  display: grid;
  gap: 10px;
}

.devices-card h3 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.server-status-card {
  margin-bottom: 16px;
}

.server-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.server-status-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.locations-summary {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.locations-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.location-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.84rem;
}

.location-chip.alive {
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.08);
}

.location-chip.dead {
  border-color: rgba(251, 113, 133, 0.25);
  background: rgba(251, 113, 133, 0.06);
}

.location-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

.location-chip.alive .location-dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.location-name {
  font-weight: 600;
}

.location-ping {
  color: var(--muted);
  font-size: 0.78rem;
}

.guide-card-compact {
  margin-top: 16px;
  padding: 16px 20px;
}

.instructions-compact {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.device-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s;
}

.device-item:hover {
  border-color: rgba(167, 139, 250, 0.25);
}

.device-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.device-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.device-meta-sep {
  opacity: 0.5;
}

.online-now {
  color: var(--success);
  font-weight: 600;
}

.instructions {
  display: grid;
  gap: 14px;
}

.instruction-step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.3), rgba(56, 189, 248, 0.2));
  color: var(--text);
}

.step-body strong {
  display: block;
  margin-bottom: 4px;
}

.step-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 12, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-content {
  width: min(500px, 100%);
  position: relative;
  background: var(--surface-strong);
}

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

.approve-mode-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.approve-mode-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.approve-mode-tab.active {
  color: var(--text);
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.12);
}

.clients-checklist {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.client-check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.client-check-item input {
  margin-top: 3px;
}

.client-check-title {
  font-weight: 600;
}

.client-check-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.client-group-title {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  margin: 8px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.client-group:first-child .client-group-title {
  margin-top: 0;
}

.hint-text {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 10px;
}

#approve-client-search {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}

.qr-frame {
  padding: 16px;
  border-radius: 18px;
  background: white;
  margin: 16px 0;
  display: flex;
  justify-content: center;
}

.qr-image {
  display: block;
  width: min(240px, 100%);
  height: auto;
}

.impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -8px 0 20px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
  font-size: 0.9rem;
}

.impersonation-banner strong {
  color: #fff;
}

.admin-badge {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.18);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.admin-monitor {
  margin-bottom: 12px;
}

.monitor-infra-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.monitor-balancers .admin-active-routes {
  margin-bottom: 0;
}

.admin-active-routes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.admin-route-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--server-color, #a78bfa) 55%, transparent);
  background: color-mix(in srgb, var(--server-color, #a78bfa) 12%, transparent);
  font-size: 0.78rem;
  max-width: 100%;
}

.admin-route-chip-label {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.admin-route-chip-value {
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.admin-route-chip-meta {
  color: var(--muted);
  font-size: 0.78rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.server-section-compact {
  margin-bottom: 0;
}

.infra-grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.infra-grid-compact .infra-card {
  padding: 12px 14px;
}

.infra-grid-compact .infra-card-title {
  font-size: 0.88rem;
}

.infra-grid-compact .infra-card-meta {
  font-size: 0.76rem;
}

.admin-stat {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  text-align: center;
}

.admin-stat-value {
  font-family: "Syne", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 2px;
  line-height: 1.1;
}

.admin-stat-label {
  color: var(--muted);
  font-size: 0.72rem;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-tab {
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.admin-tab.active {
  color: var(--text);
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.12);
}

.admin-panel h3 {
  margin: 0 0 16px;
}

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

.admin-panel-head h3 {
  margin: 0 0 4px;
}

.admin-panel-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-search {
  width: 100%;
  max-width: 280px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

.admin-bind-form {
  max-width: 520px;
}

.xui-clients-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 16px;
  min-height: 360px;
}

.xui-inbounds-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.xui-inbound-item {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.xui-inbound-item:hover {
  border-color: rgba(167, 139, 250, 0.25);
}

.xui-inbound-item.active {
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.1);
}

.xui-inbound-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.xui-inbound-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.xui-clients-detail {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.xui-clients-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.server-section {
  margin-bottom: 24px;
}

.server-section:last-child {
  margin-bottom: 0;
}

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

.server-section-head h4 {
  margin: 0;
  font-size: 1rem;
}

.infra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.infra-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.infra-card.alive {
  border-color: rgba(74, 222, 128, 0.25);
}

.infra-card.dead {
  border-color: rgba(251, 113, 133, 0.25);
}

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

.infra-card-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.infra-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.infra-status-dot.alive {
  background: var(--success);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.infra-status-dot.dead {
  background: var(--danger);
}

.infra-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.infra-card-meta span {
  display: block;
}

.client-bound-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent);
}

.client-bound-badge.free {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

@media (max-width: 760px) {
  .xui-clients-layout {
    grid-template-columns: 1fr;
  }

  .admin-panel-head,
  .xui-clients-detail-head {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-search {
    max-width: none;
  }
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.admin-row-main {
  min-width: 0;
}

.admin-row-title {
  font-weight: 600;
}

.admin-row-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.notify-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.push-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.push-flag-active {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.12);
  color: #86efac;
}

.push-flag-off {
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(148, 163, 184, 0.08);
}

.push-flag-other {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(96, 165, 250, 0.1);
  color: #93c5fd;
}

.push-flag-na {
  opacity: 0.55;
}

.admin-user-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

.notify-flag.active {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.12);
}

.notify-flag.inactive {
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(251, 113, 133, 0.08);
  opacity: 0.85;
}

.notify-flag-na {
  color: var(--muted);
  font-size: 0.85rem;
  cursor: default;
}

.admin-row-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-danger {
  background: rgba(251, 113, 133, 0.15);
  border-color: rgba(251, 113, 133, 0.35);
  color: var(--danger);
}

.btn-success {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--success);
}

.merge-details {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.92rem;
}

.merge-details p {
  margin: 0 0 6px;
}

.merge-details p:last-child {
  margin-bottom: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

#approve-inbound-select {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
}

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .dashboard-intro { flex-direction: column; }
  .admin-row { flex-direction: column; align-items: stretch; }
  .admin-row-actions { justify-content: stretch; }
}

/* --- Compact admin + mobile PWA --- */

.card-compact {
  padding: 14px 16px;
  border-radius: 16px;
}

.message-compact {
  margin-top: 8px;
  font-size: 0.82rem;
}

.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-topbar-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-topbar-title {
  min-width: 0;
}

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

.push-controls-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (min-width: 768px) {
  .admin-topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .admin-topbar-main {
    flex: 1;
    min-width: 0;
  }

  .push-controls {
    flex: 0 1 auto;
    max-width: min(100%, 520px);
  }
}

.push-status-text {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.push-status-text.active {
  color: var(--success);
}

.admin-topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-title {
  margin: 0;
  font-family: "Syne", sans-serif;
  font-size: clamp(1.15rem, 4vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.eyebrow-compact {
  margin-bottom: 4px;
  font-size: 0.68rem;
}

.admin-monitor-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-monitor-title {
  margin: 0 0 2px;
  font-size: 0.95rem;
  font-weight: 700;
}

.btn-icon {
  min-width: 38px;
  padding: 8px 10px;
  line-height: 1;
}

.admin-stats-inline {
  margin-bottom: 10px;
}

.admin-analytics {
  margin-bottom: 12px;
}

.admin-analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.admin-analytics-card {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.admin-analytics-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.admin-analytics-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

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

.admin-chart-block {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.admin-chart-title {
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-bar-chart-top-devices {
  gap: 10px;
}

@media (min-width: 760px) {
  .admin-bar-chart-top-devices {
    display: block;
    columns: 2;
    column-gap: 24px;
  }

  .admin-bar-chart-top-devices .admin-bar-row {
    break-inside: avoid;
    margin-bottom: 10px;
  }
}

.admin-bar-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.admin-bar-main {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.admin-bar-rank {
  flex-shrink: 0;
  width: 22px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.35;
}

.admin-bar-info {
  min-width: 0;
}

.admin-bar-title {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.admin-bar-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
  word-break: break-word;
}

.admin-bar-metrics {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.admin-bar-value {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-bar-percent {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-bar-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
  min-width: 0;
}

.admin-bar-label {
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-bar-subtitle {
  color: var(--muted);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.admin-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.85), rgba(167, 139, 250, 0.85));
}

.admin-bar-fill.warn {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.9), rgba(245, 158, 11, 0.9));
}

.admin-bar-fill.danger {
  background: linear-gradient(90deg, rgba(251, 113, 133, 0.95), rgba(239, 68, 68, 0.95));
}

.admin-server-panel {
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.admin-server-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.admin-server-resources {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-resource-row {
  min-width: 0;
}

.admin-server-load {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.admin-server-load-label,
.admin-server-net-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-server-load-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.admin-server-load-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.68rem;
}

.admin-server-net {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-server-net-item {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.admin-server-net-item.up {
  border-color: rgba(52, 211, 153, 0.22);
}

.admin-server-net-item.down {
  border-color: rgba(96, 165, 250, 0.22);
}

.admin-server-net-value {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.monitor-outbounds-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.monitor-outbounds-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.infra-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.infra-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.82rem;
}

.infra-row.alive {
  border-color: rgba(74, 222, 128, 0.22);
  border-left-color: var(--success);
}

.infra-row.dead {
  border-color: rgba(251, 113, 133, 0.22);
  border-left-color: var(--danger);
}

.infra-row-main {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.infra-down-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.28);
  color: #fda4af;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.infra-row-traffic {
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.infra-row-ping.dead {
  color: #fda4af;
  font-size: 0.72rem;
  min-width: 88px;
  text-align: right;
}

.infra-row.alive {
  border-color: rgba(74, 222, 128, 0.22);
}

.infra-row.dead {
  border-color: rgba(251, 113, 133, 0.22);
}

.infra-row-name {
  font-weight: 600;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.infra-row-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.infra-row-down {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.28);
  color: #fda4af;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.infra-row-meta {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.infra-row-ping {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

.infra-row-ping.dual {
  min-width: 118px;
  font-size: 0.78rem;
  line-height: 1.2;
  white-space: nowrap;
}

.balancer-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.balancer-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.balancer-switch-ui {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.balancer-switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}

.balancer-toggle-input:checked + .balancer-switch-ui {
  background: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.35);
}

.balancer-toggle-input:checked + .balancer-switch-ui::after {
  transform: translateX(14px);
  background: var(--success);
}

.balancer-toggle-input:disabled + .balancer-switch-ui {
  opacity: 0.55;
}

.balancer-switch-label {
  color: var(--muted);
  font-size: 0.68rem;
  min-width: 42px;
}

.admin-tabs-sticky {
  position: sticky;
  top: 0;
  z-index: 8;
  margin-bottom: 12px;
  padding: 6px 0 8px;
  background: linear-gradient(180deg, rgba(8, 9, 15, 0.98) 70%, rgba(8, 9, 15, 0));
  backdrop-filter: blur(10px);
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.admin-tabs-sticky::-webkit-scrollbar {
  display: none;
}

.admin-tabs-sticky .admin-tab {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 8px 12px;
  font-size: 0.82rem;
}

#admin-section .admin-panel {
  padding: 16px;
  border-radius: 16px;
}

#admin-section .admin-panel h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

#admin-section .admin-panel-head {
  margin-bottom: 12px;
}

#admin-section .admin-row {
  padding: 12px;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .container {
    width: min(1020px, calc(100% - 16px));
    padding: 0 0 calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .header {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    margin-bottom: 16px;
    gap: 10px;
  }

  .header .btn {
    padding: 8px 12px;
    font-size: 0.82rem;
    flex-shrink: 0;
  }

  .brand {
    min-width: 0;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .brand-tag {
    display: none;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    padding: 8px;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .admin-badge {
    padding: 6px 10px;
    font-size: 0.72rem;
    flex-shrink: 0;
  }

  .admin-topbar-main {
    align-items: center;
  }

  .push-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.22);
  }

  .push-status-text {
    white-space: normal;
    font-size: 0.78rem;
  }

  .push-controls-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .push-controls-buttons .btn {
    width: 100%;
    justify-content: center;
    min-height: 40px;
  }

  #push-broadcast-btn {
    grid-column: 1 / -1;
  }

  .admin-monitor-toolbar {
    align-items: center;
  }

  .admin-monitor-toolbar .btn-icon {
    flex-shrink: 0;
  }

  .server-status-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .server-status-actions {
    width: 100%;
    justify-content: space-between;
  }

  .admin-stats {
    gap: 6px;
  }

  .admin-stat {
    padding: 8px 6px;
  }

  .admin-stat-value {
    font-size: 1.05rem;
  }

  .admin-stat-label {
    font-size: 0.68rem;
  }

  .admin-analytics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-charts-grid {
    grid-template-columns: 1fr;
  }

  .infra-row {
    grid-template-columns: 8px minmax(0, 1fr) auto auto;
    gap: 6px;
  }

  .balancer-switch-label {
    display: none;
  }

  .admin-route-chip-value {
    max-width: 96px;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .device-item {
    flex-direction: column;
    align-items: stretch;
  }

  .device-actions {
    justify-content: flex-end;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .impersonation-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
}

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

.user-analytics-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.push-user-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.push-user-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.push-user-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.push-user-card .push-controls-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .push-user-card .push-controls-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .push-user-card .push-controls-buttons .btn {
    width: 100%;
    justify-content: center;
  }
}

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

.metrics-history-grid .admin-chart-block-wide {
  grid-column: 1 / -1;
}

.admin-chart-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.admin-chart-subtitle {
  font-size: 0.72rem;
  color: var(--muted);
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: 160px;
  display: block;
}

.chart-grid-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.chart-axis-label {
  fill: rgba(255, 255, 255, 0.45);
  font-size: 10px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
}

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

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.traffic-chart-block {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.08), transparent 70%),
    rgba(255, 255, 255, 0.02);
}

.traffic-share-wrap {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.traffic-share-bar {
  display: flex;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.traffic-share-segment {
  display: block;
  min-width: 2px;
  height: 100%;
}

.traffic-share-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 0.72rem;
  color: var(--muted);
}

.traffic-share-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.traffic-share-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.traffic-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.traffic-stat-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.74rem;
}

.traffic-stat-chip-muted {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.68rem;
}

.traffic-stat-label {
  color: var(--muted);
}

.traffic-stat-value {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.traffic-hour-bar-segment {
  transition: fill-opacity 0.15s ease;
}

.traffic-hour-bar-segment:hover {
  fill-opacity: 1;
}

.traffic-spike-marker {
  fill: #f59e0b;
  opacity: 0.9;
}

.traffic-avg-line {
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}

.traffic-avg-label {
  fill: rgba(255, 255, 255, 0.45);
  font-size: 10px;
}

.chart-wrap-traffic {
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  padding: 8px 10px 10px;
}

.traffic-chart-shell {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.chart-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 240px;
  padding: 12px 0;
}

.chart-plot-area {
  min-width: 0;
}

.chart-x-axis {
  position: relative;
  height: 28px;
  margin-top: 6px;
  margin-left: 66px;
}

.chart-x-axis-spread {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  position: static;
  height: auto;
  min-height: 24px;
  margin-left: 0;
  margin-top: 8px;
}

.chart-wrap-line .chart-x-axis-spread {
  padding: 0 4px;
}

.chart-axis-tick-spread {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.chart-axis-tick-spread:first-child {
  text-align: left;
}

.chart-axis-tick-spread:last-child {
  text-align: right;
}

.chart-svg-line {
  height: 160px;
}

.availability-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.availability-card {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.availability-card-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.availability-card-body {
  min-width: 0;
}

.availability-card-name {
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.availability-card-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
}

.availability-card-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.availability-card-ok {
  border-color: rgba(34, 197, 94, 0.18);
}

.chart-axis-tick {
  color: rgba(255, 255, 255, 0.58);
  font-size: 11px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-axis-tick-y {
  text-align: right;
  padding-right: 2px;
}

.chart-axis-tick-x {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
}

.chart-svg-traffic {
  width: 100%;
  height: 240px;
  display: block;
  shape-rendering: geometricPrecision;
}

.chart-grid-line-vertical {
  stroke: rgba(255, 255, 255, 0.05);
}

.chart-area-fill {
  transition: opacity 0.2s ease;
}

.chart-area-line {
  opacity: 0.95;
}

.chart-legend-traffic {
  gap: 8px;
}

.chart-legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.72rem;
  color: var(--muted);
}

.chart-legend-chip .chart-legend-dot {
  background: var(--chip-color);
  box-shadow: 0 0 10px color-mix(in srgb, var(--chip-color) 45%, transparent);
}

.chart-legend-name {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend-total {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.metrics-placeholder {
  padding: 12px 0 4px;
}

.balancer-timeline {
  display: flex;
  width: 100%;
  min-height: 28px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.balancer-segment {
  min-width: 2px;
  flex: 1 1 auto;
}

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

@media (max-width: 640px) {
  .metrics-history-grid {
    gap: 10px;
  }

  .admin-chart-block {
    padding: 12px;
  }

  .traffic-chart-shell {
    grid-template-columns: 1fr;
  }

  .chart-y-axis {
    display: none;
  }

  .chart-wrap-traffic .chart-x-axis-spread {
    margin-left: 0;
  }

  .chart-svg-traffic {
    height: 170px;
  }

  .traffic-stats-row {
    gap: 6px;
  }

  .traffic-stat-chip {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .traffic-share-labels {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .chart-legend-traffic {
    display: none;
  }

  .traffic-stat-chip-muted {
    flex: 1 1 100%;
  }

  .chart-legend-chip {
    max-width: 100%;
  }

  .chart-legend-name {
    max-width: none;
    white-space: normal;
  }

  .chart-axis-tick {
    font-size: 10px;
  }

  .chart-axis-tick-spread {
    white-space: normal;
    line-height: 1.25;
  }

  .admin-bar-main {
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 6px;
  }

  .admin-bar-title {
    font-size: 0.82rem;
  }

  .admin-bar-metrics {
    min-width: 72px;
  }
}

.pull-refresh-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(280px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(12, 14, 24, 0.92);
  color: var(--muted);
  font-size: 0.78rem;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.2s ease;
  pointer-events: none;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.pull-refresh-indicator.hidden {
  opacity: 0;
}

.pull-refresh-indicator.refreshing {
  opacity: 1;
  transform: translate(-50%, calc(env(safe-area-inset-top, 8px) + 8px));
}

.pull-refresh-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
}

.pull-refresh-indicator.refreshing .pull-refresh-spinner {
  animation: pull-refresh-spin 0.8s linear infinite;
}

@keyframes pull-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (display-mode: standalone) {
  body {
    overscroll-behavior-y: contain;
  }
}
