/* The Button: dark, mobile-first, one look for every module. */
:root {
  color-scheme: dark;
  --bg: #0b0c10; --bg2: #121419; --card: #171923; --card2: #1e2130; --line: #272b3a; --line2: #333849;
  --text: #eceef3; --muted: #8e93a3; --muted2: #5f6475;
  --accent: #ff453a; --accent-2: #ff6b61; --ok: #30d158; --warn: #ffd60a; --bad: #ff453a; --info: #0a84ff; --off: #6b7080;
  --radius: 16px; --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; font: 16px/1.4 var(--font); color: var(--text); background: var(--bg); min-height: 100vh; overscroll-behavior-y: none; }
a { color: var(--info); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 28px; height: 28px; }
.boot { color: var(--muted); padding: 40px; text-align: center; }

/* layout */
.app { max-width: 1100px; margin: 0 auto; padding: 0 16px calc(84px + var(--sab)); }
.hdr { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--sat)) 0 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.hdr h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr .sub { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.iconbtn { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 12px; width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.iconbtn:active { background: var(--card2); }
.iconbtn.ghost { background: transparent; border-color: transparent; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.conn.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.conn.off { background: var(--bad); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; padding: 6px 8px calc(8px + var(--sab));
  background: color-mix(in srgb, var(--bg2) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.nav a { color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; padding: 4px 14px; border-radius: 10px; min-width: 64px; }
.nav a.on { color: var(--text); }
.nav a .ic { width: 22px; height: 22px; }
.section { margin: 18px 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.grid.one { grid-template-columns: 1fr; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.center { text-align: center; }
p.lead { color: var(--muted); margin: 6px 0 16px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.broken { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }
.card.dashed { border-style: dashed; }
.card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-head .mod-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--card2); display: inline-flex; align-items: center; justify-content: center; color: var(--text); flex: none; }
.card-head .mod-icon.bad { color: var(--bad); }
.card-head .title { font-weight: 600; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-head .title a { color: inherit; }
.card-head .meta { color: var(--muted); font-size: 12px; }
.card .err { color: var(--bad); font-size: 13px; background: color-mix(in srgb, var(--bad) 12%, transparent); padding: 8px 10px; border-radius: var(--radius-sm); word-break: break-word; }
.card .stale { color: var(--warn); font-size: 12px; }
.widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.w { min-width: 0; }
.w.wide { grid-column: 1 / -1; }
.w-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions:empty { display: none; }

/* state colors */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.s-ok { --c: var(--ok); } .s-warn { --c: var(--warn); } .s-bad { --c: var(--bad); } .s-info { --c: var(--info); } .s-off { --c: var(--off); }
.dot.s-ok, .dot.s-warn, .dot.s-bad, .dot.s-info, .dot.s-off { background: var(--c); }
.dot.s-ok { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.s-bad { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }

/* widgets */
.badge { display: flex; align-items: center; gap: 8px; background: var(--card2); border-radius: var(--radius-sm); padding: 10px 12px; }
.badge .txt { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
.stat { background: var(--card2); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .unit { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.gauge { background: var(--card2); border-radius: var(--radius-sm); padding: 10px 12px; }
.gauge .top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.gauge .val { font-weight: 700; font-size: 18px; }
.gauge .bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.gauge .bar i { display: block; height: 100%; width: 0; background: var(--c, var(--info)); border-radius: 4px; transition: width .4s ease; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--card2); border: 1px solid var(--line2); color: var(--text);
  border-radius: 12px; padding: 10px 14px; font-weight: 600; font-size: 15px; min-height: 42px; flex: 1 1 auto; }
.btn:active { filter: brightness(1.2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { background: color-mix(in srgb, var(--bad) 18%, var(--card2)); border-color: color-mix(in srgb, var(--bad) 50%, var(--line2)); color: #ffb0aa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:disabled { background: var(--card2); border-color: var(--line2); color: var(--muted); }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; border-radius: 9px; flex: none; }
.btn.icon { padding: 6px; min-height: 32px; width: 32px; flex: none; border-radius: 9px; }
.btn.block { width: 100%; }
.btn .ic { width: 18px; height: 18px; }
.btn.busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card2); border-radius: var(--radius-sm); padding: 10px 12px; }
.switch { width: 48px; height: 28px; border-radius: 14px; background: var(--line2); position: relative; border: 0; padding: 0; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch.on { background: var(--ok); } .switch.on::after { left: 23px; }
.switch:disabled { opacity: .5; }
.list { background: var(--card2); border-radius: var(--radius-sm); overflow: hidden; }
.list .li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); min-width: 0; }
.list .li:first-child { border-top: 0; }
.list .li .main { flex: 1; min-width: 0; }
.list .li .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li .s { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li .ops { display: flex; gap: 4px; flex: none; }
.list .empty { padding: 14px; }
.tablewrap { background: var(--card2); border-radius: var(--radius-sm); overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
table.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 8px 10px; border-top: 1px solid var(--line); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
table.tbl tr:first-child td { border-top: 0; }
table.tbl td.r, table.tbl th.r { text-align: right; }
table.tbl td.ops { text-align: right; }
pre.log { margin: 0; background: #0d0e13; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font: 12px/1.45 var(--mono); color: #c9cdd8;
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
pre.log.tall { max-height: 60vh; }
pre.log:empty::before { content: "(no output)"; color: var(--muted2); }
.form { display: flex; flex-direction: column; gap: 10px; background: var(--card2); border-radius: var(--radius-sm); padding: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field .help { font-size: 12px; color: var(--muted2); }
.field input[type=text], .field input[type=number], .field input[type=url], .field input[type=file], .field select, .field textarea {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; font-size: 16px; width: 100%; color: var(--text); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--info); }
.field textarea { min-height: 80px; resize: vertical; }
.field .check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.field input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ok); }
.field.err input, .field.err select { border-color: var(--bad); }
.field .errmsg { color: var(--bad); font-size: 12px; }
.dropzone { border: 2px dashed var(--line2); border-radius: var(--radius-sm); padding: 18px 12px; text-align: center; color: var(--muted); background: var(--card2); }
.dropzone.over { border-color: var(--info); color: var(--text); }
.dropzone input { display: none; }
.dropzone .btn { margin-top: 10px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--info); width: 0; transition: width .2s; }
.result { display: flex; gap: 8px; align-items: center; margin-top: 10px; background: var(--bg2); border-radius: 10px; padding: 8px 10px; }
.result a { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 13px; }
.linkw { display: flex; align-items: center; gap: 8px; background: var(--card2); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text); font-weight: 600; font-size: 14px; }
.linkw .ic:last-child { color: var(--muted); margin-left: auto; }
.textw { background: var(--card2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.textw.mono { font-family: var(--mono); font-size: 12px; }

/* alerts, unclaimed, jobs */
.banner { display: flex; gap: 10px; align-items: flex-start; background: color-mix(in srgb, var(--warn) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.banner.bad { background: color-mix(in srgb, var(--bad) 12%, var(--card)); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.banner .ic { color: var(--warn); margin-top: 2px; }
.banner.bad .ic { color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--card2); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.pill .dot { width: 7px; height: 7px; }
.pill.s-ok { color: var(--ok); } .pill.s-bad { color: var(--bad); } .pill.s-warn { color: var(--warn); } .pill.s-info { color: var(--info); }
.job-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.job-row:first-child { border-top: 0; }
.job-row .main { flex: 1; min-width: 0; }
.job-row .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-row .s { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* overlays */
.toasts { position: fixed; top: calc(12px + var(--sat)); left: 0; right: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--card2); border: 1px solid var(--line2); color: var(--text); border-radius: 12px; padding: 10px 14px; font-size: 14px; max-width: min(92vw, 520px);
  box-shadow: 0 8px 30px rgba(0,0,0,.45); pointer-events: auto; display: flex; gap: 8px; align-items: center; animation: pop .18s ease; }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--line2)); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line2)); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }
dialog { border: 1px solid var(--line2); background: var(--card); color: var(--text); border-radius: var(--radius); padding: 18px; width: min(92vw, 440px); box-shadow: 0 20px 60px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 6px; font-size: 19px; }
dialog p { margin: 0 0 14px; color: var(--muted); }
dialog .actions { margin-top: 14px; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--card); border: 1px solid var(--line2); border-bottom: 0; border-radius: 18px 18px 0 0;
  padding: 10px 14px calc(14px + var(--sab)); max-height: 80vh; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 -10px 40px rgba(0,0,0,.5); transform: translateY(100%); transition: transform .22s ease; }
.sheet.open { transform: none; }
.sheet .handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line2); margin: 0 auto 4px; }
.sheet .head { display: flex; align-items: center; gap: 10px; }
.sheet .head .t { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet pre.log { flex: 1; max-height: 50vh; }
.scrim { position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
@media (min-width: 720px) {
  .sheet { left: auto; right: 16px; bottom: 16px; width: 560px; border-radius: 18px; border-bottom: 1px solid var(--line2); padding-bottom: 14px; }
}

/* auth pages */
.auth { max-width: 420px; margin: 10vh auto 0; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.auth .logo { width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 6px; background: var(--card2); display: flex; align-items: center; justify-content: center; }
.auth .logo i { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); box-shadow: inset -6px -6px 14px rgba(0,0,0,.35), 0 0 0 10px var(--card); }
.auth h1 { margin: 0; font-size: 26px; }
.auth .form { text-align: left; }
.big { font-size: 24px; letter-spacing: .14em; text-align: center; font-family: var(--mono); text-transform: uppercase; }
