/* OmniRMM console - design tokens. Dark (navy/indigo) is the default; light is opt-in via the theme toggle. */
:root {
  color-scheme: dark;
  --bg: #090d16;
  --surface: #111726;
  --surface-2: #151c2d;
  --surface-3: #1a2336;
  --raised: #0f1524;
  --input-bg: #0b1120;
  --border: #1f293d;
  --border-strong: #2c3a55;
  --text: #e2e8f0;
  --text-strong: #ffffff;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-deep: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --accent-border: rgba(99, 102, 241, 0.28);
  --glow: 0 0 22px -6px rgba(99, 102, 241, 0.55);
  --grid: #1e293b;
  --axis: #334155;
  --series-1: #6366f1;
  --good: #10b981;
  --good-ink: #34d399;
  --warning: #f59e0b;
  --warning-ink: #fbbf24;
  --serious: #f97316;
  --serious-ink: #fb923c;
  --critical: #f43f5e;
  --critical-ink: #fb7185;
  --violet: #a78bfa;
  --code-bg: #0b1120;
  --sidebar: #0d121f;
  --sidebar-text: #94a3b8;
  --sidebar-strong: #ffffff;
  --nav-hover: rgba(148, 163, 184, 0.08);
  --topbar-bg: rgba(13, 18, 31, 0.7);
  --backdrop: rgba(2, 6, 23, 0.7);
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --topbar-h: 64px;
  --sidebar-w: 256px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, .6);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --raised: #ffffff;
  --input-bg: #ffffff;
  --border: #e5e7ef;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-strong: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --accent: #6366f1;
  --accent-2: #4f46e5;
  --accent-deep: #4338ca;
  --accent-soft: rgba(99, 102, 241, 0.09);
  --accent-border: rgba(99, 102, 241, 0.25);
  --glow: 0 6px 18px -6px rgba(79, 70, 229, 0.45);
  --grid: #eef0f4;
  --axis: #cbd5e1;
  --good: #10b981;
  --good-ink: #047857;
  --warning: #f59e0b;
  --warning-ink: #b45309;
  --serious: #f97316;
  --serious-ink: #c2410c;
  --critical: #f43f5e;
  --critical-ink: #be123c;
  --violet: #7c3aed;
  --code-bg: #f6f7fb;
  --sidebar: #ffffff;
  --sidebar-text: #475569;
  --sidebar-strong: #0f172a;
  --nav-hover: rgba(15, 23, 42, 0.05);
  --topbar-bg: rgba(255, 255, 255, 0.75);
  --backdrop: rgba(15, 23, 42, 0.45);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 24px 60px -12px rgba(15, 23, 42, .25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
::selection { background: var(--accent); color: #fff; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.02em; color: var(--text-strong); }
h2 { font-size: 14.5px; margin: 0 0 14px; font-weight: 600; color: var(--text-strong); letter-spacing: -.005em; }
h3 { font-size: 11px; margin: 0 0 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
kbd { font-family: var(--mono); font-size: 10.5px; background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text-2); padding: 1px 6px; border-radius: 5px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ping { 75%, 100% { transform: scale(2.2); opacity: 0; } }

/* ---------- layout: full-height sidebar | (sticky topbar + scrolling main) */
.shell { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); border-right: 1px solid var(--border);
  position: sticky; top: 0; width: var(--sidebar-w); height: 100vh; flex-shrink: 0;
  overflow-y: auto; display: flex; flex-direction: column; z-index: 60;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; color: var(--sidebar-strong); }
.sidebar > .brand { height: var(--topbar-h); padding: 0 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0; color: #fff; font-size: 15px; font-weight: 700;
  background: linear-gradient(45deg, var(--accent-deep), #818cf8); display: grid; place-items: center; box-shadow: var(--glow);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name span { color: var(--accent-2); font-weight: 500; }
.brand-sub { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); font-weight: 600; margin-top: 1px; }
.nav { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--sidebar-text);
  font-weight: 500; font-size: 13.5px; border: 1px solid transparent; transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }
.nav a:hover { background: var(--nav-hover); text-decoration: none; color: var(--text-strong); }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-border); box-shadow: var(--shadow); }
.nav .badge { margin-left: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; padding: 16px 12px 6px; }
.nav-section:first-child { padding-top: 6px; }
.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); display: flex; flex-direction: column; gap: 12px; }
.sidebar-foot button { align-self: flex-start; }
.status-chip {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-weight: 500;
}
.status-chip .pulse { position: relative; width: 9px; height: 9px; flex-shrink: 0; }
.status-chip .pulse::before, .status-chip .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--good); }
.status-chip .pulse::before { animation: ping 1.6s cubic-bezier(0, 0, .2, 1) infinite; opacity: .7; }
.status-chip.down .pulse::before { animation: none; opacity: 0; }
.status-chip.down .pulse::after { background: var(--critical); }
.status-chip .status-meta { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text-3); }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-meta { min-width: 0; line-height: 1.3; }
.user-name { font-weight: 600; color: var(--text-strong); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); text-transform: capitalize; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--accent-2); font-weight: 700; font-size: 12px;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.main { flex: 1; min-width: 0; padding: 26px 28px 56px; animation: fadeIn .25s cubic-bezier(.16, 1, .3, 1); }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .spacer { flex: 1; }
.spacer { flex: 1; }
.crumb { color: var(--text-3); font-size: 13px; }
.menu-btn, .topbar .menu-btn { display: none; }

