/* The fleet dashboard, in the schedule pages' look (schedule-web/schedule.css): the same palette,
   light by default and dark when the system prefers dark, the same rounded Nimbus-style controls and
   the same type. The world map stays dark in both — it is game imagery on a black void — and only
   the panels floating over it follow the theme. */
:root {
  color-scheme: light dark;
  --bg: #F3F5F8;
  --panel: #FFFFFF;
  --side: #FBFCFD;
  --line: #DCE1E7;
  --ink: #1B2430;
  --muted: #5E6B7A;
  --faint: #8A95A3;
  --accent: #2B6FD6;
  --ok: #2E9E62;
  --warn: #B7791F;
  --bad: #C2452D;
  --btn-top: #FBFCFD;
  --btn-bottom: #DFE4EA;
  --btn-border: #A8B1BC;
  --on-top: #C9D3DE;
  --on-bottom: #E3E8EE;
  --hover-border: #7C8896;
  --input-bg: #FFFFFF;
  --row-hover: #F6F8FA;
  --selected: #DCE8F8;
  --idle: #9AA4B0;
  --err-bg: #FBE3E0;
  --err-border: #E5B4AA;
  --err-ink: #8E2A17;
  --danger-top: #FBEDEA;
  --danger-bottom: #F2D3CC;
  --danger-border: #C98B7E;
  --overlay: rgba(255, 255, 255, 0.94);
  --tip-bg: #FFFFE6;
  --tip-border: #A8A88C;
  --shadow: rgba(0, 0, 0, 0.18);
  --backdrop: rgba(27, 36, 48, 0.35);
  --map-bg: #070A0E;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1116;
    --panel: #151A21;
    --side: #12161C;
    --line: #2A323D;
    --ink: #D7DDE6;
    --muted: #8B95A1;
    --faint: #5F6A77;
    --accent: #4C9AFF;
    --ok: #3FB950;
    --warn: #D29922;
    --bad: #F05D5D;
    --btn-top: #262D37;
    --btn-bottom: #1B2129;
    --btn-border: #3A4450;
    --on-top: #2D3A4B;
    --on-bottom: #24303E;
    --hover-border: #5B6878;
    --input-bg: #0F1318;
    --row-hover: #1A2028;
    --selected: #1D3557;
    --idle: #4A535E;
    --err-bg: #2A1515;
    --err-border: #6B2B2B;
    --err-ink: #FFB4B4;
    --danger-top: #3A1D1D;
    --danger-bottom: #2C1616;
    --danger-border: #6B2B2B;
    --overlay: rgba(21, 26, 33, 0.94);
    --tip-bg: #222A33;
    --tip-border: #3A4450;
    --shadow: rgba(0, 0, 0, 0.5);
    --backdrop: rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.4 system-ui, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

code, pre, textarea { font-family: var(--mono); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.error { color: var(--bad); }
.small { font-size: 12px; margin: 0 0 12px; }

/* ---- controls (as on the schedule pages) ---- */

button {
  font: inherit;
  color: var(--ink);
  padding: 4px 12px;
  border: 1px solid var(--btn-border);
  border-radius: 7px;
  background: linear-gradient(var(--btn-top), var(--btn-bottom));
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--hover-border); }
button:active:not(:disabled), button.on {
  background: linear-gradient(var(--on-top), var(--on-bottom));
  border-color: var(--hover-border);
  box-shadow: inset 0 1px 2px var(--shadow);
}
button:disabled { color: var(--faint); opacity: 0.7; cursor: default; }
button.primary { background: linear-gradient(#4E8CE0, #2B6FD6); border-color: #1F58AE; color: #fff; }
button.danger {
  background: linear-gradient(var(--danger-top), var(--danger-bottom));
  border-color: var(--danger-border);
  color: var(--err-ink);
}

select, textarea, input:not([type=checkbox]):not([type=radio]) {
  font: inherit;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--btn-border);
  border-radius: 5px;
  padding: 3px 6px;
}
textarea { font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(43, 111, 214, 0.35);
  outline-offset: 0;
  border-color: var(--accent);
}
label.check { display: flex; align-items: center; gap: 6px; }

/* ---- header: title, tabs, the fleet in numbers, link state ---- */

header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 15px; font-weight: 700; }
nav { display: flex; gap: 4px; }
a.tab {
  padding: 4px 12px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
}
a.tab:hover { color: var(--ink); }
a.tab.on { color: var(--ink); border-color: var(--btn-border); background: linear-gradient(var(--on-top), var(--on-bottom)); }

.stats { display: flex; gap: 16px; margin-left: 10px; color: var(--muted); }
.stat b { color: var(--ink); font-variant-numeric: tabular-nums; }
.stat.ok b { color: var(--ok); }

.link-state { color: var(--warn); }
.link-state::before { content: "● "; }
.link-state.up { color: var(--ok); }
.link-state.down { color: var(--bad); }

/* the action bar under it (the schedule pages' subject bar) */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 16px;
  background: var(--side);
  border-bottom: 1px solid var(--line);
}
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

