/* ═══════════════════════════════════════════════════════════════════════════
   ELEMENT Web Frontend — Main Stylesheet
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* ── Brand colours ── */
  --primary:          #007D88;
  --primary-light:    #00a8b5;
  --primary-dark:     #005f69;
  --primary-dim:      rgba(0,125,136,.15);
  --primary-alpha:    rgba(0,125,136,.15);
  --primary-glow:     rgba(0,125,136,.35);
  --accent:           #18DDEF;
  --danger:           #FF4B4B;
  --danger-dim:       rgba(255,75,75,.15);
  --warning:          #FFC400;
  --success:          #00D67F;
  --success-dim:      rgba(0,214,127,.15);
  --info:             #18DDEF;

  /* ── Layout ── */
  --sidebar-w:        270px;
  --sidebar-width:    270px;
  --sidebar-collapsed:72px;
  --topbar-h:         64px;
  --header-height:    64px;

  /* ── Radii ── */
  --radius:           0.5rem;
  --radius-sm:        0.375rem;
  --radius-lg:        0.75rem;
  --radius-xl:        1.25rem;
  --border-radius:    0.5rem;
  --border-radius-sm: 0.375rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1.25rem;

  /* ── Motion ── */
  --transition:       all 0.22s cubic-bezier(0.4,0,0.2,1);
  --transition-fast:  all 0.14s ease;

  /* ── Typography ── */
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* ── Shadows ── */
  --shadow-sm:      0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow:         0 4px 12px rgba(0,0,0,.15), 0 2px 4px rgba(0,0,0,.1);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  --shadow-primary: 0 4px 20px rgba(0,125,136,.35);
}

/* ── Dark theme (default) ── */
[data-theme="dark"] {
  --bg:           #12151a;
  --bg-2:         #1a1e26;
  --bg-3:         #1e2330;
  --surface:      #1e2330;
  --surface-2:    #252b38;
  --border:       #2d3446;
  --border-light: #232937;
  --border-focus: rgba(0,125,136,.5);

  --text:         #e8eaf0;
  --text-2:       #8b93a7;
  --text-muted:   #5a6278;

  --sidebar-bg:   #161b24;
  --header-bg:    #1a1e26;

  --scrollbar-bg:    #1a1e26;
  --scrollbar-thumb: #2d3446;

  /* aliases for ported components */
  --bg-base:        #12151a;
  --bg-elevated:    #1a1e26;
  --bg-card:        #1e2330;
  --bg-hover:       #252b38;
  --bg-input:       #252b38;
  --text-primary:   #e8eaf0;
  --text-secondary: #8b93a7;
  --border-color:   #2d3446;
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg:           #f0f2f7;
  --bg-2:         #ffffff;
  --bg-3:         #e8edf5;
  --surface:      #ffffff;
  --surface-2:    #f5f6fa;
  --border:       #e2e6ef;
  --border-light: #edf0f7;
  --border-focus: rgba(0,125,136,.4);

  --text:         #1e2330;
  --text-2:       #5a6278;
  --text-muted:   #9ba3b8;

  --sidebar-bg:   #ffffff;
  --header-bg:    #ffffff;

  --scrollbar-bg:    #f0f2f7;
  --scrollbar-thumb: #d0d5e0;

  /* aliases */
  --bg-base:        #f0f2f7;
  --bg-elevated:    #ffffff;
  --bg-card:        #ffffff;
  --bg-hover:       #f5f6fa;
  --bg-input:       #ffffff;
  --text-primary:   #1e2330;
  --text-secondary: #5a6278;
  --border-color:   #e2e6ef;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 0.9375rem;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, textarea, select { font-family: var(--font); }
ul, ol { list-style: none; }
img, svg { display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg, var(--bg-2)); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb, var(--border)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Typography helpers */
h1 { font-size: 1.625rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem;     font-weight: 600; }
h5 { font-size: 0.875rem; font-weight: 600; }
.text-sm      { font-size: 0.8125rem; }
.text-xs      { font-size: 0.75rem; }
.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-2); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.font-600 { font-weight: 600; }
.font-700 { font-weight: 700; }

/* ── Loading screen ──────────────────────────────────────────────────────── */
.loading-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 9999;
}
.loading-inner { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.loading-logo { animation: pulse 2s ease-in-out infinite; }
.loading-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--primary-dim);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:.6; } 50% { opacity:1; } }

/* ── App shell ───────────────────────────────────────────────────────────── */
.app-shell, .app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info,
.sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-head, .sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 0.625rem; overflow: hidden; white-space: nowrap; }
.logo-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-alpha);
  border-radius: 0.5rem; flex-shrink: 0;
}
.logo-text {
  font-size: 1.0625rem; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text); transition: var(--transition);
}
.sidebar-toggle {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--border-radius-sm);
  color: var(--text-muted); transition: var(--transition-fast); flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-toggle svg { transition: transform 0.25s ease; }

.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.nav-section { display: flex; flex-direction: column; gap: 0.125rem; margin-bottom: 1rem; }
.nav-label {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); padding: 0 0.625rem 0.375rem;
  display: block; white-space: nowrap; overflow: hidden; transition: var(--transition);
}
.sidebar.collapsed .nav-label { height: 0; padding: 0; margin: 0; }

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--border-radius);
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  transition: var(--transition-fast);
  position: relative; white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item:hover .nav-icon { transform: translateX(3px); }
.nav-item.active { background: var(--primary-alpha); color: var(--primary-light); }
.nav-item.active .nav-icon { color: var(--primary); }

.nav-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: inherit; transition: transform 0.2s ease;
}
.nav-text { flex: 1; transition: var(--transition); overflow: hidden; }
.nav-badge {
  font-size: 0.6875rem; font-weight: 600;
  background: var(--bg-hover); color: var(--text-secondary);
  padding: 0.1rem 0.4rem; border-radius: 99px; flex-shrink: 0;
  transition: var(--transition);
}
.nav-badge--danger, .nav-badge-danger { background: rgba(255,75,75,.2); color: var(--danger); }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); flex-shrink: 0; margin-left: auto;
  box-shadow: 0 0 6px var(--success);
  animation: pulse-dot 2s infinite;
}
.status-dot.warning  { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.danger   { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }
.status-dot.inactive, .status-dot.disconnected { background: var(--text-muted); box-shadow: none; animation: none; }
.status-dot.connecting { background: var(--warning); animation: pulse 1.5s infinite; }
.status-dot.connected  { background: var(--success); box-shadow: 0 0 0 3px rgba(0,214,127,.2); }
.status-dot.active     { background: var(--success); box-shadow: 0 0 5px var(--success); }
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:.5} }

.sidebar-foot, .sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 0.75rem; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.ws-status {
  display: flex; align-items: center; gap: 6px;
  font-size: .75rem; color: var(--text-muted);
}
.user-card {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem; border-radius: var(--border-radius);
  transition: var(--transition-fast); cursor: default;
}
.user-card:hover { background: var(--bg-hover); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem; font-weight: 700;
  background: var(--primary-alpha); color: var(--primary);
  flex-shrink: 0; text-transform: uppercase;
}
.user-info { flex: 1; min-width: 0; overflow: hidden; transition: var(--transition); }
.user-name {
  display: block; font-size: 0.875rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; }
.btn-icon-sm {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--border-radius-sm); color: var(--text-muted); transition: var(--transition-fast); flex-shrink: 0;
}
.btn-icon-sm:hover { background: var(--bg-hover); color: var(--danger); }

/* ── Main wrap ───────────────────────────────────────────────────────────── */
.main-wrap, .main-content {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.4,0,0.2,1);
}
.sidebar.collapsed ~ .main-wrap { margin-left: var(--sidebar-collapsed); }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar, .top-header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky; top: 0; z-index: 50;
  flex-shrink: 0;
}
.page-title { font-size: 1.0625rem; font-weight: 700; color: var(--text); flex: 1; }
.topbar-right, .header-right { display: flex; align-items: center; gap: 0.625rem; }
.header-left { display: flex; align-items: center; gap: 0.875rem; }
.header-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem; font-weight: 700;
  background: var(--primary-alpha); color: var(--primary);
  cursor: pointer; flex-shrink: 0;
}

/* ── Topbar search ─────────────────────────────────────────────────── */
.topbar-search-wrap {
  position: relative; display: flex; align-items: center;
}
.topbar-search-icon {
  position: absolute; left: 9px; color: var(--text-muted); pointer-events: none; flex-shrink: 0;
}
.topbar-search {
  height: 30px; padding: 0 10px 0 28px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .8rem; font-family: inherit; width: 180px;
  transition: var(--transition);
}
.topbar-search::placeholder { color: var(--text-muted); }
.topbar-search:focus { outline: none; border-color: var(--primary); width: 220px; background: var(--surface); }

/* ── Topbar language switcher ──────────────────────────────────────── */
.topbar-lang-wrap { position: relative; }
.topbar-lang-btn {
  display: flex; align-items: center; gap: .3rem;
  height: 30px; padding: 0 .55rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-2);
  font-size: .75rem; font-weight: 600; letter-spacing: .04em;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.topbar-lang-btn:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.topbar-lang-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 155px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 10px 28px rgba(0,0,0,.2);
  padding: .3rem; z-index: 200;
}
.topbar-lang-option {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .45rem .65rem;
  background: transparent; border: none;
  color: var(--text); font-size: .8125rem; font-weight: 500;
  border-radius: calc(var(--radius-lg) - 4px);
  cursor: pointer; text-align: left; transition: var(--transition);
}
.topbar-lang-option:hover:not([disabled]) { background: var(--surface-2); }
.topbar-lang-option.active  { color: var(--primary); font-weight: 600; }
.topbar-lang-option[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Topbar notifications ──────────────────────────────────────────── */
.topbar-notif-wrap { position: relative; }
.topbar-notif-btn  { position: relative; }
.topbar-notif-badge {
  position: absolute; top: 0; right: 0;
  min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--danger); color: #fff;
  font-size: .6rem; font-weight: 700; line-height: 16px;
  text-align: center; padding: 0 3px;
  border: 2px solid var(--header-bg);
  transform: translate(30%, -30%);
}
.topbar-notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 310px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(0,0,0,.22);
  z-index: 200; overflow: hidden;
}
.topbar-notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem .6rem;
  border-bottom: 1px solid var(--border);
}
.topbar-notif-head-title { font-size: .8125rem; font-weight: 700; color: var(--text); }
.topbar-notif-clear-btn {
  font-size: .72rem; font-weight: 600; color: var(--text-muted);
  background: transparent; border: none; cursor: pointer; padding: 0;
  transition: var(--transition);
}
.topbar-notif-clear-btn:hover { color: var(--danger); }
.topbar-notif-list { max-height: 260px; overflow-y: auto; }
.topbar-notif-empty {
  padding: 1.25rem 1rem; text-align: center;
  font-size: .8125rem; color: var(--text-muted);
}
.topbar-notif-item {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .65rem 1rem; cursor: pointer; transition: var(--transition);
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,.04));
}
.topbar-notif-item:hover { background: var(--surface-2); }
.topbar-notif-item.read .topbar-notif-item-dot { opacity: 0; }
.topbar-notif-item-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
  background: var(--primary);
}
.topbar-notif-item-body { flex: 1; min-width: 0; }
.topbar-notif-item-text { font-size: .8rem; color: var(--text); line-height: 1.4; }
.topbar-notif-item-time { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.topbar-notif-foot {
  padding: .55rem 1rem; border-top: 1px solid var(--border); text-align: center;
}
.topbar-notif-view-all {
  font-size: .78rem; font-weight: 600; color: var(--primary);
  text-decoration: none; transition: var(--transition);
}
.topbar-notif-view-all:hover { color: var(--primary-light); }

/* ── Topbar user pill ──────────────────────────────────────────────── */
.topbar-user-pill {
  position: relative; display: flex; align-items: center; gap: .45rem;
  padding: .25rem .5rem .25rem .25rem;
  border-radius: var(--radius-lg); cursor: pointer;
  transition: var(--transition); user-select: none;
  border: 1px solid transparent;
}
.topbar-user-pill:hover,
.topbar-user-pill.open { background: var(--surface-2); border-color: var(--border); }
.topbar-user-pill-info {
  display: flex; flex-direction: column; line-height: 1.2;
  min-width: 0;
}
.topbar-user-name {
  font-size: .8125rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.topbar-user-role {
  font-size: .68rem; color: var(--text-muted); text-transform: capitalize;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.topbar-user-pill-chevron { color: var(--text-muted); flex-shrink: 0; transition: transform .2s; }
.topbar-user-pill.open .topbar-user-pill-chevron { transform: rotate(180deg); }

/* Dropdown */
.topbar-user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 210px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(0,0,0,.22);
  z-index: 200; overflow: hidden; padding: .3rem;
}
.topbar-dd-user-head {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .75rem .5rem;
}
.topbar-dd-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-dim); color: var(--primary);
  font-size: .8rem; font-weight: 700;
}
.topbar-dd-user-info { min-width: 0; }
.topbar-dd-user-name {
  font-size: .8125rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-dd-user-role {
  font-size: .7rem; color: var(--text-muted); text-transform: capitalize; margin-top: 1px;
}
.topbar-dd-sep {
  height: 1px; background: var(--border); margin: .3rem 0;
}
.topbar-dd-item {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; padding: .48rem .75rem;
  background: transparent; border: none;
  color: var(--text); font-size: .8125rem; font-weight: 500;
  border-radius: calc(var(--radius-lg) - 4px);
  cursor: pointer; text-decoration: none; text-align: left;
  transition: var(--transition);
}
.topbar-dd-item:hover { background: var(--surface-2); }
.topbar-dd-item--danger { color: var(--danger); }
.topbar-dd-item--danger:hover { background: var(--danger-dim); }
.header-status {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.3rem 0.75rem; background: var(--bg-hover);
  border-radius: 99px; font-size: 0.8125rem; color: var(--text-secondary);
}
.btn-icon-header, .icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--border-radius);
  color: var(--text-secondary); transition: var(--transition-fast);
}
.btn-icon-header:hover, .icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-toggle-mobile { display: none; }

/* ── Outlet / Page content ───────────────────────────────────────────────── */
.outlet, .page-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
}
/* Map page: disable scroll so Leaflet can fill the outlet */
.outlet:has(.map-page-wrap) { overflow: hidden; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem; font-weight: 500; font-family: var(--font);
  border-radius: var(--border-radius);
  transition: var(--transition-fast);
  white-space: nowrap; cursor: pointer; border: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-light); box-shadow: var(--shadow-primary); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(255,75,75,.15); color: var(--danger); border: 1px solid rgba(255,75,75,.3); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.3125rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }
.form-label-group { display: flex; align-items: center; justify-content: space-between; }
.form-input, .form-control {
  width: 100%; padding: 0.5625rem 0.875rem;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--border-radius); color: var(--text-primary);
  font-size: 0.9375rem; font-family: var(--font);
  transition: var(--transition-fast); outline: none;
}
.form-input:focus, .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-alpha); }
.form-input::placeholder, .form-control::placeholder { color: var(--text-muted); }
.form-hint { font-size: 0.8125rem; color: var(--text-muted); margin-top: 0.25rem; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow); }
.card-header, .card-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.card-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1.25rem; }
.card-body.p-0 { padding: 0; }
.card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem;
}

/* ── Login page — faithful port of public/ design ────────────────────────── */
.outlet .login-split { min-height: 100vh; }

.login-split {
  display: flex; align-items: stretch;
  min-height: 100vh; background: var(--bg);
}
.login-left {
  width: 420px; min-width: 320px; max-width: 480px;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 3rem 2.5rem 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: relative; z-index: 1;
}
.login-left-inner {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding-bottom: 2rem;
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 2rem; }
.logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary-dim);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-text { font-weight: 700; font-size: 1.05rem; letter-spacing: .06em; }
.login-form-wrap { margin-top: 2.25rem; }
.login-title   { font-size: 1.375rem; font-weight: 700; line-height: 1.25; }
.login-subtitle { color: var(--text-2); font-size: .875rem; margin-top: .35rem; line-height: 1.5; }
.login-error {
  padding: 10px 14px; margin-top: 1rem;
  background: var(--danger-dim); border: 1px solid rgba(255,77,79,.3);
  border-radius: var(--radius); color: var(--danger); font-size: .85rem;
}
.login-error.show { display: block !important; }

/* input group (password show/hide) */
.input-group { display: flex; align-items: stretch; }
.input-group .form-input { border-radius: var(--radius) 0 0 var(--radius); flex: 1; }
.input-addon {
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-2); font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; cursor: pointer; white-space: nowrap;
}
.input-addon:hover { color: var(--primary); background: var(--primary-dim); }

