/* "Enterprise slate" theme, retinted to the real iaconnects.co.uk brand
   (pulled from the live site's own CSS custom properties + rendered
   screenshot - same source used for the AMS Sync Service retheme, so the
   two sibling apps now read as one family): a light content area with a
   dark, fixed sidebar (the Azure Portal/ServiceNow split kept from the
   previous pass), the site's own navy ink as the one accent for every
   primary action/link/active-state, its lime-green logo accent reserved for
   the dark sidebar's active-state (where a flat navy would vanish), and
   status colours drawn from its own green/red/orange accents - dark/
   saturated enough to read as text as well as fills. Replaced the previous
   invented indigo palette wholesale - see git history if that's ever needed
   again. */
:root {
  /* Base surfaces (light content area) - iaconnects' own neutral gray */
  --bg: #f2f4f7;
  --panel: #ffffff;
  --panel-alt: #f2f4f7;
  --text: #20202d;
  --text-secondary: #4a4a58;
  /* Was #878787 - measured contrast against --bg/--panel came out at ~3.3:1/
     3.6:1, below WCAG AA's 4.5:1 minimum for normal text, and this token is
     used at 10-12px on nearly every table timestamp/label in the app.
     #6b6b6b clears 4.5:1 on both light backgrounds while reading as
     essentially the same shade. */
  --muted: #6b6b6b;
  --border: #dddddd;
  --border-strong: #c3c4ae;
  --row-hover: rgba(32, 32, 45, 0.035);
  --track-color: #a8a89e;

  /* Sidebar - deliberately dark against the otherwise light app, so
     navigation reads as a distinct, permanent structural element rather
     than just another light panel (see #app-sidebar below). Now iaconnects'
     own navy ink instead of a generic slate. */
  --sidebar-bg: #20202d;
  --sidebar-bg-hover: #323348;
  --sidebar-border: #323348;
  --sidebar-text: #a3a3ad;
  --sidebar-text-active: #ffffff;

  /* Accent - iaconnects' own navy ink, used for every primary button, link,
     active nav state, and focus/selection highlight (this is what their own
     site uses for its CTA buttons, not the logo's lime). Two shades: the
     darker one reads as text/fills on the light content area, the lighter
     one is for the dark sidebar (a flat navy accent would be invisible
     against --sidebar-bg, which is now that same navy). */
  --accent: #20202d;
  --accent-hover: #323348;
  --accent-soft: #f1f7b5;
  --accent-on-dark: #bed730;

  /* Status semantics - iaconnects' own green/red/orange accents, kept
     dark/saturated enough to double as readable text, not just fills.
     Mirrored by hand in STATUS_COLORS/GAUGE_COLORS (public/js/graph.js
     draws these straight into SVG attributes, so it can't read a CSS
     variable) - keep both in sync if these ever change. */
  --status-fresh: #13612e;
  --status-warning: #c25200;
  --status-stale: #b82105;
  --status-dead: #64748b;
  --status-error: #7a1600;
  --status-unknown: #475569;

  /* Soft tints of the above, for badge/banner backgrounds on a light panel
     (the old theme could get away with a translucent rgba() over a dark
     panel for this; that reads as barely-there on white, so these are flat
     colours instead). */
  --status-fresh-soft: #dfeee4;
  --status-warning-soft: #fbe7d4;
  --status-stale-soft: #fae3db;
  --status-dead-soft: #f2f4f7;
  --status-error-soft: #fae3db;
  --status-unknown-soft: #f2f4f7;

  --shadow-sm: 0 1px 3px rgba(32, 32, 45, 0.08);
  --shadow-md: 0 4px 14px rgba(32, 32, 45, 0.10);
  --shadow-lg: 0 12px 32px rgba(32, 32, 45, 0.14);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Inter via Google Fonts CDN (each page's own <head> carries the <link>,
     same convention as the existing per-page stylesheet links - this app
     has no shared templating). Falls back to the previous system-font stack
     if the CDN is unreachable. Kept character-for-character identical to
     AMS Sync Service's own --font-sans (public/css/style.css) - 2026-08-27
     typography pass unified both apps onto that app's more deliberate
     scale, so this fallback stack shouldn't drift from its either. */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

/* This app never had a base button reset - every button (`.header-btn`,
   #login-form button, admin.css's buttons, etc.) was left to the browser's
   UA default form-control font instead of explicitly inheriting Inter, the
   one thing AMS Sync Service's own base `button` rule sets that this app's
   specific button classes below don't each need to repeat. Deliberately
   just `font: inherit` here, not a full copy of AMS's padding/min-height/
   border-radius - this app's existing button classes already have their
   own deliberately-tuned box models for their specific contexts (compact
   table-row actions, toolbar buttons, etc.), and blanket-overriding those
   would be a sizing change, not a typography one. */
button { font: inherit; }

/* Modernized interactive-control feel, applied broadly (every <button> in
   the app, plus the two link-styled button classes) rather than repeated
   per-button-id - three things this app had nowhere before this pass:
   a smoother multi-property transition (previously most buttons only
   transitioned border-color, so a hover felt like a single flat colour
   swap rather than a considered state change), a visible pressed state on
   click, and a visible focus ring for keyboard users (grepping both
   stylesheets before this pass found exactly one custom :focus rule in the
   whole app, on the fleet-tile info icon - everything else relied on the
   bare browser default, which is genuinely hard to see against the dark
   sidebar). Kept deliberately non-invasive: only transition/transform/
   outline are set here, never background/border/radius, so it can never
   fight with any of the many per-button colour rules below or in admin.css -
   those still fully control what a button looks like, this only controls
   how it responds. */
button,
.header-btn,
.panel-toolbar-btn,
a.row-external-btn {
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
button:not(:disabled):active,
.header-btn:not(:disabled):active,
.panel-toolbar-btn:not(:disabled):active {
  transform: translateY(1px);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
/* A flat navy focus ring (var(--accent)) would be nearly invisible against
   the sidebar's own navy background - same reasoning as --accent-on-dark's
   existing role for active-state/logo colour on that one surface. */
#app-sidebar :focus-visible {
  outline-color: var(--accent-on-dark);
}

/* A true global utility, unlike the many scoped `#some-id.hidden` rules
   already scattered through this file (one per element that happens to
   need hiding) - this project never had a single catch-all `.hidden` rule
   before, which meant every newly-hidden element needed its own explicit
   selector added here or it would silently keep rendering despite the
   class being applied. Purely additive - identical `display: none` to
   every scoped rule above, so it can never conflict with one - just
   covers anything that doesn't have (or hasn't yet needed) its own. */
.hidden { display: none; }

/* Aligns numerals in every data table (gateway/uptime/audit-log/webhooks/
   data-quality) and any other tabular numeric text - lining figures share
   one fixed width in a tabular-nums font, so a column of counts/timestamps
   lines up cleanly instead of drifting as digit widths vary (a "1" is
   narrower than an "8" without this). A small, cheap, purely typographic
   modernization with no layout risk - just a font-feature toggle. */
table {
  font-variant-numeric: tabular-nums;
}

body {
  margin: 0;
  /* Explicit 15px/1.5 - previously unset (browser default, ~16px/normal),
     which was the single biggest driver behind this app and AMS Sync
     Service "feeling different" even with identical colours - AMS Sync
     Service's dense-dashboard scale is the shared standard both apps use
     now (2026-08-27). */
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* App-wide left sidebar - persistent across the app's top-level pages
   (public/pipelines.html "Customer Pipelines", public/data-quality.html "Data
   Quality Control", public/users.html "Manage Users"), giving the app room
   to grow into further tools without any one page having to carry multiple
   unrelated purposes (that's what pushed the name-mismatch report out of
   pipelines.html onto its own page - see README). Deliberately NOT present on
   public/customers.html - that's a sub-page reached FROM Customer Pipelines'
   own header link, not a top-level destination in its own right (unlike
   Manage Users, which - despite also being admin-only - gets a sidebar
   entry since it isn't tied to any one other page the way customer admin
   is). Each page just hardcodes its own copy of this markup (this app has
   no shared templating), with `.active` set on whichever link matches that
   page. */
#app-shell {
  display: flex;
  min-height: 100vh;
  /* Breathing room between the dark sidebar and the light content column -
     without this the two surfaces' hard colour contrast reads as if they're
     jammed against each other even though there's technically a 1px border
     between them. The page's own background (var(--bg)) shows through this
     gap, so it reads as intentional whitespace rather than a gap-shaped
     hole. */
  gap: 20px;
  background: var(--bg);
}
#app-sidebar {
  width: 208px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  box-shadow: var(--shadow-md);
  /* Without this, the sidebar is just a flex sibling of #app-content and
     stretches to match ITS height - on a tall page (a long gateway table,
     audit log, or uptime report) that drags the "Signed in as.../Sign out"
     widget (margin-top: auto, below) far down the page instead of keeping
     it where you'd expect: pinned to the viewport, one scroll away at most.
     Pins the sidebar to the viewport instead and lets it scroll on its own
     if the nav links themselves ever grow taller than the screen. */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
#app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--sidebar-border);
}
#app-sidebar-brand svg { flex-shrink: 0; color: var(--accent-on-dark); }
/* Two-line brand block (company name + this app's name underneath, e.g.
   "IAconnects" / "Infrastructure Monitoring") replacing the old single-line
   "Infra Monitoring" text - matches AMS Sync Service's own sidebar brand
   (public/css/style.css there), same nested-column approach. */
.app-sidebar-brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.app-sidebar-brand-name { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; color: var(--sidebar-text-active); }
.app-sidebar-brand-subtitle {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-on-dark);
}
/* Floating rounded "pill" nav item (margin + border-radius) replacing the
   previous full-bleed row with a flat left border for its active/hover
   state - the same shape most contemporary SaaS sidebars (Linear, Vercel,
   Notion) use, and a step up from a hard-edged accent bar. The active
   state's accent indicator moves from border-left (which took up real
   layout space, 3px of every link's box even when transparent) to an
   inset box-shadow instead - purely decorative, adds no width, so it can't
   nudge the icon/label any closer together than the hover state does. */
.app-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.1s ease;
}
.app-nav-link svg { flex-shrink: 0; opacity: 0.85; }
.app-nav-link:hover { color: var(--sidebar-text-active); background: var(--sidebar-bg-hover); }
.app-nav-link:active { transform: scale(0.98); }
.app-nav-link.active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-bg-hover);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-on-dark);
}
.app-nav-link.active svg { opacity: 1; color: var(--accent-on-dark); }
/* Sticks to the bottom of the sidebar (margin-top: auto, inside the
   sidebar's own column flex) regardless of how many nav links are above it
   - a placeholder for now (see README), not yet wired to package.json. */
