/* ---------- stat cards ---------- */
.ac-stats-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.ac-stat { background: var(--panel-bg); border: 1px solid var(--accent); border-radius: 9px; padding: 11px 13px; display: flex; flex-direction: column; gap: 4px; }
.ac-stat-label { font-size: 10px; color: var(--text-5); }
.ac-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; color: var(--text); }
.ac-stat-delta { font-size: 9.5px; color: var(--accent); }

/* ---------- search card ---------- */
.ac-searchcard { background: var(--panel-bg); border: 1px solid var(--accent); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ac-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ac-chip { font-size: 11.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-input); color: var(--text-4); background: none; }
.ac-chip.active { background: var(--accent-18); color: var(--accent-tint); border-color: var(--accent-50); }
.ac-searchrow { display: flex; gap: 8px; align-items: center; }
.ac-searchinput { flex: 1; background: var(--bg-sunken); border: 1px solid var(--line-input); border-radius: 7px; padding: 9px 12px; font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--text-2); }
.ac-searchinput::placeholder { color: var(--text-6); }
.ac-searchbtn { padding: 9px 18px; border-radius: 7px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 12px; border: none; }
.ac-advanced { font-size: 11px; color: var(--text-5); background: none; border: none; text-align: left; padding: 0; }
.ac-advanced b { color: var(--accent); font-weight: 600; }

/* ---------- result / generic data table ---------- */
.ac-resultpanel { background: var(--panel-bg); border: 1px solid var(--accent); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.ac-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-toolbar); flex-wrap: wrap; gap: 8px; }
.ac-toolbar-title { font-size: 12.5px; font-weight: 700; color: var(--text); }
.ac-toolbar-title span { font-family: 'JetBrains Mono', monospace; font-weight: 400; color: var(--text-5); margin-left: 8px; font-variant-numeric: tabular-nums; }
.ac-toolbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.ac-toolbtn { display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 8px; border-radius: 8px; border: 1px solid var(--line-input); background: none; color: inherit; text-decoration: none; }
.ac-toolbtn:hover { border-color: var(--accent-60); }
.ac-toolbtn-icon { width: 24px; height: 24px; border-radius: 6px; background: var(--accent-14); display: flex; align-items: center; justify-content: center; }
.ac-toolbtn-label { font-size: 11px; font-weight: 600; color: var(--text-2); }

.ac-tablescroll { overflow-x: auto; }
.ac-thead, .ac-row { display: grid; padding: 10px 18px; gap: 8px; }
.ac-thead { font-size: 10px; font-weight: 700; color: var(--text-5); text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--line-soft); }
.ac-row { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text-2); border-bottom: 1px solid var(--line-soft); width: 100%; background: none; border-left: none; border-right: none; border-top: none; text-align: left; }
.ac-row:hover { background: var(--bg-hover); }
.ac-row.selected { background: var(--accent-10); }
.ac-row .dim { color: var(--text-5); }
.ac-row > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-tablefoot { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; font-size: 10.5px; color: var(--text-5); }
.ac-pagebtns { display: flex; gap: 6px; }
.ac-pagebtn { padding: 4px 9px; border-radius: 6px; border: 1px solid var(--line-input); background: none; color: inherit; font-size: inherit; }
.ac-pagebtn:disabled { opacity: 0.4; cursor: default; }
.ac-pagebtn.next { background: var(--accent); color: var(--on-accent); font-weight: 700; border: none; }
.ac-empty { padding: 28px 18px; text-align: center; font-size: 12px; color: var(--text-5); }

.ac-actioncell { display: flex; gap: 6px; }
.ac-iconaction { width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--line-input); background: none; color: var(--text-4); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ac-iconaction:hover { color: var(--text); border-color: var(--accent-60); }
.ac-iconaction.danger:hover { color: var(--danger); border-color: var(--danger-border); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-border); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-neutral { background: var(--bg-hover); color: var(--text-4); border: 1px solid var(--line-input); }