/* ---- the map ---- */

main { flex: 1; display: flex; min-height: 0; }

#map-pane { flex: 1; position: relative; min-width: 0; background: var(--map-bg); }
/* Leaflet's panes stack inside the map, below the controls, menus and windows over it. */
#map { position: absolute; inset: 0; z-index: 0; background: var(--map-bg); }

#map-controls {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--overlay);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
}
#map-controls label { color: var(--ink); display: flex; align-items: center; gap: 5px; }
#map-hint { color: var(--faint); }

/* ---- the area maker (areas.js) ---- */

#area-panel {
  position: absolute;
  left: 12px;
  top: 60px;
  width: 360px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 120px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--overlay);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 8;
}
#area-panel[hidden] { display: none; }
.ap-head, .ap-code-head { display: flex; align-items: center; gap: 8px; }
.ap-head .cp-seg button { padding: 3px 10px; }
.ap-hint { margin: 0; color: var(--muted); font-size: 12px; }
#ap-list { overflow-y: auto; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.ap-empty { margin: 0; font-size: 12px; }
.ap-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.ap-row:hover { background: var(--row-hover); }
.ap-row.on { background: var(--selected); }
.ap-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ap-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ap-name { font: inherit; font-weight: 600; border: 1px solid transparent; background: transparent; color: var(--ink); padding: 1px 3px; margin-left: -4px; border-radius: 4px; }
.ap-name:hover, .ap-name:focus { border-color: var(--line); background: var(--input-bg); }
.ap-meta { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ap-row button { padding: 1px 7px; }
.ap-cursor { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; min-height: 1em; color: var(--muted); font-variant-numeric: tabular-nums; }
#ap-code {
  font-family: var(--mono);
  font-size: 11.5px;
  resize: vertical;
  min-height: 70px;
  background: var(--input-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  white-space: pre;
  flex: none;
}

#tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
  border-radius: 4px;
  box-shadow: 0 2px 6px var(--shadow);
  padding: 5px 8px;
  white-space: pre;
  font-size: 12px;
  z-index: 5;
}

/* ---- the side panel: accounts, jobs, agents ---- */

