/* Night Engineer — "Night Watch" control console.
   Identity: monospace-as-hero instrument panel; a single sodium-amber accent
   (the color of a streetlamp) glowing on cold midnight. */
:root {
  --void: #0a0d13;
  --panel: #11151e;
  --well: #0c0f16;
  --line: #1d2531;
  --line-2: #2a3440;
  --ink: #eaeef6;
  --ink-2: #aab4c6;
  --mute: #6b7689;
  --sodium: #ffb163;
  --sodium-2: #ffc788;
  --sodium-wash: rgba(255, 177, 99, .12);
  --ok: #54d08a;
  --ok-wash: rgba(84, 208, 138, .13);
  --warn: #e3b341;
  --warn-wash: rgba(227, 179, 65, .14);
  --bad: #ff6b61;
  --bad-wash: rgba(255, 107, 97, .13);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --r: 10px;
  --r-sm: 7px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 78% -8%, rgba(255, 177, 99, .05), transparent 60%),
    var(--void);
  background-attachment: fixed;
  color: var(--ink);
  font: 14px/1.55 var(--sans);
  letter-spacing: .01em;
}
a { color: var(--sodium-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--mute); }
.small { font-size: 12px; }

/* eyebrow / instrument labels — the recurring structural device */
.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--mute);
}

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px 56px; }

/* ── watch bar ───────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 20px 0 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-moon { font-size: 19px; filter: drop-shadow(0 0 9px rgba(255, 177, 99, .5)); }
.brand-name {
  font-family: var(--mono); font-size: 15px; font-weight: 600;
  letter-spacing: .26em; text-transform: uppercase; color: var(--ink);
}
.topbar-right { display: flex; align-items: center; gap: 18px; }
.signout {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--mute);
}
.signout:hover { color: var(--ink-2); text-decoration: none; }

/* the signature: a "watch" status medallion */
.watch { display: flex; align-items: center; gap: 10px; }
.watch-orb {
  position: relative; width: 13px; height: 13px; border-radius: 50%; flex: none;
}
.watch-orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
}
.watch.working .watch-orb { background: var(--sodium); box-shadow: 0 0 12px var(--sodium); }
.watch.working .watch-orb::after { box-shadow: 0 0 0 0 rgba(255, 177, 99, .6); animation: ring 1.8s infinite; }
.watch.idle .watch-orb { background: transparent; border: 2px solid var(--sodium); box-shadow: 0 0 9px rgba(255, 177, 99, .35); }
.watch.offline .watch-orb { background: transparent; border: 2px solid var(--line-2); }
.watch-txt { display: flex; flex-direction: column; line-height: 1.25; }
.watch-state {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
}
.watch.working .watch-state { color: var(--sodium-2); }
.watch.idle .watch-state { color: var(--ink-2); }
.watch.offline .watch-state { color: var(--mute); }
.watch-sub { font-family: var(--mono); font-size: 10.5px; color: var(--mute); }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255, 177, 99, .55); } 70% { box-shadow: 0 0 0 11px rgba(255, 177, 99, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 177, 99, 0); } }

/* ── vitals instrument strip ─────────────────────────────── */
.vitals {
  display: flex; flex-wrap: wrap; align-items: stretch;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; margin-bottom: 18px;
}
.vital { flex: 1 1 0; min-width: 130px; padding: 14px 18px; border-left: 1px solid var(--line); }
.vital:first-child { border-left: none; }
.vital-v { font-family: var(--mono); font-size: 27px; font-weight: 600; line-height: 1.1; color: var(--ink); }
.vital-l { margin-top: 5px; }
.vital-s { margin-top: 3px; font-family: var(--mono); font-size: 11px; color: var(--sodium-2); }

/* ── nav rail + global actions ───────────────────────────── */
.navrail {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 4px; }
.tab {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--mute); padding: 7px 15px; border-radius: var(--r-sm); cursor: pointer;
  border: none; background: none;
}
.tab:hover { color: var(--ink-2); }
.tab.on { color: var(--void); background: var(--sodium); font-weight: 600; }
.gactions { display: flex; gap: 8px; }