/* ---------- drawers (fixed, slide in) ---------- */
.ac-drawer {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 500px; max-width: 100vw;
  background: var(--drawer-bg); border-left: 1px solid var(--accent);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 16px;
  transform: translateX(100%); transition: transform 0.18s ease-out, background-color 0.2s ease, border-color 0.2s ease; z-index: 220;
  box-shadow: var(--shadow-drawer); overflow-y: auto;
}
.ac-drawer.open { transform: translateX(0); }
.ac-drawer-head { display: flex; align-items: center; justify-content: space-between; }
.ac-insp-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; color: var(--text-6); text-transform: uppercase; }
.ac-drawer-close { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line-input); background: none; display: flex; align-items: center; justify-content: center; color: var(--text-3); flex-shrink: 0; }
.ac-field { display: flex; flex-direction: column; gap: 3px; }
.ac-field-label { font-size: 10px; color: var(--text-6); }
.ac-field-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text); word-break: break-all; }
.ac-related { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ac-related-item { font-size: 11.5px; color: var(--text-4); padding: 8px 10px; background: var(--bg-sunken); border-radius: 6px; border: 1px solid var(--line-soft); }
.ac-insp-actions { display: flex; gap: 8px; margin-top: auto; }
.ac-insp-btn { flex: 1; text-align: center; padding: 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line-input); color: var(--text-2); background: none; }
.ac-insp-btn.primary { background: var(--accent); color: var(--on-accent); border: none; }

.settings-section { display: flex; flex-direction: column; gap: 4px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.settings-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
/* Server status has its own heavier <hr class="settings-divider"> right
   after it (see serverStatus.js) instead of the standard thin section
   border, so it doesn't end up with two divider lines back to back. */
#srv-status-section { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.settings-divider { border: none; border-top: 1px solid var(--line); margin: 14px 0 16px; }
.settings-label { margin-bottom: 8px; }
.theme-toggle { display: flex; gap: 6px; }
.theme-opt { flex: 1; padding: 8px; border-radius: 7px; border: 1px solid var(--line-input); background: none; color: var(--text-3); font-size: 12px; font-weight: 600; }
.theme-opt.active { background: var(--accent-18); border-color: var(--accent-50); color: var(--accent-tint); }
.theme-opt:disabled { opacity: 0.45; cursor: not-allowed; }
.theme-preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-preset-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 8px; border: 1px solid var(--line-input); background: none; color: var(--text-3); font-size: 9.5px; font-weight: 600; text-align: center; line-height: 1.3; }
.theme-preset-btn:hover { border-color: var(--accent-60); }
.theme-preset-btn.active { border-color: var(--accent); background: var(--accent-14); color: var(--accent-tint); }
.theme-preset-swatch { width: 26px; height: 26px; border-radius: 50%; border: 1px solid oklch(0% 0 0 / 0.25); display: flex; align-items: center; justify-content: center; color: var(--text-4); font-size: 11px; flex-shrink: 0; }
.accent-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.accent-swatch { width: 26px; height: 26px; border-radius: 50%; border: none; padding: 0; outline: 2px solid transparent; outline-offset: 2px; }
.accent-swatch.active { outline-color: var(--text); }
.accent-custom { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 11.5px; color: var(--text-4); }
.accent-custom input[type="color"] { width: 36px; height: 26px; border: 1px solid var(--line-input); border-radius: 6px; background: none; padding: 2px; cursor: pointer; }
.settings-hint { font-size: 10.5px; color: var(--text-6); line-height: 1.5; }
.text-size-row { display: flex; align-items: center; gap: 10px; }
.text-size-value { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-4); width: 34px; flex-shrink: 0; text-align: right; }
.text-size-slider {
  flex: 1; -webkit-appearance: none; appearance: none; height: 4px; border-radius: 999px;
  background: var(--line-input); outline: none;
}
.text-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--panel-bg-2);
  box-shadow: 0 0 0 1px var(--accent-50);
}
.text-size-slider::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent); cursor: pointer;
  border: 2px solid var(--panel-bg-2); box-shadow: 0 0 0 1px var(--accent-50);
}