.login-keep-row { display: flex; align-items: center; margin-top: 1rem; margin-bottom: 1.25rem; }
.login-keep-label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8125rem; color: var(--text-2); cursor: pointer; user-select: none;
}
.form-checkbox { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.login-submit-btn { font-size: .9375rem; padding: .75rem 1.25rem; letter-spacing: .03em; width: 100%; }
.login-page-footer {
  font-size: .75rem; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: .375rem;
  padding-top: 1rem; border-top: 1px solid var(--border);
}
/* ── Top controls bar (lang + theme) ── */
.login-top-controls {
  position: absolute; top: 1rem; right: 1rem;
  display: flex; align-items: center; gap: .5rem; z-index: 20;
}

/* Language switcher */
.login-lang-wrap { position: relative; }
.login-lang-btn {
  display: flex; align-items: center; gap: .35rem;
  height: 34px; padding: 0 .65rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-2);
  font-size: .75rem; font-weight: 600; letter-spacing: .04em;
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.login-lang-btn:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.login-lang-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 155px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: .3rem; z-index: 100; overflow: hidden;
}
.login-lang-option {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .45rem .65rem;
  background: transparent; border: none;
  color: var(--text); font-size: .8125rem; font-weight: 500;
  border-radius: calc(var(--radius-lg) - 4px);
  cursor: pointer; text-align: left; transition: var(--transition);
}
.login-lang-option:hover:not([disabled]) { background: var(--surface-2); }
.login-lang-option.active { color: var(--primary); font-weight: 600; }
.login-lang-option[disabled] { opacity: .5; cursor: not-allowed; }
.topbar-lang-soon {
  margin-left: auto;
  font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--primary-dim); color: var(--primary);
  padding: 1px 6px; border-radius: 20px;
}

.login-theme-toggle {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: var(--transition);
}
.login-theme-toggle:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }

/* ── Right panel ── */
.login-right {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  background: linear-gradient(135deg, #161b24 0%, #1a2233 50%, #0e1821 100%);
}
[data-theme="light"] .login-right {
  background: linear-gradient(135deg, #e8f4f6 0%, #f0f8fa 50%, #e2f0f2 100%);
}
.login-right-inner {
  width: 100%; max-width: 580px;
  padding: 3rem 2.5rem; display: flex; flex-direction: column; gap: 2rem;
}
.login-right-block { display: flex; flex-direction: column; gap: 1.5rem; width: 100%; }

@keyframes loginHeroIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes loginHeroShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}
.login-hero-text { text-align: center; max-width: 32rem; margin-inline: auto; }
.login-hero-title {
  font-size: clamp(1.3rem, 2.4vw, 1.7rem); font-weight: 700; line-height: 1.28;
  margin: 0 0 .625rem; letter-spacing: -.02em; color: var(--text);
  opacity: 0; animation: loginHeroIn .78s cubic-bezier(.22,1,.36,1) forwards;
}
.login-hero-title-inner {
  display: inline;
  background: linear-gradient(105deg, var(--text) 0%, var(--text) 38%, var(--primary) 52%, var(--accent) 62%, var(--text) 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  animation: loginHeroShimmer 8s ease-in-out .5s infinite;
}
.login-hero-tagline { margin: 0; font-size: .9375rem; line-height: 1.55; color: var(--text-2); }
.login-hero-row {
  display: block; opacity: 0;
  animation: loginHeroIn .72s cubic-bezier(.22,1,.36,1) forwards;
}
.login-hero-row:nth-of-type(1) { animation-delay: .14s; }
.login-hero-row:nth-of-type(2) { animation-delay: .3s; }
.login-hero-row--accent { color: var(--primary); font-weight: 500; margin-top: .35rem; }
.login-right-graphic {
  position: relative; border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; background: var(--surface); padding: 1rem;
  opacity: 0; animation: loginHeroIn .82s cubic-bezier(.22,1,.36,1) .2s forwards;
}
.login-map-svg { width: 100%; height: auto; display: block; overflow: visible; }
[data-theme="light"] .login-map-svg .login-map-sea { fill: url(#loginMapSeaLight); }

@keyframes loginMapZoneFloat    { 0%,100%{transform:translate(0,0)} 50%{transform:translate(5px,-4px)} }
@keyframes loginMapZoneFloatRev { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-4px,5px)} }
.login-map-zone--1 { animation: loginMapZoneFloat     24s ease-in-out       infinite; }
.login-map-zone--2 { animation: loginMapZoneFloatRev  20s ease-in-out   -3s infinite; }
.login-map-zone--3 { animation: loginMapZoneFloat     26s ease-in-out   -6s infinite; }
.login-map-zone--4 { animation: loginMapZoneFloatRev  22s ease-in-out   -2s infinite; }
.login-map-zone--5 { animation: loginMapZoneFloat     21s ease-in-out   -4s infinite; }
@keyframes loginMapDashFlow { to { stroke-dashoffset: -100; } }
.login-map-track    { animation: loginMapDashFlow 3.2s linear infinite; }
.login-map-track--b { animation-duration: 4.1s; animation-direction: reverse; opacity: .85; }
@keyframes loginMapPin1 {
  0%,100%{transform:translate(68px,90px)} 25%{transform:translate(92px,74px)}
  50%{transform:translate(82px,108px)}    75%{transform:translate(54px,96px)}
}
@keyframes loginMapPin2 {
  0%,100%{transform:translate(196px,64px)} 30%{transform:translate(220px,52px)}
  60%{transform:translate(208px,86px)}     85%{transform:translate(176px,72px)}
}
@keyframes loginMapPin3 {
  0%,100%{transform:translate(276px,74px)} 35%{transform:translate(302px,62px)}
  70%{transform:translate(288px,94px)}
}
.login-map-pin--1 { animation: loginMapPin1 17s ease-in-out      infinite; }
.login-map-pin--2 { animation: loginMapPin2 19s ease-in-out  -4s infinite; }
.login-map-pin--3 { animation: loginMapPin3 15s ease-in-out  -7s infinite; }
@keyframes loginMapDot1 { 0%,100%{transform:translate(104px,166px)} 50%{transform:translate(132px,184px)} }
@keyframes loginMapDot2 { 0%,100%{transform:translate(214px,148px)} 50%{transform:translate(196px,128px)} }
@keyframes loginMapDot3 { 0%,100%{transform:translate(332px,172px)} 50%{transform:translate(352px,154px)} }
.login-map-dot--1 { animation: loginMapDot1 13s ease-in-out  -1s infinite; }
.login-map-dot--2 { animation: loginMapDot2 11s ease-in-out  -3s infinite; }
.login-map-dot--3 { animation: loginMapDot3 14s ease-in-out  -5s infinite; }
@keyframes loginMapHaloPulse { 0%,100%{transform:scale(1);opacity:.14} 50%{transform:scale(1.45);opacity:.26} }
.login-map-pin .login-map-halo { transform-origin: 0 0; animation: loginMapHaloPulse 2.6s ease-in-out infinite; }
.login-map-pin--2 .login-map-halo { animation-delay: .5s; }
.login-map-pin--3 .login-map-halo { animation-delay: 1s; }

.login-stat-pills { display: flex; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; }
.login-stat-pill {
  display: flex; align-items: center; gap: .375rem;
  font-size: .75rem; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 2rem; padding: .25rem .75rem;
}
.login-stat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.login-stat-dot.online { background: var(--primary); box-shadow: 0 0 6px var(--primary); }
.login-stat-dot.sos    { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }

@media (max-width: 768px) {
  .login-split { flex-direction: column; }
  .login-left { width: 100%; max-width: 100%; min-width: 0; padding: 2rem 1.25rem 1.25rem; border-right: none; border-bottom: 1px solid var(--border); }
  .login-right { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .login-hero-title,.login-hero-row,.login-right-graphic,
  .login-map-zone--1,.login-map-zone--2,.login-map-zone--3,.login-map-zone--4,.login-map-zone--5,
  .login-map-track,.login-map-pin--1,.login-map-pin--2,.login-map-pin--3,
  .login-map-dot--1,.login-map-dot--2,.login-map-dot--3,.login-map-pin .login-map-halo {
    animation: none !important; opacity: 1 !important; transform: none !important;
  }
  .login-hero-title-inner { animation: none !important; background: none; -webkit-text-fill-color: var(--text); color: var(--text); }
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.dashboard {
  padding: 1.5rem 1.75rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}

/* ─── STAT CARDS ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.375rem 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: var(--transition);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--primary));
  border-radius: 3px 3px 0 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--stat-bg, var(--primary-dim));
  color: var(--stat-color, var(--primary));
}
/* legacy modifier classes */
.stat-icon.primary  { background: var(--primary-dim); color: var(--primary); }
.stat-icon.danger   { background: var(--danger-dim);  color: var(--danger); }
.stat-icon.success  { background: var(--success-dim); color: var(--success); }
.stat-icon.warning  { background: rgba(250,173,20,.15); color: var(--warning); }
.stat-body { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.875rem; font-weight: 700; line-height: 1.1;
  color: var(--text);
}
.stat-num { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8125rem; color: var(--text-2); margin-top: 0.25rem; }
.stat-change {
  font-size: 0.75rem; font-weight: 600;
  margin-top: 0.375rem;
  display: flex; align-items: center; gap: 0.25rem;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── TWO-COLUMN GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

/* ─── ACTIVITY FEED ── */
.activity-item {
  display: flex; align-items: flex-start; gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-3); }
.activity-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 0.1rem;
}
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 0.875rem; color: var(--text); line-height: 1.4; }
.activity-text strong { color: var(--primary-light); }
.activity-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.font-600 { font-weight: 600; }

/* ─── AVATAR + ONLINE INDICATOR ── */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8125rem; font-weight: 700; color: #fff;
  text-transform: uppercase; flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 0.6875rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1.125rem; }
.online-badge { position: relative; display: inline-flex; }
.online-badge::after {
  content: '';
  position: absolute; bottom: 1px; right: 1px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); border: 2px solid var(--surface);
}
.online-badge.offline::after { background: var(--text-muted); }

/* ─── EMPTY STATE ── */
.empty-state { text-align: center; padding: 3.5rem 1.5rem; color: var(--text-muted); }
.empty-icon {
  width: 56px; height: 56px; border-radius: var(--radius-lg);
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.25rem; color: var(--text-muted);
}
.empty-state h4 { color: var(--text-2); margin-bottom: 0.375rem; }
.empty-state p  { font-size: 0.875rem; }

/* ─── DASHBOARD MAP WIDGET ── */
.map-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.map-widget-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.map-widget-header h3 { font-size: 0.9375rem; font-weight: 600; }
.map-widget-body { display: flex; min-height: 280px; }
.map-widget-body--full { display: block; }
.map-area {
  flex: 1; position: relative;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; overflow: hidden;
}
.map-area--leaflet {
  flex-direction: column; align-items: stretch;
  padding: 0.75rem 0.75rem 0.5rem;
}
.dashboard-leaflet-map {
  width: 100%;
  height: min(420px, 50vh);
  min-height: 300px;
  border-radius: var(--radius-lg);
  z-index: 1;
}
.map-area--leaflet .leaflet-container { font-family: var(--font); background: var(--bg-2); }
.map-area--leaflet .leaflet-control-attribution {
  font-size: 0.625rem; line-height: 1.25; max-width: calc(100% - 12px);
  white-space: normal; padding: 3px 8px; border-radius: 4px; margin: 6px;
  background: rgba(0,0,0,.5); color: rgba(255,255,255,.88);
}
.map-area--leaflet .leaflet-control-attribution a { color: inherit; }
[data-theme="light"] .map-area--leaflet .leaflet-control-attribution {
  background: rgba(255,255,255,.92); color: var(--text-muted);
}
.map-attr {
  display: block; padding: 0.4rem 0.5rem 0.35rem;
  font-size: 0.625rem; color: var(--text-muted); opacity: 0.72; line-height: 1.35;
}

/* ─── DASHBOARD MAP PINS ── */
.dashboard-map-pin-wrapper { background: transparent !important; border: none !important; }
.dashboard-map-pin {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.dashboard-map-pin-core {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--pin-color, var(--primary));
  border: 2px solid rgba(255,255,255,.92);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin-color, var(--primary)) 35%, transparent);
  animation: dashboardPinPulse 2.2s ease-in-out infinite;
}
@keyframes dashboardPinPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pin-color, var(--primary)) 35%, transparent); }
  50%       { transform: scale(1.08); box-shadow: 0 0 0 8px color-mix(in srgb, var(--pin-color, var(--primary)) 15%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .dashboard-map-pin-core { animation: none; } }

/* ─── DASHBOARD POPUP ── */
.leaflet-popup.dashboard-user-popup-wrap .leaflet-popup-content-wrapper {
  border-radius: var(--radius); padding: 0; overflow: hidden;
}
.leaflet-popup.dashboard-user-popup-wrap .leaflet-popup-content { margin: 0; min-width: 220px; }
.dashboard-user-popup { padding: 0.75rem 0.9rem; }
.dashboard-user-popup-name { font-weight: 600; font-size: 0.9375rem; color: var(--text); }
.dashboard-user-popup-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.dashboard-user-popup-dl {
  margin: 0.65rem 0 0;
  display: grid; grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem; font-size: 0.75rem;
}
.dashboard-user-popup-dl dt { margin: 0; color: var(--text-muted); font-weight: 500; }
.dashboard-user-popup-dl dd { margin: 0; color: var(--text); }

/* ─── Responsive ── */
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 400px) { .stat-grid { grid-template-columns: 1fr; } }

/* ── Channels ────────────────────────────────────────────────────────────── */
.channels-page { padding: 24px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-head h2 { font-size: 1.1rem; font-weight: 600; }
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  display: flex; flex-direction: column; gap: 10px;
}
.channel-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.channel-name { font-weight: 600; font-size: .95rem; }
.channel-desc { font-size: .82rem; color: var(--text-2); }
.channel-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: .75rem; color: var(--text-muted);
}
.channel-type-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  background: var(--primary-dim); color: var(--primary);
}
.channel-type-badge.private { background: rgba(250,173,20,.15); color: var(--warning); }
.channel-type-badge.password { background: var(--surface-2); color: var(--text-muted); }

/* ── Chat page ───────────────────────────────────────────────────────────── */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
}
.chat-main {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; min-height: 62px;
}
.chat-header-name { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.chat-header-members { font-size: .78rem; color: var(--text-muted); line-height: 1.4; margin-top: 1px; }

.messages {
  flex: 1; overflow-y: auto;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.message {
  display: flex; flex-direction: column;
  padding: 8px 0;
  gap: 3px;
}
.message-header {
  display: flex; align-items: baseline; gap: 8px;
}
.message-sender {
  font-weight: 600; font-size: .85rem;
}
.message-time { font-size: .72rem; color: var(--text-muted); }
.message-body { font-size: .9rem; color: var(--text); line-height: 1.5; word-break: break-word; }
.message-body code {
  font-family: 'Consolas', monospace;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .82rem;
}
.message.own .message-sender { color: var(--primary); }
.message.system { opacity: .5; font-size: .78rem; font-style: italic; }
.message-group .message + .message { padding-top: 2px; }
.message-group .message + .message .message-header { display: none; }

.typing-indicator {
  padding: 6px 20px;
  font-size: .78rem; color: var(--text-muted); font-style: italic;
  min-height: 26px;
}

.chat-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; gap: 10px;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--border-focus); }
.chat-input::placeholder { color: var(--text-muted); }
.chat-send-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  transition: background var(--transition);
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--accent); }
.chat-send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Users page ──────────────────────────────────────────────────────────── */
.users-page { padding: 24px; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.users-table th { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.users-table tr:hover td { background: var(--surface-2); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); display: inline-block; }
.online-dot.online { background: var(--success); }

/* ── SOS page ────────────────────────────────────────────────────────────── */
.sos-page { padding: 24px; }
.sos-banner {
  background: var(--danger-dim);
  border: 1px solid rgba(255,77,79,.3);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
  color: var(--danger);
  font-weight: 600;
}
.sos-event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.sos-event-card.active { border-color: var(--danger); }
.sos-status-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.sos-status-badge.active        { background: var(--danger-dim); color: var(--danger); }
.sos-status-badge.acknowledged  { background: rgba(250,173,20,.15); color: var(--warning); }
.sos-status-badge.resolved      { background: var(--success-dim); color: var(--success); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 10000;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .85rem;
  pointer-events: all;
  animation: toast-in .2s ease;
  max-width: 320px;
}
.toast.success { border-color: rgba(82,196,26,.3); }
.toast.danger  { border-color: rgba(255,77,79,.3); }
.toast.warning { border-color: rgba(250,173,20,.3); }
@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px; text-align: center;
  color: var(--text-muted);
}
.empty svg { opacity: .3; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-2); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
.modal-footer { margin-top: 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── Skeleton ────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .82rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.open { transform: none; }
  #sidebar-toggle-mobile { display: flex; }
  .chat-layout { flex-direction: column; }
}
@media (min-width: 769px) {
  #sidebar-toggle-mobile { display: none; }
}

/* ── Nav sections ────────────────────────────────────────────────────────── */
.nav-section { display: flex; flex-direction: column; }
.nav-label {
  padding: 12px 16px 4px;
  font-size: .67rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
}