#app-version {
  padding: 4px 20px 0;
  font-size: 11px;
  color: var(--sidebar-text);
}
#app-content {
  flex: 1;
  min-width: 0;
}

/* "Signed in as X (role)" + Sign out - lives at the bottom of the sidebar,
   just above #app-version (public/js/auth-widget.js populates this once its
   own GET /api/auth/me resolves). margin-top: auto pushes this - and
   #app-version right after it - down to the bottom of the sidebar's column
   flex regardless of how many nav links are above; #app-version has no
   margin-top of its own so it just follows immediately below this rather
   than also fighting for the same auto space. Stacked vertically here since
   the sidebar is only 200px wide - too narrow for the horizontal layout this
   same widget still uses in #admin-main's header (see admin.css), which is
   why the vertical-stack rules below are scoped to #app-sidebar rather than
   changing #user-widget's own base rule. */
#app-sidebar #user-widget {
  margin-top: auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 20px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--sidebar-text);
}
#app-sidebar #user-widget .role-badge {
  border-color: var(--sidebar-border);
  color: var(--sidebar-text);
}
#app-sidebar #sign-out-btn {
  width: 100%;
  padding: 5px 10px;
  font-size: 12px;
  background: transparent;
  color: var(--sidebar-text);
  border-color: var(--sidebar-border);
}
#app-sidebar #sign-out-btn:hover { background: var(--sidebar-bg-hover); border-color: var(--sidebar-border); color: var(--sidebar-text-active); }