#side {
  width: 420px;
  border-left: 1px solid var(--line);
  background: var(--side);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-head {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.side-head input { flex: 1; }

#rows { flex: 1; overflow-y: auto; background: var(--panel); }

/* the side panel's tabs: Farms (default) and Accounts */
.side-tabs { display: flex; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.side-tabs button { flex: 1; }
.side-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.side-pane[hidden] { display: none; }

/* the Farms tab */
.sf-tiles { padding: 10px 12px; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.sf-tiles .cp-tile { background: var(--panel); padding: 6px 8px; }
.sf-tiles .cp-tile .v { font-size: 18px; }
.sf-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.sf-head .spacer { flex: 1; }
.sf-open { font-size: 12px; color: var(--accent); text-decoration: none; }
.sf-open:hover { text-decoration: underline; }
#sf-continuous.on { color: var(--ok); }
#sf-continuous.off { color: var(--bad); }
.sf-list { flex: 1; overflow-y: auto; background: var(--panel); }
.sf-card { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sf-card.off { opacity: 0.6; }
.sf-title { display: flex; align-items: baseline; gap: 6px; }
.sf-title .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-sub { color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.sf-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.sf-nums div { font-size: 11px; color: var(--muted); }
.sf-nums b { display: block; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.sf-nums .ok b { color: var(--ok); }
.sf-nums .warn b { color: var(--warn); }
.sf-nums .bad b { color: var(--bad); }
.sf-run { margin-top: 6px; }
.sf-acct { display: grid; grid-template-columns: 9px 1fr auto; gap: 8px; align-items: center;
  padding: 3px 4px; font-size: 12px; border-radius: 4px; cursor: pointer; }
.sf-acct:hover { background: var(--row-hover); }
.sf-acct.sel { background: var(--selected); }
.sf-acct .meta { white-space: nowrap; }
.sf-more { font-size: 12px; color: var(--faint); padding: 2px 4px; }

.row {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.row:hover { background: var(--row-hover); }
.row.sel { background: var(--selected); }
.row.jagex { background: var(--row-hover); }
.row.jagex .caret-x { width: 9px; color: var(--muted); font-size: 11px; }
.row.child { padding-left: 30px; }
.stage { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 8px;
  background: var(--line); color: var(--muted); vertical-align: 1px; }
.stage.ok { color: var(--ok); }
.stage.warn { color: var(--warn); }
.stage.bad { color: var(--bad); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); }
.dot.CONNECTING { background: var(--warn); }
.dot.LOBBY { background: var(--accent); }
.dot.IN_GAME { background: var(--ok); }
.dot.ERROR { background: var(--bad); }

.name { font-weight: 600; }
.meta { color: var(--muted); font-size: 12px; }
.meta.err { color: var(--bad); }
.row-actions { position: relative; display: flex; gap: 4px; }
.row-actions button { padding: 1px 9px; font-size: 12px; }
.row-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 2px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 110px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.row-menu[hidden] { display: none; }
.row-menu button {
  text-align: left;
  border-color: transparent;
  background: none;
  box-shadow: none;
  padding: 3px 10px;
}
.row-menu button:hover { background: var(--line); }
.row-menu button.danger { color: var(--bad); }

.jobs, .agents {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  overflow-y: auto;
}
.jobs { max-height: 30%; }
.agents { max-height: 25%; color: var(--muted); }
.agents div { display: flex; justify-content: space-between; }
.agents .role { font-size: 11px; color: var(--accent); margin-left: 6px; }

.jobs h3 { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: var(--ink); }
.job { display: grid; grid-template-columns: 9px 1fr auto; gap: 2px 10px; align-items: center; padding: 3px 0; }
.job .dot.QUEUED, .job .dot.CANCELLED { background: var(--idle); }
.job .dot.RUNNING { background: var(--warn); }
.job .dot.DONE { background: var(--ok); }
.job .dot.FAILED { background: var(--bad); }
.job .meta { grid-column: 2 / 4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job button { padding: 1px 8px; font-size: 12px; }

/* ---- dialogs ---- */

dialog {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 50px var(--shadow);
  padding: 18px 20px;
  width: 440px;
}
dialog::backdrop { background: var(--backdrop); }
dialog.wide { width: 620px; }
dialog h2 { margin: 0 0 14px; font-size: 15px; }
dialog label { display: block; margin-bottom: 10px; color: var(--muted); }
dialog label input:not([type=checkbox]), dialog label select, dialog textarea {
  display: block;
  width: 100%;
  margin-top: 3px;
}
dialog label.check { display: flex; color: var(--ink); }
dialog .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 16px 0 0; padding: 0; }
dialog textarea { padding: 6px; resize: vertical; }
dialog p.error {
  padding: 6px 10px;
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  border-radius: 6px;
  color: var(--err-ink);
}

/* the proxies window (in the creation panel's frame: dialog.panel, .cp-head, .cp-card) */
.px-table select.ppool { min-width: 130px; max-width: 200px; padding: 1px 4px; font-size: 12.5px; }
.px-table td { vertical-align: middle; }
.px-table code { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.px-table tr.px-group { cursor: pointer; user-select: none; }
.px-table tr.px-group td { background: var(--side); padding: 6px 6px; font-size: 13px; }
.px-table tr.px-group:hover td { background: var(--row-hover); }
.px-chev { display: inline-block; width: 16px; color: var(--muted); }
.px-gstats { margin-left: 10px; font-size: 12px; color: var(--muted); }
.px-gstats .ok { color: var(--ok); }
.px-gstats .bad { color: var(--bad); }
.px-gcreate { float: right; padding: 1px 9px; font-size: 12px; }
.px-table tr.prow:hover td { background: var(--row-hover); }
.px-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.px-state { font-size: 12px; white-space: nowrap; }
.px-state::before { content: "● "; }
.px-state.ok { color: var(--ok); }
.px-state.used { color: var(--accent); }
.px-state.bad { color: var(--bad); }
#px-filter { width: 240px; font-size: 12.5px; }
.cp-seg button .muted { font-size: 11.5px; margin-left: 3px; font-variant-numeric: tabular-nums; }
.px-add { display: grid; grid-template-columns: 1fr 260px; gap: 14px; align-items: start; }
.px-add label, .px-form label { margin: 0; font-size: 12.5px; }
.px-add textarea { min-height: 96px; }
.px-add-side { display: flex; flex-direction: column; gap: 8px; }
.px-add-side .cp-sub { margin: 0; }
.px-add-side button { align-self: flex-end; }
.px-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 14px; margin-top: 10px; }
.px-form label.wide { grid-column: span 2; }
.px-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.cp-card p.error { margin: 10px 0 0; }
@media (max-width: 640px) {
  .px-add { grid-template-columns: 1fr; }
  .px-form label.wide { grid-column: auto; }
  #px-filter { width: 100%; }
}

/* ---- floating debug windows ---- */

/* The window layer sits over the map and passes clicks through to it; only the windows
   themselves take pointer events, so panning the map still works around them. */
#windows { position: absolute; inset: 0; pointer-events: none; z-index: 6; }

#taskbar { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; z-index: 7; }
#taskbar button { box-shadow: 0 2px 8px var(--shadow); }

.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 380px;
  min-height: 200px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 14px 40px var(--shadow);
  pointer-events: auto;
  overflow: hidden;
}
.win.focused { border-color: var(--hover-border); }

.win-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  background: var(--side);
  border-bottom: 1px solid var(--line);
  cursor: move;
  user-select: none;
  flex: none;
}
.win.focused .win-bar { background: linear-gradient(var(--btn-top), var(--btn-bottom)); }
.win-title { font-weight: 700; white-space: nowrap; }
.win-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; }
.win-actions { margin-left: auto; display: flex; gap: 3px; }
.win-actions button {
  width: 22px;
  height: 20px;
  padding: 0;
  line-height: 1;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  box-shadow: none;
}
.win-actions button:hover { background: var(--panel); border-color: var(--btn-border); color: var(--ink); }
.win-actions button.close:hover { border-color: var(--bad); color: var(--bad); }

.win-tabs {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.win-tabs button {
  padding: 1px 9px;
  font-size: 12px;
  background: none;
  border-color: transparent;
  color: var(--muted);
}
.win-tabs button:hover { color: var(--ink); }
.win-tabs button.on { color: var(--ink); border-color: var(--btn-border); background: linear-gradient(var(--on-top), var(--on-bottom)); box-shadow: none; }

.win-script {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  font-size: 12px;
}
.win-script.running { border-left-color: var(--good, var(--accent)); }
.win-script.paused { border-left-color: var(--warn, var(--muted)); }
.win-script select { font-size: 12px; max-width: 220px; }
.win-script button { font-size: 12px; padding: 1px 9px; }
.win-script .script-state { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

.win-dialog {
  flex: none;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  font-size: 12px;
  max-height: 45%;
  overflow: auto;
}
.win-dialog.sent { opacity: 0.55; }
.win-dialog .dlg-line { margin-bottom: 5px; line-height: 1.4; }
.win-dialog .dlg-title { margin: 2px 0 4px; }
.win-dialog .dlg-buttons { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin-bottom: 4px; }
.win-dialog .dlg-buttons button { font-size: 12px; padding: 2px 10px; text-align: left; }
.win-dialog .dlg-input { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.win-dialog .dlg-input input { width: 140px; font-size: 12px; }
.win-body { flex: 1; overflow: auto; padding: 6px 10px; font-size: 12px; }
.win-body table { border-collapse: collapse; width: 100%; }
.win-body th {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
  border-bottom: 1px solid var(--line);
  padding: 3px 8px 3px 0;
  position: sticky;
  top: -6px;
  background: var(--panel);
}
.win-body td { padding: 2px 8px 2px 0; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.win-body tr:hover td { background: var(--row-hover); }
.win-body table.clickable tbody tr { cursor: pointer; }
.win-body h3 { margin: 8px 0 4px; font-size: 12px; }
.win-body pre { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.win-body .out { color: var(--accent); }
.win-body .in { color: var(--muted); }
.win-body .kv { display: grid; grid-template-columns: 130px 1fr; gap: 2px 10px; }
.win-body .kv span:nth-child(odd) { color: var(--muted); }

.win-console {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding: 5px 8px;
  flex: none;
  background: var(--side);
}
.win-console .prompt { color: var(--accent); font-family: var(--mono); }
.win-console input { flex: 1; font-size: 12px; font-family: var(--mono); }

/* The resize grip: the usual corner triangle, drawn rather than imaged. */
.win-grip {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, var(--btn-border) 50%, var(--btn-border) 62%, transparent 62%,
                    transparent 74%, var(--btn-border) 74%, var(--btn-border) 86%, transparent 86%);
}
.win.maximized .win-grip { display: none; }

/* ---- the right-click menu ---- */

#menu {
  position: absolute;
  z-index: 20;
  min-width: 180px;
  padding: 4px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px var(--shadow);
  font-size: 12px;
}
#menu .head { padding: 3px 12px 5px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 3px; }
#menu .item { padding: 5px 12px; cursor: pointer; display: flex; gap: 8px; }
#menu .item:hover { background: var(--selected); }
#menu .item .target { color: var(--muted); margin-left: auto; }
#menu .item .verb { color: var(--ink); }

/* ---- signed-in corner (session.js) ---- */

.me { display: inline-flex; gap: 12px; align-items: center; color: var(--muted); }
.me-name { color: var(--ink); font-weight: 600; }
.me a { color: var(--accent); text-decoration: none; }
.me a:hover { text-decoration: underline; }

/* ---- admin and account pages ---- */

body.page { height: auto; min-height: 100vh; }
.page-body { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 16px; display: block; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 8px; font-size: 15px; }
.card > p { margin: 0 0 10px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; }
.inline-form input { flex: 1; max-width: 360px; }
.stack-form { display: grid; gap: 8px; max-width: 360px; }
.stack-form label { color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.stack-form button { justify-self: start; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; color: var(--muted); font-weight: 400; border-bottom: 1px solid var(--line); padding: 5px 10px 5px 0; }
table.data td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; vertical-align: middle; }
table.data .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
table.data td.nowrap { white-space: nowrap; }
table.data td.detail { font-family: var(--mono); font-size: 11.5px; color: var(--muted); word-break: break-word; }
table.data button { padding: 2px 10px; font-size: 12px; }
input.code-input { width: 170px; font-family: var(--mono); text-transform: uppercase; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); }
.pill.active { color: var(--ok); }
.pill.pending { color: var(--warn); border-color: var(--warn); }
.pill.invited { color: var(--accent); }
.pill.disabled { color: var(--bad); }
.pill.muted-pill { color: var(--muted); }

.notice {
  padding: 8px 12px;
  border-radius: 6px;
  margin: 0 0 12px;
  background: var(--selected);
  border: 1px solid var(--line);
}
.notice.bad { background: var(--err-bg); border-color: var(--err-border); color: var(--err-ink); }

.secret-box { margin: 10px 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--side); }
.secret-box p { margin: 0 0 6px; }
.secret-box pre { margin: 6px 0 0; white-space: pre-wrap; word-break: break-all; font-size: 12px; }
.secret {
  font: 600 14px/1.4 var(--mono);
  padding: 8px 10px;
  border: 1px dashed var(--btn-border);
  border-radius: 6px;
  background: var(--panel);
  word-break: break-all;
  user-select: all;
}
#secret-dialog .secret { margin: 6px 0 4px; }

/* Audit log: the chain check and lines that did not go through. */
.chain { margin: 0 0 12px; font-weight: 600; }
.chain.ok { color: var(--ok); }
.chain.bad { color: var(--bad); }
tr.audit-bad td { color: var(--bad); }
tr.audit-bad td.muted { color: var(--bad); opacity: 0.8; }

/* ---- account creation status panel ---- */

/* A fixed-size window: the head (title, page switch, actions) stays put and only the page under
   it scrolls, so switching pages does not make the dialog jump around. */
dialog.panel {
  width: min(1080px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 48px));
  padding: 0;
  overflow: hidden;
}
dialog.panel[open] { display: flex; flex-direction: column; }
.cp-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--side);
}
.cp-head h2 { margin: 0 6px 0 0; font-size: 15px; }
.cp-head .spacer, .cp-jobs-head .spacer { flex: 1; }
.cp-head .small-note { font-size: 12px; font-variant-numeric: tabular-nums; }
#cp-close { padding: 2px 9px; }
.cp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 18px; outline: none; }
.cp-page[hidden] { display: none; }
.cp-page > * + * { margin-top: 14px; }

