/* Big Ideas siteXA — matches the RAPIX Facilities app (same tokens, header, sidebar, login). */
:root {
  --teal: #152834;
  --teal-dark: #0f1f29;
  --teal-light: #eef2ea;
  --nav-bg: #11212b;
  --nav-bg-2: #152834;
  --nav-text: #cfd8cc;
  --nav-accent: #ffc400;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a2332;
  --dim: #64748b;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --off: #94a3b8;
  --side-w: 196px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--teal); }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- Sign in (same as the Facilities login overlay) ---------- */
body.logged-out { background: var(--nav-bg); }
.login-overlay {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 16px;
  background: #152834;                             /* the logo's own background, so the big logo sits on it seamlessly */
}
.login-card {
  background: #fff; border-radius: 6px; padding: 28px 32px; width: 100%; max-width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-logo { width: 64px; height: 64px; display: block; margin: 0 auto 10px; border-radius: 12px; }
.login-hero { width: 380px; max-width: 86vw; height: auto; display: block; margin: 0 auto 6px; }
@media (max-height: 640px) { .login-hero { width: 240px; } }
.brand-logo { border-radius: 7px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; color: var(--text); text-align: center; }
.login-sub { color: var(--dim); font-size: 13px; margin: 0 0 16px; text-align: center; }
.login-note { background: var(--teal-light); color: var(--teal-dark); font-size: 12.5px; padding: 8px 10px; border-radius: 4px; margin-bottom: 12px; }
.login-card label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 10px; }
.login-card input[type=text], .login-card input[type=password] {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 6px; font-size: 14px; color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(255,196,0,.15); }
.login-remember { display: flex !important; align-items: center; gap: 8px; }
.login-card button.primary {
  width: 100%; margin-top: 8px; padding: 10px; border: none; border-radius: 6px;
  background: var(--teal); color: #fff; font-weight: 600; cursor: pointer; font-size: 14px;
}
.login-card button.primary:hover { background: var(--teal-dark); }
.login-error { color: var(--err); font-size: 12px; min-height: 18px; margin-top: 8px; }
.login-link { display: block; text-align: center; font-size: 12.5px; margin-top: 6px; text-decoration: none; }
.login-link:hover { text-decoration: underline; }

/* ---------- App shell (topbar + navy sidebar) ---------- */
.app-shell { height: 100vh; display: flex; flex-direction: column; }
.app-shell.nav-collapsed { --side-w: 60px; }
.topbar {
  height: 46px; flex-shrink: 0; display: flex; align-items: center;
  background: var(--teal); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); z-index: 5;
}
.topbar .brand {
  width: var(--side-w); height: 100%; display: flex; align-items: center; gap: 8px;
  padding: 0 16px; flex-shrink: 0; overflow: hidden; transition: width .15s;
}
.brand-logo { width: 32px; height: 32px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; white-space: nowrap; }
.brand-name { font-weight: 700; font-size: 13px; }
.brand-sub { font-size: 10.5px; opacity: .85; letter-spacing: .03em; }
.app-shell.nav-collapsed .brand-text { display: none; }
.app-shell.nav-collapsed .topbar .brand { padding: 0 14px; }
.page-title { font-size: 16px; padding-left: 14px; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; padding-right: 14px; font-size: 12px; }
.logout-btn {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; color: #fff; font-size: 12px;
  font-weight: 600; border-radius: 4px; opacity: .9; text-decoration: none;
}
.logout-btn:hover { background: rgba(255,255,255,.16); opacity: 1; }
.logout-btn svg { width: 16px; height: 16px; stroke: currentColor; }