#user-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
#user-widget .role-badge {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--muted);
}
#sign-out-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
#sign-out-btn:hover { border-color: var(--border-strong); background: var(--row-hover); }

/* Login page (public/login.html) - deliberately has no #app-shell/sidebar
   of its own, since there's nothing to navigate to yet while signed out. */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
#login-form {
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-md);
}
#login-form h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
}
#login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#login-form input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
}
#login-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.12s ease;
}
#login-form button:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
#login-error {
  color: var(--status-stale);
  font-size: 12.5px;
}
#login-error.hidden { display: none; }

/* "Sign in with Microsoft" - the primary path when SSO is configured (see
   public/js/login.js's initMicrosoftSignIn()), styled as a real button even
   though it's a plain <a> (a full-page navigation to
   /api/auth/microsoft/login, not a fetch() - the whole point is leaving this
   app for Microsoft's own sign-in page). Hidden entirely, along with the
   divider below it, when SSO isn't configured - the password form beneath is
   then the only thing on the page, exactly as it was before SSO existed. */
#microsoft-sign-in-link {
  display: block;
  text-align: center;
  background: var(--text);
  color: #fff;
  border: 1px solid var(--text);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  text-decoration: none;
  transition: background-color 0.12s ease;
}
#microsoft-sign-in-link:hover { background: var(--text-secondary); border-color: var(--text-secondary); }
#login-password-divider {
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--text);
}

#meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

#notifications-wrap { position: relative; }

#notifications-bell {
  position: relative;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
#notifications-bell:hover { border-color: var(--border-strong); background: var(--row-hover); }

#notifications-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--status-stale);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  min-width: 16px;
  text-align: center;
}
#notifications-badge.hidden { display: none; }
/* Shown instead of a normal count when GET /api/faults itself failed (see
   refreshFaults()/renderNotifications() in graph.js) - deliberately a
   different colour and glyph ("!" not a number) from the ordinary badge, so
   "couldn't check for faults" is never visually confused with "checked, and
   there are none". */
#notifications-badge.notifications-badge-error { background: var(--status-error); }

#notifications-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  width: 320px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  text-align: left;
}
#notifications-dropdown.hidden { display: none; }

.notification-item {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--row-hover); }
.notification-text { color: var(--text); }
.notification-detail { color: var(--muted); font-size: 11px; margin-top: 2px; }

.notifications-empty, .notifications-more {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.notifications-error {
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--status-error);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

/* Brief highlight when a gateway fault in the notifications dropdown is
   clicked (see jumpToGatewayFault() in graph.js) - draws the eye to the
   exact row after scrollIntoView, since the table itself has no other way
   to show "this is the one you just clicked". */
@keyframes row-flash-fade {
  from { background: rgba(180, 83, 9, 0.18); }
  to { background: transparent; }
}
.row-flash { animation: row-flash-fade 2s ease-out; }

/* Shared header/toolbar action-button look (Refresh, Refresh customer,
   Clear selection, Webhooks' Refresh, and any future one like them) - a
   single reusable class rather than an ever-growing ID selector list here,
   so a new page's own refresh/action button gets this styling automatically
   just by adding the class, instead of silently rendering as an unstyled
   native <button> (which is what happened to connection-states.html's refresh
   button before this existed). */
.header-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.header-btn:not(:disabled):hover { border-color: var(--border-strong); background: var(--row-hover); }
.header-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#clear-selection-btn.hidden { display: none; }

#breadcrumb-nav {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  /* "Source"/"Organisation" label sizing - matches AMS Sync Service's own
     small-caps label convention (.stat-label: 12px/700/uppercase/0.04em)
     rather than the larger section-h2 pattern below, since these are field
     labels above a dropdown, not page-section headers. Previously 11px with
     no font-weight set (inherited normal/400). */
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#breadcrumb-nav label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

#breadcrumb-nav select,
#breadcrumb-nav input {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
  min-width: 160px;
}

