/* Vigil design system.
   Extracted from templates/base.html so browsers cache it once instead of
   re-downloading ~50KB of identical CSS with every page navigation. */

/* ═══════════════════════════════════════════════════════════════════════
   Vigil Design System
   ═══════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette */
  --navy:      #0F1C35;
  --navy-mid:  #1B2D4F;
  --navy-light:#243A63;
  --accent:    #3B82F6;
  --accent-h:  #2563EB;
  --teal:      #0EA5E9;
  --green:     #10B981;
  --amber:     #F59E0B;
  --red:       #EF4444;
  --purple:    #8B5CF6;

  /* Argus palette.
     Matched to the Vigil triskele mark, whose plate is #3B82F6 — the same blue
     as --accent. The assistant is part of the product, not a third-party
     add-on, and the previous indigo-to-pink gradient read as one. */
  --ai-1: #3B82F6;   /* the triskele plate colour exactly */
  --ai-2: #2563EB;   /* deeper blue, for text and focus rings on light ground */
  --ai-3: #0EA5E9;   /* the palette's teal, so the gradient still has movement */
  --ai-glow: 59,130,246;   /* rgb triplet for shadows and focus rings */

  /* Surfaces */
  --bg:        #F0F4F8;
  --surface:   #FFFFFF;
  --surface-2: #F8FAFC;
  --border:    #E2E8F0;
  --border-2:  #CBD5E1;

  /* Text */
  --text:      #0F172A;
  --text-2:    #475569;
  --text-3:    #94A3B8;

  /* Sidebar */
  --sb-w:          240px;
  --sb-collapsed-w: 60px;
  --sb-bg:   var(--navy);
  --sb-text: rgba(255,255,255,.75);
  --sb-text-h: #FFFFFF;
  --sb-active: rgba(59,130,246,.25);
  --sb-border: rgba(255,255,255,.08);

  /* Misc */
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --transition: 150ms ease;
}

/* ── Reset & base ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(59,130,246,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,.045) 1px, transparent 1px);
  background-size: 32px 32px;
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
svg { display: block; flex-shrink: 0; }
button { cursor: pointer; font-family: inherit; }

.page-body {
  padding: 24px;
  flex: 1;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sb-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}
.sidebar-nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
/* Transitions enabled only after JS restores state (prevents FOUC) */
.sidebar.sb-anim            { transition: width 0.28s cubic-bezier(.4,0,.2,1); }
.sidebar.sb-anim + .main-wrap { transition: margin-left 0.28s cubic-bezier(.4,0,.2,1); }

.sidebar.collapsed { width: var(--sb-collapsed-w); }
.sidebar.collapsed + .main-wrap { margin-left: var(--sb-collapsed-w); }

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--sb-border);
  overflow: hidden; white-space: nowrap;
}
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 18px 0 14px; gap: 0; }
.logo-mark {
  width: 32px; height: 32px; flex-shrink: 0;
  background: linear-gradient(135deg, #3B82F6, #6366F1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
@keyframes triskele-spin {
  to { transform: rotate(-360deg); }
}
.logo-mark svg {
  width: 20px; height: 20px;
  animation: triskele-spin 28s linear infinite;
  transform-origin: center;
  transform-box: fill-box;
  transition: animation-duration .4s;
}
.logo-mark:hover svg { animation-duration: 4s; }

/* ══ The mark ══
   Every triskele on the platform is this: the real asset (never a redrawn
   SVG, which drifts from the app icon), turning slowly the way the Argus
   button does. Hovering its container spins it up; the mark has 120°
   rotational symmetry, so any third of a turn lands it back on itself. */
.vg-mark {
  display: block; width: 70%; height: 70%; object-fit: contain; pointer-events: none;
  animation: triskele-spin 28s linear infinite;
  transform-origin: center;
}
.logo-mark .vg-mark, .brand-mark .vg-mark { width: 62%; height: 62%; }
.logo-mark:hover .vg-mark, .brand-mark:hover .vg-mark { animation-duration: 4s; }
/* On light surfaces the white mark disappears, so the auto variant follows the theme. */
.vg-mark-auto { content: url("../img/vigil_triskele_dark.16ae3b31cfe0.png"); }
[data-theme="dark"] .vg-mark-auto, [data-theme="midnight"] .vg-mark-auto,
[data-theme="ocean"] .vg-mark-auto, [data-theme="forest"] .vg-mark-auto,
[data-theme="crimson"] .vg-mark-auto { content: url("../img/vigil_triskele_white.3708769aea88.png"); }
@media (prefers-reduced-motion: reduce) { .vg-mark { animation-duration: 120s; } }
.logo-text-wrap { overflow: hidden; transition: opacity .2s, width .28s; }
.sidebar.collapsed .logo-text-wrap { opacity: 0; width: 0; }
.logo-text { color: #fff; font-weight: 700; font-size: 16px; }
.logo-org  { color: var(--sb-text); font-size: 11px; margin-top: 1px; }

.sidebar-section { padding: 8px 8px 0; }
.sidebar-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sb-text);
  opacity: .5; padding: 8px 8px 4px;
  overflow: hidden; white-space: nowrap;
  transition: opacity .15s, height .28s;
}
.sidebar.collapsed .sidebar-section-label { opacity: 0; height: 0; padding: 0; }

.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--sb-text);
  font-size: 13px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  white-space: nowrap; overflow: hidden;
  position: relative; /* allows badge to anchor absolutely in collapsed mode */
}
.sidebar nav a svg { width: 16px; height: 16px; opacity: .7; flex-shrink: 0; }
.sidebar nav a:hover { background: rgba(255,255,255,.1); color: var(--sb-text-h); }
.sidebar nav a:hover svg { opacity: 1; }
.sidebar nav a.active { background: var(--sb-active); color: var(--sb-text-h); }
.sidebar nav a.active svg { opacity: 1; }

/* Collapsed sidebar: pin count badges to top-right corner of the icon */
.sidebar.collapsed #nav-alert-badge,
.sidebar.collapsed #nav-report-badge {
  position: absolute;
  top: 3px; right: 3px;
  margin-left: 0;
  min-width: 14px; height: 14px;
  padding: 0 3px;
  font-size: 8px;
  border-radius: 7px;
}

/* ── Rich nav tooltip ── */
#nav-tooltip {
  position: fixed;
  left: 0; top: 0; /* positioned by JS */
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity .08s ease;
  max-width: 240px;
}
#nav-tooltip.visible { opacity: 1; }
#nav-tooltip-inner {
  background: #1a1f2e;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px;
  padding: 10px 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
#nav-tooltip-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  letter-spacing: .01em;
}
#nav-tooltip-desc {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  line-height: 1.55;
}

.sidebar.collapsed nav a { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-label { display: none; }

/* AI nav link special icon */
.ai-icon-wrap {
  width: 22px; height: 22px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ai-1), var(--ai-3));
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
}
.ai-icon-wrap svg { width: 13px; height: 13px; opacity: 1; color: #fff; }
.sidebar.collapsed nav a .ai-icon-wrap { width: 20px; height: 20px; }
.sidebar nav a.active .ai-icon-wrap { box-shadow: 0 0 10px rgba(var(--ai-glow),.4); }

.sidebar-toggle {
  display: flex; align-items: center; justify-content: center;
  padding: 10px; margin: 4px 8px 0;
  background: none; border: none;
  border-radius: 6px;
  color: rgba(255,255,255,.35);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.75); }
.sidebar-toggle svg { width: 14px; height: 14px; transition: transform 0.28s cubic-bezier(.4,0,.2,1); }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--sb-border);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--sb-text);
  overflow: hidden; white-space: nowrap;
}
.sidebar.collapsed .sidebar-footer { padding: 12px 0; display: flex; justify-content: center; align-items: center; }
.sidebar-footer .user-email { font-weight: 500; color: #fff; }
.sidebar-footer-full { transition: opacity .2s; }
.sidebar.collapsed .sidebar-footer-full { display: none; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #0D9488, #0891B2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: rgba(255,255,255,.9);
  flex-shrink: 0;
}
.sidebar-avatar-collapsed { display: none; }
/* Sign out: a button of its own at the foot of the sidebar (any /logout/ link plays the departure in base.html) */
.sb-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.sb-actions #theme-toggle-btn { margin-left: 0 !important; height: 30px; }
.sb-signout { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .14); background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .02));
  color: rgba(255, 255, 255, .78); font-size: 12px; font-weight: 650; letter-spacing: .01em; text-decoration: none;
  transition: color .18s, background .18s, border-color .18s, box-shadow .18s; }
