/* Manager — instrument-panel UI. No frameworks, no webfonts. */

:root {
  --bg: #0e1218;
  --panel: #141a22;
  --panel-2: #1a222d;
  --panel-3: #212b38;
  --line: #232e3c;
  --line-2: #31405269;
  --text: #d8e0ea;
  --muted: #93a1b3;
  --dim: #7e8b9e;
  --amber: #e9a23b;
  --amber-2: #f5b95c;
  --amber-dim: rgba(233, 162, 59, 0.14);
  --ok: #43bc81;
  --ok-dim: rgba(67, 188, 129, 0.13);
  --err: #e15b54;
  --err-dim: rgba(225, 91, 84, 0.13);
  --mono: ui-monospace, 'Cascadia Code', Consolas, 'JetBrains Mono', 'SF Mono', monospace;
  --ui: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --r: 8px;
  --r-s: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--amber-dim); }

* { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

button { font: inherit; color: inherit; }

/* ------------------------------------------------------------ login */

.login-screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(233, 162, 59, 0.045), transparent),
    linear-gradient(rgba(132, 148, 167, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(132, 148, 167, 0.05) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px, 28px 28px;
  padding: 24px;
}

.wordmark {
  font-family: var(--mono);
  font-size: 21px;
  letter-spacing: 0.42em;
  color: var(--text);
  text-indent: 0.42em; /* re-center: letterspacing adds trailing space */
  user-select: none;
}

.wordmark b { color: var(--amber); font-weight: 400; }

.login-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.08em;
  margin-top: -18px;
}

.login-card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 26px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card .field label { display: block; }

.login-error {
  color: var(--err);
  font-size: 12.5px;
  min-height: 18px;
  font-family: var(--mono);
}

/* ------------------------------------------------------- app shell */

.shell { display: flex; height: 100%; }

.rail {
  width: 196px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 2px;
}

.brand {
  font-family: var(--mono);
  font-size: 13.5px;
  letter-spacing: 0.3em;
  padding: 6px 10px 18px;
  user-select: none;
  white-space: nowrap;
}