#device-search-wrap { position: relative; }

#device-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: var(--shadow-lg);
}
#device-search-results.hidden { display: none; }
#device-search-results .result-item {
  padding: 8px 10px;
  font-size: 12.5px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
#device-search-results .result-item:last-child { border-bottom: none; }
#device-search-results .result-item:hover { background: var(--row-hover); }
#device-search-results .result-item .muted { color: var(--muted); font-size: 11px; }

#source-banner {
  padding: 10px 24px;
  font-size: 12.5px;
  background: var(--status-error-soft);
  border-bottom: 1px solid var(--status-error);
  color: var(--status-error);
}
#source-banner.hidden { display: none; }
#source-banner .source-line { margin: 2px 0; }

#legend {
  display: flex;
  gap: 18px;
  padding: 10px 24px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
#legend .legend-item { display: flex; align-items: center; gap: 6px; }
#legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
#legend .legend-divider { width: 1px; align-self: stretch; background: var(--border); }
#legend .legend-heading {
  display: flex;
  align-items: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

#map-container {
  padding: 24px;
  overflow: auto;
}

#map { width: 100%; min-width: 700px; height: auto; display: block; }

/* Split into two side-by-side panes (#gateway-pane / #integrations-pane)
   rather than stacking Gateways above Integrations - both are "what's live
   right now for this organisation" summaries meant to be scanned together,
   and stacking them would push Integrations below the fold on anything but
   a tall window. #gateway-section itself stays the single show/hide unit
   driven by org selection (see gatewaySection in graph.js) - only its
   internal layout changes here. */
#gateway-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  padding: 8px 24px 32px;
  border-top: 1px solid var(--border);
}
#gateway-section.hidden { display: none; }
#gateway-section h2 {
  /* Matches AMS Sync Service's unified section h2 pattern (bold, uppercase,
     0.06em tracking) - was plain 14px/var(--text)/no transform before. */
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 12px;
  color: var(--muted);
}
#gateway-pane { min-width: 0; padding-right: 20px; }
#integrations-pane {
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

#gateway-filters:empty { display: none; }
#gateway-filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  align-items: flex-end;
}
#gateway-filters .panel-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
  min-width: 140px;
}
#gateway-filters .panel-filter select,
#gateway-filters .panel-filter input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}

#gateway-table-wrap { overflow-x: auto; }
#gateway-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  /* Fixed layout + explicit per-column widths below, rather than letting
     the browser size columns from content - otherwise a long gateway name
     and the once-inline Last seen date/time (now its own line - see the
     lastSeen template string in graph.js) fight over the same auto-sized
     space and wrap unpredictably. Name gets the extra room freed up by
     narrowing Last seen. */
  table-layout: fixed;
}
#gateway-table.hidden { display: none; }
/* Column order: select, Name, System, Status, Maintenance, Last seen -
   see the <thead> in public/pipelines.html. */
#gateway-table th:nth-child(2) { width: 30%; }
#gateway-table th:nth-child(3) { width: 70px; }
#gateway-table th:nth-child(4) { width: 130px; }
#gateway-table th:nth-child(5) { width: 200px; }
#gateway-table th:nth-child(6) { width: 100px; }
#gateway-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
#gateway-table th:hover { color: var(--text); }
/* Sort direction indicator - only one header carries either class at a
   time (see updateGatewaySortHeaderUI() in graph.js), a plain unicode arrow
   rather than an image/icon font so it needs no extra asset. */
#gateway-table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
#gateway-table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }
#gateway-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#gateway-table tbody tr:last-child td { border-bottom: none; }
#gateway-table tbody tr:hover { background: var(--row-hover); }
#gateway-table .muted { color: var(--muted); font-size: 11px; }

.gateway-group-row td {
  padding: 10px 12px 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: none;
  background: none;
}
.gateway-group-row:hover { background: none; }

/* Checkbox column shared by the gateway table and (task #233) the device
   panel list - narrow and non-sortable, so it's excluded from the
   pointer/hover-color treatment the rest of #gateway-table th gets. */
.select-col { width: 32px; cursor: default !important; }
.select-col:hover { color: var(--muted) !important; }
.gateway-group-row .select-col { padding: 10px 12px 4px; }

/* Inline "under maintenance" indicator next to a gateway/device name - a
   plain emoji (no extra asset) with a tooltip carrying the note, distinct
   from .station-node-maintenance-badge which sits on the SVG map itself. */
.maintenance-badge { font-size: 12px; cursor: help; }

/* Multi-select toolbar above the gateway table (renderGatewayToolbar() in
   graph.js) - reuses .panel-toolbar-btn/-count/-status from the device
   panel toolbar so both look and behave the same way. */
#gateway-toolbar.hidden { display: none; }
#gateway-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  flex-wrap: wrap;
}

/* Trigger Maintenance popup (renderGatewayToolbar()'s Trigger Maintenance
   button opens this instead of a bare window.prompt()) - same fixed
   overlay + centered panel convention as #webhook-key-modal in admin.css,
   just its own selectors since this is graph.js/pipelines.html's own feature
   rather than the customers admin page's. */
