/* ATCC Power & Equipment Dashboard — style */
:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-on-dark: #f1f5f9;
  --accent: #305496;
  --accent-soft: #8ea9db;
  --main-ups: #2563eb;
  --secondary-ups: #7c3aed;
  --pdu1: #059669;
  --pdu2: #0891b2;
  --ground: #d97706;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);
  --radius: 10px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: #f1f5f9;
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* ── Sticky chrome wrapper (Dashboard rack page) ──────────────────────
   Header + stats + controls all live inside .sticky-chrome so they
   pin together at the top while rack cards scroll underneath. */
.sticky-chrome {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg-card);
  box-shadow: 0 1px 6px rgba(15,23,42,0.10);
}

/* ── App header (Dashboard rack page — compact mobile-first topbar) ─────
   Topology.html still uses the old .brand / .nav-links structure inside
   .app-header — those rules live further down. The selectors below
   target the *new* index.html topbar via child selectors so they don't
   clash. */
.app-header {
  background: linear-gradient(135deg, var(--bg) 0%, var(--accent) 100%);
  color: var(--text-on-dark);
  padding: 10px 14px calc(10px + env(safe-area-inset-top, 0)) 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.app-header .hdr-back,
.app-header .hdr-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--accent-soft);
  background: rgba(255,255,255,0.06);
  transition: background 0.15s, color 0.15s, transform 0.15s;
  cursor: pointer;
}
.app-header .hdr-back svg,
.app-header .hdr-icon svg { width: 20px; height: 20px; }
.app-header .hdr-back:hover, .app-header .hdr-icon:hover,
.app-header .hdr-back:focus-visible, .app-header .hdr-icon:focus-visible {
  background: rgba(255,255,255,0.16);
  color: #fff; outline: none;
}
.app-header .hdr-back:active, .app-header .hdr-icon:active { transform: scale(0.92); }
.app-header .hdr-title { flex: 1; min-width: 0; }
.app-header .hdr-title h1 {
  margin: 0; color: var(--text-on-dark);
  font: 700 16px/1.15 var(--font-sans);
  letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-header .hdr-title .hdr-sub {
  margin: 1px 0 0;
  font-size: 10.5px; line-height: 1.2;
  color: var(--accent-soft);
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-header .hdr-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
/* Gear: subtle continuous rotation; faster on hover (matches home.html) */
.app-header .hdr-gear svg {
  animation: hdr-gear-idle 14s linear infinite;
  transform-origin: 50% 50%;
}
.app-header .hdr-gear:hover svg, .app-header .hdr-gear:focus-visible svg {
  animation: hdr-gear-spin 1.4s linear infinite;
}
@keyframes hdr-gear-idle { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes hdr-gear-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
/* Logout: ambient breathing color → red on hover, with shake (matches home.html) */
.app-header .hdr-logout { position: relative; animation: hdr-logout-breathe 4s ease-in-out infinite; border: 0; cursor: pointer; }
.app-header .hdr-logout svg { transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); transform-origin: 50% 55%; }
.app-header .hdr-logout::before {
  content: ''; position: absolute; inset: 4px;
  border-radius: 8px;
  background: radial-gradient(closest-side, rgba(239,68,68,0.32), transparent 75%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.app-header .hdr-logout:hover, .app-header .hdr-logout:focus-visible {
  background: rgba(239,68,68,0.22); color: #fecaca; animation: none;
}
.app-header .hdr-logout:hover::before, .app-header .hdr-logout:focus-visible::before { opacity: 1; }
.app-header .hdr-logout:hover svg, .app-header .hdr-logout:focus-visible svg {
  animation: hdr-logout-shake 0.6s ease-in-out;
}
@keyframes hdr-logout-breathe {
  0%, 100% { color: var(--accent-soft); }
  50%      { color: rgba(252,165,165,0.85); }
}
@keyframes hdr-logout-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20%      { transform: translateX(2px) rotate(6deg); }
  40%      { transform: translateX(-2px) rotate(-4deg); }
  60%      { transform: translateX(1px) rotate(3deg); }
  80%      { transform: translateX(-1px) rotate(-2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .app-header .hdr-gear svg, .app-header .hdr-gear:hover svg,
  .app-header .hdr-logout, .app-header .hdr-logout:hover svg { animation: none; }
}

/* Legacy header content (topology.html still uses) */
.brand { display: flex; align-items: center; gap: 0; }
.brand-text { display: flex; flex-direction: column; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.brand .subtitle { margin: 4px 0 0; color: var(--accent-soft); font-size: 13px; }
.brand-logo { flex-shrink: 0; }

/* Stats strip — full-width row directly under topbar */
.stats {
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(48,84,150,0.08), transparent);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stats::-webkit-scrollbar { display: none; }
.stat-box {
  flex: 1 0 auto;
  background: #fff;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 78px;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}
.stat-box .num {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.05;
  color: var(--accent);
  display: block;
}
.stat-box .lbl {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 2px;
}
#stat-search .num { color: #d97706; }

/* Controls — search + filters + view-toggle.
   Mobile-first: rows stack vertically. Block layout (NOT flex) so child
   widths don't get re-distributed by parent flex wrap from old @media
   rules. Sticky behavior comes from parent .sticky-chrome. */
.controls {
  background: #fff;
  padding: 7px 12px 5px;
  border-bottom: 1px solid var(--border);
  display: block;
}
.controls > * + * { margin-top: 5px; }
.search-wrap { display: block; width: 100%; }
#search {
  width: 100%;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;        /* tighter than tổng thể (was 14px) */
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  background: #f8fafc;
}
#search::placeholder {
  color: #94a3b8;
  font-weight: 500;
}
#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(48, 84, 150, 0.15);
  background: #fff;
}
/* Filter row: groups stack vertically with their data-label as prefix */
.filter-row {
  display: flex; flex-direction: column; gap: 3px;
}
/* Filter group: label PINNED at left while chips scroll horizontally
   underneath. Achieved with position:sticky on the ::before pseudo. */
.filter-group {
  display: flex;
  gap: 4px;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 1px 8px 1px 0;
  position: relative;
}
.filter-group::-webkit-scrollbar {
  display: none;
  width: 0; height: 0;
}
.filter-group::before {
  content: attr(data-label) ':';
  position: sticky; left: 0; z-index: 2;
  flex-shrink: 0;
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-right: 6px;
  /* White-to-transparent fade so chips behind appear smoothly */
  background: linear-gradient(90deg, #fff 70%, rgba(255,255,255,0));
  min-width: 64px;
}
.filter-btn {
  padding: 3px 9px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(48,84,150,0.30);
}

/* View toggle — single icon button, flips state expanded ↔ collapsed.
   Animates the chevron rotation + label text per current state. */
.view-toggle {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
.view-toggle .toggle-collapse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.view-toggle .toggle-collapse:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.view-toggle .toggle-collapse:active { transform: scale(0.96); }
.view-toggle .toggle-icon {
  display: inline-grid; place-items: center;
  width: 16px; height: 16px;
}
.view-toggle .toggle-icon svg { width: 14px; height: 14px; transition: transform 0.32s cubic-bezier(0.4, 1.4, 0.6, 1); }
/* expanded = chevron pointing UP (▲) — clicking collapses content */
.view-toggle .toggle-collapse[data-state="expanded"] .toggle-icon svg { transform: rotate(0deg); }
.view-toggle .toggle-collapse[data-state="expanded"] .toggle-label::after { content: ''; }
/* collapsed = chevron pointing DOWN (▼) — clicking expands content */
.view-toggle .toggle-collapse[data-state="collapsed"] .toggle-icon svg { transform: rotate(180deg); }
/* Just-clicked feedback: brief bounce */
.view-toggle .toggle-collapse.flash {
  animation: toggle-flash 0.36s ease-out;
}
@keyframes toggle-flash {
  0%   { background: #fff; }
  35%  { background: rgba(48,84,150,0.10); transform: scale(1.04); }
  100% { background: #fff; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .view-toggle .toggle-icon svg, .view-toggle .toggle-collapse.flash { animation: none; transition: none; }
}

.rack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
  padding: 20px 28px 60px;
}

.rack-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.rack-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.1), 0 10px 20px rgba(15, 23, 42, 0.08);
}
.rack-card.hidden { display: none; }

.card-head {
  background: linear-gradient(90deg, var(--accent) 0%, #4472c4 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.rack-title { flex: 1; min-width: 0; }
.rack-id {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  display: block;
}
.rack-desc {
  font-size: 12px;
  opacity: 0.85;
  display: block;
  margin-top: 2px;
}
.rack-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  flex-shrink: 0;
}
.badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgba(255,255,255,0.2);
}
.floor-badge { background: rgba(255,255,255,0.25); }
.system-badge { background: rgba(255,255,255,0.2); }
.eq-count-badge { background: #fbbf24; color: #78350f; }
.eq-count-badge.empty { background: rgba(255,255,255,0.15); color: white; }
/* Re-cabling badge (S1.9g) — orange accent matches export color scheme */
.recabling-badge {
  background: #fed7aa;
  color: #9a3412;
  border: 1px solid #fb923c;
  cursor: help;
}

.rack-section {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
/* Unified section header — same level for Nguồn cấp / Cáp mạng / Thiết bị */
.section-head {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.section-head:hover { color: var(--accent); }
.section-head .sh-title { flex: 1; }
.section-head .sh-arrow {
  font-size: 12px;
  transition: transform 0.2s;
  color: var(--text-muted);
}
.rack-section.collapsed .sh-arrow { transform: rotate(-90deg); }
.rack-section.collapsed .section-body { display: none; }
.section-body { margin-top: 8px; }
.derived-note {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0;
  text-transform: none;
  font-style: italic;
}
.cable-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.cable-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}
.cable-badge .ico { font-size: 13px; }
.cable-badge.copper { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.cable-badge.fiber  { background: #fce7f3; color: #9f1239; border-color: #fbcfe8; }
.cable-badge.switch { background: #ecfccb; color: #3f6212; border-color: #d9f99d; }
.cable-badge.kvm    { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.cable-badge.serial { background: #f3e8ff; color: #581c87; border-color: #e9d5ff; }
.cable-badge.ntp    { background: #cffafe; color: #155e75; border-color: #a5f3fc; }
.cable-badge.ws     { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.cable-badge.server { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.cable-badge.empty  { background: #f8fafc; color: var(--text-muted); font-style: italic; font-weight: 400; }
.cable-hints {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 11px;
}
.cable-hints li {
  padding: 3px 0 3px 18px;
  position: relative;
  color: var(--text);
  line-height: 1.45;
}
.cable-hints li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* ═══ Neptuno Voice Recording section (RSOPS06 only) ═══ */
.neptuno-section {
  background: linear-gradient(180deg, #fdf4ff 0%, #faf5ff 100%);
}
.neptuno-section .section-head { color: #86198f; }
.neptuno-section .derived-note {
  background: #fae8ff;
  color: #86198f;
  font-style: italic;
  font-weight: 600;
}
.neptuno-section .nep-role {
  font-size: 11px;
  color: var(--text);
  background: white;
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 3px solid #a855f7;
  margin-bottom: 8px;
}
.neptuno-section .nep-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.neptuno-section .nep-stat {
  background: #a855f7;
  color: white;
  padding: 6px 8px;
  border-radius: 5px;
  text-align: center;
}
.neptuno-section .nep-num {
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-mono);
}
.neptuno-section .nep-lbl {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.9;
}
.neptuno-section .nep-block h4 {
  font-size: 10px;
  font-weight: 700;
  color: #86198f;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 10px 0 4px;
}
.neptuno-section .nep-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 11px;
  line-height: 1.5;
}
.neptuno-section .nep-list li {
  padding: 3px 0 3px 18px;
  position: relative;
}
.neptuno-section .nep-list li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: #a855f7;
  font-weight: 700;
}
.neptuno-section .nep-components {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px;
}
.neptuno-section .nep-comp {
  background: white;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  border: 1px solid #f3e8ff;
}
.neptuno-section .nep-comp code {
  background: #a855f7;
  color: white;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 700;
  margin-right: 6px;
}
.neptuno-section .nep-sources {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 9.5px;
  color: var(--text-muted);
}
.neptuno-section .nep-sources li {
  padding: 2px 0 2px 12px;
  position: relative;
  line-height: 1.4;
}
.neptuno-section .nep-sources li::before {
  content: "📄";
  position: absolute;
  left: 0;
  font-size: 8px;
}
.neptuno-section .nep-sources code {
  background: transparent;
  color: var(--text-muted);
  font-size: 9.5px;
  padding: 0;
  word-break: break-all;
}

/* RSOPS06 special header color — purple gradient for NEPTUNO system */
.rack-card[data-system="NEPTUNO"] .card-head {
  background: linear-gradient(90deg, #86198f, #a855f7) !important;
}

/* BCK partition (v1.11.0) — backup ATM system at Existing AACC HCM Building */
.rack-card[data-system="BCK"] .card-head {
  background: linear-gradient(90deg, #6d28d9, #8b5cf6) !important;
}

/* ═══ Positions section (operator/controller sub-positions) ═══ */
.positions-section .pos-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
}
.positions-section .pos-stat {
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 4px;
  color: var(--text);
}
.positions-section .pos-stat b { color: var(--accent); }
.positions-section .pos-stat.pos-note { background: transparent; font-style: italic; color: var(--text-muted); }
.positions-section .pos-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 6px;
}
.positions-section .pos-card {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-left: 3px solid var(--accent);
  padding: 6px 8px;
  border-radius: 5px;
  cursor: help;
  font-size: 10.5px;
}
.positions-section .pos-code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  color: #1e40af;
}
.positions-section .pos-role {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-style: italic;
}
.positions-section .pos-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 9.5px;
}
.positions-section .pos-meta code {
  background: white;
  padding: 0 4px;
  border-radius: 2px;
  font-family: var(--font-mono);
}
.positions-section .pos-vcs {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed #bfdbfe;
  font-size: 9px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  cursor: help;
}
.positions-section .pos-vcs code {
  font-size: 9px;
  background: #fef3c7;
  color: #78350f;
}
.positions-section .vcs-ip {
  padding: 0 4px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 9px;
}
.positions-section .vcs-ip.main {
  background: #dbeafe;
  color: #1e40af;
}
.positions-section .vcs-ip.bck {
  background: #ede9fe;
  color: #6d28d9;
}
.positions-section .vcs-est {
  background: #fbbf24;
  color: #78350f;
  padding: 0 3px;
  border-radius: 2px;
  font-size: 8px;
  font-weight: 700;
  margin-left: auto;
}
.positions-section .pos-served {
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}
.positions-section .pos-served code {
  background: #f1f5f9;
  padding: 0 5px;
  border-radius: 3px;
  font-style: normal;
  color: var(--text);
}

/* ═══ Cable Sankey Spine ═══ */
.cable-sankey-wrap {
  position: relative;
  margin: 10px 0 8px;
  padding: 8px 8px 6px;
  background: linear-gradient(180deg, #fafbfc 0%, #f1f5f9 100%);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cable-sankey-wrap:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(48, 84, 150, 0.08);
}
.sankey-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.sankey-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sankey-hint {
  font-size: 10px;
  font-style: italic;
  color: var(--text-muted);
  flex: 1;
}
.sankey-pin {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}
.sankey-pin:hover { background: #fef3c7; border-color: #fbbf24; }

.cable-sankey {
  width: 100%;
  height: 80px;
  display: block;
}
.cable-sankey.no-data { height: 40px; }
.cable-sankey .ribbon {
  opacity: 0.55;
  transition: opacity 0.15s;
  cursor: pointer;
}
.cable-sankey .ribbon:hover,
.cable-sankey .ribbon.highlight { opacity: 0.95; }
.cable-sankey .stack-rect {
  cursor: pointer;
  transition: filter 0.15s;
}
.cable-sankey .stack-rect:hover { filter: brightness(1.1) drop-shadow(0 0 3px rgba(0,0,0,0.2)); }
.cable-sankey .center-node rect {
  fill: white;
  stroke: var(--accent);
  stroke-width: 2;
  filter: drop-shadow(0 1px 2px rgba(15,23,42,0.1));
}
.cable-sankey .center-node text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  fill: var(--accent);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.cable-sankey .stack-label {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  fill: white;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(0,0,0,0.3);
  stroke-width: 0.6px;
}
.cable-sankey .dir-label {
  font-family: -apple-system, sans-serif;
  font-size: 8px;
  fill: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Popover (hover peek) — floats above everything, size based on content */
.cable-popover {
  position: fixed;
  background: rgba(15,23,42,0.98);
  color: white;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  z-index: 900;
  font-size: 11.5px;
  min-width: 340px;
  max-width: min(560px, calc(100vw - 40px));
  max-height: min(480px, calc(100vh - 80px));
  overflow-y: auto;
  pointer-events: auto;
  backdrop-filter: blur(6px);
}
.cable-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: rgba(15,23,42,0.98);
  border-top: none;
}
.cable-popover.above::before {
  top: auto;
  bottom: -6px;
  border-bottom: none;
  border-top: 6px solid rgba(15,23,42,0.98);
}
.cable-popover[hidden] { display: none; }
.cable-popover .pop-title {
  font-family: var(--font-mono);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.cable-popover .pop-title-id {
  color: #fbbf24;
  font-weight: 700;
  font-size: 14px;
  margin-right: 8px;
}
.cable-popover .pop-title-desc {
  color: #cbd5e1;
  font-size: 11px;
  font-family: -apple-system, sans-serif;
}
.cable-popover .pop-dir {
  margin-bottom: 10px;
}
.cable-popover .pop-dir:last-child { margin-bottom: 0; }
.cable-popover .pop-dir-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 11px;
  color: #fbbf24;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cable-popover .pop-dir-head .pop-dir-count {
  font-size: 10px;
  background: rgba(251,191,36,0.2);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.cable-popover .pop-group {
  margin-bottom: 6px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 5px;
  border-left: 3px solid currentColor;
  transition: background 0.2s, box-shadow 0.2s;
}
.cable-popover .pop-group.pulse {
  animation: pop-group-pulse 2s ease-out;
}
@keyframes pop-group-pulse {
  0%, 100% { background: rgba(255,255,255,0.06); box-shadow: 0 0 0 0 rgba(251,191,36,0); }
  20% { background: rgba(251,191,36,0.18); box-shadow: 0 0 0 4px rgba(251,191,36,0.5); }
}

/* Stack-rect / ribbon click affordance */
.cable-sankey .stack-rect { cursor: pointer; }
.cable-sankey .ribbon { cursor: pointer; }
.cable-sankey .stack-label { pointer-events: none; }
.cable-popover .pop-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 4px;
}
.cable-popover .pop-group-ribbon {
  display: inline-block;
  height: 6px;
  background: currentColor;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.cable-popover .pop-chip {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  margin: 2px 2px 0 0;
  cursor: pointer;
  transition: background 0.1s;
}
.cable-popover .pop-chip:hover { background: rgba(255,255,255,0.25); }
.cable-popover .pop-chip .chip-note {
  display: block;
  font-family: var(--font-sans);
  font-size: 9px;
  font-style: italic;
  color: #cbd5e1;
  margin-top: 1px;
}
.cable-popover .pop-footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 9px;
  color: #94a3b8;
  font-style: italic;
}

/* Jump-highlight when clicking endpoint chip — 3 pulses + glow */
.rack-card.flash-highlight {
  animation: flash-highlight 2.6s ease-out;
  position: relative;
  z-index: 5;
}

/* Persistent attention state — card remains visually emphasized until the
   user hovers or focuses it. Gentle 2s breathing pulse (loops). */
.rack-card.flash-attention {
  animation: flash-attention 2s ease-in-out infinite;
  position: relative;
  z-index: 5;
}
@keyframes flash-attention {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(251,191,36,0.35),
                0 0 14px 2px rgba(251,191,36,0.22);
    outline: 2px solid rgba(245,158,11,0.55);
    outline-offset: 0;
  }
  50% {
    box-shadow: 0 0 0 7px rgba(251,191,36,0.65),
                0 0 26px 4px rgba(251,191,36,0.45);
    outline: 2px solid rgba(245,158,11,0.9);
    outline-offset: 2px;
  }
}
@keyframes flash-highlight {
  0%   {
    box-shadow: 0 0 0 0 rgba(251,191,36,0),
                0 0 0 0 rgba(251,191,36,0);
    transform: scale(1);
    outline: 0px solid rgba(251,191,36,0);
  }
  8%   {
    box-shadow: 0 0 0 10px rgba(251,191,36,0.85),
                0 0 40px 4px rgba(251,191,36,0.45);
    transform: scale(1.025);
    outline: 3px solid rgba(245,158,11,0.9);
  }
  18%  {
    box-shadow: 0 0 0 4px rgba(251,191,36,0),
                0 0 20px 2px rgba(251,191,36,0);
    transform: scale(1);
    outline: 0px solid rgba(251,191,36,0);
  }
  30%  {
    box-shadow: 0 0 0 10px rgba(251,191,36,0.7),
                0 0 40px 4px rgba(251,191,36,0.35);
    transform: scale(1.02);
    outline: 3px solid rgba(245,158,11,0.75);
  }
  40%  {
    box-shadow: 0 0 0 4px rgba(251,191,36,0),
                0 0 20px 2px rgba(251,191,36,0);
    transform: scale(1);
    outline: 0px solid rgba(251,191,36,0);
  }
  52%  {
    box-shadow: 0 0 0 8px rgba(251,191,36,0.55),
                0 0 30px 3px rgba(251,191,36,0.25);
    transform: scale(1.015);
    outline: 2px solid rgba(245,158,11,0.6);
  }
  60%  {
    box-shadow: 0 0 0 2px rgba(251,191,36,0),
                0 0 10px 1px rgba(251,191,36,0);
    transform: scale(1);
    outline: 0px solid rgba(251,191,36,0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(251,191,36,0),
                0 0 0 0 rgba(251,191,36,0);
    transform: scale(1);
    outline: 0px solid rgba(251,191,36,0);
  }
}
/* legacy .power-section h3 / .equipment-section h3 styles removed —
   unified into .section-head above. Equipment table still needs its
   own sticky header styling below. */

.power-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.power-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  align-items: start;
}
.power-row + .power-row { border-top: 1px dashed var(--border); }
.power-row .label {
  font-weight: 600;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  color: white;
  text-align: center;
  line-height: 1.3;
  height: fit-content;
}
.power-row[data-type="MAIN UPS"] .label { background: var(--main-ups); }
.power-row[data-type="SECONDARY UPS"] .label { background: var(--secondary-ups); }
.power-row[data-type="PDU 1"] .label { background: var(--pdu1); }
.power-row[data-type="PDU 2"] .label { background: var(--pdu2); }
.power-row[data-type="GROUNDING"] .label { background: var(--ground); }
.power-row[data-type="Fiber Optic"] .label { background: #be185d; }
.power-row .detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  word-break: break-word;
}
.power-row .detail .path { display: block; color: var(--text); }
.power-row .detail .spec { display: block; color: var(--text-muted); font-size: 10px; margin-top: 2px; }

.equipment-wrap {
  max-height: 400px;
  overflow-y: auto;
  margin: 0 -16px -12px;
  padding: 0 16px 12px;
}
.equipment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--font-mono);
}
.equipment-table th {
  text-align: left;
  font-weight: 600;
  padding: 4px 6px;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  font-family: var(--font-sans);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  z-index: 1;
}
.equipment-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  word-break: break-word;
}
.equipment-table tr:hover { background: #f8fafc; }
.equipment-table td.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 20px;
  font-family: var(--font-sans);
}
.equipment-table td.prm-cell { text-align: center; padding: 2px 4px; }

/* Inline network hostname/IP hint under equipment description */
.eq-net {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  margin-top: 3px;
  padding: 2px 6px;
  background: #eff6ff;
  border-left: 3px solid #2563eb;
  border-radius: 3px;
  cursor: help;
}
.eq-net code {
  background: white;
  color: #1d4ed8;
  padding: 0 4px;
  border-radius: 2px;
  font-weight: 700;
}
.eq-net .net-ip {
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 9px;
}
.eq-net .net-ip.main {
  background: #dbeafe;
  color: #1e40af;
}
.eq-net .net-ip.bck {
  background: #ede9fe;
  color: #6d28d9;
}
.eq-net .net-aliases {
  color: var(--text-muted);
  font-size: 9px;
  font-style: italic;
}
.prm-link {
  font-size: 10px;
  padding: 2px 6px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 4px;
  color: #78350f;
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 600;
}
.prm-link:hover { background: #fde68a; }
.prm-none { color: #cbd5e1; font-size: 14px; }

/* PDU outlets — Văn-recheck physical layout (per-equipment row + section header summary) */
.eq-pdu {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  margin-top: 3px;
  padding: 2px 6px;
  background: #fdf4ff;
  border-left: 3px solid #a855f7;
  border-radius: 3px;
  cursor: help;
}
.pdu-chip {
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.2px;
}
.pdu-chip.pdu-a {  /* Branch A — Main UPS feed */
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}
.pdu-chip.pdu-b {  /* Branch B — Secondary UPS feed */
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.pdu-chip.pdu-other {
  background: #f3f4f6;
  color: #475569;
  border: 1px solid #d1d5db;
}
.pdu-single {  /* visual flag: device has only 1 PSU/branch (no power redundancy) */
  font-size: 8.5px;
  font-weight: 600;
  color: #c2410c;
  background: #ffedd5;
  padding: 0 4px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.eq-pdu .u-pos {
  font-size: 8.5px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 0 4px;
  border-radius: 2px;
}
/* Equipment section-head summary badge */
.eq-pdu-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  font-size: 10px;
  font-weight: 600;
}
.pdu-sum-chip {
  padding: 1px 6px;
  background: #f3e8ff;
  color: #6b21a8;
  border: 1px solid #d8b4fe;
  border-radius: 3px;
  font-family: var(--font-mono);
  letter-spacing: 0.2px;
}
.pdu-sum-warn {
  padding: 1px 5px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ============================================================
   PWA + Mobile responsive (added v1.7.0)
   ============================================================ */

/* Safe-area insets — apply UNIVERSALLY (PWA, Capacitor APK, browser).
 * env(safe-area-inset-*) returns 0 on devices without notches/cutouts/nav-bars,
 * so this is safe across all platforms. v1.32.0 (display-mode: standalone)-only
 * gate was wrong: Capacitor WebView doesn't report standalone, so Android APK
 * had its content overlapped by Android status bar (top) and gesture-nav bar
 * (bottom). v1.33.0 makes this universal.
 */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Note: per-page sticky/fixed headers (e.g. .page-header in settings.html)
 * MUST add their own padding-top: env(safe-area-inset-top) because they
 * escape body's content flow when scrolled. Body padding above is enough
 * for normal-flow elements. */

/* Tablet — single column rack grid */
@media (max-width: 1024px) {
  #grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
  }
}

/* ============================================================
   Chrome auto-hide + floating ☰ toggle (v1.8.3 — universal: all viewports)
   ============================================================
   Applied to ALL viewports (desktop + mobile portrait + mobile landscape).
   Per anh's request v1.8.3: same behavior cho cả desktop.

   Behavior:
     - Default: header + controls visible at top
     - Scroll DOWN > 60px → translate up → both hidden (only floating ☰ visible)
     - Scroll UP (any) → slide back down to show
     - Floating ☰ FAB top-right → tap to manually force show/hide
*/
body.chrome-collapsed .app-header,
body.chrome-collapsed .top-bar,
body.chrome-collapsed .controls {
  transform: translateY(-100%);
  pointer-events: none;
}
.app-header,
.top-bar,
.controls {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Floating ☰ toggle button — fixed top-right, visible on ALL viewports */
#mobile-chrome-toggle {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 200;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(31, 78, 120, 0.92);
  color: white;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
#mobile-chrome-toggle:hover {
  background: rgba(43, 111, 168, 1);
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
#mobile-chrome-toggle:active {
  transform: scale(0.92);
  background: rgba(43, 111, 168, 1);
}
#mobile-chrome-toggle .toggle-icon {
  transition: transform 0.25s;
  display: inline-block;
  line-height: 1;
}
body.chrome-collapsed #mobile-chrome-toggle .toggle-icon {
  transform: rotate(180deg);
}
/* v1.11.1 — hide FAB when focus banner is open so it doesn't overlap
   the banner's close (✕) button in the top-right corner on mobile. */
#mobile-chrome-toggle.hidden-by-focus {
  display: none !important;
}
/* Push content up when chrome hidden so user gets full viewport */
body.chrome-collapsed #grid,
body.chrome-collapsed .topology-main {
  margin-top: 0 !important;
}
/* v1.11.1 — when chrome hidden, topology-main must fill the ENTIRE window
   (not calc(100vh - 180px) that assumed chrome was present). Without this,
   on mobile landscape (short viewport), main stays 560px tall while window
   is only 375px, pushing the wrap + focused node offscreen below. */
body.chrome-collapsed .topology-main {
  height: 100vh !important;
  position: fixed !important;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Mobile — compact header + collapsible controls + maximize content viewport (v1.8.1 fix #5) */
@media (max-width: 768px) {
  /* HEADER — ultra-compact: title + stats inline, smaller fonts */
  .app-header {
    padding: 8px 12px !important;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px !important;
    align-items: center !important;
  }
  .brand { flex: 1 1 100%; min-width: 0; }
  .app-header h1 { font-size: 15px !important; line-height: 1.2; margin: 0; }
  .app-header .subtitle {
    font-size: 10px !important;
    margin: 1px 0 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Stats inline, much smaller */
  .stats {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    flex: 1 1 auto;
    overflow-x: auto;
  }
  .stat-box, .stat-card {
    flex: 0 0 auto !important;
    min-width: 56px !important;
    padding: 4px 8px !important;
    border-radius: 6px !important;
  }
  .stat-box .num, .stat-num {
    font-size: 14px !important;
    line-height: 1.1 !important;
    display: block !important;
  }
  .stat-box .lbl, .stat-lbl {
    font-size: 8px !important;
    letter-spacing: 0.3px !important;
  }
  .nav-links {
    display: flex;
    gap: 4px !important;
    flex-wrap: nowrap;
    justify-content: flex-end;
    flex: 0 0 auto;
  }
  .nav-link {
    font-size: 11px !important;
    padding: 5px 8px !important;
    min-height: 30px !important;
    border-radius: 6px !important;
  }

  /* CONTROLS — collapse to icon-only summary; tap to expand (handled by JS class .controls-expanded) */
  .controls {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 6px 10px !important;
    gap: 6px !important;
    flex-wrap: wrap;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  .search-wrap { width: 100%; order: -1; }
  #search {
    width: 100% !important;
    font-size: 16px !important;  /* prevent iOS zoom on focus */
    padding: 6px 10px !important;
    height: 34px !important;
  }
  /* Filter groups — single row scroll horizontally if too many */
  .filter-group {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    gap: 4px !important;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-group::-webkit-scrollbar { display: none; }
  .filter-label {
    font-size: 10px !important;
    flex-shrink: 0;
  }
  .filter-chip, .fchip, .filter-btn {
    font-size: 11px !important;
    padding: 4px 8px !important;
    flex-shrink: 0 !important;
    white-space: nowrap;
  }
  .view-toggle {
    display: flex;
    gap: 4px;
    margin-left: auto;
  }
  .view-toggle button {
    font-size: 10.5px !important;
    padding: 4px 8px !important;
    height: 28px !important;
  }

  /* Rack grid — single column */
  #grid {
    grid-template-columns: 1fr !important;
    padding: 10px !important;
    gap: 12px !important;
  }
  .rack-card { font-size: 13px; }
  .rack-card .rack-head {
    flex-wrap: wrap;
    padding: 12px !important;
  }
  .rack-card .rack-id { font-size: 17px !important; }
  .rack-card .rack-desc { font-size: 12px !important; }
  .rack-card .floor-badge,
  .rack-card .system-badge,
  .rack-card .eq-count-badge,
  .rack-card .recabling-badge {
    font-size: 9.5px !important;
    padding: 2px 6px !important;
  }

  /* Section headers — tighter */
  .section-head {
    padding: 10px 12px !important;
    font-size: 13px !important;
  }
  .sh-title { font-size: 12.5px; }

  /* Power list — tighten */
  .power-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 12px !important;
  }
  .power-row .label {
    align-self: flex-start;
    font-size: 9.5px !important;
  }
  .power-row .detail {
    width: 100%;
  }
  .power-row .path,
  .power-row .spec { font-size: 11.5px !important; line-height: 1.4; }

  /* Equipment table — horizontal scroll */
  .equipment-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .equipment-table {
    min-width: 640px;  /* keep table readable; user scrolls horizontally */
    font-size: 11px;
  }
  .equipment-table th,
  .equipment-table td {
    padding: 4px 6px !important;
  }

  /* Sankey caption */
  .sankey-caption {
    flex-wrap: wrap;
    font-size: 10px !important;
  }

  /* Positions card — single column on mobile */
  .pos-cards { grid-template-columns: 1fr !important; }

  /* Section header summary chip wrap */
  .eq-pdu-summary {
    margin-left: 0 !important;
    margin-top: 4px;
    flex-wrap: wrap;
  }
}

/* Small mobile — extra-tight */
@media (max-width: 480px) {
  .app-header h1 { font-size: 16px !important; }
  .stat-card { flex: 1 1 calc(50% - 4px); }
  .rack-card .rack-id { font-size: 15px !important; }
  /* Hide PRM column on very small screens — symbol still visible via row title */
  .equipment-table { min-width: 560px; }
}

/* Ensure touch-friendly tap targets (min 44x44 per Apple HIG) */
@media (hover: none) and (pointer: coarse) {
  button, .nav-link, .filter-chip, .fchip,
  .section-head, .pdu-chip, .eq-net code,
  .prm-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }
}

/* PRM modal */
.prm-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.prm-modal[hidden] { display: none; }
.prm-modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,0.6); backdrop-filter: blur(4px); }
.prm-modal-box {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  width: 90%;
  padding: 28px 32px;
}
.prm-modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
}
.prm-modal-close:hover { background: #f1f5f9; }
.prm-head .prm-tag {
  display: inline-block;
  background: #fbbf24;
  color: #78350f;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}
.prm-head h2 { margin: 0 0 4px; font-size: 20px; color: var(--text); }
.prm-head .prm-category { margin: 0; color: var(--text-muted); font-size: 13px; }
.prm-context {
  background: #f8fafc;
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  margin: 16px 0;
  font-size: 12px;
  border-radius: 0 6px 6px 0;
}
.prm-context .lbl { color: var(--text-muted); min-width: 95px; display: inline-block; }
.prm-context code { background: white; padding: 1px 5px; border-radius: 3px; font-size: 11px; }
.prm-specs h3 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.prm-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
}
.prm-row:last-child { border-bottom: none; }
.prm-key { color: var(--accent); font-weight: 600; font-size: 11px; }
.prm-val { color: var(--text); font-family: var(--font-mono); font-size: 11px; line-height: 1.5; }
.prm-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}

/* PRM modal — network block */
.prm-network {
  margin: 14px 0;
  padding: 12px 14px;
  background: #f0f9ff;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
}
.prm-network h3 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e40af;
}
.prm-network h3 code {
  font-size: 10px;
  background: white;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.prm-net-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.prm-net-col {
  padding: 8px 10px;
  border-radius: 6px;
  background: white;
  border-left: 3px solid;
  font-family: var(--font-mono);
  font-size: 11px;
}
.prm-net-col.main { border-left-color: #2563eb; }
.prm-net-col.bck  { border-left-color: #7c3aed; }
.prm-net-col.empty {
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.prm-net-lbl {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}
.prm-net-ip {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}
.prm-net-host code {
  background: #f8fafc;
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 10px;
}
.prm-net-aliases {
  margin-top: 4px;
  font-size: 9.5px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}
.prm-net-aliases span {
  font-family: var(--font-mono);
  color: var(--text);
}

/* Highlight for search match */
mark {
  background: #fde68a;
  color: #78350f;
  padding: 0 2px;
  border-radius: 2px;
}

/* ═══ Back-to-top floating button ═══
   Bottom-right corner, BELOW topbar so it never overlaps. Icon-only
   (up-arrow) — replaces old "↑ TOP" pill. */
#back-to-top {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  z-index: 800;
  width: 42px; height: 42px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  padding: 0;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(48, 84, 150, 0.35);
  transition: transform 0.2s, background 0.15s, box-shadow 0.2s, opacity 0.25s;
  opacity: 0;
  transform: translateY(16px);
}
#back-to-top svg { width: 20px; height: 20px; transition: transform 0.2s; }
#back-to-top[hidden] { display: none; }
#back-to-top.visible {
  opacity: 0.92;
  transform: translateY(0);
}
#back-to-top:hover {
  background: #4472c4;
  box-shadow: 0 6px 18px rgba(48, 84, 150, 0.5);
  transform: translateY(-2px);
  opacity: 1;
}
#back-to-top:hover svg { transform: translateY(-2px); }
#back-to-top:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(48, 84, 150, 0.4);
}
#back-to-top .btt-arrow,
#back-to-top .btt-label {
  display: none; /* superseded by SVG icon */
}

/* ═══ Instant hint tooltip (AIOS-OC style, zero-delay) ═══ */
.instant-hint {
  position: fixed;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.97);
  color: #f1f5f9;
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.45;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  max-width: 360px;
  white-space: pre-line;          /* respect \n in title strings */
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.08s ease-out, transform 0.08s ease-out;
}
.instant-hint.show {
  opacity: 1;
  transform: translateY(0);
}
.instant-hint[hidden] { display: none; }
.instant-hint::after {
  content: "";
  position: absolute;
  border: 5px solid transparent;
}
.instant-hint.below::after {
  top: -10px;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
  border-bottom-color: rgba(15,23,42,0.97);
  border-top: none;
}
.instant-hint.above::after {
  bottom: -10px;
  left: var(--arrow-x, 50%);
  transform: translateX(-50%);
  border-top-color: rgba(15,23,42,0.97);
  border-bottom: none;
}

/* Floor color cues */
.rack-card[data-floor="T2"] .card-head { background: linear-gradient(90deg, #7c2d12, #c2410c); }
.rack-card[data-floor="T3"] .card-head { background: linear-gradient(90deg, var(--accent), #4472c4); }
.rack-card[data-floor="T4"] .card-head { background: linear-gradient(90deg, #065f46, #059669); }
.rack-card[data-floor="T5"] .card-head { background: linear-gradient(90deg, #581c87, #7c3aed); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}
.empty-state h2 { margin: 0 0 6px; color: var(--text); }
.search-hints {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  text-align: left;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.search-hints .sh-col {
  background: white;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid var(--border);
}
.search-hints .sh-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.search-hints ul { list-style: none; margin: 0; padding: 0; font-size: 11px; line-height: 1.9; }
.search-hints code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--text);
  font-size: 10px;
  margin: 0 2px;
}
