*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f4f6fb;
  min-height: 100vh;
}

/* ─── Login ─────────────────────────────────────── */
body.login-body {
  background: #eaeaea;
}

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-form {
  background: #fff;
  border: 1px solid #d0d0d0;
  padding: 32px 28px;
  width: 100%;
  max-width: 320px;
}

.login-form .field {
  margin-bottom: 14px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #bbb;
  background: #fafafa;
  font-size: 14px;
  color: #333;
  outline: none;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
  border-color: #888;
  background: #fff;
}

.login-form button {
  width: 100%;
  padding: 9px;
  background-color: #3a6bc9;
  color: #fff;
  border: none;
  font-size: 14px;
  cursor: pointer;
  margin-top: 4px;
}

.login-form button:hover {
  background-color: #2f5db0;
}

.error-msg {
  background: #fff0f0;
  border: 1px solid #e0aaaa;
  color: #b00020;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ─── Navbar ─────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid #e5e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: #555;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: #f0f2f8;
  color: #1a1a2e;
}

.nav-link.active {
  background: #eef1fb;
  color: #3a6bc9;
  font-weight: 500;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-admin-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.nav-username {
  font-size: 13.5px;
  font-weight: 600;
  color: #1a1a2e;
}

.nav-role {
  font-size: 11px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.logout-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid #e0e3ed;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.logout-icon-btn:hover {
  background: #fff0f0;
  border-color: #f0b8b8;
  color: #c0392b;
}

/* ─── Page content ───────────────────────────────── */
.page-content {
  padding: 32px 36px;
}

.page-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.02em;
}

.page-count {
  font-size: 13px;
  color: #999;
}

/* ─── Table ──────────────────────────────────────── */
.table-card {
  background: #fff;
  border: 1px solid #e5e8f0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  table-layout: fixed;
}

/* Fixed column widths — table never reflows on content change */
.data-table th:nth-child(1) { width: 160px; } /* Username */
.data-table th:nth-child(2) { width: 200px; } /* Device ID */
.data-table th:nth-child(3) { width: 100px; } /* Status */
.data-table th:nth-child(4) { width: 90px;  } /* Type */
.data-table th:nth-child(5) { width: 170px; } /* Note */
.data-table th:nth-child(6) { width: 140px; } /* Last Seen */
.data-table th:nth-child(7) { width: 130px; } /* Traffic */

.data-table thead tr {
  background: #f8f9fc;
  border-bottom: 1px solid #e5e8f0;
}

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f2f8;
  color: #2a2a3e;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Hover only on actual data rows — not log/config/modal rows */
.data-table tbody tr.server-row:hover td,
.data-table tbody tr[data-id]:not(.server-row):hover td {
  background: #fafbff;
}

.row-banned td {
  opacity: 0.6;
}

.td-mono {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12.5px;
  color: #666;
}

.td-date {
  white-space: nowrap;
  color: #777;
  font-size: 13px;
}

.td-username {
  font-weight: 500;
}

.table-empty {
  text-align: center;
  color: #aaa;
  padding: 48px 16px;
}

/* ─── Status badges ──────────────────────────────── */
.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}

.status-active {
  background: #e6f9f0;
  color: #1a8a50;
}

.status-banned {
  background: #fde8e8;
  color: #c0392b;
}

.status-free {
  background: #eef2ff;
  color: #3a6bc9;
}

.status-premium {
  background: #fef9e7;
  color: #a06000;
}

/* ─── Inline editable cells ──────────────────────── */
.edit-cell,
.note-cell,
.ban-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
}

.cell-display {
  flex: 1;
}

/* ── All icon buttons: base style (hidden, but keep layout space via opacity) */
.cell-icon-btn {
  display: flex;          /* always in flow — no layout shift */
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 5px;
  border: 1px solid #e0e3ed;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.1s;
  /* invisible + non-interactive by default */
  opacity: 0;
  pointer-events: none;
}

