/* RESET & BASE SETUP */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ─── CSS VARIABLES — Nexus light (default) ─── */
:root {
  --bg-page:      #eef2f7;
  --bg-card:      #ffffff;
  --bg-accent:    #f1f5f9;
  --bg-deep:      #f8fafc;
  --bg-row-even:  #f8fafc;
  --bg-row-hover: #eff6ff;
  --border:       #e2e8f0;
  --border-color: #e2e8f0;   /* alias used by wallboard/encode */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #64748b;
  --text-dim:       #94a3b8;
  --accent:         #3730a3;   /* Nexus indigo */
  --accent-hover:   #4338ca;
  --amber:          #f59e0b;   /* Nexus amber accent */
  --sc-up:    #10b981;
  --sc-warn:  #f59e0b;
  --sc-down:  #ef4444;
  --sc-unkn:  #94a3b8;
  --badge-ok-bg:   #d1fae5;
  --badge-ok-fg:   #065f46;
  --badge-crit-bg: #fee2e2;
  --badge-crit-fg: #991b1b;
  --badge-warn-bg: #fef3c7;
  --badge-warn-fg: #92400e;
  --badge-unkn-bg: #f3f4f6;
  --badge-unkn-fg: #374151;
  --shadow: rgba(15, 23, 42, 0.08);

  /* Sidebar — Light Mode */
  --sidebar-bg: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  --sidebar-text: #1e293b;
  --sidebar-text-secondary: #64748b;
  --sidebar-border: rgba(15, 23, 42, 0.08);
  --sidebar-hover-bg: rgba(15, 23, 42, 0.06);
  --sidebar-hover-text: #0f172a;
  --sidebar-active-bg: rgba(245,158,11,0.14);
  --sidebar-active-text: #0f172a;
  --sidebar-child-text: #475569;

  /* Warehouse dashboard — theme-aware surfaces & text (LIGHT) */
  --wh-body-bg: radial-gradient(1200px 600px at 20% -10%, #f8fafc 0%, #eef2f7 55%, #e2e8f0 100%);
  --wh-card-bg: linear-gradient(180deg, #ffffff, #f8fafc);
  --wh-card-border: #e2e8f0;
  --wh-card-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  --wh-pop-bg: #ffffff;
  --wh-text:       #0f172a;
  --wh-text-body:  #1e293b;
  --wh-text-soft:  #475569;
  --wh-text-muted: #64748b;
  --wh-text-faint: #94a3b8;
  --wh-ic-bg: rgba(37, 99, 235, 0.10);
  --wh-ic-fg: #2563eb;
  --wh-active-bg: #2563eb;
  --wh-active-fg: #ffffff;
  --wh-overlay:        rgba(15, 23, 42, 0.04);
  --wh-overlay-strong: rgba(15, 23, 42, 0.09);
  --wh-divider:        rgba(15, 23, 42, 0.08);
  --wh-focus: #6366f1;
  --wh-map-glow: rgba(46, 134, 222, 0.10);
  --wh-pin-hover: #2563eb;
  --wh-err: #dc2626;
}

/* ─── Optional dark mode (toggle) ─── */
[data-theme="dark"] {
  --bg-page:      #1a1a2e;
  --bg-card:      #16213e;
  --bg-accent:    #0f3460;
  --bg-deep:      #0a1929;
  --bg-row-even:  #0d1b30;
  --bg-row-hover: #1a3050;
  --border:       #0f3460;
  --border-color: #0f3460;
  --text-primary:   #ffffff;
  --text-secondary: #f7f8f8;
  --text-muted:     #95a5a6;
  --text-dim:       #555555;
  --accent:         #6366f1;
  --accent-hover:   #818cf8;
  --amber:          #f59e0b;
  --sc-up:    #4cd137;
  --sc-warn:  #f1c40f;
  --sc-down:  #ff6b6b;
  --sc-unkn:  #95a5a6;
  --badge-ok-bg:   #1a4a1a;
  --badge-ok-fg:   #4cd137;
  --badge-crit-bg: #4a1a1a;
  --badge-crit-fg: #ff6b6b;
  --badge-warn-bg: #4a3a00;
  --badge-warn-fg: #f1c40f;
  --badge-unkn-bg: #2a2a2a;
  --badge-unkn-fg: #95a5a6;
  --shadow: rgba(0, 0, 0, 0.3);

  /* Sidebar — Dark Mode */
  --sidebar-bg: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  --sidebar-text: #ffffff;
  --sidebar-text-secondary: rgba(255,255,255,0.55);
  --sidebar-border: rgba(255,255,255,0.08);
  --sidebar-hover-bg: rgba(255,255,255,0.10);
  --sidebar-hover-text: #ffffff;
  --sidebar-active-bg: rgba(245,158,11,0.14);
  --sidebar-active-text: #ffffff;
  --sidebar-child-text: rgba(255,255,255,0.74);

  /* Warehouse dashboard — theme-aware surfaces & text (DARK) */
  --wh-body-bg: radial-gradient(1200px 600px at 20% -10%, #16213e 0%, #0b1020 55%, #080b16 100%);
  --wh-card-bg: linear-gradient(180deg, rgba(25, 34, 60, 0.75), rgba(16, 22, 40, 0.85));
  --wh-card-border: rgba(255, 255, 255, 0.08);
  --wh-card-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  --wh-pop-bg: #141b30;
  --wh-text:       #ffffff;
  --wh-text-body:  #e8edf5;
  --wh-text-soft:  #cbd5e1;
  --wh-text-muted: #8a94a8;
  --wh-text-faint: #5d6a82;
  --wh-ic-bg: rgba(59, 130, 246, 0.16);
  --wh-ic-fg: #60a5fa;
  --wh-active-bg: #2563eb;
  --wh-active-fg: #ffffff;
  --wh-overlay:        rgba(255, 255, 255, 0.05);
  --wh-overlay-strong: rgba(255, 255, 255, 0.10);
  --wh-divider:        rgba(255, 255, 255, 0.07);
  --wh-focus: #6366f1;
  --wh-map-glow: rgba(46, 134, 222, 0.12);
  --wh-pin-hover: #93c5fd;
  --wh-err: #ff8a8a;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  width: 100vw;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s, color 0.2s;
}

/* Lock body scroll when tab shell is active */
body.tab-shell {
  height: 100vh;
  overflow: hidden;
}

/* ─── TAB BAR ─── */
.tab-bar {
  display: flex;
  align-items: flex-end;
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  padding: 3px 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  gap: 3px;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px 6px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-accent);
  border: 1px solid var(--border);
  border-bottom: none;
  white-space: nowrap;
  user-select: none;
  transition: background 0.2s, color 0.2s, box-shadow 0.25s, transform 0.2s;
  position: relative;
  margin-bottom: -2px;
}

.tab-item.active {
  background: var(--bg-page);
  color: var(--text-primary);
  box-shadow: inset 0 2px 0 var(--accent);
  border-bottom-color: var(--bg-page);
  z-index: 1;
}

.tab-item:active { transform: scale(0.96); }
.tab-item[draggable="true"] { cursor: grab; }
.tab-item.dragging { opacity: 0.38; cursor: grabbing; transform: none !important; }
.tab-item.drag-over { box-shadow: -2px 0 0 var(--accent); }
.tab-item.active.drag-over { box-shadow: inset 0 2px 0 var(--accent), -2px 0 0 var(--accent); }

.tab-item:hover:not(.active) {
  background: var(--bg-row-hover);
  color: var(--text-secondary);
}

.tab-item i { font-size: 0.8rem; color: var(--accent); }

.tab-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  margin-left: 2px;
  transition: background 0.15s, color 0.15s;
}
.tab-close:hover { background: var(--accent); color: #fff; }

/* ─── TAB CONTENT ─── */
.tab-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.tab-pane {
  display: none;
  flex-direction: column;
  flex-grow: 1;
  overflow-y: auto;
  min-height: 0;
}
.tab-pane.active {
  display: flex;
  animation: pane-in 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Smooth entrance played each time a tab becomes active (incl. auto-rotate). */
@keyframes pane-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* Dashboard fades only — its cards supply the motion (no compounding). */
#pane-dashboard.active { animation: pane-fade 0.3s ease both; }
@keyframes pane-fade { from { opacity: 0; } to { opacity: 1; } }

/* Staggered card cascade when the dashboard pane appears. */
#pane-dashboard.active .card {
  animation: card-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
#pane-dashboard.active .card:nth-child(1) { animation-delay: 0.04s; }
#pane-dashboard.active .card:nth-child(2) { animation-delay: 0.10s; }
#pane-dashboard.active .card:nth-child(3) { animation-delay: 0.16s; }
#pane-dashboard.active .card:nth-child(4) { animation-delay: 0.22s; }
#pane-dashboard.active .card:nth-child(5) { animation-delay: 0.28s; }
#pane-dashboard.active .card:nth-child(6) { animation-delay: 0.34s; }

@keyframes card-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Respect users who prefer no motion. */
@media (prefers-reduced-motion: reduce) {
  .tab-pane.active,
  #pane-dashboard.active .card { animation: none; }
}

/* ─── KIOSK / ROTATING FULLSCREEN ─── */
/* While auto-rotating, hide the chrome so the active page fills the screen,
   just like the wallboard. */
body.kiosk-rotating .site-header,
body.kiosk-rotating .tab-bar { display: none; }
body.kiosk-rotating .tab-content { height: 100vh; }

/* Floating controls shown only during rotation. */
.kiosk-bar {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 9999;
  display: none;
  gap: 8px;
  align-items: center;
}
body.kiosk-rotating .kiosk-bar { display: flex; animation: kiosk-bar-in 0.5s ease; }

@keyframes kiosk-bar-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.kiosk-bar .kiosk-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: .3px;
  border: none;
  cursor: pointer;
  color: #fff;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s, background 0.2s;
}
.kiosk-bar .kiosk-pill:hover { transform: translateY(-1px); background: rgba(15, 23, 42, 0.9); }
.kiosk-bar .kiosk-pill.stop { background: rgba(239, 68, 68, 0.85); }
.kiosk-bar .kiosk-pill.stop:hover { background: rgba(220, 38, 38, 0.95); }
.kiosk-bar .kiosk-live i { color: #4cd137; animation: kiosk-pulse 1.4s ease-in-out infinite; }

@keyframes kiosk-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.tab-iframe {
  width: 100%;
  flex-grow: 1;
  border: none;
  min-height: 600px;
}

/* ─── APP SHELL / SIDEBAR / HEADER ─── */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
}
.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: width 0.22s ease, transform 0.22s ease;
  overflow: hidden;
}
.app-sidebar.collapsed { width: 0; }
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar-header {
  padding: 16px 10px 4px;
  border-bottom: none;
}
.sidebar-nav-heading {
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidebar-text-secondary);
  display: block;
}
.sidebar-brand-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.sidebar-nav {
  padding: 12px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.sidebar-group-toggle, .sidebar-link {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.sidebar-group-toggle:hover,
.sidebar-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }
.sidebar-group-toggle,
.sidebar-link.direct-link {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--sidebar-text);
}
.sidebar-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.sidebar-group-label i,
.sidebar-link.direct-link i:first-child {
  width: 18px;
  text-align: center;
  color: var(--amber);
  font-size: 0.85rem;
  opacity: 0.85;
}
.sidebar-chevron { font-size: 0.72rem; opacity: 0.6; }
.sidebar-group-children {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 3px 2px 6px 10px;
}
.sidebar-group.open .sidebar-group-children { display: flex; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
  color: var(--sidebar-child-text);
}
.sidebar-link i:first-child { font-size: 0.5rem; opacity: 0.45; }
.sidebar-link.active,
.sidebar-link.direct-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar-group-label span,
.sidebar-link.direct-link span { font-size: 1.01rem; font-weight: 500;}
.sidebar-link span { font-size: 1.0rem; font-weight: 500; }
.sidebar-group.active-parent > .sidebar-group-toggle { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }
.app-sidebar.collapsed .sidebar-brand-label,
.app-sidebar.collapsed .sidebar-group-label span,
.app-sidebar.collapsed .sidebar-link.direct-link span,
.app-sidebar.collapsed .sidebar-group-children,
.app-sidebar.collapsed .sidebar-group-toggle .sidebar-chevron,
.app-sidebar.collapsed .sidebar-nav-heading {
  display: none;
}
.app-sidebar.collapsed .sidebar-group-toggle,
.app-sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 10px 0;
}
.app-sidebar.collapsed .sidebar-group-label {
  justify-content: center;
}

