/* ═══ IRIS Shared Design System ═══════════════════════════════════════
   All pages import this. Page-specific overrides go in <style> blocks.
   Industrial Reasoning & Intelligence System — UI on top of ATLAS.
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

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

:root {
  --bg-0: #0b0f14;
  --bg-1: #131a23;
  --bg-2: #1b2532;
  --bg-3: #242f3f;
  --bg-4: #2c3a4f;
  --surface-1: rgba(23, 33, 46, 0.82);
  --surface-2: rgba(13, 19, 28, 0.96);
  --surface-3: rgba(11, 17, 25, 0.72);
  --border: #33455d;
  --border-hi: #4f6b8e;
  --text-0: #edf3fb;
  --text-1: #bdd0e8;
  --text-2: #88a2c2;
  --accent: #f59e0b;
  --accent-dk: #b26b00;
  --green: #34d399;
  --green-dk: #0f7658;
  --green-bg: #0b2f28;
  --yellow: #fbbf24;
  --yellow-bg: #3b2a05;
  --red: #f87171;
  --red-dk: #b91c1c;
  --red-bg: #320f12;
  --cyan: #22d3ee;
  /* Teal accent — used by the engineer-view top nav's active tab.
     Moved here 2026-05-24 evening so rca.html (and any other page
     adding the IRIS top nav) gets matching colors instead of
     hard-coded literals. */
  --teal: #1ee0b8;
  --teal-dk: #0b7a63;
  --teal-bg: rgba(30, 224, 184, .10);
  --teal-bd: rgba(30, 224, 184, .38);
  --panel-bd: rgba(110, 139, 173, .22);
  --font: "Space Grotesk", "Avenir Next", "Trebuchet MS", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", "Consolas", monospace;
  --radius: 10px;
  --radius-lg: 18px;
  --shadow: 0 14px 40px rgba(0, 0, 0, .35);
  --shadow-soft: 0 18px 44px rgba(0, 0, 0, .28);
  --shell-border: rgba(110, 139, 173, 0.22);
}

html, body {
  min-height: 100%;
  color: var(--text-0);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  overflow-x: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, #091018 0%, #0b1118 38%, #0b0f14 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: 0;
  background:
    radial-gradient(1100px 720px at -8% -18%, rgba(34, 211, 238, 0.12), transparent 62%),
    radial-gradient(980px 660px at 112% -10%, rgba(245, 158, 11, 0.11), transparent 58%),
    radial-gradient(900px 560px at 50% 118%, rgba(79, 107, 142, 0.18), transparent 68%);
}

body::after {
  z-index: 0;
  opacity: .22;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 120px 120px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.38), transparent 88%);
}

body > * {
  position: relative;
  z-index: 1;
}

a {
  color: inherit;
}

body > .page,
body > .main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

body > .main {
  max-width: 980px;
}

body > .page {
  max-width: 1120px;
}

body .page-title {
  font-size: clamp(26px, 3.2vw, 34px);
  line-height: 1.08;
  letter-spacing: -.6px;
  font-weight: 700;
  margin-bottom: 8px;
}

body .page-sub {
  max-width: 760px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 28px;
}

/* ─── Shared Header ─────────────────────────────────────────────────────── */

.gf-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  min-height: 62px;
  border-bottom: 1px solid var(--shell-border);
  background:
    linear-gradient(180deg, rgba(18, 26, 36, 0.9) 0%, rgba(9, 13, 19, 0.84) 100%);
  backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  position: sticky;
  top: 0;
  z-index: 100;
}

.gf-header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.gf-header .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.gf-header .logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gf-header .logo > div {
  /* 2026-05-24 evening — when the right-cluster is wide (rca.html
     has project + role select + gear), the brand div was getting
     squeezed enough to wrap onto multiple lines. Prevent shrink
     and keep the brand text on a single line. */
  flex-shrink: 0;
  white-space: nowrap;
}
.gf-header .logo-text {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text-0);
  white-space: nowrap;
}

.gf-header .logo-sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  margin-top: -2px;
  white-space: nowrap;
}

.gf-header .header-spacer { flex: 1; }

.gf-header .nav-links {
  display: flex;
  gap: 6px;
}

.gf-header .nav-links a {
  color: var(--text-1);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all .15s;
}

.gf-header .nav-links a:hover {
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.06);
  color: var(--text-0);
}

.gf-header .nav-links a.active {
  background: rgba(245, 158, 11, .12);
  border-color: rgba(245, 158, 11, .24);
  color: #ffd289;
}

/* IRIS primary top-nav (2026-05-24 evening). Used by engineer.html
   + rca.html (+ any future page) so all pages share the same five-
   link bar: Projects / Virtual Map / Commissioning Report / Logic
   Viewer / Fault Explorer. Active tab uses the teal accent so
   "you are here" reads at a glance.

   Previously defined inline in engineer.html; lifted here so
   rca.html (and any other page that adopts the nav) doesn't drift
   visually. */