#gateway-maintenance-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  /* Soft blur behind the modal, rather than a flat colour wash - reads as a
     genuine layer of depth above the app instead of a plain dark rectangle.
     -webkit- prefix for Safari, which still needs it for backdrop-filter. */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#gateway-maintenance-modal.hidden { display: none; }
#gateway-maintenance-modal-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  width: 420px;
  max-width: calc(100vw - 32px);
}
#gateway-maintenance-modal-panel h3 { margin: 0 0 8px; font-size: 15px; }
.gwm-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}
.gwm-field input,
.gwm-field textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
}
.gwm-field textarea { resize: vertical; }
/* Collapsed (rather than removed) when UFN is ticked, so unchecking it
   again doesn't lose whatever end date/time the user had already entered -
   see the ufn checkbox's change handler in graph.js. */
#gwm-end-field.hidden { display: none; }
.gwm-checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 12.5px;
  color: var(--text);
}
.gwm-checkbox-field input { flex-shrink: 0; }
#gwm-status { font-size: 11.5px; color: var(--status-fresh); min-height: 14px; margin-bottom: 8px; }
#gwm-status.error { color: var(--status-dead); }
#gateway-maintenance-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
#gwm-cancel-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  cursor: pointer;
}
#gwm-cancel-btn:hover { border-color: var(--border-strong); background: var(--row-hover); }
#gwm-start-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12.5px;
  cursor: pointer;
}
#gwm-start-btn:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }

.system-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.6;
}

#gateway-empty {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 12.5px;
}
#gateway-empty.hidden { display: none; }

/* Integrations pane (public/pipelines.html, driven by graph.js's
   refreshIntegrations()/renderIntegrationsTable()) - mirrors #gateway-filters/
   #gateway-table/#gateway-empty above almost rule-for-rule rather than
   sharing selectors, same convention this stylesheet already uses for each
   independent section (see the Data Quality Control comment below). No
   toolbar/select-column equivalent - integrations are read-only here (managed
   from /customers.html instead), so there's nothing to bulk-act on. Status
   cells reuse .webhook-status-cell/-ok/-error (below, shared with the
   standalone Webhooks page) rather than inventing a second colour pairing
   for the same two-value status. */
#integrations-filters:empty { display: none; }
#integrations-filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  align-items: flex-end;
}
#integrations-filters .panel-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
  min-width: 140px;
}
#integrations-filters .panel-filter select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}

#integrations-table-wrap { overflow-x: auto; }
#integrations-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#integrations-table.hidden { display: none; }
#integrations-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
#integrations-table th:hover { color: var(--text); }
#integrations-table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
#integrations-table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }
#integrations-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#integrations-table tbody tr:last-child td { border-bottom: none; }
#integrations-table tbody tr:hover { background: var(--row-hover); }
#integrations-table .muted { color: var(--muted); font-size: 11px; }

#integrations-empty {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 12.5px;
}
#integrations-empty.hidden { display: none; }

/* Data Quality Control page (public/data-quality.html) - mirrors
   #gateway-section/table styling above rather than sharing selectors, same
   convention this stylesheet already uses for each independent section.
   Used to sit below the map/gateways on pipelines.html; now the sole content of
   its own page (reached via #app-sidebar), so `.hidden` is never actually
   applied there - kept only in case something needs it in future. */
#data-quality-section {
  padding: 8px 24px 32px;
  border-top: 1px solid var(--border);
}
#data-quality-section.hidden { display: none; }
#data-quality-section h2 {
  /* Matches AMS Sync Service's unified section h2 pattern (bold, uppercase,
     0.06em tracking) - was plain 14px/var(--text)/no transform before. */
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 4px;
  color: var(--muted);
}
.section-subtitle {
  /* 13.5px to match AMS Sync Service's .subtitle (was 12px). */
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 12px;
}

/* Rendered CHANGELOG.md (public/js/changelog.js's small hand-written
   markdown-to-HTML converter) - a simple, readable long-form document
   inside the main content pane, not a data table/panel like most of this
   app's other sections. */
#changelog-content {
  max-width: 720px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
}
#changelog-content h2 {
  font-size: 20px;
  margin: 0 0 12px;
}
#changelog-content h3 {
  font-size: 16px;
  margin: 28px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
#changelog-content h3:first-of-type { padding-top: 0; border-top: none; }
#changelog-content h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 14px 0 6px;
}
#changelog-content p { margin: 0 0 10px; }
#changelog-content ul {
  margin: 0 0 10px;
  padding-left: 20px;
}
#changelog-content li { margin-bottom: 6px; }
#changelog-content code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
#changelog-content a { color: var(--accent); }
#changelog-content a:hover { color: var(--accent-hover); }
#data-quality-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
}
#data-quality-controls .panel-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 200px;
}
#data-quality-controls .panel-filter select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}
#data-quality-download-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
#data-quality-download-btn:hover { border-color: var(--border-strong); background: var(--row-hover); }
#data-quality-table-wrap { overflow-x: auto; }
#data-quality-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#data-quality-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
#data-quality-table th:hover { color: var(--text); }
#data-quality-table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
#data-quality-table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }
#data-quality-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#data-quality-table tbody tr:last-child td { border-bottom: none; }
#data-quality-table tbody tr:hover { background: var(--row-hover); }
/* Per-system present/absent breakdown in the Systems column - see
   public/js/data-quality.js's systemsBreakdownHtml(). */