/* ── Page layout helpers ─────────────────────────────────────────────────── */
.page-content { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 1.05rem; font-weight: 600; }
.page-actions { display: flex; align-items: center; gap: 8px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: .72rem; font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2); color: var(--text-2);
}
.badge-success  { background: var(--success-dim);        color: var(--success); }
.badge-danger   { background: var(--danger-dim);         color: var(--danger); }
.badge-warning  { background: rgba(250,173,20,.15);      color: var(--warning); }
.badge-primary  { background: var(--primary-dim);        color: var(--primary); }
.badge-muted    { background: var(--surface-2);          color: var(--text-muted); }
.badge-system   { background: var(--bg-3);               color: var(--text-2); border: 1px solid var(--border); }

/* ── Button extras ───────────────────────────────────────────────────────── */
.btn-outline {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-icon.danger:hover { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.btn-icon.success:hover { background: var(--success-dim); color: var(--success); border-color: var(--success); }

/* ── Form extras ─────────────────────────────────────────────────────────── */
.form-select {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  width: 100%;
  appearance: none;
  transition: border-color var(--transition);
}
.form-select:focus { border-color: var(--border-focus); outline: none; }
.form-textarea {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  width: 100%; resize: vertical; min-height: 80px;
  transition: border-color var(--transition);
}
.form-textarea:focus { border-color: var(--border-focus); outline: none; }

/* ── Data table ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead tr { border-bottom: 1px solid var(--border); }
.data-table th {
  padding: 10px 16px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); text-align: left; white-space: nowrap;
  background: var(--surface);
}
.data-table td {
  padding: 11px 16px;
  font-size: .88rem; color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table .actions-col { display: flex; align-items: center; gap: 4px; }
.col-actions { width: 1px; white-space: nowrap; }

/* ── Metric rows ─────────────────────────────────────────────────────────── */
.metric-list { display: flex; flex-direction: column; gap: 0; }
.metric-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  gap: 12px;
}
.metric-row:last-child { border-bottom: none; }
.metric-label { font-size: .85rem; color: var(--text-2); }
.metric-value { font-size: .9rem; font-weight: 600; color: var(--text); font-family: monospace; }
.metric-value.ok     { color: var(--success); }
.metric-value.warn   { color: var(--warning); }
.metric-value.error  { color: var(--danger); }

/* ── Spinner / Page loading ──────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--primary-dim);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.page-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px 20px;
  gap: 12px; color: var(--text-muted); font-size: .9rem;
}

/* ── Live Map page ───────────────────────────────────────────────────────── */
.map-page-wrap {
  position: relative;
  height: calc(100vh - var(--topbar-h));
  display: flex;
  overflow: hidden;
}
.map-page-wrap.map-fullscreen {
  position: fixed; inset: 0; z-index: 500; height: 100vh;
}
#map-leaflet {
  flex: 1; height: 100%; background: var(--bg);
}

/* Floating controls — single vertical card, top-right */
.map-float-controls {
  position: absolute; top: 1rem; right: 1rem;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden; z-index: 410;
}
.map-float-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer;
  transition: var(--transition); position: relative; flex-shrink: 0;
}
.map-float-btn:hover  { background: var(--surface-2); color: var(--primary); }
.map-float-btn.active { background: var(--primary-dim); color: var(--primary); }
.map-float-sep { height: 1px; background: var(--border); margin: 0 6px; }
.map-float-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--primary); color: white;
  border-radius: 50%; width: 14px; height: 14px;
  font-size: .55rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* Basemap dropdown */
.map-basemap-dropdown {
  position: absolute; top: 1rem; right: calc(36px + 1.5rem);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  min-width: 150px; z-index: 420; padding: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.map-basemap-dropdown.hidden { display: none !important; }
.map-basemap-dropdown-title {
  padding: 6px 10px;
  font-size: .7rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
}
.map-basemap-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius);
  font-size: .83rem; color: var(--text); width: 100%; text-align: left;
  background: transparent; border: none; cursor: pointer;
  transition: background var(--transition);
}
.map-basemap-option:hover  { background: var(--surface-2); }
.map-basemap-option.active { background: var(--primary-dim); color: var(--primary); }
.map-basemap-option-icon   { font-size: 1rem; width: 20px; text-align: center; }

/* Geocoder — top-center */
.map-geocoder {
  position: absolute; top: 1rem; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  height: 36px; padding: 0 4px 0 0; z-index: 410;
  min-width: 240px; max-width: 340px;
}
.map-geocoder-input {
  flex: 1; border: none; background: transparent;
  font-size: .83rem; color: var(--text); outline: none; padding: 0 4px;
}
.map-geocoder-input::placeholder { color: var(--text-muted); }
.map-geocoder-btn {
  padding: 4px 12px; border-radius: var(--radius);
  background: var(--primary); color: white;
  font-size: .78rem; font-weight: 600; border: none; cursor: pointer;
  flex-shrink: 0;
}
.map-geocoder-btn:hover { opacity: .85; }

/* Side panel (users) — left slide-in */
.map-channel-panel {
  position: absolute; top: 0; height: 100%;
  width: 270px; background: var(--surface);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; z-index: 420;
  box-shadow: var(--shadow);
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .18s ease;
}
.map-channel-panel.hidden { opacity: 0; pointer-events: none; }
.map-users-panel {
  left: 0; right: auto;
  border-left: none; border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.map-users-panel.hidden  { transform: translateX(-100%); }
.map-channel-panel-header {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.map-channel-panel-header h3 { font-size: .9rem; font-weight: 600; }
.map-channel-list { flex: 1; overflow-y: auto; }
.map-channel-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.map-channel-item:hover { background: var(--surface-2); }
.map-channel-item:last-child { border-bottom: none; }
.map-channel-item-name  { font-size: .875rem; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-channel-item-count { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }

/* Live status pill — bottom-center */
.map-live-pill {
  position: absolute; bottom: 1.75rem; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: .3rem .875rem;
  font-size: .8rem; font-weight: 500;
  display: flex; align-items: center; gap: .5rem;
  z-index: 410; box-shadow: var(--shadow);
  pointer-events: none; white-space: nowrap;
}
@keyframes mapPulse { 0%,100%{box-shadow:0 0 0 0 rgba(82,196,26,.6)} 70%{box-shadow:0 0 0 6px rgba(82,196,26,0)} }
.map-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 6px var(--success);
  animation: mapPulse 2s ease infinite;
}

/* ── DM / Chat sidebar layout ────────────────────────────────────────────── */
.dm-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
}
.dm-sidebar {
  width: 260px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-2);
}
.dm-sidebar-head {
  padding: 14px 16px;
  font-weight: 600; font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.dm-user-list { flex: 1; overflow-y: auto; }
.dm-user-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}
.dm-user-item:hover { background: var(--primary-dim); }
.dm-user-item.active { background: var(--primary-dim); border-left-color: var(--primary); }
.dm-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.dm-user-name  { font-size: .88rem; font-weight: 500; }
.dm-user-status { font-size: .72rem; color: var(--text-muted); }
.dm-thread {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.dm-thread-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: .9rem;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 0 0 4px;
}
.tab-btn {
  padding: 10px 16px;
  font-size: .85rem; font-weight: 500;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-page { padding: 24px; max-width: 640px; }
.settings-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.settings-tab {
  padding: 10px 16px;
  font-size: .88rem; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  margin-bottom: -1px;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-section { display: flex; flex-direction: column; gap: 16px; }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}
.color-swatch.selected { border-color: var(--text); transform: scale(1.15); }
.color-swatch:hover { transform: scale(1.1); }

/* ── Roles / Matrix page ─────────────────────────────────────────────────── */
.roles-page { padding: 24px; }
.roles-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.roles-table-row-actions { display: flex; align-items: center; gap: 4px; }

.matrix-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
}
.matrix-roles-list {
  width: 220px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg-2);
  padding: 8px 0;
}
.matrix-role-item {
  padding: 10px 16px; cursor: pointer;
  font-size: .88rem; color: var(--text-2);
  transition: background var(--transition);
  border-left: 3px solid transparent;
}
.matrix-role-item:hover { background: var(--primary-dim); color: var(--text); }
.matrix-role-item.active { background: var(--primary-dim); color: var(--primary); border-left-color: var(--primary); font-weight: 500; }
.matrix-panel {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.matrix-panel-head {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .95rem;
  display: flex; align-items: center; justify-content: space-between;
}
.matrix-panel-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.matrix-module-group { margin-bottom: 20px; }
.matrix-module-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.matrix-module-title { font-weight: 600; font-size: .88rem; text-transform: capitalize; }
.matrix-module-count { font-size: .72rem; color: var(--text-muted); }
.matrix-perm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.matrix-perm-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.matrix-perm-item:hover { background: var(--surface-2); }
.matrix-perm-item input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
.matrix-perm-label { font-size: .82rem; color: var(--text-2); }
.matrix-footer {
  padding: 10px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-size: .8rem; color: var(--text-muted); min-height: 42px;
}
.matrix-save-hint { display: flex; align-items: center; gap: 6px; }

/* ── Activity / audit log ────────────────────────────────────────────────── */
.activity-page { padding: 24px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-chip {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .75rem; font-weight: 500;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border);
  cursor: pointer; transition: all var(--transition);
}
.filter-chip.active { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.log-detail { font-size: .78rem; color: var(--text-muted); max-width: 300px; word-break: break-word; }

/* ── System page ─────────────────────────────────────────────────────────── */
.system-page { padding: 24px; }
.system-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
@media (max-width: 768px) { .system-grid { grid-template-columns: 1fr; } }

/* ── APOC pages ──────────────────────────────────────────────────────────── */
.apoc-page { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* Admin — Traccar sync (/admin/traccar-sync) */
.admin-traccar-page .ats-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 12px;
}
.admin-traccar-page .ats-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
}
.admin-traccar-page .ats-stat-val { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.admin-traccar-page .ats-stat-lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-top: 4px; }
.ats-sync-group-title { margin: 20px 0 10px; font-size: .9rem; font-weight: 600; color: var(--text-2); }
.ats-sync-group-title--danger { color: var(--danger); }

.apoc-stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.apoc-detail-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.staleness-ok   { color: var(--success); }
.staleness-warn { color: var(--warning); }
.staleness-stale{ color: var(--danger); }

/* ── Tracking page ───────────────────────────────────────────────────────── */
.tracking-page { padding: 24px; }
.tracking-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

/* ── History page ────────────────────────────────────────────────────────── */
.history-page { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.history-list-wrap { padding: 16px 20px; }
.history-summary { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: .8rem; }
.history-day-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 8px 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.history-timeline { padding-left: 20px; border-left: 2px solid var(--border); margin-bottom: 20px; }
.history-entry {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 8px 0; cursor: pointer; transition: background var(--transition);
  border-radius: var(--radius); margin-left: -20px; padding-left: 10px;
}
.history-entry:hover { background: var(--surface-2); }
.history-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--bg);
  flex-shrink: 0; margin-top: 5px; position: relative; left: -6px;
}
.history-dot-end { background: var(--success); }
.history-entry-body { flex: 1; min-width: 0; }
.history-entry-time { font-size: .75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; }
.history-entry-coords { font-size: .85rem; font-weight: 500; font-family: monospace; color: var(--text); }
.history-entry-meta { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ── Modal extended ──────────────────────────────────────────────────────── */
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-close-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); border-radius: var(--radius);
  transition: all var(--transition);
}
.modal-close-btn:hover { background: var(--surface-2); color: var(--text); }
.modal-body > * + * { margin-top: 14px; }
.modal-lg { max-width: 600px; }
.modal-sm { max-width: 360px; }

/* ── Confirm dialog ──────────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 9500;
}
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%; max-width: 360px;
  box-shadow: var(--shadow);
}
.confirm-title { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.confirm-body { font-size: .88rem; color: var(--text-2); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Error / alert ───────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 12px;
}
.alert-danger { background: var(--danger-dim); border: 1px solid rgba(255,77,79,.3); color: var(--danger); }
.alert-warning { background: rgba(250,173,20,.1); border: 1px solid rgba(250,173,20,.3); color: var(--warning); }
.alert-success { background: var(--success-dim); border: 1px solid rgba(82,196,26,.3); color: var(--success); }
.alert-info { background: var(--primary-dim); border: 1px solid var(--primary-glow); color: var(--primary); }

/* ── Auto-refresh indicator ──────────────────────────────────────────────── */
.auto-refresh-row {
  display: flex; align-items: center; gap: 8px;
  font-size: .8rem; color: var(--text-muted);
}
.auto-refresh-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--success-dim);
  animation: pulse 2s infinite;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 6px;
  margin-top: 16px;
}
.page-btn {
  min-width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem;
  border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.page-btn:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Page layout helpers (extended) ─────────────────────────────────────── */
.page { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.page-sub { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

/* ── Map page — faithful port of public/ design ──────────────────────────── */
.map-page-wrap {
  position: relative;
  height: calc(100vh - var(--topbar-h));
  display: flex;
  overflow: hidden;
}

#map-leaflet {
  flex: 1;
  height: 100%;
  background: var(--bg);
}

/* Leaflet overrides */
.map-page-wrap .leaflet-container { background: #111318 !important; }
.map-page-wrap .leaflet-control-attribution {
  background: rgba(0,0,0,.45) !important;
  color: var(--text-muted) !important;
  font-size: .65rem !important;
}

/* Floating controls — single card panel top-right */
.map-float-controls {
  position: absolute;
  top: 1rem; right: 1rem;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  overflow: hidden;
  z-index: 410;
}
.map-float-btn {
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  position: relative; flex-shrink: 0;
}
.map-float-btn:hover  { background: var(--surface-2); color: var(--primary); }
.map-float-btn.active { background: var(--primary-dim); color: var(--primary); }
.map-float-sep {
  height: 1px; background: var(--border); margin: 0 6px;
}
.map-float-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--primary); color: #fff;
  border-radius: 50%; width: 14px; height: 14px;
  font-size: .55rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; pointer-events: none;
}

/* Geocoder — top-center */
.map-geocoder {
  position: absolute; top: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 900; display: flex; align-items: center; gap: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  overflow: hidden; min-width: 300px;
}
.map-geocoder-input {
  flex: 1; padding: .5rem .5rem .5rem .4rem;
  background: transparent; color: var(--text);
  border: none; font-size: .825rem; outline: none; min-width: 0;
}
.map-geocoder-input::placeholder { color: var(--text-muted); font-size: .8rem; }
.map-geocoder-btn {
  padding: .5rem .9rem;
  background: var(--primary); color: #fff; border: none;
  cursor: pointer; font-size: .75rem; font-weight: 600;
  letter-spacing: .03em; white-space: nowrap;
  transition: background .12s; flex-shrink: 0;
}
.map-geocoder-btn:hover { background: #007D88; }

/* Side panels — slide in from left (users) */
.map-channel-panel {
  position: absolute; top: 0; height: 100%; width: 270px;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  z-index: 420;
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .18s ease;
  right: calc(36px + 1.5rem); left: auto;
  border-right: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.map-channel-panel.hidden { opacity: 0; pointer-events: none; }
.map-users-panel {
  left: 0; right: auto;
  border-left: none; border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.map-users-panel.hidden { transform: translateX(-100%); }

.map-channel-panel-header {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.map-channel-panel-header h3 { font-size: .9rem; font-weight: 600; }
.map-channel-list { flex: 1; overflow-y: auto; }
.map-channel-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .75rem 1rem; border-bottom: 1px solid rgba(255,255,255,.05);
  cursor: pointer; transition: background .12s;
}
.map-channel-item:hover { background: var(--surface-2); }
.map-channel-item:last-child { border-bottom: none; }
.map-channel-item-name  { font-size: .875rem; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-channel-item-count { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }

/* Live pill — bottom-center */
.map-live-pill {
  position: absolute; bottom: 1.75rem; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 99px;
  padding: .3rem .875rem; font-size: .8rem; font-weight: 500;
  display: flex; align-items: center; gap: .5rem;
  z-index: 410; box-shadow: var(--shadow); pointer-events: none; white-space: nowrap;
}
@keyframes mapPulse { 0%,100%{transform:scale(1);opacity:.25} 50%{transform:scale(2);opacity:0} }
.map-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 6px var(--success);
  position: relative;
}
.map-live-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: var(--success); animation: mapPulse 2s ease infinite;
}

/* Basemap dropdown */
.map-basemap-dropdown {
  position: absolute; right: calc(36px + 1.5rem); top: 50%; transform: translateY(-50%);
  min-width: 150px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  z-index: 430; padding: .3rem;
  transition: opacity .15s ease, transform .15s ease;
}
.map-basemap-dropdown.hidden {
  opacity: 0; pointer-events: none;
  transform: translateY(-50%) translateX(6px);
}
.map-basemap-dropdown-title {
  font-size: .6875rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  padding: .4rem .6rem .25rem;
}
.map-basemap-option {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .45rem .6rem; border: none;
  background: transparent; color: var(--text); font-size: .8125rem;
  font-weight: 500; border-radius: calc(var(--radius-lg) - 4px);
  cursor: pointer; text-align: left; transition: var(--transition);
}
.map-basemap-option:hover  { background: var(--surface-2); }
.map-basemap-option.active { color: var(--primary); font-weight: 600; }
.map-basemap-option-icon   { font-size: 1rem; line-height: 1; width: 20px; text-align: center; }

/* action-btn (close button used inside panels) */
.action-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--text-muted);
  background: transparent; border: none; cursor: pointer;
  transition: var(--transition);
}
.action-btn:hover { background: var(--surface-2); color: var(--text); }
.action-btn.action-danger:hover { background: var(--danger-dim); color: var(--danger); }

/* ── Floating chat popup ─────────────────────────────────────────────────── */
.chat-popup-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 1100;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  box-shadow: 0 4px 20px var(--primary-dim);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.chat-popup-fab:hover  { transform: scale(1.08); box-shadow: 0 6px 24px var(--primary-dim); }
.chat-popup-fab.active { background: var(--text-muted); }
.chat-popup-panel {
  position: fixed; bottom: 92px; right: 28px; z-index: 1099;
  width: 340px; max-height: 540px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.3);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-popup-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-popup-back {
  background: none; border: none; cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; padding: 2px;
  transition: color var(--transition);
}
.chat-popup-back:hover { color: var(--text); }
.chat-popup-title { font-size: .9rem; font-weight: 600; color: var(--text); flex: 1; }
.chat-popup-close {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; padding: 2px;
  transition: color var(--transition);
}
.chat-popup-close:hover { color: var(--danger); }
.chat-popup-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-popup-tab {
  flex: 1; padding: 9px; font-size: .82rem; font-weight: 500;
  color: var(--text-2); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.chat-popup-tab:hover { color: var(--text); }
.chat-popup-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.chat-popup-list-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-popup-list { flex: 1; overflow-y: auto; }
.chat-popup-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  transition: background var(--transition);
}
.chat-popup-list-item:hover { background: var(--surface-2); }
.chat-popup-item-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.chat-popup-item-info { flex: 1; min-width: 0; }
.chat-popup-item-name { font-size: .84rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-popup-item-meta { font-size: .75rem; color: var(--text-muted); margin-top: 1px; }
.chat-popup-status-dot {
  position: absolute; bottom: 0; right: 0;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); border: 2px solid var(--surface);
}
.chat-popup-status-dot.online { background: var(--success); }
.chat-popup-loading { padding: 1.5rem; text-align: center; font-size: .8rem; color: var(--text-muted); }
.chat-popup-empty  { padding: 2rem;   text-align: center; font-size: .8rem; color: var(--text-muted); }
.chat-popup-thread-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-popup-messages { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.popup-msg-author { font-size: .72rem; font-weight: 700; color: var(--text-muted); margin-top: 8px; padding-left: 2px; }
.popup-msg-author.own { text-align: right; padding-right: 2px; padding-left: 0; }
.popup-msg-row { display: flex; align-items: flex-end; gap: 6px; }
.popup-msg-row.own { flex-direction: row-reverse; }
.popup-msg-bubble {
  background: var(--surface-2); color: var(--text);
  border-radius: 12px 12px 12px 4px;
  padding: 7px 10px; font-size: .83rem; max-width: 200px; word-break: break-word;
}
.popup-msg-bubble.own { background: var(--primary); color: #fff; border-radius: 12px 12px 4px 12px; }
.popup-msg-time { font-size: .68rem; color: var(--text-muted); white-space: nowrap; }
.chat-popup-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.chat-popup-input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: .84rem; color: var(--text);
  outline: none; transition: border-color var(--transition);
}
.chat-popup-input:focus { border-color: var(--primary); }
.chat-popup-send-btn {
  background: var(--primary); color: #fff; border: none;
  border-radius: 8px; width: 36px; height: 36px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: opacity var(--transition);
}
.chat-popup-send-btn:hover { opacity: .85; }
.chat-popup-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── SOS bulk bar ────────────────────────────────────────────────────────── */
.sos-bulk-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; margin-bottom: 12px;
  background: var(--primary-dim); border: 1px solid var(--primary);
  border-radius: var(--radius-lg); color: var(--text);
}

/* ── Responsive adjustments ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dm-layout { flex-direction: column; }
  .dm-sidebar { width: 100%; height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .matrix-layout { flex-direction: column; }
  .matrix-roles-list { width: 100%; height: 140px; border-right: none; border-bottom: 1px solid var(--border); }
  .system-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   CHANNELS PAGE — card-grid redesign
   ═══════════════════════════════════════════════════════════════════════════ */
.channels-page { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

.channels-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.ch-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
}
.ch-stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ch-stat-icon.primary { background: var(--primary-dim); color: var(--primary); }
.ch-stat-icon.success { background: var(--success-dim); color: var(--success); }
.ch-stat-icon.warning { background: rgba(250,173,20,.15); color: var(--warning); }
.ch-stat-icon.accent  { background: rgba(24,221,239,.12); color: var(--accent); }
.ch-stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.ch-stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.channels-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.ch-filter-tabs {
  display: flex; gap: 4px;
  background: var(--surface-2); border-radius: var(--radius); padding: 3px;
}
.ch-filter-tab {
  padding: 5px 12px; border-radius: 6px;
  font-size: .78rem; font-weight: 500; color: var(--text-2);
  cursor: pointer; transition: all var(--transition);
}
.ch-filter-tab:hover { color: var(--text); }
.ch-filter-tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.2); }