/* the segmented page switch */
.cp-seg { display: inline-flex; }
.cp-seg button { border-radius: 0; margin-left: -1px; padding: 3px 14px; font-size: 13px; }
.cp-seg button:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.cp-seg button:last-child { border-radius: 0 7px 7px 0; }

/* one section of a page */
.cp-card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 12px 14px; min-width: 0; }
dialog.panel h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* the toolbar's Creation menu */
.dropdown { position: relative; }
.dropdown .caret { font-size: 10px; margin-left: 2px; opacity: 0.85; }
.dd-menu { left: 0; right: auto; min-width: 190px; }
.dd-menu hr { border: 0; border-top: 1px solid var(--line); margin: 3px 2px; }
#chip-creating { cursor: pointer; }
#chip-creating:hover b { text-decoration: underline; }

.cp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.cp-tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--side); }
.cp-tile .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.cp-tile .k { font-size: 12px; color: var(--muted); }
.cp-tile .s { font-size: 11px; color: var(--faint); }
.cp-tile.ok .v { color: var(--ok); }
.cp-tile.warn .v { color: var(--warn); }
.cp-tile.bad .v { color: var(--bad); }

.cp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.cp-grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cp-grid section { min-width: 0; }
.cp-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.cp-line:last-child { border-bottom: 0; }
.cp-line .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-line .grow.block { white-space: normal; overflow-wrap: anywhere; }
.cp-line .num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.cp-empty { color: var(--faint); font-size: 13px; padding: 4px 0; }
.cp-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.cp-bar > span { display: block; height: 100%; background: var(--accent); }
.cp-bar.warn > span { background: var(--warn); }
.cp-bar.bad > span { background: var(--bad); }
.cp-sub { font-size: 12px; color: var(--muted); }

