/* ═══════════════════════════════════════════════════════════════
   HSEFQ Design System — app.css
   ═══════════════════════════════════════════════════════════════ */

/* ── 1. CSS Variables (Light mode) ────────────────────────────── */
:root {
  --accent:          #4376a8;
  --accent-hover:    #3461a0;
  --accent2:         #76b571;
  --accent-gradient: linear-gradient(135deg, #4376a8 0%, #76b571 100%);

  --sidebar-bg:      #ffffff;
  --sidebar-text:    #334155;
  --sidebar-muted:   #64748b;
  --sidebar-hover:   #f1f5f9;
  --sidebar-active:  #f8fafc;
  --topbar-bg:       #ffffff;
  --topbar-border:   #e2e8f0;
  --bg-page:         #f0f4f8;
  --bg-elevated:     #ffffff;
  --footer-bg:       #f8fafc;

  --border:          #e2e8f0;
  --text-muted:      #64748b;
  --text-heading:    #1e293b;
  --text-body:       #334155;

  --font-title:  'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body:   'Segoe UI', system-ui, -apple-system, sans-serif;

  --radius-btn:  8px;
  --radius-card: 12px;

  --mod-safety:      #eab308;
  --mod-fire:        #f43f5e;
  --mod-env:         #10b981;
  --mod-health:      #0ea5e9;
  --mod-quality:     #a855f7;
  --mod-documents:   #475569;
  --mod-compliance:  #14b8a6;
  --mod-contractor:  #f59e0b;
  --mod-chemical:    #14b8a6;
  --mod-equipment:   #94a3b8;
  --mod-hr:          #64748b;
  --mod-training:    #f2ae5c;
  --mod-audit:       #14b8a6;
  --mod-hygiene:     #af4848;
  --mod-ghg:         #76b571;
  --mod-admin:       #475569;
  --mod-capa:        #f59e0b;

  --sidebar-w: 256px;
  --sidebar-mini-w: 64px;
  --topbar-h:  56px;
}

/* ── 2. Dark mode ──────────────────────────────────────────────── */
[data-theme="dark"] {
  --sidebar-bg:    #0f172a;
  --sidebar-text:  #cbd5e1;
  --sidebar-muted: #94a3b8;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: rgba(255,255,255,0.10);
  --topbar-bg:     #1e293b;
  --topbar-border: #334155;
  --bg-page:       #0f172a;
  --bg-elevated:   #1e293b;
  --footer-bg:     #1e293b;
  --border:        #334155;
  --text-muted:    #94a3b8;
  --text-heading:  #f1f5f9;
  --text-body:     #cbd5e1;
  --mod-documents: #f8fafc;
}

/* ── 3. Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--font-body); font-size: 14px; color: var(--text-body); background: var(--bg-page); }

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

/* ── 5. Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 200;
  transition: transform 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand-logo { width: 30px; height: auto; flex-shrink: 0; }

.sidebar-brand-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.sidebar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.52rem 1rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.sidebar-section:hover { background: rgba(255,255,255,0.04); }

.sidebar-section-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.46);
}

.sidebar-section-chevron {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.28);
  transition: transform 0.2s ease;
}

.sidebar-section-chevron.open { transform: rotate(90deg); }

.nav-group-children {
  overflow: hidden;
  transition: max-height 0.28s ease;
  background: rgba(0,0,0,0.18);
}

.nav-link-hsefq {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 1rem 0.4rem 1.25rem;
  font-size: 0.81rem;
  color: rgba(255,255,255,0.68);
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}

.nav-link-hsefq:hover { color: #ffffff; background: rgba(255,255,255,0.08); text-decoration: none; }

.nav-link-hsefq.active {
  color: #ffffff;
  background: rgba(67,118,168,0.38);
  border-right: 3px solid var(--accent);
  font-weight: 500;
}

.sidebar-footer {
  padding: 0.85rem 1rem;
  font-size: 0.67rem;
  color: rgba(255,255,255,0.36);
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: auto;
  flex-shrink: 0;
  line-height: 1.5;
}

/* ── 6. Main area ──────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  overflow: hidden;
}

/* ── 7. Topbar ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 0.55rem;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-btn);
  cursor: pointer;
  position: relative;
  color: var(--text-muted);
  background: transparent;
  border: none;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}

.topbar-btn:hover { background: var(--border); color: var(--text-heading); }

.topbar-title { font-weight: 600; font-size: 0.9rem; color: var(--text-heading); flex: 1; }
.topbar-welcome { font-size: 0.79rem; color: var(--text-muted); }
.divider-v { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }

.notif-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid var(--topbar-bg);
}

.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.67rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  user-select: none;
}

.theme-icon-light { display: block; }
.theme-icon-dark  { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark  { display: block; }

/* ── 8. Page content ───────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 1.5rem;
  background: var(--bg-page);
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── 9. Footer ──────────────────────────────────────────────────── */
.app-footer {
  background: var(--footer-bg);
  border-top: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  font-size: 0.71rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { color: var(--accent); }

/* ── 10. Module icon colors ─────────────────────────────────────── */
.icon-accent     { color: var(--accent); }
.icon-safety     { color: var(--mod-safety); }
.icon-fire       { color: var(--mod-fire); }
.icon-env        { color: var(--mod-env); }
.icon-health     { color: var(--mod-health); }
.icon-quality    { color: var(--mod-quality); }
.icon-capa       { color: var(--mod-capa); }
.icon-documents  { color: var(--mod-documents); }
.icon-compliance { color: var(--mod-compliance); }
.icon-contractor { color: var(--mod-contractor); }
.icon-chemical   { color: var(--mod-chemical); }
.icon-equipment  { color: var(--mod-equipment); }
.icon-hr         { color: var(--mod-hr); }
.icon-training   { color: var(--mod-training); }
.icon-audit      { color: var(--mod-audit); }
.icon-hygiene    { color: var(--mod-hygiene); }
.icon-ghg        { color: var(--mod-ghg); }
.icon-admin      { color: var(--mod-admin); }

/* High-contrast module colors on top-level sidebar groups */
.sidebar-section-label .bi-shield-exclamation { color: var(--mod-safety); }
.sidebar-section-label .bi-heart-pulse        { color: var(--mod-health); }
.sidebar-section-label .bi-tree,
.sidebar-section-label .bi-tree-fill          { color: var(--mod-env); }
.sidebar-section-label .bi-fire               { color: var(--mod-fire); }
.sidebar-section-label .bi-patch-check        { color: var(--mod-quality); }
.sidebar-section-label .bi-clipboard2-check,
.sidebar-section-label .bi-journal-check      { color: var(--mod-audit); }
.sidebar-section-label .bi-folder2-open       { color: var(--mod-documents); }

/* Universal light/dark sidebar contrast */
.sidebar-brand { border-bottom-color: var(--border); }
.sidebar-brand-name { color: var(--sidebar-text); }
.sidebar-brand-sub { color: var(--sidebar-muted); }
.sidebar-section { color: var(--sidebar-muted); }
.sidebar-section:hover { background: var(--sidebar-hover); }
.sidebar-section-label { color: var(--sidebar-muted); }
.sidebar-section-chevron { color: var(--sidebar-muted); }
.nav-group-children { background: transparent; }
.nav-link-hsefq { color: var(--sidebar-text); border-radius: 10px; }
.nav-link-hsefq:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
.nav-link-hsefq.active {
  color: var(--sidebar-text);
  background: var(--sidebar-active);
  border-right: 0;
  box-shadow: inset 0 0 0 1px rgba(148,163,184,0.16);
}
.sidebar-footer { color: var(--sidebar-muted); border-top-color: var(--border); }

/* Desktop hover-to-expand sidebar */
@media (min-width: 768px) {
  .sidebar {
    width: var(--sidebar-mini-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 28px rgba(15,23,42,0.08);
    transition: width 0.3s ease-in-out, background-color 0.2s ease, border-color 0.2s ease;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: var(--sidebar-w);
  }

  .sidebar-brand {
    justify-content: center;
    padding-inline: 0.75rem;
    min-height: 64px;
    border-bottom-color: var(--border);
  }

  .sidebar:hover .sidebar-brand,
  .sidebar:focus-within .sidebar-brand {
    justify-content: flex-start;
    padding-inline: 1rem;
  }

  .sidebar-brand-logo,
  .sidebar-brand svg {
    width: 34px;
    max-width: 34px;
    transition: transform 0.25s ease;
  }

  .sidebar-brand > div {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transform: translateX(-6px);
    transition: opacity 0.2s ease, width 0.25s ease, transform 0.25s ease;
  }

  .sidebar:hover .sidebar-brand > div,
  .sidebar:focus-within .sidebar-brand > div {
    opacity: 1;
    width: 170px;
    transform: translateX(0);
  }

  .sidebar-brand-name { color: var(--sidebar-text); }
  .sidebar-brand-sub  { color: var(--sidebar-muted); }

  .sidebar-section {
    min-height: 44px;
    padding: 0.55rem 0;
    justify-content: center;
    color: var(--sidebar-muted);
    transition: background-color 0.15s ease, padding 0.25s ease;
  }

  .sidebar:hover .sidebar-section,
  .sidebar:focus-within .sidebar-section {
    justify-content: space-between;
    padding: 0.55rem 1rem;
  }

  .sidebar-section:hover {
    background: var(--sidebar-hover);
  }

  .sidebar-section-label {
    width: 24px;
    overflow: hidden;
    white-space: nowrap;
    color: transparent;
    transition: width 0.25s ease, color 0.2s ease, opacity 0.2s ease;
  }

  .sidebar:hover .sidebar-section-label,
  .sidebar:focus-within .sidebar-section-label {
    width: auto;
    color: var(--sidebar-muted);
  }

  .sidebar-section-label i {
    color: inherit;
    font-size: 1.05rem;
    margin-right: 0 !important;
  }

  .sidebar:hover .sidebar-section-label i,
  .sidebar:focus-within .sidebar-section-label i {
    margin-right: 0.35rem !important;
  }

  .sidebar-section-chevron {
    opacity: 0;
    width: 0;
  }

  .sidebar:hover .sidebar-section-chevron,
  .sidebar:focus-within .sidebar-section-chevron {
    opacity: 1;
    width: auto;
    color: var(--sidebar-muted);
  }

  .sidebar:not(:hover):not(:focus-within) .nav-group-children {
    max-height: 0 !important;
  }

  .nav-group-children {
    background: transparent;
  }

  .nav-link-hsefq {
    min-height: 38px;
    margin: 2px 8px;
    padding: 0.45rem 0;
    justify-content: center;
    gap: 0;
    border-radius: 10px;
    color: transparent;
    white-space: nowrap;
    overflow: hidden;
    transition: color 0.18s ease, background 0.12s ease, padding 0.25s ease, justify-content 0.25s ease;
  }

  .sidebar:hover .nav-link-hsefq,
  .sidebar:focus-within .nav-link-hsefq {
    justify-content: flex-start;
    gap: 0.6rem;
    padding: 0.45rem 1rem;
    color: var(--sidebar-text);
  }

  .nav-link-hsefq i,
  .nav-link-hsefq .copilot-icon-sm {
    flex: 0 0 20px;
    min-width: 20px;
    text-align: center;
  }

  .nav-link-hsefq:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover);
  }

  .nav-link-hsefq.active {
    color: var(--sidebar-text);
    background: var(--sidebar-active);
    border-right: 0;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(148,163,184,0.16);
  }

  .sidebar-footer {
    opacity: 0;
    max-height: 0;
    padding: 0;
    overflow: hidden;
    border-top: 0;
    color: var(--sidebar-muted);
    transition: opacity 0.2s ease, max-height 0.25s ease, padding 0.25s ease;
  }

  .sidebar:hover .sidebar-footer,
  .sidebar:focus-within .sidebar-footer {
    opacity: 1;
    max-height: 88px;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
  }
}

/* ── 11. Copilot icon ───────────────────────────────────────────── */
.copilot-icon-sm { display: inline-block; font-size: 0.85em; color: #6366f1; }

/* ── 12. Dashboard tabs ─────────────────────────────────────────── */
.dash-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.dash-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  transition: color 0.12s, background 0.12s;
}

.dash-tab:hover { color: var(--accent); background: rgba(67,118,168,0.06); text-decoration: none; }

.dash-tab.active {
  color: var(--accent);
  background: var(--bg-elevated);
  border-color: var(--border);
  border-bottom-color: var(--bg-elevated);
  font-weight: 600;
}

/* ── 13. Dark mode – Bootstrap overrides ────────────────────────── */
[data-theme="dark"] .card { background: var(--bg-elevated); border-color: var(--border) !important; color: var(--text-body); }
[data-theme="dark"] .card-header { background: rgba(255,255,255,0.04); border-color: var(--border); }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] h1,[data-theme="dark"] h2,[data-theme="dark"] h3,
[data-theme="dark"] h4,[data-theme="dark"] h5,[data-theme="dark"] h6 { color: var(--text-heading); }
[data-theme="dark"] .table { color: var(--text-body); }
[data-theme="dark"] .table th,[data-theme="dark"] .table td { border-color: var(--border); }
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .form-control,[data-theme="dark"] .form-select { background: var(--bg-page); border-color: var(--border); color: var(--text-body); }
[data-theme="dark"] .form-control:focus,[data-theme="dark"] .form-select:focus { background: var(--bg-page); border-color: var(--accent); color: var(--text-body); box-shadow: 0 0 0 3px rgba(67,118,168,0.2); }
[data-theme="dark"] .modal-content { background: var(--bg-elevated); border-color: var(--border); color: var(--text-body); }
[data-theme="dark"] .modal-header,[data-theme="dark"] .modal-footer { border-color: var(--border); }
[data-theme="dark"] .dropdown-menu { background: var(--bg-elevated); border-color: var(--border); }
[data-theme="dark"] .dropdown-item { color: var(--text-body); }
[data-theme="dark"] .dropdown-item:hover { background: rgba(255,255,255,0.06); color: var(--text-heading); }
[data-theme="dark"] .bg-white { background: var(--bg-elevated) !important; }
[data-theme="dark"] .border { border-color: var(--border) !important; }
[data-theme="dark"] .input-group-text { background: var(--bg-page); border-color: var(--border); color: var(--text-muted); }