.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.ch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  display: flex; flex-direction: column; gap: 12px;
  position: relative;
}
.ch-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-dim), 0 4px 16px rgba(0,0,0,.15);
  transform: translateY(-1px);
}
.ch-card-header {
  display: flex; align-items: flex-start; gap: 12px;
}
.ch-card-avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.ch-card-header-info { flex: 1; min-width: 0; }
.ch-card-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-card-desc { font-size: .8rem; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-card-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: .75rem; color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 10px; margin-top: 2px;
}
.ch-card-meta-item { display: flex; align-items: center; gap: 5px; }
.ch-card-meta-time { margin-left: auto; }
.ch-card-actions {
  display: flex; gap: 6px; align-items: center;
}
.ch-card-more-btn {
  position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}
.ch-card:hover .ch-card-more-btn { opacity: 1; }
.ch-card-more-btn:hover { background: var(--surface-2); color: var(--text); }

/* ═══════════════════════════════════════════════════════════════════════════
   CHAT — improved message bubbles & input bar
   ═══════════════════════════════════════════════════════════════════════════ */

/* Message rows */
.chat-msg-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 2px 0;
  position: relative;
}
.chat-msg-row.own { flex-direction: row-reverse; }
.chat-msg-row.grouped .chat-msg-avatar-wrap { visibility: hidden; }

.chat-msg-avatar-wrap { flex-shrink: 0; }
.chat-msg-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
}
.chat-msg-gutter { width: 30px; flex-shrink: 0; }

.chat-msg-body { max-width: 68%; display: flex; flex-direction: column; gap: 2px; }
.chat-msg-row.own .chat-msg-body { align-items: flex-end; }

.chat-msg-meta {
  display: flex; align-items: baseline; gap: 6px;
  padding: 0 4px;
}
.chat-msg-author { font-size: .76rem; font-weight: 600; }
.chat-msg-time   { font-size: .68rem; color: var(--text-muted); }

.chat-msg-bubble--text {
  background: var(--surface-2);
  color: var(--text);
  border-radius: 4px 14px 14px 4px;
  padding: 7px 12px;
  font-size: .88rem; line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
}
.chat-msg-bubble--text.own {
  background: var(--primary);
  color: #fff;
  border-radius: 14px 4px 4px 14px;
}
.chat-msg-hover-time {
  font-size: .65rem; color: var(--text-muted);
  align-self: center; opacity: 0; transition: opacity var(--transition);
  white-space: nowrap;
}
.chat-msg-row:hover .chat-msg-hover-time { opacity: 1; }

/* Date divider */
.chat-date-divider {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; color: var(--text-muted);
}
.chat-date-divider::before,
.chat-date-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.chat-date-divider span {
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
}

/* New pill input bar */
.chat-input-bar {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-end; gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: var(--bg-2);
}

/* Reply strip + reactions (channel + DM) */
.chat-reply-bar {
  flex: 1 1 100%;
  order: -1;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .82rem;
}
.chat-reply-bar-inner {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.chat-reply-bar-text { flex: 1; min-width: 0; color: var(--text-2); line-height: 1.4; }
.chat-msg-reply-quote {
  font-size: .78rem;
  color: var(--text-muted);
  border-left: 3px solid var(--primary);
  padding: 4px 0 4px 8px;
  margin-bottom: 6px;
  background: var(--surface-2);
  border-radius: 0 4px 4px 0;
}
.chat-msg-reply-label { font-weight: 600; color: var(--text-2); margin-right: 4px; }
.chat-msg-reactions {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px; align-items: center;
}
.chat-react-pill,
.chat-react-add {
  font-size: .78rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
}
.chat-react-pill:hover,
.chat-react-add:hover { border-color: var(--primary); background: var(--primary-dim); }
.chat-react-n { font-size: .72rem; opacity: .85; margin-left: 2px; }
.chat-msg-reply-btn {
  font-size: .78rem;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.chat-msg-reply-btn:hover { color: var(--primary); border-color: var(--primary); }

.chat-msg-menu-btn {
  position: absolute;
  top: 2px;
  right: 4px;
  opacity: 0;
  transition: opacity .12s;
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 6px;
  width: 28px;
  height: 24px;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
  z-index: 2;
}
.chat-msg-row.own .chat-msg-menu-btn { right: auto; left: 4px; }
.chat-msg-row:hover .chat-msg-menu-btn { opacity: 1; }
.chat-msg-reply-quote[data-scroll-to] { cursor: pointer; }
.chat-msg-reply-quote[data-scroll-to]:hover { filter: brightness(1.08); }

.msg-action-menu {
  position: fixed;
  z-index: 4000;
  min-width: 200px;
  max-width: min(280px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  padding: 4px 0;
}
.msg-action-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  font-size: .86rem;
  cursor: pointer;
}
.msg-action-menu-item:hover:not(:disabled) { background: var(--surface-2); }
.msg-action-menu-item:disabled { opacity: .45; cursor: not-allowed; }
.msg-action-menu-item.danger { color: var(--danger); }
.msg-action-menu-item.danger:hover:not(:disabled) { background: rgba(239,68,68,.08); }
.msg-action-menu-ic { width: 20px; text-align: center; flex-shrink: 0; font-size: 1rem; }
.msg-action-menu-lb { flex: 1; }

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.chat-header-actions .icon-btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.chat-send-btn-circle.is-sending {
  pointer-events: none;
  opacity: 0.65;
  animation: chat-send-pulse 0.9s ease-in-out infinite;
}
@keyframes chat-send-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.92); }
}

.dm-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-2);
}
.dm-user-item.dm-user-item-unread {
  background: rgba(0, 168, 181, 0.06);
}
.dm-user-item.dm-user-item-unread:not(.active) {
  border-left-color: rgba(0, 168, 181, 0.35);
}

.ch-card-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.ch-unread-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-2);
}
.ch-card-has-unread {
  box-shadow: 0 0 0 1px rgba(0, 168, 181, 0.25);
}
.chat-input-field-wrap {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px 14px;
  transition: border-color var(--transition);
}
.chat-input-field-wrap:focus-within { border-color: var(--border-focus); }
.chat-input-field {
  width: 100%;
  background: none; border: none; outline: none;
  color: var(--text); font-family: inherit; font-size: .88rem;
  line-height: 1.5; resize: none; max-height: 120px;
}
.chat-input-field::placeholder { color: var(--text-muted); }
.chat-send-btn-circle {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}
.chat-send-btn-circle:hover { background: var(--accent); transform: scale(1.05); }
.chat-send-btn-circle:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* DM sidebar search */
.chat-sidebar-search-wrap {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.chat-sidebar-search-input {
  width: 100%; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .82rem; outline: none;
  transition: border-color var(--transition);
}
.chat-sidebar-search-input:focus { border-color: var(--border-focus); }
.chat-sidebar-search-input::placeholder { color: var(--text-muted); }

/* DM online status dot — must be absolute so it overlays the avatar, not stacks below it */
.dm-status-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg-2);
}
.dm-status-dot.online { background: var(--success); }
.dm-header-avatar-wrap { position: relative; display: inline-flex; }
.dm-hdr-status-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg-2);
}
.dm-hdr-status-dot.online { background: var(--success); }

/* ═══════════════════════════════════════════════════════════════════════════
   ROLES PAGE — stat cards
   ═══════════════════════════════════════════════════════════════════════════ */
.roles-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.roles-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  text-align: center;
}
.roles-stat-num { font-size: 1.6rem; font-weight: 700; color: var(--primary); line-height: 1; }
.roles-stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.roles-slug-code {
  font-family: monospace; font-size: .82rem;
  background: var(--surface-2); color: var(--text-2);
  padding: 2px 6px; border-radius: 4px;
}
.roles-perms-link { color: var(--primary); font-size: .82rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   BADGES — extra variants
   ═══════════════════════════════════════════════════════════════════════════ */
.badge-system { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); }
.badge-info   { background: rgba(24,221,239,.12); color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════════════
   MAP PAGE — faithful port of public/ design
   ═══════════════════════════════════════════════════════════════════════════ */
.map-page-wrap {
  position: relative;
  height: calc(100vh - var(--topbar-h));
  display: flex;
  overflow: hidden;
}

.map-page-wrap.map-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 500;
  margin: 0;
  height: 100vh;
}

#map-leaflet {
  flex: 1;
  height: 100%;
  background: var(--bg);
}

/* Leaflet overrides */
.map-page-wrap .leaflet-container { background: #111318 !important; }
.map-page-wrap .leaflet-control-attribution {
  background: rgba(0,0,0,.45) !important;
  color: var(--text-muted) !important;
  font-size: .68rem;
}
.map-page-wrap .leaflet-control-attribution a { color: var(--primary) !important; }

/* ── Floating controls — vertical card, top-right ───── */
.map-float-controls {
  position: absolute;
  top: 1rem; right: 1rem;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  overflow: hidden;
  z-index: 410;
}

.map-float-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}
.map-float-btn:hover  { background: var(--surface-2); color: var(--primary); }
.map-float-btn.active { background: var(--primary-dim); color: var(--primary); }

.map-float-sep {
  height: 1px;
  background: var(--border);
  margin: 0 6px;
}

.map-float-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 14px; height: 14px;
  font-size: .55rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* ── Geocoder — top-center ────────────────────────────── */
.map-geocoder {
  position: absolute;
  top: 1rem; left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex; align-items: center; gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  overflow: hidden;
  min-width: 300px;
}
.map-geocoder-input {
  flex: 1;
  padding: .5rem .5rem .5rem .4rem;
  background: transparent;
  color: var(--text);
  border: none;
  font-size: .825rem;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.map-geocoder-input::placeholder { color: var(--text-muted); font-size: .8rem; }
.map-geocoder-btn {
  padding: .5rem .9rem;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: .75rem; font-weight: 600;
  font-family: inherit;
  letter-spacing: .03em;
  white-space: nowrap;
  transition: background .12s;
  flex-shrink: 0;
}
.map-geocoder-btn:hover { background: #007a85; }

/* ── Side panels — floating overlays ─────────────────── */
.map-channel-panel {
  position: absolute;
  top: 0; height: 100%;
  width: 270px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 420;
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .18s ease;
  /* default: slide from right */
  right: calc(36px + 1.5rem);
  left: auto;
  border-right: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.map-channel-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 3rem));
}
/* Users panel — left side */
.map-users-panel {
  left: 0; right: auto;
  border-left: none;
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.map-users-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-100%);
}

.map-channel-panel-header {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.map-channel-panel-header h3 { font-size: .9rem; font-weight: 600; }

.map-channel-list { flex: 1; overflow-y: auto; }
.map-channel-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.05);
  cursor: pointer;
  transition: background .12s;
}
.map-channel-item:hover { background: var(--surface-2); }
.map-channel-item:last-child { border-bottom: none; }
.map-channel-item-name {
  font-size: .875rem; font-weight: 500;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.map-channel-item-count { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }

/* ── Live pill — bottom-center ───────────────────────── */
.map-live-pill {
  position: absolute;
  bottom: 1.75rem; left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .3rem .875rem;
  font-size: .8rem; font-weight: 500;
  display: flex; align-items: center; gap: .5rem;
  z-index: 410;
  box-shadow: 0 4px 12px rgba(0,0,0,.15), 0 2px 4px rgba(0,0,0,.1);
  pointer-events: none;
  white-space: nowrap;
}
.map-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: mapPulse 2s ease infinite;
}
@keyframes mapPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.5); opacity: .6; }
}