/* ── Trigger icons: fade in on their own cell hover only */
.edit-cell:hover .edit-trigger,
.note-cell:hover .edit-trigger,
.note-cell:hover:not(.empty-note) .clear-trigger {
  opacity: 1;
  pointer-events: auto;
  color: #aaa;
}

.edit-trigger:hover,
.clear-trigger:hover {
  background: #f0f2f8;
  border-color: #d8dbe8;
  color: #444 !important;
}

/* ── Save / confirm: always green */
.save-btn,
.confirm-ban-btn,
.confirm-clear-btn {
  color: #1a8a50;
  border-color: #a8ddb8;
}

.save-btn:hover,
.confirm-ban-btn:hover,
.confirm-clear-btn:hover {
  background: #e8f7ee;
  border-color: #7acc9a;
  color: #146b3d;
}

/* ── Cancel: always red */
.cancel-btn,
.cancel-ban-btn,
.cancel-clear-btn {
  color: #c0392b;
  border-color: #f0b8b8;
}

.cancel-btn:hover,
.cancel-ban-btn:hover,
.cancel-clear-btn:hover {
  background: #fdeaea;
  border-color: #e08080;
  color: #9b2318;
}

/* ── Username editing state */
/* input: hidden by default, shown when editing */
.edit-cell .cell-input { display: none; flex: 1; }
/* save/cancel: in layout always, invisible until editing */
.edit-cell .save-btn,
.edit-cell .cancel-btn { opacity: 0; pointer-events: none; }

.edit-cell.is-editing .cell-display,
.edit-cell.is-editing .edit-trigger { display: none; }

.edit-cell.is-editing .cell-input { display: flex; }
.edit-cell.is-editing .save-btn,
.edit-cell.is-editing .cancel-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ── Note editing state */
.note-cell .cell-input  { display: none; flex: 1; }
.note-cell .save-btn,
.note-cell .cancel-btn  { opacity: 0; pointer-events: none; }
.note-cell .clear-confirm { display: none; }

.note-cell.is-editing .cell-display,
.note-cell.is-editing .edit-trigger,
.note-cell.is-editing .clear-trigger { display: none; }

.note-cell.is-editing .cell-input { display: flex; }
.note-cell.is-editing .save-btn,
.note-cell.is-editing .cancel-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ── Note clear confirm state */
.note-cell.is-confirming .cell-display,
.note-cell.is-confirming .edit-trigger,
.note-cell.is-confirming .clear-trigger { display: none; }

.note-cell.is-confirming .clear-confirm {
  display: flex;
  align-items: center;
  gap: 4px;
}

.note-cell.is-confirming .clear-confirm .cell-icon-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ── Ban confirm state */
.ban-cell .ban-confirm { display: none; }

.ban-cell.is-confirming .ban-toggle { display: none; }
.ban-cell.is-confirming .ban-confirm {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ban-cell.is-confirming .ban-confirm .cell-icon-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ── Ban toggle button */
.ban-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 20px;
}

.ban-toggle:hover .status-badge {
  filter: brightness(0.93);
}

/* ── Confirm label */
.confirm-label {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
}

/* ── Cell input */
.cell-input {
  min-width: 0;
  padding: 3px 7px;
  border: 1px solid #c0c8e0;
  border-radius: 5px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  outline: none;
}

.cell-input:focus {
  border-color: #3a6bc9;
  box-shadow: 0 0 0 2px rgba(58,107,201,0.12);
}

/* ── Note cell */
.td-note {
  max-width: 240px;
}

.note-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #555;
  font-size: 13px;
}

.note-empty {
  color: #ccc;
}

/* ─── Servers ─────────────────────────────────────── */

/* Column widths for servers table (6 cols) */
#servers-table th:nth-child(1) { width: 200px; } /* Name */
#servers-table th:nth-child(2) { width: 140px; } /* IP */
#servers-table th:nth-child(3) { width: 120px; } /* Visible */
#servers-table th:nth-child(4) { width: 130px; } /* Traffic */
#servers-table th:nth-child(5) { width: 160px; } /* Created */
#servers-table th:nth-child(6) { width: 52px;  } /* Actions */

