:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sidebar-bg: #1a1d27;
  --sidebar-text: #c9d1e0;
  --sidebar-hover: #252836;
  --sidebar-active: #2d3045;
  --accent: #7aa2f7;
  --accent-h: #5d87e8;
  --danger: #f7768e;
  --danger-h: #d95f77;
  --success: #9ece6a;
  --text: #1a1d27;
  --muted: #64748b;
  --border: #e2e8f0;
  --r: 6px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 18px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
}
.header h1 { font-size: 15px; font-weight: 600; letter-spacing: .03em; }
.header-meta { font-size: 12px; opacity: .55; }

/* ── Layout ── */
.layout { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 210px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,.05);
}
.sidebar-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.sidebar-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; opacity: .4; }

.client-list { list-style: none; overflow-y: auto; flex: 1; }
.client-list:empty::after {
  content: 'No clients';
  display: block;
  padding: 14px 12px;
  font-size: 12px;
  opacity: .35;
}

.cli-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background .1s;
  user-select: none;
}
.cli-item:hover { background: var(--sidebar-hover); }
.cli-item.active { background: var(--sidebar-active); }
.cli-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #3d4155;
  flex-shrink: 0;
  transition: background .2s;
}
.cli-dot.on { background: var(--success); }
.cli-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Content ── */
.content { flex: 1; overflow-y: auto; padding: 22px 26px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  gap: 10px;
}
.empty-icon { font-size: 40px; }
.empty-state p { font-size: 13px; }

/* ── Detail ── */
.detail { display: flex; flex-direction: column; gap: 18px; }
.detail-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.detail-hd h2 { font-size: 20px; margin-bottom: 6px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #e2e8f0;
  color: var(--muted);
}
.badge.on { background: #dcfce7; color: #15803d; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-hd { display: flex; align-items: center; justify-content: space-between; }
.card-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card-title { font-size: 13px; font-weight: 600; }

.token-row { display: flex; align-items: center; gap: 8px; }
.token {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 9px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.hint code { font-family: monospace; background: #f1f5f9; padding: 1px 4px; border-radius: 3px; }

/* ── Table ── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #f8fafc; }

.port-tag {
  display: inline-block;
  font-family: monospace;
  font-size: 12.5px;
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  padding: 2px 7px;
  border-radius: 4px;
}

/* ── Add tunnel form ── */
.add-row {
  display: flex;
  gap: 7px;
  padding-top: 10px;
  flex-wrap: wrap;
}
.add-row input {
  flex: 1;
  min-width: 120px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.add-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(122,162,247,.15); }

/* ── Code block ── */
.codeblock {
  position: relative;
  background: #1a1d27;
  border-radius: 4px;
}
.codeblock pre {
  color: #c9d1e0;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 11px 14px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  padding-right: 70px;
}
.copy-pre {
  position: absolute;
  top: 6px;
  right: 6px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 13px;
  border: none;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s;
}
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-h); }
.btn-icon { background: none; color: var(--muted); padding: 3px 7px; border-radius: 4px; }
.btn-icon:hover { background: #fee2e2; color: var(--danger); }

/* ── Modal ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-box {
  background: var(--surface);
  border-radius: 8px;
  padding: 22px 24px;
  width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-box h3 { font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.field input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.hidden { display: none !important; }
