:root {
  --bg: #07101f;
  --bg-soft: #0b1629;
  --panel: rgba(14, 27, 48, 0.82);
  --panel-strong: rgba(18, 34, 58, 0.96);
  --line: rgba(151, 178, 220, 0.13);
  --line-strong: rgba(151, 178, 220, 0.25);
  --text: #f2f7ff;
  --muted: #8fa1bc;
  --blue: #5d8cff;
  --blue-bright: #7da4ff;
  --green: #41d99f;
  --purple: #a77cff;
  --orange: #ffb55d;
  --red: #ff647c;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -5%, rgba(71, 111, 225, 0.16), transparent 31rem),
    radial-gradient(circle at 92% 102%, rgba(116, 65, 213, 0.13), transparent 34rem),
    linear-gradient(145deg, #07101f 0%, #08111f 55%, #060d19 100%);
}

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

.ambient {
  position: fixed;
  z-index: -1;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .17;
  pointer-events: none;
}
.ambient-one { top: -9rem; left: 18%; background: #315dff; }
.ambient-two { right: -8rem; bottom: -10rem; background: #7b45ef; }

.glass {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

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

.login-card {
  width: min(100%, 28rem);
  padding: 2.5rem;
  border-radius: 1.5rem;
  text-align: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 4.1rem;
  height: 4.1rem;
  margin: 0 auto 1.4rem;
  border: 1px solid rgba(125, 164, 255, .46);
  border-radius: 1.25rem;
  color: white;
  font-size: 1.65rem;
  font-weight: 800;
  background: linear-gradient(145deg, #4579f5, #7754e8);
  box-shadow: 0 16px 42px rgba(71, 107, 234, .35), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark.small { width: 2.7rem; height: 2.7rem; margin: 0; border-radius: .85rem; font-size: 1.05rem; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .55rem; font-size: clamp(1.75rem, 3vw, 2.4rem); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 1.18rem; letter-spacing: -.015em; }
.eyebrow { margin-bottom: .45rem; color: var(--blue-bright); font-size: .68rem; font-weight: 750; letter-spacing: .18em; }
.muted { color: var(--muted); }

form label, .modal > label {
  display: grid;
  gap: .5rem;
  margin-top: 1rem;
  color: #c8d3e4;
  text-align: left;
  font-size: .8rem;
  font-weight: 650;
}
label em { color: var(--muted); font-style: normal; font-weight: 500; }

input {
  min-width: 0;
  width: 100%;
  padding: .82rem .9rem;
  color: var(--text);
  outline: none;
  border: 1px solid var(--line-strong);
  border-radius: .72rem;
  background: rgba(5, 14, 28, .75);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input::placeholder { color: #687a96; }
input:focus { border-color: rgba(93, 140, 255, .82); box-shadow: 0 0 0 3px rgba(93, 140, 255, .13); background: rgba(7, 18, 35, .92); }

button {
  cursor: pointer;
  border: 0;
  border-radius: .72rem;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, opacity .16s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { cursor: wait; opacity: .55; transform: none; }
.primary { padding: .76rem 1rem; font-weight: 750; background: linear-gradient(135deg, #4c7cf4, #6f55e5); box-shadow: 0 10px 26px rgba(70, 96, 220, .22); }
.primary:hover { background: linear-gradient(135deg, #5b89fa, #7b61ed); }
.wide { width: 100%; margin-top: 1.35rem; }
.ghost { padding: .7rem .88rem; border: 1px solid var(--line-strong); background: rgba(16, 30, 51, .7); }
.ghost:hover { background: rgba(31, 49, 77, .82); }
.danger { padding: .72rem .95rem; font-weight: 700; background: rgba(255, 100, 124, .15); border: 1px solid rgba(255, 100, 124, .36); color: #ff9aaa; }
.danger:hover { background: rgba(255, 100, 124, .24); }
.form-error { min-height: 1.2rem; margin: .8rem 0 0; color: #ff91a3; font-size: .78rem; text-align: left; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  width: 15.5rem;
  display: flex;
  flex-direction: column;
  padding: 1.6rem 1rem;
  border-width: 0 1px 0 0;
  border-radius: 0;
  box-shadow: 14px 0 50px rgba(0,0,0,.16);
}
.brand-row { display: flex; align-items: center; gap: .85rem; padding: 0 .45rem 1.8rem; }
.brand-row strong, .brand-row span { display: block; }
.brand-row strong { font-size: 1.05rem; letter-spacing: .08em; }
.brand-row span { margin-top: .15rem; color: var(--muted); font-size: .7rem; }
nav { display: grid; gap: .35rem; }
.nav-item { display: flex; align-items: center; gap: .78rem; width: 100%; padding: .78rem .88rem; color: var(--muted); text-align: left; background: transparent; }
.nav-item:hover, .nav-item.active { color: var(--text); background: rgba(93, 140, 255, .11); }
.nav-item.active { box-shadow: inset 3px 0 0 var(--blue); }
.nav-icon { width: 1.25rem; color: var(--blue-bright); font-size: 1.1rem; text-align: center; }
.sidebar-foot { display: flex; align-items: center; gap: .55rem; margin-top: auto; padding: .8rem; color: var(--muted); font-size: .72rem; }
.secure-dot { width: .48rem; height: .48rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px rgba(65,217,159,.7); }

.workspace { grid-column: 2; width: min(100%, 100rem); margin: 0 auto; padding: 2rem clamp(1.2rem, 3vw, 3.4rem) 4rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.65rem; }
.topbar h1 { margin-bottom: 0; }
.top-actions { display: flex; align-items: center; gap: .65rem; }
.icon-button { width: 2.65rem; height: 2.65rem; border: 1px solid var(--line-strong); background: rgba(16, 30, 51, .7); font-size: 1.1rem; }
.service-pill { display: flex; align-items: center; gap: .52rem; min-height: 2.65rem; padding: 0 .85rem; border: 1px solid var(--line); border-radius: .72rem; color: var(--muted); background: rgba(16, 30, 51, .7); font-size: .76rem; }
.service-pill span:first-child { width: .5rem; height: .5rem; border-radius: 50%; background: var(--orange); }
.service-pill.online span:first-child { background: var(--green); box-shadow: 0 0 12px rgba(65,217,159,.65); }
.service-pill.offline span:first-child { background: var(--red); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stat-card { position: relative; overflow: hidden; min-height: 9.5rem; padding: 1.25rem; border-radius: 1rem; box-shadow: 0 14px 42px rgba(0,0,0,.18); }
.stat-card::after { content: ""; position: absolute; width: 8rem; height: 8rem; right: -4rem; top: -4rem; border-radius: 50%; background: var(--accent); filter: blur(25px); opacity: .17; }
.accent-blue { --accent: var(--blue); }
.accent-green { --accent: var(--green); }
.accent-purple { --accent: var(--purple); }
.accent-orange { --accent: var(--orange); }
.stat-label { display: block; margin-bottom: .9rem; color: var(--muted); font-size: .76rem; }
.stat-card strong { display: block; font-size: 2rem; letter-spacing: -.04em; }
.stat-card small { display: block; margin-top: .75rem; color: #94a8c7; font-size: .72rem; }

.panel { margin-top: 1rem; padding: 1.25rem; border-radius: 1rem; box-shadow: 0 16px 50px rgba(0,0,0,.2); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.panel-head.compact { margin-bottom: 1rem; }
.panel-tools { display: flex; align-items: center; gap: .7rem; }
.search-box { display: flex; align-items: center; gap: .45rem; min-width: min(18rem, 35vw); padding-left: .75rem; border: 1px solid var(--line); border-radius: .72rem; color: var(--muted); background: rgba(5,14,28,.48); }
.search-box input { padding-left: .2rem; border: 0; box-shadow: none; background: transparent; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { padding: .75rem .7rem; color: #71839e; font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-align: left; text-transform: uppercase; border-bottom: 1px solid var(--line); }
td { padding: .95rem .7rem; vertical-align: middle; border-bottom: 1px solid rgba(151,178,220,.08); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(101,135,199,.035); }
.user-name { font-weight: 750; color: #eaf2ff; }
.user-password { display: block; max-width: 12rem; margin-top: .3rem; overflow: hidden; color: #7186a6; font-size: .66rem; text-overflow: ellipsis; }
.status-badge { display: inline-flex; align-items: center; gap: .35rem; padding: .32rem .55rem; border-radius: 999px; font-size: .68rem; font-weight: 700; }
.status-badge::before { content: ""; width: .38rem; height: .38rem; border-radius: 50%; }
.status-badge.enabled { color: #87ebc5; background: rgba(65,217,159,.1); }
.status-badge.enabled::before { background: var(--green); }
.status-badge.disabled { color: #ff9eae; background: rgba(255,100,124,.1); }
.status-badge.disabled::before { background: var(--red); }
.device-count, .traffic-total, .expiry-date { color: #d6e1f2; font-weight: 650; }
td small { display: block; max-width: 13rem; margin-top: .28rem; overflow: hidden; color: #71839e; font-size: .64rem; text-overflow: ellipsis; white-space: nowrap; }
.expiry-note.warning { color: var(--orange); }
.expiry-note.expired { color: var(--red); }
.route-cell { min-width: 12rem; }
.route-select { width: 100%; min-width: 11.5rem; padding: .48rem .58rem; color: #dce8f8; border: 1px solid var(--line-strong); border-radius: .58rem; outline: 0; background: #101e33; font-size: .7rem; }
.route-select:focus { border-color: rgba(93, 140, 255, .82); box-shadow: 0 0 0 3px rgba(93, 140, 255, .13); }
.route-select:disabled { cursor: wait; opacity: .58; }
.row-actions { display: flex; justify-content: flex-end; gap: .35rem; }
.action-button { min-width: 2.15rem; min-height: 2.1rem; padding: .42rem .58rem; color: #9eb0c9; border: 1px solid var(--line); background: rgba(15,29,49,.8); font-size: .68rem; }
.action-button:hover { color: white; border-color: var(--line-strong); background: rgba(35,53,81,.9); }
.action-button.red:hover { color: #ff9aaa; border-color: rgba(255,100,124,.3); background: rgba(255,100,124,.1); }
.empty-state { display: grid; justify-items: center; gap: .5rem; padding: 3rem; color: var(--muted); text-align: center; }
.empty-state div { color: var(--blue-bright); font-size: 2rem; }
.empty-state strong { color: #c7d4e8; }
.empty-state span { font-size: .75rem; }

.server-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; }
.server-card { margin-top: 1rem; }
.server-list { margin: 0; }
.server-list div, .health-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .72rem 0; border-bottom: 1px solid rgba(151,178,220,.08); }
.server-list div:last-child, .health-row:last-child { border-bottom: 0; }
dt, .health-row span, .meter-block span { color: var(--muted); font-size: .73rem; }
dd { margin: 0; color: #d6e1f2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; }
.health-row strong, .meter-block strong { font-size: .74rem; }
.meter-block { padding: .78rem 0; }
.meter-block > div:first-child { display: flex; justify-content: space-between; margin-bottom: .55rem; }
.meter { height: .42rem; overflow: hidden; border-radius: 999px; background: rgba(119,144,183,.13); }
.meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--purple)); transition: width .35s ease; }

dialog {
  color: var(--text);
  border: 1px solid var(--line-strong);
}
dialog::backdrop { background: rgba(1, 6, 15, .72); backdrop-filter: blur(8px); }
.modal { width: min(calc(100% - 2rem), 32rem); padding: 1.35rem; border-radius: 1rem; background: var(--panel-strong); box-shadow: 0 30px 100px rgba(0,0,0,.56); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.close-button { width: 2rem; height: 2rem; color: var(--muted); background: transparent; font-size: 1.35rem; }
.close-button:hover { color: white; background: rgba(255,255,255,.06); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1.25rem; }
.qr-wrap { display: grid; place-items: center; width: 14rem; height: 14rem; margin: 1rem auto; padding: .7rem; border-radius: .9rem; background: white; }
.qr-wrap img { width: 100%; height: 100%; object-fit: contain; }
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; }
.copy-row button { padding: 0 .8rem; color: #cbd8eb; border: 1px solid var(--line-strong); background: rgba(32,48,74,.8); font-size: .72rem; }
.raw-hint { display: grid; gap: .35rem; margin-top: 1rem; padding: .85rem; border: 1px solid rgba(93,140,255,.2); border-radius: .72rem; background: rgba(93,140,255,.07); }
.raw-hint strong { color: #b9ccff; font-size: .76rem; }
.raw-hint span { color: var(--muted); font-size: .7rem; line-height: 1.5; }
.confirm-modal { width: min(calc(100% - 2rem), 28rem); }

.toast {
  position: fixed;
  z-index: 20;
  right: 1.25rem;
  bottom: 1.25rem;
  max-width: min(24rem, calc(100% - 2.5rem));
  padding: .8rem 1rem;
  color: #e8f1ff;
  border: 1px solid var(--line-strong);
  border-radius: .72rem;
  background: rgba(18,34,58,.96);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: .22s ease;
  font-size: .76rem;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,100,124,.4); color: #ffadba; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .server-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; flex-direction: row; align-items: center; padding: .75rem 1rem; border-width: 0 0 1px; }
  .brand-row { padding: 0; }
  .brand-row span, .brand-row strong + span, .sidebar-foot { display: none; }
  nav { display: flex; margin-left: auto; }
  .nav-item { width: auto; padding: .65rem; font-size: 0; }
  .nav-item.active { box-shadow: inset 0 -2px 0 var(--blue); }
  .nav-icon { font-size: 1.1rem; }
  .workspace { padding: 1.2rem .9rem 3rem; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .service-pill { display: none; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-tools { width: 100%; }
  .search-box { min-width: 0; flex: 1; }
}

@media (max-width: 540px) {
  .login-card { padding: 1.6rem; }
  .topbar h1 { font-size: 1.55rem; }
  .topbar .eyebrow { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .stat-card { min-height: 8rem; padding: 1rem; }
  .stat-card strong { font-size: 1.5rem; }
  .stat-card small { font-size: .64rem; }
  .panel { padding: .85rem; }
  .panel-tools { align-items: stretch; flex-direction: column; }
  .primary { white-space: nowrap; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .qr-wrap { width: 11rem; height: 11rem; }
  .copy-row { grid-template-columns: 1fr; }
  .copy-row button { padding: .7rem; }
}