.sb-signout svg { width: 15px; height: 15px; flex-shrink: 0; transition: transform .22s cubic-bezier(.2, .8, .2, 1); }
.sb-signout small { margin-left: auto; font-size: 10.5px; font-weight: 500; color: rgba(255, 255, 255, .7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .2s; }
.sb-signout:hover, .sb-signout:focus-visible { color: #fff; border-color: rgba(96, 165, 250, .55); background: linear-gradient(180deg, rgba(59, 130, 246, .28), rgba(59, 130, 246, .12));
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .16), 0 8px 18px -10px rgba(59, 130, 246, .9); outline: none; text-decoration: none; }
.sb-signout:hover svg, .sb-signout:focus-visible svg { transform: translateX(3px); }
.sb-signout:hover small, .sb-signout:focus-visible small { opacity: 1; transform: none; }   /* a goodbye, on the way out */
.sb-signout:active { transform: translateY(1px); }
.sb-signout-mini { display: none; width: 30px; height: 30px; margin-top: 8px; border-radius: 9px; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, .6); border: 1px solid rgba(255, 255, 255, .12); transition: color .18s, background .18s, border-color .18s; }
.sb-signout-mini svg { width: 15px; height: 15px; }
.sb-signout-mini:hover, .sb-signout-mini:focus-visible { color: #fff; background: rgba(59, 130, 246, .22); border-color: rgba(96, 165, 250, .55); outline: none; }
.sidebar.collapsed .sidebar-footer:has(.sb-signout-mini) { flex-direction: column; }
.sidebar.collapsed .sb-signout-mini { display: flex; }
@media (prefers-reduced-motion: reduce) { .sb-signout svg { transition: none; } }
.sidebar.collapsed .sidebar-avatar-collapsed { display: flex; }

/* ── Main content ── */
.main-wrap {
  margin-left: var(--sb-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ── Top bar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; margin-right: 12px; }
.topbar-sb-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: none; border: none; border-radius: 6px;
  color: var(--text-3); cursor: pointer; flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.topbar-sb-toggle:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 768px) { .topbar-sb-toggle { display: none !important; } }
.topbar-page-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: .55; }
.topbar-page-icon svg { width: 18px; height: 18px; color: var(--text); }
/* one line, always: a long name ends in an ellipsis (the page heading and the hover title carry it whole) */
.topbar-breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2);
  min-width: 0; white-space: nowrap; overflow: hidden; }