.dq-system-status { display: inline-block; width: 14px; font-weight: 700; }
.dq-system-present { color: var(--status-ok, #13612e); }
.dq-system-absent { color: var(--status-error); }
#audit-log-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
}
#audit-log-controls .panel-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 200px;
}
#audit-log-controls .panel-filter select,
#audit-log-controls .panel-filter input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}
#audit-log-table-wrap { overflow-x: auto; }
#audit-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#audit-log-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
#audit-log-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#audit-log-table tbody tr:last-child td { border-bottom: none; }
#audit-log-table tbody tr:hover { background: var(--row-hover); }
#audit-log-table .muted { color: var(--muted); font-size: 11px; }
#audit-log-table.hidden { display: none; }
#audit-log-empty {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 12.5px;
}
#audit-log-load-more-btn {
  margin-top: 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
#audit-log-load-more-btn:hover { border-color: var(--border-strong); background: var(--row-hover); }
#audit-log-load-more-btn.hidden { display: none; }
#data-quality-empty {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 12.5px;
}

#uptime-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
}
#uptime-controls .panel-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 180px;
}
#uptime-controls .panel-filter select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}
#uptime-table-wrap { overflow-x: auto; }
#uptime-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#uptime-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
#uptime-table th:hover { color: var(--text); }
#uptime-table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
#uptime-table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }
#uptime-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#uptime-table tbody tr:last-child td { border-bottom: none; }
#uptime-table tbody tr:hover { background: var(--row-hover); }
#uptime-table .muted { color: var(--muted); font-size: 11px; }
#uptime-table.hidden { display: none; }
.uptime-cell { font-weight: 600; }
.uptime-cell.uptime-good { color: var(--status-fresh); }
.uptime-cell.uptime-warn { color: var(--status-warning); }
.uptime-cell.uptime-bad { color: var(--status-stale); }
.uptime-cell.uptime-none { color: var(--muted); font-weight: 400; }
/* Marks a source with at least one FAILED poll attempt in the report range
   (src/db.js's poll_log, via computeUptimeForSource()'s lastError) - distinct
   from the uptime % itself, which alone can't tell "reachable but few/no
   devices" apart from "actually can't reach the API". Cursor+title (not a
   click target) since the detail is a plain native tooltip, not a panel. */
.uptime-error-flag { cursor: help; font-size: 12px; }

/* Connection States page (public/connection-states.html) - same table/filter shell as the
   Uptime page above, just under its own #webhooks-* ids so neither page's
   CSS accidentally leaks into the other if one changes later. */
#webhooks-controls {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
#webhooks-controls .panel-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 180px;
}
#webhooks-controls .panel-filter select,
#webhooks-controls .panel-filter input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}
#webhooks-table-wrap { overflow-x: auto; }
#webhooks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#webhooks-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
#webhooks-table th[data-sort] { cursor: pointer; user-select: none; }
#webhooks-table th[data-sort]:hover { color: var(--text); }
#webhooks-table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
#webhooks-table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }
#webhooks-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#webhooks-table tbody tr:last-child td { border-bottom: none; }
#webhooks-table tbody tr:hover { background: var(--row-hover); }
#webhooks-table .muted { color: var(--muted); font-size: 11px; }
#webhooks-table.hidden { display: none; }
.webhook-status-cell { font-weight: 600; }
.webhook-status-cell.webhook-status-ok { color: var(--status-fresh); }
.webhook-status-cell.webhook-status-error { color: var(--status-error); }

/* Type column badge (Connection States page + graph.js's per-org Connections
   pane) - distinguishes an HTTP integration row from an MQTT connection row
   now that both share one unified table. Same neutral pill shape regardless
   of type; only the two type labels differ, so one shared class plus a
   modifier rather than two entirely separate rule sets. */
.connection-type-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel-alt);
}
.connection-type-badge.connection-type-http { color: var(--accent); border-color: var(--accent); }
.connection-type-badge.connection-type-mqtt { color: var(--status-fresh); border-color: var(--status-fresh); }
#uptime-empty {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 12.5px;
}

#fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.fleet-tile {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--status-unknown);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.fleet-tile:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.fleet-tile-fresh { border-left-color: var(--status-fresh); }
.fleet-tile-warning { border-left-color: var(--status-warning); }
.fleet-tile-stale { border-left-color: var(--status-stale); }
.fleet-tile-dead { border-left-color: var(--status-dead); }
.fleet-tile-error { border-left-color: var(--status-error); }
.fleet-tile-unknown { border-left-color: var(--status-unknown); }
.fleet-tile-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.fleet-tile-name { font-size: 14px; font-weight: 600; }
.fleet-tile-status-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fleet-tile-count { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.fleet-tile-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.fleet-tile-chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
.fleet-tile-chip-fresh { color: var(--status-fresh); }
.fleet-tile-chip-warning { color: var(--status-warning); }
.fleet-tile-chip-stale { color: var(--status-stale); }
.fleet-tile-chip-dead { color: var(--status-dead); }
.fleet-tile-chip-error { color: var(--status-error); }
.fleet-tile-chip-unknown { color: var(--muted); }
.fleet-tile-faults { font-size: 12px; color: var(--status-warning); font-weight: 600; }
.fleet-tile-faults-none { color: var(--muted); font-weight: 400; }

/* Info-icon tooltips explaining how a fleet tile's metrics are calculated -
   pure CSS (no JS), since the tile itself is a single <a> covering the whole
   card; a click on the icon has to be swallowed in JS (see fleet.js) so it
   doesn't also navigate to that customer's map. Reuses :hover AND :focus so
   it's reachable via keyboard (tabindex="0" on the icon) as well as mouse. */
.fleet-metric-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 10px;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  text-transform: none; /* .fleet-tile-status-label is uppercase - don't let that turn the icon's "i" into "I" */
}
.fleet-metric-info:hover,
.fleet-metric-info:focus {
  border-color: var(--accent, var(--text));
  color: var(--accent, var(--text));
  outline: none;
}
.fleet-metric-info-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 8px 10px;
  font-size: 11px;
  font-style: normal;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.45;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 20;
}
.fleet-metric-info:hover .fleet-metric-info-tip,
.fleet-metric-info:focus .fleet-metric-info-tip {
  opacity: 1;
}
#fleet-empty {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 12.5px;
}
#data-quality-empty.hidden { display: none; }

