/* booknip Knowledge Hub – theme on top of Bootstrap 5.3. Colours follow the original React/Tailwind design. */
:root {
  --ms-blue: #0078d4;
  --ms-blue-dark: #106ebe;
  --kb-bg: #f8f9fa;
  --sidebar-w: 272px;
  --sidebar-w-collapsed: 64px;
  --bs-body-font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Arabic", "Noto Sans Devanagari", sans-serif;
  --bs-body-color: #111827;
  --bs-border-color: #e5e7eb;
  --bs-border-radius: .5rem;
}
html[lang="ar"] { --bs-body-font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Arial, sans-serif; }
html[lang="hi"] { --bs-body-font-family: "Nirmala UI", "Noto Sans Devanagari", "Mangal", ui-sans-serif, system-ui, sans-serif; }
body { background: var(--kb-bg); font-family: var(--kb-font, var(--bs-body-font-family)); -webkit-font-smoothing: antialiased; }

/* ---------- icons ---------- */
.lucide-icon, svg.lucide { width: 1.25rem; height: 1.25rem; flex-shrink: 0; vertical-align: -0.2em; }
.icon-2 { width: .5rem !important; height: .5rem !important; }
.icon-3 { width: .75rem !important; height: .75rem !important; }
.icon-4 { width: 1rem !important; height: 1rem !important; }
.icon-5 { width: 1.25rem !important; height: 1.25rem !important; }
.icon-6 { width: 1.5rem !important; height: 1.5rem !important; }
.icon-8 { width: 2rem !important; height: 2rem !important; }
.icon-10 { width: 2.5rem !important; height: 2.5rem !important; }
.icon-12 { width: 3rem !important; height: 3rem !important; }
.icon-16 { width: 4rem !important; height: 4rem !important; }
.fill-current { fill: currentColor; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- colour utilities (Tailwind palette names used by the original) ---------- */
.text-ms-blue { color: var(--kb-link) !important; } .bg-ms-blue { background: var(--ms-blue) !important; color: #fff; }
.text-ms-red { color: #a80000 !important; } .text-ms-green { color: #107c10 !important; } .text-ms-orange { color: #d83b01 !important; }
.bg-ms-blue-10 { background: color-mix(in srgb, var(--ms-blue) 10%, transparent) !important; }
.text-gray-400 { color: var(--kb-t400) !important; } .text-gray-500 { color: var(--kb-t500) !important; } .text-gray-600 { color: var(--kb-t600) !important; }
.text-gray-700 { color: var(--kb-t700) !important; } .text-gray-800 { color: var(--kb-t800) !important; } .text-gray-900 { color: var(--kb-t900) !important; }
.bg-gray-50 { background: var(--kb-surface-2) !important; } .bg-gray-100 { background: var(--kb-surface-2) !important; } .bg-gray-200 { background: var(--kb-surface-3) !important; }
.border-gray-200 { border-color: var(--bs-border-color) !important; }
.bg-blue-50 { background: #eff6ff !important; } .bg-blue-100 { background: #dbeafe !important; } .text-blue-600 { color: #2563eb !important; } .text-blue-700 { color: #1d4ed8 !important; } .text-blue-800 { color: #1e40af !important; } .text-blue-900 { color: #1e3a8a !important; } .border-blue-100 { border-color: #dbeafe !important; } .border-blue-200 { border-color: #bfdbfe !important; } .bg-blue-500 { background: #3b82f6 !important; } .bg-blue-200 { background: #bfdbfe !important; }
.bg-indigo-50 { background: #eef2ff !important; } .bg-indigo-100 { background: #e0e7ff !important; } .text-indigo-600 { color: #4f46e5 !important; } .text-indigo-700 { color: #4338ca !important; } .text-indigo-800 { color: #3730a3 !important; } .border-indigo-100 { border-color: #e0e7ff !important; } .border-indigo-200 { border-color: #c7d2fe !important; } .bg-indigo-500 { background: #6366f1 !important; }
.bg-purple-50 { background: #faf5ff !important; } .bg-purple-100 { background: #f3e8ff !important; } .text-purple-600 { color: #9333ea !important; } .text-purple-700 { color: #7e22ce !important; } .text-purple-800 { color: #6b21a8 !important; } .border-purple-100 { border-color: #f3e8ff !important; } .border-purple-200 { border-color: #e9d5ff !important; } .bg-purple-500 { background: #a855f7 !important; }
.bg-violet-50 { background: #f5f3ff !important; } .bg-violet-100 { background: #ede9fe !important; } .text-violet-600 { color: #7c3aed !important; } .border-violet-100 { border-color: #ede9fe !important; }
.bg-green-50 { background: #f0fdf4 !important; } .bg-green-100 { background: #dcfce7 !important; } .text-green-500 { color: #22c55e !important; } .text-green-600 { color: #16a34a !important; } .text-green-700 { color: #15803d !important; } .text-green-800 { color: #166534 !important; } .border-green-100 { border-color: #dcfce7 !important; } .border-green-200 { border-color: #bbf7d0 !important; } .bg-green-500 { background: #22c55e !important; }
.bg-emerald-50 { background: #ecfdf5 !important; } .bg-emerald-100 { background: #d1fae5 !important; } .text-emerald-600 { color: #059669 !important; } .text-emerald-700 { color: #047857 !important; }
.bg-teal-50 { background: #f0fdfa !important; } .bg-teal-100 { background: #ccfbf1 !important; } .bg-teal-200 { background: #99f6e4 !important; } .text-teal-600 { color: #0d9488 !important; } .text-teal-700 { color: #0f766e !important; } .border-teal-100 { border-color: #ccfbf1 !important; } .bg-teal-500 { background: #14b8a6 !important; }
.bg-cyan-50 { background: #ecfeff !important; } .bg-cyan-100 { background: #cffafe !important; } .text-cyan-600 { color: #0891b2 !important; } .border-cyan-100 { border-color: #cffafe !important; }
.bg-amber-50 { background: #fffbeb !important; } .bg-amber-100 { background: #fef3c7 !important; } .text-amber-500 { color: #f59e0b !important; } .text-amber-600 { color: #d97706 !important; } .text-amber-700 { color: #b45309 !important; } .text-amber-800 { color: #92400e !important; } .text-amber-900 { color: #78350f !important; } .border-amber-100 { border-color: #fef3c7 !important; } .border-amber-200 { border-color: #fde68a !important; }
.bg-yellow-50 { background: #fefce8 !important; } .bg-yellow-100 { background: #fef9c3 !important; } .text-yellow-500 { color: #eab308 !important; } .text-yellow-600 { color: #ca8a04 !important; } .text-yellow-700 { color: #a16207 !important; } .text-yellow-800 { color: #854d0e !important; } .bg-yellow-500 { background: #eab308 !important; }
.bg-orange-50 { background: #fff7ed !important; } .bg-orange-100 { background: #ffedd5 !important; } .text-orange-500 { color: #f97316 !important; } .text-orange-600 { color: #ea580c !important; } .text-orange-700 { color: #c2410c !important; } .text-orange-800 { color: #9a3412 !important; }
.bg-red-50 { background: #fef2f2 !important; } .bg-red-100 { background: #fee2e2 !important; } .text-red-500 { color: #ef4444 !important; } .text-red-600 { color: #dc2626 !important; } .text-red-700 { color: #b91c1c !important; } .text-red-800 { color: #991b1b !important; } .border-red-100 { border-color: #fee2e2 !important; } .border-red-200 { border-color: #fecaca !important; } .bg-red-500 { background: #ef4444 !important; } .bg-red-600 { background: #dc2626 !important; }
.bg-pink-50 { background: #fdf2f8 !important; } .bg-pink-100 { background: #fce7f3 !important; } .text-pink-600 { color: #db2777 !important; } .text-pink-700 { color: #be185d !important; } .text-pink-800 { color: #9d174d !important; } .bg-pink-500 { background: #ec4899 !important; }
.bg-slate-50 { background: #f8fafc !important; } .bg-slate-100 { background: #f1f5f9 !important; } .text-slate-600 { color: #475569 !important; } .text-slate-700 { color: #334155 !important; } .bg-slate-800 { background: #1e293b !important; } .bg-slate-900 { background: #0f172a !important; }

.bg-grad-blue { background: linear-gradient(to right, #3b82f6, #4f46e5) !important; color: #fff; }
.bg-grad-violet { background: linear-gradient(to right, #8b5cf6, #9333ea) !important; color: #fff; }
.bg-grad-ms-soft { background: linear-gradient(to right, color-mix(in srgb, var(--ms-blue) 10%, transparent), color-mix(in srgb, var(--ms-blue-dark) 10%, transparent)) !important; }
.bg-grad-blue-soft { background: linear-gradient(to right, #eff6ff, #eef2ff) !important; }
.bg-grad-purple-soft { background: linear-gradient(to right, #faf5ff, #fdf2f8) !important; }
.bg-grad-kb { background: linear-gradient(135deg, var(--ms-blue), color-mix(in srgb, var(--kb-accent) 70%, var(--ms-blue))) !important; color: var(--kb-on-primary); }
.text-white-80 { color: rgba(255,255,255,.8) !important; } .text-white-90 { color: rgba(255,255,255,.9) !important; }

/* ---------- typography sizes from Tailwind ---------- */
.text-xs { font-size: .75rem !important; line-height: 1rem; } .text-sm { font-size: .875rem !important; line-height: 1.25rem; }
.text-base { font-size: 1rem !important; } .text-lg { font-size: 1.125rem !important; } .text-xl { font-size: 1.25rem !important; }
.text-2xl { font-size: 1.5rem !important; } .text-3xl { font-size: 1.875rem !important; } .text-4xl { font-size: 2.25rem !important; }
.fw-medium { font-weight: 500 !important; } .fw-semibold { font-weight: 600 !important; } .fw-light { font-weight: 300 !important; }
.lh-tight { line-height: 1.25 !important; }
.cursor-pointer { cursor: pointer; }
.min-w-0 { min-width: 0; }
.max-w-3xl { max-width: 48rem; } .max-w-5xl { max-width: 64rem; } .max-w-md { max-width: 28rem; } .max-w-lg { max-width: 32rem; }
.ws-pre-wrap { white-space: pre-wrap; }
.rounded-lg-kb { border-radius: .5rem !important; } .rounded-xl-kb { border-radius: .75rem !important; }

/* ---------- components ---------- */
.btn-ms { background: var(--ms-blue); border-color: var(--ms-blue); color: var(--kb-on-primary); }
.btn-ms:hover, .btn-ms:focus { background: var(--ms-blue-dark); border-color: var(--ms-blue-dark); color: var(--kb-on-primary); }
.btn-gray { background: var(--kb-surface-2); color: var(--kb-t700); border-color: transparent; }
.btn-gray:hover { background: var(--kb-surface-3); color: var(--kb-t700); }
.btn-dark-gray { background: #374151; color: #fff; } .btn-dark-gray:hover { background: #1f2937; color: #fff; }
.btn-white { background: #fff; color: #2563eb; border-color: #fff; } .btn-white:hover { background: #eff6ff; color: #2563eb; }
.btn-outline-white { background: transparent; color: #fff; border-color: #fff; } .btn-outline-white:hover { background: rgba(255,255,255,.2); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; } .btn-ghost:hover { background: var(--kb-surface-2); }
.btn-icon { padding: .375rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.btn .lucide-icon, .btn svg { width: 1rem; height: 1rem; }

.card { border-color: var(--bs-border-color); border-radius: .5rem; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card-header { background: transparent; border-bottom: 0; padding: 1.5rem 1.5rem .5rem; }
.card-title { font-size: 1.5rem; font-weight: 600; line-height: 1.2; margin-bottom: .25rem; display: flex; align-items: center; gap: .5rem; }
.card-desc { color: var(--kb-t500); font-size: .875rem; margin: 0; }
.card-body { padding: 1.5rem; }
.card-hover { transition: box-shadow .2s, transform .2s; } .card-hover:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.card-lift:hover { transform: translateY(-2px); }
.panel { background: var(--kb-surface); border-radius: .5rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.badge-outline { background: transparent; border: 1px solid var(--bs-border-color); color: var(--kb-t900); font-weight: 600; border-radius: 9999px; padding: .2rem .6rem; font-size: .75rem; }
.badge-soft { border-radius: 9999px; padding: .2rem .6rem; font-size: .75rem; font-weight: 600; border: 1px solid transparent; display: inline-block; }
.tag-chip { background: var(--kb-surface-2); color: var(--kb-t600); border: 1px solid var(--bs-border-color); border-radius: .375rem; padding: .1rem .5rem; font-size: .75rem; font-weight: 600; transition: all .3s; }
.tag-chip:hover { background: color-mix(in srgb, var(--ms-blue) 10%, transparent); color: var(--ms-blue); }

.icon-circle { border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-square { border-radius: .375rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.p-2-5 { padding: .625rem !important; }

.progress { height: .5rem; background: var(--kb-surface-3); border-radius: 9999px; }
.progress-bar { background: #0f172a; border-radius: 9999px; }
.progress-thin { height: .375rem; }

/* Tabs that look like shadcn TabsList */
.kb-tabs { display: inline-flex; background: var(--kb-surface-2); border-radius: .375rem; padding: .25rem; gap: .125rem; flex-wrap: wrap; }
.kb-tabs .nav-link { color: var(--kb-t500); padding: .375rem .75rem; border-radius: .25rem; font-size: .875rem; font-weight: 500; border: 0; background: transparent; }
.kb-tabs .nav-link.active { background: var(--kb-surface); color: var(--kb-t900); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.kb-tabs.kb-tabs-ms .nav-link.active { background: var(--ms-blue); color: #fff; }

/* ---------- layout: sidebar + main ---------- */
#sidebar {
  position: fixed; top: 0; inset-inline-start: 0; height: 100vh; width: var(--sidebar-w); background: var(--kb-surface);
  border-inline-end: 1px solid var(--bs-border-color); z-index: 1040; transition: width .18s ease; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.05); display: flex; flex-direction: column;
}
#sidebar .sb-head { height: 3.5rem; display: flex; align-items: center; gap: .375rem; padding: 0 .875rem; border-bottom: 1px solid var(--bs-border-color); flex-shrink: 0; }
#sidebar .sb-brand { font-size: 1.25rem; font-weight: 600; color: var(--kb-link); white-space: nowrap; line-height: 1.1; transition: opacity .3s; }
#sidebar .sb-nav { padding: .25rem 0 1rem; overflow-y: auto; flex: 1; min-height: 0; position: relative; }
#sidebar .sb-nav a { display: flex; align-items: center; gap: .75rem; padding: .5rem 1.375rem; color: var(--kb-t900); text-decoration: none; font-weight: 500; line-height: 1.3; transition: background .15s, color .15s; }
#sidebar .sb-nav a:hover, #sidebar .sb-nav a.active { background: color-mix(in srgb, var(--ms-blue) 10%, var(--kb-surface)); color: var(--kb-link); }
#sidebar .sb-nav a.active { box-shadow: inset 3px 0 0 var(--ms-blue); }
[dir="rtl"] #sidebar .sb-nav a.active { box-shadow: inset -3px 0 0 var(--ms-blue); }
#sidebar .sb-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--kb-t400); padding: .75rem 1rem .25rem; white-space: nowrap; }
#sidebar .sb-foot { border-top: 1px solid var(--bs-border-color); padding: .75rem 1rem; background: var(--kb-surface-2); display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
#sidebar .sb-label { transition: opacity .2s; overflow: hidden; text-overflow: ellipsis; }
#main { margin-inline-start: var(--sidebar-w); min-height: 100vh; transition: margin .3s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; }
body.sb-collapsed #main { margin-inline-start: var(--sidebar-w-collapsed); }
body.copilot-open #main { margin-inline-end: 0; }
@media (max-width: 767.98px) {
  /* Phones: the sidebar becomes an off-canvas drawer opened from the top bar / header menu button. */
  #sidebar { transform: translateX(-100%); width: min(85vw, 300px); box-shadow: none; }
  [dir="rtl"] #sidebar { transform: translateX(100%); }
  body.sb-mobile-open #sidebar, body.sb-mobile-open.sb-collapsed #sidebar { transform: none; width: min(85vw, 300px); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
  #sidebar .sb-nav a { padding-top: .75rem; padding-bottom: .75rem; }
  #main, body.sb-collapsed #main { margin-inline-start: 0; }
  #sbBackdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s; }
  body.sb-mobile-open #sbBackdrop { opacity: 1; visibility: visible; }
  body.sb-mobile-open { overflow: hidden; }
}
#sbBackdrop { display: none; }
@media (max-width: 767.98px) { #sbBackdrop { display: block; } }
#sidebar .sb-prefs { border-top: 1px solid var(--bs-border-color); padding: .75rem 1rem; flex-shrink: 0; }
#sidebar .sb-prefs .hdr-select { max-width: none; flex: 1; min-width: 0; font-size: 16px; }
#mobileTopbar { position: sticky; top: 0; z-index: 1020; height: 3.5rem; background: var(--kb-surface); box-shadow: 0 1px 2px rgba(0,0,0,.06); display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; }
#mobileTopbar .mt-brand { font-size: 1.125rem; font-weight: 600; color: var(--ms-blue); min-width: 0; }
#mobileTopbar .mt-brand img, #sidebar .sb-brand img { display: block; height: 28px; width: auto; }
/* Product lockup: booknip wordmark + "Knowledge Hub" (the system name is "booknip Knowledge Hub"). */
.kb-lockup { display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-width: 0; line-height: 1; }
#mobileTopbar .mt-brand.kb-lockup img, #sidebar .sb-brand.kb-lockup img { height: 24px; }
.kb-lockup .kb-product { font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #05ADCB; white-space: nowrap; padding-inline-start: 2px; }
[data-bs-theme=dark] .kb-lockup .kb-product, [data-theme=corporate][data-on-primary=light] #sidebar .kb-lockup .kb-product { color: #fff; }
body.has-kb-header #mobileTopbar { display: none !important; }

/* ---------- header ---------- */
.kb-header { background: var(--kb-surface); box-shadow: 0 1px 2px rgba(0,0,0,.05); position: sticky; top: 0; z-index: 1020; }
.kb-header .hdr-inner { height: 3.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.hdr-pill { padding: .375rem .75rem; border-radius: .375rem; font-weight: 500; cursor: pointer; transition: all .2s; text-decoration: none; white-space: nowrap; }
.hdr-pills { display: none; gap: .75rem; }
@media (min-width: 1280px) { .hdr-pills { display: flex; } }
@media (min-width: 1280px) and (max-width: 1399.98px) {
  .hdr-pills { gap: .25rem; }
  .hdr-pill { font-size: .75rem; padding: .25rem .4rem; }
  .kb-header .hdr-select { max-width: 7.5rem; }
  .kb-header .text-nowrap.d-xl-inline { display: none !important; }
}
.hdr-pill:hover { box-shadow: 0 4px 6px rgba(0,0,0,.08); transform: translateY(-1px); }
.hdr-pill.p-blue { background: linear-gradient(to right, #dbeafe, #bfdbfe); color: #1e40af; }
.hdr-pill.p-purple { background: linear-gradient(to right, #f3e8ff, #e9d5ff); color: #6b21a8; }
.hdr-pill.p-green { background: linear-gradient(to right, #dcfce7, #bbf7d0); color: #166534; }
.hdr-pill.p-amber { background: linear-gradient(to right, #fef3c7, #fde68a); color: #92400e; }
.hdr-pill.p-pink { background: linear-gradient(to right, #fce7f3, #fbcfe8); color: #9d174d; }
.hdr-btn { border: 0; background: transparent; padding: .5rem; border-radius: 9999px; color: var(--kb-t600); position: relative; }
.hdr-btn:hover { background: var(--kb-surface-2); color: var(--ms-blue); }
.hdr-badge { position: absolute; top: -2px; inset-inline-end: -2px; background: var(--ms-blue); color: #fff; font-size: .65rem; width: 1rem; height: 1rem; border-radius: 9999px; display: flex; align-items: center; justify-content: center; }
.avatar { width: 2rem; height: 2rem; border-radius: 9999px; background: var(--kb-surface-3); color: var(--kb-t700); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; flex-shrink: 0; }
.hdr-select { font-size: .8rem; padding: .25rem 1.75rem .25rem .5rem; border-radius: .375rem; max-width: 11rem; }

/* ---------- page container ---------- */
.page-container { max-width: none; margin: 0; padding: 1.5rem 1rem; width: 100%; }
.page-bg { background: var(--kb-bg); flex: 1; }

/* ---------- global search ---------- */
.gs-box { border: 2px solid var(--bs-border-color); border-radius: .375rem; overflow: visible; display: flex; align-items: center; position: relative; background: var(--kb-surface); transition: border-color .2s; }
.gs-box:focus-within { border-color: var(--ms-blue); }
.gs-box input { border: 0; outline: 0; font-size: 1.125rem; padding: .75rem 0; flex: 1; min-width: 0; padding-inline-start: 2.5rem; background: transparent; }
.gs-box .gs-icon { position: absolute; inset-inline-start: .75rem; color: var(--kb-t400); }
.gs-suggest { position: absolute; top: 100%; inset-inline-start: 0; inset-inline-end: 0; z-index: 30; background: var(--kb-surface); border: 1px solid var(--bs-border-color); box-shadow: 0 10px 15px rgba(0,0,0,.1); border-radius: .375rem; margin-top: .25rem; padding: .5rem; }
.gs-suggest div { padding: .5rem .75rem; border-radius: .25rem; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
.gs-suggest div:hover { background: var(--kb-surface-2); }
.chip-btn { background: var(--kb-surface-2); border: 0; border-radius: .375rem; padding: .25rem .5rem; color: var(--kb-t700); font-size: .875rem; margin: 0 .5rem .5rem 0; }
[dir="rtl"] .chip-btn { margin: 0 0 .5rem .5rem; }
.chip-btn:hover { background: var(--kb-surface-3); }

/* ---------- document library ---------- */
.dept-list button { width: 100%; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; color: var(--kb-t700); background: none; border: 0; text-align: start; border-inline-start: 3px solid transparent; }
.dept-list button:hover { background: var(--kb-surface-2); }
.dept-list button.active { border-inline-start-color: var(--ms-blue); background: color-mix(in srgb, var(--ms-blue) 8%, transparent); }
.dept-list button.active .lucide-icon, .dept-list button.active svg { color: var(--ms-blue); }
.doc-card { background: var(--kb-surface); border-radius: .5rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); padding: 1rem; margin-bottom: .75rem; cursor: pointer; transition: all .3s; }
.doc-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-4px); }
.doc-card:hover .doc-title { color: var(--ms-blue); }
.doc-card .doc-underline { height: 2px; width: 0; background: linear-gradient(to right, var(--ms-blue), #83c3f7); margin-top: .5rem; transition: width .5s; }
.doc-card:hover .doc-underline { width: 100%; }
.star-on { color: #ffaa44 !important; fill: #ffaa44; }
.ext-card { border: 1px solid var(--bs-border-color); border-radius: .375rem; padding: .75rem; cursor: pointer; transition: all .3s; }
.ext-card:hover { border-color: var(--ms-blue); box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-2px); }
.ext-card:hover h4 { color: var(--ms-blue); }

/* ---------- side panels (Copilot / Virtual agent) ---------- */
.side-panel { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: 25%; min-width: 360px; background: var(--kb-surface); box-shadow: -4px 0 24px rgba(0,0,0,.12); z-index: 1060; display: none; flex-direction: column; }
.side-panel.open { display: flex; }
.side-panel.pva { width: 450px; }
@media (max-width: 767.98px) { .side-panel, .side-panel.pva { width: 100%; min-width: 0; } }
.side-panel .sp-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--bs-border-color); }
.side-panel .sp-body { flex: 1; overflow-y: auto; padding: 1rem; }
.side-panel .sp-foot { padding: 1rem; border-top: 1px solid var(--bs-border-color); }
.msg-assistant { background: var(--kb-surface-2); border-radius: .5rem; padding: .75rem; max-width: 85%; color: var(--kb-t700); }
.msg-assistant h1 { font-size: 1.25rem; font-weight: 700; margin: .75rem 0 .5rem; } .msg-assistant h2 { font-size: 1.125rem; font-weight: 600; margin: .75rem 0 .25rem; } .msg-assistant h3 { font-size: 1rem; font-weight: 500; margin: .5rem 0 .25rem; }
.msg-assistant ul, .msg-assistant ol { padding-inline-start: 1.25rem; margin: .5rem 0; font-size: .875rem; }
.msg-assistant p { margin: 0 0 .5rem; white-space: pre-wrap; } .msg-assistant p:last-child { margin-bottom: 0; }
.msg-user { background: var(--ms-blue); color: #fff; border-radius: .5rem; padding: .75rem; max-width: 85%; white-space: pre-wrap; }
.dot-bounce { width: .5rem; height: .5rem; border-radius: 9999px; background: var(--ms-blue); display: inline-block; animation: kbBounce 1s infinite; }
.dot-bounce:nth-child(2) { animation-delay: .15s; } .dot-bounce:nth-child(3) { animation-delay: .3s; }
@keyframes kbBounce { 0%, 100% { transform: translateY(-25%); } 50% { transform: none; } }
.animate-pulse { animation: kbPulse 2s cubic-bezier(.4,0,.6,1) infinite; }
@keyframes kbPulse { 50% { opacity: .5; } }
.pulse-line { height: .5rem; background: #bfdbfe; border-radius: .25rem; animation: kbPulse 2s infinite; }

/* ---------- document viewer ---------- */
#documentViewer .modal-dialog { max-width: 64rem; }
#documentViewer .modal-content { height: 83vh; }
#documentViewer .modal-body { overflow-y: auto; }

/* ---------- onboarding ---------- */
.kg-preview { position: relative; height: 300px; background: var(--kb-surface-2); border-radius: .375rem; overflow: hidden; }
.kg-node { position: absolute; border-radius: 9999px; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 4px 6px rgba(0,0,0,.1); z-index: 2; animation: kgIn .5s both; }
@keyframes kgIn { from { opacity: 0; transform: scale(0); } to { opacity: 1; } }
.kg-preview svg line { stroke-dasharray: 400; stroke-dashoffset: 400; animation: kgDraw .8s forwards; }
@keyframes kgDraw { to { stroke-dashoffset: 0; } }
.kg-particle { position: absolute; border-radius: 9999px; animation: kgFloat 15s linear infinite; }
@keyframes kgFloat { 0% { transform: translate(50px, 50px); } 25% { transform: translate(200px, 150px); } 50% { transform: translate(300px, 250px); } 75% { transform: translate(150px, 200px); } 100% { transform: translate(50px, 50px); } }
.step-dot { width: .5rem; height: .5rem; border-radius: 9999px; background: #d1d5db; display: inline-block; }
.step-dot.on { background: #3b82f6; }

/* ---------- footer ---------- */
.kb-footer { background: var(--kb-surface-2); border-top: 1px solid var(--bs-border-color); padding: 2rem 0; margin-top: auto; }
.kb-footer a, .kb-footer .f-link { color: var(--kb-t600); font-size: .875rem; text-decoration: none; transition: color .3s; }
.kb-footer a:hover, .kb-footer .f-link:hover { color: var(--ms-blue); }

/* ---------- admin ---------- */
.perm-table th, .perm-table td { vertical-align: middle; text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: start; }
.perm-table .form-check-input { width: 1.15rem; height: 1.15rem; cursor: pointer; }
.stat-card { border-radius: .5rem; background: var(--kb-surface); box-shadow: 0 1px 2px rgba(0,0,0,.06); padding: 1.25rem; height: 100%; }
.rag { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .8rem; padding: .2rem .6rem; border-radius: 9999px; }
.rag-Green { background: #dcfce7; color: #166534; } .rag-Amber { background: #fef3c7; color: #92400e; } .rag-Red { background: #fee2e2; color: #991b1b; }
.sev-Critical { background: #7f1d1d; color: #fff; } .sev-High { background: #fee2e2; color: #991b1b; } .sev-Medium { background: #fef3c7; color: #92400e; } .sev-Low { background: #e0f2fe; color: #075985; }
.st-Open { background: #fee2e2; color: #991b1b; } .st-In-Progress { background: #dbeafe; color: #1e40af; } .st-Resolved, .st-Done { background: #dcfce7; color: #166534; } .st-Closed { background: var(--kb-surface-3); color: var(--kb-t700); } .st-Deferred, .st-N-A { background: var(--kb-surface-2); color: var(--kb-t500); } .st-Accepted-Risk { background: #fef3c7; color: #92400e; } .st-Blocked { background: #7f1d1d; color: #fff; } .st-Not-Started { background: var(--kb-surface-2); color: var(--kb-t600); }
.gauge { position: relative; width: 140px; height: 140px; }
.gauge .gauge-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.table-kb { font-size: .875rem; }
.table-kb thead th { background: var(--kb-surface-2); color: var(--kb-t500); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.chart-box { position: relative; height: 280px; }

/* ---------- misc ---------- */
.hover-bg-gray:hover { background: var(--kb-surface-2); }
.hover-blue:hover { color: #2563eb !important; }
.border-ms-20 { border: 2px solid color-mix(in srgb, var(--ms-blue) 20%, transparent) !important; }
.border-2 { border-width: 2px !important; }
.skeleton { background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: .5rem; }
@keyframes sk { to { background-position: -200% 0; } }
.code-block { background: #0f172a; color: #e2e8f0; border-radius: .5rem; padding: 1rem; font-size: .8rem; overflow-x: auto; white-space: pre; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; text-align: left; }
.toast-container { z-index: 1090; }
.min-h-screen { min-height: 100vh; }
.grid-auto { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.hover-shadow { transition: background .15s; } .hover-shadow:hover { background: #dbeafe !important; }
.border-indigo-100 { border-color: #e0e7ff !important; }
.line-clamp-2{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.line-clamp-3{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.text-teal-500{color:#14b8a6}.text-teal-600{color:#0d9488}.bg-teal-50{background:#f0fdfa}.bg-teal-100{background:#ccfbf1}
.bg-amber-500{background:#f59e0b}.bg-amber-50{background:#fffbeb}
/* Grid utilities used by the ported page layouts (CSS grid; pair with Bootstrap gap-* classes) */
.kb-grid{display:grid;grid-template-columns:minmax(0,1fr)}
.cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.span-2{grid-column:span 2/span 2}.col-span-full{grid-column:1/-1}
@media (min-width:640px){.sm-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media (min-width:768px){.md-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.md-span-2{grid-column:span 2/span 2}.md-span-3{grid-column:span 3/span 3}}
@media (min-width:1024px){.lg-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.lg-span-2{grid-column:span 2/span 2}.lg-span-3{grid-column:span 3/span 3}}
ul.vstack>li,ol.vstack>li{display:list-item}
.h-plain{font-size:inherit;font-weight:inherit;line-height:inherit}
.code-line{display:grid;grid-template-columns:1.5rem 1fr;gap:1rem}.kb-code pre{white-space:pre}
.border-blue-300{border-color:#93c5fd!important}.border-green-300{border-color:#86efac!important}.border-purple-300{border-color:#d8b4fe!important}.border-pink-300{border-color:#f9a8d4!important}.border-amber-300{border-color:#fcd34d!important}.border-teal-300{border-color:#5eead4!important}.text-teal-800{color:#115e59}
.avatar{position:relative;overflow:hidden}.avatar>img.av-img{position:absolute;top:0;left:0;width:100%;height:100%}

/* =====================================================================================================
   Responsive layer: phones (< 576px), large phones / small tablets (< 768px), tablets (768–1199px).
   ===================================================================================================== */
#main { min-width: 0; }
img, video, canvas, iframe { max-width: 100%; }
#pageContent { overflow-wrap: break-word; }
.w-sm-auto { width: 100%; }
@media (min-width: 576px) { .w-sm-auto { width: auto !important; } }
.chart-box canvas { max-width: 100%; }

/* Tab strips and the admin sub-navigation scroll sideways on small screens instead of wrapping into a block. */
@media (max-width: 767.98px) {
  .kb-tabs:not(.d-grid), .admin-nav { flex-wrap: nowrap !important; overflow-x: auto; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .kb-tabs:not(.d-grid) { display: flex; }
  .kb-tabs::-webkit-scrollbar, .admin-nav::-webkit-scrollbar { display: none; }
  .kb-tabs .nav-link, .admin-nav > a { white-space: nowrap; flex-shrink: 0; }
  .kb-tabs.d-grid .nav-link { padding-inline: .25rem; }
}

/* Header on phones: tighter spacing, larger tap targets. */
@media (max-width: 575.98px) {
  .kb-header .hdr-inner { gap: .5rem; }
  .kb-header .hdr-inner > div:last-child { gap: .25rem !important; }
  .hdr-btn { padding: .5rem; min-width: 2.5rem; min-height: 2.5rem; }
  .kb-header .dropdown-menu { max-width: calc(100vw - 1.5rem); }
}

/* Global search box: buttons drop under the input on phones. */
@media (max-width: 575.98px) {
  .gs-box { flex-wrap: wrap; }
  .gs-box .gs-icon { top: 1rem; }
  .gs-box input { font-size: 1rem; }
  .gs-actions { width: 100%; padding: 0 .5rem .5rem !important; }
  .gs-actions .btn { flex: 1 1 0; min-width: 0; justify-content: center; white-space: nowrap; padding-inline: .5rem !important; }
  .gs-actions .btn > svg.lucide-external-link, .gs-actions .btn > .lucide-icon:last-child:not(:first-child) { display: none; }
}

/* Forms: 16px inputs stop iOS from zooming the page on focus; full-width action buttons in narrow modals. */
@media (max-width: 767.98px) {
  .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 16px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-fullscreen-sm-down .modal-footer > .btn, .modal-fullscreen-md-down .modal-footer > .btn { flex: 1 1 auto; }
  .page-container { padding: 1rem .75rem; }
  .card-header { padding: 1rem 1rem .5rem; }
  .card-body { padding: 1rem; }
  .card-title { font-size: 1.25rem; }
  .text-3xl { font-size: 1.5rem !important; }
  .text-4xl { font-size: 1.875rem !important; }
  .stat-card { padding: 1rem; }
  .side-panel .sp-foot { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  #toastContainer { left: 0; right: 0; padding: .75rem !important; }
  #toastContainer .toast { width: 100%; }
}
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-fullscreen-sm-down):not(.modal-fullscreen-md-down):not(.kb-drill-large):not(.kb-drill-fit) { margin: .75rem; max-width: none !important; }
  #documentViewer .modal-content { height: 100%; }
}
@media (max-width: 991.98px) { #documentViewer .modal-content { height: 100%; } }
@media (min-width: 992px) { #documentViewer .modal-content { height: 83vh; } }

/* Data tables become stacked cards on phones (labels come from KB.labelTables in core.js). */
@media (max-width: 767.98px) {
  table.table-stack { display: block; width: 100%; }
  table.table-stack thead { display: none; }
  table.table-stack tbody, table.table-stack tr { display: block; width: 100%; }
  table.table-stack tr { padding: .75rem 1rem; border-bottom: 1px solid var(--bs-border-color); }
  table.table-stack tr:last-child { border-bottom: 0; }
  table.table-stack > tbody > tr > td { display: block; width: 100%; border: 0 !important; padding: .2rem 0 .2rem 38% !important; position: relative; text-align: start !important; white-space: normal !important; min-height: 1.6rem; background: transparent; box-shadow: none; }
  [dir="rtl"] table.table-stack > tbody > tr > td { padding: .2rem 38% .2rem 0 !important; }
  table.table-stack > tbody > tr > td::before { content: attr(data-label); position: absolute; inset-inline-start: 0; top: .3rem; width: 35%; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--kb-t500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  table.table-stack > tbody > tr > td:first-child, table.table-stack > tbody > tr > td[colspan], table.table-stack > tbody > tr > td[data-label=""] { padding: .2rem 0 !important; }
  table.table-stack > tbody > tr > td:first-child::before, table.table-stack > tbody > tr > td[colspan]::before, table.table-stack > tbody > tr > td[data-label=""]::before { display: none; }
  table.table-stack > tbody > tr > td:first-child { font-weight: 600; padding-bottom: .4rem !important; }
  table.table-stack > tbody > tr > td:empty { display: none; }
  table.table-stack > tbody > tr > td .btn-group, table.table-stack > tbody > tr > td .d-flex { flex-wrap: wrap; justify-content: flex-start !important; }
  table.table-stack.table-hover > tbody > tr:hover > * { --bs-table-bg-state: transparent; }
  .table-responsive:has(> table.table-stack) { overflow-x: visible; }
  /* Wide matrices keep horizontal scrolling; keep the first column readable while scrolling. */
  .perm-table td:first-child, .perm-table th:first-child, .perm-matrix td:first-child, .perm-matrix th:first-child { position: sticky; inset-inline-start: 0; background: var(--kb-surface); z-index: 1; min-width: 8rem; }
}

/* Charts and gauges shrink with their card. */
@media (max-width: 575.98px) {
  .chart-box { height: 230px; }
  .gauge { width: 120px; height: 120px; }
  .kg-preview { height: 240px; }
}

/* Two-up summary cards on phones: put the icon above the figures so labels are not squeezed. */
@media (max-width: 575.98px) {
  .kb-grid.cols-2 > .card > .card-body.d-flex { flex-direction: column; gap: .5rem !important; padding: .875rem; }
  .kb-grid.cols-2 .text-2xl { font-size: 1.375rem !important; }
}


/* Fixed-width filters and dropdowns never get wider than the screen. */
.form-select[style*="width"], .form-control[style*="width"], .dropdown-menu[style*="width"] { max-width: calc(100vw - 1.5rem); }

/* Desktop: pages use the full width of the window (no centred fixed-width column), with a little more breathing room on wide screens. */
#pageContent .container-xxl, #pageContent .container-xl, #pageContent .container-lg, #pageContent .container { max-width: none; }
@media (min-width: 1200px) {
  #pageContent .page-container, #pageContent .container-xxl { padding-left: 2rem !important; padding-right: 2rem !important; }
}

/* ---------- sidebar: every row keeps its position, so shrinking and hovering only reveal or clip it ---------- */
html { scrollbar-gutter: stable; }
#sidebar > * { width: var(--sidebar-w); flex-shrink: 0; }
#sidebar > .sb-nav { flex: 1 1 0; }
#sidebar .sb-ic { width: 1.25rem; flex-shrink: 0; display: inline-flex; justify-content: center; }
#sidebar .sb-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: .9375rem; }
#sidebar .sb-sec-head .sb-label { font-size: inherit; }
#sidebar a.sb-sub .sb-label { font-size: .8125rem; }
#sidebar .sb-brand { min-width: 0; }
#sidebar .sb-search { display: flex; align-items: center; gap: .75rem; padding: .5rem 1.375rem; color: var(--kb-t500); border-bottom: 1px solid var(--bs-border-color); }
#sidebar .sb-search input { flex: 1; min-width: 0; border: 1px solid var(--bs-border-color); border-radius: .375rem; padding: .25rem .5rem; font-size: .8125rem; background: var(--kb-surface); color: var(--kb-t900); outline: 0; }
#sidebar .sb-search input:focus { border-color: var(--ms-blue); }
#sidebar .sb-sec-head { display: flex; align-items: center; gap: .75rem; width: 100%; padding: .5rem 1.375rem; border: 0; background: transparent; color: var(--kb-t500); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; text-align: start; }
#sidebar .sb-sec-head:hover { color: var(--kb-link); }
#sidebar .sb-sec-head .sb-label { flex: 1; }
#sidebar .sb-chev, #sidebar .js-tree svg { transition: transform .15s; }
#sidebar .sb-sec.closed > .sb-sec-head .sb-chev, #sidebar .sb-tree.closed > .js-tree svg { transform: rotate(-90deg); }
[dir=rtl] #sidebar .sb-sec.closed > .sb-sec-head .sb-chev, [dir=rtl] #sidebar .sb-tree.closed > .js-tree svg { transform: rotate(90deg); }
#sidebar .sb-sec.closed > .sb-sec-body, #sidebar .sb-tree.closed > .sb-subs { display: none; }
#sidebar .sb-tree { position: relative; }
#sidebar .sb-tree > a { padding-inline-end: 2.5rem; }
#sidebar .sb-tree-btn { position: absolute; top: .25rem; inset-inline-end: .75rem; border: 0; background: transparent; color: inherit; padding: .25rem; line-height: 0; border-radius: .25rem; }
#sidebar .sb-tree-btn:hover { background: var(--kb-surface-2); }
#sidebar .sb-nav a.sb-sub { position: relative; padding: .3rem 1rem .3rem 4.25rem; font-size: .8125rem; font-weight: 400; }
#sidebar .sb-nav a.sb-sub::before { content: ''; position: absolute; top: 50%; inset-inline-start: 1.875rem; width: .3rem; height: .3rem; margin-top: -.15rem; border-radius: 50%; background: currentColor; opacity: .55; }
#sidebar .sb-nav a.active { font-weight: 600; background: color-mix(in srgb, var(--ms-blue) 14%, var(--kb-surface)); color: var(--kb-link); }
#sidebar .sb-tree.active-parent > a { color: var(--kb-link); }
#sidebar .sb-none { padding: .75rem 1.375rem; margin: 0; font-size: .8125rem; color: var(--kb-t500); }
#sidebar .sb-hide { display: none !important; }
#sidebar.sb-filtering .sb-sec-body { display: block !important; }
#sidebar.sb-filtering .sb-tree-hit > .sb-subs { display: block !important; }
#sidebar.sb-filtering .sb-tree:not(.sb-tree-hit) > .sb-subs { display: none !important; }

/* Shrunk to the icon rail on a desktop: hovering any icon opens it over the page, so the page itself never moves. */
@media (min-width: 768px) {
  body.sb-collapsed #sidebar { width: var(--sidebar-w-collapsed); }
  body.sb-collapsed #sidebar .sb-search input, body.sb-collapsed #sidebar .sb-label, body.sb-collapsed #sidebar .sb-chev, body.sb-collapsed #sidebar .sb-tree-btn { opacity: 0; }
  body.sb-collapsed #sidebar .js-all, body.sb-collapsed #sidebar .sb-brand { visibility: hidden; }
}
@media (min-width: 768px) and (hover: hover) {
  body.sb-collapsed #sidebar:not(.sb-nohover):hover, body.sb-collapsed #sidebar.sb-searching { width: var(--sidebar-w); box-shadow: 0 10px 30px rgba(0,0,0,.18); transition-delay: .08s; }
  body.sb-collapsed #sidebar:not(.sb-nohover):hover .sb-search input, body.sb-collapsed #sidebar.sb-searching .sb-search input,
  body.sb-collapsed #sidebar:not(.sb-nohover):hover .sb-label, body.sb-collapsed #sidebar.sb-searching .sb-label,
  body.sb-collapsed #sidebar:not(.sb-nohover):hover .sb-chev, body.sb-collapsed #sidebar.sb-searching .sb-chev,
  body.sb-collapsed #sidebar:not(.sb-nohover):hover .sb-tree-btn, body.sb-collapsed #sidebar.sb-searching .sb-tree-btn { opacity: 1; }
  body.sb-collapsed #sidebar:not(.sb-nohover):hover .js-all, body.sb-collapsed #sidebar:not(.sb-nohover):hover .sb-brand, body.sb-collapsed #sidebar.sb-searching .js-all, body.sb-collapsed #sidebar.sb-searching .sb-brand { visibility: visible; }
}
@media (max-width: 767.98px) { #sidebar > * { width: 100%; } }
