/* Noble Engineering Standards app - shared stylesheet.
   Implements the design-token standard (#15): one token set, neutral borders,
   no decorative side-stripes or accent bars. Components here are the same ones
   demonstrated on the demo screens. */

:root {
  /* Brand */
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-primary-soft: #eff6ff;
  /* Semantic */
  --color-success: #16a34a;
  --color-warning: #b45309;
  --color-danger: #dc2626;
  --color-info: #2563eb;
  /* Neutrals */
  --color-bg: #f9fafb;
  --color-card: #ffffff;
  --color-bg-muted: #f8fafc;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  /* Layout */
  --sidebar-width: 248px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.18);
  --focus-ring: 0 0 0 2px var(--color-primary);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 15px;
}
*:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: -999px; top: auto; width: 1px; height: 1px; overflow: hidden; z-index: 999; }
.skip-link:focus { left: 16px; top: 16px; width: auto; height: auto; background: var(--color-primary); color: #fff; padding: 8px 16px; border-radius: var(--radius); font-weight: 600; }

/* ---------- Sidebar (standard #16) ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh;
  background: var(--color-card); border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; z-index: 80;
}
.sidebar-brand { background: #1e293b; color: #fff; padding: 14px 16px; flex: 0 0 auto; }
.sidebar-brand h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; margin: 0 0 2px; }
.sidebar-brand h1 span { color: #60a5fa; }
.sidebar-brand .brand-sub { font-size: 11px; color: rgba(255, 255, 255, 0.6); }

.search-trigger {
  display: flex; align-items: center; gap: 8px; margin: 10px 12px 2px;
  padding: 7px 10px; width: calc(100% - 24px);
  background: var(--color-bg-muted); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); color: var(--color-text-muted);
  font-size: 13px; cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.search-trigger kbd {
  margin-left: auto; font-family: inherit; font-size: 11px; color: var(--color-text-muted);
  background: var(--color-card); border: 1px solid var(--color-border); border-radius: 4px; padding: 1px 5px;
}

.sidebar-nav { padding: 4px 12px 8px; flex: 0 0 auto; }
.nav-group { margin-bottom: 2px; }
.nav-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--color-text-muted); padding: 12px 12px 3px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 12px;
  color: var(--color-text-muted); text-decoration: none; font-size: 13.5px;
  border-radius: var(--radius-sm); line-height: 1.4;
}
.nav-item:hover { background: #f1f5f9; color: var(--color-text); }
.nav-item.active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }
.nav-ic { display: inline-flex; align-items: center; flex: 0 0 auto; }

.sidebar-context { border-top: 1px solid var(--color-border); margin-top: 6px; padding: 0 12px 8px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.context-label { padding-top: 12px; }
.toc a {
  display: block; padding: 4px 12px; color: var(--color-text-muted); text-decoration: none;
  font-size: 12.5px; border-radius: var(--radius-sm); line-height: 1.45;
}
.toc a:hover { background: #f1f5f9; color: var(--color-text); }
.toc a.active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }
.toc .section-num { display: inline-block; width: 26px; color: var(--color-primary); font-weight: 600; font-size: 11.5px; }
.toc .toc-appendix { font-weight: 600; color: var(--color-text); margin-top: 10px; }
.toc-group { margin-bottom: 2px; }

.sidebar-footer { flex: 0 0 auto; border-top: 1px solid var(--color-border); padding: 10px 12px; margin-top: auto; }
.user-card { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #1e293b; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex: 0 0 auto;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--color-text-muted); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--color-text-muted); cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm); text-decoration: none;
}
.logout-form { display: inline-flex; margin: 0; }
.icon-btn:hover { background: #f1f5f9; color: var(--color-text); }

/* Mobile top bar + drawer */
.mobile-topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 90;
  background: #1e293b; color: #fff; align-items: center; gap: 8px; padding: 0 10px;
}
.mobile-topbar .icon-btn { color: rgba(255, 255, 255, 0.85); }
.mobile-brand { font-size: 15px; flex: 1; }
.mobile-brand strong { color: #60a5fa; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 85; }

main { margin-left: var(--sidebar-width); padding: 28px 40px 80px; max-width: 1160px; }

/* Secondary sections sidebar: a second fixed column for the document TOC so
   every section is scannable without scrolling the main nav. */
.sidebar2 {
  position: fixed; top: 0; bottom: 0; left: var(--sidebar-width); width: 238px;
  background: var(--color-card); border-right: 1px solid var(--color-border);
  overflow-y: auto; padding: 4px 12px 24px; z-index: 70;
}
.sidebar2-head { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--color-text-muted); padding: 16px 12px 4px; }
body.has-sidebar2 main { margin-left: calc(var(--sidebar-width) + 238px); }
.sidebar-context-compact { display: none; }
@media (max-width: 1200px) {
  .sidebar2 { display: none; }
  body.has-sidebar2 main { margin-left: var(--sidebar-width); }
  .sidebar-context-compact { display: block; }
}
@media (max-width: 768px) {
  body.has-sidebar2 main { margin-left: 0; }
}