/* ── Basemap dropdown ────────────────────────────────── */
.map-basemap-dropdown {
  position: absolute;
  right: calc(36px + 1.5rem);
  top: 50%;
  transform: translateY(-50%);
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2), 0 4px 8px rgba(0,0,0,.12);
  z-index: 430;
  padding: .3rem;
  transition: opacity .15s ease, transform .15s ease;
}
.map-basemap-dropdown.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(6px);
}
.map-basemap-dropdown-title {
  font-size: .6875rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  padding: .4rem .6rem .25rem;
}
.map-basemap-option {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .45rem .6rem;
  border: none; background: transparent;
  color: var(--text); font-size: .8125rem; font-weight: 500;
  border-radius: calc(var(--radius-lg) - 4px);
  cursor: pointer; text-align: left;
  transition: var(--transition);
}
.map-basemap-option:hover  { background: var(--surface-2); }
.map-basemap-option.active { color: var(--primary); font-weight: 600; }
.map-basemap-option-icon   { font-size: 1rem; line-height: 1; width: 20px; text-align: center; }

/* action-btn used in map panel close button and other inline actions */
.action-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  border: none; cursor: pointer;
  transition: var(--transition);
}
.action-btn:hover { background: var(--surface-2); color: var(--text); }
.action-btn.action-danger:hover { background: rgba(255,75,75,.1); color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED STAT CARD GRID  (SOS / Tracking / Users)
   ═══════════════════════════════════════════════════════════════════════════ */
.sos-stats, .track-stats, .usr-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 900px) {
  .sos-stats, .track-stats, .usr-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .sos-stats, .track-stats, .usr-stats { grid-template-columns: 1fr; }
}

/* Individual stat card */
.sos-stat-card, .track-stat-card, .usr-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
}
.sos-stat-card:hover, .track-stat-card:hover, .usr-stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-dim);
}

/* Icon box */
.sos-stat-icon, .track-stat-icon, .usr-stat-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* Number + label */
.sos-stat-num, .track-stat-num, .usr-stat-num {
  font-size: 1.5rem; font-weight: 700; line-height: 1.1;
  color: var(--text);
}
.sos-stat-label, .track-stat-label, .usr-stat-label {
  font-size: .78rem; color: var(--text-muted); margin-top: 2px;
}

/* SOS color variants */
.sos-stat-total  .sos-stat-icon { background: var(--danger-dim);  color: var(--danger);  }
.sos-stat-active .sos-stat-icon { background: var(--danger-dim);  color: var(--danger);  }
.sos-stat-acked  .sos-stat-icon { background: rgba(250,173,20,.15); color: var(--warning); }
.sos-stat-resolved .sos-stat-icon { background: var(--success-dim); color: var(--success); }

/* ── Topbar search input (inline pages) ─── */
.topbar-search-input {
  height: 30px;
  padding: 0 10px 0 22px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: .82rem;
  font-family: inherit;
  width: 100%;
}
.topbar-search-input:focus { outline: none; }
.topbar-search-input::placeholder { color: var(--text-muted); }

/* ── Tracking filter row ─── */
.track-filter-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}

/* ── Users filter bar ─── */
.usr-filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.usr-filter-bar .topbar-search-wrap { flex: 1; min-width: 180px; }

/* ═══════════════════════════════════════════════════════════════════════════
   ACTIVITY LOG
   ═══════════════════════════════════════════════════════════════════════════ */
.act-stats {
  display: flex; align-items: center; gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 16px;
  flex-wrap: wrap; gap: 12px;
}
.act-stat-item {
  display: flex; align-items: baseline; gap: 6px;
}
.act-stat-num {
  font-size: 1.25rem; font-weight: 700; color: var(--text);
}
.act-stat-label {
  font-size: .78rem; color: var(--text-muted);
}
.act-stat-divider {
  width: 1px; height: 24px;
  background: var(--border); flex-shrink: 0;
}
.act-filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.act-filter-bar .topbar-search-wrap { flex: 1; min-width: 180px; }
.act-view-toggle {
  display: flex; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; flex-shrink: 0;
}
.act-view-btn {
  width: 32px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.act-view-btn:hover  { background: var(--surface-2); color: var(--text); }
.act-view-btn.active { background: var(--primary-dim); color: var(--primary); }
.act-level-dot {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; margin-right: 4px; flex-shrink: 0;
}
.act-pagination-wrap {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 16px 0 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SYSTEM PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
.sys-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .sys-hero { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .sys-hero { grid-template-columns: 1fr; } }

.sys-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px 16px;
  display: flex; flex-direction: column;
  transition: var(--transition);
}
.sys-hero-card:hover { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary-dim); }
.sys-hero-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; flex-shrink: 0;
}
.sys-hero-val {
  font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.1;
  margin-bottom: 4px;
}
.sys-hero-label {
  font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px;
}
.sys-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 860px) { .sys-grid { grid-template-columns: 1fr; } }
.sys-check-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.sys-check-dot.ok   { background: var(--success); }
.sys-check-dot.fail { background: var(--danger); }

