/* ============================================================================
   MeshCore Tracking — self-contained dark UI
   Sections: 1 palette/reset  2 header  3 layout  4 sidebar  5 node list
             6 map + legend  7 detail panel  8 forms/controls  9 telemetry chart
             10 messages  11 activity  12 toasts/banner  13 leaflet overrides
             14 responsive
   ========================================================================== */

/* ------------------------------ 1. palette / reset ------------------------ */
:root {
  --bg:         #0b0f16;
  --bg-1:       #111825;
  --bg-2:       #16202e;
  --bg-3:       #1d2938;
  --line:       #243044;
  --line-soft:  #1b2534;
  --text:       #e7eef8;
  --text-dim:   #a9b7c9;
  --muted:      #7d8ca1;
  --accent:     #4cc9f0;
  --accent-dim: #2b8fae;
  --green:      #56d364;
  --warn:       #ffb74d;
  --danger:     #ff6b6b;
  --violet:     #b388ff;
  --radius:     10px;
  --radius-sm:  7px;
  --shadow:     0 8px 28px rgba(0, 0, 0, .5);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #26313f; border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #33414f; background-clip: content-box; }

.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.h3 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.h3:first-child { margin-top: 0; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0 12px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 8px 0 0; }
.hint b { color: var(--text-dim); }

/* ------------------------------ 2. header --------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 9px 14px;
  background: linear-gradient(180deg, #131c2a, #0e1622);
  border-bottom: 1px solid var(--line);
  z-index: 3;
}
.brand { font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.brand-thin { color: var(--muted); font-weight: 400; }

.devbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.stat { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12.5px; min-width: 0; }
.stat label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.stat b { font-weight: 550; color: var(--text); font-family: var(--mono); font-size: 12px; }
.stat .dot { align-self: center; }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); display: inline-block; flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .05);
}
.dot.big { width: 12px; height: 12px; }
.dot.ok    { background: var(--green);  box-shadow: 0 0 8px rgba(86, 211, 100, .55); }
.dot.warn  { background: var(--warn);   box-shadow: 0 0 8px rgba(255, 183, 77, .45); }
.dot.err   { background: var(--danger); box-shadow: 0 0 8px rgba(255, 107, 107, .5); }
.dot.unknown { background: #4a5768; }
.dot.pulse { animation: dotpulse 2.2s ease-in-out infinite; }
@keyframes dotpulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2);
  font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.live-badge.live { border-color: #1f6b46; background: #10281e; color: #9ff0c0; }
.live-badge.live .dot { background: var(--green); }
.live-badge.connecting { border-color: #6b5320; background: #2a2211; color: #f2d59a; }
.live-badge.connecting .dot { background: var(--warn); }
.live-badge.offline { border-color: #5c2a2a; background: #2a1414; color: #f0b3b3; }
.live-badge.offline .dot { background: var(--danger); }

/* ------------------------------ 3. layout --------------------------------- */
#layout {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 420px;
  grid-template-rows: minmax(0, 1fr);
  gap: 10px; padding: 10px;
}
.sidebar, .detail, .map-wrap {
  min-height: 0; min-width: 0;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar, .detail { overflow-y: auto; }
.sidebar { padding: 10px; gap: 10px; }
.detail { padding: 0; }

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: #2a1414; border-bottom: 1px solid #5c2a2a; color: #ffd9d9;
  font-size: 13px;
}
.banner-icon { color: var(--danger); }
.banner button { margin-left: auto; }

/* ------------------------------ 4. sidebar -------------------------------- */
.side-block {
  border: 1px solid var(--line-soft);
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.side-title {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); margin-bottom: 8px;
}
.side-block .input { width: 100%; }