/* ── 14. Mobile ─────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    height: 100%;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  .main-area { width: 100%; }
  .page-content { padding: 1rem 0.75rem; }
  .topbar { padding: 0 0.75rem; }
  .app-footer { flex-direction: column; gap: 0.25rem; text-align: center; }
}

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

/* ── 16. Utility ────────────────────────────────────────────────── */
.card { border-radius: var(--radius-card) !important; }
.btn { border-radius: var(--radius-btn) !important; }
.shadow-sm { box-shadow: 0 1px 4px rgba(0,0,0,0.08) !important; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ── 17. Notification panel ─────────────────────────────────────────── */
.notif-anchor {
  position: relative;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  z-index: 500;
  display: flex;
  flex-direction: column;
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-panel-header h6 {
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.notif-close-btn {
  width: 26px; height: 26px;
  border: none; background: transparent;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  transition: background 0.12s;
}
.notif-close-btn:hover { background: var(--border); color: var(--text-heading); }
.notif-item {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.1s;
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: rgba(67,118,168,0.06); }
.notif-item.unread { background: rgba(67,118,168,0.05); }
.notif-dot-icon {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 5px;
}
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: 0.79rem; font-weight: 600; color: var(--text-heading); margin-bottom: 2px; }
.notif-item-msg   { font-size: 0.73rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-time  { font-size: 0.67rem; color: var(--text-muted); margin-top: 2px; }
.notif-empty      { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.8rem; }
.notif-footer     { padding: 0.5rem 1rem; border-top: 1px solid var(--border); text-align: center; flex-shrink: 0; }
.notif-footer a   { font-size: 0.75rem; color: var(--accent); text-decoration: none; }
.notif-footer a:hover { text-decoration: underline; }

/* ── 18. Inline CAPA panel ──────────────────────────────────────────── */
.capa-inline-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--bg-elevated);
  overflow: hidden;
}
.capa-inline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: rgba(245,158,11,0.07);
  border-bottom: 1px solid var(--border);
}
.capa-inline-header h6 {
  margin: 0;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--mod-capa);
}
.capa-mini-form {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  background: rgba(245,158,11,0.03);
  margin-bottom: 0.5rem;
}
.capa-mini-form:last-child { margin-bottom: 0; }
.capa-linked-table th { font-size: 0.73rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.capa-linked-table td { font-size: 0.79rem; vertical-align: middle; }

/* ── 19. QHSSE Copilot floating assistant ─────────────────────────────────── */
.qhsse-copilot {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: inherit;
}

.qhsse-copilot-fab {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, #312e81, #a855f7, #14b8a6, #312e81);
  background-size: 280% 280%;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
  animation: qhsse-copilot-border 4s ease infinite;
  cursor: pointer;
}

.qhsse-copilot-fab-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.55rem;
  background: radial-gradient(circle at 30% 25%, #6366f1, #1e1b4b 72%);
}

.qhsse-copilot-panel {
  width: min(420px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 112px));
  margin-bottom: 14px;
  border-radius: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.qhsse-copilot-header {
  padding: 1rem 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, #1e1b4b, #6d28d9, #0f766e);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.qhsse-copilot-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.98rem;
  font-weight: 800;
}

.qhsse-copilot-subtitle {
  font-size: 0.74rem;
  opacity: 0.78;
  margin-top: 0.1rem;
}

.qhsse-copilot-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 10px;
  color: #fff;
  background: rgba(255,255,255,0.12);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.qhsse-copilot-body {
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.qhsse-copilot-message {
  max-width: 88%;
  border-radius: 16px;
  padding: 0.72rem 0.85rem;
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.qhsse-copilot-message.assistant {
  align-self: flex-start;
  color: var(--text-heading);
  background: rgba(67, 118, 168, 0.08);
  border: 1px solid rgba(67, 118, 168, 0.14);
}

.qhsse-copilot-message.user {
  align-self: flex-end;
  color: #fff;
  background: linear-gradient(135deg, #4338ca, #7c3aed);
}

.qhsse-copilot-chips,
.qhsse-copilot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.qhsse-copilot-chip,
.qhsse-copilot-action {
  border: 1px solid rgba(67, 118, 168, 0.2);
  border-radius: 999px;
  padding: 0.42rem 0.65rem;
  color: var(--accent);
  background: rgba(67, 118, 168, 0.06);
  font-size: 0.74rem;
  text-decoration: none;
  cursor: pointer;
}

.qhsse-copilot-chip:hover,
.qhsse-copilot-action:hover {
  color: #fff;
  background: var(--accent);
}

.qhsse-copilot-footer {
  display: flex;
  gap: 0.6rem;
  padding: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.qhsse-copilot-input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 96px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.62rem 0.75rem;
  color: var(--text-heading);
  background: var(--bg-base);
  outline: none;
}

.qhsse-copilot-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(67,118,168,0.13);
}

.qhsse-copilot-send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #4338ca, #14b8a6);
  display: grid;
  place-items: center;
}

.qhsse-copilot-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.qhsse-copilot-thinking {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  min-height: 18px;
}

.qhsse-copilot-thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: qhsse-copilot-dot 1s ease-in-out infinite;
}

.qhsse-copilot-thinking span:nth-child(2) { animation-delay: 0.15s; }
.qhsse-copilot-thinking span:nth-child(3) { animation-delay: 0.3s; }

@keyframes qhsse-copilot-border {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes qhsse-copilot-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 576px) {
  .qhsse-copilot {
    right: 16px;
    bottom: 16px;
  }

  .qhsse-copilot-fab {
    width: 58px;
    height: 58px;
  }
}