/* ---------- sticky glass top bar */
.topbar {
  position: sticky; top: 0; height: var(--topbar-h); z-index: 50; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--topbar-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border); color: var(--text-2);
}
.search-trigger {
  width: min(380px, 100%); justify-content: flex-start; gap: 10px; padding: 8px 12px; border-radius: 12px;
  background: var(--input-bg); border: 1px solid var(--border); color: var(--text-3); font-size: 12.5px; font-weight: 400;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .15);
}
.search-trigger svg { width: 16px; height: 16px; transition: color .15s; }
.search-trigger:hover { background: var(--surface-2); border-color: var(--border-strong); }
.search-trigger:hover svg { color: var(--accent-2); }
.search-trigger kbd { margin-left: auto; }
.topbar-menu { position: relative; display: flex; align-items: center; }
.topbar-icons { display: flex; align-items: center; gap: 6px; }
.topbar .divider { width: 1px; height: 18px; background: var(--border-strong); margin: 0 6px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 11px; background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer; position: relative; padding: 0;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-3); border-color: var(--border); color: var(--text-strong); }
.icon-badge { position: absolute; top: 2px; right: 2px; box-shadow: 0 0 0 2px var(--bg); }
.theme-dark-ic { display: inline; }
.theme-light-ic { display: none; }
:root[data-theme="light"] .theme-dark-ic { display: none; }
:root[data-theme="light"] .theme-light-ic { display: inline; }
.account-btn { padding: 3px 8px 3px 3px; border-radius: 999px; gap: 6px; background: transparent; border-color: transparent; color: var(--text-2); }
.account-btn svg { width: 15px; height: 15px; }
.account-btn:hover { background: var(--surface-3); border-color: var(--border); }
.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0; background: var(--raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); min-width: 220px;
  padding: 6px; display: flex; flex-direction: column; z-index: 80; animation: pop .16s ease-out;
}
.account-menu .menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.account-menu a, .account-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 9px; color: var(--text-2);
  text-decoration: none; background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 500;
}
.account-menu svg { width: 16px; height: 16px; }
.account-menu a:hover, .account-menu button:hover { background: var(--surface-3); color: var(--text-strong); }
.account-menu .danger:hover { color: var(--critical-ink); background: rgba(244, 63, 94, .1); }

/* ---------- notifications pull-down (top bar) and page */
.notif-menu {
  position: absolute; top: calc(100% + 8px); right: -54px; z-index: 80; width: min(380px, calc(100vw - 24px));
  background: var(--raised); color: var(--text); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .16s ease-out;
}
.notif-menu-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-strong); }
.notif-list { max-height: min(440px, 60vh); overflow-y: auto; padding: 6px; }
.notif-item {
  width: 100%; display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 10px; text-align: left;
  background: none; border: 1px solid transparent; color: var(--text); font-weight: 400;
}
.notif-item:hover, .notif-item:focus-visible { background: var(--surface-3); border-color: transparent; }
.notif-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; border: 1px solid; }
.notif-icon svg { width: 15px; height: 15px; }
.notif-text { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.notif-title { font-weight: 600; font-size: 13px; color: var(--text-strong); overflow-wrap: anywhere; }
.notif-body { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.notif-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 12px; color: var(--text-3); font-size: 13px; }
.notif-empty svg { width: 22px; height: 22px; color: var(--good); }
.notif-menu-foot {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px; border-top: 1px solid var(--border);
  background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--accent-2);
}
.notif-menu-foot svg { width: 14px; height: 14px; }
.notif-menu-foot:hover { background: var(--surface-3); text-decoration: none; }
.notif-cell .notif-title { font-weight: 500; color: var(--text-2); }
.notif-cell.unread .notif-title { font-weight: 650; color: var(--text-strong); }
.unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.unread-dot.read { background: transparent; box-shadow: inset 0 0 0 1.5px var(--border-strong); }
td a svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
.bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius-md);
  background: var(--accent-soft); border: 1px solid var(--accent-border); color: var(--text-strong); animation: fadeIn .2s ease-out;
}
.bulk-bar strong { margin-right: 6px; }
@media (max-width: 520px) { .notif-menu { right: -100px; } }