@media (max-width: 768px) {
  .mobile-topbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.18s ease; width: 280px; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  main { margin-left: 0; padding: 68px 16px 80px; }
}

/* ---------- Content card (standards document) ---------- */
.content-card { background: var(--color-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 40px 48px; }
.content-card h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; padding-bottom: 16px; border-bottom: 2px solid var(--color-border); }
.content-card h2 { font-size: 22px; font-weight: 700; margin-top: 40px; margin-bottom: 16px; padding-top: 20px; border-top: 1px solid var(--color-border); scroll-margin-top: 16px; }
.content-card h2:first-of-type { margin-top: 16px; border-top: none; padding-top: 0; }
.content-card h3 { font-size: 17px; font-weight: 600; margin-top: 32px; margin-bottom: 12px; scroll-margin-top: 16px; }
.content-card h4 { font-size: 15px; font-weight: 600; margin-top: 24px; margin-bottom: 8px; color: var(--color-text-muted); }
.content-card p { margin-bottom: 12px; font-size: 15px; }
.content-card ul, .content-card ol { margin-bottom: 12px; padding-left: 24px; }
.content-card li { margin-bottom: 6px; font-size: 15px; }
.content-card strong { font-weight: 600; }
.content-card hr { border: none; border-top: 1px solid var(--color-border); margin: 32px 0; }
.content-card code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: "JetBrains Mono", "Fira Code", Consolas, monospace; }
.content-card pre { background: #1e293b; color: #e2e8f0; padding: 16px 20px; border-radius: var(--radius); overflow-x: auto; margin-bottom: 16px; font-size: 13px; line-height: 1.5; }
.content-card pre code { background: none; padding: 0; color: inherit; }
.content-card table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.content-card th { background: var(--color-bg-muted); font-weight: 600; text-align: left; padding: 10px 12px; border: 1px solid var(--color-border); font-size: 13px; }
.content-card td { padding: 8px 12px; border: 1px solid var(--color-border); vertical-align: top; }
/* Callouts stay neutral: plain border, no colored side-stripe. */
.content-card blockquote { border: 1px solid var(--color-border); padding: 12px 16px; background: var(--color-bg-muted); border-radius: var(--radius); margin-bottom: 16px; }
.content-card input[type="checkbox"] { margin-right: 8px; accent-color: var(--color-primary); }
mark.search-hl { background: #fef08a; padding: 1px 2px; border-radius: 2px; }

/* ---------- Page scaffolding for app screens ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; }
.page-sub { color: var(--color-text-muted); font-size: 14px; max-width: 640px; }
.page-head-refs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 6px; }
.muted-small { font-size: 12px; color: var(--color-text-muted); }
.card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Stat / KPI cards (standard #28) */
.stat-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 18px; display: block; text-decoration: none; color: inherit; }
a.stat-card:hover { border-color: var(--color-border-strong); }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-muted); }
.stat-value { font-size: 26px; font-weight: 800; margin: 2px 0; }
.stat-delta { font-size: 12px; font-weight: 600; }
.stat-delta.up { color: var(--color-success); }
.stat-delta.down { color: var(--color-danger); }
.stat-delta .vs { color: var(--color-text-muted); font-weight: 400; }

