:root {
  --bg0: #020804;
  --bg1: rgba(4, 14, 8, 0.82);
  --bg2: rgba(8, 28, 16, 0.72);
  --bg3: rgba(12, 40, 24, 0.85);
  --surface: rgba(2, 12, 6, 0.82);
  --surface-muted: rgba(0, 0, 0, 0.35);
  --input-bg: rgba(0, 8, 4, 0.85);
  --btn-bg: rgba(0, 20, 10, 0.75);
  --hover-bg: rgba(57, 255, 136, 0.06);
  --line: rgba(57, 255, 136, 0.22);
  --line-soft: rgba(57, 255, 136, 0.12);
  --text: #d4ffe6;
  --muted: #6fbf8f;
  --accent: #39ff88;
  --accent-soft: rgba(57, 255, 136, 0.12);
  --accent-2: #7dffb2;
  --neon: #39ff88;
  --neon-dim: rgba(57, 255, 136, 0.35);
  --danger: #ff6b6b;
  --ok: #39ff88;
  --warn: #ffe066;
  --expired: #ff6b6b;
  --radius: 4px;
  --sidebar-w: 248px;
  --agent-rail-w: 280px;
  --topbar-h: 64px;
  --font: "JetBrains Mono", "Share Tech Mono", ui-monospace, monospace;
  --mono: "Share Tech Mono", "JetBrains Mono", ui-monospace, monospace;
  --glow: 0 0 12px rgba(57, 255, 136, 0.35);
  --shadow-sm: 0 1px 0 rgba(57, 255, 136, 0.06);
  --shadow-md: 0 0 16px rgba(57, 255, 136, 0.12);
  --shadow-card: inset 0 1px 0 rgba(57, 255, 136, 0.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #020804;
  min-height: 100%;
  position: relative;
}

/* CRT overlays */
.matrix-scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.35;
}
.matrix-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, rgba(0, 20, 8, 0.25), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.4));
}
#app {
  position: relative;
  z-index: 2;
  min-height: 100%;
}

.term-prompt {
  color: var(--neon);
  margin-right: 0.35rem;
  text-shadow: var(--glow);
}
.term-cursor {
  display: inline-block;
  color: var(--neon);
  animation: blink 1.05s step-end infinite;
  text-shadow: var(--glow);
  font-weight: 400;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }
#ttl-left, #token-ttl { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--neon); text-shadow: var(--glow); }
#ttl-left.ttl-expired, #token-ttl.ttl-expired, .ttl-expired { color: var(--expired); text-shadow: 0 0 8px rgba(255, 107, 107, 0.4); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.brand {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--neon);
  text-shadow: var(--glow);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 20, 10, 0.75);
  color: var(--text);
  border-radius: 2px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(57, 255, 136, 0.04);
}
.btn:hover {
  border-color: var(--neon-dim);
  background: rgba(8, 40, 22, 0.9);
  box-shadow: var(--glow);
}
.btn.primary {
  background: rgba(57, 255, 136, 0.18);
  border-color: var(--neon);
  color: #e8ffe8;
  text-shadow: var(--glow);
  box-shadow: 0 0 16px rgba(57, 255, 136, 0.25);
}
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffc9c9; border-color: rgba(255, 107, 107, 0.45); }
.btn.small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
  background: var(--surface-muted);
  white-space: nowrap;
}
.pill.on {
  color: var(--neon);
  border-color: var(--neon-dim);
  background: var(--accent-soft);
  text-shadow: 0 0 8px rgba(57, 255, 136, 0.45);
}
.pill.off { color: #9a8868; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: transparent;
}
.login-panel {
  width: min(420px, 100%);
  background: rgba(2, 12, 6, 0.78);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2rem;
  animation: rise 0.45s ease both;
  box-shadow:
    0 0 0 1px rgba(57, 255, 136, 0.08),
    0 0 40px rgba(57, 255, 136, 0.12),
    inset 0 0 60px rgba(0, 40, 20, 0.35);
  backdrop-filter: blur(8px);
}
.login-panel h1 {
  margin: 0.35rem 0 0.4rem;
  font-size: 1.65rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: #e8ffe8;
  text-shadow: var(--glow);
}
.login-panel::before {
  content: "> auth --admin";
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.04em;
}
.lede { margin: 0 0 1.4rem; color: var(--muted); font-family: var(--mono); font-size: 0.85rem; }
label { display: grid; gap: 0.35rem; margin-bottom: 0.9rem; font-size: 0.9rem; color: var(--muted); }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 8, 4, 0.85);
  color: var(--text);
  border-radius: 2px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  caret-color: var(--neon);
}
input:focus, select:focus {
  outline: 1px solid var(--neon);
  border-color: var(--neon);
  box-shadow: 0 0 12px rgba(57, 255, 136, 0.2);
}
.form-error { min-height: 1.2rem; color: var(--danger); font-size: 0.9rem; }