.gf-header .nav-tabs {
  display: flex;
  gap: 4px;
  margin-left: 14px;
}
.gf-header .nav-tabs a {
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.gf-header .nav-tabs a:hover {
  color: var(--text-0);
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.06);
}
.gf-header .nav-tabs a.active {
  background: var(--teal-bg);
  border-color: var(--teal-bd);
  color: var(--teal);
}

/* Right-cluster controls (project selector, role selector, etc.)
   in the IRIS top nav. Lifted from engineer.html so rca.html (and
   any other page) gets the same layout + control styling. */
.gf-header .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.gf-header .proj-select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-0);
  font: 500 12px var(--font);
  padding: 8px 11px;
  border-radius: 8px;
  outline: none;
  min-width: 160px;
  cursor: pointer;
}
.gf-header .proj-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(30,224,184,.18);
}

/* Notification bell + signed-in avatar. Lifted from engineer.html
   inline styles so rca.html (and any future page) gets them. */
.gf-header .bell-btn {
  position: relative;
  width: 36px; height: 36px;
  background: linear-gradient(180deg, rgba(36,47,63,.92), rgba(25,34,45,.96));
  border: 1px solid var(--panel-bd);
  border-radius: 10px;
  color: var(--text-1);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.gf-header .bell-btn:hover {
  color: var(--teal); border-color: var(--teal);
}
.gf-header .bell-dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px rgba(248,113,113,.85);
}
.gf-header .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal) 0%, #2b7bf7 100%);
  color: #0a1c17; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.12);
}

/* Header icon buttons (settings gear, refresh) */
.gf-header .btn-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(180deg, rgba(36,47,63,.92), rgba(25,34,45,.96));
  border: 1px solid var(--shell-border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-1);
  transition: transform .15s, border-color .2s, color .2s;
}

.gf-header .btn-icon:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Shared Section Cards ──────────────────────────────────────────────── */

.section {
  background: linear-gradient(180deg, rgba(23, 33, 46, 0.78), rgba(12, 18, 27, 0.96));
  border: 1px solid var(--shell-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 18px;
}

/* ─── Shared Buttons ────────────────────────────────────────────────────── */

.btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--shell-border);
  background: linear-gradient(180deg, rgba(43, 58, 78, 0.9), rgba(28, 39, 53, 0.96));
  color: var(--text-1);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

body .btn:not(:disabled):hover,
body .setup-btn:not(:disabled):hover,
body .scan-btn:not(:disabled):hover {
  background: linear-gradient(180deg, rgba(57, 75, 98, 0.94), rgba(32, 45, 61, 0.98));
  color: var(--text-0);
  border-color: var(--border-hi);
  transform: translateY(-1px);
}

/* A disabled button must READ as disabled — no full color, no hover lift, no
   pointer. Otherwise a safety-gated button (e.g. Delete before the safety box is
   ticked) looks live even though its clicks are blocked. */
.btn:disabled, .btn[disabled] {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-save {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.78), rgba(178, 107, 0, 0.95));
  color: #fff8eb;
  border-color: rgba(245, 158, 11, 0.32);
}
.btn-save:hover { background: linear-gradient(180deg, rgba(245, 176, 49, 0.9), rgba(208, 124, 0, 0.98)); color: var(--bg-0); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red-dk); }
.btn-primary {
  background: linear-gradient(180deg, rgba(31, 114, 89, 0.92), rgba(15, 69, 56, 0.95));
  border-color: rgba(52,211,153,.34);
  color: var(--green);
}
.btn-primary:hover {
  border-color: rgba(52,211,153,.7);
  color: #7df0c5;
}

/* ─── Shared Inputs ─────────────────────────────────────────────────────── */

.gf-input, .gf-select {
  width: 100%;
  background: linear-gradient(180deg, rgba(23, 33, 45, 0.92), rgba(17, 24, 34, 0.98));
  border: 1px solid rgba(86, 110, 139, 0.34);
  color: var(--text-0);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
}

.gf-input:focus, .gf-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245,158,11,.16);
}

.gf-input.mono { font-family: var(--mono); }

body .input,
body .select,
body .key-input,
body .model-select,
body .role-select,
body .setup-input,
body .setup-select,
body .gf-input,
body .gf-select {
  background: linear-gradient(180deg, rgba(23, 33, 45, 0.92), rgba(16, 23, 32, 0.98));
  border: 1px solid rgba(86, 110, 139, 0.34);
  border-radius: 10px;
  color: var(--text-0);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}

/* Header ROLE selector — size it like Fault Explorer on EVERY page. The rule
   above sets colors/border but NOT padding/font, so the role dropdown rendered
   at the tiny browser default on non-dashboard pages while Fault Explorer got
   its size from dashboard.html's own .role-select. Mirror that size here so all
   pages match (David 2026-07-01: "copy the larger size from fault explorer").
   Value = Fault Explorer's .role-select (padding 8px 12px, 12px). */