/* Badges: functional status chips (allowed), never decorative stripes */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-bg-muted); color: var(--color-text); white-space: nowrap; }
.badge-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.badge-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.badge-danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.badge-info { background: var(--color-primary-soft); border-color: #bfdbfe; color: var(--color-primary-dark); }
.badge-link { text-decoration: none; cursor: pointer; }
.badge-link:hover { border-color: var(--color-border-strong); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; text-decoration: none; line-height: 1.4; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-card); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-bg-muted); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-text { background: none; border: none; color: var(--color-text-muted); font-size: 13px; cursor: pointer; margin-top: 12px; }
.btn-text:hover { color: var(--color-text); }

/* ---------- Tables (standard #19) ---------- */
.table-wrap { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--color-border); flex-wrap: wrap; }
.table-search { position: relative; flex: 0 0 auto; }
.table-search input { padding: 7px 10px 7px 30px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13px; width: 220px; outline: none; }
.table-search input:focus { border-color: var(--color-primary); }
.table-search .ic { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); display: inline-flex; }
.table-search .clear-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--color-text-muted); cursor: pointer; font-size: 14px; padding: 2px; display: none; }
.table-scroll { overflow: auto; max-height: 640px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { position: sticky; top: 0; z-index: 2; background: var(--color-bg-muted); border-bottom: 1px solid var(--color-border); text-align: left; padding: 9px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--color-primary); }
.data-table th .sort-ind { font-size: 10px; margin-left: 4px; color: var(--color-primary); }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--color-bg-muted); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tfoot td { background: var(--color-bg-muted); font-weight: 700; border-top: 1px solid var(--color-border-strong); position: sticky; bottom: 0; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--color-border); font-size: 13px; color: var(--color-text-muted); flex-wrap: wrap; }
.row-count { white-space: nowrap; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 4px; }
.pagination button { min-width: 30px; height: 30px; border: 1px solid var(--color-border); background: var(--color-card); border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; color: var(--color-text); }
.pagination button:hover { border-color: var(--color-border-strong); }
.pagination button[aria-current="page"] { background: var(--color-primary); color: #fff; border-color: var(--color-primary); font-weight: 700; }
.pagination button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Filter bar (standard #20): one bar, horizontal scroll ---------- */
.filter-bar { display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: thin; flex: 1 1 auto; min-width: 0; }
.filter-bar::-webkit-scrollbar { height: 6px; }
.filter-bar::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 3px; }
.filter-chip-count { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; }
.clear-filters { white-space: nowrap; }

/* Multi-select dropdown with typeahead (standard #20) */
.msel { position: relative; flex: 0 0 auto; }
.msel-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-card); font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--color-text); }
.msel-btn:hover { border-color: var(--color-border-strong); }
.msel-btn .count { background: var(--color-primary); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 6px; line-height: 16px; }
.msel-panel { position: absolute; top: calc(100% + 4px); left: 0; min-width: 230px; background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 60; padding: 8px; }
.msel-panel input[type="text"] { width: 100%; padding: 6px 9px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 6px; outline: none; }
.msel-panel input[type="text"]:focus { border-color: var(--color-primary); }
.msel-list { max-height: 220px; overflow-y: auto; }
.msel-item { display: flex; align-items: center; gap: 8px; padding: 5px 7px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; }
.msel-item:hover, .msel-item.kb-active { background: var(--color-bg-muted); }
.msel-item input { accent-color: var(--color-primary); }
.msel-actions { display: flex; justify-content: space-between; border-top: 1px solid var(--color-border); margin-top: 6px; padding-top: 6px; }

select.select, input.input, textarea.textarea { padding: 8px 11px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: var(--color-card); color: var(--color-text); outline: none; }
select.select:focus, input.input:focus, textarea.textarea:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* ---------- Forms (standard #30) ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: #374151; }
.field .req { color: var(--color-danger); }
.field input, .field select, .field textarea { padding: 9px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; outline: none; background: var(--color-card); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.field .hint { font-size: 12px; color: var(--color-text-muted); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--color-danger); }
.field .field-error { font-size: 12px; color: var(--color-danger); }
.form-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--color-border); padding-top: 16px; margin-top: 8px; }