/* ---------- settings: record numbering */
.numbering-row {
  display: grid; grid-template-columns: 170px minmax(120px, 1fr) minmax(120px, 160px) minmax(200px, 1.4fr); gap: 14px; align-items: end;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.numbering-label { align-self: center; }
.numbering-sample { display: flex; flex-direction: column; gap: 6px; }
.numbering-preview { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 38px; padding: 8px 12px; border-radius: 11px; background: var(--code-bg); border: 1px dashed var(--border-strong); }
.numbering-preview .mono { color: var(--accent-2); font-weight: 600; }
input.invalid, input.invalid:focus { border-color: var(--critical); box-shadow: 0 0 0 3px rgba(244, 63, 94, .15); }
.ref { color: var(--accent-2); font-weight: 600; white-space: nowrap; }
.ticket-search { width: 320px; }
@media (max-width: 520px) { .ticket-search { width: 100%; } }
@media (max-width: 860px) { .numbering-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .numbering-label, .numbering-sample { grid-column: 1 / -1; } }

/* ---------- command palette */
.palette-back { align-items: start; padding-top: 12vh; }
.palette { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .18s ease-out; }
.palette-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); }
.palette-head svg { width: 18px; height: 18px; }
.palette-head input { flex: 1; border: none; background: transparent; font-size: 14px; padding: 4px 0; box-shadow: none; }
.palette-head input:focus { outline: none; box-shadow: none; border: none; }
.palette-list { max-height: 340px; overflow-y: auto; padding: 6px; }
.palette-item { width: 100%; border: none; background: none; padding: 10px 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
.palette-item svg { width: 16px; height: 16px; color: var(--accent-2); }
.palette-item:hover, .palette-item.active { background: var(--surface-3); }
.palette { width: min(680px, 100%); }
.palette-list { max-height: min(520px, 62vh); }
.palette-group { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.palette-group .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.palette-item { gap: 10px; text-align: left; }
.palette-item:hover { border-color: transparent; }
.palette-item .pill { margin-left: auto; flex-shrink: 0; }
.palette-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.palette-title { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-sub { font-size: 12px; color: var(--text-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-ref { display: inline-block; margin-right: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--accent-2); font-weight: 600; }
.palette-item mark { background: var(--accent-soft); color: var(--text-strong); border-radius: 3px; box-shadow: 0 0 0 1px var(--accent-border); }
.palette-status { display: flex; align-items: center; gap: 10px; padding: 12px; color: var(--text-3); font-size: 12.5px; }
.palette-hint { padding: 10px 12px 12px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--border); margin-top: 6px; }

/* ---------- floating "Ask about a device" assistant (assistant.js) */
.ai-fab {
  position: fixed; z-index: 85; width: 56px; height: 56px; border-radius: 50%; padding: 0; justify-content: center;
  background: linear-gradient(135deg, var(--accent-deep), #818cf8); border: 1px solid rgba(255, 255, 255, .18); color: #fff;
  box-shadow: 0 10px 30px -8px rgba(79, 70, 229, .7), var(--glow); cursor: grab; touch-action: none; user-select: none;
  transition: transform .15s, box-shadow .15s;
}
.ai-fab svg { width: 24px; height: 24px; }
.ai-fab:hover { background: linear-gradient(135deg, var(--accent), #a5b4fc); border-color: rgba(255, 255, 255, .3); transform: translateY(-2px); }
.ai-fab.dragging { cursor: grabbing; transform: scale(1.06); transition: none; }
.ai-fab.open { box-shadow: 0 0 0 4px var(--accent-soft), 0 10px 30px -8px rgba(79, 70, 229, .7); }
.ai-panel {
  position: fixed; z-index: 86; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.16, 1, .3, 1);
}
.ai-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ai-avatar { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(45deg, var(--accent-deep), #818cf8); box-shadow: var(--glow); flex-shrink: 0; }
.ai-avatar svg { width: 18px; height: 18px; }
.ai-title { flex: 1; min-width: 0; font-weight: 600; color: var(--text-strong); line-height: 1.3; }
.ai-title .small { font-weight: 400; }
.ai-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.ai-msg.me { align-self: flex-end; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-msg.err { color: var(--critical-ink); border-color: rgba(244, 63, 94, .3); background: rgba(244, 63, 94, .08); }
.ai-msg .answer { font-size: 13.5px; }
.ai-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11.5px; margin-bottom: 6px; }
.ai-meta a { font-weight: 600; }
.ai-meta .confidence .meter { width: 50px; }
.ai-evidence { margin-top: 8px; font-size: 12px; color: var(--text-2); }
.ai-evidence summary { cursor: pointer; color: var(--accent-2); font-weight: 500; }
.ai-evidence ul { margin: 6px 0 0; padding-left: 18px; }
.ai-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ai-chip { font-size: 12px; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-2); }
.ai-chip:hover { background: var(--accent-soft); border-color: var(--accent); }
.ai-foot { border-top: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.ai-foot select { width: 100%; font-size: 12.5px; padding: 6px 10px; }
.ai-input { display: flex; gap: 8px; }
.ai-input input { flex: 1; }
.ai-send { padding: 0; width: 38px; justify-content: center; flex-shrink: 0; }
.ai-send svg { width: 16px; height: 16px; }
.typing { display: inline-flex; gap: 4px; padding: 3px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- surfaces */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); min-width: 0; transition: border-color .15s;
}
.card + .card { margin-top: 16px; }
.grid > .card + .card, .stack > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* Two side-by-side halves inside one card, separated by a vertical rule. */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.split > * + * { border-left: 1px solid var(--border); padding-left: 28px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.right { margin-left: auto; }

/* ---------- reports */
.report-range { gap: 6px; color: var(--text-3); }
.report-range svg { width: 16px; height: 16px; }
.report-range select, .report-range input { padding: 6px 10px; }
.report-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.report .grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.report .kpi .value { font-size: 24px; }
.kpi-dot { width: 9px; height: 9px; border-radius: 50%; border: none; background: currentColor !important; box-shadow: 0 0 0 4px var(--accent-soft); }
.report .grid.cols-3 > .card, .report .grid.cols-2 > .card { margin-top: 0; }
@media print {
  .sidebar, .topbar, .ai-fab, .ai-panel, .tabs, .report-range, .page-head button, .report-head button, .drag-handle, .toast-host { display: none !important; }
  body, .card { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .card { border-color: #ccc !important; break-inside: avoid; }
  .main { padding: 0 !important; animation: none; }
  .shell { display: block; }
}

/* ---------- terminal page */
.term-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.term-layout > .card { margin-top: 0; }
.term-side { display: flex; flex-direction: column; gap: 10px; padding: 14px; position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 40px); }
.term-side input { width: 100%; }
.term-devices { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.term-device { width: 100%; text-align: left; justify-content: flex-start; gap: 10px; padding: 8px 10px; border-radius: 10px; background: none; border-color: transparent; }
.term-device:hover { background: var(--surface-3); border-color: transparent; }
.term-device.active { background: var(--accent-soft); border-color: var(--accent-border); }
.term-device.active .term-device-name { color: var(--accent-2); }
.term-device-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.term-device-name { font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-device-meta .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.term-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.term-dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.term-dot.off { background: var(--text-3); }
.term-pane { min-height: 420px; display: flex; flex-direction: column; gap: 14px; }
.term-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.term-empty { margin: auto; text-align: center; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 0; }
.term-empty .kpi-icon { width: 48px; height: 48px; border-radius: 14px; }
.term-empty .kpi-icon svg { width: 22px; height: 22px; }
.term-empty h2 { margin: 6px 0 0; }
.key-override summary { cursor: pointer; color: var(--accent-2); font-size: 12.5px; font-weight: 500; }
.key-override[open] summary { margin-bottom: 10px; }
@media (max-width: 860px) {
  .term-layout { grid-template-columns: minmax(0, 1fr); }
  .term-side { position: static; max-height: 260px; }
}

/* ---------- drag-to-reorder cards (sortableGrid) */
.sortable { position: relative; }
.drag-handle {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 28px; height: 28px; padding: 0; justify-content: center;
  border-radius: 9px; background: var(--surface-3); border-color: var(--border-strong); color: var(--text-3);
  cursor: grab; touch-action: none; opacity: 0; transition: opacity .15s, color .15s;
}
.drag-handle svg { width: 16px; height: 16px; stroke-width: 3.2; }
.drag-handle:hover { color: var(--accent-2); border-color: var(--accent-border); background: var(--surface-3); }
.sortable:hover > .drag-handle, .drag-handle:focus-visible, .sortable.dragging > .drag-handle { opacity: 1; }
@media (hover: none) { .drag-handle { opacity: .75; } }
.kpi > .drag-handle { top: auto; bottom: 12px; }  /* top-right is taken by the KPI icon */
.kpi.sortable .sub, .sortable > h2, .sortable > .chart-head { padding-right: 36px; }  /* keep text clear of the handle */
.sortable.dragging { opacity: .6; outline: 2px dashed var(--accent); outline-offset: 3px; box-shadow: var(--glow); }
.sortable.dragging > .drag-handle { cursor: grabbing; color: var(--accent-2); }
.grid.sorting { user-select: none; cursor: grabbing; }

/* ---------- KPI tiles */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; transition: border-color .15s, transform .15s; }
a.kpi:hover { border-color: var(--border-strong); transform: translateY(-1px); text-decoration: none; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi .label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 10px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.kpi-top + .value { margin-top: 12px; }
.kpi .sub { color: var(--text-3); font-size: 11.5px; margin-top: 2px; }
.kpi-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; border: 1px solid; }
.kpi-icon svg { width: 16px; height: 16px; }
.tone-accent { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-border); }
.tone-good { background: rgba(16, 185, 129, .1); color: var(--good-ink); border-color: rgba(16, 185, 129, .22); }
.tone-warning { background: rgba(245, 158, 11, .1); color: var(--warning-ink); border-color: rgba(245, 158, 11, .22); }
.tone-serious { background: rgba(249, 115, 22, .1); color: var(--serious-ink); border-color: rgba(249, 115, 22, .22); }
.tone-critical { background: rgba(244, 63, 94, .1); color: var(--critical-ink); border-color: rgba(244, 63, 94, .22); }
.tone-violet { background: rgba(167, 139, 250, .1); color: var(--violet); border-color: rgba(167, 139, 250, .22); }

/* ---------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th {
  font-size: 11px; font-weight: 600; color: var(--text-3); white-space: nowrap; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-2);
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-3); }
tr.clickable { cursor: pointer; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .sort-arrow { display: inline-block; margin-left: 4px; opacity: .35; font-size: 9px; }
th.sorted { color: var(--accent-2); }
th.sorted .sort-arrow { opacity: 1; color: var(--accent-2); }

/* ---------- controls */
button, .btn {
  font: inherit; font-size: 13px; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text);
  padding: 7px 14px; border-radius: 11px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s; line-height: 1.4;
}
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--text-3); text-decoration: none; }
button:active:not(:disabled), .btn:active { transform: scale(.98); }
button.primary, .btn.primary {
  background: linear-gradient(90deg, var(--accent-deep), var(--accent)); border-color: transparent; color: var(--accent-ink); box-shadow: var(--glow);
}
button.primary:hover, .btn.primary:hover { background: linear-gradient(90deg, var(--accent), #818cf8); border-color: transparent; }
button.danger { color: var(--critical-ink); background: rgba(244, 63, 94, .08); border-color: rgba(244, 63, 94, .25); }
button.danger:hover { background: rgba(244, 63, 94, .16); border-color: rgba(244, 63, 94, .4); }
button.primary.danger { background: linear-gradient(90deg, #e11d48, var(--critical)); color: #fff; border-color: transparent; box-shadow: 0 0 20px -6px rgba(244, 63, 94, .6); }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-3); border-color: transparent; }
button.ghost.danger:hover { background: rgba(244, 63, 94, .1); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm, .btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 9px; }
/* The `hidden` attribute is a UA-stylesheet default, so any of our own `display:`
   rules (buttons, .form-grid, .row, …) silently out-specifies it unless we say so
   explicitly here - this one rule covers every element, not just the ones hit so far. */
[hidden] { display: none !important; }
input, select, textarea {
  font: inherit; font-size: 13px; color: var(--text); background: var(--input-bg); border: 1px solid var(--border);
  border-radius: 11px; padding: 8px 11px; min-width: 0; max-width: 100%; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; padding: 0; }
input[type="file"] { padding: 6px; }
input[type="file"]::file-selector-button {
  font: inherit; font-size: 12px; margin-right: 10px; border: 1px solid var(--border-strong); background: var(--surface-3);
  color: var(--text); border-radius: 8px; padding: 4px 10px; cursor: pointer;
}
select { cursor: pointer; }
textarea { width: 100%; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 260px; background: var(--code-bg); tab-size: 2; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 500; }
label.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* ---------- pills / status: tinted fill + border in the status hue */
.pill {
  --tone: var(--text-3); --tone-ink: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap; color: var(--tone-ink);
  background: color-mix(in srgb, var(--tone) 12%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 26%, transparent);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tone); }
.st-good, .st-online, .st-completed, .st-successful, .st-installed, .st-resolved, .st-low, .st-active { --tone: var(--good); --tone-ink: var(--good-ink); }
.st-warning, .st-pending, .st-pending_approval, .st-acknowledged, .st-available, .st-medium, .st-approved, .st-open { --tone: var(--warning); --tone-ink: var(--warning-ink); }
.st-critical, .st-offline, .st-failed, .st-rejected, .st-expired, .st-revoked, .st-breached { --tone: var(--critical); --tone-ink: var(--critical-ink); }
.st-serious, .st-security, .st-high { --tone: var(--serious); --tone-ink: var(--serious-ink); }
.st-new, .st-queued, .st-sent, .st-running, .st-installing, .st-info, .st-used, .st-closed { --tone: var(--accent); --tone-ink: var(--accent-2); }
.badge { background: var(--critical); color: #fff; border-radius: 999px; font-size: 10.5px; padding: 1px 7px; font-weight: 700; line-height: 1.5; }
.nav .badge { background: rgba(244, 63, 94, .15); color: var(--critical-ink); border: 1px solid rgba(244, 63, 94, .25); }
.tag { display: inline-block; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 7px; font-size: 11px; margin: 1px 4px 1px 0; }
.meter { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-deep), var(--accent-2)); border-radius: 999px; transition: width .5s; }
.meter.warn > span { background: var(--warning); }
.meter.crit > span { background: var(--critical); }

/* ---------- tabs: segmented control */
.tabs {
  display: flex; width: fit-content; max-width: 100%; gap: 3px; padding: 4px; margin-bottom: 18px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
}
.tabs button { border: 1px solid transparent; background: none; border-radius: 9px; padding: 6px 14px; color: var(--text-2); white-space: nowrap; }
.tabs button:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.tabs button.active { background: var(--surface-3); color: var(--accent-2); border-color: var(--border-strong); box-shadow: var(--shadow); }

.ft-bar { margin-bottom: 10px; gap: 8px; }
.ft-bar .ft-search { flex: 1 1 220px; max-width: 340px; }
.ft-bar select { width: auto; max-width: 220px; }
.device-tabs-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.device-tabs-row .tabs { margin-bottom: 0; }
.device-power { gap: 6px; }

/* ---------- wizard */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-3); font-weight: 550; font-size: 13px; }
.step .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 700; }
.step.active { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-border); }
.step.active .n, .step.done .n { background: var(--accent); color: #fff; }
.os-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.os-tile { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 20px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--text); }
.os-tile svg { width: 40px; height: 40px; color: var(--text-2); }
.os-tile:hover { border-color: var(--accent-border); background: var(--surface-2); }
.os-tile.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--glow); }
.os-tile.selected svg { color: var(--accent-2); }
.os-tile .sub { font-weight: 400; color: var(--text-3); font-size: 12px; }
.codebox { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; overflow-x: auto; }
.codebox pre { white-space: pre; padding-right: 80px; }
.codebox .copy { position: absolute; top: 9px; right: 9px; }
.tok-cmd { color: #818cf8; font-weight: 600; }
.tok-flag, .tok-key { color: #c084fc; }
.tok-str { color: #34d399; }
.tok-url { color: #fb923c; }
.tok-com { color: var(--text-3); font-style: italic; }
:root[data-theme="light"] .tok-cmd { color: #4f46e5; }
:root[data-theme="light"] .tok-flag, :root[data-theme="light"] .tok-key { color: #7c3aed; }
:root[data-theme="light"] .tok-str { color: #047857; }
:root[data-theme="light"] .tok-url { color: #c2410c; }
.notice { border: 1px solid var(--accent-border); background: var(--accent-soft); color: var(--text); padding: 11px 14px; border-radius: var(--radius-md); font-size: 13px; }
.notice.warn { border-color: rgba(245, 158, 11, .3); background: rgba(245, 158, 11, .08); }
.notice.err { border-color: rgba(244, 63, 94, .3); background: rgba(244, 63, 94, .08); color: var(--critical-ink); }
.notice.ok { border-color: rgba(16, 185, 129, .3); background: rgba(16, 185, 129, .08); }
.term-wrap { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); padding: 10px; background: #0b1120; }
.term-wrap { height: 440px; }  /* fitTerminal() sizes the terminal's rows/cols to this box */
.term-wrap.tall { height: calc(100vh - var(--topbar-h) - 220px); min-height: 360px; }
.desk-wrap { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); background: #0b1120; height: min(70vh, 720px); min-height: 360px; display: flex; }
.desk-video { flex: 1; width: 100%; height: 100%; min-width: 0; object-fit: contain; outline: none; cursor: default; }
.desk-video:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- charts */
.chart { position: relative; min-height: 150px; }
.chart svg { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .series { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: .12; }
.chart text { fill: var(--text-3); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .tip { position: absolute; pointer-events: none; background: var(--raised); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); border-radius: 9px; padding: 5px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -115%); }
.chart-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.chart-head .now { margin-left: auto; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series-1); transition: opacity .12s; }
.chart .bar:hover { opacity: .75; }

/* ---------- ranked bar list */
.barlist { display: flex; flex-direction: column; gap: 12px; }
.barlist-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 12px; align-items: center; }
.barlist-row.clickable { cursor: pointer; }
.barlist-label { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.barlist-track > span { display: block; height: 100%; border-radius: 999px; min-width: 2px; transition: width .5s; }
.barlist-value { font-size: 12.5px; font-weight: 600; text-align: right; color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* ---------- kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 14px; overflow-x: auto; }
.kanban .col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kanban .col h3 { display: flex; justify-content: space-between; padding: 2px 2px 4px; }
.kanban .tcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.kanban .tcard:hover { border-color: var(--accent-border); transform: translateY(-1px); }

/* ---------- misc */
.output { background: #0b1120; color: #e2e8f0; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; max-height: 420px; overflow: auto; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; }
.output .err { color: #fb7185; }
.comment { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-md); padding: 10px 12px; }
.comment.internal { background: rgba(245, 158, 11, .07); border-color: rgba(245, 158, 11, .22); }
.empty { text-align: center; color: var(--text-3); padding: 32px 12px; font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0 20px; font-size: 13px; }
.kv dt, .kv dd { padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text-strong); font-weight: 500; }
.kv dt:nth-last-of-type(1), .kv dd:nth-last-of-type(1) { border-bottom: none; }
.toast-host { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--raised); color: var(--text);
  border: 1px solid rgba(16, 185, 129, .35); padding: 11px 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  max-width: 400px; font-size: 13px; font-weight: 500; animation: fadeIn .2s cubic-bezier(.16, 1, .3, 1);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.toast.err { border-color: rgba(244, 63, 94, .4); color: var(--critical-ink); }
.toast.err::before { background: var(--critical); box-shadow: 0 0 0 3px rgba(244, 63, 94, .18); }
.modal-back { position: fixed; inset: 0; background: var(--backdrop); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 90; padding: 16px; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: min(640px, 100%); max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.16, 1, .3, 1);
}
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.modal-head h2 { margin: 0; font-size: 15.5px; flex: 1; }
.modal-body { padding: 20px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(600px 400px at 20% 10%, rgba(99, 102, 241, .16), transparent 70%),
              radial-gradient(500px 360px at 85% 90%, rgba(129, 140, 248, .10), transparent 70%), var(--bg);
}
.login .card { width: min(400px, 100%); padding: 30px 28px; box-shadow: var(--shadow-lg); gap: 16px; animation: pop .3s cubic-bezier(.16, 1, .3, 1); }
.login .brand { font-size: 19px; }
.login button.primary { justify-content: center; padding: 10px 14px; }
.qr-wrap { display: flex; justify-content: center; padding: 6px 0; }
.qr { display: block; border-radius: var(--radius-md); box-shadow: 0 0 0 1px var(--border), var(--shadow); }
.confidence { display: inline-flex; align-items: center; gap: 6px; }
.confidence .meter { width: 80px; }
.answer { font-size: 15px; line-height: 1.6; }

@media (max-width: 1100px) {
  .grid.cols-2, .grid.cols-3, .split { grid-template-columns: minmax(0, 1fr); }
  .split > * + * { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 20px; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 95; width: 264px; transform: translateX(-100%); transition: transform .22s cubic-bezier(.16, 1, .3, 1); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { padding: 18px 16px 44px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .menu-btn, .topbar .menu-btn { display: inline-flex; }
  .search-trigger { width: auto; flex: 1; }
  .search-trigger kbd { display: none; }
}
@media (max-width: 520px) {
  .search-trigger span { display: none; }
  .search-trigger { flex: 0 0 auto; width: 36px; height: 36px; padding: 0; justify-content: center; }
  .topbar .divider { display: none; }
  .barlist-row { grid-template-columns: 90px 1fr 34px; }
}

/* ---------- settings: AI integration provider tiles */
.ai-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ai-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; text-align: left;
  border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); font-weight: 400; color: var(--text);
}
.ai-tile:hover { border-color: var(--accent-border); background: var(--surface-2); }
.ai-tile.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--glow); }
.ai-tile-name { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text-strong); }
.ai-tile-help { font-size: 12px; color: var(--text-3); line-height: 1.45; }
a svg { width: 13px; height: 13px; vertical-align: -2px; margin-left: 3px; }

/* ---------- AI assistant: references, agent mode, proposed actions */
.ai-panel { min-height: 0; }
.ai-answer { max-width: 96%; }
.ai-refs { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.ai-ref {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px; font-size: 12.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); min-width: 0;
}
.ai-ref:hover { border-color: var(--accent-border); text-decoration: none; }
.ai-ref svg { width: 14px; height: 14px; color: var(--accent-2); flex-shrink: 0; margin: 0; }
.ai-ref-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-ref .pill { flex-shrink: 0; }
.ai-mode-tag { display: block; font-size: 10.5px; opacity: .75; margin-top: 3px; text-transform: uppercase; letter-spacing: .06em; }
.ai-agent-toggle { display: flex; align-items: center; gap: 10px; font-size: 12.5px; cursor: pointer; padding: 6px 8px; border-radius: 10px; border: 1px dashed var(--border-strong); }
.ai-agent-toggle.on { border-style: solid; border-color: var(--accent-border); background: var(--accent-soft); }
.ai-agent-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ai-switch { width: 30px; height: 17px; border-radius: 999px; background: var(--border-strong); position: relative; flex-shrink: 0; transition: background .15s; }
.ai-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: transform .15s; }
.ai-agent-toggle input:checked + .ai-switch { background: var(--accent); }
.ai-agent-toggle input:checked + .ai-switch::after { transform: translateX(13px); }
.ai-agent-toggle input:focus-visible + .ai-switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.ai-action { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--accent-border); display: flex; flex-direction: column; gap: 6px; }
.ai-action.changes { border-color: rgba(249, 115, 22, .4); }
.ai-action-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-action svg { width: 13px; height: 13px; vertical-align: -2px; }
.ai-script { background: #0b1120; color: #e2e8f0; border-radius: 8px; padding: 8px 10px; font-size: 11.5px; max-height: 180px; overflow: auto; white-space: pre-wrap; margin-top: 6px; }
.ai-action .output { max-height: 220px; font-size: 11.5px; }
.ai-explain { background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; }
.ai-explain ul { margin: 6px 0 0; padding-left: 18px; }
/* Full-screen remote session (remote.js "Full screen" button): the view fills the screen. */
.term-wrap:fullscreen, .desk-wrap:fullscreen { height: 100vh; min-height: 0; border: 0; border-radius: 0; }
/* Maximized dialog (modal opts.maximizable): fills the window; a remote session view inside
   takes all the height left over, and each viewer rescales to it. */
.modal.max { width: calc(100vw - 32px); height: calc(100vh - 32px); max-height: none; }  /* .modal-back pads 16px */
.modal.max .modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.modal.max .remote-panel { flex: 1; min-height: 0; }
.modal.max .remote-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.modal.max .remote-view > .desk-wrap, .modal.max .remote-view > .term-wrap { flex: 1; height: auto; min-height: 300px; }
/* Vulnerability scan: CVE / MITRE ATT&CK badges (FR-1.3), clickable to the public refs. */
.cve-badge { display: inline-block; font-family: var(--mono); font-size: 11px; padding: 1px 7px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
a.cve-badge:hover { border-color: var(--accent-border); color: var(--accent-2); text-decoration: none; }
a.cve-badge.cve { color: var(--accent-2); }
/* Vulnerability findings: cap Location/Title width so long paths or URLs don't stretch the
   row (full value on hover) - keeps every source's rows the same tidy length. */
.vuln-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vuln-cell .small { white-space: normal; }

/* ---------- Emails: classic three-pane mailbox (folders | list | reading) */
.mail-layout { display: grid; grid-template-columns: 210px 340px 1fr; gap: 0; height: calc(100vh - var(--topbar-h) - 150px);
  min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.mail-layout > * { overflow: auto; min-width: 0; }
.mail-folders { border-right: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 3px; background: var(--surface-2); }
.mail-compose { width: 100%; justify-content: center; margin-bottom: 8px; }
.mail-folder { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; }
.mail-folder:hover { background: var(--surface-3); }
.mail-folder.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.mail-folder.add { color: var(--text-3); margin-top: 6px; justify-content: flex-start; gap: 6px; font-size: 12px; }
.mail-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.mail-list-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.mail-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border);
  padding: 10px 12px; cursor: pointer; }
.mail-item:hover { background: var(--surface-2); }
.mail-item.active { background: var(--accent-soft); }
.mail-item.unread .mail-from, .mail-item.unread .mail-subject { font-weight: 700; color: var(--text-strong); }
.mail-item-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-from { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-subject { font-size: 13px; color: var(--text); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-flag { color: var(--warning-ink); }
.mail-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-read { display: flex; flex-direction: column; }
.mail-read-actions { gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.mail-read-actions select { max-width: 150px; }
.mail-head { padding: 14px 16px 6px; }
.mail-head h2 { margin: 0 0 8px; font-size: 17px; }
.mail-meta { display: flex; flex-direction: column; gap: 2px; color: var(--text-2); }
.mail-body { padding: 10px 16px 20px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.5; }
.mail-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-3); }
.mail-empty svg { width: 40px; height: 40px; }
@media (max-width: 1100px) { .mail-layout { grid-template-columns: 170px 1fr; } .mail-read { display: none; } }

/* ---------- Comment composer: formatting toolbar + input + footer (tickets/problems/changes) */
.composer { display: flex; flex-direction: column; gap: 0; }
.fmt-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 5px 6px; border: 1px solid var(--border); border-bottom: 0;
  border-radius: 10px 10px 0 0; background: var(--surface-2); }
.fmt-btn { background: none; border: 0; border-radius: 6px; padding: 4px 8px; font-size: 12.5px; color: var(--text-2); cursor: pointer; line-height: 1.4; }
.fmt-btn:hover { background: var(--surface-3); color: var(--text-strong); }
.composer > textarea { border-radius: 0 0 10px 10px; border-top-left-radius: 0; border-top-right-radius: 0; margin: 0; }
.composer-foot { margin-top: 8px; align-items: center; }
/* Rendered comment bodies */
.rich { white-space: normal; }
.rich p { margin: 0 0 8px; white-space: pre-wrap; }
.rich p:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 4px 0 8px; padding-left: 22px; }
.rich li { margin: 2px 0; }
.rich code { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.rich blockquote { margin: 4px 0; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.rich a { color: var(--accent-2); }
/* Build PDF report: section checklist */
.doc-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; margin-top: 8px; }
/* SLA policy editor: per-priority targets grid */
.sla-targets { border-collapse: collapse; width: 100%; }
.sla-targets th { text-align: left; font-size: 11.5px; color: var(--text-3); font-weight: 600; padding: 4px 8px; }
.sla-targets td { padding: 5px 8px; border-top: 1px solid var(--border); }

/* ---------- Request forms: builder (Settings -> Forms) and portal rendering */
.form-builder { display: grid; grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); gap: 16px; align-items: start; }
.form-preview { position: sticky; top: 12px; }
.form-field-editor { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.form-field-editor.heading { border-style: dashed; }
.form-add { padding-top: 4px; border-top: 1px dashed var(--border); }
.request-form { gap: 16px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.req { color: var(--critical); }
.form-heading h3 { margin: 6px 0 2px; font-size: 14px; color: var(--text-strong); text-transform: none; letter-spacing: 0; }
.form-heading { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.form-choices { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
/* Portal: New request 65 / 35 split, form cards */
.portal-split { display: grid; grid-template-columns: minmax(0, 65fr) minmax(0, 35fr); gap: 16px; align-items: start; }
.form-card { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; color: inherit; }
.form-card:hover { border-color: var(--border-strong); }
.form-card.active { border-color: var(--accent); background: var(--accent-soft); }
.form-card-name { font-weight: 600; color: var(--text-strong); margin-bottom: 2px; }
.form-card .kpi-icon { flex-shrink: 0; }
/* Portal: department cards above New request (a click narrows the request forms) */
.dept-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
/* Portal: My tickets dashboard */
.portal-kpi { text-align: left; cursor: pointer; color: inherit; font: inherit; }
.portal-filters { gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.portal-filters input[type="search"] { flex: 1 1 260px; }
@media (max-width: 900px) { .portal-split, .form-builder { grid-template-columns: 1fr; } .form-preview { position: static; } }
.portal-split > .card + .card { margin-top: 0; }                      /* columns, not a stack */
.portal-kpi { align-items: stretch; justify-content: flex-start; }    /* KPI tiles are buttons here */
.portal-kpi .kpi-top { width: 100%; }
.sortable > .row:first-child { padding-right: 36px; }  /* report table cards: title row */

/* Settings -> Email -> requester email template preview */
.req-mail-preview { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); display: grid; gap: 6px; }
.req-mail-subject { font-weight: 600; }
.req-mail-body { margin: 0; white-space: pre-wrap; font: inherit; font-size: 13px; color: var(--text-2, inherit); }

/* Network discovery: selection column and push-deploy details */
.check-col { width: 34px; }
.deploy-error { max-width: 280px; white-space: normal; margin-top: 4px; }
.deploy-list { margin: 6px 0 0; padding-left: 18px; }

/* Settings -> Security Config */
.sec-job { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 18px; padding: 14px 0; border-top: 1px solid var(--border); }
.sec-job:first-of-type { border-top: 0; }
.sec-job-main h3 { margin: 0 0 4px; }
.sec-job-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; }
.sec-err { color: var(--critical, #f87171); }
.sec-job-side { display: grid; gap: 8px; align-content: start; }
@media (max-width: 720px) { .sec-job { grid-template-columns: 1fr; } }

/* My Account -> notification preferences */
.notif-prefs td.num, .notif-prefs th.num { text-align: center; width: 150px; }
.notif-prefs th .sm { margin-top: 4px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.notif-prefs tr.notif-group td { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); padding-top: 10px; }

/* Software page */
.sw-link, .sw-url { word-break: break-all; }
.sw-review dd { word-break: break-word; }
.sw-device-list { max-height: 320px; overflow: auto; gap: 6px; }
.sw-ai { background: color-mix(in srgb, var(--violet, #8b5cf6) 18%, transparent); color: var(--violet-ink, #c4b5fd); border-color: transparent; }
.movable-head { margin: -6px 0 2px; min-height: 26px; }
/* Emails: list selection */
.mail-list-head input[type=checkbox] { margin-right: 8px; }
.mail-bulk { padding: 6px 10px; gap: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.mail-item { position: relative; padding-left: 34px !important; }
.mail-pick { position: absolute; left: 10px; top: 12px; }
.mail-item.picked { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.mail-item { cursor: pointer; }

/* Ticket Management -> Delete module data */
.danger-zone { border-color: color-mix(in srgb, var(--critical) 45%, var(--border)); }
.purge-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.purge-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.purge-row.disabled { opacity: .6; cursor: default; }
.purge-row input { margin-top: 3px; flex: none; }
.audit-filters input[type=search] { min-width: 260px; flex: 1; }

/* ---------- portal: request sub-items in the nav, "+ New request" pull-down */
.nav a.nav-sub { padding-left: 30px; font-size: 13px; }
.raise-menu { min-width: 280px; }
.raise-menu a { align-items: flex-start; }
.raise-menu a svg { margin-top: 2px; }
.raise-menu strong { color: var(--text-strong); }

/* ---------- ticket: Post Incident Review section (omnirmm.pir) */
.pir-card > summary { cursor: pointer; list-style: none; gap: 10px; }
.pir-card > summary::-webkit-details-marker { display: none; }
.pir-card > summary::before { content: "▸"; color: var(--text-3); transition: transform .15s; }
.pir-card[open] > summary::before { transform: rotate(90deg); }
.pir-section { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.pir-row { flex-wrap: nowrap; gap: 6px; }
.pir-row input[type="datetime-local"] { width: 190px; flex: none; }
.pir-row input[type="date"] { width: 150px; flex: none; }
.pir-row select { width: 130px; flex: none; }
@media (max-width: 720px) { .pir-row { flex-wrap: wrap; } }
.pir-sub { padding-left: 4px; gap: 8px; }
.pir-sub h4 { font-size: 13px; color: var(--text-2); }

/* ---------- searchable dropdown (core.js searchPicker) */
.search-pick { position: relative; }
.search-pick > input { width: 100%; }
.search-pick-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 90; max-height: 260px; overflow: auto;
  background: var(--raised); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px;
}
.search-pick-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; padding: 8px 8px 4px; }
.search-pick-item { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.search-pick-item:hover, .search-pick-item.active { background: var(--surface-3); }
.search-pick-item.chosen > span:first-child { font-weight: 600; color: var(--accent-2); }
.search-pick-empty { padding: 8px; font-size: 12.5px; color: var(--text-3); }
.search-select { display: inline-block; min-width: 170px; vertical-align: middle; }
label.field .search-select, .form-grid .search-select { display: block; width: 100%; }
.search-select > input { padding-right: 26px; cursor: pointer; }
.search-select > input:focus { cursor: text; }
.search-select-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; font-size: 11px; }

/* ---------- desktop notifications (notify.js): the one-time offer and clickable in-app toasts */
.desk-offer { position: fixed; right: 18px; bottom: 18px; z-index: 120; width: min(380px, calc(100vw - 32px)); padding: 14px;
  box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.notif-toast { display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer; font: inherit; max-width: 360px; }
.notif-toast span { font-size: 12.5px; opacity: .85; }
.desk-card { background: var(--surface-2, transparent); }
.toast.notif-toast { pointer-events: auto; border-color: var(--accent-border, var(--border)); }
.toast.notif-toast::before { display: none; }

/* ---------- approvals list filters (console and portal) */
.approval-filters { gap: 8px; align-items: center; }
.approval-filters input[type="search"] { flex: 1 1 260px; min-width: 200px; }
.approval-filters .search-select { min-width: 180px; }