/* ── buttons ─────────────────────────────────────────────── */
.btn {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink-2);
  border-radius: var(--r-sm); padding: 8px 13px; transition: border-color .14s, color .14s, background .14s;
}
.btn:hover { border-color: var(--sodium); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--sodium); outline-offset: 2px; }
.btn.primary { background: var(--sodium); border-color: var(--sodium); color: var(--void); font-weight: 600; }
.btn.primary:hover { background: var(--sodium-2); border-color: var(--sodium-2); }
.btn.danger { border-color: rgba(255, 107, 97, .5); color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-wash); color: #ff8e85; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 5px 10px; font-size: 10.5px; }

/* ── panels ──────────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
h2 { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--mute); font-weight: 600; }

/* ── live: current task + terminal ───────────────────────── */
.now {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: linear-gradient(180deg, var(--sodium-wash), transparent 70%);
  padding: 13px 15px; margin-bottom: 14px;
}
.now-pulse { width: 11px; height: 11px; border-radius: 50%; background: var(--sodium); margin-top: 4px; flex: none; box-shadow: 0 0 0 0 rgba(255, 177, 99, .6); animation: ring 1.8s infinite; }
.now-body { flex: 1; min-width: 0; }
.now-title { font-weight: 600; color: var(--ink); }
.now-title .nid { font-family: var(--mono); color: var(--sodium-2); }
.now-meta { margin-top: 4px; font-family: var(--mono); font-size: 11.5px; color: var(--mute); }
.now-meta b { color: var(--ink-2); font-weight: 600; }
.idle-line { font-family: var(--mono); font-size: 12px; color: var(--mute); padding: 6px 2px; }

.term-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.term-dot.on { background: var(--ok); box-shadow: 0 0 7px var(--ok); }
.term-dot.off { background: var(--bad); }
.terminal {
  background: var(--well); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 13px; height: 360px; overflow: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
}
.tline { display: flex; gap: 9px; white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.tprefix { color: var(--mute); flex: none; width: 1em; text-align: center; }
.t-text .ttext { color: #cfd8e6; }
.t-tool .ttext { color: var(--sodium-2); }
.t-result .ttext { color: var(--mute); }
.t-info .ttext { color: var(--ok); }

/* ── filters ─────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.inp {
  background: var(--well); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 11px; font: 13px var(--sans);
}
.inp:focus { outline: none; border-color: var(--sodium); }
.inp:focus-visible { outline: 2px solid var(--sodium); outline-offset: 1px; }
input.inp { min-width: 210px; flex: 1; }
select.inp { font-family: var(--mono); font-size: 12px; }

/* ── history table ───────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--mute); font-weight: 600; }
tbody tr:hover { background: rgba(255, 255, 255, .015); }
td.idcell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ── status badges ───────────────────────────────────────── */
.badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px; text-transform: lowercase; white-space: nowrap;
}
.badge.ok { background: var(--ok-wash); color: var(--ok); }
.badge.warn { background: var(--warn-wash); color: var(--warn); }
.badge.bad { background: var(--bad-wash); color: var(--bad); }
.badge.muted { background: rgba(139, 147, 164, .14); color: var(--mute); }
.badge.live { background: var(--sodium-wash); color: var(--sodium-2); }

/* ── kanban ──────────────────────────────────────────────── */
/* minmax(0,1fr) — not a fixed minimum — so the six columns always shrink to
   fit the container instead of overflowing and clipping the last column. */
.board { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 11px; padding-bottom: 8px; }
.kcol { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 11px; min-height: 140px; }
.kcol-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.kcol-title { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-2); }
.kcount { font-family: var(--mono); font-size: 10.5px; color: var(--mute); background: var(--well); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.kcol-body { display: flex; flex-direction: column; gap: 9px; }
.kempty { font-family: var(--mono); font-size: 11px; color: var(--mute); text-align: center; padding: 10px 0; opacity: .55; }
.kcard { background: var(--well); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 11px; cursor: pointer; transition: border-color .14s, transform .08s; }
.kcard:hover { border-color: var(--sodium); }
.kcard:active { transform: translateY(1px); }
.kcard.live { border-color: var(--sodium); box-shadow: 0 0 0 1px rgba(255, 177, 99, .25); background: linear-gradient(180deg, var(--sodium-wash), var(--well)); }
.kcard-id { font-family: var(--mono); font-size: 12px; color: var(--ink); margin-bottom: 7px; word-break: break-all; }
.kcard-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kcard-meta .m { font-family: var(--mono); font-size: 10.5px; color: var(--mute); }

/* ── issue drawer ────────────────────────────────────────── */
.drawer-bg { position: fixed; inset: 0; background: rgba(4, 6, 10, .62); backdrop-filter: blur(2px); display: flex; justify-content: flex-end; z-index: 50; }
.drawer { width: 580px; max-width: 94vw; height: 100%; overflow: auto; background: var(--void); border-left: 1px solid var(--line-2); padding: 20px; }
.drawer-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.drawer-id { font-family: var(--mono); font-size: 15px; color: var(--ink); letter-spacing: .03em; }
.xbtn { background: none; border: 1px solid var(--line-2); color: var(--ink-2); border-radius: var(--r-sm); width: 32px; height: 32px; cursor: pointer; font-size: 15px; }
.xbtn:hover { border-color: var(--sodium); color: var(--ink); }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 16px; }
.tl { border-left: 2px solid var(--line-2); padding: 0 0 14px 14px; margin-left: 3px; }
.tl:last-child { padding-bottom: 0; }
.tl-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-meta { font-family: var(--mono); font-size: 11px; color: var(--mute); }
.tl-detail { margin-top: 5px; font-size: 12.5px; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; max-height: 130px; overflow: auto; }

