:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-elevated: #11141b;
  --bg-sidebar: #0f1218;
  --surface: #161a22;
  --surface-2: #1d222c;
  --surface-3: #242a35;
  --field: #20242e;
  --border: #2b323f;
  --border-strong: #3a4351;
  --text: #e8ebf2;
  --text-soft: #a8b0bf;
  --text-muted: #737d90;
  --primary: #00a884;
  --primary-hover: #12c29b;
  --primary-soft: rgba(0, 168, 132, 0.15);
  --blue: #1677ff;
  --blue-soft: rgba(22, 119, 255, 0.14);
  --warning: #f5b041;
  --warning-soft: rgba(245, 176, 65, 0.14);
  --danger: #ff4d4f;
  --danger-soft: rgba(255, 77, 79, 0.14);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-width: 252px;
  font-family: Inter, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(0, 168, 132, 0.08), transparent 30rem),
    linear-gradient(180deg, #0b0d12 0%, #0e1118 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  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: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent 72%);
}

.snake {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 0.2;
  filter: saturate(0.8);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

button:hover {
  border-color: var(--primary);
  background: #222936;
}

button:active {
  background: #1d2330;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 0.45rem;
}

label span,
.status-text,
.hint,
.panel-head p,
.xui-topbar p,
.admin-header p,
.template-pill small,
.inbound-chip small,
.user-identity small,
.cell-muted {
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--field);
  padding: 0.58rem 0.75rem;
  outline: none;
  transition:
    border-color 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

input::placeholder {
  color: #697386;
}

textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.5;
}

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

h1,
h2,
h3 {
  margin-bottom: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

.xui-shell,
.login-center,
.restore-ui-button {
  position: relative;
  z-index: 1;
}

.xui-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
}

.xui-sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem 0.85rem;
  background: rgba(15, 18, 24, 0.94);
  border-right: 1px solid var(--border);
  box-shadow: 16px 0 34px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand-block {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem;
  border: 0;
  background: transparent;
  text-align: left;
}

.brand-block:hover {
  background: var(--surface);
}

.brand-block span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #04100d;
  background: var(--primary);
  font-weight: 800;
}

.brand-block strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.98rem;
  text-overflow: ellipsis;
}

.side-menu {
  display: grid;
  gap: 0.35rem;
  margin-top: 1.1rem;
}

.mode-node {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0.6rem 0.72rem 0.6rem 2.15rem;
  border: 0;
  border-radius: var(--radius);
  color: var(--text-soft);
  background: transparent;
  text-align: left;
}

.mode-node::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--text-muted);
}

.mode-node:hover {
  color: var(--text);
  background: var(--surface);
}

.mode-node.active {
  color: #dffcf5;
  background: var(--primary-soft);
}

.mode-node.active::before {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 168, 132, 0.12);
}

.xui-main {
  min-width: 0;
  padding: 1rem;
}

.xui-topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(17, 20, 27, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.xui-topbar h1 {
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-weight: 700;
}

.xui-topbar p {
  margin: 0.25rem 0 0;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
}

.session-chip {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
}

.session-chip span {
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 50%;
  background: var(--primary);
}

.session-chip strong {
  max-width: 16rem;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-in 160ms ease both;
}

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

.xui-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(22, 26, 34, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 1rem;
}

.subscription-panel,
.profile-panel,
.security-panel {
  padding: 1rem;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-head h2,
.profile-panel h2,
.security-panel h2,
.admin-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.panel-head p,
.admin-header p {
  margin: 0.25rem 0 0;
}

#copyButton,
.xui-form button[type="submit"],
.inspector-form button[type="submit"],
#applyBulkInbounds,
#createUserForm button[type="submit"],
.template-card button[type="submit"] {
  color: #061411;
  border-color: var(--primary);
  background: var(--primary);
}

#copyButton:hover,
.xui-form button[type="submit"]:hover,
.inspector-form button[type="submit"]:hover,
#applyBulkInbounds:hover,
#createUserForm button[type="submit"]:hover,
.template-card button[type="submit"]:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

#privateUrl,
#inspectorProfiles,
#createdSub {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.86rem;
}

.app-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.app-links a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  padding: 0.4rem 0.65rem;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
}

