:root {
  --bg: #0b0d10;
  --panel: #13161b;
  --panel2: #1a1e25;
  --line: #262b34;
  --text: #e6e9ee;
  --muted: #8b93a1;
  --accent: #39b8e0;
  --ok: #2fbf71;
  --warn: #f0b429;
  --error: #ef4f5f;
  --offline: #6b7380;
  --new: #6c8cff;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.small { font-size: 13px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: rgba(11,13,16,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { color: var(--text); font-weight: 650; font-size: 17px; display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
#nav { display: flex; gap: 8px; align-items: center; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; }

/* buttons & inputs */
button, .btn { font: inherit; font-size: 14px; font-weight: 550; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 38px;
  display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #3a414d; text-decoration: none; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: #1b6f8c; border-color: #2387aa; }
button.primary:hover { background: #20809f; }
button.danger { background: #5a1d25; border-color: #8a2b37; }
button.danger:hover { background: #6d222c; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=time], input[type=number], select {
  font: inherit; color: var(--text); background: #0f1216; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; min-height: 38px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .05em; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: rgba(47,191,113,.12); }
.pill.warn { color: var(--warn); background: rgba(240,180,41,.12); }
.pill.error { color: var(--error); background: rgba(239,79,95,.14); }
.pill.offline { color: var(--offline); background: rgba(107,115,128,.16); }
.pill.new { color: var(--new); background: rgba(108,140,255,.13); }
.pill.done { color: var(--ok); background: rgba(47,191,113,.12); }
.pill.failed, .pill.expired { color: var(--error); background: rgba(239,79,95,.14); }
.pill.queued, .pill.sent { color: var(--accent); background: rgba(57,184,224,.12); }
.pill.cancelled { color: var(--offline); background: rgba(107,115,128,.16); }

/* overview */
.overview-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.counts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.counts b { color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
a.card { display: block; color: var(--text); border-left: 4px solid var(--line); transition: border-color .15s, background .15s; }
a.card:hover { text-decoration: none; background: #161a20; }
a.card.ok { border-left-color: var(--ok); }
a.card.warn { border-left-color: var(--warn); }
a.card.error { border-left-color: var(--error); }
a.card.offline { border-left-color: var(--offline); }
a.card.new { border-left-color: var(--new); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card .name { font-size: 17px; font-weight: 600; }
.card .type { font-size: 13px; color: var(--muted); }
.card .summary { margin: 10px 0 8px; font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .foot { margin-top: 10px; font-size: 12px; color: var(--muted); }
.v-ok { color: var(--ok); } .v-warn { color: var(--warn); } .v-error { color: var(--error); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h1 { color: var(--text); margin-bottom: 8px; }

/* events */
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.events li:first-child { border-top: 0; }
.events time { color: var(--muted); font-size: 13px; }
.events .lvl-error { color: #ff8a95; }
.events .lvl-warn { color: #ffd37a; }
.events .dev { color: var(--muted); }

/* detail */
.back { display: inline-block; margin-bottom: 12px; font-size: 14px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.detail-head .title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.subline { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 15px; }
.banner.error { background: rgba(239,79,95,.12); border: 1px solid rgba(239,79,95,.35); }
.banner.warn { background: rgba(240,180,41,.10); border: 1px solid rgba(240,180,41,.3); }
.banner.offline { background: rgba(107,115,128,.14); border: 1px solid rgba(107,115,128,.35); }
.banner.new { background: rgba(108,140,255,.10); border: 1px solid rgba(108,140,255,.3); }
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.readings { display: grid; gap: 14px; }
.rgroup h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.rrow { display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rrow:first-of-type { border-top: 0; }
.rrow .l { color: var(--muted); }
.rrow .v { overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions + .actions { margin-top: 8px; }
.cmds { width: 100%; border-collapse: collapse; font-size: 14px; }
.cmds td { padding: 7px 6px 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
.cmds tr:first-child td { border-top: 0; }
.cmds .when { color: var(--muted); white-space: nowrap; font-size: 13px; }
.cmds .res { color: var(--muted); font-size: 13px; }

/* schedule editor */
.sched-top { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 10px; }
.sched { width: 100%; border-collapse: collapse; font-size: 14px; }
.sched th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 0 6px 6px 0; }
.sched td { padding: 4px 6px 4px 0; }
.sched td.day { width: 54px; font-weight: 600; }
.sched tr.off input[type=time], .sched tr.off select { opacity: .4; }
.sched select { width: 100%; min-width: 0; }
.sched input[type=time] { width: 100%; min-width: 92px; }
.sched-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.dirty-note { color: var(--warn); font-size: 13px; }

/* forms */
.form { display: grid; gap: 12px; max-width: 520px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.login { max-width: 360px; margin: 10vh auto 0; }
.setup { background: #0f1216; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all; }
.radio { display: grid; gap: 8px; }
.radio label { display: flex; gap: 10px; align-items: flex-start; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.radio label small { display: block; color: var(--muted); }

/* modal & toast */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: 440px; max-width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.6); display: grid; gap: 14px; }
.modal-box h3 { font-size: 18px; }
.modal-box .btns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; transition: all .2s;
  max-width: calc(100vw - 32px); z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--error); }

.sched tr.seqrow { display: none; }
.sched tr.seqrow td { padding-top: 0; padding-bottom: 8px; }

@media (max-width: 820px) {
  .cols { grid-template-columns: 1fr; }
  .rrow { grid-template-columns: 120px 1fr; }
}
@media (max-width: 520px) {
  main { padding: 14px 12px 50px; }
  .grid { grid-template-columns: 1fr; }
  .events li { grid-template-columns: 1fr; gap: 0; }
  .sched td.day { width: 40px; }
  .sched input[type=time] { min-width: 0; padding: 6px 4px; }
  .sched th.seq, .sched td.seq { display: none; }
  .sched tr.seqrow { display: table-row; }
}
@media (max-width: 520px) {
  .top { padding: 10px 12px; }
  .brand { font-size: 15px; }
  #nav .btn, #nav button { white-space: nowrap; padding: 6px 10px; font-size: 13px; min-height: 34px; }
}

/* software */
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-title h2 { margin: 0; }
button.small-btn, .small-btn { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.sw-list { display: grid; gap: 10px; }
.sw { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #11141a; }
.sw-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sw-details { margin-top: 6px; }
.sw-details .rrow { grid-template-columns: 130px 1fr; padding: 4px 0; font-size: 13px; }
.sw-btns { margin-top: 8px; }
.sw-form { display: grid; gap: 12px; }
.sw-form label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.sw-form label.check { display: flex; color: var(--text); font-size: 14px; }
.sw-form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; }
.sw-form legend { font-size: 13px; color: var(--text); padding: 0 4px; }
.sw-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sw-form .inline { display: flex; gap: 6px; }
.sw-form .inline input { flex: 1; min-width: 0; }
.sw-form input, .sw-form select { width: 100%; }
.sw-form .inline select { width: auto; }
.modal-box { max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-box:has(.sw-form) { width: 560px; }
@media (max-width: 520px) { .sw-form .two { grid-template-columns: 1fr; } }
.sw-form input[type=checkbox] { width: 18px; flex: none; margin: 0; }
.sw-form label.check { justify-content: flex-start; align-items: center; gap: 10px; }
.sw-form [hidden] { display: none; }
.sw-form .three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .sw-form .three { grid-template-columns: 1fr 1fr; } }