/* ========== Terminal admin shell ========== */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  background: transparent;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: rgba(2, 10, 6, 0.88);
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45), inset -1px 0 0 rgba(57, 255, 136, 0.08);
  backdrop-filter: blur(10px);
  z-index: 40;
}

.app-sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.15rem 1.15rem 1rem;
  border-bottom: 1px solid var(--line-soft);
}
.app-sidebar-product {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.75rem;
  flex: 1;
  overflow: auto;
}
.app-nav-label {
  margin: 0 0 0.45rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  color: var(--muted);
  font-family: var(--mono);
}

.app-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  border-radius: 2px;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.app-nav-item:hover { background: rgba(57, 255, 136, 0.06); border-color: var(--line-soft); }
.app-nav-item.active {
  background: var(--accent-soft);
  border-color: var(--neon-dim);
  box-shadow: inset 2px 0 0 var(--neon), 0 0 18px rgba(57, 255, 136, 0.12);
}
.app-nav-icon {
  flex-shrink: 0;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: lowercase;
  color: var(--neon);
  background: rgba(57, 255, 136, 0.08);
  border: 1px solid rgba(57, 255, 136, 0.28);
  text-shadow: var(--glow);
}
.app-nav-item.active .app-nav-icon {
  background: rgba(57, 255, 136, 0.2);
  color: #e8ffe8;
}
.app-nav-text {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}
.app-nav-text strong {
  font-size: 0.92rem;
  font-weight: 650;
}
.app-nav-text small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.3;
}

.app-sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 0.75rem;
}
.app-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}
.app-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}
.app-user-meta { display: grid; gap: 0.1rem; min-width: 0; }
.app-user-label {
  font-size: 0.68rem;
  text-transform: lowercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-family: var(--mono);
}
.app-user-email {
  font-size: 0.78rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.app-topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0 1.35rem;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(2, 10, 6, 0.78);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(57, 255, 136, 0.06);
}
.app-topbar-title h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  text-transform: lowercase;
  color: var(--neon);
  text-shadow: var(--glow);
}
.app-topbar-title p { margin: 0.1rem 0 0; }
.sidebar-toggle { display: none; }

.app-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

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

.page-agents {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.1rem 1.35rem 1.5rem;
  overflow: auto;
  gap: 1rem;
}

.agents-page-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 2.5rem;
}

.btn-glow {
  border-color: var(--neon);
  color: #e8ffe8;
  background: rgba(57, 255, 136, 0.1);
  box-shadow: 0 0 18px rgba(57, 255, 136, 0.22);
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
}

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

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(2, 12, 6, 0.78);
  box-shadow: inset 0 1px 0 rgba(57, 255, 136, 0.05);
  min-height: 5.5rem;
}

.stat-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: rgba(57, 255, 136, 0.08);
  flex-shrink: 0;
  position: relative;
}
.stat-icon::after {
  content: "";
  position: absolute;
  inset: 0.45rem;
  border-radius: 3px;
  background: var(--neon);
  opacity: 0.55;
  box-shadow: 0 0 10px rgba(57, 255, 136, 0.45);
}

