/* nolag — shared dark/glass theme. No inline styles anywhere (strict CSP). */
:root {
  --bg: #0b0d12;
  --bg2: #11141c;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-brd: rgba(255, 255, 255, 0.09);
  --ink: #e6e9f0;
  --muted: #8b93a7;
  --accent: #7c9cff;
  --accent-2: #4fd1a1;
  --danger: #ff6b6b;
  --warn: #ffb454;
  --ok: #4fd1a1;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --ctrl: 36px;           /* shared height for inputs / selects / buttons so rows line up */
  --input-bg: #0c0f17;    /* opaque equivalent of the text-box background (for <option>s) */
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 700px at 15% -10%, #1b2030 0%, transparent 55%),
    radial-gradient(1000px 600px at 110% 10%, #161a26 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 22px 64px; }

/* header */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 28px;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { font-size: 22px; margin: 0; letter-spacing: -0.5px; }
.brand .dot { color: var(--accent); }
.brand .sub { color: var(--muted); font-size: 13px; }
.topbar .right { display: flex; gap: 10px; align-items: center; }

/* glass cards */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.section { padding: 20px 22px; margin-bottom: 20px; }
.section h2 { margin: 0 0 14px; font-size: 15px; letter-spacing: 0.3px; color: var(--ink); }
.section h2 .hint { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }

/* tiles grid (landing) */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-bottom: 20px; }
.tile {
  display: block; padding: 22px; border-radius: var(--radius);
  border: 1px solid var(--panel-brd); background: var(--panel);
  backdrop-filter: blur(10px); transition: transform 0.14s ease, border-color 0.14s ease;
  position: relative; overflow: hidden;
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.tile .name { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.tile .desc { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.5; }
.tile .edge { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); opacity: 0.85; }
.tile .badge { font-size: 11px; color: var(--muted); margin-top: 14px; display: inline-block;
  border: 1px solid var(--panel-brd); padding: 2px 8px; border-radius: 999px; }

/* status dot */
.statusdot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.statusdot.up { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.statusdot.down { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.statusdot.unknown { background: var(--warn); }

/* buttons */
/* one source of truth for control height so a button is never taller than the box beside it */
.btn, input:not([type="checkbox"]), select { height: var(--ctrl); box-sizing: border-box; }
.btn {
  font: inherit; font-size: 13px; line-height: 1; cursor: pointer; color: var(--ink);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--panel-brd);
  padding: 0 14px; border-radius: 10px; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: rgba(255, 255, 255, 0.11); border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #0b0d12; border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(255, 107, 107, 0.5); color: var(--danger); }
.btn.danger:hover { background: rgba(255, 107, 107, 0.12); }
.btn.small { padding: 0 11px; font-size: 12px; }

/* service rows — wrap on narrow screens so buttons never overflow the card */
.svc { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--panel-brd); flex-wrap: wrap; }
.svc:first-of-type { border-top: none; }
.svc .label { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 10px; }
.svc .label .name { font-weight: 500; }
.svc .actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* forms */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input:not([type="checkbox"]), select {
  font: inherit; font-size: 13px; color: var(--ink); background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-brd); border-radius: 9px; padding: 0 10px;
  height: var(--ctrl); min-width: 120px;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
input:focus, select:focus { outline: none; border-color: var(--accent); }

/* native <select> dropdown: inactive options match the text box, selection uses the accent */
select { accent-color: var(--accent); }
select option { background: var(--input-bg); color: var(--ink); }
select option:checked, select option:hover { background: var(--accent); color: #0b0d12; }

/* inline label (text beside the control, single row height) */
.ctl { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.inl { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink); }

/* config rows — flex so the input, Save button and status all sit on one centered line */
.cfg { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--panel-brd); flex-wrap: wrap; }
.cfg:first-of-type { border-top: none; }
.cfg .info { flex: 1; min-width: 220px; }
.cfg .ctrls { display: flex; align-items: center; gap: 10px; margin-left: auto; }  /* input + Save flush right */
.cfg input { width: 170px; }
.cfg .status { font-size: 12px; color: var(--muted); min-width: 90px; text-align: right; }
.cfg .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.cfg .name { color: var(--ink); font-weight: 600; font-size: 13px; }
.cfg.active { border-left: 2px solid var(--accent); padding-left: 10px; }
.cfg.active .name { color: var(--accent); }
.cfg .meta.ab { color: var(--accent-2); }

/* console / log pane */
.console {
  background: #06070b; border: 1px solid var(--panel-brd); border-radius: 12px;
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, monospace;
  font-size: 12.5px; line-height: 1.55; padding: 12px 14px; height: 320px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.console::-webkit-scrollbar { width: 11px; height: 11px; }
.console::-webkit-scrollbar-track { background: transparent; }
.console::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
}
.console::-webkit-scrollbar-thumb:hover { background: rgba(124, 156, 255, 0.55); background-clip: padding-box; }
.console .meta { color: var(--accent); }
.console .stderr { color: var(--warn); }
.console .err { color: var(--danger); }
.console .result { color: var(--ok); }
.console .dim { color: var(--muted); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }
.pill { font-size: 11px; color: var(--muted); border: 1px solid var(--panel-brd); border-radius: 999px; padding: 0 10px; height: 26px; display: inline-flex; align-items: center; }
.pill.live { color: var(--ok); border-color: var(--ok); box-shadow: 0 0 8px rgba(79, 209, 161, 0.35); }

/* scripts & jobs — equal-width cards side by side, wrapping on small screens */
.scripts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.scriptcard {
  display: flex; flex-direction: column; gap: 8px; padding: 16px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--panel-brd); border-radius: 12px;
}
.scriptcard .title { font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -0.2px; }
.scriptcard .desc { font-size: 12px; color: var(--muted); line-height: 1.45; }
.scriptcard .controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.scriptcard .controls .btnrow { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* error banner (shown by NL.showError so a JS/fetch failure is never a silently blank page) */
.errbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 107, 107, 0.16); border: 1px solid var(--danger); color: #ffd9d9;
  border-radius: 10px; padding: 10px 14px; margin: 0 0 16px; font-size: 13px;
}
/* dedicated live console for script runs, beneath the cards */
.scripts-out-bar { margin-top: 16px; margin-bottom: 10px; }
#scriptPane { height: 220px; }

/* page-wide scrollbar to match */
html { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.14) transparent; }

@media (max-width: 560px) {
  .svc .label { min-width: 100%; }
  .svc .actions { width: 100%; }
  .topbar { flex-wrap: wrap; }
}

/* login */
.login-alt { margin: 18px 0 0; font-size: 13px; text-align: center; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; padding: 30px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.err-msg { color: var(--danger); font-size: 13px; min-height: 18px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.narrow { min-width: 70px; width: 90px; }
.toast { font-size: 12px; color: var(--muted); }

/* wake-model row diagnostic sub-line (the row itself uses the standard .svc styling) */
.wakediag { flex-basis: 100%; font-size: 12px; color: var(--muted); margin-top: 2px; }
.wakediag.warn { color: var(--warn); }
