:root {
  --bg: #f6f7f9; --panel: #fff; --text: #1b1f24; --dim: #5f6b7a; --line: #dfe3e8;
  --accent: #2f6fde; --accent-text: #fff; --good: #1a7f37; --bad: #cf222e; --warn: #9a6700;
  --row: #f9fafb; --code: #f0f2f5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --text: #e3e7ec; --dim: #8b96a5; --line: #2a313a;
    --accent: #4c8dff; --accent-text: #fff; --good: #3fb950; --bad: #f85149; --warn: #d29922;
    --row: #1b2027; --code: #1f252d;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --text: #e3e7ec; --dim: #8b96a5; --line: #2a313a;
  --accent: #4c8dff; --accent-text: #fff; --good: #3fb950; --bad: #f85149; --warn: #d29922;
  --row: #1b2027; --code: #1f252d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.dim { color: var(--dim); }
.sub { color: var(--dim); margin: -6px 0 14px; }
main { padding: 20px 24px 60px; max-width: 1600px; margin: 0 auto; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 24px; background: var(--panel);
       border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--text); }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 6px 12px; border-radius: 6px; color: var(--dim); }
.top nav a.on, .top nav a:hover { background: var(--code); color: var(--text); text-decoration: none; }
.who { display: flex; gap: 10px; align-items: center; color: var(--dim); margin: 0; }
.notesbtn { flex: none; padding: 5px 12px; font-size: 13px; }

.subnav { display: flex; align-items: center; gap: 4px; padding: 8px 24px; background: var(--panel);
          border-bottom: 1px solid var(--line); position: sticky; top: 45px; z-index: 4; flex-wrap: wrap; }
.subnav a { padding: 5px 11px; border-radius: 6px; color: var(--dim); }
.subnav a.on, .subnav a:hover { background: var(--code); color: var(--text); text-decoration: none; }
.subnav .dbcrumb { color: var(--dim); padding-left: 0; }
.subnav .sep { color: var(--dim); opacity: .6; }
.subnav .dbcur { font-weight: 700; color: var(--text); margin-right: 8px; }

.theme-toggle { flex: none; width: 46px; height: 26px; padding: 0; position: relative; cursor: pointer;
  background: var(--code); border: 1px solid var(--line); border-radius: 999px; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle .thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; transition: left .15s ease; }
.theme-toggle .thumb::after { content: "\2600"; }
:root[data-theme="dark"] .theme-toggle .thumb { left: 22px; }
:root[data-theme="dark"] .theme-toggle .thumb::after { content: "\263E"; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .thumb { left: 22px; }
  :root:not([data-theme="light"]) .theme-toggle .thumb::after { content: "\263E"; }
}

button, .btn { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); cursor: pointer; display: inline-block; }
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button.link { background: none; border: 0; color: var(--accent); padding: 0; }
.btn:hover { text-decoration: none; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; resize: vertical; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 14px; }
.bar label { display: flex; gap: 6px; align-items: center; color: var(--dim); }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.more { font-size: 12px; font-weight: 400; }
h2.section { margin: 22px 0 12px; padding-top: 4px; border-top: 1px solid var(--line); }