.body-row { flex: 1; display: flex; min-height: 0; }
.content-col { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.sidenav {
  width: var(--side-w); flex-shrink: 0; background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; transition: width .15s; overflow: hidden;
}
.nav-group { padding-top: 6px; }
.nav-group + .nav-group { border-top: 1px solid rgba(255,255,255,.08); margin-top: 6px; }
.tab {
  display: flex; align-items: center; gap: 14px; height: 44px; padding: 0 18px;
  color: var(--nav-text); font-size: 13px; font-weight: 500; text-decoration: none;
  border-left: 3px solid transparent; white-space: nowrap;
}
.tab svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; }
.tab:hover { background: rgba(255,255,255,.05); color: #fff; }
.tab.active { background: var(--nav-bg-2); color: #fff; border-left-color: var(--nav-accent); }
.tab.active svg { stroke: var(--nav-accent); }
.nav-spacer { flex: 1; }
.nav-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); overflow: hidden; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; background: var(--teal);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.who { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.who-name { font-size: 12px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge {
  align-self: flex-start; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: rgba(92,184,255,.18); color: var(--nav-accent); white-space: nowrap;
}
.nav-collapse {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 20px; border: none;
  border-top: 1px solid rgba(255,255,255,.08); background: transparent; color: var(--nav-text);
  font-size: 13px; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.nav-collapse:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-collapse svg { width: 16px; height: 16px; stroke: currentColor; transition: transform .15s; }
.app-shell.nav-collapsed .nav-collapse svg { transform: rotate(180deg); }
.app-shell.nav-collapsed .lbl,
.app-shell.nav-collapsed .who { display: none; }
.app-shell.nav-collapsed .tab { padding: 0 20px; }

/* ---------- Sub bar: "List of sites" + search ---------- */
.subbar {
  flex-shrink: 0; height: 44px; display: flex; align-items: stretch; gap: 16px; padding: 0 16px;
  background: var(--card); border-bottom: 1px solid var(--border);
}
.subtab {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--teal-dark);
  border-bottom: 2px solid var(--teal); padding: 0 4px; white-space: nowrap;
}
.subtab svg { width: 16px; height: 16px; stroke: currentColor; }
.search {
  margin-left: auto; align-self: center; display: flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0 10px;
  width: 280px; max-width: 50%; color: var(--dim);
}
.search:focus-within { border-color: var(--teal); background: #fff; }
.search svg { width: 14px; height: 14px; stroke: currentColor; flex-shrink: 0; }
.search input { border: none; background: transparent; padding: 7px 0; font-size: 13px; width: 100%; color: var(--text); outline: none; font-family: inherit; }

/* ---------- Site tiles ---------- */
.sites-wrap { flex: 1; overflow-y: auto; padding: 20px; }
.sites-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.site-card {
  position: relative; display: block; aspect-ratio: 1 / 1; border-radius: 4px; overflow: hidden;
  background: var(--nav-bg); color: #fff; text-decoration: none;
  box-shadow: 0 1px 2px rgba(15,31,51,.08), 0 2px 8px rgba(15,31,51,.06);
  transition: transform .15s, box-shadow .15s;
}
.site-card:hover, .site-card:focus-visible {
  transform: translateY(-2px); outline: none;
  box-shadow: 0 0 0 3px var(--teal), 0 8px 22px rgba(15,31,51,.22);
}
.site-card.not-ready { cursor: default; }
.site-card.not-ready:hover { transform: none; box-shadow: 0 1px 2px rgba(15,31,51,.08); }
.site-card.not-ready .site-img { filter: grayscale(.8) brightness(.8); }
.site-img {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  background-color: var(--nav-bg-2);
  background-image: linear-gradient(160deg, #11212b 0%, #0f1f29 60%, #152834 100%);
  display: flex; align-items: center; justify-content: center; transition: transform .3s;
}
.site-card:hover .site-img { transform: scale(1.03); }
.site-ph { width: 38%; height: auto; opacity: .9; margin-bottom: 18%; }
.site-cap {
  position: absolute; left: 0; right: 0; bottom: 0; min-height: 50px; padding: 10px 14px;
  background: rgba(15,31,51,.82); border-top: 2px solid var(--teal);
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.site-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.site-client { font-size: 11px; color: var(--nav-text); }
.site-status, .site-role {
  position: absolute; top: 10px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 10px;
  background: rgba(15,31,51,.78); color: #fff; backdrop-filter: blur(2px);
}
.site-status { right: 10px; }
.site-role { left: 10px; background: rgba(255,196,0,.88); }
.site-status em { font-style: normal; }
.site-status i, .statusbar i { width: 8px; height: 8px; border-radius: 50%; background: var(--off); display: inline-block; }
.site-status.checking i { animation: pulse 1.2s infinite ease-in-out; }
.site-status.on i, .st-on { background: var(--ok) !important; }
.site-status.warn i, .st-warn { background: var(--warn) !important; }
.site-status.err i, .st-err { background: var(--err) !important; }
@keyframes pulse { 50% { opacity: .3; } }

.sites-foot { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 22px 0 6px; font-size: 13px; color: var(--text); }
.link-btn { border: none; background: none; color: var(--teal); font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }
.no-match, .empty { text-align: center; color: var(--dim); padding: 50px 20px; font-size: 14px; }
.empty img { width: 56px; height: 56px; margin-bottom: 12px; }
.empty h2 { font-size: 16px; color: var(--text); margin-bottom: 6px; }

.statusbar {
  flex-shrink: 0; height: 32px; display: flex; align-items: center; gap: 18px; padding: 0 14px;
  background: #fff; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--dim);
}
.statusbar .sw { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.statusbar .grow { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .app-shell { --side-w: 60px; }
  .brand-text, .lbl, .who { display: none; }
  .tab { padding: 0 20px; }
  .nav-collapse { display: none; }
}
@media (max-width: 600px) {
  .page-title { display: none; }
  .subbar { padding: 0 12px; gap: 10px; }
  .subtab { font-size: 12px; }
  .search { max-width: none; width: auto; flex: 1; }
  .sites-wrap { padding: 16px; }
  .sites-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .site-card { aspect-ratio: 3 / 4; }
  .site-name { font-size: 11.5px; }
  .site-role { display: none; }
  .statusbar .sw:nth-child(2) { display: none; }
}

/* ===================== Standalone portal additions ===================== */
.login-help { font-size: 12px; color: var(--dim); text-align: center; margin-top: 6px; }
.login-card code { font-size: 11.5px; background: #f1f5f9; padding: 1px 4px; border-radius: 3px; }
.top-right form { display: contents; }
button.logout-btn { border: none; background: transparent; cursor: pointer; font-family: inherit; }

.subtab-link {
  display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text);
  text-decoration: none; padding: 0 4px; white-space: nowrap;
}
.subtab-link:hover { color: var(--teal); }
.subtab-link svg { width: 14px; height: 14px; stroke: currentColor; }

.page-wrap { flex: 1; overflow-y: auto; padding: 20px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; margin-right: auto; }
.panel-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 4px; padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(15,31,51,.05); min-width: 0;
}
.panel-card.flush { padding: 0; overflow-x: auto; }
.panel-card h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim);
  font-weight: 600; margin-bottom: 12px;
}
.panel-card h3.mt { margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: block; font-size: 12px; color: var(--dim); font-weight: 600; margin-bottom: 14px; }
.field input, .field select {
  display: block; width: 100%; margin-top: 5px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; color: var(--text); font-family: inherit; font-weight: 400; background: #fff;
}
.field.narrow input { max-width: 120px; }
.field input:focus, select:focus, .secret-row input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(255,196,0,.15); }
.field small, .panel-card small { display: block; font-weight: 400; color: var(--dim); font-size: 11.5px; margin-top: 4px; line-height: 1.45; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text); margin: 10px 0 0; }
.check input { margin-top: 2px; }
.muted { color: var(--dim); font-size: 12.5px; line-height: 1.5; }
p.muted { margin-bottom: 12px; }
code, .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; }
.btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); color: #fff; }
.btn.danger { color: var(--err); border-color: #f5c2c2; }
.btn.danger:hover { background: #fef2f2; border-color: var(--err); color: #b42318; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.danger-zone { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; background: #f4f6f8; font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 12px; white-space: nowrap;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data a { color: var(--text); text-decoration: none; }
table.data a:hover { color: var(--teal); }
table.data .num { text-align: right; }
table.data .actions { text-align: right; width: 1%; }
table.data.compact td, table.data.compact th { padding: 6px 8px; }
table.data select { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; width: 100%; background: #fff; font-family: inherit; }
table.data tr.dim td { color: var(--dim); }
.panel-card table.data.compact { margin-top: 4px; }
.thumb-col { width: 72px; }
.thumb { display: block; width: 56px; height: 42px; object-fit: cover; border-radius: 3px; }
.thumb.ph { background: linear-gradient(160deg, #11212b 0%, #0f1f29 60%, #152834 100%); }
.pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; background: var(--teal-light); color: var(--teal-dark); vertical-align: 1px; }
.pill.grey { background: #f1f5f9; color: var(--dim); }
.empty-row { padding: 30px; text-align: center; color: var(--dim); }

.alert { padding: 10px 14px; border-radius: 4px; font-size: 13px; margin-bottom: 14px; }
.alert.err { background: #fef2f2; border: 1px solid #fecaca; color: #b42318; }
.alert.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; margin-top: 8px; }
.ctl-box { border-top: 1px solid #e5e7eb; margin-top: 16px; padding-top: 4px; }
.ctl-box h3 .pill { vertical-align: middle; margin-left: 6px; }
.toast {
  position: fixed; right: 20px; bottom: 48px; z-index: 50; padding: 10px 16px; border-radius: 6px;
  background: var(--nav-bg); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  border-left: 3px solid var(--ok); transition: opacity .4s;
}
.toast.hide { opacity: 0; pointer-events: none; }

.photo-row { display: flex; gap: 14px; align-items: flex-start; }
.photo-row input[type=file] { font-size: 12.5px; max-width: 100%; }
.photo-preview {
  width: 120px; height: 120px; flex-shrink: 0; border-radius: 4px; background-size: cover; background-position: center;
  background-color: var(--nav-bg); display: flex; align-items: center; justify-content: center;
  background-image: linear-gradient(160deg, #11212b 0%, #0f1f29 60%, #152834 100%);
}
.photo-preview img { width: 44px; opacity: .9; }
.secret-row { display: flex; gap: 8px; }
.secret-row input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; background: #f8fafc; color: var(--text); }

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page-wrap { padding: 16px; }
  .subtab-link { display: none; }
  .photo-row { flex-direction: column; }
  table.data th:nth-child(3), table.data td:nth-child(3) { display: none; }
}

/* ---------- Pis (codes, status) ---------- */
.pill.ok { background: #dcfae6; color: #067647; }
.pill.warn { background: #fef0c7; color: #93370d; }
.pill.bad { background: #fee4e2; color: #b42318; }
.panel-card.mb { margin-bottom: 16px; }
.pi-line { font-size: 13px; line-height: 1.7; margin-bottom: 10px; }
.field.narrow-code input { max-width: 220px; text-transform: uppercase; letter-spacing: .14em; font-size: 16px; font-family: ui-monospace, Menlo, Consolas, monospace; }
details.pending { margin-top: 4px; font-size: 12.5px; }
details.pending summary { cursor: pointer; color: var(--teal); margin-bottom: 8px; }
.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; }
.addr-preview { margin: 6px 0 8px; padding: 9px 12px; border: 1px dashed var(--border); border-radius: 6px; background: #f8fafc;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; font-weight: 500; color: var(--text); word-break: break-all; }
.addr-preview.muted { color: var(--dim); }
.field .check { font-weight: 400; color: var(--text); font-size: 13px; display: flex; align-items: center; gap: 6px; margin: 2px 0 6px; }
.field input[hidden] { display: none; }
.field .check input[type=checkbox] { display: inline-block; width: auto; margin: 0; padding: 0; }

/* remote programming list on the site page (1.5) */
ul.plain { list-style: none; padding: 0; margin: 8px 0; }
ul.plain li { padding: 6px 0; border-top: 1px solid #e2e8f0; }
ul.plain li:first-child { border-top: 0; }

/* siteXA palette */
input[type=checkbox], input[type=radio] { accent-color: #152834; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

/* head ends at a site (1.14) */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th, .mini-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
.mini-table th { font-size: 12px; color: #64748b; font-weight: 600; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0 4px 0 0; }
.btn.danger { color: #b42318; }
