/* CMonitor UI layer: shared tokens, header and page chrome, calmer surfaces.
   Loaded last on every page so it can settle older component styles. */

:root {
  --bg-primary: #0b0e13;
  --bg-secondary: #11151b;
  --surface: #12161c;
  --surface-2: #171c23;
  --surface-3: #1d232b;
  --bg-card: var(--surface);
  --card-bg: var(--surface);
  --border-color: #232a33;
  --border-color-hover: #313a46;
  --text-primary: #e6e9ed;
  --text-secondary: #a0a8b3;
  --text-muted: #727c88;

  --blue: #4a8af4;
  --blue-dim: rgba(74, 138, 244, .14);
  --green: #33b27a;
  --green-dim: rgba(51, 178, 122, .14);
  --red: #e5534b;
  --red-dim: rgba(229, 83, 75, .14);
  --yellow: #d6a23a;
  --yellow-dim: rgba(214, 162, 58, .14);

  --radius: 10px;
  --radius-sm: 7px;
  --transition: .15s ease;
  --header-h: 56px;
  --font-mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

html, body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; }
body { background: var(--bg-primary); background-image: none; font-feature-settings: 'tnum' 1; -webkit-font-smoothing: antialiased; }
::selection { background: rgba(74, 138, 244, .35); }

.i { flex: none; display: block; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 32px; padding: 6px 12px; gap: 6px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--surface-2); color: var(--text-primary);
  font-size: 13px; font-weight: 500; line-height: 1.2;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-color-hover); }
.btn-sm { min-height: 30px; padding: 5px 11px; font-size: 12.5px; }
.btn .i { width: 15px; height: 15px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #3d7de6; border-color: #3d7de6; }
.btn-success { background: var(--green); border-color: var(--green); }
.btn-danger { background: transparent; border-color: rgba(229, 83, 75, .45); color: #f0857e; }
.btn-danger:hover { background: var(--red-dim); border-color: var(--red); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 100;
  padding: 0 24px; background: rgba(11, 14, 19, .9);
  backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border-color);
}
.header-inner { display: flex; align-items: center; gap: 12px; max-width: 1400px; min-height: var(--header-h); margin: 0 auto; flex-wrap: nowrap; }
.logo { gap: 9px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.logo-icon { width: 28px; height: 28px; border-radius: 7px; }

.header-chips { display: flex; gap: 6px; flex-wrap: nowrap; padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--border-color); }
.header-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 0; border: 0; background: none; border-radius: 0;
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
}
.header-chip + .header-chip:not(.hidden)::before { content: ''; width: 3px; height: 3px; margin-right: 4px; border-radius: 50%; background: var(--text-muted); }
.header-chip.chip-green, .header-chip.chip-red, .header-chip.chip-yellow { background: none; border: 0; }
.header-chip.chip-green { color: var(--text-secondary); }
.header-chip.chip-green::after { content: none; }
#chip-active { gap: 7px; }
#chip-active::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.header-chip.chip-red { color: #f0857e; }

