/* ----------------------------------------------------------
   SHARED.CSS — Theme variables, layout, header, sidebar,
   profile dropdown, modals, toasts
---------------------------------------------------------- */

/* -- THEME VARIABLES -- */
[data-theme="dark"] {
  --cpGreen: #85a446;
  --cpBlue: #2187c6;
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2d3e;
  --text: #e5e7eb;
  --text-muted: #6b7280;
  --header-bg: #12151f;
  --sidebar-bg: #12151f;
  --sidebar-hover: #1e2130;
  --sidebar-active: rgba(59, 130, 246, 0.15);
  --sidebar-active-text: #60a5fa;
  --sidebar-icon: #6b7280;
  --api-note-bg: #12151f;
  --toggle-bg: #2a2d3e;
  --toggle-knob: #e5e7eb;
  --shadow: rgba(0, 0, 0, 0.5);
  --submenu-bg: rgba(0, 0, 0, 0.2);
  --dropdown-bg: #1e2130;
  --dropdown-border: #2a2d3e;
  --dropdown-hover: #252a3a;
  --input-bg: #0f1117;
}

[data-theme="light"] {
  --cpGreen: #85a446;
  --cpBlue: #2187c6;
  --bg: #f0f2f7;
  --card: #ffffff;
  --border: #dde1ea;
  --text: #111827;
  --text-muted: #6b7280;
  --header-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --sidebar-hover: #f3f4f6;
  --sidebar-active: rgba(59, 130, 246, 0.1);
  --sidebar-active-text: #2563eb;
  --sidebar-icon: #9ca3af;
  --api-note-bg: #f8f9fb;
  --toggle-bg: #d1d5db;
  --toggle-knob: #ffffff;
  --shadow: rgba(0, 0, 0, 0.12);
  --submenu-bg: rgba(0, 0, 0, 0.03);
  --dropdown-bg: #ffffff;
  --dropdown-border: #e5e7eb;
  --dropdown-hover: #f3f4f6;
  --input-bg: #ffffff;
}

/* -- BRAND COLORS -- */
[data-theme="dark"] .brand-clear,
[data-theme="dark"] .brand-path { color: #fff; }
[data-theme="light"] .brand-clear { color: #85c446; }
[data-theme="light"] .brand-path  { color: #2187c6; }
.brand-clear, .brand-path { font-family: Arial, sans-serif; font-weight: 600; }
.brand-group { display: flex; flex-direction: column; }
.brand-slogan { font-size: .65rem; color: var(--text-muted); font-style: italic; margin-top: -.15rem; line-height: 1; letter-spacing: 0.09rem; }
.brand-logo { width: 210px; height: auto; display: block; }
.brand-group h1 .brand-logo + .brand-clear,
.brand-group h1 .brand-logo + .brand-clear + .brand-path { display: none; }

/* -- TABLE LOADING OVERLAY -- */
.table-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .5rem;
  background: var(--card); z-index: 10; border-radius: inherit;
}
.table-loading-spinner {
  width: 36px; height: 36px; border: 4px solid var(--border);
  border-top-color: #3b82f6; border-radius: 50%;
  animation: tbl-spin .8s linear infinite;
}
.table-loading span { font-size: .82rem; color: var(--text-muted); }
@keyframes tbl-spin { to { transform: rotate(360deg); } }

/* -- RESET & BASE -- */
*, *::before, *::after {
  box-sizing: border-box;
  transition: background-color .3s, border-color .3s, color .2s;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  margin: 0;
  overflow-x: hidden;
}

/* -- LAYOUT -- */
.app-shell   { display: flex; flex-direction: column; height: 100vh; }
.app-body    { display: flex; flex: 1; overflow: hidden; }
.main-content { flex: 1; overflow-y: auto; padding: 1.5rem; }

/* -- HEADER -- */
.db-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 1px 8px var(--shadow);
  z-index: 200;
  flex-shrink: 0;
}
.db-header h1 { font-size: 2.4rem; font-weight: 400; margin: 0; white-space: nowrap; }
.header-left, .header-right { display: flex; align-items: center; gap: .85rem; }

.hamburger {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem;
  padding: .3rem .4rem; border-radius: 6px; line-height: 1;
}
.hamburger:hover { color: var(--text); background: var(--sidebar-hover); }

/* Live badge */
.live-badge {
  background: rgba(34, 197, 94, .15); color: #22c55e;
  border: 1px solid rgba(34, 197, 94, .3);
  padding: .2rem .65rem; border-radius: 999px;
  font-size: .7rem; font-weight: 600;
  display: flex; align-items: center; gap: .35rem; white-space: nowrap;
}
.live-badge::before {
  content: ''; width: 6px; height: 6px;
  background: #22c55e; border-radius: 50%;
  animation: blink 1.5s infinite; flex-shrink: 0;
}
.live-badge.offline {
  background: rgba(239, 68, 68, .15); color: #ef4444;
  border-color: rgba(239, 68, 68, .3);
}
.live-badge.offline::before { background: #ef4444; animation: none; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Subscription expiry alert */
.subscription-alert {
  padding: .2rem .65rem; border-radius: 999px;
  font-size: .7rem; font-weight: 600;
  display: flex; align-items: center; gap: .35rem; white-space: nowrap;
}
.subscription-warning {
  background: rgba(234, 179, 8, .15); color: #ca8a04;
  border: 1px solid rgba(234, 179, 8, .3);
}
.subscription-critical {
  background: rgba(239, 68, 68, .15); color: #ef4444;
  border: 1px solid rgba(239, 68, 68, .3);
  animation: blink 1.5s infinite;
}
.subscription-expired {
  background: rgba(239, 68, 68, .2); color: #ef4444;
  border: 1px solid rgba(239, 68, 68, .4);
  animation: blink 1s infinite;
}

/* Theme toggle */
.theme-toggle-wrap { display: flex; align-items: center; gap: .45rem; }
.theme-icon-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.05rem; cursor: pointer; padding: .3rem .5rem;
  border-radius: 6px; line-height: 1; transition: background .15s, color .15s;
}
.theme-icon-btn:hover { background: var(--sidebar-hover); color: var(--text); }
.toggle-switch { position: relative; width: 44px; height: 24px; cursor: pointer; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--toggle-bg); border-radius: 999px; border: 1px solid var(--border);
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--toggle-knob); transition: transform .3s;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
input:checked + .toggle-track { background: #3b82f6; border-color: #3b82f6; }
input:checked + .toggle-track::after { transform: translateX(20px); }

/* -- MOBILE SWITCH BUTTON -- */
.mobile-switch-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.1rem; cursor: pointer; padding: .3rem .5rem;
  border-radius: 6px; line-height: 1; transition: background .15s, color .15s;
}
.mobile-switch-btn:hover { background: var(--sidebar-hover); color: var(--text); }