/* ---------- Modal / slide-over / confirm (standard #31) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 150; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--color-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--color-border); }
.modal-head h2 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--color-border); }
.overlay.slideover-host { align-items: stretch; justify-content: flex-end; padding: 0; }
.slide-over { background: var(--color-card); width: 440px; max-width: 92vw; height: 100%; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.slide-over .modal-body { flex: 1; }

/* ---------- Toasts (standard #37) ---------- */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1e293b; color: #fff; border-radius: var(--radius); padding: 10px 18px; font-size: 14px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; }
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }

/* Empty states (standard #37) */
.empty-state { text-align: center; padding: 48px 24px; color: var(--color-text-muted); }
.empty-state h3 { color: var(--color-text); font-size: 16px; margin-bottom: 6px; }
.empty-state .btn { margin-top: 14px; }

/* ---------- Command palette (standard #18) ---------- */
.palette-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.palette { background: var(--color-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 600px; overflow: hidden; display: flex; flex-direction: column; max-height: 64vh; }
.palette-input-wrap { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--color-border); color: var(--color-text-muted); }
.palette-input-wrap input { flex: 1; border: none; outline: none; font-size: 16px; font-family: inherit; color: var(--color-text); background: transparent; }
.palette-results { overflow-y: auto; padding: 6px; }
.palette-group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--color-text-muted); padding: 10px 12px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; color: var(--color-text); text-decoration: none; }
.palette-item .pi-ic { color: var(--color-text-muted); display: inline-flex; flex: 0 0 auto; }
.palette-item .pi-meta { margin-left: auto; font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; }
.palette-item.kb-active { background: var(--color-primary-soft); }
.palette-item .snippet { display: block; font-size: 12px; color: var(--color-text-muted); line-height: 1.4; }
.palette-empty { padding: 24px; text-align: center; color: var(--color-text-muted); font-size: 14px; }
.palette-foot { border-top: 1px solid var(--color-border); padding: 8px 14px; font-size: 11.5px; color: var(--color-text-muted); display: flex; gap: 14px; }
.palette-foot kbd { background: var(--color-bg-muted); border: 1px solid var(--color-border); border-radius: 4px; padding: 0 5px; font-family: inherit; }

