:root {
  --bg: #0b0f17;
  --panel: #131926;
  --panel-border: #232c3d;
  --text: #e6edf7;
  --muted: #8b98b0;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 24px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-live {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.35);
}

.badge-connecting {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.35);
}

.badge-offline {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.35);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
}

.text-green {
  color: var(--green);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--panel-border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

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

.search-wrap input {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  width: 280px;
  max-width: 100%;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--primary);
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-up {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
}

.status-stopped {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
}

.status-offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
}

.client-in-use {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
}

.client-recent {
  background: rgba(34, 197, 94, 0.14);
  color: var(--green);
}

.client-idle {
  background: rgba(139, 152, 176, 0.14);
  color: var(--muted);
}

.client-ips {
  display: block;
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.endpoint-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #0b0f17;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  font-size: 0.84rem;
}

.btn {
  border: 1px solid var(--panel-border);
  background: #1b2434;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
}

.btn:hover {
  background: #253147;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-success {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

.actions-cell {
  display: flex;
  gap: 6px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1e293b;
  color: var(--text);
  border: 1px solid var(--panel-border);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 14px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.modal-field label {
  font-size: 0.8rem;
  color: var(--muted);
}

.modal-field input {
  background: #0b0f17;
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  outline: none;
}

.modal-field input:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.col-check {
  width: 36px;
  text-align: center;
}

.proxy-select-cb,
#selectAllCheckbox {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