.brand b { color: var(--amber); font-weight: 400; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  border-radius: var(--r-s);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.nav-btn svg { width: 16px; height: 16px; flex: none; }

.nav-btn:hover { background: var(--panel-2); color: var(--text); }

.nav-btn.active {
  background: var(--amber-dim);
  border-left-color: var(--amber);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  color: var(--amber-2);
}

.rail-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.rail-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* --------------------------------------------- telemetry strip (signature) */

.strip {
  height: 34px;
  flex: none;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.strip .sep { color: var(--line-2); user-select: none; }

.strip .lit { color: var(--text); }

.strip .u { color: var(--amber); }

.strip-spacer { flex: 1; }

.meter {
  display: inline-block;
  width: 44px;
  height: 5px;
  background: var(--panel-3);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: 1px;
  margin-left: 6px;
}

.meter i {
  display: block;
  height: 100%;
  background: var(--amber);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.meter.hot i { background: var(--err); }

/* ---------------------------------------------------------- content */

.content { flex: 1; overflow-y: auto; padding: 18px 22px 32px; }

.view { max-width: 1200px; margin: 0 auto; }

.view-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.view-head h1 { font-size: 17px; font-weight: 600; letter-spacing: 0.01em; }

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --------------------------------------------------- inputs & buttons */

.field label {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 5px;
}

input[type='text'], input[type='password'], input[type='search'] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  color: var(--text);
  font: 13.5px/1 var(--mono);
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.12s;
}

input:focus-visible { border-color: var(--amber); }

input::placeholder { color: var(--dim); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
  white-space: nowrap;
}

.btn svg { width: 14px; height: 14px; }

.btn:hover { background: var(--panel-3); }

.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #211404;
  font-weight: 600;
}

.btn-primary:hover { background: var(--amber-2); border-color: var(--amber-2); }

.btn-danger { color: var(--err); border-color: rgba(225, 91, 84, 0.4); }

.btn-danger:hover { background: var(--err-dim); }

.btn-ghost { background: none; border-color: transparent; color: var(--muted); }

.btn-ghost:hover { background: var(--panel-2); color: var(--text); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover { background: var(--panel-3); color: var(--text); }

.icon-btn.danger:hover { color: var(--err); background: var(--err-dim); }

.icon-btn svg { width: 15px; height: 15px; }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

input:focus-visible { outline: none; }

/* Checkboxes rely on the border for their checked state, so keep a real focus ring. */
input[type='checkbox']:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* -------------------------------------------------------- files view */

.pathbar {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 13px;
  margin-bottom: 12px;
  overflow-x: auto;
  white-space: nowrap;
}

.pathbar .prompt { color: var(--amber); margin-right: 6px; user-select: none; }

.crumb {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 4px;
}

.crumb:hover { color: var(--text); background: var(--panel-3); }

.crumb-sep { color: var(--dim); user-select: none; }

.crumb:last-of-type { color: var(--text); }

.pathbar input {
  border: none;
  background: none;
  padding: 1px 3px;
  flex: 1;
  min-width: 120px;
}

.pathbar .icon-btn { margin-left: auto; flex: none; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar .spacer { flex: 1; }

.toolbar .count { font-family: var(--mono); font-size: 12px; color: var(--dim); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--dim);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  user-select: none;
  white-space: nowrap;
}

th.sortable { cursor: pointer; }

th.sortable:hover { color: var(--muted); }

th .dir { color: var(--amber); }

td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

tbody tr { transition: background 0.08s; }

tbody tr:hover { background: var(--panel-2); }

tbody tr.selected { background: var(--amber-dim); }

.col-check { width: 30px; }

.col-actions { width: 110px; text-align: right; }

.col-size, .col-mtime, .col-mode { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.col-mode { color: var(--dim); }

/* Always visible on touch (no hover); on pointer devices, reveal on hover/selection/focus. */
td.col-actions .icon-btn { opacity: 1; transition: opacity 0.1s; }

@media (hover: hover) {
  td.col-actions .icon-btn { opacity: 0; }
  tr:hover td.col-actions .icon-btn,
  tr.selected td.col-actions .icon-btn,
  tr:focus-within td.col-actions .icon-btn { opacity: 1; }
}

.fname {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  max-width: 46vw;
  min-width: 0;
  overflow: hidden;
}

/* Truncation has to live on the text node, not the inline-flex button. */
.fname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.fname:hover { color: var(--amber-2); }

.fname svg { width: 15px; height: 15px; flex: none; }

.fname .i-dir { color: var(--amber); }

.fname .i-file { color: var(--dim); }

.fname .i-broken { color: var(--err); }

.link-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0 4px;
}

input[type='checkbox'] {
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  vertical-align: -3px;
  position: relative;
}

input[type='checkbox']:checked { background: var(--amber); border-color: var(--amber); }

input[type='checkbox']:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #211404;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
}

.notice {
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--amber-2);
  background: var(--amber-dim);
  border-bottom: 1px solid var(--line);
}

.dropzone-active .panel { outline: 2px dashed var(--amber); outline-offset: -2px; }

/* ------------------------------------------------------------ editor */