/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
.settings-page { max-width: 960px; }
.settings-layout {
  display: flex; gap: 20px; align-items: flex-start;
}
.settings-sidebar {
  width: 190px; flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  background: transparent; border: none;
  color: var(--text-2); font-size: .845rem; font-weight: 500;
  cursor: pointer; text-align: left; width: 100%;
  transition: var(--transition);
}
.settings-nav-item:hover  { background: var(--surface-2); color: var(--text); }
.settings-nav-item.active {
  background: var(--primary-dim);
  color: var(--primary);
  font-weight: 600;
}
.settings-main {
  flex: 1; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.settings-section-title {
  font-size: .925rem; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.settings-divider {
  height: 1px; background: var(--border); margin: 4px 0;
}
.settings-avatar-row {
  display: flex; align-items: center; gap: 18px; margin-bottom: 4px;
}
.settings-avatar-preview {
  width: 72px; height: 72px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700;
  border: 2px solid var(--border); overflow: hidden;
}
.settings-avatar-actions { display: flex; flex-direction: column; gap: 4px; }
.settings-notif-list { display: flex; flex-direction: column; gap: 0; }
.settings-notif-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-notif-row:last-child { border-bottom: none; }
.settings-notif-name  { font-size: .875rem; font-weight: 600; color: var(--text); }
.settings-notif-desc  { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; transition: transform .15s;
  border: 2px solid transparent;
}
.color-swatch:hover    { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); transform: scale(1.1); }
/* Toggle switch */
.toggle-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
  position: relative;
}
.toggle-track::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-muted);
  transition: transform .2s, background .2s;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--primary-dim); border-color: var(--primary);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(18px); background: var(--primary);
}
@media (max-width: 680px) {
  .settings-layout { flex-direction: column; }
  .settings-sidebar { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   APOC SETTINGS — key cards, ingest config, endpoint list, code block
   ═══════════════════════════════════════════════════════════════════════════ */
.apoc-key-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.apoc-key-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.apoc-key-name { font-size: .9rem; font-weight: 600; color: var(--text); }
.apoc-key-desc { margin-top: 2px; }
.apoc-key-value-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.apoc-key-value {
  flex: 1; min-width: 0;
  font-family: monospace; font-size: .8rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text-2); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; cursor: default;
}
.apoc-key-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.settings-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); margin-bottom: 10px;
}
.ingest-cfg-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.ingest-cfg-label { margin-bottom: 8px; }
.ingest-cfg-name  { font-size: .875rem; font-weight: 600; color: var(--text); }
.ingest-cfg-hint  { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.settings-input-row {
  display: flex; align-items: center; gap: 6px;
}
.settings-input-row .input, .settings-input-row .form-input {
  flex: 1; min-width: 0;
}
.settings-env-badge {
  margin-top: 8px;
}
.settings-env-badge code {
  font-size: .7rem; font-family: monospace;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
  color: var(--primary);
}
.btn-icon-sm {
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.apoc-code-block {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  font-family: monospace; font-size: .78rem; color: var(--text-2);
  white-space: pre-wrap; word-break: break-all;
  max-height: 140px; overflow-y: auto;
}
.apoc-endpoint-list { display: flex; flex-direction: column; gap: 0; }
.apoc-endpoint-row {
  display: grid;
  grid-template-columns: 90px 1fr 80px 1fr;
  align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.apoc-endpoint-row:last-child { border-bottom: none; }
.apoc-endpoint-name { font-weight: 600; font-size: .84rem; color: var(--text); }
.apoc-endpoint-path {
  font-family: monospace; font-size: .78rem;
  color: var(--primary); word-break: break-all;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DM PAGE — action buttons, input toolbar
   ═══════════════════════════════════════════════════════════════════════════ */
.dm-thread-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.dm-action-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  transition: var(--transition);
}
.dm-action-btn:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.dm-action-btn.dm-call  { }
.dm-action-btn.dm-video { }
.dm-input-tool-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.dm-input-tool-btn:hover { color: var(--primary); background: var(--primary-dim); }
.dm-emoji-btn {
  width: 28px; height: 28px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.dm-emoji-btn:hover { color: var(--primary); }

/* ── Call / Video popup ─── */
.dm-call-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,.6); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.dm-call-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 56px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-width: 320px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  animation: callPop .2s ease;
}
@keyframes callPop {
  from { transform: scale(.9); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
.dm-call-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
  margin-bottom: 4px;
}
.dm-call-name  { font-size: 1.3rem; font-weight: 700; color: var(--text); letter-spacing: -.01em; }
.dm-call-state { font-size: .82rem; color: var(--text-muted); letter-spacing: .02em; }
.dm-call-timer { font-size: 1.5rem; font-weight: 700; color: var(--primary); font-family: monospace; margin-top: 2px; }
.dm-call-actions {
  display: flex; gap: 20px; margin-top: 20px; align-items: center;
}
.dm-call-end-btn {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--danger); border: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 16px rgba(255,77,79,.35);
}
.dm-call-end-btn:hover { background: #cc1f1f; transform: scale(1.05); }
.dm-call-mute-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.dm-call-mute-btn:hover { background: var(--primary-dim); color: var(--primary); }
.dm-call-mute-btn.is-muted {
  background: var(--danger-dim);
  border-color: var(--danger);
  color: var(--danger);
}
.dm-call-modal--webrtc .dm-call-videos {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  margin-bottom: 8px;
}
.dm-call-video {
  flex: 1;
  min-height: 140px;
  max-height: 220px;
  border-radius: 12px;
  background: #000;
  object-fit: cover;
}
.dm-call-video-local { border: 2px solid var(--primary); }
.dm-attach-wrap { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.dm-attach-row .btn { font-size: 0.78rem; }
.dm-upload-progress {
  position: absolute;
  bottom: 72px;
  left: 16px;
  right: 16px;
  z-index: 50;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}
#dm-thread { position: relative; }
.dm-incoming-call--global {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 10060;
  max-width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.dm-incoming-call {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 850;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  padding: 14px 16px;
}
.dm-incoming-call-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dm-incoming-call-label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.dm-incoming-call-actions { display: flex; gap: 8px; }

/* ── DM header avatar ─── */
.dm-hdr-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; flex-shrink: 0;
}

/* ── DM info panel ─── */
.dm-info-panel {
  width: 240px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  padding: 24px 18px; gap: 0;
  overflow-y: auto;
}
.dm-info-panel-head {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.dm-info-avatar {
  width: 68px; height: 68px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700;
  margin: 0 auto 12px;
}
.dm-info-name {
  font-weight: 700; font-size: 1rem; color: var(--text); line-height: 1.3;
}
.dm-info-username {
  font-size: .8rem; color: var(--text-muted); margin-top: 3px;
}
.dm-info-status-wrap { margin-top: 8px; }
.dm-info-section {
  margin-top: 16px;
}
.dm-info-section-label {
  font-size: .72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted); margin-bottom: 5px;
}
.dm-info-section-value {
  font-size: .88rem; color: var(--text); line-height: 1.4;
}

.dm-call-pulse {
  position: relative;
}
.dm-call-pulse::before {
  content: ''; position: absolute; inset: -8px;
  border-radius: 50%; border: 2px solid var(--primary);
  animation: callRing 1.5s ease infinite;
}
@keyframes callRing {
  0%   { transform: scale(1);    opacity: .7; }
  100% { transform: scale(1.35); opacity: 0; }
}
/* SOS page — "View on Map" button per card */
.sos-event-map-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; padding: 4px 8px;
}

/* Ensure settings-page uses apoc-page styling base when inside APOC section */
.apoc-page .settings-layout { max-width: none; }
.apoc-page .settings-sidebar { min-width: 160px; }

/* ═══════════════════════════════════════════════════════════════════════════
   APOC SETTINGS v2 — full rewrite (as-* prefix)
   Dark-theme, premium, operational admin console
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Layout ───────────────────────────────────────────────────────────────── */
.as-layout {
  display: flex; gap: 18px; align-items: flex-start;
}
.as-nav {
  width: 188px; flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.as-body {
  flex: 1; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  min-height: 400px;
}
@media (max-width:720px) {
  .as-layout { flex-direction: column; }
  .as-nav    { width: 100%; flex-direction: row; flex-wrap: wrap; }
}

/* ── Nav buttons ──────────────────────────────────────────────────────────── */
.as-nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: .5rem .75rem; width: 100%;
  background: transparent; border: none;
  color: var(--text-2); font-size: .845rem; font-weight: 500;
  border-radius: var(--radius); cursor: pointer; text-align: left;
  transition: var(--transition);
}
.as-nav-btn:hover  { background: rgba(255,255,255,.05); color: var(--text); }
.as-nav-btn.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.as-nav-btn svg    { opacity: .7; flex-shrink: 0; }
.as-nav-btn.active svg { opacity: 1; }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.as-loading {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: .875rem; padding: 32px 8px;
}
.spin { animation: as-spin 1s linear infinite; }
@keyframes as-spin { to { transform: rotate(360deg); } }

/* ── Section blocks ───────────────────────────────────────────────────────── */
.as-section {
  margin-bottom: 28px;
}
.as-section:last-child { margin-bottom: 0; }
.as-section-hd { margin-bottom: 14px; }
.as-section-title {
  font-size: .925rem; font-weight: 700; color: var(--text);
  margin-bottom: 2px;
}
.as-section-sub {
  font-size: .8rem; color: var(--text-muted); line-height: 1.5;
}

/* ── Field cards ──────────────────────────────────────────────────────────── */
.as-field {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 14px;
}
.as-field:last-child { margin-bottom: 0; }
.as-field-row {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.as-field-row .as-field { flex: 1; min-width: 160px; margin-bottom: 0; }
.as-field-label {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: .82rem; font-weight: 600; color: var(--text-2);
}
.as-field-hint {
  font-size: .78rem; color: var(--text-muted); line-height: 1.45;
}
.as-field-hint code, .as-section-sub code { font-family: monospace; font-size: .9em; }

/* ── Inputs — dark theme ─────────────────────────────────────────────────── */
.as-input {
  width: 100%; padding: 8px 11px;
  background: var(--bg-2, #1a1e2b);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .875rem; font-family: var(--font, inherit);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.as-input:hover  { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.as-input:focus  { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-alpha, rgba(0,125,136,.2)); }
.as-input::placeholder { color: var(--text-muted); opacity: .7; }
.as-input.mono   { font-family: var(--font-mono, monospace); font-size: .82rem; letter-spacing: .01em; }
.as-textarea     { min-height: 100px; resize: vertical; line-height: 1.5; }
.as-input[type="number"] { max-width: 160px; }

/* ── Select ──────────────────────────────────────────────────────────────── */
.as-select {
  padding: 7px 11px;
  background: var(--bg-2, #1a1e2b);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: .875rem;
  outline: none; cursor: pointer;
  transition: border-color .15s;
}
.as-select:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.as-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-alpha, rgba(0,125,136,.2)); }

/* ── Input row (field + action buttons inline) ────────────────────────────── */
.as-input-row {
  display: flex; align-items: center; gap: 5px;
}
.as-input-row .as-input { flex: 1; min-width: 0; }

/* ── Icon buttons ─────────────────────────────────────────────────────────── */
.as-icon-btn {
  width: 32px; height: 32px; padding: 0; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-2);
  cursor: pointer; transition: var(--transition);
}
.as-icon-btn:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.as-icon-btn--xs  { width: 26px; height: 26px; }

/* ── Action buttons ───────────────────────────────────────────────────────── */
.as-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: .84rem; font-weight: 600; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
  border: 1px solid transparent;
}
.as-btn--primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.as-btn--primary:hover { background: var(--primary-dark, #006670); }
.as-btn--outline {
  background: transparent; color: var(--text); border-color: var(--border);
}
.as-btn--outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }
.as-btn--ghost  {
  background: transparent; color: var(--text-2); border-color: transparent;
}
.as-btn--ghost:hover { background: rgba(255,255,255,.06); color: var(--text); }
.as-btn--warn   {
  background: transparent; color: var(--warning); border-color: var(--warning);
}
.as-btn--warn:hover { background: rgba(250,173,20,.1); }
.as-btn:disabled { opacity: .5; cursor: default; pointer-events: none; }

/* ── Save row ─────────────────────────────────────────────────────────────── */
.as-save-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Status text ──────────────────────────────────────────────────────────── */
.as-status-text {
  font-size: .82rem; color: var(--success); min-width: 0;
}
.as-warn { color: var(--warning); }

/* ── Env var badge ────────────────────────────────────────────────────────── */
.as-env {
  font-family: monospace; font-size: .72rem;
  background: var(--bg-2, #1a1e2b); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
  color: var(--primary); font-weight: 400;
  white-space: nowrap;
}
.as-code-xs {
  font-family: monospace; font-size: .85em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px;
  color: var(--text);
}

/* ── Secret cards ─────────────────────────────────────────────────────────── */
.as-secret-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 8px;
}
.as-secret-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 6px;
}
.as-secret-name  { font-size: .9rem; font-weight: 600; color: var(--text); }
.as-secret-meta  { font-size: .78rem; color: var(--text-muted); margin-bottom: 4px; }
.as-secret-value {
  display: block; flex: 1; min-width: 0;
  font-family: var(--font-mono, monospace); font-size: .8rem; letter-spacing: .03em;
  background: var(--bg-2, #1a1e2b); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  user-select: none;
}
.as-secret-value--revealed { user-select: all; cursor: text; color: var(--text); }
.as-secret-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── One-time reveal box ──────────────────────────────────────────────────── */
.as-onetime-reveal {
  margin-top: 12px;
}

/* ── Callout banners ──────────────────────────────────────────────────────── */
.as-callout {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 13px; border-radius: var(--radius);
  font-size: .82rem; line-height: 1.5;
}
.as-callout--warn {
  background: rgba(250,173,20,.07); border: 1px solid rgba(250,173,20,.28);
  color: var(--warning);
}
.as-callout--warn strong { color: var(--warning); }
.as-callout--info {
  background: rgba(22,119,255,.06); border: 1px solid rgba(22,119,255,.22);
  color: var(--text);
}
.as-callout--info code { font-family: monospace; font-size: .85em; }
.as-callout svg { flex-shrink: 0; margin-top: 1px; }

/* ── Derived preview (Base URL → URL/Host) ────────────────────────────────── */
.as-derived-preview {
  margin-top: 6px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.as-derived-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: var(--bg-2, #1a1e2b); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .8rem;
}
.as-derived-lbl { color: var(--text-muted); min-width: 65px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.as-derived-val { font-family: monospace; font-size: .8rem; color: var(--primary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Code block ───────────────────────────────────────────────────────────── */
.as-code-block {
  background: var(--bg-2, #1a1e2b); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  font-family: monospace; font-size: .78rem; color: var(--text-2);
  white-space: pre-wrap; word-break: break-all; max-height: 140px; overflow-y: auto;
}

/* ── Endpoint list ────────────────────────────────────────────────────────── */
.as-endpoint-list { display: flex; flex-direction: column; }
.as-ep-row {
  display: grid; grid-template-columns: 90px 1fr 90px 1fr;
  align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.as-ep-row:last-child { border-bottom: none; }
.as-ep-name { font-weight: 600; font-size: .84rem; color: var(--text); }
.as-ep-path { font-family: monospace; font-size: .78rem; color: var(--primary); word-break: break-all; }
.as-ep-desc { font-size: .78rem; color: var(--text-muted); }

/* ── Legacy var table ─────────────────────────────────────────────────────── */
.as-legacy-table { display: flex; flex-direction: column; }
.as-legacy-row {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .8rem;
}
.as-legacy-row:last-child { border-bottom: none; }

/* ── Cert pin info ────────────────────────────────────────────────────────── */
.as-certpin-info { margin-bottom: 12px; }
.as-certpin-info strong { font-family: monospace; color: var(--primary); font-size: .82rem; }

/* ── Old classes kept for backward compat ────────────────────────────────── */
.apoc-settings-callout {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius);
  font-size: .82rem; line-height: 1.5; margin-bottom: 10px;
}
.apoc-settings-callout--warn {
  background: rgba(250,173,20,.08); border: 1px solid rgba(250,173,20,.3);
  color: var(--warning, #faad14);
}
.apoc-settings-callout--info {
  background: rgba(22,119,255,.07); border: 1px solid rgba(22,119,255,.25);
  color: var(--text);
}
.apoc-inline-code {
  display: inline; font-family: var(--font-mono, monospace);
  font-size: .8em; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 0 4px; color: var(--text);
}
.apoc-settings-loading {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: .875rem; padding: 32px 20px;
}
.settings-divider { border: none; border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════════════════
   LIVE MAP — polygon tools, right sidebar, context menu, grid
   ═══════════════════════════════════════════════════════════════════════════ */

/* Polygon tools — top left (Leaflet zoom is at bottomleft so no overlap) */
.map-poly-wrap {
  position: absolute; top: 14px; left: 14px; z-index: 500;
  display: flex; flex-direction: column; gap: 6px;
}
.map-poly-tools {
  display: flex; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 5px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.map-poly-btn {
  width: 30px; height: 30px; border-radius: 6px;
  font-size: .75rem; font-weight: 700;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.map-poly-btn:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.map-poly-btn.active { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.map-poly-a.active   { background: rgba(0,200,200,.15); color: #00C8C8; border-color: #00C8C8; }
.map-poly-b.active   { background: rgba(255,122,69,.15); color: #FF7A45; border-color: #FF7A45; }
.map-poly-clr        { color: var(--danger); }
.map-poly-clr:hover  { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }

.map-poly-filters {
  display: flex; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.map-filter-btn {
  padding: 3px 10px; border-radius: 5px; font-size: .7rem; font-weight: 700;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; transition: var(--transition); letter-spacing: .03em;
}
.map-filter-btn:hover  { background: var(--surface-2); color: var(--text); }
.map-filter-btn.active { background: var(--primary); color: #fff; }

/* Right sidebar strip */
.map-sidebar-strip {
  position: absolute; top: 14px; right: 14px; z-index: 500;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.map-sidebar-strip .map-float-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
  position: relative;
}
.map-sidebar-strip .map-float-btn:hover  { background: var(--surface-2); color: var(--primary); }
.map-sidebar-strip .map-float-btn.active { background: var(--primary-dim); color: var(--primary); }
.map-sidebar-strip .map-float-sep {
  width: 22px; height: 1px; background: var(--border); margin: 2px 0;
}
.map-sidebar-strip .map-float-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 14px; height: 14px; border-radius: 7px; padding: 0 3px;
  background: var(--danger); color: #fff; font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.map-north-indicator {
  display: flex; flex-direction: column; align-items: center;
  gap: 1px; padding: 4px 0; color: var(--primary);
  font-size: .6rem; font-weight: 800; letter-spacing: .05em; opacity: .85;
  cursor: default; user-select: none;
}

/* Context menu */
.map-ctx-menu {
  position: absolute; z-index: 600;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); min-width: 230px;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  padding: 8px 0; overflow: hidden;
}
.map-ctx-menu.hidden { display: none; }
.map-ctx-mgrs {
  padding: 8px 14px 2px;
  font-family: monospace; font-size: .82rem; font-weight: 700;
  color: var(--text); letter-spacing: .04em;
}
.map-ctx-latlon {
  padding: 1px 14px 8px;
  font-size: .75rem; color: var(--primary); font-family: monospace;
}
.map-ctx-sep {
  height: 1px; background: var(--border); margin: 4px 0;
}
.map-ctx-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 14px;
  font-size: .8rem; color: var(--text-2);
  background: none; border: none; cursor: pointer;
  text-align: left; transition: background .1s;
}
.map-ctx-item:hover { background: var(--surface-2); color: var(--text); }
.map-ctx-item svg { flex-shrink: 0; opacity: .6; }
.map-ctx-badge {
  margin-left: auto; flex-shrink: 0;
  font-size: .62rem; font-weight: 700; padding: 1px 5px;
  border-radius: 4px; background: var(--primary-dim); color: var(--primary);
  font-family: monospace; letter-spacing: .03em;
}

/* SOS fly-to popup */
.map-sos-popup .leaflet-popup-content-wrapper {
  background: var(--surface);
  border: 1px solid rgba(255,68,68,.35);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(255,68,68,.2);
}
.map-sos-popup .leaflet-popup-tip { background: var(--surface); }

/* ═══════════════════════════════════════════════════════════════════════════
   UI POLISH PASS — April 2026
   SOS Events · APOC Overview/Devices/Metrics · System · Activity · Users
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Auto-refresh control — styled label ────────────────────────────────── */
.auto-refresh-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--text-2); cursor: pointer;
  padding: 4px 10px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: var(--transition); white-space: nowrap;
  user-select: none;
}
.auto-refresh-label:hover { border-color: var(--primary); color: var(--text); }
.auto-refresh-label input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; }

/* ── Page header: timestamp muted pill ──────────────────────────────────── */
.page-ts {
  font-size: .74rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Empty-state inside cards ───────────────────────────────────────────── */
.card-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 32px 20px; text-align: center; gap: 8px;
  color: var(--text-muted);
}
.card-empty-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-2); border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px; opacity: .7;
}
.card-empty-title { font-size: .875rem; font-weight: 600; color: var(--text-2); }
.card-empty-sub   { font-size: .78rem; color: var(--text-muted); }

/* ── Metric-list: tighten row padding for page-specific use ─────────────── */
.metric-list { display: flex; flex-direction: column; }
.metric-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 18px; min-height: 38px;
  border-bottom: 1px solid var(--border-light);
}
.metric-row:last-child { border-bottom: none; }
.metric-label { font-size: .82rem; color: var(--text-2); }
.metric-value {
  font-size: .875rem; font-weight: 600; color: var(--text);
  text-align: right; max-width: 55%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.metric-value code { font-size: .8rem; color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════════════════════
   SOS EVENTS — POLISH
   ═══════════════════════════════════════════════════════════════════════════ */

/* Select-all row */
.sos-select-all-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 20px; margin-bottom: 6px;
  font-size: .8rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

/* Card — left severity accent + hover */
.sos-event-card {
  border-left: 3px solid var(--border) !important;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  cursor: default;
}
.sos-event-card:hover {
  background: var(--surface-2) !important;
  box-shadow: var(--shadow-sm);
}
/* Status-based left border */
.sos-event-card.active       { border-left-color: var(--danger)  !important; border-color: rgba(255,75,75,.25); }
.sos-event-card.acknowledged { border-left-color: var(--warning) !important; }
.sos-event-card.resolved     { border-left-color: var(--success) !important; opacity: .82; }
/* Severity override (more specific) */
.sos-event-card[data-severity="critical"] { border-left-color: var(--danger)  !important; }
.sos-event-card[data-severity="high"]     { border-left-color: #FF7A45         !important; }
.sos-event-card[data-severity="medium"]   { border-left-color: var(--warning) !important; }
.sos-event-card[data-severity="low"]      { border-left-color: var(--primary) !important; }

/* Card body */
.sos-card-body { flex: 1; min-width: 0; }

/* Card header row: badge · callsign · time */
.sos-card-header {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 6px; flex-wrap: wrap;
}
.sos-card-callsign {
  font-size: .95rem; font-weight: 700; color: var(--text);
  letter-spacing: .01em;
}
.sos-card-time {
  margin-left: auto; font-size: .75rem; color: var(--text-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Severity + message description row */
.sos-card-desc {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: .84rem; color: var(--text-2); line-height: 1.4;
}
.sos-card-msg { color: var(--text-2); }

/* Acknowledgment metadata */
.sos-card-meta {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  font-size: .75rem; color: var(--text-muted);
  margin-top: 7px; padding-top: 7px;
  border-top: 1px solid var(--border-light);
}
.sos-card-meta::before {
  content: '';
  display: inline-block; width: 6px; height: 6px; flex-shrink: 0;
  border-radius: 50%; background: var(--success);
}
.sos-card-meta strong { color: var(--text-2); font-weight: 600; }

/* Actions column */
.sos-card-actions {
  display: flex; flex-direction: column; gap: 6px;
  flex-shrink: 0; align-items: flex-end; justify-content: flex-start;
}

/* Severity badge pill */
.sos-severity {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap; flex-shrink: 0;
}
.sos-severity.critical { background: var(--danger-dim);         color: var(--danger);  }
.sos-severity.high     { background: rgba(255,122,69,.15);       color: #FF7A45;        }
.sos-severity.medium   { background: rgba(255,196,0,.15);        color: var(--warning); }
.sos-severity.low      { background: var(--primary-dim);         color: var(--primary); }

/* Map button: primary accent */
.sos-event-map-btn {
  border-color: rgba(0,125,136,.4) !important;
  color: var(--primary) !important;
}
.sos-event-map-btn:hover {
  background: var(--primary-dim) !important;
  border-color: var(--primary) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   APOC OVERVIEW — POLISH
   ═══════════════════════════════════════════════════════════════════════════ */

/* Quick Navigation — intentional link buttons */
.apoc-quick-nav {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 18px;
}
.apoc-quick-nav a.btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500;
  text-decoration: none;
}
.apoc-quick-nav a.btn::after {
  content: '→'; font-size: .9rem; opacity: .5; margin-left: auto;
}
.apoc-quick-nav a.btn:hover::after { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════════════
   APOC DEVICES — MISSING GRID LAYOUT (fix broken page)
   ═══════════════════════════════════════════════════════════════════════════ */

.apoc-dev-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 800px) { .apoc-dev-stats { grid-template-columns: 1fr 1fr; } }
@media (max-width: 500px) { .apoc-dev-stats { grid-template-columns: 1fr; } }

.apoc-dev-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  transition: var(--transition);
}
.apoc-dev-stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-dim);
}
.apoc-dev-stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.apoc-dev-stat-num {
  font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: var(--text);
}
.apoc-dev-stat-label {
  font-size: .78rem; color: var(--text-muted); margin-top: 2px;
}

/* Filter row */
.dev-filter-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

/* Table + detail panel split layout */
.apoc-dev-layout {
  display: flex; gap: 16px; align-items: flex-start;
}
.apoc-dev-table-wrap { flex: 1; min-width: 0; }

.apoc-dev-detail-panel {
  width: 300px; flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.apoc-dev-detail-inner { display: flex; flex-direction: column; }
.apoc-dev-detail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.apoc-dev-state-block { padding: 14px 16px; overflow-y: auto; }

.apoc-dev-state-freshness {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  margin-bottom: 12px;
}

/* Status dot in table */
.apoc-dev-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
}
.apoc-dev-dot.fresh { background: var(--success); box-shadow: 0 0 5px rgba(0,214,127,.5); }
.apoc-dev-dot.stale { background: var(--warning); }
.apoc-dev-dot.dead  { background: var(--danger);  }

/* Selected row highlight */
.apoc-dev-row-selected td { background: var(--primary-dim) !important; }
.apoc-dev-row-selected:hover td { background: var(--primary-dim) !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   APOC METRICS — MISSING GRID LAYOUT (fix broken page)
   ═══════════════════════════════════════════════════════════════════════════ */

.apoc-metrics-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 960px) { .apoc-metrics-hero { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .apoc-metrics-hero { grid-template-columns: 1fr 1fr; } }

.apoc-metrics-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 18px 16px;
  display: flex; flex-direction: column;
  transition: var(--transition);
}
.apoc-metrics-hero-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-dim);
}
.apoc-mhc-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px; flex-shrink: 0;
}
.apoc-mhc-value {
  font-size: 1.5rem; font-weight: 700; line-height: 1.1;
  color: var(--text); margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.apoc-mhc-label { font-size: .78rem; color: var(--text-muted); }

/* Detail grid (two column) */
.apoc-metrics-grid { display: flex; flex-direction: column; gap: 0; }
.apoc-metrics-grid-inner {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
@media (max-width: 860px) { .apoc-metrics-grid-inner { grid-template-columns: 1fr; } }

/* Counter & latency bar rows */
.apoc-counter-list,
.apoc-latency-list  { display: flex; flex-direction: column; }

.apoc-counter-row,
.apoc-latency-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-light);
}
.apoc-counter-row:last-child,
.apoc-latency-row:last-child { border-bottom: none; }

.apoc-counter-header,
.apoc-latency-header {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.apoc-counter-label,
.apoc-latency-label {
  font-size: .82rem; color: var(--text-2); text-transform: capitalize; flex: 1;
}
.apoc-counter-val {
  font-size: .875rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.apoc-latency-val {
  font-size: .875rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.apoc-counter-bar-track {
  height: 3px; background: var(--surface-2);
  border-radius: 99px; overflow: hidden;
}
.apoc-counter-bar-fill {
  height: 100%; background: var(--primary);
  border-radius: 99px; transition: width .4s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SYSTEM PAGE — POLISH
   ═══════════════════════════════════════════════════════════════════════════ */

/* Progress bar */
.sys-progress-bar {
  height: 5px; background: var(--surface-2);
  border-radius: 99px; overflow: hidden; margin-top: 4px;
}
.sys-progress-fill {
  height: 100%; border-radius: 99px;
  transition: width .4s ease;
}

/* Memory block */
.sys-mem-block { padding: 4px 0; }
.sys-mem-bar-row { padding: 8px 18px 14px; }

/* Hero val — tabular nums for cleaner display */
.sys-hero-val { font-variant-numeric: tabular-nums; }

/* Graceful fallback for missing/NaN values */
.sys-hero-val:empty::before { content: '—'; color: var(--text-muted); font-weight: 400; }

/* ═══════════════════════════════════════════════════════════════════════════
   ACTIVITY LOG — POLISH
   ═══════════════════════════════════════════════════════════════════════════ */

/* Stats bar - number colors by type */
.act-stat-num.error-count { color: var(--danger); }
.act-stat-num.warn-count  { color: var(--warning); }

/* Filter chips — enhanced */
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  font-size: .78rem; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.filter-chip:hover { border-color: var(--primary); color: var(--text); }
.filter-chip.active {
  background: var(--primary-dim); color: var(--primary);
  border-color: var(--primary);
}
/* Level-specific active state */
.filter-chip[data-level="error"].active { background: var(--danger-dim);        color: var(--danger);  border-color: var(--danger);  }
.filter-chip[data-level="warn"].active  { background: rgba(255,196,0,.15);       color: var(--warning); border-color: var(--warning); }
.filter-chip[data-level="info"].active  { background: var(--primary-dim);        color: var(--primary); border-color: var(--primary); }

/* Level badge — CSS classes to replace inline styles */
.act-level-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.act-level-error { background: var(--danger-dim);         color: var(--danger);  }
.act-level-warn  { background: rgba(255,196,0,.15);        color: var(--warning); }
.act-level-info  { background: var(--primary-dim);         color: var(--primary); }
.act-level-debug { background: var(--surface-2);           color: var(--text-muted); }

/* Row expand icon rotation */
.act-expand-icon {
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s ease; color: var(--text-muted);
}
.act-row-expanded .act-expand-icon { transform: rotate(90deg); }

/* Expand detail row */
.act-detail-expand { background: var(--surface-2) !important; }
.act-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px; padding: 14px 20px;
}
.act-detail-block-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted); margin-bottom: 5px;
}
.act-detail-block-val {
  font-size: .85rem; color: var(--text); word-break: break-all;
}
.act-detail-pre {
  font-family: monospace; font-size: .78rem; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all; margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   USERS — POLISH
   ═══════════════════════════════════════════════════════════════════════════ */

/* Stat card top-accent */
.usr-stat-card { position: relative; overflow: hidden; }
.usr-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--primary);
}
.usr-stat-online::before { background: var(--success); }
.usr-stat-admin::before  { background: var(--danger);  }

/* User row actions — fade-in on hover */
.usr-row-actions {
  display: flex; gap: 3px; align-items: center;
  opacity: 0; transition: opacity var(--transition);
}
.usr-row:hover .usr-row-actions { opacity: 1; }
.usr-row td { vertical-align: middle; }

/* Online indicator */
.usr-online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); flex-shrink: 0;
  display: inline-block;
}
.usr-online-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--success);
}

/* Search bar — enhanced for filter bar context */
.usr-filter-bar .topbar-search-wrap,
.dev-filter-row .topbar-search-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px 0 8px;
  height: 34px;
  display: flex; align-items: center; gap: 6px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.usr-filter-bar .topbar-search-wrap:focus-within,
.dev-filter-row .topbar-search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-dim);
}
.usr-filter-bar .topbar-search-input,
.dev-filter-row .topbar-search-input {
  height: 100%; background: transparent; flex: 1; border: none; outline: none;
  color: var(--text); font-size: .83rem; font-family: inherit;
}
.usr-filter-bar .topbar-search-input::placeholder,
.dev-filter-row .topbar-search-input::placeholder { color: var(--text-muted); }

/* usr-stat summary — number color accents */
.usr-stat-num  { font-variant-numeric: tabular-nums; }

/* Timeline dot level colors */
.act-tl-dot--error   { background: var(--danger)  !important; box-shadow: 0 0 0 3px rgba(255,75,75,.15)   !important; }
.act-tl-dot--warn,
.act-tl-dot--warning { background: var(--warning) !important; box-shadow: 0 0 0 3px rgba(255,196,0,.15)   !important; }
.act-tl-dot--info    { background: var(--primary) !important; box-shadow: 0 0 0 3px var(--primary-dim)    !important; }
.act-tl-dot--debug   { background: var(--text-muted) !important; box-shadow: 0 0 0 3px rgba(90,98,120,.15) !important; }

/* ── Data table shared improvements ────────────────────────────────────── */
.data-table th {
  font-size: .72rem; letter-spacing: .07em;
  color: var(--text-muted); font-weight: 700;
  padding: 10px 14px; background: var(--surface-2);
}
.data-table td { padding: 10px 14px; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover td { background: var(--surface-2); cursor: pointer; }
.data-table code {
  font-size: .78rem; color: var(--primary-light);
  background: var(--primary-dim); padding: 1px 6px;
  border-radius: 4px; font-family: monospace;
}

/* ═══════════════════════════════════════════════════════════════════════════
   USERS PAGE — FULL POLISH PASS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Container ── */
.users-page2 { padding: 24px; }

/* ── Header ── */
.users-page2 .page-header { margin-bottom: 24px; }
.users-page2 .page-header h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }

/* ── KPI stat cards ── */
.users-page2 .usr-stat-card { padding: 18px 20px; gap: 16px; }
.users-page2 .usr-stat-card::before { height: 3px; }
.users-page2 .usr-stat-icon { width: 44px; height: 44px; border-radius: 12px; }
.users-page2 .usr-stat-num { font-size: 1.65rem; }
.users-page2 .usr-stat-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  transform: translateY(-1px);
}

/* ── Filter bar ── */
.usr-filter-bar { gap: 12px; margin-bottom: 18px; }
.usr-filter-bar .usr-filter-select {
  height: 34px; padding: 0 10px; font-size: .83rem;
  background: var(--surface-2); width: auto;
}

/* Status dot inside filter chips */
.usr-status-dot-chip {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; display: inline-block;
}

/* ── Table (scoped to users page) ── */
.users-page2 .data-table td { padding: 12px 14px; }
.users-page2 .data-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--border-light);
}
.users-page2 .data-table tbody tr:hover td { background: rgba(0,125,136,.05); }
.users-page2 .usr-row.selected td { background: var(--primary-dim); }

