:root {
  --ink: #1e252b;
  --muted: #68747d;
  --panel: #ffffff;
  --panel-strong: #f4f6f7;
  --line: #dfe4e7;
  --green: #d93817;
  --green-strong: #bd2d11;
  --amber: #d78327;
  --red: #b42318;
  --navy: #1d272f;
  --shadow: 0 16px 42px rgba(21, 31, 38, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: #edf0f2;
  font-family: "Segoe UI", Inter, Arial, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(90px);
  pointer-events: none;
}

.ambient-one {
  width: 360px;
  height: 360px;
  top: -180px;
  right: 12%;
  background: rgba(69, 207, 168, 0.12);
}

.ambient-two {
  width: 280px;
  height: 280px;
  bottom: -140px;
  left: 20%;
  background: rgba(38, 103, 96, 0.18);
}

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

.login-card {
  width: min(440px, 100%);
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(145deg, rgba(27, 38, 47, 0.98), rgba(14, 22, 28, 0.98));
  box-shadow: var(--shadow);
}
.login-card .muted { color: #b7c1c8; }

.brand-logo {
  display: block;
  object-fit: contain;
}
.login-logo {
  width: 190px;
  height: auto;
  margin-bottom: 28px;
  filter: brightness(0) invert(1);
}
.sidebar-logo {
  width: 116px;
  height: auto;
  filter: brightness(0) invert(1);
}

.eyebrow, .panel-kicker {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 5vw, 2.65rem); letter-spacing: -0.05em; }
h2 { margin-bottom: 0; font-size: 1.75rem; letter-spacing: -0.035em; }
h3 { margin-bottom: 0; font-size: 1.13rem; }
.muted { color: var(--muted); line-height: 1.6; }

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 30px;
}