.stat-body { display: grid; gap: 0.15rem; min-width: 0; }
.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--neon);
  text-shadow: var(--glow);
  font-weight: 700;
}
.stat-hint {
  font-size: 0.68rem;
  color: var(--muted);
}

.agents-directory {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}

.directory-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.directory-title {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.directory-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.provider-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.provider-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.provider-tab:hover { color: var(--text); background: rgba(57, 255, 136, 0.06); }
.provider-tab.active {
  color: #03140b;
  background: var(--neon);
  border-color: var(--neon);
  box-shadow: 0 0 14px rgba(57, 255, 136, 0.35);
}

.tab-logo {
  width: 1rem;
  height: 1rem;
  border-radius: 3px;
  object-fit: cover;
}

.directory-search { flex: 1 1 12rem; min-width: 10rem; }
.directory-search input {
  width: 100%;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.35);
}

.directory-select {
  width: auto;
  min-width: 7.5rem;
  border-radius: 999px;
  padding: 0.48rem 0.75rem;
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.35);
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow: hidden;
}
.view-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 2.1rem;
  height: 2.1rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.view-btn.active {
  color: var(--neon);
  background: rgba(57, 255, 136, 0.12);
  box-shadow: inset 0 0 0 1px var(--neon-dim);
}

.agent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.5rem;
}
.agent-list.view-list {
  grid-template-columns: 1fr;
}

.agent-list button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line-soft);
  background: rgba(2, 12, 6, 0.82);
  color: inherit;
  border-radius: 8px;
  padding: 0.5rem 0.6rem 0.45rem;
  cursor: pointer;
  font: inherit;
  min-height: 6.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.agent-list button:hover {
  border-color: var(--neon-dim);
  box-shadow: 0 0 12px rgba(57, 255, 136, 0.1);
}
.agent-list button.active {
  border-color: var(--neon-dim);
  box-shadow: inset 0 0 0 1px rgba(57, 255, 136, 0.25), 0 0 14px rgba(57, 255, 136, 0.12);
}
.agent-list.view-list button {
  min-height: auto;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.45rem 0.75rem;
}
.agent-list .bal {
  display: block;
  margin-top: 0.1rem;
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--neon);
  text-shadow: 0 0 6px rgba(57, 255, 136, 0.3);
  line-height: 1.15;
}
.card-ttl {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--neon);
  text-shadow: var(--glow);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.card-ttl.ttl-expired {
  color: var(--expired);
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.4);
}

.agent-card-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  padding-right: 0.75rem;
}

.agent-card-logo {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.agent-card-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.agent-card-menu {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  pointer-events: none;
  flex-shrink: 0;
}

.agent-list .name {
  font-weight: 700;
  font-size: 0.82rem;
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-list .msisdn {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-list.view-list .bal { margin-top: 0; margin-left: auto; }

.agent-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.15rem;
}
.agent-list.view-list .agent-card-foot {
  margin-top: 0;
  margin-left: auto;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.agent-list .st {
  display: inline-flex;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.12rem 0.4rem;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.agent-list.view-list .st { margin-top: 0; }

.agent-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.35rem;
}
.page-btn {
  appearance: none;
  min-width: 2rem;
  height: 2rem;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
  background: var(--surface-muted);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.page-btn.active,
.page-btn:hover:not(:disabled) {
  color: var(--neon);
  border-color: var(--neon-dim);
  box-shadow: 0 0 10px rgba(57, 255, 136, 0.2);
}
.page-btn:disabled { opacity: 0.35; cursor: default; }

.live-widget {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  background: rgba(0, 0, 0, 0.28);
}
.live-widget-head { margin-bottom: 0.35rem; }
.live-pill.on { box-shadow: 0 0 10px rgba(57, 255, 136, 0.25); }
.live-sparkline {
  height: 2.2rem;
  margin: 0.25rem 0 0.45rem;
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(57, 255, 136, 0.08), transparent),
    repeating-linear-gradient(90deg, transparent, transparent 8px, rgba(57, 255, 136, 0.06) 8px, rgba(57, 255, 136, 0.06) 9px);
  box-shadow: inset 0 0 12px rgba(57, 255, 136, 0.08);
}
.live-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--muted);
}
.live-stats strong {
  display: block;
  color: var(--neon);
  font-size: 0.95rem;
  margin-top: 0.1rem;
}

.app-user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #03140b;
  background: var(--neon);
  flex-shrink: 0;
}
.app-user-role {
  font-size: 0.68rem;
  color: var(--muted);
}
.logout-btn {
  width: 100%;
  border-color: var(--neon-dim);
  color: var(--neon);
}