/* ─── TOP HEADER ─── */
.site-header { flex-shrink: 0; box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18); position: relative; z-index: 5; }
.util-divider { opacity: 0.35; font-size: 0.82rem; color: rgba(255,255,255,0.5); }
.main-nav {
  background: linear-gradient(135deg, #0f172a 0%, #3730a3 60%, #312e81 100%);
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 46px;
   gap: 12px;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; overflow-x: auto; }
.nav-actions::-webkit-scrollbar { display: none; }
.server-status,   /*other text on top header */
.nav-status-text,
.updated-pill{ color: rgba(255,255,255,0.8) !important; }
.db-label {       /*db text on top header */
    font-size: 0.85rem;
    color: #ffffff;
}
.main-nav .theme-toggle { border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.8); }
.main-nav .theme-toggle:hover { background: var(--amber); border-color: var(--amber); color: #0f172a; }
.updated-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.nav-cta {
  background: var(--amber);
  color: #0f172a;
  border: none;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
  transition: background 0.18s, transform 0.15s;
}
.nav-cta:hover { background: #fbbf24; transform: translateY(-1px); }
.server-status { font-size: 0.82rem; color: var(--sc-up); display: flex; align-items: center; }
.status-dot {
  height: 8px; width: 8px;
  background-color: var(--sc-up);
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

/* ─── THEME TOGGLE ─── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── DATA SOURCE TOGGLE ─── */
.source-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
  vertical-align: middle;
}
.src-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.src-btn i { font-size: 0.75rem; }
.src-btn:hover { color: #fff; }
.src-btn.active {
  background: rgba(255,255,255,0.22);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.nav-hamburger {
  display: flex;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-hamburger:hover { background: var(--amber); border-color: var(--amber); color: #0f172a; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .app-sidebar {
    width: 100%;
    max-height: 58vh;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .app-sidebar.collapsed { width: 100%; max-height: 56px; }
  .main-nav { height: auto; min-height: 46px; padding: 6px 10px; flex-wrap: wrap; }
  .nav-actions { margin-left: 0; width: 100%; justify-content: center; padding-top: 6px; }
}

/* ─── AUTO-ROTATE SETTINGS PANEL ─── */
.main-nav #rotate-settings-btn.on { background: var(--amber); border-color: var(--amber); color: #0f172a; }
.main-nav #rotate-settings-btn.on i { animation: rot-spin 3s linear infinite; }
@keyframes rot-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.settings-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 90; display: none;
}
.settings-overlay.open { display: block; }

.settings-panel {
  position: fixed; top: 64px; right: 14px; width: 320px; max-width: 92vw;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  z-index: 100; overflow: hidden;
  transform: translateY(-8px); opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.settings-panel.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: linear-gradient(135deg, #0f172a 0%, #3730a3 100%); color: #fff;
  font-weight: 800; font-size: 1rem;
}
.settings-head span { display: flex; align-items: center; gap: 8px; }
.settings-head i.fa-arrows-rotate { color: var(--amber); }
.settings-close { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; }
.settings-close:hover { background: rgba(255,255,255,0.28); }
.settings-body { padding: 14px 16px 16px; }

.set-switch-row, .set-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; font-size: 0.92rem; color: var(--text-primary);
}
.set-row select {
  background: var(--bg-accent); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; font-size: 0.88rem;
}
.set-title {
  font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-secondary); margin: 6px 0 8px; padding-top: 10px; border-top: 1px solid var(--border);
}
.set-pages { display: flex; flex-direction: column; gap: 4px; max-height: 230px; overflow-y: auto; }
.set-page {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-size: 0.92rem; color: var(--text-primary); transition: background .12s;
}
.set-page:hover { background: var(--bg-accent); }
.set-page input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.set-page i { width: 18px; text-align: center; color: var(--accent); }

.settings-actions { margin-top: 14px; }
.set-apply {
  width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: 9px; padding: 11px; font-weight: 700; font-size: 0.95rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.set-apply:hover { filter: brightness(1.08); }
.set-hint { font-size: 0.8rem; color: var(--text-secondary); margin-top: 9px; text-align: center; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 23px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; background: var(--bg-accent);
  border: 1px solid var(--border); border-radius: 23px; transition: .2s;
}
.switch .slider::before {
  content: ''; position: absolute; height: 17px; width: 17px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .slider { background: var(--sc-up); border-color: var(--sc-up); }
.switch input:checked + .slider::before { transform: translateX(19px); }

/* ─── THEME TOGGLE ─── */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── DATA SOURCE TOGGLE ─── */
.source-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
  vertical-align: middle;
}
.src-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.src-btn i { font-size: 0.75rem; }
.src-btn:hover { color: #fff; }
.src-btn.active {
  background: rgba(255,255,255,0.22);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

@media (max-width: 760px) {
  /* flex-wrap (not position:absolute) so .nav-links and .nav-actions each
     force their own full-width row via flex-basis:100% and stack in DOM
     order below the logo/hamburger row — no overlap risk, no manual offset
     math, and .main-nav's height just grows to fit when open. */
  .main-nav { flex-wrap: wrap; height: auto; min-height: 46px; padding-top: 6px; padding-bottom: 6px; }
  .nav-links, .nav-actions {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
  }
  .main-nav.nav-open .nav-links,
  .main-nav.nav-open .nav-actions {
    display: flex;
  }
  .nav-links {
    max-height: calc(100vh - 46px);
    overflow-y: auto;
    padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.12);
  }
  .nav-item { width: 100%; }
  .nav-link { width: 100%; padding: 12px 10px; font-size: 0.9rem; }
  /* Dropdowns can't rely on :hover on touch — inside the mobile panel they
     render always-expanded and indented instead of hidden-until-hover. */
  .nav-item .nav-dropdown {
    display: block;
    position: static;
    box-shadow: none;
    border: none;
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    margin: 0 0 4px;
    padding: 4px 0 4px 18px;
    min-width: 0;
  }
  .nav-dd-arrow { display: none; }
  .nav-dd-item { padding: 11px 10px; font-size: 0.85rem; color: rgba(255,255,255,0.85); }
  .nav-dd-item:hover { background: rgba(255,255,255,0.08); }
  .nav-dd-newtab { opacity: 1; color: rgba(255,255,255,0.55); }
  .nav-actions {
    gap: 10px;
    padding: 10px 0 4px;
    border-top: 1px solid rgba(255,255,255,0.12);
  }
  .nav-actions .util-divider { display: none; }
  .nav-actions > * { width: 100%; justify-content: center; }
  .source-toggle, .theme-toggle, .nav-cta, .user-chip { width: 100%; }
  .nav-cta { justify-content: center; }
  .user-chip { justify-content: space-between; }
}

/* ─── MAIN GRID LAYOUT (centralized dashboard — fills one screen, no scroll) ─── */
#pane-dashboard { overflow: hidden; }
.dashboard-grid {
  flex-grow: 1;
  min-height: 0;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 8px;
}

/* Below 3 cards' worth of width, the fixed 3×2 grid can't shrink any further —
   the "fits one screen" desktop layout only works with the fixed row count.
   Stack to a single column instead, and let the pane scroll for it (it's
   deliberately overflow:hidden above for the desktop no-scroll treatment).
   grid-auto-rows keeps a real height per card so flex-grow children (the
   donut/pie charts) still have room to fill instead of collapsing to 0. */
@media (max-width: 700px) {
  #pane-dashboard { overflow-y: auto; overflow-x: hidden; }
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: minmax(340px, auto);
  }
}

/* ─── CARDS ─── */
.card {
  background-color: var(--bg-card);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px var(--shadow), 0 2px 4px -1px var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s, border-color 0.2s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 10px 10px -5px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}

.card-header {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  cursor: pointer;
}

.card-header i { color: var(--card-accent, var(--accent)); }

.card-source-badge {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-accent);
  padding: 3px 8px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: 4px;
  white-space: nowrap;
}
.card-source-badge .live-dot {
  width: 6px;
  height: 6px;
  background: #4cd137;
  border-radius: 50%;
  display: inline-block;
}

.detail-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.detail-btn:hover {
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
  transform: translateY(-2px);
}

.detail-btn:active {
  transform: translateY(0);
}

/* ─── TSMS card period selector ─── */
.tsms-period {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.tsms-period button {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-accent);
  color: var(--text-secondary);
  font-size: 0.74rem; 
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tsms-period button:hover { color: var(--text-primary); border-color: var(--accent); }
.tsms-period button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── GRID POSITIONING ─── */
/* All six cards auto-place into the 3×2 grid and share space equally. */
/* Keep the donut chart dominant while the comparison list stays compact. */
.pie-area canvas { flex: 0 0 auto; max-width: 68%; max-height: 100%; width: auto; height: auto; }

/* ─── STATS ROW ─── */
.stats-row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 15px;
}

.stat {
  text-align: center;
  background: var(--bg-accent);
  padding: 14px 10px;
  border-radius: 8px;
  width: 32%;
}

.label {
  display: block;
  font-size: 1rem;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 600;
}

.value {
  display: block;
  font-size: 2.15em;
  font-weight: bold;
  color: var(--text-primary);
}

/* ─── STACKED BAR GRAPH ─── */
.chart-area {
  flex-grow: 1;
  background: var(--bg-accent);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
}

.bar-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  position: relative;
  padding-top: 5px;
}

.stack-bar {
  height: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  max-width: 40px;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  min-height: 40px;
}

.bar-segment {
  width: 100%;
  transition: height 0.5s ease;
  min-height: 2px;
}

.bar-segment:first-child { border-radius: 0 0 4px 4px; }
.bar-segment:last-child  { border-radius: 4px 4px 0 0; }

.bar-label {
  font-size: 0.78rem;
  font-weight: bold;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

.bar-value {
  font-size: 0.92rem;
  color: var(--text-primary);
  font-weight: bold;
  order: -1;
  margin-bottom: 4px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 3px;
}

/* ─── MHUB TRANSACTIONS ─── */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.trans-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 10px 12px;
  font-weight: bold;
  font-size: 0.92rem;
  background: var(--bg-deep);
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
}

.trans-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  background: var(--bg-accent);
  padding: 12px;
  font-size: 0.96rem;
  align-items: center;
  color: var(--text-primary);
}

.trans-row:last-child  { border-radius: 0 0 5px 5px; }
.trans-row:first-of-type { border-radius: 0; }

.trans-col { text-align: center; }
.trans-col:first-child { text-align: left; }
.trans-num { font-weight: 600; }
.trans-amt { color: var(--sc-up); font-weight: bold; }

/* ─── TIME BOXES ─── */
.time-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  height: 100%;
}