label { color: #36434c; font-size: 0.84rem; font-weight: 700; }
.login-card label { color: #e8edf0; }

input {
  width: 100%;
  margin-top: 8px;
  padding: 13px 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #fff;
}

input:focus { border-color: rgba(217, 56, 23, 0.7); box-shadow: 0 0 0 3px rgba(217, 56, 23, 0.10); }

.login-form button, .primary-button {
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #e04421, #c82f12);
  font-weight: 800;
}

.login-form button { margin-top: 8px; }
.microsoft-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  color: #10211e !important;
  background: #f4f8f7 !important;
}
.microsoft-logo {
  display: grid;
  grid-template-columns: 8px 8px;
  grid-template-rows: 8px 8px;
  gap: 2px;
}
.microsoft-logo i:nth-child(1) { background: #f25022; }
.microsoft-logo i:nth-child(2) { background: #7fba00; }
.microsoft-logo i:nth-child(3) { background: #00a4ef; }
.microsoft-logo i:nth-child(4) { background: #ffb900; }
.login-hint { margin: 5px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.5; text-align: center; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 0.82rem; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #222d35, #151e25);
  backdrop-filter: blur(18px);
}

.sidebar-brand { display: grid; gap: 9px; margin: 0 8px 38px; }
.sidebar-brand strong { display: block; letter-spacing: 0.08em; }
.sidebar-brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 0.76rem; }
.sidebar-brand strong { color: #fff; }
.sidebar-brand span { color: #aeb8bf; }

nav { display: grid; gap: 7px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-item:hover, .nav-item.active {
  color: #fff;
  border-color: rgba(255,255,255,.1);
  background: rgba(217, 56, 23, 0.18);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--green);
  background: rgba(217, 56, 23, 0.18);
  font-size: 0.65rem;
}

.server-pill { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.server-pill strong, .server-pill span { display: block; }
.server-pill strong { color: #fff; font-size: 0.78rem; }
.server-pill span { margin-top: 3px; color: var(--muted); font-size: 0.7rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 14px var(--green); }
.logout-button { width: 100%; margin-top: 9px; padding: 10px; color: var(--muted); border: 0; background: transparent; }

.main-content { min-width: 0; padding: 34px 38px 50px; background: #f4f6f7; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.updated-at { color: var(--muted); font-size: 0.75rem; }
.icon-button, .secondary-button {
  padding: 12px 15px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
}
.metric-card::after {
  content: "";
  position: absolute;
  width: 90px;
  height: 90px;
  right: -28px;
  bottom: -38px;
  border-radius: 50%;
  background: rgba(217, 56, 23, 0.06);
}
.metric-label { color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.metric-value { display: block; margin: 13px 0 6px; font-size: 2rem; letter-spacing: -0.05em; }
.metric-note { color: var(--muted); font-size: 0.72rem; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr); gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.live-badge { padding: 7px 10px; border-radius: 999px; color: var(--green); background: rgba(217, 56, 23, 0.09); font-size: 0.7rem; font-weight: 800; }

.connection-list { min-height: 300px; }
.connection-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 17px 22px; border-bottom: 1px solid rgba(156, 205, 195, 0.09); }
.connection-row:last-child { border-bottom: 0; }
.client-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #e04421, #bd2d11); font-weight: 900; }
.connection-name strong, .connection-name span { display: block; }
.connection-name span { margin-top: 4px; color: var(--muted); font-size: 0.73rem; }
.connection-ip { color: #46545d; font-family: Consolas, monospace; font-size: 0.78rem; }
.online-chip, .status-chip { padding: 7px 10px; border-radius: 999px; font-size: 0.68rem; font-weight: 800; }
.online-chip, .status-active { color: #177245; background: rgba(23, 114, 69, 0.10); }
.status-revoked { color: var(--red); background: rgba(233, 121, 121, 0.09); }
.empty-state { padding: 70px 24px; color: var(--muted); text-align: center; line-height: 1.6; }

.network-panel { overflow: hidden; }
.network-visual { position: relative; height: 230px; display: grid; place-items: center; overflow: hidden; }
.network-ring { position: absolute; border: 1px solid rgba(100, 214, 181, 0.14); border-radius: 50%; }
.ring-large { width: 220px; height: 220px; }
.ring-small { width: 140px; height: 140px; }
.server-node { z-index: 2; width: 108px; height: 108px; display: grid; place-content: center; text-align: center; border: 1px solid rgba(217, 56, 23, 0.34); border-radius: 50%; background: radial-gradient(circle, #fff, #eef1f3); box-shadow: 0 0 38px rgba(217, 56, 23, 0.12); }
.server-node span { color: var(--green); font-size: 0.68rem; font-weight: 900; }
.server-node strong { margin-top: 6px; font-size: 0.86rem; }
.client-node { position: absolute; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--green); background: #fff; font-size: 0.69rem; font-weight: 800; }
.node-a { top: 25px; right: 55px; }
.node-b { bottom: 24px; left: 64px; }
.node-c { bottom: 18px; right: 46px; }
.network-details { margin: 0; padding: 0 22px 20px; }
.network-details div { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid rgba(156, 205, 195, 0.09); }
.network-details dt { color: var(--muted); font-size: 0.73rem; }
.network-details dd { margin: 0; color: #34414a; font-family: Consolas, monospace; font-size: 0.73rem; }

.table-header { align-items: flex-end; }
.search-input { width: 220px; margin: 0; padding: 10px 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 20px; border-bottom: 1px solid rgba(156, 205, 195, 0.09); text-align: left; font-size: 0.8rem; }
th { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.09em; text-transform: uppercase; }
td { color: #34414a; }
.client-table-name strong, .client-table-name span { display: block; }
.client-table-name span { margin-top: 4px; color: var(--muted); font-size: 0.7rem; }
.actions-column { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.action-button { padding: 8px 10px; color: #bcd3cd; border: 1px solid var(--line); border-radius: 9px; background: transparent; font-size: 0.7rem; }
.action-button.danger { color: var(--red); }

.activity-list { padding: 4px 22px 18px; }
.activity-item { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 13px; align-items: start; padding: 16px 0; border-bottom: 1px solid rgba(156, 205, 195, 0.09); }
.activity-bullet { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--green); }
.activity-message { margin: 0; color: #34414a; font-size: 0.8rem; }
.activity-time { color: var(--muted); font-size: 0.68rem; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 22px; background: rgba(0, 8, 9, 0.72); backdrop-filter: blur(10px); }
.modal { width: min(520px, 100%); border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.compact-modal { width: min(440px, 100%); }
.modal-header { display: flex; justify-content: space-between; padding: 22px; border-bottom: 1px solid var(--line); }
.close-button { width: 34px; height: 34px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; background: transparent; }
.client-form { display: grid; gap: 17px; padding: 22px; }
.client-form small { display: block; margin-top: 6px; color: var(--muted); font-size: 0.68rem; font-weight: 400; }
.ip-field { display: flex; align-items: center; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.ip-field span { padding-left: 14px; color: #46545d; font-family: Consolas, monospace; }
.ip-field input { margin: 0; border: 0; background: transparent; }
.warning-box { padding: 12px 14px; border: 1px solid rgba(240, 180, 92, 0.22); border-radius: 12px; color: #e8c994; background: rgba(240, 180, 92, 0.07); font-size: 0.74rem; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 360px; padding: 13px 16px; border: 1px solid rgba(217, 56, 23, 0.25); border-radius: 12px; color: #fff; background: #27333b; box-shadow: var(--shadow); font-size: 0.8rem; }
.toast.error { border-color: rgba(233, 121, 121, 0.3); background: #392020; }

@media (max-width: 1050px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-brand { margin-bottom: 16px; }
  nav { grid-template-columns: repeat(3, 1fr); }
  .nav-item { justify-content: center; font-size: 0.72rem; }
  .nav-icon { display: none; }
  .sidebar-footer { display: none; }
  .main-content { padding: 24px 16px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .updated-at { width: 100%; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .connection-row { grid-template-columns: 42px minmax(0, 1fr) auto; }
  .connection-ip { display: none; }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .login-card { padding: 30px 24px; }
  .primary-button, .icon-button { flex: 1; }
}