.editor {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.editor-head .path {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.editor-head .path b { color: var(--text); font-weight: 400; }

.editor-dirty { color: var(--amber); font-family: var(--mono); font-size: 11px; }

.editor textarea {
  flex: 1;
  background: var(--bg);
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font: 13px/1.6 var(--mono);
  padding: 16px 20px;
  tab-size: 4;
  white-space: pre;
}

.editor-foot {
  padding: 5px 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
}

/* ------------------------------------------------------------ status */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
}

.card .eyebrow { margin-bottom: 8px; }

.card .big {
  font-family: var(--mono);
  font-size: 26px;
  color: var(--text);
  line-height: 1.15;
}

.card .big small { font-size: 14px; color: var(--muted); }

.card .sub {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  height: 6px;
  background: var(--panel-3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--amber);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.bar.hot i { background: var(--err); }

.disk-row { margin-top: 9px; }

.disk-row .lbl {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

.disk-row .lbl b { color: var(--text); font-weight: 400; }

.disk-row .bar { margin-top: 4px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 10px;
}

.section-title .eyebrow { flex: none; }

.section-title .rule { flex: 1; height: 1px; background: var(--line); }

.section-title .n { font-family: var(--mono); font-size: 11px; color: var(--dim); }

.section-title input { max-width: 200px; padding: 5px 9px; font-size: 12px; }

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 8px;
  vertical-align: 1px;
}

.dot.err { background: var(--err); }

.badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--ok-dim);
  color: var(--ok);
}

.badge.err { background: var(--err-dim); color: var(--err); }

.badge.amber { background: var(--amber-dim); color: var(--amber-2); }

.svc-name, .proc-cmd { font-family: var(--mono); font-size: 12.5px; }

.svc-desc { color: var(--muted); font-size: 12.5px; white-space: normal; }

.proc-cmd { color: var(--muted); max-width: 480px; overflow: hidden; text-overflow: ellipsis; }

.failed-panel { border-color: rgba(225, 91, 84, 0.4); margin-bottom: 14px; }

/* ----------------------------------------------------------- backups */

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.form-row .field { flex: 1; min-width: 220px; }

/* ------------------------------------------------------------- users */

.perm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 4px 0;
}

.perm-grid label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  padding: 1px 7px;
  margin: 1px 3px 1px 0;
  border-radius: 4px;
  background: var(--panel-3);
  color: var(--muted);
}

.chip.admin { background: var(--amber-dim); color: var(--amber-2); }

/* ------------------------------------------------------------ account */

.stack { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }

.stack .panel { padding: 18px; overflow: visible; }

.stack h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

.acct-note {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--amber-2);
  background: var(--amber-dim);
  border-radius: var(--r-s);
  padding: 8px 11px;
}

.stack .field { margin-bottom: 10px; }

/* ------------------------------------------------------------- modal */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 20px;
}

.modal h3 { font-size: 14.5px; font-weight: 600; margin-bottom: 12px; }

.modal .msg { color: var(--muted); font-size: 13px; margin-bottom: 14px; white-space: pre-wrap; word-break: break-word; }

.modal .field { margin-bottom: 14px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--amber);
  border-radius: var(--r-s);
  padding: 9px 16px;
  font-size: 13px;
  max-width: 480px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.18s ease;
}

.toast.err { border-left-color: var(--err); }

.toast.ok { border-left-color: var(--ok); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* -------------------------------------------------------- upload tray */

.uploads {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 10px 12px;
  z-index: 150;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.uploads h4 {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.up-item { margin-bottom: 8px; }

.up-item .lbl {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
}

.up-item .lbl span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.up-item .bar { margin-top: 3px; height: 4px; }

.up-item.done .lbl { color: var(--ok); }

.up-item.fail .lbl { color: var(--err); }

/* --------------------------------------------------------- responsive */

@media (max-width: 800px) {
  .rail { width: 54px; padding: 12px 7px; }
  .rail .brand { font-size: 12px; letter-spacing: 0; padding: 4px 6px 14px; overflow: hidden; }
  .rail .brand span { display: none; }
  .nav-btn span { display: none; }
  .nav-btn { justify-content: center; padding: 10px 0; }
  .rail-foot .who { display: none; }
  .rail-foot { justify-content: center; }
  .strip { gap: 10px; font-size: 11px; }
  .strip .opt { display: none; }
  .content { padding: 12px 12px 28px; }
  .col-mode, .col-mtime { display: none; }
  .fname { max-width: 52vw; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