.app-shell.page-agents-view .app-topbar { display: none; }

@media (max-width: 1400px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .agent-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .stats-grid { grid-template-columns: 1fr; }
  .agent-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .directory-controls { flex-direction: column; align-items: stretch; }
  .provider-tabs { flex-wrap: wrap; }
}

.page-deposits {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem 1.15rem 1.25rem;
}
.page-deposits .deposits-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.page-deposits .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.deposits-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0 0.15rem 0.85rem;
  align-items: flex-start;
}
.filter-field {
  display: grid;
  grid-template-rows: auto 2.15rem;
  gap: 0.28rem;
  width: 14rem;
  margin: 0;
}
.filter-field > span {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.filter-field input {
  font: inherit;
  color: inherit;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  padding: 0.42rem 0.55rem;
  width: 100%;
  height: 2.15rem;
  box-sizing: border-box;
  margin: 0;
}
.filter-field input:focus {
  outline: none;
  border-color: var(--neon-dim);
  box-shadow: 0 0 12px rgba(57, 255, 136, 0.15);
}
.filter-combo {
  position: relative;
}
.filter-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 20;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  max-height: 14rem;
  overflow: auto;
  background: #03140b;
  border: 1px solid var(--neon-dim);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}
.filter-menu li {
  padding: 0.38rem 0.6rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.filter-menu li:hover,
.filter-menu li.active {
  background: rgba(57, 255, 136, 0.12);
}

.agent-rail {
  border-right: 1px solid var(--line-soft);
  background: rgba(2, 10, 6, 0.72);
  backdrop-filter: blur(8px);
  padding: 1rem 0.85rem;
  overflow: auto;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
}
.sidebar-head h2 { margin: 0; font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.st-online {
  color: var(--neon);
  text-shadow: 0 0 5px rgba(57, 255, 136, 0.45);
}
.st-offline {
  color: var(--expired);
  text-shadow: none;
}
.agent-list .st.st-online {
  color: var(--neon);
  border-color: rgba(57, 255, 136, 0.35);
  background: rgba(57, 255, 136, 0.08);
}
.agent-list .st.st-offline {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.workspace {
  padding: 1.25rem 1.5rem 2rem;
  overflow: auto;
  width: 100%;
  min-width: 0;
}
.workspace.full {
  max-width: none;
  width: 100%;
}
.page-proxies .workspace {
  padding: 1.25rem 1.5rem 2rem;
}

.empty-state {
  max-width: 440px;
  margin: 2.5rem auto;
  text-align: center;
  color: var(--muted);
  animation: rise 0.4s ease both;
}
.empty-state h2 { color: var(--text); }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line-soft);
}
.detail-head-left { flex: 1; min-width: 0; }
.detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.detail-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.detail-sub { margin: 0.2rem 0 0.35rem; color: var(--muted); font-size: 0.85rem; }
.detail-summary { margin: 0 0 0.65rem; }
.detail-login-error {
  margin: 0 0 0.75rem;
  color: #ffb0b0;
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-login-error.hidden { display: none; }

.detail-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.2rem;
  background: rgba(0, 8, 4, 0.65);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.detail-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.45rem 0.85rem;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.detail-tab:hover { color: var(--text); background: rgba(57, 255, 136, 0.06); }
.detail-tab.active {
  color: #e8ffe8;
  background: rgba(57, 255, 136, 0.16);
  box-shadow: inset 0 0 0 1px var(--neon-dim), 0 0 12px rgba(57, 255, 136, 0.15);
  text-shadow: var(--glow);
}

.tab-panels { min-height: 12rem; }
.tab-panel { display: none; animation: rise 0.28s ease both; }
.tab-panel.active { display: block; }
.tab-panel[hidden] { display: none !important; }

.panel {
  background: rgba(2, 12, 6, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  animation: rise 0.35s ease both;
  backdrop-filter: blur(6px);
  box-shadow:
    inset 0 1px 0 rgba(57, 255, 136, 0.06),
    0 0 24px rgba(0, 0, 0, 0.25);
}
.panel-wide {
  width: 100%;
  max-width: none;
}
.panel h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.panel-desc { margin: 0.35rem 0 0; max-width: 62ch; }

.panel-compact {
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}
.panel-compact h3 { margin: 0; font-size: 0.92rem; font-weight: 650; }
.panel-compact .panel-head {
  margin-bottom: 0.65rem;
  gap: 0.75rem;
  align-items: center;
}
.tab-hint { margin: 0 0 0.65rem; }
.compact-actions { flex-wrap: wrap; gap: 0.35rem; margin-top: 0; }
.compact-pre {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.72rem;
  line-height: 1.45;
  max-height: 9rem;
  overflow: auto;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--neon);
  font-family: var(--mono);
  text-shadow: 0 0 6px rgba(57, 255, 136, 0.25);
}
.meta-list-compact {
  grid-template-columns: 8.5rem 1fr;
  gap: 0.28rem 0.65rem;
  font-size: 0.82rem;
}
.cashin-form { flex-wrap: wrap; }
.cashin-form input { min-width: 8rem; }
.pin-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}
.pin-row input {
  margin-left: 0.35rem;
  width: 7rem;
  padding: 0.35rem 0.5rem;
}
.table-compact table { font-size: 0.8rem; }
.table-compact th, .table-compact td { padding: 0.4rem 0.5rem; }

.status-badge {
  border-radius: 2px;
  padding: 0.35rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  flex-shrink: 0;
  font-family: var(--mono);
}
.status-badge.OK { color: var(--neon); border-color: var(--neon-dim); background: rgba(57, 255, 136, 0.1); text-shadow: var(--glow); }
.status-badge.EXPIRING, .status-badge.UNKNOWN_EXPIRY { color: #ffe066; border-color: rgba(255, 224, 102, 0.35); background: rgba(255, 224, 102, 0.08); }
.status-badge.EXPIRED, .status-badge.NO_SESSION { color: #ffb0b0; border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.1); }

.inline-form { display: flex; gap: 0.5rem; }
.inline-form input { flex: 1; }

.meta-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.4rem 0.75rem;
  margin: 0;
  font-size: 0.9rem;
}
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; word-break: break-all; }

.results { margin-top: 0.75rem; display: grid; gap: 0.55rem; }
.result-card {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.7rem 0.8rem;
  background: rgba(0, 0, 0, 0.45);
}
.result-card .row { display: flex; justify-content: space-between; gap: 0.75rem; }
.result-card .amt { font-weight: 700; color: var(--accent-2); }
.result-meta {
  display: grid;
  gap: 0.45rem 1rem;
  margin: 0;
}
.result-meta > div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}
.result-meta dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.result-meta dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
}

