/* Vuerso Bridge — login + dashboard. Base tokens (colours, fonts, radii) come from tokens.css, shared with the
   plugin's setup page; these are the few extra roles the dashboard needs. Primary/danger buttons use slightly
   deeper fills than --brand/--danger so white 14px labels pass WCAG AA. */
:root {
  --border-strong: #d4d4d4;
  --primary: #0b6fd1;
  --primary-hover: #095cb0;
  --danger-fill: #d6361a;
  --danger-fill-hover: #b52b13;
  --ok-ring: rgba(20, 174, 92, 0.16);
  --edit-bg: rgba(20, 174, 92, 0.12);
  --view-bg: rgba(255, 205, 41, 0.28);
  --idle: #b3b3b3;
  --card: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --border-strong: #4a4a4a;
    --primary-hover: #0d7fe8;
    --danger-fill-hover: #e64a2e;
    --edit-bg: rgba(25, 143, 81, 0.22);
    --view-bg: rgba(255, 205, 41, 0.18);
    --idle: #6b6b6b;
    --card: #252525;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px var(--sans);
  font-feature-settings: 'cv11';
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
code { font-family: var(--mono); font-size: 12px; background: var(--bg-2); border-radius: 4px; padding: 1px 5px; color: var(--text); }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: 8px; z-index: 20; background: var(--card); padding: 8px 12px; border-radius: 6px; transform: translateY(-200%); }
.skip:focus { transform: none; box-shadow: var(--shadow); }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 14px; letter-spacing: -0.005em; }
.mark { width: 20px; height: 20px; color: var(--text); flex: none; }
.mark-v { stroke: var(--bg); }

/* buttons + fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 500; font-size: 14px; line-height: 20px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger-fill); color: #fff; }
.btn.danger:hover { background: var(--danger-fill-hover); }
.btn.ghost { background: transparent; border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.link-btn {
  background: none; border: 0; padding: 4px 6px; margin: -4px 0; border-radius: 6px;
  color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer;
}
.link-btn:hover { color: var(--text); background: var(--bg-2); }
.link-btn.danger { color: var(--text-danger); }
.link-btn.danger:hover { background: var(--danger-soft); color: var(--text-danger); }

.label { display: block; font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.opt { color: var(--text-3); font-weight: 400; }
.input {
  display: block; width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg);
  font-size: 14px;
}
.input:hover { border-color: var(--text-3); }
.input:focus-visible { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.input[aria-invalid='true'] { border-color: var(--danger); }
.input::placeholder { color: var(--text-3); }
.mono { font-family: var(--mono); }
.field-error { margin: 8px 0 0; color: var(--text-danger); font-size: 13px; }

/* ---------- login ---------- */
body.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-wrap { width: 100%; max-width: 360px; }
.login-card { padding: 32px 28px 28px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.login-card h1 { margin: 28px 0 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.015em; }
.login-card .sub { margin: 4px 0 24px; color: var(--text-2); }
.login-form .btn { margin-top: 20px; height: 40px; }
.note { border: 1px solid var(--border); background: var(--bg-2); border-radius: 8px; padding: 12px 14px; }
.note p { margin: 0; }

/* ---------- dashboard ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--border); }
.top-in { max-width: 1200px; margin: 0 auto; height: 56px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.top-r { display: flex; align-items: center; gap: 12px; }
.top-r form { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--bg-2); font-size: 13px; color: var(--text-2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; display: inline-block; }
.dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--ok-ring); }
.dot.bad { background: var(--danger); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; padding-top: 32px; padding-bottom: 64px; align-items: start; }
.col { min-width: 0; display: grid; gap: 32px; }
.block { min-width: 0; }
.block h2 { margin: 0 0 12px; font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -0.01em; }
.block-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.block-h h2 { margin: 0; }
.count { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.panel { border: 1px solid var(--border); border-radius: 10px; background: var(--card); min-width: 0; }
.panel.pad { padding: 16px; }
.empty { margin: 0; padding: 20px 16px; color: var(--text-2); }
.empty b { color: var(--text); font-weight: 500; }
.hint { margin: 0 0 14px; color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.foot-note { margin: 8px 2px 0; color: var(--text-3); font-size: 12px; line-height: 18px; }
.foot-note code { font-size: 11px; }

/* status */
.stats { margin: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.stat { padding: 12px 16px; min-width: 0; border-left: 1px solid var(--border); }
.stat:first-child { border-left: 0; }
.stat dt { font-size: 12px; line-height: 16px; color: var(--text-2); }
.stat dd { margin: 4px 0 0; font-size: 15px; line-height: 20px; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* rows (connections, devices, clients) */
.row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); min-width: 0; }
.row:first-child { border-top: 0; }
.row > .dot { margin-top: 6px; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; min-width: 0; }
.row-title strong { font-weight: 600; overflow-wrap: anywhere; }
.row-title .sec { color: var(--text-2); overflow-wrap: anywhere; }
.row-meta { margin-top: 2px; color: var(--text-2); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.row-meta > span { white-space: nowrap; }
.row-meta span + span::before { content: '·'; padding: 0 6px; color: var(--text-3); }
.row-side { display: flex; align-items: center; gap: 4px; flex: none; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--bg-2); color: var(--text-2); white-space: nowrap; }
.badge.edit { background: var(--edit-bg); color: var(--text-success); }
.badge.view { background: var(--view-bg); color: var(--text); }
.now { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.now.busy { color: var(--text); }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--bg-3); border-top-color: var(--brand); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; border-top-color: var(--brand); } }