/* ── User cell — structured layout ── */
.usr-row-cell { display: flex; align-items: center; gap: 11px; }
.usr-row-avatar-wrap { position: relative; flex-shrink: 0; display: inline-flex; }
.usr-row-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 700;
}
.usr-row-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.usr-row-name {
  font-weight: 600; font-size: .9rem; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.usr-row-username { font-size: .75rem; color: var(--text-muted); }
.usr-you-badge {
  font-size: .62rem; color: var(--text-muted); font-weight: 500;
  background: var(--surface-2); padding: 1px 5px;
  border-radius: 4px; border: 1px solid var(--border);
}

/* Online indicator — absolutely positioned on avatar */
.users-page2 .usr-online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 9px; height: 9px;
  border: 2px solid var(--surface);
}

/* ── Role badge ── */
.usr-role-badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 6px;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  text-transform: capitalize; border-width: 1px; border-style: solid;
}

/* ── Status column ── */
.usr-status-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.usr-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.usr-status-text { font-size: .82rem; }

/* ── Row actions ── */
.usr-row-actions { gap: 5px; opacity: 0.35; }
.usr-row:hover .usr-row-actions { opacity: 1; }
.btn-icon.primary:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }

/* ── Pagination ── */
.usr-pagination-wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-top: 1px solid var(--border);
}
.usr-pg-btns { display: flex; align-items: center; gap: 4px; }
.usr-pg-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: .82rem; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; transition: var(--transition);
}
.usr-pg-btn:hover:not(:disabled) {
  border-color: var(--primary); color: var(--primary); background: var(--primary-dim);
}
.usr-pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.usr-pg-btn:disabled { opacity: .35; cursor: not-allowed; }
.usr-pg-ellipsis { padding: 0 4px; color: var(--text-muted); font-size: .82rem; align-self: center; }

/* ── Bulk action bar ── */
.usr-bulk-bar {
  gap: 10px; padding: 10px 14px;
  background: var(--primary-dim); border: 1px solid rgba(0,125,136,.35);
  border-radius: var(--radius-lg); margin-bottom: 14px; flex-wrap: wrap;
}
.usr-bulk-count { font-size: .85rem; font-weight: 600; color: var(--primary); white-space: nowrap; }
.usr-bulk-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Detail modal ── */
.usr-detail-modal { max-width: 520px; }
.usr-detail-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.usr-detail-tab {
  padding: 10px 16px; font-size: .85rem; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.usr-detail-tab:hover { color: var(--text); }
.usr-detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.usr-detail-hero { display: flex; align-items: center; gap: 16px; padding: 16px 0; }
.usr-detail-info-grid { padding: 8px 0; }
.usr-info-row {
  display: flex; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--border-light);
}
.usr-info-row:last-child { border-bottom: none; }
.usr-info-key {
  width: 90px; flex-shrink: 0; font-size: .72rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
}
.usr-info-val { font-size: .88rem; color: var(--text); word-break: break-all; }

/* ── Channel list ── */
.usr-channel-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius); background: var(--surface-2);
  border: 1px solid var(--border); transition: border-color var(--transition);
}
.usr-channel-row:hover { border-color: var(--primary); }
.usr-channel-icon { font-size: .95rem; flex-shrink: 0; }

/* ── Create modal — password row ── */
.usr-pw-row { display: flex; gap: 8px; align-items: center; }

/* ═══════════════════════════════════════════════════════════════════════════
   SOS PAGE — FULL POLISH PASS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Missing button variants ── */
.btn-warning {
  background: rgba(255,196,0,.15); color: var(--warning);
  border: 1px solid rgba(255,196,0,.3);
}
.btn-warning:hover:not(:disabled) {
  background: var(--warning); color: #1a1600; border-color: var(--warning);
}
.btn-success {
  background: var(--success-dim); color: var(--success);
  border: 1px solid rgba(0,214,127,.3);
}
.btn-success:hover:not(:disabled) {
  background: var(--success); color: #fff; border-color: var(--success);
}

/* ── Header ── */
.sos-page .page-header { margin-bottom: 24px; }
.sos-page .page-header h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }

/* ── KPI stat cards — accent stripe + premium lift ── */
.sos-stat-card { position: relative; overflow: hidden; }
.sos-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: 2px 2px 0 0; background: var(--border);
}
.sos-stat-total::before   { background: var(--danger);  }
.sos-stat-active::before  { background: var(--danger);  }
.sos-stat-acked::before   { background: var(--warning); }
.sos-stat-resolved::before { background: var(--success); }

.sos-page .sos-stat-card { padding: 18px 20px; gap: 16px; }
.sos-page .sos-stat-icon { width: 44px; height: 44px; border-radius: 12px; }
.sos-page .sos-stat-num  { font-size: 1.65rem; }
.sos-page .sos-stat-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.25); transform: translateY(-1px);
}

/* Active count always red */
#sos-stat-active { color: var(--danger); }

/* ── Alert banner — animated urgency ── */
.sos-banner {
  border-left: 3px solid var(--danger);
  font-size: .9rem;
  animation: sos-pulse-bg 2.8s ease-in-out infinite;
}
@keyframes sos-pulse-bg {
  0%, 100% { background: var(--danger-dim); }
  50%       { background: rgba(255,75,75,.2); }
}
.sos-banner svg { animation: sos-shake 3s ease-in-out infinite; }
@keyframes sos-shake {
  0%, 60%, 100% { transform: rotate(0deg); }
  65%           { transform: rotate(-12deg); }
  72%           { transform: rotate(12deg); }
  80%           { transform: rotate(-6deg); }
  87%           { transform: rotate(6deg); }
}

/* ── Event cards ── */
.sos-event-card { padding: 18px 20px; }
.sos-event-card.active { background: rgba(255,75,75,.03) !important; }
.sos-card-header { margin-bottom: 8px; }

/* Status badge — bordered pill */
.sos-status-badge { border-width: 1px; border-style: solid; border-color: transparent; }
.sos-status-badge.active       { border-color: rgba(255,75,75,.35); }
.sos-status-badge.acknowledged { border-color: rgba(250,173,20,.35); }
.sos-status-badge.resolved     { border-color: rgba(0,214,127,.35); }

/* Ack / Resolve action buttons — SOS-contextual colors */
.sos-card-actions .btn-ghost[data-action="ack"] {
  border-color: rgba(255,196,0,.4); color: var(--warning);
}
.sos-card-actions .btn-ghost[data-action="ack"]:hover {
  background: rgba(255,196,0,.12); border-color: var(--warning);
}
.sos-card-actions .btn-ghost[data-action="resolve"] {
  border-color: rgba(0,214,127,.4); color: var(--success);
}
.sos-card-actions .btn-ghost[data-action="resolve"]:hover {
  background: var(--success-dim); border-color: var(--success);
}

/* ── Bulk bar — danger-tinted for SOS context ── */
.sos-bulk-bar {
  background: var(--danger-dim) !important;
  border-color: rgba(255,75,75,.35) !important;
}
.sos-bulk-count { font-size: .875rem; font-weight: 600; color: var(--danger); }
.sos-bulk-actions { display: flex; gap: 8px; }

/* ── Trigger SOS modal ── */
.sos-trigger-modal .modal-title { color: var(--danger); }
.sos-trigger-modal .modal-desc  { font-size: .85rem; color: var(--text-2); margin-bottom: 16px; }

/* ═══════════════════════════════════════════════════════════════════════════
   MAP PAGE — SOS PANEL + BACK TO SOS BUTTON
   ═══════════════════════════════════════════════════════════════════════════ */

/* Back to SOS button — rendered inside the floating card header only when alert is selected */
.map-back-sos-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-2);
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  cursor: pointer; white-space: nowrap;
  transition: var(--transition);
}
.map-back-sos-btn:hover {
  background: var(--danger-dim); color: var(--danger);
  border-color: rgba(255,75,75,.4);
}

/* SOS Alert Details — compact floating card, injected into DOM only when an alert is selected */
.map-sos-panel {
  position: absolute;
  top: 100px;           /* sits below the poly-wrap tools */
  left: 14px;
  z-index: 490;
  width: 252px;
  max-height: calc(100% - 130px);
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(255, 75, 75, .22);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.18);
}

/* Panel header title group */
.map-sos-panel-title {
  display: flex; align-items: center; gap: 7px;
}
.map-sos-panel-title h3 {
  font-size: .9rem; font-weight: 600;
}

/* Override header padding for the compact card */
.map-sos-panel .map-channel-panel-header {
  padding: .6rem .875rem;
}

/* Scrollable panel body */
.map-sos-panel-body {
  flex: 1; overflow-y: auto;
  padding: 10px 13px;
  display: flex; flex-direction: column; gap: 0;
}

/* Empty / loading state */
.map-sos-panel-empty {
  padding: 1.25rem 0;
  color: var(--text-muted); font-size: .84rem;
  text-align: center; line-height: 1.5;
}

/* Badge row at the top of the panel body */
.map-sos-detail-badges {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* Grouped section with top separator */
.map-sos-detail-section {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.map-sos-detail-section:first-of-type {
  border-top: none; padding-top: 0; margin-top: 0;
}

/* Key/value detail row */
.map-sos-detail-row {
  display: flex; flex-direction: column; gap: 2px;
}
.map-sos-detail-key {
  font-size: .67rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
}
.map-sos-detail-val {
  font-size: .85rem; color: var(--text);
  word-break: break-word; line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACTIVITY LOG — VISUAL UPGRADE
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Page layout & header ── */
.activity-page { padding: 28px; }
.activity-page .page-header {
  margin-bottom: 24px;
  align-items: flex-start;
}
.activity-page .page-header h2 {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; color: var(--text);
}
.activity-page .page-sub {
  margin-top: 4px; font-size: .83rem; color: var(--text-muted);
}
.activity-page .page-actions { gap: 10px; flex-wrap: wrap; align-items: center; }

/* ── View toggle ── */
.act-view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; flex-shrink: 0;
}
.act-view-btn {
  width: 36px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.act-view-btn:hover { background: var(--surface-2); color: var(--text); }
.act-view-btn.active {
  background: var(--primary-dim); color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

/* ── Auto-refresh control ── */
.act-auto-label {
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--text-2); cursor: pointer; flex-shrink: 0;
  padding: 0 10px; height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: border-color var(--transition), color var(--transition);
}
.act-auto-label:hover { border-color: var(--primary); color: var(--text); }

/* ══════════════════════════════════════════════
   KPI STAT CARDS — Grid of individual cards
   ══════════════════════════════════════════════ */
.act-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 22px;
  /* Clear the old flat-bar styles */
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
.act-stats::before { display: none; }

.act-stat-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative; overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.act-stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--border);
}
.act-stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

/* Per-card accent colours */
.act-stat-card--total::before  { background: var(--text-muted); }
.act-stat-card--info::before   { background: var(--primary); }
.act-stat-card--warn::before   { background: var(--warning); }
.act-stat-card--error::before  { background: var(--danger); }
.act-stat-card--actors::before { background: var(--success); }

.act-stat-card--info:hover  { border-color: var(--primary); }
.act-stat-card--warn:hover  { border-color: var(--warning); }
.act-stat-card--error:hover { border-color: var(--danger); }

/* Override old flat item/divider styles so they don't interfere */
.act-stats .act-stat-item  { display: none; }
.act-stats .act-stat-divider { display: none; }

.act-stat-num {
  font-size: 1.8rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--text);
  letter-spacing: -.02em;
}
.act-stat-card--info   .act-stat-num { color: var(--primary); }
.act-stat-card--warn   .act-stat-num { color: var(--warning); }
.act-stat-card--error  .act-stat-num { color: var(--danger);  }
.act-stat-card--actors .act-stat-num { color: var(--success); }

