/* UEXT Switch Master Server */
:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1d2733; --muted: #6b7785; --line: #e2e7ee; --field: #aeb8c4;
  --brand: #1f5fbf; --brand-d: #174a96; --g: #1f9d55; --r: #d64545; --a: #d98a00;
  --radius: 10px; font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161d; --card: #1a212b; --ink: #e6ebf1; --muted: #93a0ae; --line: #2a3441; --field: #566476; --brand: #4d8ff0; --brand-d: #3b78d4; }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
header.top { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: .7rem 1.4rem; background: #142033; color: #fff; }
header.top a { color: #cfd9e6; }
.brand { font-weight: 700; font-size: 1.1rem; white-space: nowrap; } .brand small { font-weight: 400; color: #9fb0c6; }
.logo { color: #6fd08c; }
nav { display: flex; gap: .3rem; flex-wrap: wrap; flex: 1; }
nav a { padding: .35rem .7rem; border-radius: 6px; } nav a.on, nav a:hover { background: #24364f; color: #fff; text-decoration: none; }
.who { font-size: .99rem; color: #9fb0c6; }
main { max-width: 1400px; margin: 0 auto; padding: 1.2rem; }
footer { text-align: center; color: var(--muted); font-size: .89rem; padding: 1.5rem; }
h1 { font-size: 1.35rem; margin: 0 0 .8rem; } h2 { font-size: 1.1rem; margin: 1.2rem 0 .6rem; } h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
h1 small, h2 small { font-weight: 400; color: var(--muted); font-size: .8em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.1rem; }
.card > h2:first-child { margin-top: 0; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1.1rem; align-items: start; }
.cols > .card { margin-bottom: 0; } .cols { margin-bottom: 1.1rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .6rem 0; }
.row.between { justify-content: space-between; } .row h1 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; color: var(--muted); }
.tile b { display: block; font-size: 1.7rem; color: var(--ink); }
.tile.g { border-left-color: var(--g); } .tile.r { border-left-color: var(--r); } .tile.a { border-left-color: var(--a); }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .89rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 2px solid var(--line); padding: .45rem .5rem; }
table.list td { border-bottom: 1px solid var(--line); padding: .5rem; vertical-align: top; }
table.list tr.bad td { background: rgba(214, 69, 69, .07); }
table.list tr.awaiting td { background: rgba(217, 138, 0, .09); }
table.list tr.published td { background: rgba(31, 157, 85, .07); }
table.small td, table.small th, .small { font-size: .94rem; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; padding: .25rem 1rem .25rem 0; vertical-align: middle; white-space: nowrap; }
table.kv td { padding: .25rem 0; vertical-align: middle; }
.mono, code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
code { background: rgba(127, 127, 127, .12); padding: .05rem .3rem; border-radius: 4px; word-break: break-all; }
pre { background: rgba(127, 127, 127, .1); padding: .7rem; border-radius: 6px; overflow-x: auto; }
.muted { color: var(--muted); } .nowrap { white-space: nowrap; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .4rem; vertical-align: baseline; background: var(--field); }
.dot.g { background: var(--g); box-shadow: 0 0 0 3px rgba(31, 157, 85, .2); } .dot.r { background: var(--r); }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .87rem; font-weight: 700; color: #fff; }
.pill.g { background: var(--g); } .pill.r { background: var(--r); } .pill.a { background: var(--a); }
.cfg { font-size: .91rem; padding: .1rem .45rem; border-radius: 5px; background: rgba(127, 127, 127, .12); }
.cfg.ok { color: var(--g); } .cfg.pending, .cfg.awaiting { color: var(--a); } .cfg.ahead, .cfg.none { color: var(--r); }
.cmd.pending, .cmd.sent { color: var(--a); } .cmd.done { color: var(--g); } .cmd.cancelled { color: var(--muted); }
.warn-t { color: var(--a); }
label { display: block; margin: .55rem 0; font-weight: 500; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; border: 1px solid var(--field); border-radius: 6px; background: var(--card); color: var(--ink); font: inherit; }
input[type=checkbox] { display: inline-block; width: auto; margin: 0 .35rem 0 0; }
input[type=search] { width: 320px; max-width: 100%; margin: 0; }
.check { font-weight: 400; display: inline-block; margin-top: .3rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; } .grid2 .span2, .grid2 .check-row { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } .cols { grid-template-columns: 1fr; } }
button, .btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: .5rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
button:not(:disabled):hover, .btn:hover { background: var(--brand-d); text-decoration: none; }
button.sm, .btn.sm { padding: .25rem .6rem; font-size: .91rem; }
button.warn { background: var(--r); } button.warn:not(:disabled):hover { background: #b33636; }
button.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
button:disabled { opacity: .45; cursor: default; }
form.inline { display: inline; }
.bulkbar { border-top: 1px solid var(--line); padding-top: .7rem; }
.flash { padding: .65rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: rgba(31, 157, 85, .12); border: 1px solid rgba(31, 157, 85, .35); }
.flash.err { background: rgba(214, 69, 69, .1); border-color: rgba(214, 69, 69, .4); }
.warnbox { border-left: 5px solid var(--a); } .dangerbox { border-left: 5px solid var(--r); }
.status-hero { border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-bottom: 1.1rem; background: var(--card); border: 1px solid var(--line); }
.status-hero.ok { background: rgba(31, 157, 85, .12); border-color: rgba(31, 157, 85, .4); }
.status-hero.bad { background: rgba(214, 69, 69, .1); border-color: rgba(214, 69, 69, .4); }
.status-hero h1 { margin: 0 0 .2rem; } .status-hero p { margin: 0; color: var(--muted); }
details { border-bottom: 1px solid var(--line); padding: .4rem 0; } summary { cursor: pointer; }
input.copy { cursor: copy; }

.emu pre { max-height: 22em; overflow: auto; }
.emu .io { display: grid; grid-template-columns: 1fr 1fr; gap: 1em; }
@media (max-width: 900px) { .emu .io { grid-template-columns: 1fr; } }

/* /first switch in the top bar */
header.top .firstsw { margin: 0; }
header.top .sw { border: 0; border-radius: 999px; padding: .3rem .8rem; font-size: .94rem; cursor: pointer; color: #fff; }
header.top .sw.on { background: #1f8a4c; }
header.top .sw.off { background: #8a2b1f; }

/* user portal */
.progress { height: 8px; background: rgba(127, 127, 127, .2); border-radius: 4px; overflow: hidden; margin: .7rem 0 .3rem; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); }
.progress.run span { transition: width 1s linear; }
.nexttxt { display: block; min-height: 1.3em; }
.check.radio { margin: .25rem 0; }
.suffix { display: flex; align-items: center; gap: .3rem; }
.suffix input { flex: 1; margin-top: 0; }
label.alias { flex: 1; min-width: 260px; }
.codein { font-size: 1.3rem; text-transform: uppercase; }

/* emulator: the dongle's OLED */
.oled { display: inline-block; padding: 10px; background: #1b1f24; border-radius: 8px; }
.oled canvas { display: block; width: 512px; max-width: 100%; height: auto; image-rendering: pixelated; border-radius: 2px; }
.oled .row { margin: .5rem 0 0; color: #9fb0c6; }
.oled button.on { background: var(--brand); color: #fff; }

/* button help (assets/help.js): after 3 s of hovering */
.helptip { position: fixed; pointer-events: none; z-index: 1000; max-width: 300px; padding: .45rem .65rem; border-radius: 6px; background: #142033;
  color: #fff; font-size: .91rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); pointer-events: none; }
button.secondary.on { background: var(--brand); color: #fff; }

/* device list: tiles filter, headings sort, one line per device */
a.tile { display: block; text-decoration: none; cursor: pointer; }
a.tile:hover { text-decoration: none; border-color: var(--brand); }
a.tile.sel { outline: 2px solid var(--brand); outline-offset: -2px; }
table.oneline td { white-space: nowrap; vertical-align: middle; }
table.oneline td small { margin-left: .3rem; }
a.sort { color: inherit; text-decoration: none; } a.sort:hover, a.sort.on { color: var(--brand); }

/* live device list */
.tiles button.tile { font: inherit; text-align: left; cursor: pointer; }
.tiles button.tile:hover { border-color: var(--brand); }
.tile.sel { outline: 2px solid var(--brand); outline-offset: -2px; }
button.sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
button.sort:hover, button.sort.on { color: var(--brand); }
button.sort::after { content: attr(data-arrow); }
.pbar { width: 150px; height: 6px; border-radius: 3px; background: rgba(127, 127, 127, .25); overflow: hidden; margin: .15rem 0; }
.pbar span { display: block; height: 100%; width: 0; background: var(--brand); }
.pbar.run span { transition: width .9s linear; }
.pollbar { min-height: 2.2rem; }          /* room for the bar and its text before they are drawn: no page movement */
.pollbar small { display: block; min-height: 1.2em; white-space: nowrap; }
.pbar.late span { background: var(--r); }

pre.errlog{white-space:pre-wrap;word-break:break-all;max-height:20em;overflow:auto}
/* Green is ON */
button.ok, .btn.ok { background: var(--g); } button.ok:not(:disabled):hover, .btn.ok:hover { background: #17834a; }
button.secondary.on, .oled button.on { background: var(--g); border-color: var(--g); color: #fff; }
.bulkbar select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--field); border-radius: 6px; background: var(--card); color: var(--ink); }
.netpanel { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .6rem; margin: .6rem 0; }
.netpanel fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; margin: 0; }
.netpanel legend { font-weight: 700; padding: 0 .3rem; }
.netpanel label { display: block; margin: .25rem 0; }
/* Watchdog and alert settings */
fieldset.checks { border: 0; padding: 0; margin: .4rem 0; display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
fieldset.checks legend { padding: 0; margin-bottom: .2rem; }
.row.checks { gap: .2rem 1.2rem; }
.wdrow { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .8rem; margin: 0 0 .7rem; }
.wdrow legend { font-weight: 700; padding: 0 .3rem; }
.wdrow .row label { flex: 1 1 9rem; }
input.num { width: 4.5rem; }
label.inline { display: inline-flex; align-items: center; gap: .3rem; margin: 0 .3rem; }
.row.tight { gap: .4rem; flex-wrap: nowrap; margin: 0; }
.row.tight .grow { flex: 1 1 auto; min-width: 8rem; }
/* "?" help: hover, focus or tap shows what a setting does */
.qh { display: inline-flex; align-items: center; justify-content: center; width: 1.15em; height: 1.15em; border-radius: 50%;
      border: 1px solid var(--muted); color: var(--muted); font-size: .84rem; font-weight: 700; cursor: help; position: relative;
      margin-left: .25rem; vertical-align: middle; user-select: none; }
.qh:hover, .qh:focus { border-color: var(--brand); color: var(--brand); outline: none; }
.qh:hover::after, .qh:focus::after { content: attr(data-tip); position: absolute; left: 50%; top: 1.6em; transform: translateX(-50%);
      width: 18rem; max-width: 80vw; padding: .5rem .65rem; border-radius: 6px; background: var(--ink); color: var(--card);
      font-size: .89rem; font-weight: 400; line-height: 1.35; text-align: left; z-index: 20; box-shadow: 0 4px 14px rgba(0,0,0,.25); white-space: normal; }
details.fold > summary { list-style: none; display: flex; align-items: baseline; gap: .6rem; cursor: pointer; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '\25B8'; color: var(--muted); width: .8em; }
details.fold[open] > summary::before { content: '\25BE'; }
details.fold > summary h2 { margin: 0; display: inline; }
details.fold[open] > summary { margin-bottom: .7rem; }
details.card.fold { border: 1px solid var(--line); padding: 1.1rem 1.3rem; }
label.off { opacity: .45; }

/* user page: title with its edit link, and the switch on the right of the first panel */
.titlebox { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .8rem; }
.titlebox h1 { margin: 0; }
details.inline-edit > summary { list-style: none; display: inline; color: var(--brand); cursor: pointer; font-size: .99rem; text-decoration: underline; }
details.inline-edit > summary::-webkit-details-marker { display: none; }
details.inline-edit[open] > summary { font-weight: 600; }
details.inline-edit form { margin-top: .5rem; align-items: flex-end; }
details.inline-edit form label { flex: 1 1 12rem; }
.row.top { align-items: flex-start; }
.grow { flex: 1 1 22rem; min-width: 0; }
.switchbox { flex: 0 0 auto; text-align: right; min-width: 12rem; }
.switchbox .swstate { font-size: 1.15rem; margin: .1rem 0; }
.switchbox .swpend { min-height: 1.6em; }
.switchbox .swbtns { justify-content: flex-end; }
@media (max-width: 640px) { .switchbox { text-align: left; } .switchbox .swbtns { justify-content: flex-start; } }
/* user page: the switch state on the status line, ON / OFF / CYCLE stacked on the right, all the same size */
.statusline .swstate .dot { margin-left: 0; }
.statusline.swline { margin-top: .35rem; padding-bottom: 1.1rem; }   /* a blank line after the switch status */
.statusline .swpend .pill { margin-left: .2rem; }
form.swbtns { display: flex; flex-direction: column; align-items: stretch; gap: .45rem; flex: 0 0 7.5rem; margin-left: 1rem; }
form.swbtns button { width: 100%; padding: .45rem 0; text-align: center; }
/* network and watchdog lines: hover or click (keyboard: focus) shows the details */
.netlines { margin: .7rem 0; line-height: 1.7; }
.hoverinfo { position: relative; display: block; width: max-content; max-width: 100%; cursor: help; border-radius: 4px; outline: none; }
.hoverinfo:hover, .hoverinfo:focus-within { background: rgba(127, 127, 127, .08); }
.hoverinfo .pop { display: none; position: absolute; left: calc(100% + .8rem); top: -.5rem; z-index: 30; min-width: 22rem; background: var(--card, #fff);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); cursor: default; line-height: 1.4; }
.hoverinfo:hover .pop, .hoverinfo:focus .pop, .hoverinfo:focus-within .pop { display: block; }
.hoverinfo .pop table.kv th { text-align: left; padding-right: 1rem; color: var(--muted); font-weight: 400; white-space: nowrap; }
.dot.a { background: var(--a, #d68910); }
@media (max-width: 640px) { form.swbtns { flex: 1 1 100%; flex-direction: row; margin: .8rem 0 0; } .hoverinfo .pop { min-width: 0; width: 90vw; left: 0; top: 100%; } }
/* the watchdog page shown inside the user's Watchdog panel */
details.wdpanel .card { box-shadow: none; border: 1px solid var(--line, #ddd); margin: .8rem 0 0; }
details.wdpanel .card h2 { font-size: 1.05rem; }
button[data-autopoll="1"] { background: #1f8a4c; color: #fff; border-color: #1f8a4c; }
#flashes { display: none; }   /* messages are shown in place (.formmsg), never as a banner */
.formmsg { display: inline-block; margin-left: .6rem; font-size: .94rem; font-weight: 600; }
.formmsg.ok { color: var(--g); } .formmsg.err { color: var(--r); }
main > .formmsg { display: block; margin: 0 0 .6rem; min-height: 0; }
/* DNS names and stored values: green = stored / active, red = not active / not stored */
.st-ok { color: var(--g); font-weight: 600; } .st-bad { color: var(--r); font-weight: 600; }
form.aliasedit input { padding: .1rem .3rem; width: auto; display: inline-block; }
/* IP settings: Static (editable) or DHCP (what the dongle reported, read only); labels and fields in columns */
fieldset.ipset { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: .8rem; }
fieldset.ipset > legend { grid-column: 1 / -1; }
fieldset.ipset .ipnet { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }
fieldset.ipset .iphead { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
fieldset.ipset .iphead > b { min-width: 5.5rem; }
.ipgrid { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: .35rem .8rem; align-items: center; }
.ipgrid > label { margin: 0; font-size: .94rem; color: var(--muted); }
.ipgrid input { min-width: 0; width: 100%; box-sizing: border-box; margin: 0; }
.ipgrid input[readonly] { background: transparent; border-style: dashed; }
.ipnet:has(input[value=static]:checked) .ip-dhcp, .ipnet:has(input[value=dhcp]:checked) .ip-static { display: none; }
input.st-ok { color: var(--g); font-weight: 600; } input.st-bad { color: var(--r); font-weight: 600; }
/* copy to clipboard */
.copybtn { border: 0; background: transparent; color: var(--muted); padding: 0 .2rem; margin-left: .15rem; cursor: pointer; vertical-align: -1px; line-height: 1; }
.copybtn:hover { color: var(--brand); } .copybtn.copied { color: var(--g); } .copybtn.copyfail { color: var(--r); }
/* the alias: one box for the whole name, only the first part editable */
.aliasbox { display: inline-flex; align-items: center; border: 1px solid var(--field); border-radius: 6px; padding: .15rem .45rem; background: var(--card); margin: .15rem 0; max-width: 100%; }
.aliasbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(31, 95, 191, .15); }
.aliasbox input { border: 0; padding: 0; margin: 0; background: transparent; font: inherit; color: inherit; outline: none; width: auto; min-width: 4ch; box-shadow: none; }
.aliasbox.st-ok, .aliasbox.st-ok input { color: var(--g); } .aliasbox.st-bad, .aliasbox.st-bad input { color: var(--r); }
form.aliasform { display: inline; }
.aliasbox input { field-sizing: content; }
fieldset.ipset .iphead label.check { display: inline-flex; align-items: center; gap: .3rem; margin: 0; white-space: nowrap; }

/* device list: one line per dongle */
details.swmenu { display: inline-block; position: relative; }
details.swmenu > summary { list-style: none; cursor: pointer; display: inline-block; }
details.swmenu > summary::-webkit-details-marker { display: none; }
details.swmenu > summary .pill::after { content: ' \25BE'; font-weight: 400; }
details.swmenu .swchoices { position: fixed; z-index: 60; display: flex; flex-direction: column; gap: .25rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .25rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
details.swmenu .swchoices button { font-size: .87rem; font-weight: 700; line-height: 1.5; padding: .05rem .5rem; border-radius: 99px; box-sizing: border-box; }   /* = the pill */
td.polls { min-width: 9rem; white-space: nowrap; }
td.polls .pollcell { display: flex; align-items: center; gap: .3rem; height: .75rem; min-height: 0; line-height: 1; }   /* E above W: the row keeps its height */
td.polls .pollcell + .pollcell { margin-top: .2rem; }
td.polls .pollcell .pbar { flex: 1; width: auto; height: 5px; margin: 0; }
td.polls .pnet { font-size: .7rem; width: .8rem; color: var(--g); } td.polls .pnet.down { color: var(--r); }
td.overcell { white-space: nowrap; font-variant-numeric: tabular-nums; } td.overcell.late { color: var(--r); font-weight: 600; }
[hidden] { display: none !important; }

/* labels sit level with their fields */
label { vertical-align: middle; }
.row > label, form.row > label { align-self: center; }
th { vertical-align: middle; }
h1 small.loc { margin-left: .35rem; font-weight: 400; }
input.cnamein { width: 100%; max-width: 32rem; }
input.cnamein.st-ok { color: var(--g); } input.cnamein.st-bad { color: var(--r); }
.dnsform table.kv input { width: 100%; max-width: 32rem; }

button.armed { white-space: nowrap; overflow: hidden; text-overflow: clip; padding-left: 0; padding-right: 0; }
.st-upd, input.st-upd { color: #8a3ffc; font-weight: 600; }

/* device list: planned column widths (the longest value fits or is cut with "..."), so live updates never move the table */
#devices { table-layout: fixed; min-width: 79rem; }
#devices td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#devices td.swcell { overflow: visible; }
#devices col.c-chk { width: 2.4rem; } #devices col.c-name { width: 10rem; } #devices col.c-mac { width: 10.5rem; }
#devices col.c-code { width: 9.5rem; } #devices col.c-loc { width: 8rem; } #devices col.c-status { width: 8rem; }
#devices col.c-sw { width: 10rem; } #devices col.c-fw { width: 7rem; } #devices col.c-over { width: 6.5rem; } #devices col.c-polls { width: auto; }
td.overcell.part { color: #8a3ffc; font-weight: 600; }

/* nothing on the page moves when a scroll bar or a tip comes and goes */
html { scrollbar-gutter: stable; overflow-y: scroll; }
button:disabled { pointer-events: none; }
/* user page: the dongle's MAC address on the right of the top bar */
body.portal header.top { justify-content: space-between; }
header.top .devmac { font-size: .9rem; opacity: .85; white-space: nowrap; }
footer .copy { white-space: nowrap; }
input.ttlin { width: 7rem; }