.table-wrap { overflow: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.7rem 0.55rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }

.proxy-form {
  display: grid;
  grid-template-columns: 1.1fr 2.2fr 110px auto auto;
  gap: 0.75rem;
  align-items: end;
  margin: 1rem 0 0.5rem;
}
.proxy-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: var(--muted); margin: 0; }
.proxy-form label.check { flex-direction: row; align-items: center; gap: 0.4rem; padding-bottom: 0.55rem; }
.proxy-form input[type="text"],
.proxy-form input[type="number"],
.proxy-form input:not([type]) {
  background: var(--bg0);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.page-settings .workspace { padding: 1.25rem 1.5rem 2rem; }
.settings-grid {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line-soft);
  background: rgba(0, 8, 4, 0.45);
  cursor: pointer;
}
.settings-row span { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.settings-row strong { color: var(--text); font-size: 0.92rem; }
.settings-row small { color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.settings-grid.is-locked {
  opacity: 0.45;
  pointer-events: none;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-ui {
  width: 42px;
  height: 22px;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.55);
  position: relative;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #6f8f7a;
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch-ui {
  border-color: var(--neon-dim);
  background: var(--accent-soft);
  box-shadow: var(--glow);
}
.switch input:checked + .switch-ui::after {
  transform: translateX(20px);
  background: var(--neon);
}
.switch-label {
  font-family: var(--mono);
  font-size: 0.85rem;
  min-width: 2.2rem;
  color: var(--muted);
}
.switch input:checked ~ .switch-label {
  color: var(--neon);
  text-shadow: 0 0 8px rgba(57, 255, 136, 0.45);
}
.panel-head .switch { margin-top: 0.2rem; }
.ingest-help pre {
  margin: 0.5rem 0 0;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 2px;
  border: 1px solid var(--line);
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.78rem;
  color: var(--neon);
  font-family: var(--mono);
  text-shadow: 0 0 6px rgba(57, 255, 136, 0.2);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 30;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(2, 12, 6, 0.95);
  color: var(--text);
  padding: 0;
  width: min(440px, calc(100% - 2rem));
  box-shadow: 0 0 40px rgba(57, 255, 136, 0.15);
}
dialog.agent-detail-modal {
  width: min(960px, calc(100% - 2rem));
  max-height: calc(100vh - 2.5rem);
  overflow: auto;
  position: relative;
}
.modal-close-x {
  position: sticky;
  top: 0.45rem;
  float: right;
  z-index: 5;
  margin: 0.35rem 0.45rem 0 0;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--neon-dim);
  background: rgba(2, 12, 6, 0.92);
  color: var(--neon);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 2px;
  font-family: var(--mono);
}
.modal-close-x:hover {
  background: rgba(57, 255, 136, 0.12);
  box-shadow: 0 0 12px rgba(57, 255, 136, 0.25);
}
dialog.agent-detail-modal .agent-detail {
  padding: 1.1rem 1.2rem 1.25rem;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
dialog form, .secret-box { padding: 1.25rem; }
dialog h3 { margin: 0 0 0.85rem; color: var(--neon); text-shadow: var(--glow); }
.secret-box code {
  display: block;
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--line);
  border-radius: 2px;
  word-break: break-all;
  color: var(--neon);
  font-family: var(--mono);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes blink {
  50% { opacity: 0; }
}
@keyframes neon-blink-green {
  0%, 54% { color: #39ff88; text-shadow: 0 0 5px rgba(57, 255, 136, 0.45); }
  55%, 100% { color: #1a5c36; text-shadow: none; }
}
@keyframes neon-blink-red {
  0%, 54% { color: #ff4d4d; text-shadow: 0 0 5px rgba(255, 77, 77, 0.4); }
  55%, 100% { color: #7a2222; text-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .term-cursor,
  .st-online,
  .st-offline { animation: none; }
}

@media (max-width: 1100px) {
  .proxy-form { grid-template-columns: 1fr 1fr; }
  .proxy-form button[type="submit"] { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }
  .app-shell.sidebar-open .app-sidebar { transform: none; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop:not(.hidden) { display: block; }
  .page-agents { padding: 0.85rem; }
  .agent-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    max-height: 240px;
  }
  .proxy-form { grid-template-columns: 1fr; }
}