.act-stat-label {
  font-size: .7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted);
}

@media (max-width: 860px) {
  .act-stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .act-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════ */
.act-filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.act-filter-bar .filter-chips { margin-bottom: 0; gap: 6px; flex-wrap: nowrap; }

/* Level filter chips — bigger, more prominent */
.activity-page .filter-chip {
  height: 34px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 500;
  border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  transition: all var(--transition); white-space: nowrap;
  user-select: none;
}
.activity-page .filter-chip:hover {
  border-color: var(--text-2); color: var(--text);
  background: var(--surface);
}
.activity-page .filter-chip.active {
  background: var(--primary-dim); color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  font-weight: 600;
}
.activity-page .filter-chip[data-level="error"].active {
  background: var(--danger-dim); color: var(--danger);
  border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger);
}
.activity-page .filter-chip[data-level="warn"].active {
  background: rgba(255,196,0,.15); color: var(--warning);
  border-color: var(--warning); box-shadow: 0 0 0 1px var(--warning);
}
.activity-page .filter-chip[data-level="info"].active {
  background: var(--primary-dim); color: var(--primary);
  border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary);
}

/* Search input */
.act-filter-bar .topbar-search-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px 0 10px;
  height: 36px;
  display: flex; align-items: center; gap: 7px;
  transition: border-color var(--transition), box-shadow var(--transition);
  flex: 1; min-width: 200px; max-width: 280px;
}
.act-filter-bar .topbar-search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-dim);
}
.act-filter-bar .topbar-search-input {
  height: 100%; background: transparent; flex: 1;
  border: none; outline: none;
  color: var(--text); font-size: .85rem; font-family: inherit;
}
.act-filter-bar .topbar-search-input::placeholder { color: var(--text-muted); opacity: 1; }

/* Category dropdown */
.activity-page #act-category-filter {
  height: 36px; font-size: .83rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 12px; min-width: 150px; cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.activity-page #act-category-filter:hover,
.activity-page #act-category-filter:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-dim);
  outline: none;
}

/* ══════════════════════════════════════════════
   TABLE — The main event
   ══════════════════════════════════════════════ */
.activity-page .table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.activity-page .data-table {
  border-collapse: collapse; width: 100%;
}

/* ── Header ── */
.activity-page .data-table thead tr {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
}
.activity-page .data-table thead th {
  padding: 13px 16px;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-muted); white-space: nowrap;
  background: transparent;
}
.act-th-expand  { width: 36px !important; padding: 13px 0 13px 14px !important; }
.act-th-time    { width: 90px; }
.act-th-level   { width: 80px; }
.act-th-cat     { width: 110px; }
.act-th-actor   { width: 140px; }
.act-th-action  { color: var(--text) !important; }
.act-th-detail  { width: 200px; }

/* ── Body rows ── */
.activity-page .data-table tbody tr.act-row {
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.activity-page .data-table tbody tr.act-row:last-child {
  border-bottom: none;
}

/* Alternating row tint for scannability */
.activity-page .data-table tbody tr.act-row:nth-child(even) td {
  background: rgba(255,255,255,.018);
}

/* ── Hover — clearly visible ── */
.activity-page .data-table tbody tr.act-row:hover td {
  background: rgba(0,125,136,.1) !important;
}
.activity-page .data-table tbody tr.act-row:hover .act-td-action {
  color: var(--primary-light, var(--primary));
}

/* Expanded row highlight */
.activity-page .data-table tbody tr.act-row-expanded > td {
  background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border);
}

/* ── Cell base ── */
.activity-page .data-table tbody td {
  padding: 14px 16px; vertical-align: middle;
}

/* ── Column-specific cells ── */
.act-td-expand {
  padding: 14px 4px 14px 14px !important;
  width: 36px;
}
.act-loading-cell {
  text-align: center; padding: 36px !important;
}

/* TIME — small, muted, secondary */
.act-td-time {
  font-size: .75rem; color: var(--text-muted);
  white-space: nowrap; font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

/* LEVEL cell */
.act-td-level { white-space: nowrap; }

/* CATEGORY badge */
.act-td-cat { white-space: nowrap; }
.act-cat-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--radius);
  font-size: .7rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border);
  letter-spacing: .02em; white-space: nowrap;
}
.act-td-empty { color: var(--text-muted); font-size: .8rem; }

/* ACTOR */
.act-td-actor { white-space: nowrap; }
.act-actor-cell { display: flex; align-items: center; gap: 8px; }
.act-actor-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-dim); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .62rem; font-weight: 700; flex-shrink: 0;
  border: 1px solid rgba(0,125,136,.25);
}
.act-actor {
  color: var(--text-2); font-size: .83rem; font-weight: 500;
}

/* ACTION — PRIMARY column, highest visual weight */
.act-td-action {
  font-size: .875rem; font-weight: 600;
  color: var(--text);
  max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  transition: color var(--transition);
}

/* DETAIL — muted, truncated */
.act-td-detail { max-width: 200px; }
.log-detail {
  font-size: .75rem; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: block; max-width: 200px;
}

/* ── Level badges — stronger ── */
.act-level-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap; border: 1px solid transparent;
}
.act-level-error {
  background: var(--danger-dim); color: var(--danger);
  border-color: rgba(255,75,75,.3);
}
.act-level-warn {
  background: rgba(255,196,0,.15); color: var(--warning);
  border-color: rgba(255,196,0,.3);
}
.act-level-info {
  background: var(--primary-dim); color: var(--primary);
  border-color: rgba(0,125,136,.3);
}
.act-level-debug {
  background: var(--surface-2); color: var(--text-muted);
  border-color: var(--border);
}

/* ── Expand icon ── */
.act-expand-icon {
  opacity: .3; flex-shrink: 0;
  transition: transform .15s ease, opacity .12s ease, color .12s ease;
  display: block;
}
.act-row:hover .act-expand-icon { opacity: .75; }
.act-row-expanded .act-expand-icon {
  opacity: 1; color: var(--primary);
}

/* ── Expand detail panel ── */
.act-detail-row td { padding: 0 !important; }
.act-detail-expand {
  background: var(--surface-2) !important;
  border-top: 1px solid var(--border) !important;
  border-bottom: 2px solid var(--border) !important;
}
.act-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; padding: 18px 20px;
}
.act-detail-block-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); margin-bottom: 5px;
}
.act-detail-block-val {
  font-size: .875rem; color: var(--text); word-break: break-all; line-height: 1.5;
}
.act-detail-pre {
  font-family: monospace; font-size: .78rem; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all;
  margin: 6px 20px 18px; line-height: 1.55;
}

/* ── Pagination ── */
.act-pagination-wrap { gap: 8px; padding: 20px 0 8px; }

/* ══════════════════════════════════════════════
   TIMELINE VIEW
   ══════════════════════════════════════════════ */
.act-timeline { padding: 4px 0 16px; }
.act-tl-day-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-muted);
  padding: 14px 0 8px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: 18px;
}
.act-tl-group {
  display: flex; flex-direction: column; gap: 0;
  padding-left: 28px;
  border-left: 2px solid var(--border);
  margin-bottom: 28px; position: relative;
}
.act-tl-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 8px; position: relative;
  border-bottom: 1px solid rgba(255,255,255,.04);
  border-radius: var(--radius);
  transition: background var(--transition);
}
.act-tl-item:last-child { border-bottom: none; }
.act-tl-item:hover { background: rgba(0,125,136,.06); }
.act-tl-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
  position: absolute; left: -34px; top: 16px;
  border: 2px solid var(--bg, #0f1117);
}
.act-tl-content { flex: 1; min-width: 0; }
.act-tl-header {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 5px;
}
.act-tl-action {
  font-weight: 600; font-size: .875rem;
  color: var(--text); flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.act-tl-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem; color: var(--text-muted); margin-top: 3px;
}
.act-tl-detail {
  margin-top: 5px; font-size: .78rem; color: var(--text-muted); line-height: 1.45;
}
.act-tl-time {
  font-size: .75rem; color: var(--text-muted); margin-left: auto;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.act-tl-by { font-size: .78rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   ACTIVITY LOG — FILTER SECTION + DETAIL PANEL + COPY BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Filter section container ── */
.act-filters-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex; flex-direction: column; gap: 0;
}

/* ── Filter rows ── */
.act-filter-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.act-filter-row--top { gap: 8px; padding-bottom: 14px; }
.act-filter-row--controls {
  gap: 14px; flex-wrap: wrap; align-items: flex-end;
  border-top: 1px solid var(--border); padding-top: 14px;
}

/* ── "Quick:" label ── */
.act-filter-row-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); flex-shrink: 0;
  white-space: nowrap;
}

/* ── Quick preset chips ── */
.act-quick-chips {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1;
}
.act-quick-chip {
  height: 28px; padding: 0 11px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 500;
  border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted);
  transition: all var(--transition); white-space: nowrap;
  user-select: none;
}
.act-quick-chip:hover { border-color: var(--text-2); color: var(--text); }
.act-quick-chip.active {
  background: var(--primary-dim); color: var(--primary);
  border-color: var(--primary); font-weight: 600;
}

/* Error quick chip */
.act-quick-chip--error:hover   { border-color: var(--danger); color: var(--danger); }
.act-quick-chip--error.active  {
  background: var(--danger-dim); color: var(--danger);
  border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger);
}

/* Category quick chips */
.act-quick-chip--cat:hover  { border-color: var(--warning); color: var(--warning); }
.act-quick-chip--cat.active {
  background: rgba(255,196,0,.12); color: var(--warning);
  border-color: var(--warning); box-shadow: 0 0 0 1px var(--warning);
}

/* ── Search wrap ── */
.act-search-wrap {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 220px; max-width: 300px; flex-shrink: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.act-search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-dim);
}
.act-search-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: .84rem; font-family: inherit; color: var(--text);
}
.act-search-input::placeholder { color: var(--text-muted); }

/* ── Individual filter groups (label + control stacked) ── */
.act-filter-group {
  display: flex; flex-direction: column; gap: 5px; flex-shrink: 0;
}
.act-filter-group-label {
  font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); white-space: nowrap;
}
.act-level-chips { display: flex; gap: 5px; align-items: center; }

/* Filter select + input shared base */
.act-filter-select,
.act-filter-input {
  height: 32px; padding: 0 10px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .82rem; font-family: inherit; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.act-filter-select { min-width: 130px; cursor: pointer; }
.act-filter-input  { min-width: 120px; }
.act-filter-select:hover, .act-filter-input:hover { border-color: var(--text-2); }
.act-filter-select:focus, .act-filter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-dim);
}

/* Date inputs — dark mode calendar icon */
.act-filter-date {
  min-width: 148px;
  color-scheme: dark;
}
.act-filter-date::-webkit-calendar-picker-indicator {
  filter: invert(.55); cursor: pointer; opacity: .7;
}
.act-filter-date::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* ── Reset button ── */
.act-reset-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 12px;
  font-size: .78rem; font-weight: 500; cursor: pointer;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-muted);
  transition: all var(--transition); white-space: nowrap;
  align-self: flex-end;
}
.act-reset-btn:hover {
  border-color: var(--danger); color: var(--danger);
  background: var(--danger-dim);
}

/* ══════════════════════════════════════════════
   DETAIL PANEL
   ══════════════════════════════════════════════ */

.act-detail-td { padding: 0 !important; }

.act-detail-panel {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
}

/* Panel header */
.act-detail-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 13px; gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.act-detail-panel-title {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
}
.act-detail-panel-action {
  font-size: .9rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.act-detail-panel-hdr-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}

/* Metadata grid — cells separated by 1px border lines */
.act-detail-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0;
  background: var(--border); /* gap fills with border colour */
  border-bottom: 1px solid var(--border);
}
.act-detail-field {
  display: flex; flex-direction: column; gap: 6px;
  padding: 13px 18px;
  background: var(--surface-2);
}
.act-detail-field-label {
  font-size: .64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-muted);
}
.act-detail-field-val {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--text); word-break: break-all; line-height: 1.4;
}
.act-detail-id {
  font-family: monospace; font-size: .75rem; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}

/* Detail sections (action, payload) */
.act-detail-section {
  padding: 13px 20px;
  border-bottom: 1px solid rgba(255,255,255,.045);
}
.act-detail-section:last-child { border-bottom: none; }
.act-detail-section-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.act-detail-section-title {
  font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-muted);
}
.act-detail-section-body {
  font-size: .875rem; color: var(--text); line-height: 1.55;
  word-break: break-word;
}

/* ── Copy buttons ── */
.act-copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: var(--radius);
  font-size: .75rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted);
  transition: all var(--transition); white-space: nowrap; flex-shrink: 0;
}
.act-copy-btn:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-dim);
}
.act-copy-btn.act-copied {
  border-color: var(--success, #22c55e);
  color: var(--success, #22c55e);
  background: rgba(34,197,94,.1);
}

/* Small icon-only copy button (appears inline next to field values) */
.act-copy-btn--sm {
  padding: 2px 5px;
  font-size: .68rem;
  opacity: 0;
  transition: opacity var(--transition), border-color var(--transition),
              color var(--transition), background var(--transition);
}
.act-detail-field:hover .act-copy-btn--sm,
.act-detail-section-hd .act-copy-btn--sm { opacity: .55; }
.act-copy-btn--sm:hover { opacity: 1 !important; }
.act-copy-btn--sm.act-copied { opacity: 1; }

/* ── Improved empty state ── */
.act-empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 56px 24px; gap: 8px;
  text-align: center;
}
.act-empty-title {
  font-size: .95rem; font-weight: 600; color: var(--text-2); margin-top: 4px;
}
.act-empty-sub {
  font-size: .82rem; color: var(--text-muted); max-width: 320px; line-height: 1.5;
}
.act-empty-reset {
  margin-top: 12px; padding: 7px 18px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-2);
  font-size: .8rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.act-empty-reset:hover {
  border-color: var(--primary); color: var(--primary); background: var(--primary-dim);
}

/* ── Activity: mode tabs ──────────────────────────────────────────────────── */
.act-mode-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.act-mode-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; background: none;
  font-size: .85rem; font-weight: 500; cursor: pointer;
  color: var(--text-2); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color var(--transition), border-color var(--transition);
}
.act-mode-tab:hover { color: var(--text); }
.act-mode-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── System logs: toolbar ─────────────────────────────────────────────────── */
.sys-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 10px;
}

/* ── System logs: terminal console ───────────────────────────────────────── */
.sys-console {
  background: #0d1117; color: #c9d1d9;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 12px; font-family: 'SF Mono', 'Fira Code', Consolas, 'Courier New', monospace;
  font-size: .78rem; line-height: 1.6;
  min-height: 340px; max-height: 65vh; overflow-y: auto;
}
[data-theme="light"] .sys-console { background: #f6f8fa; color: #24292f; border-color: #d0d7de; }

.sys-console-empty {
  color: var(--text-muted, #5a6278); text-align: center; padding: 40px 0;
  font-family: inherit; font-size: .82rem;
}
.sys-loading { text-align: center; padding: 40px 0; color: var(--text-2); font-size: .82rem; }

.sys-line { display: flex; gap: 8px; align-items: baseline; padding: 1px 0; }
.sys-line:hover { background: rgba(255,255,255,.03); }
[data-theme="light"] .sys-line:hover { background: rgba(0,0,0,.03); }

.sys-ts  { color: #8b949e; flex-shrink: 0; min-width: 140px; }
.sys-lvl { flex-shrink: 0; font-weight: 600; min-width: 36px; }
.sys-lvl--info  { color: #58a6ff; }
.sys-lvl--warn  { color: #e3b341; }
.sys-lvl--error { color: #f85149; }
.sys-src { color: #79c0ff; flex-shrink: 0; }
.sys-msg { word-break: break-all; flex: 1; }

.sys-line--error .sys-msg { color: #ffa198; }
.sys-line--warn  .sys-msg { color: #e3b341; }

[data-theme="light"] .sys-ts   { color: #57606a; }
[data-theme="light"] .sys-src  { color: #0550ae; }
[data-theme="light"] .sys-lvl--info  { color: #0550ae; }
[data-theme="light"] .sys-lvl--warn  { color: #b08800; }
[data-theme="light"] .sys-lvl--error { color: #cf222e; }

.sys-live-badge {
  display: inline-block; color: #3fb950;
  font-size: .78rem; padding: 2px 0; animation: sysBlink 1.2s ease-in-out infinite;
}
@keyframes sysBlink { 0%,100%{opacity:1} 50%{opacity:.4} }

.sys-status-bar {
  margin-top: 6px; font-size: .75rem; color: var(--text-muted, #5a6278);
  text-align: right;
}