/* Hide live badge, mobile switch, and theme toggle on narrow screens */
@media (max-width: 680px) {
  .live-badge,
  .mobile-switch-btn,
  .theme-toggle-wrap { display: none !important; }
}

/* -- PROFILE BUTTON -- */
.profile-wrap { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: .55rem;
  background: none; border: 1.5px solid var(--border);
  border-radius: 999px; padding: .3rem .75rem .3rem .3rem;
  cursor: pointer; color: var(--text);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.profile-btn:hover { border-color: #3b82f6; background: var(--sidebar-hover); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.profile-btn.open  { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.profile-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; color: #fff; flex-shrink: 0; position: relative;
}
.profile-avatar .status-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; border: 1.5px solid var(--header-bg);
}
.profile-info    { display: flex; flex-direction: column; line-height: 1.2; }
.profile-name    { font-size: .8rem; font-weight: 600; white-space: nowrap; }
.profile-title   { font-size: .65rem; color: var(--text-muted); white-space: nowrap; }
.profile-chevron { font-size: .7rem; color: var(--text-muted); transition: transform .25s; }
.profile-btn.open .profile-chevron { transform: rotate(180deg); }

/* -- PROFILE DROPDOWN -- */
.profile-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0; width: 240px;
  background: var(--dropdown-bg); border: 1px solid var(--dropdown-border);
  border-radius: 14px; box-shadow: 0 12px 40px var(--shadow);
  opacity: 0; transform: translateY(-8px) scale(.97);
  pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 500; overflow: hidden;
}
.profile-dropdown.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }

.dd-header {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  padding: 1.1rem 1.1rem .9rem; display: flex; align-items: center; gap: .75rem;
}
.dd-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.25); display: flex; align-items: center;
  justify-content: center; font-size: .9rem; font-weight: 700; color: #fff;
  flex-shrink: 0; border: 2px solid rgba(255,255,255,.4);
}
.dd-name  { font-size: .88rem; font-weight: 700; color: #fff; }
.dd-email { font-size: .72rem; color: rgba(255,255,255,.75); }
.dd-role-badge {
  display: inline-flex; align-items: center; margin-top: .2rem;
  background: rgba(255,255,255,.2); color: #fff;
  font-size: .62rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px;
}
.dd-section { padding: .4rem 0; }
.dd-divider { height: 1px; background: var(--dropdown-border); margin: 0; }
.dd-label {
  font-size: .64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); padding: .5rem 1rem .25rem;
}
.dd-item {
  display: flex; align-items: center; gap: .7rem; padding: .55rem 1rem;
  font-size: .82rem; font-weight: 500; color: var(--text);
  cursor: pointer; text-decoration: none; transition: background .15s;
}
.dd-item:hover { background: var(--dropdown-hover); color: var(--text); }
.dd-item:hover .dd-item-icon { color: #3b82f6; }
.dd-item.danger { color: #ef4444; }
.dd-item.danger:hover { background: rgba(239,68,68,.08); }
.dd-item.danger:hover .dd-item-icon { color: #ef4444; }
.dd-item-icon { font-size: .95rem; color: var(--text-muted); width: 18px; text-align: center; flex-shrink: 0; transition: color .15s; }
.dd-item-text { flex: 1; }
.dd-item-badge { font-size: .62rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; background: #3b82f6; color: #fff; }
.dd-item-badge.warn { background: #f97316; }
.dd-status-row { display: flex; align-items: center; justify-content: space-between; padding: .5rem 1rem; }
.dd-status-label { font-size: .75rem; color: var(--text-muted); }
.dd-status-pill { display: flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; color: #22c55e; }
.dd-status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }

/* -- SIDEBAR -- */
.sidebar {
  width: 250px; background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto; overflow-x: hidden;
  transition: width .3s cubic-bezier(.4,0,.2,1), opacity .3s;
}
.sidebar.collapsed { width: 0; opacity: 0; pointer-events: none; }
.sidebar-section { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section-label {
  font-size: .65rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted);
  padding: .6rem 1.1rem .3rem; white-space: nowrap; overflow: hidden;
}
.nav-link-custom {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1.1rem; cursor: pointer; text-decoration: none;
  color: var(--text); font-size: .85rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; user-select: none;
}
.nav-link-custom:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-link-custom.active { background: var(--sidebar-active); color: var(--sidebar-active-text); }
.nav-link-custom.active .nav-icon { color: var(--sidebar-active-text); }
.nav-icon  { font-size: 1rem; color: var(--sidebar-icon); flex-shrink: 0; width: 18px; text-align: center; }
.nav-text  { flex: 1; }
.nav-badge { background: #3b82f6; color: #fff; font-size: .6rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; }
.nav-badge.badge-warn   { background: #f97316; }
.nav-badge.badge-danger { background: #ef4444; }
.nav-chevron { font-size: .7rem; color: var(--text-muted); transition: transform .25s; flex-shrink: 0; }
.nav-chevron.open { transform: rotate(90deg); }
.submenu { background: var(--submenu-bg); overflow: hidden; max-height: 0; transition: max-height .3s cubic-bezier(.4,0,.2,1); }
.submenu.open { max-height: 900px; }
.submenu-link {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem 1.1rem .45rem 2.6rem;
  font-size: .8rem; color: var(--text-muted); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.submenu-link:hover { background: var(--sidebar-hover); color: var(--text); }
.submenu-link.active { color: var(--sidebar-active-text); }
.submenu-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; opacity: .6; }

/* -- NESTED SUBMENU GROUP (e.g. Custom Audits) -- */
.submenu-group-hdr {
  display: flex; align-items: center; gap: .45rem;
  padding: .38rem 1.1rem .38rem 2.0rem;
  font-size: .79rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; user-select: none;
  transition: background .15s, color .15s;
}
.submenu-group-hdr:hover { background: var(--sidebar-hover); color: var(--text); }
.submenu-group-icon { font-size: .8rem; flex-shrink: 0; }
.submenu-group-chevron { font-size: .6rem; margin-left: auto; flex-shrink: 0; transition: transform .2s; }
.submenu-group-chevron.open { transform: rotate(90deg); }
.submenu-group-list { overflow: hidden; max-height: 0; transition: max-height .25s cubic-bezier(.4,0,.2,1); }
.submenu-group-list.open { max-height: 500px; }
.submenu-group-link {
  display: flex; align-items: center; gap: .5rem;
  padding: .38rem 1.1rem .38rem 3.2rem;
  font-size: .78rem; color: var(--text-muted); text-decoration: none; white-space: nowrap;
  transition: background .15s, color .15s;
}
.submenu-group-link:hover { background: var(--sidebar-hover); color: var(--text); }
.submenu-group-link.active { color: var(--sidebar-active-text); }
.sidebar-footer {
  margin-top: auto; padding: .85rem 1.1rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .65rem;
}
.s-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar-name { font-size: .78rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar-role { font-size: .67rem; color: var(--text-muted); white-space: nowrap; }

/* -- MODALS -- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; width: 100%; max-width: 460px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  transform: translateY(16px) scale(.97); transition: transform .25s; overflow: hidden;
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }
.modal-header { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h5 { margin: 0; font-size: .95rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; padding: .2rem .4rem; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: var(--sidebar-hover); }
.modal-body   { padding: 1.4rem; }
.modal-footer { padding: .9rem 1.4rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }

.profile-banner {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 12px; padding: 1.2rem;
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem;
}
.profile-banner-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.25); display: flex; align-items: center;
  justify-content: center; font-size: 1.1rem; font-weight: 700; color: #fff;
  border: 2px solid rgba(255,255,255,.45); flex-shrink: 0;
}
.profile-banner-name  { font-size: 1rem; font-weight: 700; color: #fff; }
.profile-banner-email { font-size: .75rem; color: rgba(255,255,255,.75); }

.modal-tabs { display: flex; gap: .25rem; margin-bottom: 1.2rem; background: var(--bg); padding: .3rem; border-radius: 10px; }
.modal-tab  { flex: 1; padding: .45rem; text-align: center; font-size: .78rem; font-weight: 600; color: var(--text-muted); border-radius: 7px; cursor: pointer; border: none; background: none; }
.modal-tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px var(--shadow); }
.tab-panel        { display: none; }
.tab-panel.active { display: block; }

.field-group  { margin-bottom: 1rem; }
.field-label  { font-size: .75rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; display: block; text-transform: uppercase; letter-spacing: .06em; }
.field-input  { width: 100%; padding: .55rem .8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: .85rem; outline: none; }
.field-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.field-row    { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }

.pref-row { display: flex; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.pref-row:last-child { border-bottom: none; }
.pref-label { font-size: .83rem; font-weight: 500; }
.pref-sub   { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }

.notif-item { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-icon { font-size: 1rem; width: 20px; text-align: center; }
.notif-text { flex: 1; font-size: .82rem; }
.notif-toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.notif-toggle input { opacity: 0; width: 0; height: 0; }
.notif-track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; }
.notif-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .25s; }
.notif-toggle input:checked + .notif-track { background: #3b82f6; }
.notif-toggle input:checked + .notif-track::after { transform: translateX(16px); }

/* -- SHARED BUTTONS -- */
.btn-primary-custom   { background: linear-gradient(135deg,#3b82f6,#2563eb); color: #fff; border: none; padding: .55rem 1.2rem; border-radius: 8px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.btn-primary-custom:hover { opacity: .9; }
.btn-secondary-custom { background: var(--bg); color: var(--text); border: 1px solid var(--border); padding: .55rem 1.2rem; border-radius: 8px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.btn-secondary-custom:hover { background: var(--sidebar-hover); }
.btn-danger-custom    { background: rgba(239,68,68,.1); color: #ef4444; border: 1px solid rgba(239,68,68,.25); padding: .55rem 1.2rem; border-radius: 8px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.btn-danger-custom:hover { background: rgba(239,68,68,.18); }

.logout-icon-wrap   { text-align: center; margin-bottom: 1rem; }
.logout-icon-circle { width: 56px; height: 56px; border-radius: 50%; background: rgba(239,68,68,.12); display: inline-flex; align-items: center; justify-content: center; font-size: 1.4rem; color: #ef4444; }

/* -- TOAST -- */
.toast-wrap { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--dropdown-bg); border: 1px solid var(--dropdown-border);
  border-radius: 10px; padding: .75rem 1.1rem; font-size: .82rem;
  box-shadow: 0 8px 24px var(--shadow);
  display: flex; align-items: center; gap: .65rem;
  animation: slideIn .25s ease; min-width: 220px;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { border-left: 3px solid #22c55e; }
.toast.info    { border-left: 3px solid #3b82f6; }
.toast-icon    { font-size: 1rem; }

/* -- SHARED JS UTIL CLASS -- */
.api-note { background: var(--api-note-bg); border: 1px solid var(--border); border-radius: 10px; padding: .75rem 1.1rem; font-size: .77rem; color: var(--text-muted); }
.api-note code { color: #3b82f6; background: rgba(59,130,246,.1); padding: .1rem .35rem; border-radius: 4px; }
/* ── THREE-DOT MENU (shared) ── */
.dot-menu-wrap { position: relative; }
.dot-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem;
  padding: .25rem .4rem; border-radius: 6px; line-height: 1;
  transition: color .15s, background .15s;
}
.dot-btn:hover { color: var(--text); background: var(--sidebar-hover); }
.dot-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  min-width: 185px; width: auto; background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border); border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow);
  opacity: 0; transform: translateY(-6px) scale(.97);
  pointer-events: none; transition: opacity .15s, transform .15s; z-index: 300;
}
.dot-menu.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }
.dot-menu.fixed-pos { position: fixed; }
.dot-menu-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .8rem; font-size: .8rem; font-weight: 500;
  color: var(--text); cursor: pointer; transition: background .12s;
  white-space: nowrap;
}
.dot-menu-item:first-child { border-radius: 10px 10px 0 0; }
.dot-menu-item:last-child  { border-radius: 0 0 10px 10px; }
.dot-menu-item:hover { background: var(--dropdown-hover); }
.dot-menu-item.disabled { opacity: .35; pointer-events: none; cursor: not-allowed; }
.dot-menu-item.danger { color: #ef4444; }
.dot-menu-item.danger:hover { background: rgba(239,68,68,.08); }
.dot-menu-item i { font-size: .85rem; width: 16px; text-align: center; flex-shrink: 0; }
.dot-menu-id { font-family: monospace; font-size: .7rem; color: var(--text-muted); margin-left: auto; }
.dot-divider { height: 1px; background: var(--dropdown-border); margin: .2rem 0; }

/* ── WIDGET THREE-DOT MENU ── */
.widget-menu-wrap { position:absolute; top:.55rem; right:.55rem; z-index:10; }
.widget-dot-btn {
  background:none; border:none; cursor:pointer;
  color:#fff; font-size:1rem;
  padding:.2rem .35rem; border-radius:6px; line-height:1;
  transition:color .15s, background .15s; opacity:.5;
}
.widget-dot-btn:hover { color:var(--text); background:var(--sidebar-hover); opacity:1; }
.gauge-card:hover .widget-dot-btn { opacity:1; }
.widget-dot-menu {
  /* position:fixed keeps it outside gauge-card's overflow:hidden */
  position:fixed; top:0; right:0;
  min-width:165px; background:var(--dropdown-bg);
  border:1px solid var(--dropdown-border); border-radius:10px;
  box-shadow:0 8px 24px var(--shadow);
  opacity:0; pointer-events:none; z-index:400;
}
.widget-dot-menu.open { opacity:1; pointer-events:all; }
.widget-menu-item {
  display:flex; align-items:center; gap:.55rem;
  padding:.48rem .85rem; font-size:.82rem; font-weight:500;
  color:var(--text); cursor:pointer; transition:background .12s; white-space:nowrap;
}
.widget-menu-item:first-child { border-radius:10px 10px 0 0; }
.widget-menu-item:last-child  { border-radius:0 0 10px 10px; }
.widget-menu-divider { height:1px; background:var(--dropdown-border); margin:.2rem 0; }
.widget-menu-item:hover { background:var(--dropdown-hover); }

/* ── Timespan flyout ── */
.widget-menu-item.has-sub { position:relative; }
.widget-menu-item.has-sub .wm-arrow { margin-left:auto; font-size:.7rem; opacity:.55; }
.widget-sub-menu {
  position:absolute; right:calc(100% + 2px); top:-1px;
  min-width:210px; max-height:min(72vh, 500px);
  overflow-y:auto; overflow-x:hidden;
  background:var(--dropdown-bg); border:1px solid var(--dropdown-border);
  border-radius:10px; box-shadow:0 8px 24px var(--shadow);
  z-index:500; opacity:0; pointer-events:none; transition:opacity .12s;
}
/* Transparent bridge covers the 2px gap so :hover stays active on mouse travel */
.widget-sub-menu::after {
  content:''; position:absolute; right:-4px; top:0; width:4px; height:100%;
}
.widget-menu-item.has-sub:hover .widget-sub-menu {
  opacity:1; pointer-events:all;
}
.widget-sub-item {
  display:flex; align-items:center;
  padding:.42rem .85rem; font-size:.8rem; font-weight:500;
  color:var(--text); cursor:pointer; transition:background .12s; white-space:nowrap;
}
.widget-sub-item:hover { background:var(--dropdown-hover); }
.widget-sub-item.active { color:#3b82f6; font-weight:700; }
.widget-sub-item .chk { margin-left:auto; font-size:.75rem; color:#3b82f6; padding-left:.5rem; }
.widget-sub-menu::-webkit-scrollbar { width:4px; }
.widget-sub-menu::-webkit-scrollbar-track { background:transparent; }
.widget-sub-menu::-webkit-scrollbar-thumb { background:var(--border); border-radius:999px; }
.widget-span-badge { display:none; }

/* ══════════════════════════════════════════════════════════════
   SHARED LIST PAGE STYLES
   Consolidated from notes.css and per-page CSS files.
   ══════════════════════════════════════════════════════════════ */

/* ── BUTTONS ── */
.btn-primary-sm {
  background: linear-gradient(135deg, #2187c6, #1a6fa0);
  color: #fff; border: none; padding: .45rem 1rem;
  border-radius: 8px; font-size: .8rem; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.btn-primary-sm:hover { opacity: .9; }
.btn-primary-sm:disabled { opacity: .55; cursor: not-allowed; }
.btn-danger-sm {
  background: rgba(239,68,68,.1); color: #ef4444; border: 1px solid rgba(239,68,68,.25);
  padding: .45rem 1rem; border-radius: 8px; font-size: .8rem; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.btn-danger-sm:hover { background: rgba(239,68,68,.18); }

/* ── TOOLBAR ── */
.search-box { position: relative; flex: 1; min-width: 180px; max-width: 260px; }
.search-box input {
  width: 100%; padding: .45rem .75rem .45rem 2.1rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .82rem; outline: none;
}
.search-box input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.search-box i { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; pointer-events: none; }
.filter-select {
  padding: .45rem .65rem; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: .8rem; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: #3b82f6; }
.btn-icon {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .65rem;
  cursor: pointer; color: var(--text-muted); font-size: .9rem;
  transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--text); background: var(--sidebar-hover); }
.toolbar-divider { width: 1px; height: 26px; background: var(--border); margin: 0 .1rem; flex-shrink: 0; }

/* ── STAT CHIPS ── */
.stat-chip {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: .75rem 1rem;
  display: flex; align-items: center; gap: .65rem;
}
.stat-chip-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; flex-shrink: 0;
}
.stat-chip-val { font-size: 1.1rem; font-weight: 700; }
.stat-chip-lbl { font-size: .68rem; color: var(--text-muted); }

/* ── TABLE CARD ── */
.table-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.table-card-header {
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
}
.table-card-title { font-size: .82rem; font-weight: 700; }
.per-page-wrap { display: flex; align-items: center; gap: .45rem; font-size: .78rem; color: var(--text-muted); }
.per-page-select { padding: .28rem .5rem; background: var(--card); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: .78rem; outline: none; cursor: pointer; }
.per-page-select:focus { border-color: #3b82f6; }

/* ── PAGINATION ── */
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.1rem; border-top: 1px solid var(--border);
  flex-wrap: wrap; gap: .6rem;
}
.pagination-info { font-size: .78rem; color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: .4rem; }
.page-btn {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-size: .78rem; font-weight: 600; padding: .3rem .65rem;
  border-radius: 6px; cursor: pointer; min-width: 32px; text-align: center;
  transition: background .15s, border-color .15s, color .15s;
}
.page-btn:hover:not(:disabled) { background: var(--sidebar-hover); border-color: #3b82f6; color: #3b82f6; }
.page-btn.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── BULK BAR ── */
.bulk-bar {
  display: none; align-items: center; gap: .75rem;
  background: rgba(59,130,246,.08); border: 1px solid rgba(59,130,246,.2);
  border-radius: 8px; padding: .5rem 1rem; margin-bottom: 1rem; font-size: .82rem;
}
.bulk-bar.visible, .bulk-bar.show { display: flex; }
.bulk-count { font-weight: 700; color: #3b82f6; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; opacity: .3; }

/* ── FACILITY SECTION ROW ── */
.facility-section-row td { background: var(--table-stripe); font-weight: 700; font-size: .78rem; color: var(--text-muted); padding: .5rem 1rem !important; }
.facility-section-row td i { margin-right: .4rem; }