.station-label {
  fill: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
}

/* Optional per-customer alias (Mobiusflow's "Alias" field today - see
   src/systemTypes.js/stationAliases in graph.js's render()) - sits directly
   above the station name, smaller and muted so the real station name still
   reads as the primary label. */
.station-alias-label {
  fill: var(--muted);
  font-size: 10px;
  font-style: italic;
  text-anchor: middle;
}

.station-timestamp-label {
  fill: var(--muted);
  font-size: 9.5px;
  text-anchor: middle;
  pointer-events: none;
}

.track {
  fill: none;
  stroke: var(--track-color);
  cursor: default;
}
.track.highlighted {
  stroke: var(--accent);
}
/* Same-column "link" edges (Datacake<->Mobiusflow etc - see isLink in
   pipelineEngine.js/computeColumns() above) - dashed rather than solid so
   this reads as "these two are connected" (a tube-map interchange) rather
   than the directional "feeds into" a normal solid track implies. */
.track.track-link {
  stroke-dasharray: 4 5;
}

.station-node-group { cursor: pointer; }
.station-node-group.dimmed { opacity: 0.25; }

/* Polling paused (task #396) - grey out and fade the whole station's pie/
   ring so a paused system reads as visually "switched off" at a glance,
   rather than relying solely on the small ⏸ badge (public/js/graph.js) next
   to it, which testing showed wasn't obvious enough on its own. Stacks with
   .dimmed above (a paused station can be simultaneously faded by an active
   device highlight) since both are just opacity/filter, not mutually
   exclusive states. */
.station-node-group.polling-paused {
  opacity: 0.4;
  filter: grayscale(1);
}
.station-node-wedge {
  stroke: var(--bg);
  stroke-width: 1.5;
  transition: stroke-width 0.15s;
}
.station-node-group:hover .station-node-wedge { stroke-width: 3; }
.station-node-hit { fill: transparent; }

/* Battery/service-status ring segments - visible arcs stay pointer-events:
   none (each has its own invisible, wider .station-node-ring-segment-hit
   sibling on top - see graph.js's render() - which is what actually reacts
   to the mouse). stroke-width transitions here so the JS-toggled
   .ring-segment-hover class (added/removed by that sibling's mouseenter/
   mouseleave) reads as the hovered segment visibly "popping" outward from
   the rest of the ring, rather than an instant snap. */
.station-node-battery-ring,
.station-node-service-ring,
.station-node-connect-ring {
  pointer-events: none;
}
.station-node-ring-segment {
  transition: stroke-width 0.12s ease;
}
.station-node-ring-segment.ring-segment-hover {
  stroke-width: 11;
}
.station-node-ring-segment-hit {
  cursor: pointer;
}
.station-node-maintenance-badge {
  font-size: 15px;
  cursor: default;
  user-select: none;
}

.station-node-polling-paused-badge {
  font-size: 15px;
  cursor: default;
  user-select: none;
  fill: var(--muted);
}

/* Illustrative (no-adapter) custom stations - see graph.js's buildGraph()
   `node.illustrative` branch. Deliberately plain and unclickable: dashed
   outline + neutral fill instead of a colour that would otherwise read as a
   real status, and the default cursor rather than the pointer every real
   station gets, since there's nothing to click through to. */
.station-node-illustrative { cursor: default; }
.station-node-illustrative-circle {
  fill: var(--bg);
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.tooltip {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  pointer-events: none;
  max-width: 300px;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}
.tooltip.hidden { display: none; }
.tooltip b { color: var(--text); }
.tooltip .muted { color: var(--muted); }

#device-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 460px;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(32, 32, 45, 0.18);
  z-index: 30;
  display: flex;
  flex-direction: column;
}
#device-panel.hidden { display: none; }

#device-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#device-panel-header .close-btn {
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  background: none;
  border: none;
}
#device-panel-header .close-btn:hover { color: var(--text); }

#device-panel-maintenance-banner {
  padding: 8px 20px;
  font-size: 12.5px;
  color: var(--status-warning);
  background: var(--status-warning-soft);
  border-bottom: 1px solid var(--border);
}
#device-panel-maintenance-banner.hidden { display: none; }

#device-panel-filters:empty { display: none; }
#device-panel-filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
#device-panel-filters .panel-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
  min-width: 120px;
}
#device-panel-filters .panel-filter select,
#device-panel-filters .panel-filter input,
#device-panel-filters .panel-filter .panel-multiselect-toggle {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}