/* ---------- AI chat (standard #41), UX parity with the LMS ChatBubble ---------- */
.chat-fab { position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%; background: var(--color-primary); color: #fff; border: none; cursor: pointer; z-index: 140; box-shadow: var(--shadow-md); display: flex; align-items: center; justify-content: center; transition: transform 0.12s ease; }
.chat-fab:hover { transform: scale(1.06); }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }
.nes-chat-panel { position: fixed; bottom: 5.5rem; right: 24px; width: min(460px, calc(100vw - 32px)); height: min(720px, calc(100dvh - 11.5rem)); display: flex; flex-direction: column; background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 140; overflow: hidden; animation: fadeSlideIn 0.18s ease-out; }
.nes-chat-panel.expanded { width: min(720px, calc(100vw - 32px)); height: min(880px, calc(100dvh - 9.5rem)); }
@media (max-width: 480px) {
  .nes-chat-panel { top: 0; bottom: 0; left: 0; right: 0; width: 100vw; height: 100dvh; border-radius: 0; border: none; }
  .nes-expand { display: none !important; }
  .chat-fab { bottom: 16px; right: 16px; }
}
.nes-chat-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; color: #fff; flex-shrink: 0; background-image: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%); }
.nes-chat-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nes-chat-logo { width: 36px; height: 36px; border-radius: var(--radius); background: #fff; color: var(--color-primary); font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); flex-shrink: 0; }
.nes-chat-title { font-size: 15px; font-weight: 700; color: #fff; }
.nes-chat-status { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: #fff; opacity: 0.9; margin-top: 2px; }
.nes-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 6px #22c55e; flex-shrink: 0; }
.nes-status-dot.pending { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.nes-chat-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.nes-hicon { color: #fff; opacity: 0.85; cursor: pointer; padding: 6px; border-radius: 6px; display: flex; align-items: center; justify-content: center; background: none; border: none; }
.nes-hicon:hover { opacity: 1; background: rgba(255, 255, 255, 0.16); }
.nes-chat-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; position: relative; font-size: 13.5px; line-height: 1.55; }
.nes-welcome { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; color: var(--color-text); font-size: 14px; }
.nes-welcome::before { content: ""; flex-shrink: 0; flex-basis: 20%; }
.nes-suggestions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px; }
.nes-suggestion { background: #fff; border: 1px solid var(--color-border); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--color-text); cursor: pointer; font-family: inherit; }
.nes-suggestion:hover { border-color: var(--color-primary); color: var(--color-primary); }
.nes-msg { display: flex; flex-direction: column; }
.nes-msg.user { align-self: flex-end; max-width: 85%; background: var(--color-primary); color: #fff; padding: 8px 12px; border-radius: var(--radius); }
.nes-msg.ai { align-self: flex-start; max-width: 92%; background: var(--color-bg-muted); color: var(--color-text); padding: 8px 12px; border-radius: var(--radius); }
.nes-msg.ai code { background: rgba(0, 0, 0, 0.07); padding: 1px 5px; border-radius: 3px; font-size: 12px; font-family: "JetBrains Mono", Consolas, monospace; }
.nes-msg.ai pre { background: #1e293b; color: #e2e8f0; padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 6px 0; font-size: 12px; }
.nes-msg.ai pre code { background: none; padding: 0; color: inherit; }
.nes-msg.ai ul, .nes-msg.ai ol { padding-left: 20px; margin: 4px 0; }
.nes-msg.ai a { color: var(--color-primary); }
.nes-meta-row { margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 20px; }
.nes-stamp { font-size: 11px; color: var(--color-text-muted); }
.nes-stamp.on-user { color: #fff; opacity: 0.8; }
.nes-actions { display: flex; align-items: center; gap: 4px; }
.nes-act { display: inline-flex; align-items: center; gap: 4px; color: var(--color-text-muted); cursor: pointer; padding: 4px; border-radius: 6px; font-size: 11px; background: none; border: none; transition: color 0.12s, background-color 0.12s; }
.nes-act:hover { color: var(--color-text); background: #fff; }
.nes-act[data-active="true"] { color: #fff; background: var(--color-primary); }
.nes-act[data-active="true"]:hover { color: #fff; background: var(--color-primary); }
.nes-copied { font-size: 11px; }
.nes-thinking { display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; }
.nes-thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--color-text-muted); animation: typingBounce 1.2s infinite ease-in-out; }
.nes-thinking span:nth-child(2) { animation-delay: 0.15s; }
.nes-thinking span:nth-child(3) { animation-delay: 0.3s; }
.nes-scroll-down { position: absolute; bottom: 6.5rem; right: 16px; width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 1px solid var(--color-border); box-shadow: var(--shadow-md); color: var(--color-text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1; }
.nes-scroll-down:hover { color: var(--color-text); }
.nes-chat-notice { margin: 0 12px 4px; padding: 8px 12px; font-size: 13px; color: var(--color-text); background: var(--color-bg-muted); border: 1px solid var(--color-border); border-radius: var(--radius); }
.nes-input-row { display: flex; align-items: flex-end; gap: 8px; margin: 12px; padding: 6px 8px 6px 16px; border: 1.5px solid var(--color-border); border-radius: var(--radius-lg); background: #fff; flex-shrink: 0; }
.nes-input-row:focus-within { border-color: var(--color-primary); }
.nes-input-row textarea { flex: 1; padding: 8px 0; border: none; font-size: 13.5px; color: var(--color-text); background: transparent; resize: none; max-height: 120px; line-height: 1.4; outline: none; font-family: inherit; }
.nes-char-count { font-size: 11px; color: var(--color-text-muted); align-self: center; }
.nes-send { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--color-primary); color: #fff; border: none; cursor: pointer; }
.nes-send:hover { background: var(--color-primary-dark); }
.nes-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Bug report widget (standard #45), sits left of the chat FAB ---------- */
.bug-fab { position: fixed; bottom: 24px; right: calc(24px + var(--chat-footprint, 0rem) + 10px); z-index: 139; display: inline-flex; align-items: center; gap: 7px; background: #1e293b; color: #fff; border: none; border-radius: 999px; padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-md); font-family: inherit; }
.bug-fab:hover { background: #0f172a; }
@media (max-width: 480px) { .bug-fab span { display: none; } .bug-fab { padding: 10px 12px; right: calc(16px + var(--chat-footprint, 0rem)); bottom: 16px; } }

/* ---------- Notifications bell (standard #38) ---------- */
.sidebar-toprow { display: flex; align-items: center; gap: 6px; margin: 10px 12px 2px; }
.sidebar-toprow .search-trigger { margin: 0; flex: 1; width: auto; }
.bell-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg-muted); color: var(--color-text-muted); cursor: pointer; flex-shrink: 0; }
.bell-btn:hover { color: var(--color-text); border-color: var(--color-border-strong); }
.bell-badge { position: absolute; top: -5px; right: -5px; background: var(--color-danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 0 5px; line-height: 15px; min-width: 15px; text-align: center; }
.notif-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--color-border); cursor: pointer; align-items: flex-start; }
.notif-item:hover { background: var(--color-bg-muted); }
.notif-item.unread { background: var(--color-primary-soft); }
.notif-item .n-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary); margin-top: 6px; flex-shrink: 0; }
.notif-item.read .n-dot { background: transparent; }
.notif-title { font-size: 13.5px; font-weight: 600; }
.notif-body { font-size: 12.5px; color: var(--color-text-muted); }
.notif-when { font-size: 11px; color: var(--color-text-muted); white-space: nowrap; }

/* ---------- Admin sub-nav pill strip ---------- */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.subnav a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-card); color: var(--color-text-muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.subnav a:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.subnav a.active { background: var(--color-primary-soft); border-color: #bfdbfe; color: var(--color-primary); }
.subnav .count { background: var(--color-bg-muted); border: 1px solid var(--color-border); border-radius: 999px; font-size: 11px; padding: 0 6px; line-height: 16px; }

/* ---------- Kanban (standard #35) ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.kan-col { background: var(--color-bg-muted); border: 1px solid var(--color-border); border-radius: var(--radius); min-height: 320px; display: flex; flex-direction: column; }
.kan-col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 12.5px; font-weight: 700; }
.kan-col-head .count { color: var(--color-text-muted); font-weight: 600; }
.kan-col-head .wip { margin-left: auto; font-size: 11px; color: var(--color-text-muted); font-weight: 500; }
.kan-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kan-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-sm); }
.kan-card:active { cursor: grabbing; }
.kan-card .k-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.kan-card .k-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--color-text-muted); }
.kan-col.dragover { outline: 2px dashed var(--color-primary); outline-offset: -4px; }
.kan-card.dragging { opacity: 0.5; }

/* ---------- Import wizard ---------- */
.stepper { display: flex; gap: 0; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 10px; font-size: 13px; color: var(--color-text-muted); }
.step .s-num { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--color-border-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--color-card); }
.step.active { color: var(--color-text); font-weight: 600; }
.step.active .s-num { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.step.done .s-num { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.step:not(:last-child)::after { content: ""; width: 32px; height: 1px; background: var(--color-border-strong); margin-left: 12px; }

/* ---------- Calendar (standard #21) ---------- */
.cal-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-title { font-size: 17px; font-weight: 700; min-width: 170px; text-align: center; }
.view-toggle { display: inline-flex; border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; }
.view-toggle button { border: none; background: var(--color-card); padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--color-text-muted); border-right: 1px solid var(--color-border); }
.view-toggle button:last-child { border-right: none; }
.view-toggle button[aria-pressed="true"] { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; background: var(--color-card); }
.cal-dow { background: var(--color-bg-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-muted); padding: 7px 8px; border-bottom: 1px solid var(--color-border); text-align: left; }
.cal-cell { min-height: 104px; border-bottom: 1px solid var(--color-border); border-right: 1px solid var(--color-border); padding: 5px 6px; position: relative; cursor: pointer; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell:hover { background: var(--color-bg-muted); }
.cal-cell .day-num { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.cal-cell.other-month { background: #fcfcfd; }
.cal-cell.other-month .day-num { color: #c4c9d2; }
.cal-cell.today .day-num { background: var(--color-primary); color: #fff; border-radius: 999px; padding: 1px 7px; display: inline-block; }
.cal-event { display: block; width: 100%; text-align: left; font-size: 11.5px; font-weight: 600; border: 1px solid var(--color-border); background: var(--color-bg-muted); color: var(--color-text); border-radius: 4px; padding: 1px 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-event:hover { border-color: var(--color-border-strong); }
.cal-event.type-meeting { background: var(--color-primary-soft); border-color: #bfdbfe; color: var(--color-primary-dark); }
.cal-event.type-deadline { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.cal-event.type-milestone { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.cal-more { font-size: 11px; color: var(--color-primary); font-weight: 600; cursor: pointer; background: none; border: none; padding: 1px 6px; }
.cal-week { display: grid; grid-template-columns: 56px repeat(7, 1fr); border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-card); overflow: hidden; }
.cal-hour-label { font-size: 10.5px; color: var(--color-text-muted); border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); padding: 2px 6px; height: 44px; }
.cal-week-cell { border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); height: 44px; position: relative; cursor: pointer; }
.cal-week-cell:hover { background: var(--color-bg-muted); }
.cal-week-event { position: absolute; left: 2px; right: 2px; font-size: 10.5px; font-weight: 600; border-radius: 4px; padding: 1px 5px; overflow: hidden; z-index: 2; border: 1px solid var(--color-border); cursor: pointer; text-align: left; }
.cal-list-day { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-muted); padding: 12px 4px 4px; position: sticky; top: 0; background: var(--color-bg); }
.cal-list-item { display: flex; gap: 12px; align-items: center; background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 9px 13px; margin-bottom: 6px; cursor: pointer; }
.cal-list-item:hover { border-color: var(--color-border-strong); }
.cal-list-time { font-size: 12px; color: var(--color-text-muted); min-width: 86px; }
.hover-card { position: fixed; z-index: 180; background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 12px 14px; width: 270px; font-size: 13px; pointer-events: none; }
.hover-card h4 { font-size: 13.5px; margin-bottom: 4px; }
.hover-card .meta { color: var(--color-text-muted); font-size: 12px; }
.fullscreen-host:fullscreen { background: var(--color-bg); padding: 20px; overflow: auto; }

/* ---------- Detail page (standard #29) ---------- */
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.detail-title { font-size: 22px; font-weight: 800; }
.breadcrumbs { font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 10px; }
.breadcrumbs a { color: var(--color-text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--color-primary); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); margin: 16px 0; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 14px; font-size: 13.5px; font-weight: 600; color: var(--color-text-muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.kv .k { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-muted); }
.kv .v { font-size: 14px; }
.timeline { list-style: none; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--color-border); font-size: 13.5px; }
.timeline li:last-child { border-bottom: none; }
.timeline .t-when { color: var(--color-text-muted); font-size: 12px; min-width: 130px; }

/* ---------- Files (standard #36 + #56) ---------- */
.dropzone { border: 2px dashed var(--color-border-strong); border-radius: var(--radius); padding: 36px 20px; text-align: center; color: var(--color-text-muted); cursor: pointer; background: var(--color-card); }
.dropzone.dragover { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary-dark); }
.file-row-ic { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--color-bg-muted); border: 1px solid var(--color-border); color: var(--color-text-muted); }
.thumb { width: 44px; height: 32px; object-fit: cover; border-radius: 4px; border: 1px solid var(--color-border); }
.lightbox-img { max-width: 100%; max-height: 70vh; border-radius: var(--radius); display: block; margin: 0 auto; }

/* ---------- Charts (standard #33), hand-rolled SVG ---------- */
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--color-text-muted); margin-top: 8px; }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12.5px; }
.bar-row .bar-label { width: 130px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.bar-row .bar-track { flex: 1; background: var(--color-bg-muted); border-radius: 4px; height: 16px; border: 1px solid var(--color-border); overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: #94a3b8; }
.bar-row .bar-val { min-width: 70px; font-weight: 600; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--color-bg); }
.login-wrap { width: 100%; max-width: 400px; padding: 16px; }
.login-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 44px 40px; }
.login-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.login-card h1 span { color: var(--color-primary); }
.login-sub { color: var(--color-text-muted); font-size: 14px; margin-bottom: 26px; }

/* Legacy LMS plan sidebar markup compatibility */
.toc .sidebar-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--color-text-muted); padding: 12px 12px 3px; }
.toc .sidebar-group { margin-bottom: 2px; }

/* Utility */
.muted { color: var(--color-text-muted); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.justify-between { justify-content: space-between; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