.t-box {
  background: var(--bg-accent);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

.t-box h3 { font-size: 0.88rem; color: var(--text-muted); }
.t-box p  { font-size: 1.75rem; color: var(--accent); font-weight: bold; }

/* ─── STATUS COLORS ─── */
.sc-up   { color: var(--sc-up); }
.sc-warn { color: var(--sc-warn); }
.sc-down { color: var(--sc-down); }
.sc-unkn { color: var(--sc-unkn); }

/* ─── SERVER STATUS CARD ─── */
.server-status-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
  overflow: hidden;
}

.server-source {
  background: var(--bg-accent);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 0;
}

.source-name {
  font-size: 0.86rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.source-name i { color: var(--accent); margin-right: 5px; }

.source-counts {
  display: flex;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: bold;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Clickable status counts → open the server drill-down */
.srv-chip {
  cursor: pointer;
  padding: 1px 7px;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.srv-chip:hover { border-color: currentColor; background: rgba(127, 127, 127, 0.14); }

/* ─── SERVER STATUS DRILL-DOWN MODAL ─── */
.srv-drill-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 60;
}
.srv-drill-overlay.open { opacity: 1; pointer-events: auto; }
.srv-drill {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: 540px; max-width: 92vw; max-height: 80vh;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 61; display: flex; flex-direction: column;
}
.srv-drill.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.srv-drill-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--border);
  font-weight: 800; color: var(--text-primary);
  background: linear-gradient(135deg, #0f172a 0%, #3730a3 95%); border-radius: 14px 14px 0 0;
}
.srv-drill-head, .srv-drill-head * { color: #fff; }
.srv-drill-close { background: none; border: none; color: #fff; cursor: pointer; font-size: 1rem; opacity: 0.85; }
.srv-drill-close:hover { opacity: 1; }
.srv-drill-body { padding: 8px 0; overflow-y: auto; }
.srv-row { padding: 8px 18px; border-bottom: 1px solid var(--border); border-left: 4px solid var(--border); }
.srv-row:last-child { border-bottom: none; }
.srv-row .srv-row-name { font-weight: 700; font-size: 0.92rem; color: var(--text-primary); }
.srv-row .srv-row-msg { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv-row .srv-row-time { font-size: 0.73rem; color: var(--text-dim); margin-top: 2px; }
.srv-row.srv-down, .srv-row.srv-critical { border-left-color: #ff6b6b; }
.srv-row.srv-warning { border-left-color: #f1c40f; }
.srv-row.srv-up, .srv-row.srv-ok { border-left-color: #4cd137; }
.srv-empty { text-align: center; color: var(--text-secondary); padding: 26px; font-size: 0.92rem; }

.server-last-update {
  font-size: 0.73rem;
  color: var(--text-dim);
  text-align: right;
  margin-top: 4px;
  flex-shrink: 0;
}

/* ─── SYSTEM PAGE ─── */
.system-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: var(--bg-page);
  color: var(--text-primary);
}

.system-page button {
  margin-top: 20px;
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  color: white;
  cursor: pointer;
  border-radius: 5px;
}

/* ─── MONITORING PAGE ─── */
.mon-container {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mon-section {
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 14px;
  box-shadow: 0 4px 15px var(--shadow);
  transition: background-color 0.2s;
}

.mon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.mon-header > span {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.mon-header > span i { font-size: 1rem; color: var(--accent); margin-right: 6px; }

.mon-summary {
  display: flex;
  gap: 14px;
  font-size: 0.9rem;
  font-weight: bold;
}

.mon-table-wrap {
  overflow-x: auto;
  border-radius: 6px;
}

.mon-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.mon-table thead tr {
  background: var(--bg-deep);
  color: var(--text-secondary);
  font-size: 0.84rem;
  text-transform: uppercase;
}

.mon-table th {
  font-size: 1rem;
}
.mon-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.mon-table tbody tr:nth-child(even) { background: var(--bg-row-even); }
.mon-table tbody tr:hover           { background: var(--bg-row-hover); }
.mon-table td:last-child { color: var(--text-muted); font-size: 0.82rem; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: bold;
  text-transform: uppercase;
}

.badge-up,
.badge-ok       { background: var(--badge-ok-bg);   color: var(--badge-ok-fg); }
.badge-down,
.badge-critical { background: var(--badge-crit-bg); color: var(--badge-crit-fg); }
.badge-warning  { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.badge-unknown  { background: var(--badge-unkn-bg); color: var(--badge-unkn-fg); }

.loading   { text-align: center; color: var(--text-dim);  padding: 20px; }
.error-msg { color: var(--sc-down); font-size: 0.88rem; padding: 10px; text-align: center; }

#countdown-bar {
  height: 3px;
  background: var(--bg-accent);
  margin: 0 12px 4px;
  border-radius: 2px;
  overflow: hidden;
}

#countdown-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  transition: transform 1s linear;
}
@media (prefers-reduced-motion: reduce) {
  #countdown-fill { transition: none; }
}

/* ─── PAGE TOP BAR (monitoring / encode) — single flex row like the others ─── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
}
.logo-area {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}
.logo-area i { color: var(--accent); }

.back-btn {
  background: var(--bg-accent);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.back-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.refresh-info { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; }

/* ─── PIE / DONUT CHARTS ─── */
.pie-area {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 4px;
  min-height: 0;
  overflow: hidden;
}

.pie-area canvas {
    margin-left: 10px;
    margin-right: 8px;
}

/* ─── Reusable Comparison List (shared by all donut-chart cards) ─── */
/*  Three columns via CSS Grid:  [dot+label]  [count]  [percentage]
    No table headers — alignment itself communicates the columns.   */
.comp-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 380px;
  max-width: none;
  flex: 0 0 310px;
  min-width: 0;
  font-size: 0.85rem;
  overflow-y: hidden;
  overflow-x: hidden;
}
.comp-row {
  display: grid;
  grid-template-columns: 160px 50px 50px;
  column-gap: 15px;
  align-items: center;
  min-height: 22px;
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 2px;
  margin: 0 -2px;
  transition: background 0.12s;
}
.comp-row:hover {
  background: var(--bg-accent);
}

/* ── MAIN DASHBOARD ONLY: Terminal / SIM principal legends ──────────────
   Scrollable when there are more than ~5 principals; scrollbar is only
   visible while hovering (list stays scrollable & keeps its position
   when not hovered). Uses theme variables so dark mode adapts via
   body.dark-page variable overrides. Scoped to these two IDs so other
   .comp-list users (TSMS/Merchant cards, warehouse) are unaffected. */
#legend-term.comp-list,
#legend-sim.comp-list {
  max-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
#legend-term.comp-list:hover,
#legend-sim.comp-list:hover {
  scrollbar-color: var(--text-muted) transparent;
}
#legend-term.comp-list::-webkit-scrollbar,
#legend-sim.comp-list::-webkit-scrollbar {
  width: 6px;
}
#legend-term.comp-list::-webkit-scrollbar-track,
#legend-sim.comp-list::-webkit-scrollbar-track {
  background: transparent;
}
#legend-term.comp-list::-webkit-scrollbar-thumb,
#legend-sim.comp-list::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
#legend-term.comp-list:hover::-webkit-scrollbar-thumb,
#legend-sim.comp-list:hover::-webkit-scrollbar-thumb {
  background: var(--text-muted);
}
.comp-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  min-width: 0;
  overflow: hidden;
}
.comp-label-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.comp-val {
  font-weight: bold;
  color: var(--text-primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.comp-pct {
  color: var(--text-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
}
.comp-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* ─── PIE DRILL-DOWN POPUP ─── */
.pie-popup {
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px 14px;
  min-width: 170px;
  box-shadow: 0 6px 24px var(--shadow);
  font-size: 0.9rem;
  pointer-events: all;
}

.pie-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.pie-popup-title {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.pie-popup-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.pie-popup-close:hover { background: var(--accent); color: #fff; }

.pie-popup-body { display: flex; flex-direction: column; gap: 4px; }

.pie-popup-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg-accent);
}
.pie-popup-row:last-child { border-bottom: none; }

.ppr-loc {
  color: var(--text-secondary);
  font-weight: 500;
}
.ppr-val {
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
}
.ppr-pct {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: right;
  min-width: 34px;
}

/* ── NAV CARDS ─────────────────────────────────────────────── */
.nav-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  transition: background 0.18s, transform 0.15s;
}
.nav-card:hover {
  background: var(--bg-accent);
  transform: translateY(-2px);
}
.nav-card--future {
  opacity: 0.55;
  cursor: default !important;
  pointer-events: none;
}
.nav-card-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(116,185,255,0.15);
  color: #74b9ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.nav-card-body {
  flex: 1;
  min-width: 0;
}
.nav-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-card-desc {
  font-size: 0.83rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.nav-card-arrow {
  color: var(--text-dim);
  font-size: 0.92rem;
}
.badge-soon {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(108,92,231,0.25);
  color: #a29bfe;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ============ AUTH: user chip, logout, access denied ============ */
.top-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 22px; padding: 1px 14px 6px 14px; font-size: 0.88rem;  /* 6 14 6 14 (padding)*/
  color: var(--text-primary);
}
.user-chip > i { color: var(--accent); font-size: 1.2rem; }
.user-chip b { font-weight: 700; display: block; line-height: 1.05; }
.user-chip small { color: var(--text-secondary); font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; }
.uc-logout {
  border: none; background: transparent; color: var(--text-secondary);
  cursor: pointer; width: 28px; height: 28px; border-radius: 50%; transition: .2s;
}
.uc-logout:hover { background: #e94560; color: #fff; }

.access-denied {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center;
  color: var(--text-primary); padding: 30px;
}
.access-denied i { font-size: 3.4rem; color: #e94560; }
.access-denied h1 { margin: 0; font-size: 1.8rem; }
.access-denied p { color: var(--text-secondary); margin: 0; }
.access-denied .ad-actions { display: flex; gap: 10px; margin-top: 8px; }
.access-denied button {
  border: none; background: var(--accent); color: #fff; padding: 10px 18px;
  border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 600;
}
.access-denied button.secondary { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }

/* ============ USER MANAGEMENT PAGE ============ */
.um-wrap { max-width: 1200px; margin: 0 auto; padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.um-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.um-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: 12px;
}
.um-head i { color: var(--accent); margin-right: 6px; }
.um-note { font-size: 0.82rem; color: var(--text-secondary); margin: 0 0 14px; }
.um-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; }
@media (max-width: 820px) { .um-grid { grid-template-columns: 1fr; } }

.um-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; color: var(--text-primary); }
.um-table th { text-align: left; color: var(--text-secondary); font-weight: 600; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.um-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.um-rowact { text-align: right; white-space: nowrap; }
.um-rowact button { border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer; margin-left: 4px; transition: .2s; }
.um-rowact button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.um-on { color: #4cd137; font-weight: 600; }
.um-off { color: #e94560; font-weight: 600; }

.um-rolepill { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 700;
  background: rgba(99,102,241,.15); color: var(--accent); text-transform: capitalize; }
.um-rolepill.role-admin { background: rgba(233,69,96,.16); color: #e94560; }
.um-rolepill.role-helpdesk { background: rgba(46,204,113,.16); color: #20bf6b; }
.um-rolepill.role-itss { background: rgba(241,196,15,.18); color: #c79a00; }
.um-rolepill.role-warehouse { background: rgba(52,152,219,.16); color: #2e86de; }
.um-rolepill.role-viewers { background: rgba(149,165,166,.18); color: #7f8c8d; }

.um-editor h4 { margin: 0 0 12px; color: var(--text-primary); }
.um-editor label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin: 10px 0 4px; }
.um-editor input[type=text], .um-editor input[type=password], .um-editor select {
  width: 100%; padding: 10px 12px; background: var(--bg-main, transparent);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); font-size: 0.92rem; outline: none;
}
.um-editor input:focus, .um-editor select:focus { border-color: var(--accent); }
.um-switch { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.82rem; color: var(--text-primary); }
.um-switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.um-editor-actions { display: flex; gap: 8px; margin-top: 16px; }
.um-btn { border: none; border-radius: 8px; padding: 9px 14px; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.um-btn.primary { background: var(--accent); color: #fff; }
.um-btn.primary:hover { background: var(--accent-hover); }
.um-btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.um-msg { font-size: 0.8rem; margin: 10px 0 0; min-height: 1em; }
.um-msg.ok { color: #4cd137; }
.um-msg.err { color: #e94560; }

.um-matrix-scroll { overflow-x: auto; }
.um-matrix th.um-vcol { font-size: 0.66rem; white-space: nowrap; }
.um-matrix .um-cell { text-align: center; }
.um-matrix .um-rolecell { white-space: nowrap; }
.um-matrix input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.um-matrix input[type=checkbox]:disabled { cursor: not-allowed; opacity: .55; }

.um-preview-controls { margin-bottom: 14px; }
.um-preview-controls label { font-size: 0.88rem; color: var(--text-secondary); }
.um-preview-controls select { margin-left: 8px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-card); color: var(--text-primary); font-size: 0.9rem; }
.um-homecell select.um-home {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-card); color: var(--text-primary); font-size: 0.84rem; max-width: 150px;
}
.um-homecell select.um-home:focus { border-color: var(--accent); outline: none; }
.um-pv-land { font-size: 0.84rem; color: var(--text-primary); margin-bottom: 6px; }
.um-pv-land i { color: var(--accent); margin-right: 5px; }
.um-pv-who { font-size: 0.95rem; color: var(--text-primary); margin-bottom: 12px; }
.um-pv-sub { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin: 14px 0 8px; }
.um-navpreview { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border: 1px dashed var(--border); border-radius: 10px; }
.um-navchip { font-size: 0.78rem; padding: 5px 12px; border-radius: 7px; background: rgba(99,102,241,.1); color: var(--text-primary); }
.um-navchip.active { background: var(--accent); color: #fff; }
.um-pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.um-pv-item { font-size: 0.82rem; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); }
.um-pv-item.yes { color: var(--text-primary); }
.um-pv-item.yes i { color: #4cd137; }
.um-pv-item.no { color: var(--text-secondary); opacity: .7; }
.um-pv-item.no i { color: #e94560; }

/* ============ WAREHOUSE DASHBOARD ============ */
/* Theme-aware: every surface/text colour routes through --wh-* tokens, which
   have LIGHT + DARK values in :root / [data-theme="dark"]. Saturated chart
   colours (donut segments, status chips) come from JS and read on both themes.
   The rgba(99,102,241,…) accent tints are an indigo highlight — fine on both. */
.wh-body { margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--wh-body-bg); color: var(--wh-text-body); }
.wh-body .top-bar { flex: 0 0 auto; }
/* .wh-scroll is the flex item that fills the remaining viewport below the
   header and is the scrollport into which the Warehouse sections stack
   vertically. .wh-wrap sizes naturally to the height of the 3-card row
   (min-height: 0, NOT 100%) so it never stretches to the viewport and the
   PO-Batch card that follows keeps its natural spacing in every viewport
   height (normal window, dashboard fullscreen, and browser F11). Any extra
   viewport height is absorbed by .wh-scroll's scroll area below the content
   rather than creating a gap between the row and the PO-Batch card. */
.wh-scroll { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }

.wh-wrap { flex: 0 0 auto; min-height: 0; max-width: none; margin: 0; padding: 8px;
  display: grid; grid-template-columns: 1fr 1fr 1.12fr; gap: 8px; overflow: hidden; }

.wh-card { min-height: 0; height: 800px; overflow: hidden; display: flex; flex-direction: column;
  background: var(--wh-card-bg); border: 1px solid var(--wh-card-border);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--wh-card-shadow); }

.wh-card-pobatch { flex: 0 0 auto; height: auto; min-height: 460px; margin: 0 8px 8px; }
.wh-loading { opacity: .5; pointer-events: none; }
.wh-err { color: var(--wh-err); padding: 24px; text-align: center; }
.wh-loading-msg { padding: 48px 24px; text-align: center; color: var(--wh-text-muted); font-size: 0.92rem; }
.wh-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 40px 24px; text-align: center; color: var(--wh-text-muted);
}
.wh-empty i { font-size: 1.8rem; opacity: 0.45; margin-bottom: 4px; }
.wh-empty span { font-size: 0.98rem; font-weight: 600; color: var(--wh-text-soft); }
.wh-empty small { font-size: 0.82rem; color: var(--wh-text-faint); }

.wh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex: 0 0 auto; }
.wh-title { display: flex; gap: 10px; align-items: center; }
.wh-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 1.1rem;
  background: var(--wh-ic-bg); color: var(--card-accent, var(--wh-ic-fg)); flex: 0 0 auto; }
.wh-title h3 { margin: 0; font-size: 1.3rem; color: var(--wh-text); }
.wh-title p { margin: 1px 0 0; font-size: 0.8rem; color: var(--wh-text-muted); line-height: 1.2; }
.wh-details { background: var(--wh-overlay); border: 1px solid var(--wh-divider); color: var(--wh-text-soft);
  border-radius: 8px; padding: 6px 10px; font-size: 0.9rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.wh-details:hover { background: var(--wh-overlay-strong); }

.wh-periodbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-bottom: 7px; flex: 0 0 auto; }
.wh-periodbar button { background: var(--wh-overlay); border: 1px solid var(--wh-divider); color: var(--wh-text-soft);
  border-radius: 8px; padding: 7px 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: .15s; }
.wh-periodbar button:hover { background: var(--wh-overlay-strong); }
.wh-periodbar button.active { background: var(--wh-active-bg); border-color: var(--wh-active-bg); color: var(--wh-active-fg); box-shadow: 0 4px 12px rgba(37,99,235,.4); }

.wh-tabs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; flex: 0 0 auto; }
.wh-tab { background: transparent; border: 1px solid var(--wh-divider); color: var(--wh-text-soft); border-radius: 16px;
  padding: 4px 11px; font-size: 0.74rem; font-weight: 600; cursor: pointer; transition: .15s; }
.wh-tab:hover { border-color: var(--wh-overlay-strong); color: var(--wh-text); }
.wh-tab.active { background: var(--wh-active-bg); border-color: var(--wh-active-bg); color: var(--wh-active-fg); }

.wh-principal-filter { display: flex; align-items: center; gap: 8px; padding: 8px 16px; flex: 0 0 auto;
  background: var(--wh-card-bg); border-bottom: 1px solid var(--wh-card-border); }
.wh-principal-filter label { color: var(--wh-text-soft); font-size: 1rem; font-weight: 700; white-space: nowrap; }
.wh-principal-filter label i { color: var(--wh-active-bg); margin-right: 4px; }
.wh-principal-filter select { min-width: 210px; max-width: 50vw; padding: 6px 32px 6px 10px; border: 1px solid var(--wh-divider);
  border-radius: 8px; background: var(--wh-card-bg); color: var(--wh-text); font: inherit; font-size: 1rem; font-weight: 600; }
.wh-principal-filter select:focus { outline: none; border-color: var(--wh-active-bg); box-shadow: 0 0 0 2px var(--wh-overlay); }

.wh-batch-selector { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex: 0 0 auto; }
.wh-batch-selector label { color: var(--wh-text-soft); font-size: 1rem; font-weight: 600; white-space: nowrap; }
.wh-batch-select { min-width: 190px; max-width: 100%; padding: 6px 32px 6px 11px; border: 1px solid var(--wh-divider);
  border-radius: 8px; background: var(--wh-card-bg); color: var(--wh-text); font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; }

/* Dropdown option styling — theme-aware using Warehouse variables */
.wh-principal-filter select option,
.wh-batch-select option {
    background: var(--wh-pop-bg);
    color: var(--wh-text);
}
.wh-principal-filter select option:checked,
.wh-batch-select option:checked {
    background: var(--wh-active-bg);
    color: var(--wh-active-fg);
}

.wh-batch-select:hover { border-color: var(--wh-overlay-strong); }
.wh-batch-select:focus { outline: none; border-color: var(--wh-active-bg); box-shadow: 0 0 0 2px var(--wh-overlay); }

/* Sized smaller than a normal KPI tile on purpose — this grid can grow past a
   dozen entries once an uncommon/newly-added Kintone status shows up (see
   KintoneDirectController::_principalCardFromCounts), and the Partner
   Comparison / donut section below it (.wh-bottom) needs the room more. */
.wh-statusgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 7px; margin-bottom: 10px; flex: 0 0 auto; }

/* Terminal and SIM status grids: 3 cards per row for larger tiles */
#sg-terminal.wh-statusgrid,
#sg-simcard.wh-statusgrid {
    grid-template-columns: repeat(3, 1fr);
}

/* PO Batch status grid: 3 columns × 5 rows for the 15 status cards */
#sg-pobatch.wh-statusgrid {
    grid-template-columns: repeat(3, 1fr);
}

/* Terminal Batches status card typography — scoped to #sg-pobatch so the
   Terminal and SIM Dashboard status cards (which use #sg-terminal and
   #sg-simcard) are NOT affected. */
#sg-pobatch .wh-stile-txt span {
    font-size: 1rem;       /* status label, was 0.80rem */
}
#sg-pobatch .wh-stile-txt b {
    font-size: 2rem;       /* numeric value, was 1.65rem */
}
#sg-pobatch .wh-stile {
    padding: 10px 12px;    /* slightly more padding for visual balance, was 8px 10px */
}

.wh-stile { display: flex; align-items: center; gap: 8px; background: var(--wh-overlay); border: 1px solid var(--wh-card-border);
  border-radius: 10px; padding: 8px 10px; }
.wh-stile-ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 0.85rem; flex: 0 0 auto; }
.wh-stile-txt { display: flex; flex-direction: column; min-width: 0; }
.wh-stile-txt span { font-size: 0.80rem; color: var(--wh-text-muted); font-weight: 700; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh-stile-txt b { font-size: 1.65rem; color: var(--wh-text); font-weight: 800; letter-spacing: -.02em; }

/* donut + comparison grows to fill the rest of the card and centers nicely */
.wh-bottom { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; flex: 1 1 auto; min-height: 0;
  border-top: 1px solid var(--wh-divider); padding-top: 14px; }
.wh-bottom--principal-comparison { grid-template-columns: 160px minmax(0, 1fr); gap: 12px; }
.wh-pobatch-layout { display: grid; gap: 20px; align-items: start; flex: 1 1 auto; min-height: 0; }
.wh-pobatch-layout--all {
    grid-template-columns:
        750px
        1500px
        100px;

    gap: 20px;
}

/* The outer tracks deliberately match the original all-batch layout so the
   status grid retains its existing width and six-card maximum per row. */
.wh-pobatch-all-side { grid-column: 2 / 4; display: grid; grid-template-columns: minmax(200px, max-content) 180px;
  gap: 75px; align-items: center; min-width: 0; }      /* gap here is ung layo ng pie chart sa batch comparison*/
.wh-pobatch-layout--selected { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
.wh-pobatch-layout > .wh-statusgrid { margin-bottom: 0; }
.wh-pobatch-primary { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.wh-pobatch-layout--selected .wh-statusgrid { grid-template-columns: repeat(5, minmax(128px, 1fr)); }
.wh-pobatch-side { min-width: 0; }
.wh-pobatch-side .wh-bottom { border-top: 0; padding-top: 0; }
.wh-pobatch-chart { align-self: center; transform: translateX(15px);}
.wh-pobatch-chart-row { display: grid; grid-template-columns: 180px minmax(420px, 560px); justify-content: center; gap: 5px; align-items: center; }
.wh-pobatch-status-head, .wh-pobatch-status-summary .wh-pobatch-status-row { display: grid; grid-template-columns: 18px minmax(150px, 1fr) 62px 120px; align-items: center; column-gap: 6px; }
.wh-pobatch-status-head { padding: 0 0 7px; border-bottom: 1px solid var(--wh-divider); color: var(--wh-text-muted); font-size: 1.1rem; font-weight: 700; }
.wh-pobatch-status-head span:nth-child(n + 3), .wh-pobatch-status-row .wh-cmp-stat { text-align: right; }
.wh-pobatch-status-title {font-size: 1.5rem; font-weight: 700; margin: 0; } /* added class to status title*/
.wh-pobatch-status-summary .wh-pobatch-status-row { gap: 0; }
.wh-pobatch-status-row .wh-cmp-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-donutbox { width: 180px; margin: 0 auto; text-align: center; display: flex; flex-direction: column; align-items: center; }
.wh-donut-chart { position: relative; width: 180px; height: 180px; flex: 0 0 auto; }
.wh-donut-chart canvas { width: 180px; height: 180px; }
.wh-donutc { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.wh-donutc b { font-size: 2.1rem; color: var(--wh-text); font-weight: 800; }
.wh-donut-label { margin-top: 12px; color: var(--wh-text); font-size: 1rem; font-weight: 500; line-height: 1.3; letter-spacing: 0.01em; }
.wh-compare {margin-left: 65px;} /* margin ng batch comparison (left side) */
.wh-compare h4 { margin: 0 0 10px; font-size: 1.15rem; color: var(--wh-text); }
.wh-cmp-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: 0.85rem; }
.wh-cmp-row:last-child { border-bottom: none; }
.wh-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.wh-cmp-name { font-size: 1.2rem; font-weight: 700; color: var(--wh-text-body); }
.wh-cmp-stat { color: var(--wh-text-muted); font-size: 1.2rem; } .wh-cmp-stat b { color: var(--wh-text-body); }

/* Terminal and SIM principal comparison: aligned data columns without table chrome. */
.wh-compare--principal { margin-left: 5px; min-width: 0; }
.wh-bottom--principal-comparison .wh-donutbox,
.wh-bottom--principal-comparison .wh-donut-chart,
.wh-bottom--principal-comparison .wh-donut-chart canvas { width: 160px; height: 160px; }
.wh-compare--principal .wh-cmp-list { max-height: 220px; overflow-y: hidden; overflow-x: hidden; padding-right: 4px;}
.wh-compare--principal .wh-cmp-list { scrollbar-color: var(--wh-text-muted) var(--wh-pop-bg); }
.wh-compare--principal .wh-cmp-list::-webkit-scrollbar-track { background: var(--wh-pop-bg); }
.wh-compare--principal .wh-cmp-list::-webkit-scrollbar-thumb { background: var(--wh-text-muted); }
.wh-compare--principal .wh-cmp-row{
    display:grid;
    grid-template-columns:
        10px      /* legend */
        115px      /* principal */
        43px      /* Total label */
        58px      /* Total value */
        55px      /* Active label */
        58px;     /* Active value */

    column-gap:8px;
    align-items:center;
}
.wh-compare--principal .wh-cmp-list:hover {
    overflow-y: auto;
}
.wh-compare--principal .wh-cmp-name { white-space: normal; word-break: normal; overflow-wrap: break-word }
.wh-compare--principal .wh-cmp-label { font-size: 1.2rem; color: var(--wh-text-muted); white-space: nowrap; text-align: left; }
.wh-compare--principal .wh-cmp-value {
    color: var(--wh-text-body);
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

/* PO Batch comparison table — grid layout with fixed column widths, mimicking
   the Principal Comparison table structure but with a header row and
   right-aligned numeric columns. */
.wh-compare--pobatch { margin-left: 65px; min-width: 0; }
.wh-compare--pobatch h4 { margin: 0 0 10px; font-size: 1.05rem; color: var(--wh-text); }
.wh-compare--pobatch .wh-cmp-list {
    overflow: hidden;
    padding-right: 4px;
}
.wh-cmp-header-row {
    display: grid;
    grid-template-columns: 10px 260px 95px 95px 105px;
    column-gap: 12px;
    align-items: center;
    padding: 4px 2px 8px;
    border-bottom: 1px solid var(--wh-divider);
    color: var(--wh-text-muted);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.wh-cmp-header-row span:nth-child(n+3) { text-align: right; }
.wh-compare--pobatch .wh-cmp-row {
    display: grid;
    grid-template-columns: 10px 260px 95px 95px 105px;
    column-gap: 12px;
    align-items: center;
    padding: 8px 2px;
    font-size: 1.2rem;
}
.wh-compare--pobatch .wh-cmp-row:last-child { border-bottom: none; }
.wh-compare--pobatch .wh-cmp-name {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    font-weight: 700;
    color: var(--wh-text-body);
    font-size: 1.2rem;
}
.wh-compare--pobatch .wh-cmp-stat {
    font-size: 1.2rem;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--wh-text-body);
}
.wh-compare--pobatch .wh-cmp-pct {
    font-size: 1rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--wh-text-muted);
}

.wh-fetched { margin-top: 8px; font-size: 0.9rem; color: var(--wh-text-faint); text-align: right; flex: 0 0 auto; }
.wh-fetched i { margin-right: 5px; font-size: 0.9rem; }

/* merchant region card — stacked vertically to fit a narrow column */
.wh-merch { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; }
.wh-map-frame { position: relative; width: 100%; flex: 1 1 38%; min-height: 0; border: 1px solid var(--wh-card-border);
  border-radius: 12px; background: radial-gradient(600px 300px at 60% 30%, var(--wh-map-glow), transparent 60%), var(--wh-overlay); overflow: hidden; }
.wh-map-label { position: absolute; top: 8px; left: 12px; font-size: 0.7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--wh-text-faint); }
.wh-pin { position: absolute; transform: translate(-50%, -50%); text-align: center; color: var(--wh-text-soft); }
.wh-pin > i { font-size: 1rem; color: var(--wh-text-faint); display: block; }
.wh-pin-rg { display: block; font-size: 0.62rem; letter-spacing: .04em; color: var(--wh-text-muted); margin-top: 1px; white-space: nowrap; }
.wh-pin-n { display: block; font-size: 0.92rem; font-weight: 800; color: var(--wh-text); }

/* Principal Merchant Overview — geographic cluster map and selected-principal table. */
.wh-principal-info { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--wh-overlay); border: 1px solid var(--wh-card-border); flex-wrap: wrap; }
.wh-principal-label { font-size: 0.72rem; font-weight: 700; color: var(--wh-text-muted); text-transform: uppercase; letter-spacing: .06em; }
.wh-principal-name { font-size: 1.05rem; font-weight: 750; color: var(--wh-text); }
.wh-principal-total { margin-left: auto; font-size: 0.82rem; color: var(--wh-text-soft); white-space: nowrap; }
.wh-principal-total b { color: var(--wh-text); font-weight: 750; }
.wh-merchant-map-layout { display: flex; flex: 1 1 auto; min-height: 0; align-items: stretch; gap: 14px; }
.wh-cluster-summary { position: absolute; z-index: 2; top: 12px; left: 12px; width: 160px; padding: 10px 11px; border: 1px solid var(--wh-card-border); border-radius: 10px;
  background: radial-gradient(280px 180px at 10% 0%, var(--wh-map-glow), transparent 72%), var(--wh-overlay); }
.wh-cluster-summary-row { display: grid; grid-template-columns: 10px minmax(0, 1fr); align-items: start; column-gap: 8px; padding: 6px 0; }
.wh-cluster-summary-row + .wh-cluster-summary-row { border-top: 1px solid var(--wh-divider); }
.wh-cluster-summary-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; }
.wh-cluster-summary b { display: block; color: var(--wh-text); font-size: 25px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.wh-cluster-summary span:not(.wh-cluster-summary-dot) { display: block; margin-top: 3px; color: var(--wh-text-muted); font-size: 15px; font-weight: 700; line-height: 1.15; letter-spacing: .06em; text-transform: uppercase; }
.wh-ph-map { position: relative; flex: 1 1 auto; min-width: 0; min-height: 300px; border: 1px solid var(--wh-card-border); border-radius: 12px;
  background: radial-gradient(600px 300px at 60% 30%, var(--wh-map-glow), transparent 60%), var(--wh-overlay); overflow: hidden; }
.wh-ph-map svg { display: block; width: 100%; height: 100%; min-height: 300px;
  /* Camera-style crop: enlarges the main archipelago while the existing
     overflow-hidden map frame naturally trims only distant edge islands. */
  transform: translateX(-3%) scale(1.16); transform-origin: 50% 50%; }
.wh-map-cluster { cursor: pointer; outline: none; }
.wh-map-cluster path { stroke: var(--wh-card-bg); stroke-width: 4; stroke-linejoin: round; transition: opacity .15s, transform .15s; transform-origin: center; }
.wh-map-cluster:hover path, .wh-map-cluster:focus path { opacity: .8; transform: scale(1.04); }
.wh-cluster-table { flex: 0 1 290px; min-width: 230px; padding: 12px 14px; border: 1px solid var(--wh-card-border); border-radius: 12px; background: var(--wh-overlay); }
.wh-cluster-selected { margin-bottom: 10px; font-size: 0.78rem; color: var(--wh-text-muted); }
.wh-cluster-selected strong { display: block; margin-top: 2px; color: var(--wh-text); font-size: 0.94rem; overflow-wrap: anywhere; }
.wh-cluster-table table { width: 100%; border-collapse: collapse; font-size: 0.76rem; }
.wh-cluster-table th { padding: 0 0 7px; color: var(--wh-text-muted); font-size: 0.66rem; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
.wh-cluster-table th:last-child, .wh-cluster-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.wh-cluster-table td { padding: 8px 0; border-top: 1px solid var(--wh-divider); color: var(--wh-text-soft); }
.wh-cluster-table td:last-child { color: var(--wh-text); font-weight: 800; }
.wh-cluster-total td { color: var(--wh-text) !important; font-weight: 800; }
.wh-cluster-swatch { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; }

.wh-chartcol { display: flex; flex-direction: column; flex: 1 1 62%; min-height: 0; }
.wh-totvol span { font-size: 0.7rem; color: var(--wh-text-muted); }
.wh-totvol b { display: block; font-size: 1.4rem; font-weight: 800; color: var(--wh-text); letter-spacing: -.02em; }
.wh-bars { flex: 1 1 auto; min-height: 0; display: flex; align-items: flex-end; justify-content: space-around; gap: 8px; padding: 8px 2px 0; }
.wh-barcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.wh-bar-total { font-size: 0.8rem; font-weight: 800; color: var(--wh-text); margin-bottom: 4px; }
.wh-stack { width: 100%; max-width: 46px; display: flex; flex-direction: column-reverse; height: calc(100% - 38px); justify-content: flex-start;
  border-radius: 6px 6px 0 0; overflow: hidden; }
.wh-seg { width: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 0.68rem; font-weight: 700; transition: height .5s ease; min-height: 0; }
.wh-bar-label { margin-top: 6px; font-size: 0.68rem; font-weight: 700; color: var(--wh-text-soft); text-align: center; }
.wh-legendrow { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; padding: 7px;
  background: var(--wh-overlay); border-radius: 8px; flex: 0 0 auto; }
.wh-leg { display: flex; align-items: center; gap: 6px; font-size: 0.7rem; color: var(--wh-text-soft); }

/* clickable status tiles + breakdown popover */
.wh-stile { cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.wh-stile:hover { background: var(--wh-overlay-strong); border-color: rgba(99,102,241,.55); transform: translateY(-1px); }
.wh-stile:focus-visible { outline: 2px solid var(--wh-focus); outline-offset: 1px; }
.wh-stile-go { margin-left: auto; font-size: 0.68rem; color: var(--wh-text-faint); opacity: 0; transition: opacity .15s; }
.wh-stile:hover .wh-stile-go { opacity: 1; }

.wh-pop { position: fixed; z-index: var(--z-tooltip, 9999); width: 400px; max-width: 92vw; background: var(--wh-pop-bg);
  border: 1px solid var(--wh-card-border); border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.35); padding: 14px 16px; color: var(--wh-text-body); }
.wh-pop-head { display: flex; align-items: center; gap: 10px; }
.wh-pop-ic { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 0.9rem; flex: 0 0 auto; }
.wh-pop-title { font-weight: 700; font-size: 1.3rem; }
.wh-pop-total { margin-left: auto; font-weight: 800; font-size: 1.3rem; }
.wh-pop-sub { font-size: 1.2rem; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--wh-text-muted); margin: 9px 0 10px; }
.wh-pop-row {
  display: grid;
  grid-template-columns: 20px 150px 1fr 45px 58px;
  column-gap: 4px;
  align-items: center;
  padding: 7px 0;
  font-size: 1.05rem;
}
.wh-pop-row.on { background: rgba(99,102,241,.14); border-radius: 6px; padding: 5px 8px; margin: 0 -8px; }
.wh-pop-row .wh-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  justify-self: center;
  margin-right: 0;
}
.wh-pop-name {
  font-weight: 600;
  color: var(--wh-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wh-pop-bar { height: 9px; background: var(--wh-overlay-strong); border-radius: 4px; overflow: hidden; }
.wh-pop-bar > i { display: block; height: 100%; border-radius: 4px; }
.wh-pop-val {
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.wh-pop-pct {
  color: var(--wh-text-muted);
  text-align: right;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

/* merchant interactive elements */
.wh-barcol { cursor: pointer; border-radius: 8px; transition: background .15s; }
.wh-barcol:hover { background: var(--wh-overlay); }
.wh-barcol:hover .wh-stack { outline: 2px solid rgba(99,102,241,.55); outline-offset: 2px; }
.wh-barcol:focus-visible { outline: 2px solid var(--wh-focus); outline-offset: 1px; }
.wh-leg { cursor: pointer; padding: 3px 7px; border-radius: 7px; transition: background .15s; }
.wh-leg:hover { background: var(--wh-overlay-strong); color: var(--wh-text); }
.wh-pin { cursor: pointer; }
.wh-pin:hover > i { color: var(--wh-pin-hover); transform: scale(1.12); }
.wh-pin > i { transition: transform .15s, color .15s; }

/* ─── MAIN DASHBOARD CARD TYPOGRAPHY ENLARGEMENT ────
   Increased font sizes by ~3px for all readable text inside dashboard cards
   on the Main Dashboard (scoped to .dashboard-grid). KPI numeric values (.value)
   are excluded and remain at their original size.                       */
.dashboard-grid .card-header {
  font-size: 1.24rem;   /* was 1.05rem — ~+3px */
}
.dashboard-grid .card-source-badge {
  font-size: 0.92rem;   /* was 0.73rem — ~+3px */
}
.dashboard-grid .detail-btn {
  font-size: 1.07rem;   /* was 0.88rem — ~+3px */
}
.dashboard-grid .tsms-period button {
  font-size: 0.93rem;   /* was 0.74rem — ~+3px */
}
.dashboard-grid .stats-row .label {
  font-size: 1.01rem;   /* was 0.82rem — ~+3px */
}
.dashboard-grid .comp-list {
  font-size: 1.05rem;   /* was 0.86rem — ~+3px */
}
.dashboard-grid .comp-pct {
  font-size: 1.2rem;   /* was 0.78rem — ~+3px */
}
.dashboard-grid .server-last-update {
  font-size: 0.92rem;   /* was 0.73rem — ~+3px */
}
.dashboard-grid .source-name {
  font-size: 1.05rem;   /* was 0.86rem — ~+3px */
}
.dashboard-grid .source-counts {
  font-size: 0.99rem;   /* was 0.8rem — ~+3px */
}
.dashboard-grid .trans-header {
  font-size: 1.11rem;   /* was 0.92rem — ~+3px */
}
.dashboard-grid .trans-row {
  font-size: 1.15rem;   /* was 0.96rem — ~+3px */
}
.dashboard-grid .card-status-tbl {
  font-size: 1.15rem;   /* was 0.96rem — ~+3px */
}
.dashboard-grid .card-status-tbl thead th {
  font-size: 1.01rem;   /* was 0.82rem — ~+3px */
}
.dashboard-grid .cst-pct {
  font-size: 1.07rem;   /* was 0.88rem — ~+3px */
}
.dashboard-grid .cst-label {
  font-size: 1.09rem;   /* was 0.9rem — ~+3px */
}
.dashboard-grid .cst-loading {
  font-size: 1.19rem;   /* default ~1rem — ~+3px */
}

/* Small screens: fall back to a single scrollable column rather than clipping. */
@media (max-width: 1000px) {
  .wh-body { height: auto; min-height: 100vh; overflow: auto; }
  .wh-scroll { overflow: visible; }
  .wh-wrap { grid-template-columns: 1fr; overflow: visible; min-height: 0; }
  .wh-card { height: auto; }
  .wh-merch { min-height: 420px; }
  .wh-pobatch-layout--all, .wh-pobatch-layout--selected { grid-template-columns: 1fr; }
  .wh-pobatch-all-side { grid-column: auto; grid-template-columns: minmax(0, 1fr) 180px; }
  .wh-pobatch-layout--selected .wh-statusgrid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .wh-principal-header { display: block; }
}
@media (max-width: 700px) {
  .wh-pobatch-all-side { grid-template-columns: 1fr; }
  .wh-pobatch-chart-row { grid-template-columns: 1fr; }
  .wh-principal-filter { padding: 8px; }
  .wh-principal-filter select { min-width: 0; flex: 1; }
  .wh-cluster-table { flex-basis: auto; min-width: 0; }
}