.cp-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--idle); }
.cp-dot.busy, .cp-dot.RUNNING { background: var(--warn); }
.cp-dot.idle, .cp-dot.DONE { background: var(--ok); }
.cp-dot.FAILED { background: var(--bad); }

.cp-jobs-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cp-jobs-head h3 { margin: 0; }
.cp-filter { display: flex; gap: 4px; }
.cp-filter button { padding: 1px 10px; font-size: 12px; }
.cp-filter button.on { background: linear-gradient(var(--on-top), var(--on-bottom)); }
.cp-table-wrap { overflow-x: auto; }
.cp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cp-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cp-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cp-table td.n { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.cp-table td.nw { white-space: nowrap; }
.cp-table td .sub { display: block; font-size: 11.5px; color: var(--muted); }
.cp-table td.detail { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-table td.detail.err { color: var(--bad); }
.cp-table tr.job-row { cursor: pointer; }
.cp-table tr.job-row:hover td { background: var(--row-hover); }
.cp-table tr.log-row td { background: var(--side); }
.cp-table tr.log-row pre { margin: 0; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; color: var(--muted); }
.cp-table button { padding: 1px 8px; font-size: 12px; }

.cp-flows > p.cp-sub { margin: -2px 0 8px; }
.cp-flow-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 8px 0; }
.cp-flow-add label { margin: 0; font-size: 12px; }
.cp-flow-add label select { display: block; margin-top: 2px; min-width: 150px; }
.cp-flow-add .arrow { padding-bottom: 6px; color: var(--muted); }
.cp-profile-form label input:not([type=checkbox]) { display: block; margin-top: 2px; min-width: 150px; }
.cp-profile-form label.inline { display: flex; align-items: center; gap: 5px; padding-bottom: 6px; }
.cp-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.cp-flow .route { font-weight: 600; }
.cp-flow .route .arrow { color: var(--muted); font-weight: 400; padding: 0 4px; }
.cp-flow.off .route { color: var(--faint); text-decoration: line-through; }
.cp-flow .grow { flex: 1; min-width: 200px; }
.cp-flow select { font-size: 12px; }
.cp-flow button { padding: 1px 9px; font-size: 12px; }
.cp-flow .cnt-ok { color: var(--ok); }
.cp-flow .cnt-warn { color: var(--warn); }
.cp-flow .cnt-bad { color: var(--bad); }
#cp-handoffs-box summary { cursor: pointer; font-size: 13px; padding: 4px 0; }
.cp-handoff { display: grid; grid-template-columns: 10px 160px 1fr auto; gap: 8px; align-items: baseline; padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.cp-handoff .d { color: var(--muted); overflow-wrap: anywhere; }
.cp-dot.PENDING { background: var(--warn); }
.cp-dot.FAILED { background: var(--bad); }
.cp-table td .sub.moved { color: var(--ok); }
.cp-table td .sub.stuck { color: var(--warn); }

/* provider usage view */
.cp-usage { padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--side); }
.cp-usage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cp-usage-head h3 { margin: 0; }
.cp-usage-head label { margin: 0; font-size: 12px; }
.cp-usage-head button { padding: 1px 10px; font-size: 12px; }
.cp-usage .cp-tile { background: var(--panel); }
.cp-usage[hidden] { display: none; }
.cp-tile.hero .v { font-size: 24px; white-space: nowrap; }
.cp-chart-head { font-size: 13px; margin: 6px 0 4px; }
.cp-chart { position: relative; height: 180px; margin-bottom: 12px; }
.cp-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cp-chart .bar { fill: var(--accent); }
.cp-chart .hit { fill: transparent; }
.cp-chart .hit:hover + .bar, .cp-chart .bar.hot { fill: color-mix(in srgb, var(--accent) 75%, var(--ink)); }
.cp-chart .grid { stroke: var(--line); stroke-width: 1; }
.cp-chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.cp-chart .peak { fill: var(--ink); font-size: 11px; font-weight: 600; }
.cp-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 12px; box-shadow: 0 4px 14px var(--shadow); white-space: nowrap; z-index: 2; }
.cp-tip b { display: block; font-size: 13px; }
.cp-hosts td.r, .cp-hosts th.r { text-align: right; font-variant-numeric: tabular-nums; }
.cp-hosts td.share { width: 190px; }
.cp-hosts td.share > div { display: flex; align-items: center; gap: 8px; }
.cp-hosts td.share .meter { flex: 1; }
.cp-hosts td.share .muted { width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.cp-hosts tr.more td { text-align: center; }
.cp-kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px 16px; margin: 4px 0 12px; }
.cp-kind { font-size: 12.5px; }
.cp-kind .row { display: flex; justify-content: space-between; gap: 8px; }
.cp-kind .row b { white-space: nowrap; }
.cp-kind .meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 3px; }
.cp-kind .meter > span { display: block; height: 100%; background: var(--accent); }
.cp-kind.noise .meter > span { background: var(--warn); }
.cp-hosts .meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.cp-hosts .meter > span { display: block; height: 100%; background: var(--accent); }
.cp-hosts tr.noise .meter > span { background: var(--warn); }
.cp-hosts .cat { white-space: nowrap; color: var(--muted); }