.gaugerow { display: flex; flex-wrap: wrap; gap: 8px; }
.gaugerow .gauge { flex: 1 1 110px; min-width: 0; }
.gaugerow .gaugeimg { max-width: 200px; }
.gauge { text-align: center; padding: 6px 0 2px; }
.glabel { font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.gaugeimg { width: 100%; max-width: 260px; height: auto; }
.gtrack { stroke: var(--code); }
.gval { stroke: var(--good); transition: stroke-dashoffset .4s ease; }
.gval.good { stroke: var(--good); }
.gval.warnc { stroke: var(--warn); }
.gval.bad { stroke: var(--bad); }
.gpct { fill: var(--text); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gpct.gna { fill: var(--dim); font-size: 22px; }
.gval.ghidden { display: none; }

/* Disk usage bars — a row below the gauges, one bar per physical storage device. */
.diskrow { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; padding-top: 12px; border-top: 0.5px solid var(--line); }
.diskbar { flex: 1 1 220px; min-width: 0; }
.dbhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12px; }
.dbdev { font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbpct { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.dbkind { font-size: 9.5px; font-weight: 600; letter-spacing: .03em; color: var(--dim); border: 0.5px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 4px; vertical-align: 1px; }
.dbtemp { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; margin-left: 4px; }
.dbsub { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 11px; color: var(--dim); margin: 1px 0 5px; }
.dbmounts { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbunmounted .dbpct, .dbunmounted .dbdev { color: var(--dim); font-weight: 400; }
.dbunmounted .dbpct { font-weight: 600; }
.dberror .dbpct { color: var(--bad); font-weight: 700; }

/* Clickable dashboard cells → per-host detail pages. The link is the flex item. */
.celllink { display: block; text-decoration: none; color: inherit; border-radius: 10px; padding: 2px; transition: background .12s; }
.celllink:hover { background: var(--row); }
.celllink > * { width: 100%; }
.gaugerow .celllink { flex: 1 1 110px; min-width: 0; }
.netrow .celllink { flex: 1 1 150px; min-width: 0; }
.diskrow .celllink { flex: 1 1 220px; min-width: 0; }

/* Per-host detail pages (System / Interfaces / Storage). */
.detailtop { margin-bottom: 6px; }
.hosttitle { margin: 0 0 16px; }
.hostsection { color: var(--dim); font-weight: 400; }
.detailgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .detailgrid { grid-template-columns: 1fr; } }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.dcard h2 { margin: 0 0 10px; font-size: 15px; }
table.kv { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
table.kv td { padding: 4px 0; font-size: 13px; vertical-align: top; }
table.kv td:first-child { color: var(--dim); width: 46%; }
table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.dfs { margin-top: 4px; font-size: 12px; }
.dfs td, .dfs th { padding: 3px 6px; }
.pill { font-size: 10.5px; font-weight: 600; color: var(--dim); border: 0.5px solid var(--line); border-radius: 20px; padding: 1px 8px; vertical-align: 2px; }
.pill-up { color: var(--good); border-color: var(--good); }
.pill-warn { color: var(--warn); border-color: var(--warn); }
.pill-down { color: var(--bad); border-color: var(--bad); }
table.kv td.errval { color: var(--bad); font-weight: 600; }
.dfs .u-warn { color: var(--warn); }
.dfs .u-bad { color: var(--bad); font-weight: 600; }
.dbval { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dbtrack { height: 9px; background: var(--code); border-radius: 5px; overflow: hidden; }
.dbfill { height: 100%; border-radius: 5px; background: var(--good); transition: width .4s ease; }
.dbfill.warnc { background: var(--warn); }
.dbfill.bad { background: var(--bad); }

/* NIC throughput cards — the bottom row, one card per interface. */
.netrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 0.5px solid var(--line); }
.netcard { flex: 1 1 150px; min-width: 0; background: var(--code); border-radius: 8px; padding: 8px 12px; }
.netdev { font-size: 12px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.netline { display: flex; justify-content: space-between; align-items: baseline; }
.netlbl { font-size: 11px; color: var(--dim); }
.netval { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.netval.in { color: var(--good); }
.netval.out { color: var(--accent); }
.spark { width: 100%; height: 18px; display: block; margin: 1px 0 6px; }
.spark-in { stroke: var(--good); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark-out { stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* Full-screen SSH terminal page. */
body.sshbody { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.sshbar { display: flex; align-items: center; gap: 14px; padding: 8px 16px; flex: none;
          background: var(--panel); border-bottom: 1px solid var(--line); }
.sshbar .spacer { flex: 1; }
.term { flex: 1; min-height: 0; padding: 6px 4px 4px 8px; background: var(--panel); }
.term .xterm { height: 100%; }
.term .xterm-viewport { overflow-y: auto; }

/* Terminal help overlay */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
         background: rgba(0, 0, 0, .5); padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px;
              max-width: 560px; width: 100%; box-shadow: 0 12px 48px rgba(0, 0, 0, .35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head strong { font-size: 15px; }
.modal-head .link { font-size: 16px; line-height: 1; }
.help-table { width: 100%; border-collapse: collapse; }
.help-table th, .help-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.help-table th { color: var(--dim); font-weight: 600; }
.help-table td:first-child { color: var(--dim); white-space: nowrap; }
.helpnote { font-size: 12px; margin: 12px 0 2px; }
.notes-card { max-width: 640px; }
.notes-text { width: 100%; min-height: 340px; resize: vertical; }

/* Embedded Web browser page */
.webbar { margin-bottom: 8px; }
.webbar #weburl { flex: 1; min-width: 260px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.webquick { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.webframe { width: 100%; height: calc(100vh - 220px); min-height: 380px; background: #fff;
            border: 1px solid var(--line); border-radius: 8px; }

/* Files page */
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; font-size: 14px; }
.crumbs .sep { color: var(--dim); }
.fileactions { gap: 20px; }
.fileform { display: flex; gap: 8px; align-items: center; margin: 0; }
.delform, .renameform { display: inline; margin: 0; }
.rowactions { display: flex; gap: 6px; justify-content: flex-end; }
.rowactions button, .rowactions .btn { padding: 3px 10px; font-size: 13px; }

/* File viewer */
.codeview { background: var(--code); border: 1px solid var(--line); border-radius: 8px;
            padding: 12px 14px; overflow: auto; max-height: 80vh; font-size: 13px; line-height: 1.5;
            font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre; }
.jsonview .j-key { color: var(--accent); }
.jsonview .j-str { color: var(--good); }
.jsonview .j-num { color: var(--warn); }
.jsonview .j-lit { color: var(--bad); font-weight: 600; }
.hash { color: var(--good); }
.int { color: var(--warn); }
.kw { color: var(--bad); font-weight: 600; }

/* File compare (diff) */
.diff { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 80vh;
        font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.dl { white-space: pre; padding: 0 10px; }
.dl .dsign { display: inline-block; width: 14px; color: var(--dim); }
.d-add { color: var(--good); }
.d-del { color: var(--bad); }
.dl.d-add { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.dl.d-del { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.dl.d-ctx { color: var(--dim); }
.drawview { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 8px;
            background: #fff; padding: 8px; min-height: 300px; }

/* Rsync page — two-pane (FileZilla-style) transfer tool */
.rsync-wrap { display: flex; flex-direction: column; gap: 10px; }
.rsync-panes { display: flex; gap: 10px; align-items: stretch; }
.pane { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
        border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
             padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--code); }
.pane-title { font-weight: 600; }
.pane-head .loc { display: flex; gap: 10px; }
.pane-head .loc label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--dim); }
.pane-head .remote-fields { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.pane-head .remote-fields input.r-host { width: 110px; }
.pane-head .remote-fields input.r-user { width: 84px; }
.pane-head .remote-fields input { font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.r-status { font-size: 12px; min-width: 70px; }
.r-status.ok { color: var(--good); } .r-status.warn { color: var(--warn, #d08b24); }
.pane-path { display: flex; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.pane-path .p-path { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.pane-path .p-up, .pane-path .p-go { padding: 4px 10px; }
.pane-list { list-style: none; margin: 0; padding: 4px; overflow: auto; height: 300px; }
.pane-list li { padding: 3px 8px; border-radius: 5px; cursor: default; font-size: 13px;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-list li.d { cursor: pointer; }
.pane-list li.d:hover, .pane-list li.f:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pane-list li.sel { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.pane-list li.pane-err { color: var(--bad); white-space: normal; cursor: default; }
.pane-list li.pane-hint, .pane-list li.pane-wait { color: var(--dim); cursor: default; }
.rsync-endpoints { display: flex; gap: 10px; }
.rsync-endpoints label.grow { flex: 1; min-width: 0; }
.rsync-endpoints label.grow input { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.rsync-opts { align-items: center; gap: 14px; }
.rterm { height: 240px; min-height: 180px; padding: 6px 4px 4px 8px;
         background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.rterm .xterm { height: 100%; }
@media (max-width: 820px) { .rsync-panes, .rsync-endpoints { flex-direction: column; } .pane-list { height: 220px; } }
.mdbody { max-width: 900px; line-height: 1.65; }
.mdbody h1, .mdbody h2, .mdbody h3, .mdbody h4 { margin: 20px 0 8px; line-height: 1.25; }
.mdbody h1 { font-size: 24px; } .mdbody h2 { font-size: 19px; } .mdbody h3 { font-size: 16px; }
.mdbody p, .mdbody ul, .mdbody ol { margin: 0 0 12px; }
.mdbody pre { background: var(--code); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; overflow: auto; }
.mdbody code { background: var(--code); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.mdbody pre code { background: none; padding: 0; }
.mdbody table { border-collapse: collapse; margin: 0 0 12px; }
.mdbody th, .mdbody td { border: 1px solid var(--line); padding: 6px 10px; }
.mdbody blockquote { border-left: 3px solid var(--line); margin: 0 0 12px; padding: 2px 14px; color: var(--dim); }
.mdbody img { max-width: 100%; }
.mdbody a { color: var(--accent); }
kbd { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--code);
      border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.gdetail { color: var(--dim); font-size: 12px; margin-top: -4px; }

.scroll { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.panel .scroll { max-height: 360px; }
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 5px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.grid th { position: sticky; top: 0; background: var(--code); font-weight: 600; font-size: 12px; }
.grid tbody tr:nth-child(even) { background: var(--row); }
.grid .num { text-align: right; }
.grid .null { color: var(--dim); font-style: italic; font-size: 12px; }
.grid .empty { color: var(--dim); text-align: center; padding: 16px; }
.good { color: var(--good); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.warnc { color: var(--warn); font-weight: 600; }
.meta { color: var(--dim); font-size: 12px; margin: 6px 2px 0; }
.warn { color: var(--warn); }

pre.error { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; }
p.error { color: var(--bad); margin: 0; }
details { margin: 12px 0; }
summary { cursor: pointer; color: var(--dim); }
details pre, code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
details pre { background: var(--code); padding: 10px; border-radius: 8px; overflow: auto; }
.history ul { list-style: none; padding: 0; margin: 8px 0; }
.history li { margin: 4px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; }

.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cards a { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; color: var(--text); height: 100%; }
.cards a:hover { border-color: var(--accent); text-decoration: none; }
.cards span { color: var(--dim); font-size: 13px; }

.login { max-width: 340px; margin: 12vh auto 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 28px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 13px; }
.login button { margin-top: 6px; padding: 8px; }

@media (max-width: 700px) {
  main { padding: 16px; }
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .panels { grid-template-columns: 1fr; }
}

.login .ipnote { margin: 16px 0 0; text-align: center; color: var(--dim); font-size: 12px; }
.login .ipnote code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--text); }

.login .banner { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 11px; line-height: 1.5;
  text-align: left; color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.login .banner strong { color: var(--warn); }

.login .lannote { margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 12px; text-align: center;
  color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent); }

.grid th { cursor: pointer; user-select: none; }
.grid th:hover { background: color-mix(in srgb, var(--accent) 14%, var(--code)); }
.grid th[data-sort] { color: var(--accent); }
.sort-ind { font-size: 10px; opacity: .85; }

/* Excel-style per-column sort + filter */
.th-filter { margin-left: 6px; font-size: 20px; line-height: 1; opacity: .5; cursor: pointer;
             display: inline-block; padding: 2px 4px; border-radius: 4px; vertical-align: middle; }
.th-filter:hover { opacity: 1; background: color-mix(in srgb, var(--accent) 22%, transparent); }
.grid th.filtered { color: var(--accent); }
.grid th.filtered .th-filter { opacity: 1; color: var(--accent); }
/* keep zebra striping correct while a filter hides rows */
.grid.filtering tbody tr:nth-child(even) { background: transparent; }
.grid.filtering tbody tr.odd { background: var(--row); }

.colmenu { position: fixed; z-index: 60; width: 250px; max-width: calc(100vw - 16px);
           background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
           box-shadow: 0 8px 28px rgba(0,0,0,.4); padding: 8px; font-size: 13px; }
.colmenu .cm-sort { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px;
                    padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.colmenu .cm-sort button { text-align: left; background: none; border: 0; color: var(--text);
                           padding: 5px 7px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.colmenu .cm-sort button:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.colmenu .cm-search { width: 100%; margin-bottom: 6px; font-size: 13px; }
.colmenu .cm-all { display: block; padding: 3px 4px; font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.colmenu .cm-list { list-style: none; margin: 0; padding: 0; max-height: 230px; overflow: auto; }
.colmenu .cm-list li { padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.colmenu .cm-list label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.colmenu .cm-list li:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.colmenu .cm-actions { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.colmenu .cm-actions button { flex: 1; padding: 5px; }

.roleform { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin: 0; }
.rolechk { display: inline-flex; gap: 5px; align-items: center; color: var(--text); font-size: 13px; white-space: nowrap; }
.roleform button { padding: 4px 12px; }
button.danger, .link.danger { color: var(--bad); border-color: var(--bad); }
button.link.danger { background: none; border: 0; }

.invitebox { background: color-mix(in srgb, var(--good) 10%, transparent); border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
  border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; font-size: 13px; }
.invitelink { width: 100%; margin-top: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.detailgrid .span2 { grid-column: 1 / -1; }
.tempgroups { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; }
.tempgroup h3 { margin: 6px 0 2px; font-size: 12px; font-weight: 600; color: var(--dim); }
.tempgroup table.kv td:first-child { width: auto; }

/* ---- Messenger (presence + 1:1 chat floating panel) --------------------- */
#msgr-toggle { display: inline-flex; align-items: center; gap: 6px; position: relative; padding: 6px 10px; border-radius: 6px; }
.sshbar #msgr-toggle { color: var(--text); }
.sshbar #msgr-toggle:hover { background: var(--code); text-decoration: none; }
.msgr-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.12) inset; }
.msgr-dot[data-status="online"]    { background: var(--good); }
.msgr-dot[data-status="away"]      { background: var(--warn); }
.msgr-dot[data-status="dnd"]       { background: var(--bad); }
.msgr-dot[data-status="invisible"] { background: transparent; box-shadow: 0 0 0 1.5px var(--dim) inset; }
.msgr-dot[data-status="offline"]   { background: var(--dim); opacity: .5; }
.msgr-badge { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad);
  color: #fff; font-size: 11px; line-height: 16px; text-align: center; font-weight: 700; }

/* Flash the Messenger nav button + its dot while there are unread messages. */
#msgr-toggle.msgr-alert { animation: msgr-flash 1.1s ease-in-out infinite; border-radius: 6px; }
#msgr-toggle.msgr-alert .msgr-dot { animation: msgr-dotflash 1.1s ease-in-out infinite; }
@keyframes msgr-flash {
  0%, 100% { background: transparent; color: var(--dim); }
  50% { background: var(--bad); color: #fff; }
}
@keyframes msgr-dotflash { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) {
  #msgr-toggle.msgr-alert { animation: none; background: var(--bad); color: #fff; border-radius: 6px; }
  #msgr-toggle.msgr-alert .msgr-dot { animation: none; }
}

.msgr-panel { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 640px; max-width: calc(100vw - 24px);
  height: 460px; max-height: calc(100vh - 80px); display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.28); overflow: hidden; }
/* The base rule sets display:flex, which would otherwise override the [hidden]
   attribute — so hiding/closing the panel needs this explicit rule. */
.msgr-panel[hidden] { display: none; }
/* Drag-to-resize grip (floating panel only), bottom-right corner. */
.msgr-resize { position: absolute; right: 0; bottom: 0; width: 16px; height: 16px; z-index: 2;
  cursor: nwse-resize; }
.msgr-resize::after { content: ""; position: absolute; right: 3px; bottom: 3px; width: 8px; height: 8px;
  border-right: 2px solid var(--dim); border-bottom: 2px solid var(--dim); opacity: .55; }
.msgr-standalone .msgr-resize, .msgr-min .msgr-resize { display: none; }
/* Minimized: collapse to just the title bar so it doesn't cover the page. */
.msgr-panel.msgr-min { height: auto !important; }
.msgr-panel.msgr-min .msgr-body { display: none; }
.msgr-head .msgr-min-btn { font-size: 15px; line-height: 1; padding: 2px 4px; }
.msgr-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--code); cursor: move; user-select: none; }
.msgr-head strong { font-size: 14px; }
.msgr-me { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgr-status { font: inherit; font-size: 12px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); }
.msgr-close { font-size: 15px; line-height: 1; padding: 2px 4px; }

.msgr-body { flex: 1; display: flex; min-height: 0; }
.msgr-contacts { width: 190px; flex: none; border-right: 1px solid var(--line); overflow-y: auto; padding: 6px; }
.msgr-empty { padding: 10px 8px; font-size: 12px; }
.msgr-contact { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none;
  color: var(--text); padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.msgr-contact:hover { background: var(--code); }
.msgr-contact.on { background: var(--code); }
.msgr-cname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.msgr-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.msgr-chat-head { padding: 8px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
  min-height: 36px; font-size: 13px; }
.msgr-log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.msgr-info { align-self: center; font-size: 11px; font-style: italic; text-align: center; max-width: 90%; }
.msgr-msg { display: flex; }
.msgr-msg.mine { justify-content: flex-end; }
.msgr-bubble { max-width: 78%; padding: 6px 10px; border-radius: 10px; background: var(--code);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msgr-msg.mine .msgr-bubble { background: var(--accent); color: var(--accent-text); }
.msgr-text { white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.msgr-ts { flex: none; font-size: 10px; opacity: .65; }
.msgr-compose { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); align-items: center; }
.msgr-attach { flex: none; font-size: 16px; line-height: 1; padding: 4px 6px; }
.msgr-attach:disabled { opacity: .4; cursor: default; }
.msgr-input { flex: 1; font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.msgr-input:disabled { opacity: .6; }
.msgr-send { flex: none; padding: 7px 14px; }
.msgr-fileatt { display: inline-block; font-size: 13px; word-break: break-all; }
.msgr-msg.mine .msgr-fileatt { color: var(--accent-text); text-decoration: underline; }
.msgr-chat.msgr-drop { outline: 2px dashed var(--accent); outline-offset: -6px; }

@media (max-width: 560px) {
  .msgr-panel { width: calc(100vw - 16px); height: calc(100vh - 70px); right: 8px; bottom: 8px; }
  .msgr-contacts { width: 140px; }
}

/* Messenger pop-out page (/messenger, opened in its own tab) */
.msgr-head .msgr-pop { font-size: 15px; line-height: 1; padding: 2px 4px; }
body.msgrbody { height: 100vh; overflow: hidden; }
#msgr-root { height: 100vh; display: flex; }
.msgr-panel.msgr-standalone { position: static; width: 100%; max-width: none; height: 100%;
  max-height: none; border: 0; border-radius: 0; box-shadow: none; }
.msgr-standalone .msgr-head { cursor: default; }
.msgr-standalone .msgr-pop,
.msgr-standalone .msgr-min-btn { display: none; }
/* New-message attention: recolor the pop-out tab's header (paired with the red
   favicon swap) so a background tab is easy to spot. */
body.msgr-attention .msgr-standalone .msgr-head { background: var(--bad); }
body.msgr-attention .msgr-standalone .msgr-head strong,
body.msgr-attention .msgr-standalone .msgr-head .msgr-me { color: #fff; }