details.collapsible { padding: 0; }
details.collapsible > summary {
  cursor: pointer; padding: 10px; list-style: none;
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before { content: "▸"; color: var(--muted); font-size: 11px; }
details.collapsible[open] > summary::before { content: "▾"; }
details.collapsible > summary:hover { color: var(--text); }
details.collapsible > *:not(summary) { padding: 0 10px 10px; }
#activity > .ev-list { padding: 0 10px 10px; }

/* ------------------------------ 5. node list ------------------------------ */
.node-list { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.node-row {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 8px 9px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.node-row:hover { background: var(--bg-3); border-color: var(--line); }
.node-row:active { transform: scale(.995); }
.node-row.selected {
  background: linear-gradient(90deg, rgba(76, 201, 240, .16), rgba(76, 201, 240, .03));
  border-color: var(--accent-dim);
}
.node-row .dot { margin-top: 5px; }
.node-main { min-width: 0; flex: 1 1 auto; }
.node-line1 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.node-name {
  font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node-line2 { color: var(--text-dim); font-size: 11.5px; margin-top: 2px; overflow-wrap: anywhere; }
.node-line3 { color: var(--muted); font-family: var(--mono); font-size: 10.5px; margin-top: 3px; }
.node-flags { display: flex; gap: 4px; flex: 0 0 auto; align-items: center; }

.badge {
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-dim); background: var(--bg-1);
  white-space: nowrap;
}
.badge.tracked { border-color: #1f6b46; color: #9ff0c0; background: #10281e; }
.badge.stale { border-color: #6b5320; color: #f2d59a; background: #2a2211; }

/* ------------------------------ 6. map ------------------------------------ */
.map-wrap { position: relative; }
/* The overlays are positioned against this holder, not .map-wrap, so the map
   can grow a toolbar (the time-range control) without moving them. */
.map-holder { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.map { flex: 1 1 auto; min-height: 240px; background: #0a0e14; z-index: 0; }
.map-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.map-bar #range-count { margin-right: auto; }
.map-bar .rangelbl { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.map-bar .rangesel { width: auto; min-width: 136px; padding: 3px 6px; font-size: 12px; }
.map-hint {
  position: absolute; left: 12px; bottom: 26px; z-index: 500;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(11, 15, 22, .82); border: 1px solid var(--line);
  font-size: 11.5px; pointer-events: none; max-width: 60%;
}
.map-error {
  position: absolute; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 24px; background: rgba(11, 15, 22, .94); color: var(--text-dim);
}
.legend {
  position: absolute; right: 12px; top: 12px; z-index: 500;
  background: rgba(11, 15, 22, .86);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 11px; color: var(--text-dim);
  display: flex; flex-direction: column; gap: 8px; max-width: 190px;
  backdrop-filter: blur(3px);
}
.legend-title { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 10px; margin-bottom: 3px; }
.legend-item { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.legend-line { width: 22px; height: 0; border-top: 2px solid var(--c, #888); flex: 0 0 auto; }
.legend-line.dashed { border-top-style: dashed; }
.legend-line.faint { border-top: 1px solid #5a6a80; }
.legend-swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #888); flex: 0 0 auto; }
.legend-hollow {
  width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto;
  background: transparent; border: 2px dashed var(--muted);
}
.legend-self {
  width: 11px; height: 11px; background: var(--danger); border: 2px solid #fff;
  transform: rotate(45deg); flex: 0 0 auto; display: inline-block;
}
.self-pin {
  width: 14px; height: 14px; background: var(--danger); border: 2px solid #fff;
  transform: rotate(45deg); box-shadow: 0 0 10px rgba(255, 107, 107, .7);
}

/* ------------------------------ 7. detail panel --------------------------- */
.empty-state {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  padding: 30px 20px; color: var(--muted); text-align: center; font-size: 13px;
}
.empty-state.small { padding: 14px 10px; font-size: 12px; }
.detail-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg-1); z-index: 2;
}
.detail-title { min-width: 0; flex: 1 1 auto; }
.detail-name { font-weight: 620; font-size: 15px; overflow-wrap: anywhere; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.tab {
  appearance: none; border: 1px solid transparent; border-bottom: none;
  background: transparent; color: var(--muted);
  padding: 6px 10px; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit; font-size: 12.5px;
}
.tab:hover { color: var(--text); background: var(--bg-2); }
.tab.active {
  color: var(--text); background: var(--bg-2);
  border-color: var(--line); border-bottom: 1px solid var(--bg-2); margin-bottom: -1px;
}
.panels { padding: 12px; }
.panel { display: none; }
.panel.active { display: block; }

.kv { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); overflow: hidden; }
.kv-row { display: flex; gap: 10px; padding: 6px 9px; font-size: 12.5px; background: var(--bg-2); }
.kv-row:nth-child(odd) { background: var(--bg-1); }
.kv-row .k { color: var(--muted); flex: 0 0 40%; min-width: 96px; }
.kv-row .v { flex: 1 1 auto; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; }
.kv-row .v.wrap-any { font-family: var(--sans); font-size: 12.5px; }

.callout {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 12.5px; margin-bottom: 10px; color: var(--text-dim);
}
.callout.ok   { border-color: #1f6b46; background: #10281e; color: #bdf3d3; }
.callout.warn { border-color: #6b5320; background: #2a2211; color: #f6dfae; }
.callout.err  { border-color: #5c2a2a; background: #2a1414; color: #ffc9c9; }

/* ------------------------------ 8. controls -------------------------------- */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: #26374a; border-color: #31435a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.primary { background: #12455a; border-color: #1d6e8c; color: #d9f4ff; }
.btn.primary:hover:not(:disabled) { background: #175a75; }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--bg-3); }
.btn.danger { background: #4a1d1d; border-color: #7d2f2f; color: #ffd6d6; }
.btn.danger:hover:not(:disabled) { background: #5e2525; }
.icon-btn {
  appearance: none; cursor: pointer; font: inherit;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 26px; height: 26px; border-radius: 7px; line-height: 1; flex: 0 0 auto;
}
.icon-btn:hover { color: var(--text); background: var(--bg-3); }

.input {
  appearance: none; width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 8px; font: inherit; font-size: 12.5px;
}
.input:focus { outline: none; border-color: var(--accent-dim); box-shadow: 0 0 0 2px rgba(76, 201, 240, .15); }
textarea.input { resize: vertical; min-height: 40px; font-family: inherit; }
select.input { cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

label { display: block; font-size: 12px; color: var(--text-dim); margin-top: 8px; }
label .input { margin-top: 4px; }
label.check, label.inline {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text); font-size: 12.5px; margin-top: 6px;
}
label.inline { flex-direction: column; align-items: flex-start; gap: 3px; color: var(--text-dim); font-size: 11px; }
label.inline .input { margin-top: 0; }
label.inline select.input { min-width: 150px; }
.form { display: block; }
.form-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.form-row > label { flex: 1 1 90px; margin-top: 0; }
.form-row > label.check { flex: 0 0 auto; }
.row-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.fieldset {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 8px 10px 10px; margin: 10px 0 0;
}
.fieldset legend { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 5px; }
.fieldset .row-actions, .fieldset .btn { margin-top: 8px; }

.feedback { font-size: 12px; margin-top: 8px; min-height: 0; overflow-wrap: anywhere; }
.feedback:empty { display: none; }
.feedback.ok  { color: #9ff0c0; }
.feedback.err { color: #ffb3b3; }
.feedback.info { color: var(--text-dim); }
.err { color: #ffb3b3; font-size: 11.5px; margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chips:empty { display: none; }
.chip {
  appearance: none; cursor: pointer; font: inherit; font-size: 11.5px;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text-dim);
}
.chip:hover { border-color: var(--accent-dim); color: var(--text); }
.chip.on { border-color: var(--accent-dim); background: #12455a; color: #d9f4ff; }
.chip.static { cursor: default; }

/* ------------------------------ 9. chart ---------------------------------- */
.chart-wrap { margin-top: 12px; }
.chart-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.chart {
  display: block; width: 100%; height: 200px;
  background: linear-gradient(180deg, #0e1520, #0b1017);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}

/* ------------------------------ 10. messages ------------------------------ */
.messages {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 40vh; overflow-y: auto; padding: 2px;
}
.msg {
  max-width: 90%; padding: 7px 10px; border-radius: 11px;
  background: var(--bg-2); border: 1px solid var(--line-soft);
}
.msg.in { align-self: flex-start; border-bottom-left-radius: 3px; }
.msg.out { align-self: flex-end; background: linear-gradient(180deg, #12384a, #0f2c3a); border-color: #1d5f78; border-bottom-right-radius: 3px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.msg-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 5px; font-size: 10.5px; color: var(--muted); }
.msg-meta .pill { border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.msg-meta .pill.ok { border-color: #1f6b46; color: #9ff0c0; }
.msg-meta .pill.err { border-color: #5c2a2a; color: #ffb3b3; }
.compose { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.compose .form-row { margin-top: 6px; }

/* ------------------------------ 11. activity ------------------------------ */
.ev-list { display: flex; flex-direction: column; gap: 2px; max-height: 30vh; overflow-y: auto; }
.ev-row {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 7px; border-radius: 6px; font-size: 11.5px;
  border: 1px solid transparent; cursor: default;
}
.ev-row:nth-child(odd) { background: var(--bg-1); }
.ev-row.clickable { cursor: pointer; }
.ev-row.clickable:hover { border-color: var(--line); background: var(--bg-3); }
.ev-time { color: var(--muted); font-family: var(--mono); font-size: 10.5px; flex: 0 0 auto; }
.ev-kind {
  flex: 0 0 auto; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); min-width: 62px;
}
.ev-kind.k-advert { color: var(--violet); }
.ev-kind.k-telemetry { color: var(--green); }
.ev-kind.k-message { color: var(--accent); }
.ev-kind.k-error, .ev-kind.k-device { color: var(--warn); }
.ev-text { flex: 1 1 auto; overflow-wrap: anywhere; color: var(--text-dim); }

/* ------------------------------ 12. toasts / banner ----------------------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 90vw);
}
.toast {
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  box-shadow: var(--shadow); animation: toastin .16s ease-out;
  overflow-wrap: anywhere;
}
.toast.ok   { border-color: #1f6b46; }
.toast.err  { border-color: #7d2f2f; }
.toast.warn { border-color: #6b5320; }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------ 13. leaflet overrides --------------------- */
.leaflet-container { background: #0a0e14; font-family: var(--sans); }
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--bg-2); color: var(--text); border-bottom-color: var(--line);
}
.leaflet-bar a:hover { background: var(--bg-3); }
.leaflet-control-attribution {
  background: rgba(11, 15, 22, .82) !important;
  color: var(--muted) !important; font-size: 10.5px;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--bg-2); color: var(--text); box-shadow: var(--shadow);
}
.leaflet-popup-content-wrapper { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.leaflet-popup-content { margin: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--text); }
.leaflet-tooltip {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; box-shadow: none; font-size: 11.5px; padding: 2px 7px;
}
.leaflet-tooltip-top::before { border-top-color: var(--line); }
.popup-title { font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
.popup-row { display: flex; gap: 8px; }
.popup-row .k { color: var(--muted); min-width: 62px; }
.popup-row .v { font-family: var(--mono); font-size: 11.5px; }

/* ------------------------------ 14. responsive ---------------------------- */
@media (max-width: 1180px) {
  #layout {
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-rows: minmax(240px, 1fr) minmax(200px, 45vh);
  }
  .detail { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  body { overflow: auto; height: auto; }
  #layout { display: flex; flex-direction: column; padding: 8px; }
  .sidebar, .detail, .map-wrap { overflow: visible; }
  .map-wrap { height: 62vh; }
  .map { min-height: 0; }
  .node-list { max-height: none; }
  .messages { max-height: 50vh; }
  .ev-list { max-height: 40vh; }
  .legend { right: 8px; top: 8px; font-size: 10.5px; max-width: 150px; }
  .map-hint { display: none; }
  .devbar { gap: 10px; }
  .topbar-actions { width: 100%; margin-left: 0; justify-content: flex-end; }
}

/* ==========================================================================
   Accounts and node access (administrator)
   ========================================================================== */

.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 11px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--text); max-width: 240px;
}
.user-chip .user-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600;
}
.role-badge {
  font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

/* --- node access editor --- */
.access-list {
  display: flex; flex-direction: column; gap: 2px;
  margin: 10px 0; padding: 10px 12px;
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); max-height: 320px; overflow-y: auto;
}
.access-row { padding: 5px 2px; }
.access-row input { margin-right: 2px; }

/* --- accounts modal --- */
.modal {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(4, 7, 12, .72);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(880px, 100%); background: var(--bg-1);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--bg-2); position: sticky; top: 0;
}
.modal-body { padding: 14px; }

.acc-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.acc-table th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  padding: 6px 8px; border-bottom: 1px solid var(--line);
}
.acc-table td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.acc-table tr:last-child td { border-bottom: none; }
.acc-actions { white-space: nowrap; text-align: right; }
.acc-actions .btn { margin-left: 2px; }

.btn.tiny { padding: 3px 7px; font-size: 11px; border-radius: 6px; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-3); }

.pill {
  display: inline-block; font-size: 10px; letter-spacing: .04em;
  text-transform: uppercase; padding: 1px 7px; border-radius: 999px;
}
.pill.ok  { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.pill.err { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

@media (max-width: 720px) {
  .modal { padding: 12px 8px; }
  .acc-table { font-size: 12px; }
  .acc-actions .btn { display: block; width: 100%; margin: 2px 0; }
  .user-chip .user-name { display: none; }
}

.ev-actor {
  font-size: 11px; color: var(--accent-dim); flex: 0 0 auto;
  padding: 0 6px; border-left: 1px solid var(--line-soft);
}