.topbar-breadcrumb > * { flex-shrink: 0; }
.topbar-breadcrumb .current { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-breadcrumb a { color: var(--text-2); }
.topbar-breadcrumb a:hover { color: var(--text); }
.topbar-breadcrumb .sep { color: var(--text-3); }
.topbar-breadcrumb .current { color: var(--text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

/* ── Page header ── */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p { color: var(--text-2); margin-top: 4px; font-size: 13px; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stat grid ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
a.stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(59,130,246,.12);
  transform: translateY(-1px);
}
.stat-card .s-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.stat-card .s-value { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1; }
.stat-card .s-sub   { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.stat-card .s-icon  { float: right; margin-top: -4px; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.s-icon-blue  { background: #EFF6FF; color: var(--accent); }
.s-icon-green { background: #ECFDF5; color: var(--green); }
.s-icon-amber { background: #FFFBEB; color: var(--amber); }
.s-icon-red   { background: #FEF2F2; color: var(--red); }
.s-icon-navy  { background: #EEF2FF; color: var(--navy-mid); }
.s-icon-ai    { background: linear-gradient(135deg, #DBEAFE, #E0F2FE); color: var(--ai-2); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
.td-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-red    { background: #FEE2E2; color: #B91C1C; }
.badge-amber  { background: #FEF3C7; color: #B45309; }
.badge-blue   { background: #DBEAFE; color: #1D4ED8; }
.badge-gray   { background: #F1F5F9; color: #64748B; }
.badge-purple { background: #EDE9FE; color: #6D28D9; }
.badge-ai {
  background: linear-gradient(135deg, #DBEAFE, #E0F2FE);
  color: var(--ai-2);
}
.badge-dot::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger    { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm  { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
/* ── Menu: a button that opens a short list of actions (VigilMenu in vigil.js) ──
   <div class="vg-menu"><button class="btn …" data-menu>Label</button><div class="vg-menu-list" role="menu">
     <a role="menuitem" href="…">Item<small>what it does</small></a> <button role="menuitem" onclick="…">Item</button> <hr></div></div> */
.vg-menu { position: relative; display: inline-flex }
.vg-menu > [data-menu]::after { content: ''; width: 7px; height: 7px; margin-left: 2px; border: solid currentColor; border-width: 0 1.6px 1.6px 0;
  transform: translateY(-2px) rotate(45deg); opacity: .7 }
.vg-menu > [data-menu][aria-expanded="true"] { background: var(--surface-2); color: var(--text) }
.vg-menu-list { display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 200; min-width: 240px; max-width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.16); padding: 5px }
.vg-menu-list.left { right: auto; left: 0 }
.vg-menu.open > .vg-menu-list { display: block }
.vg-menu-list > form { display: contents }
.vg-menu-list > a, .vg-menu-list > button, .vg-menu-list > form > button { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; width: 100%; text-align: left; border: none; background: none;
  font: inherit; font-size: 13px; color: var(--text); padding: 7px 10px; border-radius: 8px; cursor: pointer; text-decoration: none }
.vg-menu-list > a:hover, .vg-menu-list > button:hover, .vg-menu-list > form > button:hover, .vg-menu-list > a:focus-visible,
.vg-menu-list > button:focus-visible, .vg-menu-list > form > button:focus-visible { background: var(--surface-2); outline: none }
.vg-menu-list small { flex-basis: 100%; font-size: 11.5px; color: var(--text-3); line-height: 1.35 }
.vg-menu-list .badge { margin-left: auto }
.vg-menu-list hr { border: none; border-top: 1px solid var(--border); margin: 4px 6px }
.btn-ai {
  background: linear-gradient(135deg, var(--ai-1), var(--ai-2), var(--ai-3));
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 8px rgba(var(--ai-glow),.35);
}
.btn-ai:hover {
  box-shadow: 0 4px 14px rgba(var(--ai-glow),.45);
  color: #fff;
  filter: brightness(1.07);
}

/* ── Forms ── */
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-label .optional { font-weight: 400; color: var(--text-3); margin-left: 4px; }
.form-hint   { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.form-control {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  font-size: 13px; font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-control-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Toast notifications (fixed, above map) ── */
#toast-container {
  position: fixed; top: 68px; right: 20px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 380px; pointer-events: none;
}
.toast {
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  pointer-events: auto;
  animation: toast-slide-in .22s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  transition: opacity .3s, transform .3s;
}
.toast.toast-hiding { opacity: 0; transform: translateX(12px); }
@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-close { background: none; border: none; cursor: pointer; font-size: 15px; opacity: .45; padding: 0; flex-shrink: 0; line-height: 1; color: inherit; }
.toast-close:hover { opacity: .9; }
.toast-success { background: #ECFDF5; color: #065F46; border: 1px solid #6EE7B7; }
.toast-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.toast-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.toast-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FCD34D; }

/* An alert arriving while you work (bottom right; templates/dashboard/alerts.html and vigil.js _alertToast). Solid in every
   theme and outside the glass treatment: what is underneath must not show through a warning. */
.alert-pop { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 12px 13px; border-radius: 12px; cursor: pointer;
  background: var(--surface); background-image: none; border: 1px solid var(--border-2, var(--border)); border-left: 4px solid var(--sev, #64748B);
  box-shadow: 0 14px 34px -12px rgba(2, 6, 23, .45), 0 2px 6px rgba(2, 6, 23, .12); color: var(--text); text-decoration: none;
  pointer-events: auto; opacity: 0; transform: translateX(18px); transition: opacity .3s, transform .3s; isolation: isolate; }
.alert-pop.in { opacity: 1; transform: none; }
.alert-pop:hover { border-color: var(--sev, #64748B); text-decoration: none; }
.alert-pop .ap-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.alert-pop b { font-size: 13px; font-weight: 650; color: var(--text); }
.alert-pop .ap-sev { font-size: 10.5px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--sev, #64748B); white-space: nowrap; }
.alert-pop .ap-where { font-size: 12px; color: var(--text-2); }
.alert-pop .ap-val { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
html:not([data-glass="off"]) .alert-pop { background: var(--surface) !important; -webkit-backdrop-filter: none; backdrop-filter: none; }

/* ── Flash messages (legacy — kept for compatibility) ── */
.flash {
  padding: 10px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
  transition: opacity .4s, max-height .4s, margin .4s, padding .4s;
}
.flash.flash-hiding { opacity: 0; max-height: 0; margin: 0; padding: 0; overflow: hidden; }
.flash-error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.flash-success { background: #ECFDF5; color: #065F46; border: 1px solid #6EE7B7; }
.flash-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ── Node chips ── */
.node-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; padding: 2px 8px;
  border-radius: 4px;
}
.node-gateway    { background: #EDE9FE; color: #5B21B6; }
.node-sensor     { background: #DBEAFE; color: #1E40AF; }
.node-standalone { background: #F1F5F9; color: #475569; }

/* ── Online/offline dot ── */
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.online-dot.online  { background: var(--green); box-shadow: 0 0 0 2px rgba(16,185,129,.2); }
.online-dot.offline { background: var(--text-3); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .4; }
.empty-state p { font-size: 13px; }

/* ── HTMX spinner ── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-flex; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Value display ── */
.value-display { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 14px; font-weight: 600; }
.value-unit { font-size: 11px; color: var(--text-3); font-family: inherit; font-weight: 400; margin-left: 3px; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-2); border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tags ── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 11px; color: var(--text-2); }

/* ── AI gradient utilities ── */
.ai-gradient-text {
  background: linear-gradient(135deg, var(--ai-1), var(--ai-2), var(--ai-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Dark theme overrides
   Applied when <html data-theme="dark"> is set.
   ══════════════════════════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  --bg:        #0A1628;
  --surface:   #0F1E38;
  --surface-2: #162847;
  --border:    rgba(255,255,255,.08);
  --border-2:  rgba(255,255,255,.14);

  --text:      #C8D5E8;
  --text-2:    #7A8FAE;
  --text-3:    #3D5073;
}

[data-theme="dark"] body {
  background-image:
    linear-gradient(rgba(59,130,246,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,.04) 1px, transparent 1px);
}

/* Form inputs in dark mode */
[data-theme="dark"] .form-control { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .form-control:focus { box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
[data-theme="dark"] #argus-input { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] #argus-mem-search { background: var(--surface-2); color: var(--text); }

/* Badges */
[data-theme="dark"] .badge-green  { background: rgba(16,185,129,.15);  color: #34D399; }
[data-theme="dark"] .badge-red    { background: rgba(239,68,68,.15);   color: #F87171; }
[data-theme="dark"] .badge-amber  { background: rgba(245,158,11,.15);  color: #FBBF24; }
[data-theme="dark"] .badge-blue   { background: rgba(59,130,246,.15);  color: #60A5FA; }
[data-theme="dark"] .badge-gray   { background: rgba(100,116,139,.15); color: #94A3B8; }
[data-theme="dark"] .badge-purple { background: rgba(139,92,246,.15);  color: #A78BFA; }

/* Stat card icons */
[data-theme="dark"] .s-icon-blue  { background: rgba(59,130,246,.15); }
[data-theme="dark"] .s-icon-green { background: rgba(16,185,129,.15); }
[data-theme="dark"] .s-icon-amber { background: rgba(245,158,11,.15); }
[data-theme="dark"] .s-icon-red   { background: rgba(239,68,68,.15);  }
[data-theme="dark"] .s-icon-navy  { background: rgba(59,130,246,.15); color: var(--accent); }
[data-theme="dark"] .s-icon-ai    { background: rgba(var(--ai-glow),.14); }

/* Node chips */
[data-theme="dark"] .node-gateway    { background: rgba(139,92,246,.18); color: #C4B5FD; }
[data-theme="dark"] .node-sensor     { background: rgba(59,130,246,.18); color: #93C5FD; }
[data-theme="dark"] .node-standalone { background: rgba(100,116,139,.18); color: #94A3B8; }

/* Toast + Flash dark mode */
[data-theme="dark"] .toast-success,
[data-theme="dark"] .flash-success { background: color-mix(in srgb, rgb(16,185,129) 14%, var(--surface));  color: #6EE7B7; border-color: rgba(16,185,129,.3);  }
[data-theme="dark"] .toast-error,
[data-theme="dark"] .flash-error   { background: color-mix(in srgb, rgb(239,68,68) 14%, var(--surface));   color: #FCA5A5; border-color: rgba(239,68,68,.3);   }
[data-theme="dark"] .toast-info,
[data-theme="dark"] .flash-info    { background: color-mix(in srgb, rgb(59,130,246) 14%, var(--surface));  color: #93C5FD; border-color: rgba(59,130,246,.3);  }
[data-theme="dark"] .toast-warning { background: color-mix(in srgb, rgb(245,158,11) 14%, var(--surface));  color: #FCD34D; border-color: rgba(245,158,11,.3);  }

/* ── Midnight theme (deep violet) ── */
[data-theme="midnight"] {
  --bg:        #0D0B1E;
  --surface:   #131128;
  --surface-2: #1B183A;
  --border:    rgba(139,92,246,.12);
  --border-2:  rgba(139,92,246,.22);
  --text:      #C4B5FD;
  --text-2:    #8B7EC8;
  --text-3:    #4A4278;
  --accent:    #7C3AED;
  --accent-h:  #6D28D9;
  --sb-bg:     #0A0817;
  --sb-active: rgba(124,58,237,.3);
  --sb-border: rgba(139,92,246,.12);
}
[data-theme="midnight"] body {
  background-image:
    linear-gradient(rgba(139,92,246,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139,92,246,.04) 1px, transparent 1px);
}
[data-theme="midnight"] .form-control { background: var(--surface-2); color: var(--text); }
[data-theme="midnight"] .toast-success { background: rgba(16,185,129,.12);  color: #6EE7B7; border-color: rgba(16,185,129,.3); }
[data-theme="midnight"] .toast-error   { background: rgba(239,68,68,.12);   color: #FCA5A5; border-color: rgba(239,68,68,.3); }
[data-theme="midnight"] .toast-info    { background: rgba(124,58,237,.15);  color: #C4B5FD; border-color: rgba(124,58,237,.3); }
[data-theme="midnight"] .badge-green  { background: rgba(16,185,129,.15);  color: #34D399; }
[data-theme="midnight"] .badge-red    { background: rgba(239,68,68,.15);   color: #F87171; }
[data-theme="midnight"] .badge-amber  { background: rgba(245,158,11,.15);  color: #FBBF24; }
[data-theme="midnight"] .badge-blue   { background: rgba(124,58,237,.2);   color: #A78BFA; }
[data-theme="midnight"] .badge-gray   { background: rgba(139,92,246,.12);  color: #8B7EC8; }
[data-theme="midnight"] .badge-purple { background: rgba(139,92,246,.2);   color: #C4B5FD; }
[data-theme="midnight"] .node-gateway    { background: rgba(139,92,246,.2); color: #C4B5FD; }
[data-theme="midnight"] .node-sensor     { background: rgba(124,58,237,.2); color: #A78BFA; }
[data-theme="midnight"] .node-standalone { background: rgba(100,116,139,.18); color: #94A3B8; }
[data-theme="midnight"] #argus-drawer { box-shadow: 0 8px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3); }
[data-theme="midnight"] #argus-input,
[data-theme="midnight"] #argus-mem-search { background: var(--surface-2); color: var(--text); }
[data-theme="midnight"] #iot-bg { opacity: 0.065; }

/* ── Ocean theme (deep teal/cyan) ── */
[data-theme="ocean"] {
  --bg:        #040E1A;
  --surface:   #071624;
  --surface-2: #0C2030;
  --border:    rgba(6,182,212,.1);
  --border-2:  rgba(6,182,212,.2);
  --text:      #A5E8F5;
  --text-2:    #56A8C0;
  --text-3:    #235C75;
  --accent:    #06B6D4;
  --accent-h:  #0891B2;
  --sb-bg:     #020B14;
  --sb-active: rgba(6,182,212,.25);
  --sb-border: rgba(6,182,212,.1);
}
[data-theme="ocean"] body {
  background-image:
    linear-gradient(rgba(6,182,212,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(6,182,212,.04) 1px, transparent 1px);
}
[data-theme="ocean"] .form-control { background: var(--surface-2); color: var(--text); }
[data-theme="ocean"] .toast-success { background: rgba(16,185,129,.12);  color: #6EE7B7; border-color: rgba(16,185,129,.3); }
[data-theme="ocean"] .toast-error   { background: rgba(239,68,68,.12);   color: #FCA5A5; border-color: rgba(239,68,68,.3); }
[data-theme="ocean"] .toast-info    { background: rgba(6,182,212,.12);   color: #A5E8F5; border-color: rgba(6,182,212,.3); }
[data-theme="ocean"] .badge-green  { background: rgba(16,185,129,.15);  color: #34D399; }
[data-theme="ocean"] .badge-red    { background: rgba(239,68,68,.15);   color: #F87171; }
[data-theme="ocean"] .badge-amber  { background: rgba(245,158,11,.15);  color: #FBBF24; }
[data-theme="ocean"] .badge-blue   { background: rgba(6,182,212,.2);    color: #67E8F9; }
[data-theme="ocean"] .badge-gray   { background: rgba(6,182,212,.1);    color: #56A8C0; }
[data-theme="ocean"] .badge-purple { background: rgba(139,92,246,.15);  color: #A78BFA; }
[data-theme="ocean"] .node-gateway    { background: rgba(6,182,212,.2);    color: #67E8F9; }
[data-theme="ocean"] .node-sensor     { background: rgba(14,165,233,.2);   color: #7DD3FC; }
[data-theme="ocean"] .node-standalone { background: rgba(100,116,139,.18); color: #94A3B8; }
[data-theme="ocean"] #argus-drawer { box-shadow: 0 8px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3); }
[data-theme="ocean"] #argus-input,
[data-theme="ocean"] #argus-mem-search { background: var(--surface-2); color: var(--text); }
[data-theme="ocean"] #iot-bg { opacity: 0.065; }

/* ── Forest theme (deep emerald green) ── */
[data-theme="forest"] {
  --bg:        #050E08;
  --surface:   #0A1A0D;
  --surface-2: #0F2414;
  --border:    rgba(16,185,129,.1);
  --border-2:  rgba(16,185,129,.2);
  --text:      #A7F3D0;
  --text-2:    #4DB57D;
  --text-3:    #1F5C3A;
  --accent:    #10B981;
  --accent-h:  #059669;
  --sb-bg:     #030C06;
  --sb-active: rgba(16,185,129,.25);
  --sb-border: rgba(16,185,129,.1);
}
[data-theme="forest"] body {
  background-image:
    linear-gradient(rgba(16,185,129,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,185,129,.04) 1px, transparent 1px);
}
[data-theme="forest"] .form-control { background: var(--surface-2); color: var(--text); }
[data-theme="forest"] .toast-success { background: rgba(16,185,129,.15);  color: #6EE7B7; border-color: rgba(16,185,129,.3); }
[data-theme="forest"] .toast-error   { background: rgba(239,68,68,.12);   color: #FCA5A5; border-color: rgba(239,68,68,.3); }
[data-theme="forest"] .toast-info    { background: rgba(16,185,129,.1);   color: #A7F3D0; border-color: rgba(16,185,129,.25); }
[data-theme="forest"] .badge-green  { background: rgba(16,185,129,.2);   color: #34D399; }
[data-theme="forest"] .badge-red    { background: rgba(239,68,68,.15);   color: #F87171; }
[data-theme="forest"] .badge-amber  { background: rgba(245,158,11,.15);  color: #FBBF24; }
[data-theme="forest"] .badge-blue   { background: rgba(59,130,246,.15);  color: #60A5FA; }
[data-theme="forest"] .badge-gray   { background: rgba(16,185,129,.1);   color: #4DB57D; }
[data-theme="forest"] .badge-purple { background: rgba(139,92,246,.15);  color: #A78BFA; }
[data-theme="forest"] .node-gateway    { background: rgba(16,185,129,.2);   color: #6EE7B7; }
[data-theme="forest"] .node-sensor     { background: rgba(5,150,105,.2);    color: #34D399; }
[data-theme="forest"] .node-standalone { background: rgba(100,116,139,.18); color: #94A3B8; }
[data-theme="forest"] #argus-drawer { box-shadow: 0 8px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3); }
[data-theme="forest"] #argus-input,
[data-theme="forest"] #argus-mem-search { background: var(--surface-2); color: var(--text); }
[data-theme="forest"] #iot-bg { opacity: 0.065; }

/* ── Rose theme (light, warm red/pink tones) ── */
[data-theme="rose"] {
  --bg:        #FFF0F3;
  --surface:   #FFFFFF;
  --surface-2: #FDF2F4;
  --border:    #F5D7DC;
  --border-2:  #EBB4BE;
  --text:      #4C0519;
  --text-2:    #881337;
  --text-3:    #B8818D;
  --accent:    #E11D48;
  --accent-h:  #BE123C;
  --sb-bg:     #4C0519;
  --sb-active: rgba(225,29,72,.22);
  --sb-border: rgba(225,29,72,.12);
}
[data-theme="rose"] body {
  background-image:
    linear-gradient(rgba(225,29,72,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(225,29,72,.04) 1px, transparent 1px);
}
[data-theme="rose"] .form-control { background: var(--surface); color: var(--text); }
[data-theme="rose"] .toast-success { background: rgba(16,185,129,.12);  color: #047857; border-color: rgba(16,185,129,.25); }
[data-theme="rose"] .toast-error   { background: rgba(239,68,68,.12);   color: #B91C1C; border-color: rgba(239,68,68,.25); }
[data-theme="rose"] .toast-info    { background: rgba(225,29,72,.10);   color: #881337; border-color: rgba(225,29,72,.2); }
[data-theme="rose"] .badge-green  { background: rgba(16,185,129,.15);  color: #047857; }
[data-theme="rose"] .badge-red    { background: rgba(225,29,72,.15);   color: #BE123C; }
[data-theme="rose"] .badge-amber  { background: rgba(245,158,11,.15);  color: #B45309; }
[data-theme="rose"] .badge-blue   { background: rgba(59,130,246,.13);  color: #1D4ED8; }
[data-theme="rose"] .badge-gray   { background: rgba(184,129,141,.18); color: #881337; }
[data-theme="rose"] .badge-purple { background: rgba(139,92,246,.13);  color: #6D28D9; }
[data-theme="rose"] .node-gateway    { background: rgba(225,29,72,.16);   color: #BE123C; }
[data-theme="rose"] .node-sensor     { background: rgba(244,114,182,.18); color: #9D174D; }
[data-theme="rose"] .node-standalone { background: rgba(100,116,139,.15); color: #475569; }
[data-theme="rose"] #argus-drawer { box-shadow: 0 8px 40px rgba(76,5,25,.18), 0 2px 8px rgba(76,5,25,.08); }
[data-theme="rose"] #argus-input,
[data-theme="rose"] #argus-mem-search { background: var(--surface-2); color: var(--text); }
[data-theme="rose"] #iot-bg { opacity: 0.05; }

/* ── Crimson theme (dark, deep red tones) ── */
[data-theme="crimson"] {
  --bg:        #170408;
  --surface:   #260811;
  --surface-2: #33101A;
  --border:    rgba(239,68,68,.1);
  --border-2:  rgba(239,68,68,.2);
  --text:      #FECACA;
  --text-2:    #BA7076;
  --text-3:    #5A2B30;
  --accent:    #EF4444;
  --accent-h:  #DC2626;
  --sb-bg:     #0E0205;
  --sb-active: rgba(239,68,68,.25);
  --sb-border: rgba(239,68,68,.1);
}
[data-theme="crimson"] body {
  background-image:
    linear-gradient(rgba(239,68,68,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(239,68,68,.04) 1px, transparent 1px);
}
[data-theme="crimson"] .form-control { background: var(--surface-2); color: var(--text); }
[data-theme="crimson"] .toast-success { background: rgba(16,185,129,.15);  color: #6EE7B7; border-color: rgba(16,185,129,.3); }
[data-theme="crimson"] .toast-error   { background: rgba(239,68,68,.18);   color: #FCA5A5; border-color: rgba(239,68,68,.35); }
[data-theme="crimson"] .toast-info    { background: rgba(239,68,68,.1);    color: #FECACA; border-color: rgba(239,68,68,.25); }
[data-theme="crimson"] .badge-green  { background: rgba(16,185,129,.2);   color: #34D399; }
[data-theme="crimson"] .badge-red    { background: rgba(239,68,68,.22);   color: #FCA5A5; }
[data-theme="crimson"] .badge-amber  { background: rgba(245,158,11,.15);  color: #FBBF24; }
[data-theme="crimson"] .badge-blue   { background: rgba(59,130,246,.15);  color: #60A5FA; }
[data-theme="crimson"] .badge-gray   { background: rgba(239,68,68,.1);    color: #BA7076; }
[data-theme="crimson"] .badge-purple { background: rgba(139,92,246,.15);  color: #A78BFA; }
[data-theme="crimson"] .node-gateway    { background: rgba(239,68,68,.22);   color: #FCA5A5; }
[data-theme="crimson"] .node-sensor     { background: rgba(244,63,94,.2);    color: #FDA4AF; }
[data-theme="crimson"] .node-standalone { background: rgba(100,116,139,.18); color: #94A3B8; }
[data-theme="crimson"] #argus-drawer { box-shadow: 0 8px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3); }
[data-theme="crimson"] #argus-input,
[data-theme="crimson"] #argus-mem-search { background: var(--surface-2); color: var(--text); }
[data-theme="crimson"] #iot-bg { opacity: 0.065; }

/* Argus drawer shadow */
[data-theme="dark"] #argus-drawer {
  box-shadow: 0 8px 40px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3);
}

/* IoT bg canvas — slightly more visible on dark bg */
[data-theme="dark"] #iot-bg { opacity: 0.065; }

/* ═══════════════════════════════════════════════════════════════════════
   Mobile — ≤ 768 px only. Desktop/laptop layout is completely unaffected.
   ═══════════════════════════════════════════════════════════════════════ */

/* Bottom-nav tab base styles live outside the query so transitions work */
.mob-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: 1; padding: 6px 4px 4px;
  color: rgba(255,255,255,.45); font-size: 10px; font-weight: 500;
  text-decoration: none; background: none; border: none; cursor: pointer;
  transition: color .15s; position: relative;
  -webkit-tap-highlight-color: transparent;
}
.mob-tab svg { width: 22px; height: 22px; flex-shrink: 0; }
.mob-tab span { line-height: 1.1; }
.mob-tab.mob-tab-active { color: #fff; }
.mob-tab:active { color: rgba(255,255,255,.85); }

@media (max-width: 768px) {

  /* ── Sidebar: slide-over overlay ── */
  .sidebar {
    left: -100% !important;
    width: 280px !important;
    transition: left .28s cubic-bezier(.4,0,.2,1) !important;
    z-index: 1200 !important;
    box-shadow: 6px 0 28px rgba(0,0,0,.4);
  }
  .sidebar.sb-anim { transition: left .28s cubic-bezier(.4,0,.2,1) !important; }
  .sidebar.mobile-open { left: 0 !important; }

  /* ── Main content: no sidebar margin offset ── */
  .main-wrap,
  .sidebar + .main-wrap,
  .sidebar.collapsed + .main-wrap { margin-left: 0 !important; }

  /* ── Reserve space at bottom for nav bar ── */
  .page-body { padding-bottom: 74px; }

  /* ── Topbar: compact, hide decorative page icon ── */
  .topbar { padding: 8px 12px; min-height: 48px; }
  .topbar-page-icon { display: none !important; }
  .topbar-breadcrumb { font-size: 12px; }
  .sidebar-toggle { display: none !important; }

  /* ── Argus FAB: rise above bottom nav ── */
  #argus-btn { bottom: 70px !important; right: 14px !important; }
  #argus-show-tab { bottom: 76px !important; }

  /* ── Argus drawer: true full-screen on mobile ── */
  #argus-drawer {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    resize: none !important;
    z-index: 1300 !important;
    bottom: auto !important;
    right: auto !important;
    animation: none !important;
  }
  /* Dock + resize handle are desktop-only */
  #argus-dock-btn,
  #argus-resize-handle { display: none !important; }

  /* Hide FAB while Argus drawer is open on mobile */
  body.argus-mobile-open #argus-btn { display: none !important; }

  /* ── Common layout reflows ── */
  .grid-2 { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .page-header.page-header-row { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Tab bars scroll horizontally instead of wrapping */
  .tab-bar {
    overflow-x: auto; flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    padding-bottom: 1px; /* avoid clipping active border */
  }
  .tab-bar::-webkit-scrollbar { display: none; }

  /* Card padding tighter on small screens */
  .card-pad { padding: 14px 14px; }

  /* Topbar actions: only show primary button */
  .topbar-right .btn-ghost { display: none; }

  /* Bottom nav: show (hidden by default on desktop) */
  #mobile-bottom-nav { display: flex !important; }
}

.ai-top-bar {
  position: relative;
  overflow: hidden;
}
.ai-top-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ai-1), var(--ai-2), var(--ai-3));
}
.ai-glow {
  box-shadow: 0 0 0 1px rgba(var(--ai-glow),.22), 0 4px 20px rgba(var(--ai-glow),.10);
}


/* ══ Argus assistant ══ */
#argus-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--ai-1), var(--ai-2), var(--ai-3));
  border: none; cursor: pointer;
  box-shadow: 0 4px 20px rgba(var(--ai-glow),.45), 0 2px 8px rgba(0,0,0,.15);
  display: flex; align-items: center; justify-content: center;
  transition: transform .35s cubic-bezier(.4,0,.2,1), box-shadow .2s, opacity .25s ease-out;
}
#argus-btn:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(var(--ai-glow),.55); }

/* Collapsed state — FAB slides off to the right, edge tab slides in */
body.argus-collapsed #argus-btn {
  transform: translateX(calc(100% + 40px)) scale(.9);
  opacity: 0;
  pointer-events: none;
}
body.argus-collapsed #argus-btn:hover {
  /* Keep collapsed transform even if somehow hovered during transition */
  transform: translateX(calc(100% + 40px)) scale(.9);
}

/* Small × to collapse the FAB — floats over its top-left corner.
   Must be a SIBLING of #argus-btn (not a child), because nested <button>
   inside <button> is invalid HTML and browsers drop the inner one. */
#argus-hide-btn {
  position: fixed;
  bottom: 66px; right: 66px;
  z-index: 501;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(15, 23, 42, .82);
  border: 1.5px solid rgba(255, 255, 255, .95);
  color: #fff;
  font-size: 12px; line-height: 1;
  padding: 0; margin: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: .55;
  transition: opacity .15s, background .15s, transform .15s;
}
#argus-hide-btn:hover,
#argus-hide-btn:focus-visible { opacity: 1; background: #ef4444; transform: scale(1.1); }
body.argus-collapsed #argus-hide-btn { display: none; }

/* Edge tab — appears when collapsed, slides in from the right */
#argus-show-tab {
  position: fixed;
  bottom: 30px; right: 0;
  z-index: 500;
  width: 18px; height: 44px;
  border: none;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(135deg, var(--ai-1), var(--ai-2), var(--ai-3));
  box-shadow: -4px 3px 14px rgba(var(--ai-glow), .35), 0 0 0 1px rgba(255,255,255,.08);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  padding: 0;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1), width .18s ease-out, box-shadow .2s;
}
#argus-show-tab svg { width: 10px; height: 14px; }
#argus-show-tab:hover { width: 24px; box-shadow: -5px 4px 18px rgba(var(--ai-glow), .55); }
body.argus-collapsed #argus-show-tab {
  transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
  #argus-btn, #argus-show-tab { transition: opacity .15s ease-out; }
  body.argus-collapsed #argus-btn { transform: none; display: none; }
}
#argus-btn svg { width: 24px; height: 24px; color: #fff; }
#argus-btn .argus-badge {
  position: absolute; top: -2px; right: -2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--surface);
  display: none;
}
#argus-btn .argus-badge.has-messages { display: block; }

#argus-drawer {
  position: fixed; bottom: 88px; right: 24px; z-index: 499;
  width: 440px;
  height: 640px;
  min-width: 320px; min-height: 320px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 110px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  display: none; flex-direction: column;
  overflow: hidden;
  resize: both;        /* native browser resize handle */
  transform-origin: bottom right;
  animation: argus-open .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes argus-open {
  from { opacity: 0; transform: scale(.88) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes argus-msg-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
#argus-drawer.open { display: flex; }

/* Docked / full-height mode */
#argus-drawer.docked {
  top: 0; bottom: 0; right: 0;
  height: 100vh !important;
  border-radius: 0; border-right: none; border-top: none; border-bottom: none;
  border-left: 3px solid var(--ai-2);
  resize: none;   /* drag handle handles resize */
  animation: none;
}
/* Drag handle — left edge of docked drawer */
#argus-resize-handle {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 6px; cursor: col-resize; z-index: 10;
  background: transparent; transition: background .15s;
  display: none;
}
#argus-resize-handle:hover, #argus-resize-handle.dragging {
  background: var(--ai-2); opacity: .55;
}
#argus-dock-btn { }
#argus-dock-btn:hover { color: #fff !important; }

#argus-header {
  padding: 14px 16px 12px;
  background: linear-gradient(135deg, var(--ai-1), var(--ai-2));
  display: flex; align-items: center; gap: 10px;
}
.argus-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.argus-avatar svg {
  width: 18px; height: 18px;
  animation: triskele-spin 20s linear infinite;
  transform-origin: center;
  transform-box: fill-box;
}
#argus-btn svg {
  animation: triskele-spin 12s linear infinite;
  transform-origin: center;
  transform-box: fill-box;
}
#argus-btn:hover svg { animation-duration: 2s; }
/* IoT sensor particle background */
#iot-bg {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: 0.045;
}
#argus-header .argus-title { color: #fff; font-weight: 700; font-size: 14px; }
#argus-header .argus-sub   { color: rgba(255,255,255,.7); font-size: 11px; }
#argus-close {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.7); padding: 4px;
}
#argus-close:hover { color: #fff; }
#argus-close svg { width: 16px; height: 16px; }

#argus-context-bar {
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text-3);
  background: var(--surface-2);
  display: none;
}
#argus-context-bar.has-ctx { display: flex; align-items: center; gap: 6px; }

#argus-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.argus-msg { display: flex; flex-direction: column; gap: 3px; }
.argus-msg.user  { align-items: flex-end; }
.argus-msg.agent { align-items: flex-start; }
/* Blinking cursor on streaming bubbles */
.argus-cursor::after {
  content: '▋';
  display: inline-block;
  margin-left: 1px;
  animation: argus-blink .7s step-start infinite;
  color: var(--accent, #3b82f6);
  font-size: .8em;
  vertical-align: middle;
}
@keyframes argus-blink { 50% { opacity: 0; } }
.argus-bubble {
  padding: 9px 13px; border-radius: 12px;
  font-size: 13px; line-height: 1.55;
  max-width: 88%; word-break: break-word;
}
.argus-msg.user  .argus-bubble { background: linear-gradient(135deg, var(--ai-1), var(--ai-2)); color: #fff; border-radius: 12px 12px 2px 12px; }
.argus-msg.agent .argus-bubble { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 2px 12px 12px 12px; }
/* Markdown inside agent bubbles */
.argus-bubble h1,.argus-bubble h2,.argus-bubble h3 { font-size:13px; font-weight:700; margin:8px 0 4px; color:var(--text); }
.argus-bubble p  { margin:0 0 6px; }
.argus-bubble p:last-child { margin-bottom:0; }
.argus-bubble ul,.argus-bubble ol { margin:4px 0 6px; padding-left:18px; }
.argus-bubble li { margin-bottom:2px; }
.argus-bubble strong { font-weight:700; color:var(--text); }
.argus-bubble em { font-style:italic; }
.argus-bubble code { font-family:ui-monospace,monospace; font-size:11px; background:rgba(0,0,0,.06); padding:1px 4px; border-radius:3px; }
.argus-bubble pre { background:rgba(0,0,0,.05); border-radius:6px; padding:8px 10px; overflow-x:auto; margin:6px 0; }
.argus-bubble pre code { background:none; padding:0; }
.argus-bubble hr { border:none; border-top:1px solid var(--border); margin:8px 0; }
.argus-bubble table { border-collapse:collapse; font-size:11px; width:100%; margin:6px 0; }
.argus-bubble th,.argus-bubble td { border:1px solid var(--border); padding:4px 8px; text-align:left; }
.argus-bubble th { background:var(--surface-2); font-weight:600; }
.argus-msg .argus-meta { font-size: 10px; color: var(--text-3); padding: 0 4px; }

#argus-form { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
#argus-input {
  flex: 1; padding: 9px 12px;
  border: 1px solid var(--border-2); border-radius: 10px;
  font-size: 13px; font-family: inherit;
  resize: none; max-height: 120px; overflow-y: auto;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.4;
}
#argus-input:focus { outline: none; border-color: var(--ai-2); box-shadow: 0 0 0 3px rgba(var(--ai-glow),.16); }
#argus-send {
  width: 36px; height: 36px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--ai-1), var(--ai-2));
  border: none; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  align-self: flex-end;
  transition: filter .15s, box-shadow .15s;
  box-shadow: 0 2px 6px rgba(var(--ai-glow),.35);
}
#argus-send:hover { filter: brightness(1.1); }
#argus-send svg { width: 16px; height: 16px; color: #fff; }
#argus-stop {
  width: 36px; height: 36px; flex-shrink: 0;
  background: rgba(239,68,68,.15); border: 1.5px solid rgba(239,68,68,.4);
  border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  align-self: flex-end; transition: background .15s;
}
#argus-stop:hover { background: rgba(239,68,68,.28); }
#argus-stop svg { width: 14px; height: 14px; color: #ef4444; }
#argus-thinking { display: none; padding: 0 12px 10px; }
#argus-thinking.visible { display: flex; gap: 4px; align-items: center; }
.think-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ai-2); animation: think-pulse 1.2s infinite; }
.think-dot:nth-child(2) { animation-delay: .2s; }
.think-dot:nth-child(3) { animation-delay: .4s; }
@keyframes think-pulse { 0%,80%,100%{opacity:.2;transform:scale(.8)} 40%{opacity:1;transform:scale(1)} }
.argus-tab.active { border-bottom-color: var(--ai-2) !important; color: var(--ai-1) !important; }
.argus-tab:hover:not(.active) { color: var(--text) !important; background: var(--border) !important; }
/* Tool result cards */
.argus-tool-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 12px;
  color: var(--text-2); margin-top: 4px; max-width: 88%;
}
.argus-tool-card .tool-card-header {
  display: flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 11px; color: var(--text-3);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.argus-tool-card .tool-card-header .tool-icon { font-size: 14px; }
/* Readings card */
.argus-reading-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 11px;
}
.argus-reading-row:last-child { border-bottom: none; }
.argus-reading-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.status-ok       { color: var(--green); }
.status-warning  { color: var(--amber); }
.status-critical { color: var(--red); }
/* Inline chart */
.argus-chart-wrap {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; margin-top: 4px; max-width: 96%;
}
.argus-chart-wrap canvas { display: block; width: 100% !important; }
.argus-chart-legend {
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  padding: 6px 12px 8px; border-top: 1px solid var(--border);
}
/* Inline data table */
.argus-table-wrap { margin-top:4px; max-width:96%; }
.argus-table-toolbar {
  display:flex; align-items:center; gap:8px; padding:6px 2px; flex-wrap:wrap;
}
.argus-table-filter {
  flex:1; min-width:120px; padding:4px 8px; border:1px solid var(--border-2);
  border-radius:6px; font-size:11px; font-family:inherit;
  background:var(--surface); color:var(--text);
}
.argus-table-count { font-size:10px; color:var(--text-3); white-space:nowrap; }
.argus-table-btn {
  padding:3px 10px; font-size:11px; border:1px solid var(--border-2);
  border-radius:6px; background:var(--surface); color:var(--ai-1);
  cursor:pointer; white-space:nowrap;
}
.argus-table-btn:hover { background:var(--surface-2); }
.argus-table-scroll {
  max-height: 320px; overflow-y:auto; border:1px solid var(--border);
  border-radius:8px;
}
.argus-table {
  width:100%; border-collapse:collapse; font-size:11px;
}
.argus-table th {
  position:sticky; top:0; background:var(--surface-2);
  padding:5px 8px; text-align:left; white-space:nowrap;
  border-bottom:1px solid var(--border); color:var(--text-2); font-weight:600;
  user-select:none;
}
.argus-table td {
  padding:4px 8px; border-bottom:1px solid var(--border);
  color:var(--text); font-variant-numeric:tabular-nums; white-space:nowrap;
}
.argus-table tr:last-child td { border-bottom:none; }
.argus-table tr:hover td { background:var(--surface-2); }
/* Memory card */
.argus-mem-entry {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 11px;
}
.argus-mem-entry .mem-type {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  background: rgba(var(--ai-glow),.12); color: var(--ai-1);
  font-size: 10px; font-weight: 600; margin-bottom: 4px;
}
.argus-mem-entry .mem-content { color: var(--text); line-height: 1.5; }
.argus-mem-entry .mem-meta { color: var(--text-3); font-size: 10px; margin-top: 3px; }
/* Slash-command help card */
.argus-help-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 3px 0; font-size: 12px; color: var(--text);
}
.argus-help-ex {
  display: inline-block;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; font-size: 11px;
  color: var(--text-2); cursor: pointer;
}
.argus-help-ex:hover { background: rgba(var(--ai-glow),.1); border-color: var(--ai-2); color: var(--text); }
/* Command dropdown last item */
#argus-cmd-dropdown .argus-cmd-item:last-child { border-bottom: none; }

/* ══════════════════════════════════════════════════════════════════════════
   Mobile refinements
   ──────────────────────────────────────────────────────────────────────────
   The console is built for a desk. On a phone the same pages need to answer
   a narrower question — is the fleet healthy, what needs me, what do we know
   about this thing — without a horizontal scrollbar in the way.

   The main move is turning wide tables into stacked cards. A table with eight
   columns inside `overflow-x: auto` is technically readable on a phone and
   practically useless: you scroll sideways hunting for the column you wanted
   and lose the row you were on.
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 760px) {

  /* ── Density ── */
  .page-header h1 { font-size: 18px; }
  .page-header p  { font-size: 12.5px; }
  .card-header    { padding: 12px 14px; }
  .content-wrap, .main-content { padding: 14px !important; }

  /* Clear the fixed bottom nav so the last row is never trapped behind it. */
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

  /* ── Tables become cards ──────────────────────────────────────────────────
     Each row turns into a block; each cell carries its column name from the
     data-label attribute the template sets. Tables without labels keep the
     scrolling behaviour rather than collapsing into something unreadable. */
  table.mobile-cards thead { display: none; }
  table.mobile-cards, table.mobile-cards tbody,
  table.mobile-cards tr, table.mobile-cards td { display: block; width: 100%; }
  table.mobile-cards tr {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 9px; padding: 11px 13px;
  }
  table.mobile-cards td {
    border: none; padding: 4px 0; display: flex; align-items: baseline;
    gap: 10px; font-size: 13px;
  }
  table.mobile-cards td::before {
    content: attr(data-label); flex-shrink: 0; min-width: 92px;
    font-size: 10.5px; font-weight: 650; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-3);
  }
  /* The first cell is the row's identity — give it the weight of a heading. */
  table.mobile-cards td.mc-title { display: block; margin-bottom: 6px; }
  table.mobile-cards td.mc-title::before { display: none; }
  table.mobile-cards td.mc-hide { display: none; }

  /* ── Forms and filters stack ── */
  .dl-filters, .filters { flex-direction: column; align-items: stretch; }
  .dl-select, .dl-search, .form-control { max-width: none !important; width: 100% !important; }
  .dl-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px;
              -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .dl-chips::-webkit-scrollbar { display: none; }

  /* Stat tiles: two up rather than one, so the fold still shows the summary. */
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 21px; }

  /* ── Memory cards ── */
  .mem-when { margin-left: 0; width: 100%; margin-top: 3px; }
  .mem-head { gap: 5px; }

  /* Argus should feel like the app's own sheet, not a floating desktop panel. */
  #argus-panel {
    inset: 0 !important; width: 100% !important; height: 100% !important;
    max-height: none !important; border-radius: 0 !important;
  }
  #argus-btn { bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important; }
}

/* Very narrow: one stat per row rather than cramping two. */
@media (max-width: 380px) {
  .stat-row { grid-template-columns: 1fr; }
}


/* ══ Argus mark ══
   The real triskele asset (white on transparent) rather than a redrawn SVG, so
   it is the same shape as the app icon. Sized to fill the 52px button
   comfortably, and given a slight counter-rotation: the triskele reads as a
   spinning form, and setting it a few degrees off-axis makes it look poised
   rather than pinned. */
.argus-mark {
  display: block; object-fit: contain; pointer-events: none;
  transform: rotate(-14deg);
  transition: transform .45s cubic-bezier(.34,1.3,.5,1);
}
#argus-btn .argus-mark {
  /* 34px inside a 52px circle. The mark's extent is roughly circular, so this
     fills the button comfortably while keeping clear of the curved edge. */
  width: 34px; height: 34px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.20));
}
/* Hovering nudges it round a little further — the mark has rotational symmetry
   at 120°, so a third of a turn lands it back on itself. */
#argus-btn:hover .argus-mark { transform: rotate(106deg); }
#argus-btn:active .argus-mark { transform: rotate(-14deg) scale(.92); }

.argus-avatar .argus-mark { transform: rotate(-14deg); }
.mob-tab .argus-mark { opacity: .85; transform: rotate(-14deg); }
.mob-tab.mob-tab-active .argus-mark { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .argus-mark { transition: none; }
  #argus-btn:hover .argus-mark { transform: rotate(-14deg); }
}


/* ══ Argus: live rotation ══
   The mark turns continuously while the panel is open, which reads as "this is
   running" without adding another indicator to the header. During inference it
   speeds up, so the state is legible at a glance from across a desk.

   Two separate animations rather than one with a changing duration: changing
   animation-duration mid-cycle makes the element jump, because the browser
   re-maps elapsed time onto the new period. Swapping the animation name and
   keeping both keyframes identical restarts cleanly at the current angle. */
@keyframes argus-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.argus-mark-live {
  animation: argus-spin 14s linear infinite;   /* idle: barely perceptible */
  transform-origin: 50% 50%;
}
/* Inference in flight — roughly nine times faster, clearly deliberate motion. */
#argus-drawer.argus-busy .argus-mark-live { animation-duration: 1.6s; }

/* The header mark must not inherit the button's static tilt, or the rotation
   would be applied on top of a fixed offset and stutter at the wrap point. */
.argus-avatar .argus-mark-live { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .argus-mark-live { animation: none; }
}

/* "New Chat" — was an inline indigo/violet gradient, the last purple left in
   the panel. Now on the shared Argus tokens like everything else. */
.argus-newchat-btn {
  font-size: 11px; font-weight: 600; padding: 4px 10px;
  background: linear-gradient(135deg, var(--ai-1), var(--ai-2));
  border: 1px solid rgba(var(--ai-glow), .55);
  color: #fff; border-radius: 5px; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  transition: filter .15s; letter-spacing: .01em;
}
.argus-newchat-btn:hover { filter: brightness(1.12); }

/* ── Map appearance picker ────────────────────────────────────────────────
   The selected swatch/icon needs a ring that reads against both a saturated
   fill and the surface behind it, hence the double box-shadow rather than a
   border (a border would shift the layout on selection). */
.mstyle-color { border: 2px solid transparent; transition: box-shadow .12s, transform .12s; }
.mstyle-color:hover { transform: scale(1.12); }
.mstyle-color.sel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ai-1); }
/* Fully specified here rather than inline on the element: an inline
   background would outrank the .sel rule and the selection would not show. */
.mstyle-icon {
  width: 32px; height: 32px; border-radius: 7px;
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .12s, color .12s, background .12s;
}
.mstyle-icon:hover { border-color: var(--ai-1); color: var(--text-1); }
.mstyle-icon.sel { border-color: var(--ai-1); color: #fff; background: var(--ai-1); }
/* The "Type default" chip in the bulk dialog is the same control, wider. */
.mstyle-icon.mstyle-icon-wide { width: auto; padding: 0 10px; font-size: 11px; }
.vigil-map-marker { transition: transform .12s; }
.vigil-map-marker:hover { transform: scale(1.12); }

/* ── The triskele loader ──────────────────────────────────────────────────
   One class for anything still rendering. Add `.vg-loading` to a container
   and a slowly turning triskele appears over it, in whichever colour reads on
   the current theme; remove the class and it goes. A page that shows a blank
   box while it waits looks broken; a page that shows its own mark turning
   looks like it is working. The mark is a background image so it needs no
   markup and cannot end up inside the element's own content.            */
:root { --vg-loader-img: url("../img/vigil_triskele_dark.16ae3b31cfe0.png"); --vg-loader-veil: rgba(255,255,255,.72); }
[data-theme="dark"], [data-theme="midnight"] {
  --vg-loader-img: url("../img/vigil_triskele_white.3708769aea88.png"); --vg-loader-veil: rgba(10,16,30,.72);
}
.vg-loading { position: relative; }
.vg-loading::before {
  content: ''; position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background: var(--vg-loader-veil); backdrop-filter: blur(1.5px);
  border-radius: inherit; animation: vg-veil .18s ease-out;
}
.vg-loading::after {
  content: ''; position: absolute; z-index: 31; pointer-events: none;
  left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  background: var(--vg-loader-img) center / contain no-repeat;
  opacity: .85; animation: vg-turn 1.6s linear infinite;
}
.vg-loading.vg-sm::after { width: 20px; height: 20px; margin: -10px 0 0 -10px; }
.vg-loading.vg-lg::after { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
/* Inline variant for buttons and short text: the mark alone, no veil. */
.vg-spin { display: inline-block; width: 14px; height: 14px; vertical-align: -3px;
  background: var(--vg-loader-img) center / contain no-repeat; animation: vg-turn 1.6s linear infinite; }
/* The mark (its small-size cut, scripts/make_triskele_small.py) in the text colour, for a button whose background changes with its state (dark text on a plain button,
   white on an active blue one). The asset is a mask, so the shape is exactly the asset's and the colour is the text's. */
.vg-spin-cur { display: inline-block; flex-shrink: 0; width: 14px; height: 14px; vertical-align: -2px; background-color: currentColor;
  -webkit-mask: url("../img/vigil_triskele_small.c107f9a19b50.png") center / contain no-repeat; mask: url("../img/vigil_triskele_small.c107f9a19b50.png") center / contain no-repeat;
  animation: vg-turn 1.2s linear infinite; }
@keyframes vg-turn { to { transform: rotate(360deg); } }
@keyframes vg-veil { from { opacity: 0 } to { opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .vg-loading::after, .vg-spin, .vg-spin-cur { animation-duration: 4s; } }
/* The old generic spinner now wears the mark too. */
.spinner { border: none; background: var(--vg-loader-img) center / contain no-repeat; animation: vg-turn 1.6s linear infinite; }

/* ── Beacon ──────────────────────────────────────────────────────────────── */
.bc-hint { display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--text-3);
  background:var(--surface-2); border:1px solid var(--border); border-radius:8px; padding:5px 9px; cursor:pointer }
.bc-hint:hover { color:var(--text); border-color:var(--border-2) }
.bc-hint kbd, .bc-foot kbd, .bc-key kbd { font:600 10px/1 ui-monospace,monospace; padding:2px 5px; border-radius:4px;
  border:1px solid var(--border-2); background:var(--surface); color:var(--text-3); margin:0 1px }
@media (max-width:768px){ .bc-hint span { display:none } }
#beacon[hidden], #bc-peek[hidden] { display:none !important }
#beacon, #bc-peek { position:fixed; inset:0; z-index:9500; display:flex; align-items:flex-start; justify-content:center; padding:8vh 16px 0 }
.bc-veil { position:absolute; inset:0; background:rgba(8,12,24,.45); backdrop-filter:blur(2px) }
.bc-box { position:relative; width:min(720px,100%); background:var(--surface); border:1px solid var(--border);
  border-radius:14px; box-shadow:0 30px 80px rgba(0,0,0,.35); overflow:hidden; animation:bc-in .14s ease-out }
@keyframes bc-in { from { transform:translateY(-8px); opacity:0 } to { transform:none; opacity:1 } }
.bc-search { display:flex; align-items:center; gap:10px; padding:12px 14px; border-bottom:1px solid var(--border) }
.bc-search svg { width:17px; height:17px; color:var(--text-3); flex-shrink:0 }
.bc-search input { flex:1; border:none; background:none; font-size:15px; color:var(--text); outline:none; min-width:0 }
.bc-keysbtn { width:24px; height:24px; border-radius:6px; border:1px solid var(--border); background:var(--surface-2);
  color:var(--text-3); font-size:12px; cursor:pointer }
.bc-body { max-height:min(58vh,560px); overflow-y:auto; padding:6px 0 }
.bc-group { padding:8px 14px 2px; font-size:10px; text-transform:uppercase; letter-spacing:.07em; color:var(--text-3); font-weight:650 }
.bc-item { display:flex; align-items:center; gap:10px; padding:8px 14px; cursor:pointer; border-left:3px solid transparent }
.bc-item.on { background:var(--surface-2); border-left-color:var(--accent,#6366F1) }
.bc-ico { width:26px; height:26px; border-radius:7px; display:flex; align-items:center; justify-content:center;
  font-size:12px; flex-shrink:0; background:var(--surface-2); color:var(--text-3); border:1px solid var(--border) }
.bc-item.on .bc-ico { background:var(--surface) }
.bc-t { flex:1; min-width:0 } .bc-title { font-size:13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.bc-sub { font-size:11.5px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.bc-dot { width:7px; height:7px; border-radius:50%; background:#94A3B8; flex-shrink:0 } .bc-dot.on { background:#10B981 }
.bc-urg { font-size:9.5px; padding:1px 6px; border-radius:999px; background:#DC262612; color:#B91C1C; border:1px solid #DC262640 }
.bc-key { font-size:11px; color:var(--text-3); flex-shrink:0 }
.bc-acts { display:flex; flex-wrap:wrap; gap:5px; padding:4px 14px 10px 53px }
.bc-act { font-size:11px; padding:3px 8px; border-radius:6px; border:1px solid var(--border-2); background:var(--surface);
  color:var(--text-2); cursor:pointer; display:inline-flex; gap:5px; align-items:center }
.bc-act:hover { border-color:var(--accent,#6366F1); color:var(--text) }
.bc-act b { font-weight:600; font-size:10px; color:var(--text-3) }
.bc-empty { padding:26px 16px; text-align:center; font-size:13px; color:var(--text-3); line-height:1.6 }
.bc-foot { display:flex; gap:14px; flex-wrap:wrap; padding:8px 14px; border-top:1px solid var(--border);
  font-size:11px; color:var(--text-3); background:var(--surface-2) }
.bc-pin { display:flex; gap:8px; align-items:center; padding:8px 14px 12px 53px; font-size:12px; color:var(--text-2); flex-wrap:wrap }
.bc-pin input { width:44px; text-align:center; font:600 13px ui-monospace,monospace; padding:4px; border:1px solid var(--border-2);
  border-radius:6px; background:var(--surface); color:var(--text) }
.bc-pin .bc-act { padding:4px 10px }
.bc-err { color:#B91C1C; font-size:11.5px }
/* keys table */
.bc-keys { padding:10px 14px 14px; display:grid; grid-template-columns:1fr 1fr; gap:4px 24px; font-size:12.5px }
@media (max-width:600px){ .bc-keys { grid-template-columns:1fr } }
.bc-keys div { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:5px 0; border-bottom:1px solid var(--border) }
.bc-keys .bc-del { color:var(--text-3); cursor:pointer; font-size:11px; margin-left:6px } .bc-keys .bc-del:hover { color:#B91C1C }
/* peek */
.bc-peekbox { width:min(880px,100%) }
.bc-peekhead { display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border) }
.bc-peektitle { font-size:15px; font-weight:650; white-space:nowrap; overflow:hidden; text-overflow:ellipsis }
.bc-peeksub { font-size:12px; color:var(--text-3) }
.bc-peekacts { margin-left:auto; display:flex; gap:6px; flex-wrap:wrap }
.bc-x { width:28px; height:28px; border-radius:7px; border:1px solid var(--border); background:var(--surface-2); color:var(--text-3); font-size:16px; cursor:pointer }
.bc-peekbody { max-height:min(70vh,640px); overflow-y:auto; padding:12px 16px 16px; min-height:120px }
.bc-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:10px }
.bc-sp { border:1px solid var(--border); border-radius:10px; padding:9px 11px; background:var(--surface-2) }
.bc-sp-h { display:flex; justify-content:space-between; align-items:baseline; font-size:11.5px; color:var(--text-3) }
.bc-sp-v { font-size:16px; font-weight:650; font-variant-numeric:tabular-nums; color:var(--text) }
.bc-sp canvas { width:100%; height:54px; display:block; margin-top:6px }
.bc-sp-b { font-size:10.5px; color:var(--text-3); margin-top:4px }
.bc-mem { font-size:12px; padding:6px 0; border-bottom:1px solid var(--border); display:flex; gap:8px }
.bc-mem:last-child { border-bottom:none } .bc-mem b { font-size:10px; color:var(--text-3); text-transform:uppercase; letter-spacing:.05em; white-space:nowrap; padding-top:2px }
.bc-h { font-size:10.5px; text-transform:uppercase; letter-spacing:.07em; color:var(--text-3); font-weight:650; margin:14px 0 6px }

.bc-range { display:flex; gap:4px; align-items:center; margin-bottom:10px; flex-wrap:wrap }
.bc-rb { font-size:11px; padding:3px 9px; border-radius:6px; border:1px solid var(--border-2); background:var(--surface); color:var(--text-2); cursor:pointer }
.bc-rb.on { background:var(--text); color:var(--surface); border-color:var(--text) }
.bc-range-note { margin-left:auto; font-size:10.5px; color:var(--text-3) }
.bc-sp canvas { height:64px; cursor:crosshair }
.bc-prov { font-size:10.5px; color:var(--text-3); margin-top:2px }


/* ── Session expiry warning ───────────────────────────────────────────────── */
#session-warn { position: fixed; inset: 0; z-index: 10000; background: rgba(2,6,23,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
#session-warn .sw-in { background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 22px; width: min(420px, 100%); box-shadow: 0 24px 64px rgba(0,0,0,.35); }
#session-warn b { font-size: 16px; display: block; margin-bottom: 6px; color: var(--text); }
#session-warn p { font-size: 13px; color: var(--text-2); line-height: 1.55; margin: 0 0 14px; }
#session-warn .sw-acts { display: flex; gap: 10px; align-items: center; }
#session-warn .sw-stay { flex: 1; height: 40px; border-radius: 10px; border: 0; background: var(--accent);
  color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
#session-warn .sw-out { font-size: 13px; color: var(--text-3); text-decoration: none; padding: 0 8px; }
#session-warn .sw-out:hover { color: var(--text); }

/* ── Readable tones ─────────────────────────────────────────────────────────
   Accent text that keeps its contrast in every theme: the 700 shades read on
   light surfaces, the 300 tints on dark ones. And --text-3-read: each theme's
   own tertiary colour moved just far enough towards its text colour to reach
   4.5:1 on its surfaces (the plain --text-3 sits at 1.6–3.2:1). Pages that show
   generated content (reports, canvases) read their tertiary text with it. */
:root {
  --tone-red: #B91C1C; --tone-red-2: #DC2626; --tone-orange: #C2410C; --tone-amber: #B45309; --tone-amber-2: #D97706;
  --tone-green: #047857; --tone-blue: #1D4ED8; --tone-cyan: #0E7490; --tone-violet: #6D28D9;
  --text-3-read: #69768B;
}
[data-theme="rose"] { --text-3-read: #9D6270; }
[data-theme="dark"], [data-theme="midnight"], [data-theme="ocean"], [data-theme="forest"], [data-theme="crimson"] {
  --tone-red: #FCA5A5; --tone-red-2: #F87171; --tone-orange: #FDBA74; --tone-amber: #FCD34D; --tone-amber-2: #FBBF24;
  --tone-green: #6EE7B7; --tone-blue: #93C5FD; --tone-cyan: #67E8F9; --tone-violet: #C4B5FD;
}
[data-theme="dark"] { --text-3-read: #7A8BA6; }
[data-theme="midnight"] { --text-3-read: #8277B5; }
[data-theme="ocean"] { --text-3-read: #4D899E; }
[data-theme="forest"] { --text-3-read: #4C8E6C; }
[data-theme="crimson"] { --text-3-read: #A47375; }

/* ── charts: what happened in ink, a forecast in one accent per theme ─────────────────────────────────────────────
   Checked with the dataviz palette validator against each theme's chart surface (--surface-2): every forecast colour
   is ≥ 4:1 on it and ≥ 25 ΔE (OKLab ×100) from the ink under normal, protan and deutan vision. Midnight is violet
   itself, so its forecast is amber. */
:root                   { --chart-actual: var(--text); --chart-forecast: #7C3AED; --chart-scenario: #B45309; }
[data-theme="dark"]     { --chart-forecast: #9270F5; --chart-scenario: #FBBF24; }
[data-theme="midnight"] { --chart-forecast: #C77A1A; --chart-scenario: #2BB3A3; }
[data-theme="ocean"]    { --chart-forecast: #B06EF5; --chart-scenario: #FBBF24; }
[data-theme="forest"]   { --chart-forecast: #B06EF5; --chart-scenario: #FBBF24; }
[data-theme="crimson"]  { --chart-forecast: #6D28D9; --chart-scenario: #B45309; }
/* (a what-if — the forecast with a change applied — is the third colour: --chart-scenario, likewise validated against
   the forecast colour in every theme) */
/* a page of generated content opts in: <html class="…"> is untouched; the page's own style sets html:root */

/* ── Scrollbars ────────────────────────────────────────────────────────────
   One treatment on every platform. Linux and Windows draw a chunky grey bar
   with arrow buttons (worst on the dark sidebar); macOS overlays its own.
   Here every scrolling box gets a thin pill — no arrows, no track — in the
   theme's own colour at low contrast, brightening under the pointer; the
   sidebar gets none at all. Chrome, Edge and Safari read ::-webkit-scrollbar;
   Firefox reads the standard properties (given to Firefox alone: setting them
   in Chrome makes it draw its own bar, arrow buttons included). The pill is
   always faintly there rather than appearing on hover: Chrome resolves a
   scrollbar's style when it creates it and does not reliably restyle it when
   the box's :hover changes, so a hover-revealed bar could stay invisible.
   Wheel, trackpad, touch and keyboard scrolling are untouched.             */
:root { --scroll-thumb: rgba(15, 23, 42, .16); --scroll-thumb-hover: rgba(15, 23, 42, .34); }
[data-theme="dark"], [data-theme="midnight"], [data-theme="ocean"], [data-theme="forest"], [data-theme="crimson"] {
  --scroll-thumb: rgba(226, 232, 240, .13); --scroll-thumb-hover: rgba(226, 232, 240, .30);
}
@supports not selector(::-webkit-scrollbar) {                           /* Firefox */
  * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
}
::-webkit-scrollbar { width: 8px; height: 8px; background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--scroll-thumb); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; min-height: 28px; }
::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { background-color: var(--scroll-thumb-hover); }

/* The sidebar scrolls without a bar at all; a soft fade at an edge says there is more that way. */
.sidebar-nav-scroll { scrollbar-width: none; }
.sidebar-nav-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sidebar-nav-scroll.fade-top    { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px); mask-image: linear-gradient(to bottom, transparent 0, #000 28px); }
.sidebar-nav-scroll.fade-bottom { -webkit-mask-image: linear-gradient(to top, transparent 0, #000 28px); mask-image: linear-gradient(to top, transparent 0, #000 28px); }
.sidebar-nav-scroll.fade-top.fade-bottom {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
}