.app-links a:hover {
  border-color: var(--primary);
  background: var(--surface-3);
}

.profile-panel dl {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0 0;
}

.profile-panel dl div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0.8rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.profile-panel dt {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.profile-panel dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.security-panel {
  width: min(720px, 100%);
}

.xui-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.admin-layout {
  display: grid;
  gap: 1rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat-card {
  min-height: 84px;
  display: grid;
  gap: 0.45rem;
  align-content: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(22, 26, 34, 0.92);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

.stat-card span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.stat-card strong {
  color: var(--text);
  font-size: 1.85rem;
  font-weight: 720;
  line-height: 1;
}

.admin-panel-shell {
  min-height: calc(100vh - 185px);
  overflow: hidden;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  justify-content: flex-end;
}

.search-field {
  width: min(360px, 42vw);
}

.search-field span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.admin-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 20, 27, 0.72);
  overflow-x: auto;
}

.admin-tab {
  flex: 0 0 auto;
  min-height: 36px;
  border-color: transparent;
  color: var(--text-soft);
  background: transparent;
  white-space: nowrap;
}

.admin-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.admin-tab.active {
  color: #061411;
  border-color: var(--primary);
  background: var(--primary);
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.table-toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.soft-button,
.ghost,
.compact-button {
  color: var(--text);
  background: var(--surface-2);
}

.soft-button:hover,
.ghost:hover,
.compact-button:hover {
  background: var(--surface-3);
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  min-height: 0;
}

.user-table {
  max-height: calc(100vh - 324px);
  overflow: auto;
  display: grid;
  align-content: start;
  background: #11151c;
}

.user-table-head,
.user-card {
  display: grid;
  grid-template-columns: minmax(240px, 1.05fr) minmax(280px, 1.2fr) minmax(160px, 0.65fr) minmax(142px, auto);
  gap: 0.85rem;
  align-items: center;
}

.user-table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 42px;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  background: #161b24;
  font-size: 0.76rem;
  font-weight: 700;
}

.user-card {
  min-height: 74px;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.user-card:hover {
  background: rgba(255, 255, 255, 0.025);
}

.user-card.selected {
  background: linear-gradient(90deg, var(--primary-soft), transparent 72%);
}

.user-card-head {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 0.7rem;
  align-items: center;
  min-width: 0;
}

.selector-dot {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border-color: var(--border-strong);
  border-radius: 4px;
  background: transparent;
}

.selector-dot:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.selector-dot.active {
  border-color: var(--primary);
  background:
    linear-gradient(135deg, transparent 0 45%, #061411 45% 55%, transparent 55%),
    var(--primary);
}

.user-identity.as-link {
  width: 100%;
  min-height: auto;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.user-identity.as-link:hover {
  color: var(--primary-hover);
  background: transparent;
}

.user-identity strong,
.user-identity small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-identity strong {
  font-weight: 700;
  white-space: nowrap;
}

.user-card-section {
  min-width: 0;
  display: grid;
  gap: 0.34rem;
}

.user-card-section > span {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.user-card-section strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-chip-line,
.bulk-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
  align-items: flex-start;
}

.mini-chip,
.bulk-targets span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  max-width: 100%;
  padding: 0.16rem 0.42rem;
  border: 1px solid rgba(0, 168, 132, 0.28);
  border-radius: 999px;
  color: #bff5e8;
  background: var(--primary-soft);
  font-size: 0.72rem;
  line-height: 1.2;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.compact-button {
  min-height: 34px;
  padding: 0.42rem 0.62rem;
  font-size: 0.82rem;
}

.danger-button {
  color: #ffd8d9;
  border-color: rgba(255, 77, 79, 0.45);
  background: var(--danger-soft);
}

.danger-button:hover {
  border-color: var(--danger);
  background: rgba(255, 77, 79, 0.2);
}

.user-inspector {
  max-height: calc(100vh - 324px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.9rem;
  padding: 1rem;
  border-left: 1px solid var(--border);
  background: #141922;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.drawer-head span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.drawer-head h2 {
  max-width: 100%;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
}

.profile-lines {
  display: grid;
  gap: 0.45rem;
}

.profile-lines div {
  display: grid;
  grid-template-columns: minmax(96px, 0.42fr) minmax(0, 1fr);
  gap: 0.7rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(43, 50, 63, 0.7);
}

.profile-lines span {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.profile-lines strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
}

.inspector-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.inspector-form button {
  grid-column: 1 / -1;
}

.drawer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.drawer-actions .danger-button {
  grid-column: 1 / -1;
}

.route-section {
  display: grid;
  gap: 0.65rem;
}

.route-section h3 {
  margin-top: 0.25rem;
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

.template-choice,
.template-editor,
.inbound-button-grid,
#inboundList {
  display: grid;
  gap: 0.55rem;
}

.template-choice {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.template-editor {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  padding: 1rem;
}

.template-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #171c25;
}

.template-card .inbound-button-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.template-pill,
.inbound-chip {
  min-height: 58px;
  display: grid;
  gap: 0.2rem;
  align-content: center;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  text-align: left;
}

.template-pill:hover,
.inbound-chip:hover {
  border-color: var(--primary);
  background: var(--surface-3);
}

.template-pill strong,
.inbound-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-pill.active,
.inbound-chip.active {
  border-color: var(--primary);
  color: #dffcf5;
  background: var(--primary-soft);
}

#inboundList,
.inbound-button-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.subscription-drawer {
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
}

.subscription-drawer summary {
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 700;
}

.subscription-drawer textarea {
  margin-top: 0.65rem;
  min-height: 8rem;
}

.bulk-console {
  display: grid;
  grid-template-columns: minmax(210px, 0.24fr) minmax(260px, 0.28fr) minmax(0, 1fr);
  gap: 0.9rem;
  align-content: start;
  padding: 1rem;
}

.bulk-console > button,
.bulk-console > .status-text {
  grid-column: 1 / -1;
}

.bulk-targets {
  min-height: 72px;
  align-content: start;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  background: var(--field);
}

.create-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: end;
  padding: 1rem;
}

.create-grid button {
  min-height: 40px;
}

.result-box {
  display: grid;
  grid-template-columns: minmax(140px, 0.22fr) minmax(180px, 0.28fr) minmax(0, 1fr);
  gap: 0.85rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.result-box textarea {
  min-height: 5rem;
}

.empty-state {
  margin: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-soft);
  background: var(--surface);
}

.status-text {
  margin: 0;
}

.login-center {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.terminal-panel {
  width: min(100%, 420px);
  display: grid;
  gap: 0.85rem;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(22, 26, 34, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.terminal-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.15rem;
  color: var(--text-muted);
}

.terminal-top span {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--danger);
}

.terminal-top span:nth-child(2) {
  background: var(--warning);
}

.terminal-top span:nth-child(3) {
  background: var(--primary);
}

.terminal-top code {
  margin-left: auto;
  color: var(--text-soft);
}

.login-error {
  color: #ffd8d9;
}

.login-panel button[type="submit"] {
  color: #061411;
  border-color: var(--primary);
  background: var(--primary);
}

.restore-ui-button {
  position: fixed;
  right: 1rem;
  top: 1rem;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ui-hidden {
  overflow: hidden;
}

.ui-hidden .xui-shell {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.ui-hidden .snake {
  opacity: 0.9;
}

.ui-hidden .restore-ui-button {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 1240px) {
  .overview-grid,
  .admin-workspace,
  .bulk-console {
    grid-template-columns: 1fr;
  }

  .user-inspector {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .user-table {
    max-height: none;
  }

  .create-grid,
  .result-box {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .xui-sidebar {
    position: relative;
    min-height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-block {
    width: auto;
  }

  .brand-block strong {
    display: none;
  }

  .side-menu {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0;
    overflow-x: auto;
  }

  .mode-node {
    width: auto;
    flex: 0 0 auto;
    padding: 0.58rem 0.78rem 0.58rem 1.9rem;
  }

  .xui-main {
    padding: 0.75rem;
  }

  .xui-topbar,
  .admin-header,
  .panel-head,
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .admin-tools {
    justify-content: flex-start;
  }

  .search-field {
    width: 100%;
  }

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

  .user-table-head {
    display: none;
  }

  .user-card {
    grid-template-columns: 1fr;
    gap: 0.65rem;
    align-items: stretch;
  }

  .user-card-section strong {
    white-space: normal;
  }

  .row-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 580px) {
  body::before {
    background-size: 26px 26px;
  }

  .xui-sidebar {
    grid-template-columns: 1fr;
  }

  .brand-block {
    justify-content: start;
  }

  .brand-block strong {
    display: block;
  }

  .xui-topbar,
  .xui-panel {
    border-radius: var(--radius-sm);
  }

  .topbar-actions,
  .admin-tools,
  .app-links,
  .drawer-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .session-chip,
  .topbar-actions form,
  .topbar-actions button,
  .admin-tools button,
  .app-links a {
    width: 100%;
  }

  .stat-row,
  .create-grid,
  .result-box,
  .inspector-form,
  .profile-panel dl div,
  .profile-lines div,
  .template-editor,
  #inboundList,
  .inbound-button-grid,
  .template-choice {
    grid-template-columns: 1fr;
  }

  .admin-tabs {
    padding-inline: 0.75rem;
  }

  .admin-header,
  .table-toolbar,
  .subscription-panel,
  .profile-panel,
  .security-panel,
  .bulk-console,
  .create-grid,
  .template-editor,
  .result-box,
  .user-inspector {
    padding: 0.75rem;
  }
}

/* Admin v2: transparent, single-screen operator layout. */
body[data-view="admin"] .snake {
  opacity: 0.36;
}

body[data-view="admin"] .xui-sidebar,
body[data-view="admin"] .xui-topbar,
body[data-view="admin"] .xui-panel,
body[data-view="admin"] .stat-card {
  background-color: rgba(15, 18, 24, 0.64);
}

body[data-view="admin"] .xui-topbar {
  min-height: 64px;
  margin-bottom: 0.75rem;
}

body[data-view="admin"] .xui-topbar p {
  display: none;
}

body[data-view="admin"] .admin-layout {
  height: calc(100dvh - 98px);
  min-height: 0;
}

body[data-view="admin"] .admin-panel-shell {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(17, 20, 27, 0.58);
}

body[data-view="admin"] .admin-header {
  flex: 0 0 auto;
  min-height: 64px;
  padding: 0.8rem 1rem;
  background: rgba(12, 15, 21, 0.56);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

body[data-view="admin"] .admin-header h2 {
  font-size: 1rem;
}

body[data-view="admin"] .admin-header p {
  color: var(--text-muted);
}

body[data-view="admin"] .admin-workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(360px, 430px);
}

.users-zone {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--border);
}

.bulk-strip {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 15, 21, 0.34);
}

.bulk-strip strong,
.bulk-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  color: var(--text);
  font-size: 0.84rem;
}

.bulk-strip > span {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
  text-align: right;
}

body[data-view="admin"] .user-table {
  max-height: none;
  min-height: 0;
  background: rgba(9, 12, 17, 0.42);
}

body[data-view="admin"] .user-table-head {
  background: rgba(18, 22, 30, 0.86);
}

body[data-view="admin"] .user-card {
  background: rgba(10, 13, 18, 0.2);
}

body[data-view="admin"] .user-card:hover {
  background: rgba(255, 255, 255, 0.04);
}

body[data-view="admin"] .user-card.selected {
  background: linear-gradient(90deg, rgba(0, 168, 132, 0.22), rgba(12, 15, 21, 0.2) 78%);
}

.command-zone {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(8, 11, 16, 0.28);
}

.inspector-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(2, 5, 9, 0.62);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.user-inspector,
.admin-toolbox {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(19, 23, 31, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.user-inspector {
  width: min(920px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.9rem;
  padding: 1rem;
  border-left: 1px solid var(--border);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
}

.inspector-empty {
  padding: 1rem;
  color: var(--text-soft);
}

.inspector-empty span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.inspector-empty h2 {
  margin: 0.25rem 0 0.4rem;
  color: var(--text);
  font-size: 1.2rem;
}

.inspector-empty p {
  margin: 0;
  line-height: 1.5;
}

.drawer-head {
  align-items: center;
}

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

.profile-lines div {
  grid-template-columns: 1fr;
  gap: 0.25rem;
  padding: 0.55rem;
  border: 1px solid rgba(43, 50, 63, 0.72);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
}

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

.advanced-fields {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  padding: 0.65rem;
}

.advanced-fields summary,
.admin-toolbox summary {
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 700;
}

.advanced-fields label {
  margin-top: 0.65rem;
}

.route-section {
  gap: 0.75rem;
}

.route-section h3 {
  margin-top: 0.1rem;
}

#inboundList,
.inbound-button-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.inbound-chip[data-network="hysteria2"] {
  border-color: rgba(22, 119, 255, 0.38);
  background: rgba(22, 119, 255, 0.1);
}

.inbound-chip[data-network="hysteria2"].active {
  border-color: var(--blue);
  color: #e8f1ff;
  background: rgba(22, 119, 255, 0.22);
}

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

#saveInspectorUser,
#applyBulkInbounds,
#createUserForm button[type="submit"] {
  color: #04120f;
  border-color: var(--primary);
  background: var(--primary);
}

#saveInspectorUser {
  grid-column: 1 / -1;
}

.admin-toolbox {
  padding: 0.85rem;
}

.admin-toolbox[open] {
  background: rgba(19, 23, 31, 0.72);
}

.admin-toolbox summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
}

.admin-toolbox summary::-webkit-details-marker {
  display: none;
}

.admin-toolbox summary::after {
  content: "";
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
}

.admin-toolbox[open] summary::after {
  transform: rotate(225deg) translateY(-2px);
}

.bulk-console,
.create-grid,
.template-editor {
  padding: 0.75rem 0 0;
}

.bulk-console {
  grid-template-columns: 1fr;
}

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

.template-editor {
  grid-template-columns: 1fr;
}

.template-card {
  background: rgba(255, 255, 255, 0.035);
}

@media (min-width: 901px) {
  body[data-view="admin"] {
    overflow: hidden;
  }

  body[data-view="admin"] .xui-shell,
  body[data-view="admin"] .xui-sidebar,
  body[data-view="admin"] .xui-main {
    height: 100dvh;
  }

  body[data-view="admin"] .xui-main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  body[data-view="admin"] #view-admin,
  body[data-view="admin"] #view-admin.active {
    min-height: 0;
    overflow: hidden;
  }
}

@media (max-width: 1240px) {
  body[data-view="admin"] .admin-workspace {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  }

  .profile-lines,
  .inspector-form,
  .drawer-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body[data-view="admin"] .admin-layout,
  body[data-view="admin"] .admin-panel-shell {
    height: auto;
    overflow: visible;
  }

  body[data-view="admin"] .admin-workspace {
    grid-template-columns: 1fr;
  }

  .users-zone {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .bulk-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .bulk-strip > span {
    text-align: left;
  }

  .command-zone {
    overflow: visible;
  }
}

@media (max-width: 580px) {
  .create-grid,
  .profile-lines,
  .inspector-form,
  .drawer-actions {
    grid-template-columns: 1fr;
  }

  .command-zone {
    padding: 0.6rem;
  }

  .inspector-overlay {
    padding: 0.45rem;
  }

  .user-inspector {
    width: calc(100vw - 0.9rem);
    max-height: calc(100dvh - 0.9rem);
  }
}

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