/* The controller's look (style brief, 22 Oct 2026; name removed 26 Oct): white page,
   olive accent, dark-green header and footer, Archivo Narrow headings, Abel body,
   square-ish corners, flat. The product name comes from PC_PRODUCT_NAME. */
@import url("https://fonts.googleapis.com/css2?family=Abel&family=Archivo+Narrow:wght@700&display=swap");

:root {
  --page: #ffffff;
  --alt: #f2f2f2;
  --text: #121212;
  --muted: rgba(18, 18, 18, 0.6);
  --line: rgba(18, 18, 18, 0.14);
  --line-strong: rgba(18, 18, 18, 0.3);

  --accent: #aec570;
  --accent-hover: #a4be5e;
  --accent-tint: rgba(174, 197, 112, 0.3);
  --dark: #112009;
  --alert: #ff555d;
  --alert-hover: #f0434b;

  /* status colours, chosen to sit with the olive accent */
  --ok-text: #3f5f12;
  --ok-bg: rgba(174, 197, 112, 0.35);
  --warn-text: #7a5000;
  --warn-bg: rgba(232, 176, 60, 0.28);
  --bad-text: #a8232a;
  --bad-bg: rgba(255, 85, 93, 0.18);
  --info-text: #2d4a55;
  --info-bg: rgba(110, 150, 165, 0.2);

  --radius: 2px;
  --head: "Archivo Narrow", "Arial Narrow", sans-serif;
  --body: "Abel", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 16px;
  background: var(--page);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--head); font-weight: 700; margin: 0; letter-spacing: 0.01em; }
code { font-family: var(--mono); font-size: 12px; background: var(--alt); padding: 1px 5px; border-radius: var(--radius); }
.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- header band */
.header-band { background: var(--dark); color: #fff; }
.topbar {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; color: #fff; text-decoration: none; }
.logo-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--dark);
  font-family: var(--head); font-size: 22px; letter-spacing: 0.02em;
  border-radius: var(--radius);
}
.brand h1 { font-size: 22px; color: #fff; }
.subtitle { margin: 2px 0 0; font-size: 14px; color: rgba(255, 255, 255, 0.7); }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 17px;
  padding: 10px 14px;
  border-radius: var(--radius);
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav a.active { color: var(--dark); background: var(--accent); }

.user-menu { position: relative; }
.user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  color: #fff;
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--body);
}
.user-trigger:hover, .user-trigger[aria-expanded="true"] { border-color: var(--accent); }
.avatar {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--dark);
  border-radius: var(--radius);
  font-family: var(--head);
  text-transform: uppercase;
}
.who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.who strong { font-size: 15px; font-weight: 400; }
.who span { font-size: 12px; color: rgba(255, 255, 255, 0.65); }
.chevron { font-size: 10px; color: rgba(255, 255, 255, 0.65); }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 190px;
  background: var(--page);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 20;
}
.user-dropdown[hidden] { display: none; }
.user-dropdown button {
  width: 100%; text-align: left;
  background: none; border: none;
  padding: 12px; font: inherit; color: var(--text);
  cursor: pointer; border-radius: var(--radius);
}
.user-dropdown button:hover { background: var(--alt); }
.user-dropdown button.danger { color: var(--bad-text); }