.rename { display: flex; gap: 8px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
.rename .input { height: 32px; max-width: 260px; font-size: 14px; }

/* activity */
.act { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; table-layout: fixed; }
.act th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.act td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.act tr:first-child td { border-top: 0; }
.act .t { width: 76px; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.act .c { width: 64px; color: var(--text-2); }
.act .o { width: 124px; font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
.act .ms { width: 72px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.act .s { width: 40px; text-align: right; }
.act .err { display: block; margin-top: 2px; color: var(--text-danger); }
.ok-mark { color: var(--text-success); font-weight: 600; }
.bad-mark { color: var(--text-danger); font-weight: 600; }
.more { display: block; width: 100%; padding: 10px; border: 0; border-top: 1px solid var(--border); background: none; color: var(--text-2); font-size: 13px; cursor: pointer; border-radius: 0 0 10px 10px; }
.more:hover { background: var(--bg-2); color: var(--text); }

/* pair + setup */
.pair .label + .input { margin-bottom: 14px; }
.pair .field-error { margin: -6px 0 12px; }
.pair .btn { margin-top: 2px; }
.code-input { text-transform: uppercase; letter-spacing: 0.04em; font-size: 15px; }
.code-input::placeholder { text-transform: none; }
.setup .meta { margin: 8px 0 0; color: var(--text-2); font-size: 13px; }
.steps { list-style: none; margin: 16px 0 0; padding: 0; counter-reset: s; }
.steps li { position: relative; padding: 12px 0 12px 34px; border-top: 1px solid var(--border); counter-increment: s; color: var(--text-2); font-size: 13px; line-height: 20px; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 12px;
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong);
  font: 600 11px/20px var(--sans); text-align: center; color: var(--text);
}
.steps b { color: var(--text); font-weight: 500; }
.path { color: var(--text); font-weight: 500; }
.path i { font-style: normal; color: var(--text-3); padding: 0 3px; }

/* toast + dialog */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 8px;
  background: #1e1e1e; color: #fff; font-size: 13px; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .toast { background: #f5f5f5; color: #111; } }
.toast.err { background: var(--danger); color: #fff; }
.dialog { border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: min(400px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.32); }
.dialog h3 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; }
.dialog p { margin: 6px 0 0; color: var(--text-2); }
.dialog form { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* responsive */
@media (max-width: 1040px) {
  /* One column; pairing moves up next to connections, reference material goes last. */
  .layout { grid-template-columns: minmax(0, 1fr); }
  .col, .side { display: contents; }
  .b-status { order: 1; } .b-conn { order: 2; } .b-pair { order: 3; } .b-dev { order: 4; }
  .b-act { order: 5; } .b-cl { order: 6; } .b-setup { order: 7; }
}
@media (max-width: 760px) {
  .wrap, .top-in { padding-left: 16px; padding-right: 16px; }
  .layout { padding-top: 20px; gap: 28px; }
  .col { gap: 28px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--border); }
  .stat:nth-child(-n + 2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--border); }
  .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .row { flex-wrap: wrap; }
  .row-meta { display: flex; flex-wrap: wrap; column-gap: 12px; }
  .row-meta span + span::before { content: none; }
  .row-side.actions { width: 100%; padding-left: 20px; margin-top: -4px; }
  .pill .pill-text { display: none; }
  .act thead { display: none; }
  .act, .act tbody, .act tr { display: block; }
  .act tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; column-gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); }
  .act tr:first-child { border-top: 0; }
  .act td { padding: 0; border: 0; width: auto !important; }
  .act .t { grid-column: 1; }
  .act .c { grid-column: 2; }
  .act .o { grid-column: 3; text-align: left; }
  .act .s { grid-column: 4; grid-row: 1; }
  .act .l { grid-column: 1 / 4; grid-row: 2; margin-top: 4px; }
  .act .ms { grid-column: 4; grid-row: 2; align-self: end; }
}