body .role-select {
  font-family: var(--font);
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
}

body .select,
body .model-select,
body .role-select,
body .setup-select,
body .gf-select {
  color-scheme: dark;
}

body select option,
body .select option,
body .model-select option,
body .role-select option,
body .setup-select option,
body .gf-select option {
  background: #131a23;
  color: var(--text-0);
}

body select option:checked,
body .select option:checked,
body .model-select option:checked,
body .role-select option:checked,
body .setup-select option:checked,
body .gf-select option:checked {
  background: #1f4d8d;
  color: #ffffff;
}

body .input::placeholder,
body .key-input::placeholder,
body .setup-input::placeholder,
body .gf-input::placeholder {
  color: rgba(136, 162, 194, 0.62);
}

body .input:focus,
body .select:focus,
body .key-input:focus,
body .model-select:focus,
body .role-select:focus,
body .setup-input:focus,
body .setup-select:focus,
body .gf-input:focus,
body .gf-select:focus {
  outline: none;
  border-color: rgba(245, 158, 11, 0.82);
  box-shadow: 0 0 0 2px rgba(245,158,11,.16), 0 0 0 1px rgba(245,158,11,.1) inset;
}

/* ─── Status Messages ───────────────────────────────────────────────────── */

.msg { font-size: 13px; padding: 8px 12px; border-radius: 6px; margin-top: 8px; }
.msg.ok { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-dk); }
.msg.err { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-dk); }
.msg.warn { background: var(--yellow-bg); color: var(--yellow); border: 1px solid #6b4f0c; }

body .msg {
  border-radius: 10px;
  background: rgba(14, 21, 30, 0.72);
  border: 1px solid rgba(86, 110, 139, 0.24);
  color: var(--text-1);
  min-height: 38px;
  display: flex;
  align-items: center;
}

body .msg:empty {
  display: none;
}

body .msg.ok {
  background: rgba(11, 47, 40, 0.65);
  border-color: rgba(52, 211, 153, 0.24);
}

body .msg.err {
  background: rgba(50, 15, 18, 0.72);
  border-color: rgba(248, 113, 113, 0.28);
}

body .msg.warn {
  background: rgba(59, 42, 5, 0.78);
  border-color: rgba(251, 191, 36, 0.28);
}

/* ─── Shared Shell Surfaces ─────────────────────────────────────────────── */

body .card,
body .section,
body .history-wrap,
body .scan-wrap,
body .fault-list-wrap,
body .modal,
body .setup-panel,
body .support-files,
body .table-wrap,
body .review-scroll {
  border-color: var(--shell-border);
  box-shadow: var(--shadow-soft);
}

body .card,
body .history-wrap,
body .scan-wrap,
body .fault-list-wrap,
body .modal,
body .setup-panel {
  background:
    linear-gradient(180deg, rgba(26, 38, 52, 0.82), rgba(12, 18, 27, 0.96));
  backdrop-filter: blur(16px);
}

body .card-title,
body .modal-title {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -.3px;
  color: var(--text-0);
}

body .provider-row,
body .model-row,
body .history-item,
body .mp-step {
  border-bottom-color: rgba(86, 110, 139, 0.2);
}

body .table-wrap,
body .review-scroll,
body .support-files {
  background: rgba(8, 13, 20, 0.46);
}

body .table th,
body .tag-review-table th {
  color: var(--text-2);
  background: rgba(8, 13, 20, 0.46);
}

body .table td,
body .tag-review-table td {
  color: var(--text-1);
}

@media (max-width: 760px) {
  body > .page,
  body > .main {
    width: min(100%, calc(100% - 20px));
    padding: 22px 0 40px;
  }

  .gf-header {
    padding: 12px 16px;
    min-height: auto;
    flex-wrap: wrap;
  }

  .gf-header .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .section {
    padding: 20px;
  }
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ─── Spinner ───────────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Shared header Live/status pill ───────────────────────────────────────
   The header pill (_partials/iris_header.html) renders on EVERY page. Its CSS
   used to live only in dashboard.html, so Fault Explorer showed a styled pill
   while the other pages showed bare "Live"/"Offline" text. Moved here so every
   page that loads common.css styles it identically. (dashboard.html keeps its
   own copy for the Fault Explorer layout; identical values, no conflict.) */
.header-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(10,16,24,.45);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-2);
  flex-shrink: 0;
}
.dot.green  { background: var(--green);  box-shadow: 0 0 8px rgba(52,211,153,.85); }
.dot.red    { background: var(--red);    box-shadow: 0 0 8px rgba(248,113,113,.8); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 8px rgba(251,191,36,.8); }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.85); }
}
.dot.pulse { animation: pulse 2s ease-in-out infinite; }
