@import url("https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Fira+Sans:wght@400;500;600;700&display=swap");
:root {
  color-scheme: dark;
  --bg: #0b0f1a;
  --surface: #121826;
  --surface-2: #1a2234;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --muted: #8b93a7;
  --accent: #22c55e;
  --accent-ink: #052e16;
  --danger: #ff453a;
  --danger-bg: #3a1515;
  --radius: 12px;
  --pad-x: clamp(16px, 2.5vw, 32px);
  --font: "Fira Sans", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --mono: "Fira Code", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: 180ms ease;
}
* { box-sizing: border-box; }
body {
  font: 14px/1.45 var(--font);
  margin: 0; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button, a, .seg-btn, .sort-btn, .filter-btn, summary { cursor: pointer; }
button, .seg-btn, .sort-btn, .filter-btn, .icon-btn, select, input {
  transition: background var(--ease), color var(--ease), border-color var(--ease), opacity var(--ease);
}
header {
  display: flex; gap: 12px; align-items: center;
  padding: 10px var(--pad-x);
  background: rgba(18, 24, 38, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
@media (prefers-reduced-motion: reduce) {
  button, .seg-btn, .sort-btn, .filter-btn, .icon-btn, select, input { transition: none; }
}
.brand {
  display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 650;
  font-size: 15px; letter-spacing: -.01em;
}
.brand .logo { height: 32px; width: auto; display: block; object-fit: contain; filter: brightness(1.12); }
.nav-link { color: var(--muted); font-size: 13px; }
.nav-link:hover { color: var(--text); }
.nav-main {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  background: transparent;
}
.nav-item svg { flex-shrink: 0; opacity: 0.9; }
.nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}
.nav-item.on {
  color: var(--text);
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
}
.nav-item.on svg { color: var(--accent); }
.vpn-pick { display: flex; align-items: center; gap: 8px; }
.seg, .sort-seg, .filter-seg {
  display: inline-flex; gap: 0;
  border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
  background: var(--surface-2);
}
.seg-btn, .sort-btn, .filter-btn {
  background: transparent; border: 0; border-radius: 0;
  padding: 7px 12px; color: var(--muted); font: inherit; cursor: pointer;
}
.seg-btn { min-width: 3.6em; font-weight: 600; }
.seg-btn.on, .sort-btn.on, .filter-btn.on {
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #333; }
.who .name { font-size: 13px; font-weight: 600; }
.who .host { color: var(--muted); font-size: 11px; }
.who .role { color: var(--accent); font-size: 11px; }

button, select, input, textarea {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; font: inherit;
}
button { cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.danger { background: var(--danger-bg); border-color: #833; color: #ffb4ae; }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--surface-2); }

main { padding: 16px var(--pad-x) 48px; width: 100%; max-width: 960px; }
body.people main {
  max-width: none;
  padding: 18px var(--pad-x) 56px;
}

.sticky-bar {
  position: sticky; top: 52px; z-index: 15;
  margin: 0 calc(-1 * var(--pad-x)) 16px;
  padding: 14px var(--pad-x) 16px;
  background: rgba(11, 15, 26, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.control-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.control-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}
.control-search #q {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--surface);
}
.control-search #q:focus {
  outline: 2px solid rgba(34, 197, 94, 0.35);
  border-color: rgba(34, 197, 94, 0.55);
}
.icon-btn {
  width: 42px; height: 42px; padding: 0;
  display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); font-size: 16px;
}
.icon-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.16); }

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: end;
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.control-group-grow { flex: 1 1 220px; }
.control-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.control-group select {
  min-height: 38px;
  min-width: 180px;
  width: 100%;
  max-width: 320px;
}
.control-count {
  margin-left: auto;
  align-self: center;
  font-variant-numeric: tabular-nums;
  padding-bottom: 6px;
}

.control-issue {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  align-items: center;
}
.plan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.plan-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 132px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
}
.plan-chip:hover { border-color: rgba(255,255,255,0.18); }
.plan-chip.on {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.25);
}
.plan-chip-title { font-size: 13px; font-weight: 650; line-height: 1.2; }
.plan-chip-meta { font-size: 11px; color: var(--muted); line-height: 1.3; }
.plan-chip.on .plan-chip-title { color: var(--accent); }
.talk-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 4px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}
.talk-switch input { accent-color: var(--accent); width: 16px; height: 16px; }
.talk-ico { width: 18px; height: 18px; display: block; color: #5bbcff; flex-shrink: 0; }
.icon-act {
  box-sizing: border-box;
  position: relative;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  vertical-align: middle;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  flex: 0 0 40px;
  color: var(--text);
}
.icon-act:hover {
  border-color: rgba(255,255,255,0.18);
  background: #222a3c;
  color: #fff;
  z-index: 5;
}
.icon-act .ico {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}
.icon-act[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(2px);
  padding: 5px 8px;
  border-radius: 6px;
  background: #0a0e18;
  border: 1px solid rgba(255,255,255,0.12);
  color: #f5f5f7;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms;
  z-index: 30;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.icon-act[data-tip]:hover::after,
.icon-act[data-tip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.talk-act {
  background: rgba(0, 130, 201, 0.18);
  border-color: rgba(0, 130, 201, 0.45);
  color: #7ec8f0;
}
.talk-act:hover {
  background: #0082c9;
  border-color: #0082c9;
  color: #fff;
  filter: none;
}
.danger-act {
  background: var(--danger-bg);
  border-color: rgba(255, 69, 58, 0.35);
  color: #ff8a82;
  font-size: inherit;
  font-weight: inherit;
}
.danger-act:hover {
  background: #5a1a18;
  border-color: #ff453a;
  color: #ffb4ae;
  filter: none;
}
.warn-act {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}
.warn-act:hover {
  background: rgba(245, 158, 11, 0.28);
  border-color: #f59e0b;
  color: #fde68a;
  filter: none;
}
.on-act {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.4);
  color: #4ade80;
}
.on-act:hover {
  background: rgba(34, 197, 94, 0.28);
  border-color: #22c55e;
  color: #bbf7d0;
  filter: none;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}
.status-pill.online {
  background: rgba(34, 197, 94, 0.22);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.5);
}
.status-pill.online .dot {
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
  animation: online-pulse 1.6s ease-out infinite;
}
@keyframes online-pulse {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}
.status-pill.idle {
  background: rgba(139, 147, 167, 0.12);
  color: var(--muted);
  border: 1px solid var(--line);
}
.status-pill.off {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.person-traf .created {
  display: block;
  font-size: 11px;
  margin-top: 2px;
}
.person.key-off {
  opacity: 0.72;
}
.person.key-off .person-name b {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(251, 191, 36, 0.7);
}
.person.is-online {
  border-color: rgba(34, 197, 94, 0.28);
}
.sync-btn { min-height: 40px; white-space: nowrap; }

.muted { color: var(--muted); font-size: 12px; }
.err { color: #ff6961; }
.okmsg { color: var(--accent); }
.empty { padding: 40px 12px; text-align: center; }

.people-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.person {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px 24px;
  align-items: center;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow: visible;
}
.person.has-key { border-color: rgba(34, 197, 94, 0.28); }
.person:hover { border-color: rgba(255, 255, 255, 0.14); }
.person.has-key:hover { border-color: rgba(34, 197, 94, 0.45); }
.person-main { min-width: 0; }
.person-top { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.person-name { font-size: 15px; letter-spacing: -.01em; }
.person-name .uid { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 400; }
.person-traf { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.person-keys { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.person-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  align-self: center;
  flex-shrink: 0;
  overflow: visible;
}
.person-actions .issue { min-height: 40px; padding: 8px 14px; font-weight: 650; }
.pill {
  display: inline-block; background: #2a2a30; border-radius: 999px;
  padding: 2px 8px; font-size: 11px; font-weight: 600;
}
.pill.vpn { background: #1c2e24; color: #8d8; }
.pill.on { background: var(--accent); color: var(--accent-ink); }
.plan-tag {
  font-size: 11px; color: var(--muted); margin-left: 4px;
}
.no { color: #636366; }
.groups-more { margin-top: 4px; }
.groups-more summary {
  cursor: pointer; list-style: none; font-size: 11px; color: var(--muted);
}
.groups-more summary::-webkit-details-marker { display: none; }
.groups-more summary::before { content: "▸ "; }
.groups-more[open] summary::before { content: "▾ "; }
.groups-full { margin-top: 4px; font-size: 11px; line-height: 1.35; }

dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  max-width: 720px; width: 90vw; padding: 16px;
}
pre {
  white-space: pre-wrap; word-break: break-all;
  background: #0a0a0b; padding: 10px; border-radius: 8px;
  font: 12px/1.4 var(--mono);
}

/* settings page leftovers */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; max-width: 720px; }
.card.wide { max-width: 960px; }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.card h3 { font-size: 13px; margin: 16px 0 8px; color: #bbb; font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; align-items: center; }
.row input { flex: 1; min-width: 180px; }
.fields { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; align-items: start; margin: 8px 0 14px; }
.fields.compact { grid-template-columns: 100px 1fr; gap: 6px 10px; margin: 10px 0; }
.fields label { color: var(--muted); font-size: 12px; padding-top: 8px; }
.fields input, .fields textarea { width: 100%; }
.fields textarea { min-height: 72px; resize: vertical; }
.talk-editor { margin: 12px 0 14px; }
.talk-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.talk-editor-head label { color: var(--muted); font-size: 12px; font-weight: 500; }
.ghost-btn {
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.ghost-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.16); }
.ghost-btn.ok { color: var(--accent); border-color: rgba(34, 197, 94, 0.4); }
#v-direct.talk-direct,
textarea.talk-direct {
  width: 100%;
  min-height: 320px;
  max-height: none;
  height: min(42vh, 420px);
  font: 13px/1.45 var(--mono);
  resize: vertical;
}
#talk-box > summary { cursor: pointer; list-style: none; margin-bottom: 10px; }
#talk-box > summary::-webkit-details-marker { display: none; }
#talk-box > summary::before { content: "▸ "; color: var(--muted); }
#talk-box[open] > summary::before { content: "▾ "; }
.nc-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; background: #121214; }
.nc-block .nc-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.nc-block .nc-url { font-weight: 600; word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 999px;
  background: #1c2e24; border: 1px solid #2a4a36; color: #8d8; cursor: pointer;
}
#talk-tpl {
  width: 100%;
  min-height: 420px;
  max-height: none;
  height: min(55vh, 560px);
  font: 13px/1.45 var(--mono);
  resize: vertical;
}
.preview {
  background: #111; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; white-space: pre-wrap; font-size: 13px; max-height: 220px; overflow: auto;
}
details.preview-box { margin-top: 10px; }
details.preview-box summary { cursor: pointer; color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #232326; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.in-cell { white-space: nowrap; }
.in-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.in-check input { width: 14px; height: 14px; accent-color: var(--accent); }

.mob-only { display: none; }
.desk-only { display: revert; }
.icon-link { font-size: 18px; padding: 4px 8px; color: var(--muted); }

@media (max-width: 900px) {
  .control-count { margin-left: 0; width: 100%; padding-bottom: 0; }
  .control-group select { max-width: none; }
}

@media (max-width: 760px) {
  :root { --pad-x: 12px; }
  header { padding: 8px var(--pad-x); gap: 8px; }
  .brand .logo { height: 26px; }
  .brand span { font-size: 13px; }
  .nav-item { padding: 7px 10px; font-size: 12px; }
  .nav-item svg { width: 16px; height: 16px; }
  #v-direct.talk-direct, textarea.talk-direct { height: min(50vh, 480px); min-height: 280px; }
  #talk-tpl { height: min(60vh, 640px); min-height: 360px; }
  main, body.people main { padding: 10px var(--pad-x) 28px; }
  .sticky-bar { top: 48px; margin-bottom: 10px; }
  .control-row { gap: 12px; }
  .control-group { width: 100%; }
  .control-group .seg { width: 100%; }
  .control-group .seg-btn { flex: 1; text-align: center; min-height: 40px; }
  .control-issue { align-items: stretch; }
  .plan-chip { flex: 1 1 140px; }
  .talk-switch, .sync-btn { width: 100%; justify-content: flex-start; }
  .mob-only { display: initial; }
  .desk-only { display: none !important; }
  .person {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }
  .person-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .person-actions .icon-act {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .person-actions .issue { flex: 1 1 100%; }
  dialog { width: 96vw; max-width: none; }
}