/* ---------- server status (settings drawer section, injected by serverStatus.js) ---------- */
.srv-status-grid { display: flex; justify-content: space-between; gap: 6px; }
.srv-ring { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.srv-ring-visual { position: relative; width: 62px; height: 62px; flex-shrink: 0; }
.srv-ring-visual svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.srv-ring-track { fill: none; stroke: var(--line-soft); stroke-width: 6; }
.srv-ring-bar { fill: none; stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.srv-ring-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: var(--text); }
.srv-ring-label { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-5); text-align: center; }
.srv-spark-label { font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-5); text-align: center; margin: 16px 0 4px; }
.srv-spark-wrap { background: var(--bg-sunken); border: 1px solid var(--line-soft); border-radius: 8px; padding: 6px 4px; }
.srv-spark { width: 100%; height: 52px; display: block; }
.srv-spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.srv-stats-row { display: flex; justify-content: space-between; text-align: center; margin-top: 12px; }
.srv-stat { flex: 1; }
.srv-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 700; }
.srv-stat-label { font-size: 10px; color: var(--text-5); margin-top: 2px; }
/* Live indicator beside the panel title, and the one-line detail under it. */
.srv-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; vertical-align: middle; background: var(--line-input); }
.srv-dot[data-state="live"] { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.srv-dot[data-state="down"] { background: var(--text-6); }
.srv-verdict { margin-top: 12px; text-align: center; font-size: 10.5px; font-weight: 700; color: var(--text-5); }
.srv-verdict[data-state="ok"] { color: var(--accent); }
.srv-verdict[data-state="busy"] { color: var(--orange); }
.srv-verdict[data-state="heavy"] { color: var(--red); }

/* ---------- toast notifications ---------- */
/* Scoped under .toast-stack so these win over Bootstrap's own .toast rules
   (loaded via the legacy stack on some pages), which otherwise force a
   vertical block layout and override the flex row. */
.toast-stack { position: fixed; top: calc(var(--topbar-h, 56px) + 10px); right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; width: 340px; max-width: calc(100vw - 32px); pointer-events: none; }
.toast-stack .toast {
  position: relative; overflow: hidden; pointer-events: auto; box-sizing: border-box; width: 100%;
  background: color-mix(in srgb, var(--bg-hover) 90%, var(--tone, var(--accent)));
  border: 1px solid var(--line); border-left: 3px solid var(--tone, var(--accent));
  border-radius: 10px; padding: 11px 13px 13px 13px; box-shadow: var(--shadow-win);
  font-size: 12.5px; line-height: 1.45; color: var(--text-2);
  display: flex !important; flex-direction: row; align-items: flex-start; gap: 10px;
  opacity: 0; transform: translateX(14px) scale(0.98); float: none; min-height: 0;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.22,1,0.36,1);
}
.toast-stack .toast.toast-in { opacity: 1; transform: translateX(0) scale(1); }
.toast-stack .toast.toast-out { opacity: 0; transform: translateX(14px) scale(0.98); }
.toast-stack .toast-icon { flex: 0 0 16px; width: 16px; height: 16px; margin-top: 1px; color: var(--tone, var(--accent)); display: inline-flex; align-items: center; justify-content: center; }
.toast-stack .toast-icon svg { display: block; width: 16px; height: 16px; }
.toast-stack .toast-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast-stack .toast-title { font-size: 12.5px; font-weight: 700; color: var(--text); letter-spacing: 0.01em; }
.toast-stack .toast-msg { color: var(--text-3); overflow-wrap: anywhere; }
.toast-stack .toast-msg strong { color: var(--text-2); }
.toast-stack .toast-close { flex: 0 0 18px; width: 18px; height: 18px; border: 0; background: none; padding: 0; border-radius: 5px; color: var(--text-5); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin-top: 0; transition: background-color .12s, color .12s; }
.toast-stack .toast-close svg { display: block; width: 13px; height: 13px; }
.toast-stack .toast-close:hover { background: var(--bg-hover); color: var(--text-2); }
/* countdown bar hugging the bottom edge */
.toast-stack .toast-timer { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; transform-origin: left; background: var(--tone, var(--accent)); opacity: 0.6; animation-name: toast-countdown; animation-timing-function: linear; animation-fill-mode: forwards; }
.toast-stack .toast.paused .toast-timer { animation-play-state: paused; }
@keyframes toast-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
/* per-type tone drives edge, icon and timer via one variable */
.toast-stack .toast-info { --tone: var(--accent); }
.toast-stack .toast-success { --tone: var(--ok-text); }
.toast-stack .toast-warning { --tone: var(--warn); }
.toast-stack .toast-error { --tone: var(--danger); }
@media (prefers-reduced-motion: reduce) {
  .toast-stack .toast { transition: opacity 0.2s ease; transform: none; }
  .toast-stack .toast.toast-in, .toast-stack .toast.toast-out { transform: none; }
  .toast-stack .toast-timer { animation: none; display: none; }
}