.td-bold { font-weight: 500; }

.td-pubkey {
  font-size: 12px;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Setting up status — pulsing amber */
.status-setup {
  background: #fff8e6;
  color: #a06000;
  animation: pulse-amber 1.6s ease-in-out infinite;
}

@keyframes pulse-amber {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* Log row */
.log-row td {
  padding: 0;
  background: #1a1a2e;
}

.setup-log {
  margin: 0;
  padding: 14px 20px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #c8d0e0;
  background: #0a0f1a;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 280px;
  overflow-y: auto;
}

/* Actions column */
.td-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid #e0e3ed;
  background: none;
  cursor: pointer;
  color: #888;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}

.action-btn:hover {
  background: #f0f2f8;
  border-color: #c8ccdc;
  color: #333;
}

.action-btn.active {
  background: #eef1fb;
  border-color: #b0bcec;
  color: #3a6bc9;
}

/* ─── Config panel ───────────────────────────────── */
.config-row td {
  padding: 0;
  background: #0f1623;
}

.config-panel {
  display: flex;
  flex-direction: column;
}

.config-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid #1e2d45;
  font-size: 12px;
  color: #7a92b8;
}

.config-panel-actions {
  display: flex;
  gap: 8px;
}

.btn-copy-config,
.btn-dl-config {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.btn-copy-config {
  background: #1e3a5f;
  border: 1px solid #2a5080;
  color: #7ab8f5;
}

.btn-copy-config:hover { background: #264d7a; border-color: #3a6ba0; }

.btn-dl-config {
  background: transparent;
  border: 1px solid #2a3a50;
  color: #7a92b8;
}

.btn-dl-config:hover { background: #1a2a3a; border-color: #3a5070; }

.config-content {
  margin: 0;
  padding: 16px 20px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  line-height: 1.6;
  color: #a8d4a8;
  background: #0a0f1a;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-y: auto;
}

/* Delete cell inline confirm — reuses cell-icon-btn pattern */
.delete-cell {
  display: flex;
  align-items: center;
  gap: 5px;
}

.delete-cell .delete-confirm { display: none; align-items: center; gap: 4px; }
.delete-cell.is-confirming .delete-trigger { display: none; }
.delete-cell.is-confirming .delete-confirm {
  display: flex;
}
.delete-cell.is-confirming .delete-confirm .cell-icon-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Add Server form card ────────────────────────── */
.form-card {
  background: #fff;
  border: 1px solid #e5e8f0;
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.form-title {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 18px;
}

.country-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.country-chip {
  padding: 4px 9px;
  font-size: 12px;
  border: 1px solid #d0d4e0;
  border-radius: 20px;
  background: #f5f7fc;
  color: #333;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  font-family: inherit;
  line-height: 1.4;
}

.country-chip:hover {
  background: #e8edf8;
  border-color: #3a6bc9;
  color: #1a3070;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin-bottom: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-field input {
  padding: 8px 10px;
  border: 1px solid #d0d4e0;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafbff;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.form-field input:focus {
  border-color: #3a6bc9;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(58,107,201,0.12);
}

.form-error {
  background: #fff0f0;
  border: 1px solid #e0aaaa;
  color: #b00020;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-primary {
  padding: 8px 18px;
  background: #3a6bc9;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}

.btn-primary:hover  { background: #2f5db0; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  padding: 8px 14px;
  background: none;
  color: #666;
  border: 1px solid #d0d4e0;
  border-radius: 6px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.btn-ghost:hover {
  background: #f4f6fb;
  border-color: #b0b8cc;
}

.btn-danger {
  padding: 8px 18px;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}

.btn-danger:hover { background: #a93226; }

/* ─── Assign cell ────────────────────────────────── */
.assign-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
}

.assign-cell .cell-input { display: none; flex: 1; min-width: 80px; }
.assign-cell .save-btn,
.assign-cell .cancel-btn { opacity: 0; pointer-events: none; }

.assign-cell:hover .assign-trigger {
  opacity: 1;
  pointer-events: auto;
  color: #aaa;
}

.assign-cell.is-editing .assign-trigger { display: none; }
.assign-cell.is-editing .cell-input     { display: flex; }
.assign-cell.is-editing .save-btn,
.assign-cell.is-editing .cancel-btn     { opacity: 1; pointer-events: auto; }

/* ─── Modals ─────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eef0f6;
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.01em;
}

.modal-subtitle {
  font-size: 13px;
  color: #888;
  margin-top: 2px;
  font-family: "SF Mono", "Fira Code", monospace;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: #aaa;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  margin-top: -2px;
  flex-shrink: 0;
}

.modal-close-btn:hover { color: #444; }

/* ── Modal title inline edit ───────────────────────────────────────────── */

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.modal-title-edit-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s, background 0.12s;
}

.modal-title-wrap:hover .modal-title-edit-btn:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}

.modal-title-edit-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }

.modal-title-input {
  display: none;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 6px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 4px 10px;
  outline: none;
  min-width: 0;
  flex: 1;
  font-family: inherit;
}

.modal-title-input::placeholder { color: rgba(255,255,255,0.4); }
.modal-title-input:focus { border-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.18); }

.modal-title-action {
  display: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s;
}

.modal-name-save  { background: #43a047; color: #fff; }
.modal-name-save:hover  { background: #2e7d32; transform: scale(1.1); }
.modal-name-cancel { background: #e53935; color: #fff; }
.modal-name-cancel:hover { background: #b71c1c; transform: scale(1.1); }

/* editing state */
.modal-title-wrap.is-editing .modal-title      { display: none; }
.modal-title-wrap.is-editing .modal-title-edit-btn { display: none; }
.modal-title-wrap.is-editing .modal-title-input { display: flex; }
.modal-title-wrap.is-editing .modal-title-action { display: flex; }

/* ── Detail modal — modern dark header ─────────────────────────────────── */

.modal-detail .modal-header {
  background: linear-gradient(135deg, #1e3a7a 0%, #0f1e4a 100%);
  border-bottom: none;
  padding: 22px 24px 20px;
}

.modal-detail .modal-title {
  font-size: 17px;
  color: #fff;
}

.modal-detail .modal-subtitle {
  color: #90b8f0;
  margin-top: 4px;
}

.modal-detail .modal-close-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-size: 13px;
  color: #fff;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-top: 0;
}

.modal-detail .modal-close-btn:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

.modal-tabs {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  border-bottom: 1px solid #eef0f6;
  flex-shrink: 0;
}

.modal-tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}

.modal-tab:hover  { color: #444; }
.modal-tab.active { color: #3a6bc9; border-bottom-color: #3a6bc9; }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-top: 1px solid #eef0f6;
  flex-shrink: 0;
}

.modal-assign-bar {
  display: flex;
  gap: 8px;
  padding: 10px 24px;
  border-top: 1px solid #eef0f6;
  flex-shrink: 0;
}

.assign-bar-input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #d0d4e0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.assign-bar-input:focus {
  border-color: #3a6bc9;
  box-shadow: 0 0 0 2px rgba(58,107,201,0.12);
}

.delete-confirm-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.confirm-text {
  font-size: 13px;
  color: #888;
}

/* ── Keys list ──────────────────────────────────────────────────────────── */

.panel-loading {
  padding: 24px;
  color: #888;
  font-size: 13px;
}

/* ── Traffic column in users table ────────────────────────────────────── */

.td-traffic {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.traffic-rx {
  font-size: 12px;
  font-weight: 500;
  color: #2a7abf;
}

.traffic-tx {
  font-size: 12px;
  font-weight: 500;
  color: #2e7d32;
}

/* ── Stats panels (server peers + user per-server) ─────────────────────── */

.stats-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-total-card {
  background: #f5f8ff;
  border: 1px solid #dde6f7;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-total-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b8dd6;
}

.stat-total-value {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
}

.stat-total-value.rx { color: #2a7abf; }
.stat-total-value.tx { color: #2e7d32; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b8dd6;
  padding: 6px 10px;
  border-bottom: 1px solid #eef0f6;
}

.stats-table tbody tr:hover { background: #f8faff; }

.stats-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f2f8;
  vertical-align: middle;
}

.stats-table tbody tr:last-child td { border-bottom: none; }

.stats-username {
  display: block;
  font-weight: 600;
  color: #1a1a2e;
  font-size: 13px;
}

.stats-device {
  display: block;
  font-size: 11px;
  color: #888;
  font-family: "SF Mono", "Fira Code", monospace;
}

.stats-handshake {
  color: #666;
  font-size: 12px;
}

.key-item {
  border-bottom: 1px solid #eef0f6;
}

.key-item:last-child {
  border-bottom: none;
}

.key-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  gap: 12px;
}

.key-server-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.key-server-name {
  font-weight: 600;
  font-size: 13px;
  color: #1a1a2e;
  white-space: nowrap;
}

.key-server-ip {
  font-size: 12px;
  color: #888;
  font-family: "SF Mono", "Fira Code", monospace;
  white-space: nowrap;
}

.key-copy-btn {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 4px;
  background: #f0f4ff;
  border: 1px solid #c5d0ee;
  color: #2a4a9f;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.1s;
}

.key-copy-btn:hover {
  background: #dce6ff;
}

.key-config {
  margin: 0;
  padding: 10px 20px 14px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 10.5px;
  line-height: 1.55;
  color: #a8d4a8;
  background: #0a0f1a;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Visibility toggle ─────────────────────────────────────────────────── */

.modal-text {
  font-size: 14px;
  color: #444;
  line-height: 1.6;
}

/* Info panel layout */
.info-section {
  margin-bottom: 16px;
}

.info-section:last-child { margin-bottom: 0; }

.info-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #aaa;
  margin-bottom: 10px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

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

.info-item {
  background: #f5f8ff;
  border: 1px solid #dde6f7;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-item.item-success {
  background: #f0faf4;
  border-color: #a8dbb8;
}

.info-item.item-success .info-label { color: #3a9e5f; }
.info-item.item-success .info-value  { color: #1f6b3a; font-weight: 700; }

.info-item.item-warning {
  background: #fffbf0;
  border-color: #f0d080;
}

.info-item.item-warning .info-label { color: #b88a20; }
.info-item.item-warning .info-value  { color: #7a5800; }

.info-item-wide {
  grid-column: span 2;
}

.info-item-full {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.info-item-vis {
  margin-top: 4px;
  background: #f5f8ff;
  border: 1px solid #dde6f7;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b8dd6;
}

.info-item-vis .info-label {
  min-width: 70px;
  flex-shrink: 0;
}

.info-value {
  font-size: 13.5px;
  font-weight: 600;
  color: #1a1a2e;
}

.info-value.mono {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11.5px;
  font-weight: 400;
  word-break: break-all;
  color: #3a4a6e;
}

/* ── AWG dark section ──────────────────────────────────────────────────── */

.awg-section {
  background: #0f1a2e;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 8px;
}

.awg-section .info-section-title { color: #5a9ff0; margin-bottom: 10px; }

.awg-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.awg-section .info-item {
  background: #162135;
  border-color: #1e3050;
  padding: 7px 10px;
}

.awg-section .info-label { color: #5a9ff0; }
.awg-section .info-value { color: #a0c8ff; font-size: 13px; font-weight: 600; }
.awg-section .info-value.mono { color: #6ddb90; font-size: 10px; font-weight: 400; }

/* ── Visibility select (table + modal) ────────────────────────────────── */

.vis-select {
  padding: 4px 8px;
  border: 1px solid #dde3f0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #3a4a6e;
  background: #f8f9fc;
  cursor: pointer;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}

.vis-select:hover  { border-color: #b0bfe8; background: #f0f4ff; }
.vis-select:focus  { border-color: #7a9de0; background: #fff; }
.vis-select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Config panel inside modal */
.modal-body .config-panel {
  margin: -20px -24px;
}

.modal-body .config-panel-header {
  padding: 12px 20px;
  border-bottom: 1px solid #1e2d45;
  font-size: 12px;
  color: #7a92b8;
  background: #0f1623;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body .config-panel-actions {
  display: flex;
  gap: 8px;
}

.modal-body .config-panel-actions button {
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}

#modal-copy-config {
  background: #1e3a5f;
  border: 1px solid #2a5080;
  color: #7ab8f5;
}

#modal-copy-config:hover { background: #264d7a; }

#modal-dl-config {
  background: transparent;
  border: 1px solid #2a3a50;
  color: #7a92b8;
}

#modal-dl-config:hover { background: #1a2a3a; }

/* ── Users search & pagination ───────────────────────────────────────────── */

.users-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 360px;
  margin: 0 12px;
}

.users-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa5c0;
  display: flex;
  pointer-events: none;
}

.users-search-input {
  flex: 1;
  min-width: 0;
  padding: 7px 30px 7px 32px;
  border: 1px solid #dde3f0;
  border-right: none;
  border-radius: 7px 0 0 7px;
  font-size: 13px;
  color: #2a3a5a;
  background: #f8f9fc;
  outline: none;
}
.users-search-input:focus { border-color: #7a9de0; background: #fff; }

.users-search-clear {
  position: absolute;
  right: 76px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #9aa5c0;
  cursor: pointer;
  display: flex;
  padding: 2px;
  line-height: 1;
}
.users-search-clear:hover { color: #3a4a7a; }

.users-search-btn {
  padding: 7px 14px;
  background: #1a3a6e;
  color: #fff;
  border: 1px solid #1a3a6e;
  border-radius: 0 7px 7px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.users-search-btn:hover { background: #22508a; border-color: #22508a; }

.users-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid #f0f2f8;
}

.pagination-info {
  font-size: 12px;
  color: #9aa5c0;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #dde3f0;
  background: #fff;
  color: #4a5a8a;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
  line-height: 1;
}
.page-btn:hover:not(:disabled) { background: #f0f4ff; border-color: #b0bfe8; }
.page-btn.active { background: #1a3a6e; border-color: #1a3a6e; color: #fff; pointer-events: none; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-ellipsis { color: #9aa5c0; font-size: 13px; padding: 0 2px; }

/* ── Stats Page ──────────────────────────────────────────────────────────── */

.sp-wrap { display: flex; flex-direction: column; gap: 20px; }

/* Range bar */
.sp-range-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  border: 1px solid #e5e9f4;
  border-radius: 10px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.sp-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sp-preset {
  padding: 5px 13px;
  border: 1px solid #dde3f0;
  background: transparent;
  color: #5a6a8a;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.sp-preset:hover { background: #f0f4ff; border-color: #b0bfe8; color: #3a4a7a; }
.sp-preset.active { background: #1a3a6e; border-color: #1a3a6e; color: #fff; }

.sp-range-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sp-range-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sp-range-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa5c0;
}

.sp-dt {
  padding: 6px 10px;
  border: 1px solid #dde3f0;
  border-radius: 6px;
  font-size: 12.5px;
  color: #2a3a5a;
  background: #f8f9fc;
  outline: none;
  cursor: pointer;
}
.sp-dt:focus { border-color: #7a9de0; background: #fff; }

.sp-range-arrow { color: #b0bfe8; font-size: 16px; margin-top: 14px; }

.sp-apply {
  margin-top: 14px;
  padding: 6px 16px;
  background: #1a3a6e;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.sp-apply:hover { background: #22508a; }

/* KPI grid */
.sp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.sp-kpi {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e9f4;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-left: 3px solid var(--kpi-c);
}

.sp-kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--kpi-bg);
  color: var(--kpi-c);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sp-kpi-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa5c0;
  margin-bottom: 4px;
}

.sp-kpi-val {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
}

.sp-kpi--users { --kpi-c: #f59e0b; --kpi-bg: #fffbeb; }
.sp-kpi--rx    { --kpi-c: #0ea5e9; --kpi-bg: #f0f9ff; }
.sp-kpi--tx    { --kpi-c: #10b981; --kpi-bg: #f0fdf4; }
.sp-kpi--total { --kpi-c: #8b5cf6; --kpi-bg: #f5f3ff; }

/* Tabs */
.sp-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e8ecf4;
}

.sp-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #8a96b0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.12s, border-color 0.12s;
}
.sp-tab:hover { color: #3a4a7a; }
.sp-tab.active { color: #1a3a6e; border-bottom-color: #1a3a6e; }

.sp-rx { color: #0ea5e9; font-weight: 500; }
.sp-tx { color: #10b981; font-weight: 500; }

.sp-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sp-sortable:hover { color: #1a3a6e; }
.sp-sorted { color: #1a3a6e; }
.sp-sort-icon { font-style: normal; }

/* ── User modal stats tab ─────────────────────────────────────────────────── */

.us-range-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: #f8f9fc;
  border: 1px solid #e5e9f4;
  border-radius: 8px;
  margin-bottom: 12px;
}

.us-presets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.us-preset {
  padding: 4px 11px;
  border: 1px solid #dde3f0;
  background: #fff;
  color: #5a6a8a;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.us-preset:hover { background: #f0f4ff; border-color: #b0bfe8; }
.us-preset.active { background: #1a3a6e; border-color: #1a3a6e; color: #fff; }

.us-range-inputs {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.us-dt {
  padding: 5px 8px;
  border: 1px solid #dde3f0;
  border-radius: 6px;
  font-size: 11.5px;
  color: #2a3a5a;
  background: #fff;
  outline: none;
  flex: 1;
  min-width: 140px;
}
.us-dt:focus { border-color: #7a9de0; }

.us-arrow { color: #b0bfe8; font-size: 14px; }

.us-apply {
  padding: 5px 12px;
  background: #1a3a6e;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.us-apply:hover { background: #22508a; }

.us-kpis {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.us-kpi {
  flex: 1;
  background: #f8f9fc;
  border: 1px solid #e5e9f4;
  border-radius: 7px;
  border-left: 3px solid var(--kpi-c);
  padding: 10px 14px;
}

.us-kpi-lbl {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa5c0;
  margin-bottom: 3px;
}

.us-kpi-val {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.us-kpi--rx    { --kpi-c: #0ea5e9; }
.us-kpi--tx    { --kpi-c: #10b981; }
.us-kpi--total { --kpi-c: #8b5cf6; }

.us-traffic-table { margin-top: 0; }

/* ── Account tier management (user modal info tab) ───────────────────────── */

.tier-mgmt {
  border-top: 1px solid #eef0f6;
  padding-top: 14px;
}

.tier-mgmt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tier-mgmt-row:last-child { margin-bottom: 0; }

.tier-mgmt-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7a9e;
  min-width: 120px;
  flex-shrink: 0;
}

.tier-date-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d0d4e0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafbff;
  outline: none;
}

.tier-date-input:focus {
  border-color: #3a6bc9;
  box-shadow: 0 0 0 2px rgba(58,107,201,0.12);
}

.tier-num-input {
  width: 120px;
  padding: 6px 10px;
  border: 1px solid #d0d4e0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafbff;
  outline: none;
}

.tier-num-input:focus {
  border-color: #3a6bc9;
  box-shadow: 0 0 0 2px rgba(58,107,201,0.12);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12.5px;
}