/* Multi-select filter (Status/Battery/Application/Service/Enabled - see
   createMultiSelectFilter() in graph.js): a button summarising the current
   selection that toggles a checkbox-list popover below it, so several
   values can be selected at once and a single Copy/Export combines them
   into one result instead of needing a separate export per value. */
#device-panel-filters .panel-multiselect { position: relative; }
#device-panel-filters .panel-multiselect-toggle {
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#device-panel-filters .panel-multiselect-toggle::after {
  content: '\25BE';
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
}
#device-panel-filters .panel-multiselect-toggle:hover { border-color: var(--border-strong); }
#device-panel-filters .panel-multiselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  min-width: 100%;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 6px;
}
#device-panel-filters .panel-multiselect-menu.hidden { display: none; }
#device-panel-filters .panel-multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  /* WCAG 2.2 Target Size (Minimum): 24px - the row's own min-height covers
     this regardless of the 13px label font. */
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
#device-panel-filters .panel-multiselect-option:hover { background: var(--row-hover); }

#device-panel-toolbar:empty { display: none; }
#device-panel-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-toolbar-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.panel-toolbar-btn:hover { border-color: var(--border-strong); background: var(--row-hover); }
.panel-toolbar-count { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.panel-toolbar-status { font-size: 11.5px; color: var(--status-fresh); width: 100%; }

#device-panel-body {
  padding: 12px 20px;
  overflow-y: auto;
  font-size: 12.5px;
}

.device-panel-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.device-panel-row:last-child { border-bottom: none; }
.device-panel-row .row-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.device-panel-row .row-title span { flex: 1; }
.device-panel-row .row-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.row-select { display: flex; align-items: center; flex-shrink: 0; cursor: pointer; }

/* Sub-row of Trigger/End-Maintenance controls, appended into
   #device-panel-toolbar (see renderDevicePanelMaintenanceToolbar() in
   graph.js) - only occupies space once something's actually selected,
   otherwise collapses to nothing rather than leaving an empty gap. */
#device-panel-maintenance-toolbar:empty { display: none; }
#device-panel-maintenance-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}
.row-view-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 400;
  cursor: pointer;
  flex-shrink: 0;
}
.row-view-btn:hover { border-color: var(--border-strong); background: var(--row-hover); }
/* "ChirpStack/Datacake ↗" - deliberately its own class, NOT also
   .row-view-btn (see graph.js's comment on the click-handler bug that
   caused) - so the base button look is repeated here rather than shared,
   just visually distinguished as a link OUT of this app rather than a
   drill-in within it. */
.row-external-btn {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 400;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--accent);
}
.row-external-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.row-external-btn:disabled { opacity: 0.6; cursor: default; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.signal-meta { font-size: 11px; margin-top: 6px; }
.signal-errors { color: var(--status-error); font-size: 11px; margin-top: 4px; }

.device-panel-section { padding: 12px 0 4px; border-top: 1px solid var(--border); margin-top: 8px; }
.device-panel-section-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; }

.signal-gauges-row { display: flex; flex-wrap: wrap; gap: 10px 6px; justify-content: space-between; }
.signal-gauges-loading { color: var(--muted); font-size: 12px; padding: 4px 0; }

/* "Device properties" section (graph.js's showDevicePanel/fetchDeviceProperties)
   - a generic key/value dump of whatever a non-ChirpStack source's raw
   reading contained (DeviceHQ's hardware attributes today), shown where
   Signal quality would otherwise sit for a station that has no LoRaWAN-style
   link metrics at all. Two-column label/value grid rather than a plain list
   so a longer property set stays scannable rather than turning into a wall
   of single-column text. */
.device-properties-grid { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 5px; font-size: 12px; }
.device-property-label { color: var(--muted); white-space: nowrap; }
.device-property-value { word-break: break-word; }
.device-property-value.device-property-enabled-true { color: var(--status-ok, #13612e); font-weight: 600; }
.device-property-value.device-property-enabled-false { color: var(--status-error, #b82105); font-weight: 600; }
/* Nested object/array attribute values (e.g. DeviceHQ's network/location
   blocks) render as an indented bullet list rather than a flat JSON blob -
   see renderPropertyValueHtml() in graph.js. Each level of nesting gets its
   own indent via the browser's normal list nesting, so a sub-object inside
   an array item is still visibly a level deeper. */
.device-property-value ul.device-property-sublist { margin: 4px 0 0 0; padding-left: 18px; list-style: disc; }
.device-property-value ul.device-property-sublist li { margin: 2px 0; }
.device-property-sublabel { color: var(--muted); }

.signal-gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 58px; }
.gauge-ring { position: relative; width: 52px; height: 52px; }
.gauge-ring svg { width: 100%; height: 100%; }
.gauge-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.15;
  white-space: pre-line;
  padding: 0 2px;
}
.gauge-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; text-align: center; }

.station-list-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
}
.station-list-item:last-child { border-bottom: none; }
/* ChirpStack-only device profile line (see graph.js's showDevicePanel) -
   flex-basis: 100% forces it onto its own wrapped row below the existing
   name/battery/age spans above, rather than squeezing into the same line
   with them (see flex-wrap: wrap above). */
.station-list-item-profile { flex-basis: 100%; color: var(--muted); font-size: 11px; margin-top: 2px; }