/* ---------- modal ---------- */
/* Above the draggable windows (#canvas_box and friends sit at 8999) and the
   tooltips they carry (9999). At 400 a confirmation opened *behind* the canvas
   window, which looked like the button had done nothing. A modal is by
   definition the topmost thing on screen. */
.modal-root { position: fixed; inset: 0; z-index: 10050; display: none; }
.modal-root.open { display: block; }
.modal-backdrop { position: absolute; inset: 0; z-index: 0; background: oklch(0% 0 0 / 0.5); opacity: 0; animation: modalFade 0.15s ease forwards; }
/* z-index needed: the backdrop is absolutely positioned over the whole root, so
   without it the card is painted under the backdrop and cannot be clicked. */
.modal-card { position: relative; z-index: 1; max-width: 420px; margin: 10vh auto 0; background: var(--panel-bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-win); display: flex; flex-direction: column; transform: translateY(10px); opacity: 0; animation: modalIn 0.18s ease forwards; }
@keyframes modalFade { to { opacity: 1; } }
@keyframes modalIn { to { opacity: 1; transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-title { font-size: 14px; font-weight: 700; }
.modal-close { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line-input); background: none; color: var(--text-3); display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 16px 18px; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 18px; }
.modal-btn { padding: 8px 16px; border-radius: 7px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-input); background: none; color: var(--text-2); }
.modal-btn-primary { background: var(--accent); color: var(--on-accent); border: none; }
.modal-btn-danger { background: var(--danger); color: white; border: none; }
.modal-btn-ghost { background: none; border: 1px solid transparent; color: var(--text-4); }

/* ---------- misc shared: avatars, timeline, tabs, switches, pagination ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: white; flex-shrink: 0; }
.avatar-sm { width: 24px; height: 24px; font-size: 9.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 17px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--panel-bg); margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); }
.tab-btn { padding: 9px 14px; font-size: 12.5px; font-weight: 600; color: var(--text-5); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text-2); }
.tab-btn.active { color: var(--accent-tint); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track { position: absolute; inset: 0; background: var(--line-input); border-radius: 999px; transition: background 0.15s ease; cursor: pointer; }
.switch-track::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: transform 0.15s ease; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }

.progress-thin { height: 6px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.progress-thin .bar { height: 100%; border-radius: 999px; background: var(--accent); }

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 5px; top: 22px; bottom: 0; width: 1px; background: var(--line-soft); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); margin-top: 4px; flex-shrink: 0; box-shadow: 0 0 0 3px var(--accent-14); }
.timeline-body { flex: 1; }
.timeline-title { font-size: 12.5px; color: var(--text-2); }
.timeline-time { font-size: 10.5px; color: var(--text-6); margin-top: 2px; }

.pagination { display: flex; gap: 4px; align-items: center; }
.page-num { min-width: 26px; height: 26px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-input); background: none; color: var(--text-3); font-size: 11.5px; }
.page-num.active { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 700; }

.alert { display: flex; gap: 10px; padding: 11px 14px; border-radius: 8px; font-size: 12.5px; line-height: 1.5; }
.alert[hidden] { display: none !important; }
.alert i { margin-top: 1px; }
.alert-info { background: var(--blue-bg); color: var(--blue); }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 20px; text-align: center; color: var(--text-5); }
.empty-state i { font-size: 28px; color: var(--text-6); }
.empty-state-title { font-size: 13px; font-weight: 700; color: var(--text-3); }
.empty-state-text { font-size: 11.5px; max-width: 320px; }

/* ---------- floating chat widget (global chrome, every shelled page) ---------- */
.chatw { position: fixed; right: 20px; bottom: 20px; z-index: 480; }
.chatw-fab { position: relative; width: 56px; height: 56px; border-radius: 50%; border: none; flex-shrink: 0; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-win); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.chatw-fab:hover { filter: brightness(1.08); }
.chatw-fab-badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: white; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }

.chatw-panel {
  position: fixed; right: 20px; bottom: 88px; width: 340px; height: 460px;
  max-height: calc(100vh - var(--topbar-h) - 108px);
  background: var(--panel-bg-2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-menu); display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(0.98); pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease, background-color 0.2s ease, border-color 0.2s ease;
}
.chatw-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.chatw-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); background: var(--bg-toolbar); flex-shrink: 0; }
.chatw-head-title { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.chatw-head-title i { color: var(--accent); }
.chatw-head-actions { display: flex; gap: 4px; }
.chatw-head-btn { width: 24px; height: 24px; border-radius: 6px; border: none; background: none; color: var(--text-4); display: flex; align-items: center; justify-content: center; }
.chatw-head-btn:hover { background: var(--bg-hover); color: var(--text); }

.chatw-list { flex: 1; overflow-y: auto; }
.chatw-item { display: flex; gap: 10px; width: 100%; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); align-items: center; background: none; border-left: none; border-right: none; border-top: none; text-align: left; }
.chatw-item:hover { background: var(--bg-hover); }
.chatw-item-body { flex: 1; min-width: 0; }
.chatw-item-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.chatw-item-name { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.chatw-item-preview { font-size: 11px; color: var(--text-5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chatw-thread, .chatw-newchat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chatw-thread-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0; }
.chatw-back { width: 24px; height: 24px; border-radius: 6px; border: none; background: none; color: var(--text-4); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chatw-back:hover { background: var(--bg-hover); color: var(--text); }
.chatw-thread-name { font-size: 12.5px; font-weight: 700; color: var(--text); }
.chatw-messages { flex: 1; padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chatw-msg { max-width: 78%; padding: 8px 11px; border-radius: 13px; font-size: 12px; line-height: 1.4; }
.chatw-msg.them { align-self: flex-start; background: var(--bg-sunken); color: var(--text-2); border-bottom-left-radius: 4px; }
.chatw-msg.me { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.chatw-msg-time { font-size: 9px; opacity: 0.7; margin-top: 3px; }
.chatw-composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line-soft); flex-shrink: 0; }
.chatw-composer input { flex: 1; }
.chatw-composer button { flex-shrink: 0; width: 36px; padding: 0; display: flex; align-items: center; justify-content: center; }
.chatw-newsearch { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0; }

/* .chatw-thread/-newchat set `display: flex` directly for their own layout,
   which otherwise beats the UA [hidden]{display:none} rule (author origin
   always wins over user-agent origin, regardless of specificity) — same
   issue already noted on .win[hidden] in windows.css. .chatw-list is covered
   here too defensively, so toggling `hidden` between the three panel views
   (list/thread/new-chat) reliably shows exactly one at a time. */
.chatw-list[hidden], .chatw-thread[hidden], .chatw-newchat[hidden] { display: none !important; }

@media (max-width: 480px) {
  .chatw { right: 12px; bottom: 12px; }
  .chatw-panel { right: 12px; left: 12px; width: auto; bottom: 78px; height: calc(100vh - var(--topbar-h) - 96px); }
}

/* ---------- stats carousel (main/banner/count.html, shared by public + app shells) ---------- */
.ld-carousel-panel { position: relative; margin-bottom: 18px; }
.ld-carousel .swiper { padding: 4px 2px 26px; }
.ld-carousel-pause {
  position: absolute; top: -2px; right: 0; z-index: 5; width: 26px; height: 26px;
  border-radius: 7px; border: 1px solid var(--line-input); background: var(--panel-bg);
  color: var(--text-4); display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.ld-carousel-pause:hover { color: var(--text); border-color: var(--accent-60); }
.ld-stat { background: var(--panel-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; height: 100%; box-sizing: border-box; }
.ld-stat-label { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: 0.02em; }
.ld-stat-label i { color: var(--accent); font-size: 12px; flex-shrink: 0; }
.ld-stat-value { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-stat-delta { font-size: 10.5px; color: var(--text-5); display: flex; align-items: center; gap: 5px; }
.ld-stat-delta i { color: var(--ok-text); font-size: 10px; flex-shrink: 0; }
/* What the search figures leave out, so a 0 reads as 'no customer activity'
   rather than as a broken query. */
.ld-stat-note { font-size: 10px; color: var(--text-6); font-style: italic; }
.ld-carousel-pagination.swiper-pagination { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; }
.ld-carousel-pagination .swiper-pagination-bullet { background: var(--line-input); opacity: 1; }
.ld-carousel-pagination .swiper-pagination-bullet-active { background: var(--accent); }

/* ---------- profile header ---------- */
.profile-cover { height: 130px; border-radius: 10px 10px 0 0; background: linear-gradient(120deg, var(--accent-22), var(--purple-bg) 60%, var(--blue-bg)); position: relative; }
.profile-header { display: flex; align-items: flex-end; gap: 16px; padding: 0 20px 16px; margin-top: -34px; }
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar-wrap .avatar-lg { border: 4px solid var(--panel-bg); background-size: cover; background-position: center; font-size: 22px; }
.profile-avatar-upload-btn { position: absolute; bottom: 0; right: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); border: 2px solid var(--panel-bg); display: flex; align-items: center; justify-content: center; font-size: 9px; cursor: pointer; }
.profile-header-info { flex: 1; padding-bottom: 4px; }
.profile-name { font-size: 16px; font-weight: 700; }
.profile-role { font-size: 11.5px; color: var(--text-5); margin-top: 2px; }

/* ---------- search-term highlight (jquery.highlight / DataTables searchHighlight) ----------
   The searchHighlight plugin's CDN stylesheet paints `table.dataTable span.highlight`
   pale yellow (#FFFF88). On the dark theme that left light text on yellow (about
   1.2:1 contrast outside the results panel, 1.6:1 inside). Themed instead: the
   theme's own text colour on a translucent accent tint, with an accent underline
   so matches still stand out. The extra `html body` makes this win over the
   plugin rule whatever order the stylesheets load in. No padding or margin, so a
   highlighted row keeps its height. */
html body span.highlight,
html body table.dataTable span.highlight {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: 3px;
  padding: 0;
  margin: 0;
  line-height: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}


/* ==========================================================================
   Select boxes — a square radio
   ==========================================================================
   One indicator for every native checkbox in the app: an outlined square with
   a filled square inside it, rather than the browser's tick. A solid block
   reads as "a coloured square is here"; the inset fill reads as "this one is
   chosen", the way a radio does.

   Until now these were native checkboxes with nothing but `accent-color`, so
   each platform drew its own tick. `appearance: none` is what makes the
   indicator ours to draw -- there was no `appearance: none` on any checkbox in
   the project before this.

   Scoped to `input[type="checkbox"]` and deliberately NOT applied to the
   toggle switches (.switch/.slider, Switchery), which hide their input and
   draw a pill: those are a different control and are left alone.

   Radios get the same treatment with a round indicator so the two stay
   visually related and still read as single-choice. */
input[type="checkbox"]:not(.switch input):not(.js-switch):not(.flat),
input[type="radio"]:not(.js-switch) {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin: 0;
  border: 1.5px solid var(--line-input);
  border-radius: 3px;
  background: var(--bg-sunken);
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
input[type="radio"]:not(.js-switch) { border-radius: 50%; }

input[type="checkbox"]:not(.switch input):not(.js-switch):not(.flat)::after,
input[type="radio"]:not(.js-switch)::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background-color .12s;
}
input[type="radio"]:not(.js-switch)::after { border-radius: 50%; }

input[type="checkbox"]:not(.switch input):not(.js-switch):not(.flat):checked,
input[type="radio"]:not(.js-switch):checked { border-color: var(--accent); }
input[type="checkbox"]:not(.switch input):not(.js-switch):not(.flat):checked::after,
input[type="radio"]:not(.js-switch):checked::after { background: var(--accent); }

input[type="checkbox"]:not(.switch input):not(.js-switch):not(.flat):focus-visible,
input[type="radio"]:not(.js-switch):focus-visible {
  outline: 2px solid var(--accent-50);
  outline-offset: 1px;
}
input[type="checkbox"]:not(.switch input):not(.js-switch):not(.flat):disabled,
input[type="radio"]:not(.js-switch):disabled { opacity: .45; cursor: not-allowed; }
input[type="checkbox"]:not(.switch input):not(.js-switch):not(.flat):indeterminate::after {
  inset: 5px 2px;
  background: var(--accent);
}