.cp-mail > p.cp-sub { margin: -2px 0 8px; }
.cp-dot.FREE { background: var(--ok); }
.cp-dot.LEASED { background: var(--warn); }
.cp-dot.USED { background: var(--accent); }
.cp-dot.BURNED { background: var(--bad); }
.cp-table td.r, .cp-table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.cp-card details { margin-top: 8px; }
.cp-card details > summary { cursor: pointer; font-size: 13px; padding: 4px 0; color: var(--ink); }

/* ---- background jobs in the top bar (session.js) ---- */

.jobs { position: relative; }
.jobs-chip {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: var(--side);
}
.jobs-chip.busy::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  vertical-align: -1px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: jobs-spin 0.9s linear infinite;
}
.jobs-chip.busy { color: var(--ink); }
.jobs-chip.with-bad { border-color: var(--bad); }
.jobs-chip.bad { color: var(--err-ink); background: var(--err-bg); border-color: var(--err-border); }
.jobs-chip.bad::before { content: "! "; font-weight: 700; }
.jobs-chip.ok { color: var(--ok); }
.jobs-chip.ok::before { content: "✓ "; }
@keyframes jobs-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .jobs-chip.busy::before { animation: none; } }

.jobs-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 1000;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  overflow: auto;
  padding: 8px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 24px var(--shadow);
}
.jobs-head { padding: 2px 14px 6px; font-weight: 600; color: var(--muted); font-size: 12px; }
.jobs-row { padding: 7px 14px; border-top: 1px solid var(--line); }
.jobs-title { display: flex; gap: 8px; align-items: baseline; }
.jobs-title b { font-weight: 600; }
.jobs-state { color: var(--muted); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.jobs-row.done .jobs-state { color: var(--ok); }
.jobs-row.failed .jobs-state { color: var(--bad); }
.jobs-bar { height: 5px; margin: 6px 0 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.jobs-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }
.jobs-bar.unknown i { width: 30%; animation: jobs-slide 1.2s ease-in-out infinite alternate; }
@keyframes jobs-slide { from { margin-left: 0; } to { margin-left: 70%; } }
.jobs-detail { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.jobs-error { color: var(--err-ink); background: var(--err-bg); border: 1px solid var(--err-border); border-radius: 5px;
  padding: 4px 7px; margin-top: 5px; font-size: 12px; font-family: var(--mono); overflow-wrap: anywhere; }
.jobs-dismiss { margin-top: 6px; padding: 2px 10px; font-size: 12px; }

/* the map's own word while it has no pictures: loading, or why it cannot be drawn */
.map-status {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  z-index: 500;
  max-width: min(560px, calc(100% - 32px));
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--overlay);
  border: 1px solid var(--line);
  color: var(--ink);
  box-shadow: 0 4px 18px var(--shadow);
  text-align: center;
  pointer-events: none;
  overflow-wrap: anywhere;
}
.map-status.bad { color: var(--err-ink); background: var(--err-bg); border-color: var(--err-border); }

/* the web walker's holding page while its data is built */
body.pending-page { height: auto; }
.pending { max-width: 640px; margin: 12vh auto; padding: 0 16px; }
.pending h1 { font-size: 20px; margin-bottom: 12px; }
.pending-status { font-family: var(--mono); padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow-wrap: anywhere; }