/* ── confirm / prompt modal ──────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(4, 6, 10, .68); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 80; }
.modal { width: 400px; max-width: 100%; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.modal h3 { margin: 0 0 8px; font-family: var(--mono); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }
.modal p { margin: 0 0 16px; color: var(--ink-2); font-size: 13.5px; }
.modal .inp { width: 100%; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; }

/* ── toast ───────────────────────────────────────────────── */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--panel); border: 1px solid var(--line-2); border-left: 3px solid var(--sodium);
  border-radius: var(--r-sm); padding: 11px 16px; font-family: var(--mono); font-size: 12px; color: var(--ink);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .5); max-width: 90vw; }
.toast.bad { border-left-color: var(--bad); }

footer { margin-top: 22px; text-align: center; }
.footer-line { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--mute); text-transform: uppercase; }

/* ── login ───────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 350px; max-width: 100%; background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; padding: 34px 30px; text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.login-moon { font-size: 38px; filter: drop-shadow(0 0 16px rgba(255, 177, 99, .55)); }
.login-title { margin: 12px 0 4px; font-family: var(--mono); font-size: 17px; letter-spacing: .24em; text-transform: uppercase; }
.login-sub { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); margin-bottom: 22px; }
.login-inp { display: block; width: 100%; margin: 9px 0; }
.login-btn { width: 100%; margin-top: 16px; padding: 11px; border: none; border-radius: var(--r-sm); background: var(--sodium); color: var(--void); font: 600 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; }
.login-btn:hover { background: var(--sodium-2); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-err { color: var(--bad); font-family: var(--mono); font-size: 12px; margin-top: 12px; }

/* ── reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .watch.working .watch-orb::after, .now-pulse { animation: none; }
}

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 820px) {
  /* below this width six columns can't stay legible, so switch to a
     horizontally swipeable board with comfortably wide cards. */
  .board { grid-template-columns: repeat(6, 78vw); overflow-x: auto; }
  .vital { flex-basis: 50%; border-left: none; border-top: 1px solid var(--line); }
  .vital:first-child, .vital:nth-child(2) { border-top: none; }
}
@media (max-width: 560px) {
  .navrail { flex-direction: column; align-items: stretch; }
  .gactions { justify-content: stretch; }
  .gactions .btn { flex: 1; justify-content: center; }
}