/* Right-click menu (Units) */
.ctx-menu {
  position: fixed; min-width: 180px;
  background: var(--page);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 4px; z-index: 30;
}
.ctx-menu[hidden] { display: none; }
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  background: none; border: none;
  padding: 10px 12px; font: inherit; color: var(--text);
  cursor: pointer; border-radius: var(--radius);
}
.ctx-menu button:hover { background: var(--alt); }
.ctx-menu button.danger { color: var(--bad-text); }
.ctx-menu button:disabled { color: var(--muted, #888); cursor: default; background: none; }

/* ---------------------------------------------------------------- page */
.app { max-width: 1080px; margin: 0 auto; padding: 18px 16px 40px; }

.strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.chip {
  font-size: 15px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--alt);
  color: var(--text);
}
.chip-ok { background: var(--ok-bg); border-color: transparent; color: var(--ok-text); }
.chip-warn { background: var(--warn-bg); border-color: transparent; color: var(--warn-text); }
.chip-bad { background: var(--bad-bg); border-color: transparent; color: var(--bad-text); }
.chip-muted { color: var(--muted); }
.chip-accent { background: var(--info-bg); border-color: transparent; color: var(--info-text); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.card {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 { font-size: 20px; margin: 0 0 6px; }
.card p { margin: 0 0 14px; font-size: 15px; }
.history { margin-bottom: 18px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.history-head h2 { margin: 0; }
.history-head .actions { flex: 0 0 auto; }

/* ---------------------------------------------------------------- forms + buttons */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 14px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"], select {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--page);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin-bottom: 14px; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent-hover); }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; color: var(--muted); }
label.inline select { width: auto; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  font-family: var(--body);
  font-size: 18px;
  padding: 12px 18px;
  min-height: 46px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--page);
  color: var(--text);
  cursor: pointer;
  flex: 1 1 auto;
  text-align: center;
  justify-content: center;
}
.btn:hover { border-color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--alert); border-color: var(--alert); color: #fff; }
.btn-danger:hover { background: var(--alert-hover); border-color: var(--alert-hover); }
.btn-ghost { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn-ghost:hover { border-color: var(--line); }
.btn-block { width: 100%; flex: none; margin-top: 10px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.history-head .btn, .detail .actions .btn { flex: 0 0 auto; min-width: 0; }

.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.preset {
  font: inherit; font-size: 16px;
  min-width: 52px; min-height: 42px;
  padding: 8px 12px;
  background: var(--alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}
.preset:hover { border-color: var(--accent); }
.preset.active { background: var(--accent-tint); border-color: var(--accent); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  text-align: left;
  font-family: var(--head);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px;
  border-bottom: 2px solid var(--dark);
}
td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--alt); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-sent { background: var(--ok-bg); color: var(--ok-text); }
.badge-pending { background: var(--warn-bg); color: var(--warn-text); }
.badge-failed { background: var(--bad-bg); color: var(--bad-text); }
.badge-cancelled { background: var(--alt); color: var(--muted); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions button {
  font: inherit; font-size: 15px;
  min-height: 38px; padding: 6px 12px;
  background: var(--page);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}
.row-actions button:hover { border-color: var(--accent); }

.role-badge { font-size: 13px; padding: 3px 8px; border-radius: var(--radius); text-transform: uppercase; }
.role-admin { background: var(--accent-tint); color: var(--ok-text); }
.role-user { background: var(--alt); color: var(--muted); }

/* ---------------------------------------------------------------- dashboard nodes */
.nodes-table tr.node-row { cursor: pointer; }
.nodes-table tr.node-row.open { background: var(--accent-tint); }
.nodes-table tr.node-row.missing td:first-child strong { color: var(--bad-text); }
.nodes-table tr.detail-row:hover { background: none; }
.nodes-table tr.detail-row > td { background: var(--alt); border-bottom: 2px solid var(--accent); }
.detail { padding: 8px 4px 12px; }
.detail p { margin: 6px 0; font-size: 15px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 18px;
  margin-bottom: 8px;
}
.detail-grid span { display: block; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-grid strong { font-size: 15px; font-weight: 400; word-break: break-all; }
.detail .actions { margin-top: 12px; align-items: center; }
.path { font-family: var(--mono); font-size: 13px; word-break: break-all; }
.link-history table { margin-top: 10px; background: var(--page); }
.gw-table { margin: 4px 0 6px; background: var(--page); }
.gw-table td { padding: 8px 10px; }

/* ---------------------------------------------------------------- footer */
.footer-band { background: var(--dark); color: rgba(255, 255, 255, 0.7); font-size: 14px; }
.footer-band div { max-width: 1080px; margin: 0 auto; padding: 14px 16px; }

/* ---------------------------------------------------------------- toast + modals */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  background: var(--dark); color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  font-size: 16px;
  max-width: calc(100% - 32px);
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-left-color: var(--alert); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(17, 32, 9, 0.55);
  display: none; place-items: center;
  padding: 16px;
  z-index: 40;
}
.modal-backdrop.open { display: grid; }
.modal { background: var(--page); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 420px;
  max-height: calc(100vh - 32px); overflow-y: auto; }
#sites-modal .modal { max-width: 640px; }
.modal h2 { margin: 0 0 16px; font-size: 22px; }
.modal .actions { margin-top: 18px; }

/* ---------------------------------------------------------------- sign-in page */
.auth-body { display: grid; place-items: center; padding: 16px; background: var(--alt); }
.auth-card { background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 0 22px; width: 100%; max-width: 400px; overflow: hidden; }
.auth-card form, .auth-card .auth-hint { padding: 0 22px; }
.auth-brand { background: var(--dark); padding: 16px 22px; margin-bottom: 22px; }
.auth-brand h1 { font-size: 20px; }
.auth-error { color: var(--bad-text); font-size: 15px; min-height: 20px; margin: 10px 0 0; }
.auth-hint { font-size: 14px; margin: 12px 0 0; }

/* ---------------------------------------------------------------- phone */
@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .brand h1 { font-size: 20px; }
  .subtitle { display: none; }
  .nodes-table th:nth-child(2), .nodes-table td:nth-child(2) { display: none; }
  .card { padding: 14px; }
  .btn { width: 100%; }
}

/* ---------------------------------------------------------------- progress page */
.bar { height: 10px; background: var(--alt); border-radius: var(--radius); margin: 4px 0 14px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }

/* Controls only admins get (Workshop and User roles don't). */
.admin-hidden { display: none !important; }

/* Something is running (poll, link tests): a pulsing dot on the busy chip. */
.chip.busy::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px;
  border-radius: 50%; background: currentColor; vertical-align: middle;
  animation: busy-pulse 1s ease-in-out infinite;
}
@keyframes busy-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

/* Dispatch scan lines: green can go, red says why not. */
tr.scan-ok td { background: var(--ok-bg); }
tr.scan-bad td { background: var(--bad-bg); }