.header-search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 160px; max-width: 340px; min-height: 34px;
  margin-left: auto; padding: 0 3px 0 10px;
  border: 1px solid var(--border-color); border-radius: 8px; background: var(--surface); color: var(--text-muted);
}
.header-search:focus-within { border-color: #4a6fa5; box-shadow: 0 0 0 3px rgba(74, 138, 244, .12); }
.header-search input { font-size: 13px; padding: 6px 0; color: var(--text-primary); }
.header-search input::placeholder { color: var(--text-muted); }
.header-search input::-webkit-search-cancel-button { display: none; }
.header-search button { width: 28px; height: 28px; border-radius: 6px; background: transparent; color: var(--text-muted); }
.header-search button:hover { background: var(--surface-3); color: var(--text-primary); }

.header-tools { display: flex; align-items: center; gap: 2px; }
.hdr-tool {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 10px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.hdr-tool:hover { background: var(--surface-2); color: var(--text-primary); }
.hdr-tool .i { color: var(--text-muted); }
.hdr-tool:hover .i { color: var(--text-secondary); }

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: 4px; flex-wrap: nowrap; position: relative; min-width: 0; }
.menu-wrap { position: relative; }
.btn-add { min-height: 34px; padding: 0 12px 0 10px; }

.admin-user-scope { display: flex; align-items: center; gap: 0; min-width: 0; height: 34px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--surface); overflow: hidden; }
.admin-user-scope.hidden { display: none; }
.admin-user-label { padding: 0 8px 0 10px; color: var(--text-muted); font-size: 11.5px; border-right: 1px solid var(--border-color); line-height: 34px; white-space: nowrap; }
.admin-user-search { width: 130px; height: 100%; padding: 0 10px; border: 0; border-radius: 0; background: transparent; color: var(--text-primary); font-size: 13px; }
.admin-user-search:focus { background: transparent; outline: none; }
.admin-user-scope:focus-within { border-color: #4a6fa5; }

.hdr-account {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 8px 0 4px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-secondary);
  font: inherit; font-size: 13px; cursor: pointer;
}
.hdr-account:hover, .hdr-account[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border-color); color: var(--text-primary); }
.hdr-account .i { width: 14px; height: 14px; color: var(--text-muted); }
.hdr-avatar { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #23324a; color: #c9dbfb; font-size: 12px; font-weight: 600; }
.hdr-avatar:empty::before { content: '·'; }
.header-user { padding: 0; font-size: 13px; color: inherit; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.add-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 120; min-width: 190px; padding: 5px;
  background: var(--surface-2); border: 1px solid var(--border-color-hover); border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.add-menu button, .add-menu a {
  display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--text-primary); font: inherit; font-size: 13px; text-align: left; text-decoration: none; cursor: pointer;
}
.add-menu button:hover, .add-menu a:hover { background: var(--surface-3); }
.add-menu hr { margin: 5px 4px; border: 0; border-top: 1px solid var(--border-color); }
.add-menu .logout-btn { color: #f0857e; }
.add-menu .logout-btn:hover { background: var(--red-dim); color: #f6a39d; }

/* ---------- Page head (title + section actions) ---------- */
.main { padding: 24px 24px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .tab-nav-bar { position: static; top: auto; z-index: auto; background: none; border: 0; }
.page-head .tab-nav-inner { display: block; max-width: none; margin: 0; padding: 0; font-size: inherit; font-weight: inherit; }
.page-head .tab-nav-btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 0; margin: 0;
  border: 0; background: none; cursor: default;
  color: var(--text-primary); font-size: 20px; font-weight: 650; letter-spacing: -.015em;
}
.page-head .tab-nav-btn.active { border: 0; color: var(--text-primary); }
.page-head .tab-nav-btn .tab-nav-count { font-size: 12px; font-weight: 500; padding: 1px 8px; background: var(--surface-3); color: var(--text-secondary); letter-spacing: 0; }
.v2ray-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }

.v2ray-view-tabs { gap: 4px; margin: 0 0 18px; border-bottom: 1px solid var(--border-color); }
.v2ray-view-tab { padding: 9px 4px; margin-right: 14px; margin-bottom: -1px; font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; }
.v2ray-view-tab:hover { color: var(--text-primary); border-bottom-color: transparent; }
.v2ray-view-tab.active { color: var(--text-primary); border-bottom-color: var(--text-primary); }
.tab-nav-count { background: var(--surface-3); color: var(--text-secondary); font-weight: 500; }
.v2ray-view-tab.active .tab-nav-count { background: var(--surface-3); color: var(--text-primary); }
.v2ray-view-heading { margin: 0 0 12px; }
.v2ray-view-heading strong { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.v2ray-view-heading span { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Group bar + toolbar ---------- */
.vless-group-bar { gap: 6px; margin: 0 0 12px; }
.vless-group-bar > button, .vless-group-bar .vless-group-chip, .vless-group-bar [class*="group-chip"] { border-radius: 7px; }
.vless-toolbar { gap: 8px; margin: 0 0 18px; }
.vless-toolbar-main { gap: 8px; }
.vless-toolbar input[type=search], .vless-toolbar select {
  min-height: 34px; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--surface); font-size: 13px;
}
.vless-toolbar input[type=search]:focus, .vless-toolbar select:focus { border-color: #4a6fa5; outline: none; box-shadow: 0 0 0 3px rgba(74, 138, 244, .12); }
.vless-filter-chips, .vless-view-toggle { gap: 2px; padding: 2px; border-radius: 8px; border-color: var(--border-color); background: var(--surface); }
.vless-filter-chips button, .vless-view-toggle button { min-height: 28px; padding: 3px 10px; border-radius: 6px; font-size: 12.5px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.vless-filter-chips button:hover, .vless-view-toggle button:hover { color: var(--text-primary); background: var(--surface-2); }
.vless-filter-chips button.active, .vless-view-toggle button.active { background: var(--surface-3); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--border-color-hover); }
.vless-filter-chips button b { margin-left: 0; padding: 0 6px; background: rgba(255, 255, 255, .06); color: var(--text-muted); font-weight: 500; }
.vless-filter-chips button.active b { color: var(--text-secondary); }
.vless-view-toggle .i { width: 14px; height: 14px; }

/* ---------- Config cards ---------- */
.vless-card, .tester-health-card {
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: none;
}
.vless-card:hover { border-color: var(--border-color-hover); box-shadow: none; }
.vless-header { background: none; border-bottom: 1px solid var(--border-color); padding: 12px 16px; }
.vless-title-block .vless-name, .vless-name { font-size: 14px; font-weight: 600; letter-spacing: -.005em; }

.vless-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; text-transform: capitalize; letter-spacing: 0; border: 1px solid transparent;
}
.vless-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.vless-status-ok { background: var(--green-dim); color: #4cc690; }
.vless-status-down { background: var(--red-dim); color: #f0857e; }
.vless-status-unstable { background: var(--yellow-dim); color: #e3b553; }
.vless-status-unknown { background: rgba(255, 255, 255, .05); color: var(--text-muted); }
.vless-status-disabled { background: rgba(255, 255, 255, .05); color: var(--text-muted); border-color: transparent; }
.vless-card.vless-card-disabled { opacity: .7; border-color: var(--border-color); }

.vless-metrics { gap: 22px; }
.vless-metric { align-items: flex-start; min-width: 52px; }
.vm-val { font-family: inherit; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.vm-val.vm-avg { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.vm-lbl { font-size: 11px; text-transform: none; letter-spacing: 0; color: var(--text-muted); margin-top: 1px; }

.vless-actions { gap: 4px; }
.vless-actions .btn-icon {
  width: 32px; height: 32px; min-height: 32px; padding: 0; display: grid; place-items: center;
  border: 1px solid transparent; background: transparent; color: var(--text-muted); box-shadow: none;
}
.vless-actions .btn-icon:hover { background: var(--surface-3); border-color: var(--border-color); color: var(--text-primary); box-shadow: none; }
.vless-actions .btn-icon.btn-danger:hover { background: var(--red-dim); border-color: transparent; color: #f0857e; }
.vless-actions .btn-icon svg { width: 16px; height: 16px; }

.vless-endpoint, .vless-route-ip, .vless-route-exit, code { font-family: var(--font-mono); }
.vless-node-strip { border-bottom: 1px solid var(--border-color); background: none; }
.vless-route-verdicts { background: var(--surface-2); border-color: var(--border-color); }
.vless-history-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.vless-range-btn { border-radius: 6px; }
.vless-group-heading-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.vless-group-heading-count { color: var(--text-muted); }

/* Metric label sits above its value; the average stays below */
.vless-metric .vm-lbl { order: -1; margin: 0 0 2px; }
.tester-history-heading > span:first-child, .tester-history-heading { text-transform: none; letter-spacing: 0; }
.tester-history-heading > span:first-child { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.vless-uptime-range { justify-self: start; }
.qc-tab-btn { border-radius: 8px; }

/* ---------- Modals & toasts ---------- */
.modal-overlay { background: rgba(5, 7, 10, .72); backdrop-filter: blur(3px); }
.modal { background: var(--bg-secondary); border: 1px solid var(--border-color-hover); border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.modal-header { border-bottom: 1px solid var(--border-color); }
.modal-footer { border-top: 1px solid var(--border-color); }
.form-input { background: var(--surface); border-color: var(--border-color); border-radius: 8px; }
.form-input:focus { border-color: #4a6fa5; box-shadow: 0 0 0 3px rgba(74, 138, 244, .12); }

/* ---------- Admin pages ---------- */
.admin-header { background: rgba(11, 14, 19, .92); border-bottom: 1px solid var(--border-color); }
.admin-card { background: var(--surface); border-color: var(--border-color); border-radius: var(--radius); }

/* ---------- Medium widths: icon-only tools ---------- */
@media (max-width: 1240px) {
  .hdr-tool { padding: 0 9px; }
  .hdr-tool span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .hdr-tool .i { width: 18px; height: 18px; color: var(--text-secondary); }
  .header-user { display: none; }
}
@media (max-width: 1000px) {
  #chip-latency, #chip-config-limit { display: none; }
}

/* ---------- Phones / small tablets ---------- */
@media (max-width: 760px) {
  :root { --header-h: 52px; }
  /* No backdrop-filter here: it would make the header the containing block of the fixed tab bar */
  .header { position: static; padding: 0 12px; background: var(--bg-primary); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .header-inner { flex-wrap: wrap; gap: 8px 10px; padding: 8px 0 10px; min-height: 0; }
  .logo-text { font-size: 15px; }
  .header-chips { order: 2; padding-left: 10px; margin-right: auto; }
  .header-actions { display: contents; }
  .header-actions > .menu-wrap { order: 3; }
  .header-actions > .menu-wrap:first-of-type { margin-left: auto; }
  .header-search { order: 5; flex: 1 1 100%; max-width: none; min-height: 40px; margin: 0; }
  .header-search input { font-size: 16px; }
  .admin-user-scope { order: 6; flex: 1 1 100%; height: 40px; }
  .admin-user-label { line-height: 40px; }
  .admin-user-search { flex: 1; width: auto; font-size: 16px; }
  .btn-add { width: 36px; min-height: 36px; padding: 0; justify-content: center; }
  .btn-add span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .hdr-account { height: 36px; padding: 0 4px; }

  /* Tools move to a bottom tab bar */
  .header-tools {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 110;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    background: rgba(13, 16, 21, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
  }
  .hdr-tool { flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 2px; border-radius: 8px; font-size: 11px; color: var(--text-secondary); }
  .hdr-tool span { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .hdr-tool .i { width: 20px; height: 20px; color: var(--text-secondary); }
  .hdr-tool:active { background: var(--surface-2); }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .toast-container { bottom: calc(76px + env(safe-area-inset-bottom)); right: 12px; left: 12px; }

  .main { padding: 16px 12px 28px; }
  .page-head { margin-bottom: 10px; }
  .page-head .tab-nav-btn { font-size: 18px; }
  .v2ray-toolbar { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .v2ray-toolbar .btn { min-height: 38px; justify-content: center; flex: none; }
  .v2ray-view-tabs { display: flex; margin-bottom: 14px; }
  .v2ray-view-tab { flex: 0 0 auto; min-height: 40px; padding: 8px 2px; margin-right: 18px; }

  /* Group bar and status filters scroll sideways instead of wrapping */
  .vless-group-bar, .vless-filter-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .vless-group-bar::-webkit-scrollbar, .vless-filter-chips::-webkit-scrollbar { display: none; }
  .vless-group-bar > * { flex: none; }
  .vless-toolbar-main { flex-wrap: nowrap; width: 100%; }
  .vless-toolbar-main input[type=search] { flex: 1 1 auto; min-height: 40px; font-size: 16px; }
  .vless-view-toggle { flex: none; flex-wrap: nowrap; }
  .vless-view-toggle button { min-height: 34px; padding: 3px 9px; }
  .vless-toolbar-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; width: 100%; align-items: center; }
  .vless-toolbar-filters .vless-uptime-range { grid-column: 1 / -1; }
  .vless-filter-chips { display: flex; max-width: 100%; }
  .vless-filter-chips button { flex: none; min-height: 34px; }
  .vless-toolbar select { min-height: 38px; font-size: 14px; max-width: 150px; }

  .vless-header { padding: 12px; }
  .vless-metrics { border-top: 1px solid var(--border-color); }
  .vless-metrics .vless-metric { align-items: center; }
  .vless-actions { gap: 6px; }
  .vless-actions .btn-icon { width: 100%; border-color: var(--border-color); background: var(--surface-2); color: var(--text-secondary); height: 40px; min-height: 40px; }
  .v2ray-view-heading { display: none; }
  .vless-route-verdicts { align-self: flex-start; justify-content: flex-start; }
  .vless-node-assign-pair select, .vless-node-assign select { min-height: 40px; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-width: none !important; max-height: calc(100dvh - 24px); border-radius: 14px 14px 0 0; border-bottom: 0; }
  .modal-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
@media (max-width: 400px) {
  .logo-text { display: none; }
}

/* ---------- Admin pages ---------- */
.admin-shell { background: var(--bg-primary); }
.admin-header { padding: 0 24px; box-shadow: none; }
.admin-header-top { min-height: 56px; gap: 16px; }
.admin-back { font-weight: 500; font-size: 13px; }
.admin-back-icon { width: 28px; height: 28px; border-radius: 7px; }
.admin-brand { padding-left: 16px; }
.admin-brand strong { font-size: 14px; font-weight: 600; }
.admin-brand small { display: none; }
.admin-nav { gap: 20px; max-width: none; }
.admin-nav-link {
  flex: none; min-width: 0; gap: 0; padding: 0 2px 10px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; box-shadow: none;
  color: var(--text-muted); font-size: 13px;
}
.admin-nav-link:hover { background: none; transform: none; color: var(--text-primary); }
.admin-nav-link.active { background: none; box-shadow: none; border-color: transparent; border-bottom-color: var(--text-primary); color: var(--text-primary); }
.admin-nav-link strong { font-size: 13px; font-weight: 500; }
.admin-nav-icon, .admin-nav-arrow { display: none; }
.admin-nav-link small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.admin-main { margin-top: 28px; }
.admin-intro h1 { font-size: 20px; font-weight: 650; }
.admin-intro p { font-size: 13px; }
.admin-table th { font-size: 11px; letter-spacing: .03em; font-weight: 500; }
.admin-table td { font-size: 12.5px; border-bottom-color: var(--border-color); }
.admin-slot-card { background: var(--surface-2); box-shadow: none; }
.admin-form-note { background: var(--surface); border-color: var(--border-color); color: var(--text-secondary); }

@media (max-width: 700px) {
  .admin-header { padding: 0 12px; }
  .admin-header-top { flex-wrap: wrap; gap: 10px; min-height: 0; padding: 10px 0; }
  .admin-brand { padding-left: 10px; }
  .admin-back > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .admin-header-top { flex-wrap: nowrap; }
  .admin-header-actions { margin-left: auto; width: auto; flex-wrap: nowrap; }
  .admin-nav { display: flex; gap: 20px; grid-template-columns: none; }
  .admin-nav-link { width: auto; }
  .admin-main { margin-top: 18px; width: calc(100% - 24px); }
  /* Rows become compact cards: label and value side by side */
  .admin-table tr { padding: 4px 0; border-radius: var(--radius); }
  .admin-table td { position: relative; display: block; padding: 7px 14px 7px 124px; border: 0; min-height: 34px; }
  .admin-table td[data-label]::before { position: absolute; left: 14px; top: 9px; width: 100px; margin: 0; font-size: 11.5px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-muted); }
  .admin-table td:not([data-label]), .admin-table td[data-label=""] { padding-left: 14px; }
  .admin-table td:last-child { padding: 10px 14px 6px; margin-top: 4px; border-top: 1px solid var(--border-color); }
  .admin-table td:last-child::before { display: none; }
}
@media (min-width: 701px) {
  .admin-table .btn, .admin-table .btn-sm { min-height: 28px; padding: 4px 9px; font-size: 12px; }
}

/* Unified, live search across the account. */
.header-search { position: relative; flex: 1 1 260px; max-width: 400px; }
.server-search-results { position: absolute; left: 0; top: calc(100% + 8px); width: min(520px, calc(100vw - 24px)); max-height: min(440px, 60dvh); overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border-color-hover); border-radius: 10px; box-shadow: 0 12px 30px #0006; padding: 6px; z-index: 140; }
.server-search-results[hidden] { display: none; }
.search-summary { padding: 8px 10px; font-size: 12px; color: var(--text-muted); }
.header-search .server-search-results button { display: block; width: 100%; height: auto; text-align: left; padding: 10px; color: var(--text-primary); }
.server-search-results button strong, .server-search-results button small { display: block; overflow-wrap: anywhere; }
.server-search-results button small { margin-top: 4px; color: var(--text-muted); line-height: 1.5; }
.server-search-results button[aria-selected="true"] { background: var(--surface-3); outline: 1px solid var(--accent); }
.users-page .admin-main { width: min(1320px, calc(100% - 48px)); }
.users-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
.users-overview > div { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border-color); border-radius: 10px; padding: 18px 20px; background: var(--surface); }
.users-overview span { color: var(--text-muted); font-size: 13px; }
.users-overview strong { font-size: 26px; font-weight: 600; }
.users-toolbar { display: flex; gap: 12px; align-items: end; margin-bottom: 24px; }
.users-toolbar > div { min-width: 0; }
.users-toolbar .users-search { flex: 1; }
.users-toolbar label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 7px; }
.users-toolbar .form-input { min-height: 40px; }
.users-page .admin-table td { padding: 18px 16px; }
.users-page .admin-table th { padding: 12px 16px; }
.user-identity { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.user-identity > div { min-width: 0; overflow-wrap: anywhere; }
.user-avatar { flex: none; display: grid; place-items: center; width: 38px; height: 38px; background: var(--surface-3); border: 1px solid var(--border-color); border-radius: 10px; color: var(--text-secondary); font-size: 12px; }
.user-identity strong { font-size: 14px; margin-right: 8px; }
.user-identity .admin-muted, .user-note { margin-top: 6px; }
.user-note { color: var(--text-secondary); font-size: 12px; max-width: 280px; overflow-wrap: anywhere; }
.user-attention, .user-form-error { color: #e3b553; font-size: 12px; margin-top: 6px; }
.users-page .status-dot { box-shadow: none; }
.users-page .admin-actions { flex-wrap: nowrap; }
.users-page .admin-table .btn { min-height: 34px; padding: 6px 12px; }
.users-empty { padding: 36px 16px; text-align: center; }
.users-empty p { color: var(--text-muted); margin: 10px 0; }
.users-page #user-delete-btn { margin-right: auto; }
.users-page .admin-slot-form { margin-bottom: 20px; }
.users-page .admin-slot-summary { background: var(--surface); border-color: var(--border-color); padding: 16px; }
.users-page .admin-slot-stat { flex: 1; }
.users-page .admin-slot-stat strong { font-size: 22px; }
@media (max-width: 760px) {
  .header-search { max-width: none; }
  .users-page { padding-bottom: 0; }
  .users-page .admin-main { width: calc(100% - 24px); }
  .users-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 18px 0; }
  .users-overview > div { padding: 12px 10px; gap: 8px; }
  .users-overview span { font-size: 11px; }
  .users-overview strong { font-size: 22px; }
  .users-toolbar { flex-wrap: wrap; gap: 10px; }
  .users-toolbar .users-search { flex: 1 1 100%; }
  .users-toolbar > div { flex: 1; }
  .users-toolbar .form-input { font-size: 16px; }
}
@media (max-width: 700px) {
  .users-page .admin-card { border: 0; background: none; overflow: visible; }
  .users-page .admin-table td { padding: 10px 14px 10px 124px; }
  .users-page .admin-table td:first-child { padding: 14px; border-bottom: 1px solid var(--border-color); }
  .users-page .admin-table td:first-child::before { display: none; }
  .users-page .admin-table td:last-child { padding: 12px 14px; }
  .users-page .admin-actions .btn { flex: 1; justify-content: center; min-height: 40px; }
}
.users-page #modal-user .modal { max-width: 720px; }
.users-page #user-form { padding: 20px 20px 0; }
.users-page #user-form > .modal-footer { margin: 20px -20px 0; }
.users-page .admin-slot-modal > div:not(.modal-header) { margin-left: 20px; margin-right: 20px; }
.users-page .admin-slot-modal > .admin-slot-form { margin-left: 20px; margin-right: 20px; }
.users-page .admin-slot-modal { padding-bottom: 20px; }
@media (max-width: 700px) {
  .users-page .admin-slot-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Trial and premium ---------- */
.hdr-tool, .v2ray-toolbar .btn, .add-menu button, .settings-tab { position: relative; }
.is-locked { color: var(--text-muted) !important; }
.is-locked > .i:first-child { opacity: .6; }
.lock-mark { display: inline-flex; align-items: center; margin-left: 2px; color: var(--yellow); }
.lock-mark .i { width: 12px; height: 12px; }
.add-menu button.is-locked { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
@media (max-width: 760px) {
  .hdr-tool .lock-mark { position: absolute; top: 5px; left: calc(50% + 5px); margin: 0; padding: 2px; border-radius: 50%; background: var(--bg-secondary); }
}

.trial-banner {
  display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 10px 12px 10px 14px;
  background: var(--yellow-dim); border: 1px solid rgba(214, 162, 58, .3); border-radius: var(--radius);
}
.trial-banner.is-ended { background: var(--red-dim); border-color: rgba(229, 83, 75, .35); }
.trial-banner-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: rgba(214, 162, 58, .18); color: var(--yellow); flex: none; }
.is-ended .trial-banner-icon { background: rgba(229, 83, 75, .2); color: #f0857e; }
.trial-banner-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; font-size: 13px; line-height: 1.4; }
.trial-banner-text strong { font-weight: 600; color: var(--text-primary); }
.trial-banner-text span { color: var(--text-secondary); }
.trial-banner-btn { flex: none; }
@media (max-width: 560px) {
  .trial-banner { flex-wrap: wrap; padding: 12px; gap: 10px; }
  .trial-banner-text { flex-basis: calc(100% - 44px); }
  .trial-banner-btn { width: 100%; min-height: 40px; justify-content: center; }
}

.premium-modal { max-width: 560px; width: 100%; }
.premium-lead { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.premium-lock { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--yellow-dim); color: var(--yellow); flex: none; }
.premium-lock .i { width: 20px; height: 20px; }
.premium-lead h3 { margin: 0 0 4px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; color: var(--text-primary); }
.premium-lead p { margin: 0; color: var(--text-secondary); font-size: 13.5px; line-height: 1.55; }
.premium-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.premium-compare section { padding: 14px; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--surface); }
.premium-compare section.is-premium { border-color: rgba(74, 138, 244, .5); background: var(--blue-dim); }
.premium-compare h4 { margin: 0 0 10px; font-size: 13px; font-weight: 650; color: var(--text-primary); }
.premium-compare ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.premium-compare li { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.4; color: var(--text-primary); }
.premium-compare li .i { width: 15px; height: 15px; margin-top: 1px; color: var(--green); }
.premium-compare li.off { color: var(--text-muted); }
.premium-compare li.off .i { color: var(--text-muted); }
.premium-note { margin: 14px 0 0; font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 560px) {
  .premium-compare { grid-template-columns: 1fr; }
  .premium-modal .modal-footer .btn { width: 100%; min-height: 44px; justify-content: center; }
}

/* Plan badges in admin */
.plan-badge { display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.6; }
.plan-trial { background: var(--yellow-dim); color: #e2b65a; }
.plan-premium { background: var(--blue-dim); color: #8db6f8; }
.empty-state .empty-icon { display: grid; place-items: center; font-size: 0; color: var(--text-muted); margin-bottom: 12px; }

/* Enable/disable switch on config cards */
.vless-switch{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;background:none;border:0;padding:0;cursor:pointer}
.vless-switch-track{width:36px;height:20px;border-radius:10px;background:var(--border,#3a3f4b);position:relative;transition:background .2s}
.vless-switch-knob{position:absolute;top:3px;left:3px;width:14px;height:14px;border-radius:50%;background:#fff;transition:transform .2s}
.vless-switch.is-on .vless-switch-track{background:#22c55e}
.vless-switch.is-on .vless-switch-knob{transform:translateX(16px)}
.vless-switch:disabled{opacity:.5;cursor:wait}
.vless-switch:focus-visible .vless-switch-track{outline:2px solid #60a5fa;outline-offset:2px}
@media (prefers-reduced-motion:reduce){.vless-switch-track,.vless-switch-knob{transition:none}}
