/* =============================================================================
   CAFM System – Design System  (main.css)
   Bloomberg Terminal meets modern SaaS
   Primary: #1B4F72 | Secondary: #2E86C1 | Accent: #148F77
   ============================================================================= */

/* ── 1. CSS Custom Properties ──────────────────────────────────────────────── */
:root {
  /* Brand palette */
  --color-primary:    #1B4F72;
  --color-primary-d:  #13374f;
  --color-primary-l:  #2563a0;
  --color-secondary:  #2E86C1;
  --color-secondary-d:#1a6fa6;
  --color-secondary-l:#4fa0d8;
  --color-accent:     #148F77;
  --color-accent-d:   #0d6b59;
  --color-accent-l:   #1ab899;

  /* Semantic colors */
  --color-success:  #148F77;
  --color-warning:  #D4A017;
  --color-danger:   #C0392B;
  --color-info:     #2E86C1;

  /* Status badge colors */
  --badge-critical-bg:  #fde8e8;
  --badge-critical-fg:  #9b1c1c;
  --badge-high-bg:      #fef3e0;
  --badge-high-fg:      #92400e;
  --badge-medium-bg:    #dbeafe;
  --badge-medium-fg:    #1e40af;
  --badge-low-bg:       #f3f4f6;
  --badge-low-fg:       #374151;
  --badge-success-bg:   #d1fae5;
  --badge-success-fg:   #065f46;
  --badge-info-bg:      #dbeafe;
  --badge-info-fg:      #1e40af;

  /* Layout */
  --sidebar-width:      260px;
  --sidebar-width-sm:   64px;
  --header-height:      52px;

  /* Sidebar (always dark) */
  --sidebar-bg:         #0c1e2d;
  --sidebar-border:     #1a3349;
  --sidebar-header-bg:  #1B4F72;
  --sidebar-text:       #a8c0d0;
  --sidebar-text-active:#ffffff;
  --sidebar-icon:       #6a90a8;
  --sidebar-icon-active:#ffffff;
  --sidebar-hover-bg:   rgba(255,255,255,0.06);
  --sidebar-active-bg:  #2E86C1;
  --sidebar-group-label:#4d7a95;
  --sidebar-badge-bg:   #C0392B;
  --sidebar-badge-fg:   #ffffff;
  --sidebar-context-bg: rgba(0,0,0,0.25);
  --sidebar-context-fg: #7aacbf;

  /* Content area */
  --bg-page:         #f0f4f8;
  --bg-card:         #ffffff;
  --bg-card-alt:     #f9fafb;
  --bg-input:        #ffffff;
  --bg-hover:        #f8fafc;
  --bg-selected:     #eff6ff;
  --bg-code:         #f1f5f9;

  /* Text */
  --text-primary:    #1a2332;
  --text-secondary:  #4a5568;
  --text-muted:      #718096;
  --text-disabled:   #a0aec0;
  --text-inverse:    #ffffff;
  --text-link:       #2E86C1;
  --text-link-hover: #1B4F72;

  /* Borders */
  --border-color:    #e2e8f0;
  --border-color-d:  #cbd5e0;
  --border-color-l:  #f0f4f8;
  --border-radius-sm:  3px;
  --border-radius:     5px;
  --border-radius-md:  8px;
  --border-radius-lg:  12px;
  --border-radius-full:9999px;

  /* Header */
  --header-bg:       #ffffff;
  --header-border:   #e2e8f0;
  --header-text:     #1a2332;
  --header-icon:     #4a5568;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl:  0 20px 25px rgba(0,0,0,0.10), 0 10px 10px rgba(0,0,0,0.04);
  --shadow-inset: inset 0 2px 4px rgba(0,0,0,0.05);

  /* Spacing scale (4px base) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
               Helvetica, Arial, sans-serif, "Apple Color Emoji";
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

  --text-xs:   11px;
  --text-sm:   12px;
  --text-base: 13px;
  --text-md:   14px;
  --text-lg:   16px;
  --text-xl:   18px;
  --text-2xl:  22px;
  --text-3xl:  28px;

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed:1.65;

  --weight-normal:  400;
  --weight-medium:  500;
  --weight-semibold:600;
  --weight-bold:    700;

  /* Transitions */
  --transition-fast:  100ms ease;
  --transition-base:  180ms ease;
  --transition-slow:  300ms ease;

  /* Z-index layers */
  --z-base:    1;
  --z-dropdown:200;
  --z-sticky:  300;
  --z-modal:   400;
  --z-toast:   500;
  --z-tooltip: 600;
}

/* Dark theme for content area */
[data-theme="dark"] {
  --bg-page:      #0f1923;
  --bg-card:      #1a2535;
  --bg-card-alt:  #1e2c3d;
  --bg-input:     #1e2c3d;
  --bg-hover:     #1e2c3d;
  --bg-selected:  #1a3349;
  --bg-code:      #111d2b;
  --text-primary:    #e2e8f0;
  --text-secondary:  #a0aec0;
  --text-muted:      #718096;
  --text-disabled:   #4a5568;
  --border-color:    #1e3349;
  --border-color-d:  #2d4a65;
  --border-color-l:  #152433;
  --header-bg:       #1a2535;
  --header-border:   #1e3349;
  --header-text:     #e2e8f0;
  --header-icon:     #a0aec0;
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.4);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.4);
}

/* ── 2. Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--text-base);
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-page);
  overflow: hidden;
  height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text-link);
  text-decoration: none;
}
a:hover { color: var(--text-link-hover); text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; border: none; background: none; }

ul, ol { list-style: none; }

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--sp-4) 0;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* ── 3. App Shell Layout ────────────────────────────────────────────────────── */
#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow: hidden;
  transition: width var(--transition-slow);
  z-index: var(--z-sticky);
}

/* Main container (header + content) */
#main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Header */
#header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  z-index: var(--z-base);
  box-shadow: var(--shadow-xs);
}

/* Page content area */
#page-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  scroll-behavior: smooth;
}

/* Overlay for mobile sidebar */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-sticky) - 1);
}

/* ── 4. Sidebar Components ──────────────────────────────────────────────────── */

/* Logo / Brand area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4);
  height: var(--header-height);
  background: var(--sidebar-header-bg);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,0.2);
  text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-brand-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: #ffffff;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
}

/* Navigation scroll area */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-2) 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Group label */
.nav-group-label {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--sidebar-group-label);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  overflow: hidden;
}

/* Nav item */
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 7px var(--sp-4);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--sidebar-text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
}
.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}
.nav-item.active .nav-icon { color: var(--sidebar-icon-active); }
.nav-item:not(.active) .nav-icon { color: var(--sidebar-icon); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: rgba(255,255,255,0.6);
}

/* Sub-item (child navigation) */
.nav-item.sub-item {
  padding-left: calc(var(--sp-4) + 16px + var(--sp-3)); /* icon + gap */
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  padding-top: 5px;
  padding-bottom: 5px;
}
.nav-item.sub-item.active {
  background: rgba(46,134,193,0.3);
  color: var(--sidebar-text-active);
}
.nav-item.sub-item.active::before { display: none; }

.nav-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.nav-icon svg { width: 16px; height: 16px; }

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  flex-shrink: 0;
  background: var(--sidebar-badge-bg);
  color: var(--sidebar-badge-fg);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  min-width: 18px;
  height: 18px;
  border-radius: var(--border-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

.nav-chevron {
  flex-shrink: 0;
  color: var(--sidebar-icon);
  transition: transform var(--transition-base);
  display: flex;
  align-items: center;
}
.nav-chevron svg { width: 12px; height: 12px; }
.nav-item[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }

/* Nav section (collapsible children) */
.nav-section {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition-slow);
}
.nav-section.open { max-height: 400px; }

/* Sidebar footer / context indicator */
.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--sidebar-border);
  background: var(--sidebar-context-bg);
  flex-shrink: 0;
}
.sidebar-context-label {
  font-size: var(--text-xs);
  color: var(--sidebar-group-label);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-1);
}
.sidebar-context-value {
  font-size: var(--text-sm);
  color: var(--sidebar-context-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar divider */
.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: var(--sp-2) var(--sp-4);
}

/* Collapsed sidebar (icon-only) */
.sidebar-collapsed #sidebar {
  width: var(--sidebar-width-sm);
}
.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-badge,
.sidebar-collapsed .nav-chevron,
.sidebar-collapsed .nav-group-label,
.sidebar-collapsed .sidebar-footer { display: none; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 7px; gap: 0; }
.sidebar-collapsed .nav-item.sub-item { display: none; }
.sidebar-collapsed .nav-section { max-height: 0 !important; }

/* ── 5. Header Components ───────────────────────────────────────────────────── */
.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.breadcrumb-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb-item a {
  color: var(--text-secondary);
}
.breadcrumb-item a:hover { color: var(--color-secondary); text-decoration: none; }
.breadcrumb-item.active { color: var(--text-primary); font-weight: var(--weight-medium); }
.breadcrumb-sep {
  color: var(--text-disabled);
  flex-shrink: 0;
  font-size: var(--text-xs);
}

/* Global search */
.header-search {
  position: relative;
  flex-shrink: 0;
}
.header-search-input {
  width: 240px;
  height: 32px;
  padding: 0 var(--sp-3) 0 32px;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), width var(--transition-base);
  outline: none;
}
.header-search-input:focus {
  border-color: var(--color-secondary);
  width: 320px;
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(46,134,193,0.12);
}
.header-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  display: none;
}
.header-search-input:focus ~ .search-results-dropdown,
.search-results-dropdown:hover { display: block; }
.search-result-group-label {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  background: var(--bg-card-alt);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: background var(--transition-fast);
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-icon { color: var(--text-muted); flex-shrink: 0; }
.search-result-text { flex: 1; min-width: 0; }
.search-result-title { truncate: ellipsis; overflow: hidden; white-space: nowrap; }
.search-result-sub { font-size: var(--text-xs); color: var(--text-muted); }

/* Hamburger (mobile) */
.header-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  color: var(--header-icon);
  flex-shrink: 0;
}
.header-hamburger:hover { background: var(--bg-hover); }

/* Notification bell */
.header-notif {
  position: relative;
  flex-shrink: 0;
}
.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  color: var(--header-icon);
  transition: background var(--transition-fast);
}
.header-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: var(--color-danger);
  color: #fff;
  border-radius: var(--border-radius-full);
  font-size: 10px;
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--header-bg);
  line-height: 1;
}

/* User avatar dropdown */
.header-user {
  position: relative;
  flex-shrink: 0;
}
.header-user-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-2) 4px var(--sp-1);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.header-user-btn:hover { background: var(--bg-hover); }
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--border-radius-full);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
  text-transform: uppercase;
}
.user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--header-text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chevron { color: var(--text-muted); }

/* Dropdown panels (notif + user) */
.dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  min-width: 200px;
  display: none;
  overflow: hidden;
}
.dropdown-panel.open { display: block; }
.dropdown-header {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item.danger:hover { background: #fde8e8; }
.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--sp-1) 0;
}
.dropdown-footer {
  padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--border-color);
}

/* Language toggle pills */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--sp-2) var(--sp-4);
}
.lang-btn {
  flex: 1;
  padding: 3px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  background: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.lang-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.lang-btn:hover:not(.active) { border-color: var(--color-secondary); color: var(--color-secondary); }

/* ── 6. Page Layout Primitives ──────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
}
.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--sp-1);
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* Grid system */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

/* ── 7. Card Component ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-color-l);
}
.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.card-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.card-body { padding: var(--sp-5); }
.card-body-sm { padding: var(--sp-4); }
.card-body-flush { padding: 0; }
.card-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-color-l);
  background: var(--bg-card-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

/* KPI Card */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--kpi-accent, var(--color-primary));
}
.kpi-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-2);
}
.kpi-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--sp-1);
}
.kpi-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.kpi-trend {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: var(--sp-1);
}
.kpi-trend.up { color: var(--color-success); }
.kpi-trend.down { color: var(--color-danger); }

/* ── 8. Table Component ─────────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table thead {
  background: var(--bg-card-alt);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table th {
  padding: 9px var(--sp-3);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
}
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text-primary); background: var(--bg-hover); }
.table th.sort-asc::after  { content: ' ↑'; color: var(--color-secondary); }
.table th.sort-desc::after { content: ' ↓'; color: var(--color-secondary); }
.table td {
  padding: 8px var(--sp-3);
  border-bottom: 1px solid var(--border-color-l);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-hover); }
.table tr.selected td { background: var(--bg-selected); }
.table td.mono { font-family: var(--font-mono); font-size: var(--text-xs); }
.table td.nowrap { white-space: nowrap; }
.table td.actions {
  white-space: nowrap;
  text-align: right;
}
.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: var(--sp-12) var(--sp-6) !important;
  font-size: var(--text-sm);
}
.table-loading td {
  padding: var(--sp-8) !important;
  text-align: center;
}

/* Density toggle */
.table.dense th, .table.dense td { padding: 5px var(--sp-3); }
.table.compact th, .table.compact td { padding: 3px var(--sp-2); font-size: var(--text-xs); }

/* ── 9. Badge / Status Pill ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--sp-2);
  border-radius: var(--border-radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  line-height: 1.4;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--border-radius-full);
  background: currentColor;
}
.badge-critical { background: var(--badge-critical-bg); color: var(--badge-critical-fg); }
.badge-high     { background: var(--badge-high-bg);     color: var(--badge-high-fg);     }
.badge-medium   { background: var(--badge-medium-bg);   color: var(--badge-medium-fg);   }
.badge-low      { background: var(--badge-low-bg);      color: var(--badge-low-fg);      }
.badge-success  { background: var(--badge-success-bg);  color: var(--badge-success-fg);  }
.badge-info     { background: var(--badge-info-bg);     color: var(--badge-info-fg);     }
.badge-warning  { background: var(--badge-high-bg);     color: var(--badge-high-fg);     }
.badge-default  { background: var(--badge-low-bg);      color: var(--badge-low-fg);      }
/* Status-specific (easy mapping) */
.badge-open       { background: var(--badge-medium-bg); color: var(--badge-medium-fg); }
.badge-in_progress{ background: var(--badge-high-bg);   color: var(--badge-high-fg);   }
.badge-resolved   { background: var(--badge-success-bg);color: var(--badge-success-fg);}
.badge-closed     { background: var(--badge-low-bg);    color: var(--badge-low-fg);    }
.badge-draft      { background: var(--badge-low-bg);    color: var(--badge-low-fg);    }
.badge-active     { background: var(--badge-success-bg);color: var(--badge-success-fg);}
.badge-approved   { background: var(--badge-success-bg);color: var(--badge-success-fg);}
.badge-pending    { background: var(--badge-high-bg);   color: var(--badge-high-fg);   }
.badge-expired    { background: var(--badge-critical-bg);color: var(--badge-critical-fg);}

/* ── 10. Button Component ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 6px 14px;
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.4;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-d); border-color: var(--color-primary-d); }

.btn-secondary {
  background: var(--color-secondary);
  color: #fff;
  border-color: var(--color-secondary);
}
.btn-secondary:hover { background: var(--color-secondary-d); border-color: var(--color-secondary-d); }

.btn-accent {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-accent:hover { background: var(--color-accent-d); border-color: var(--color-accent-d); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: #fff; }

.btn-outline-secondary {
  background: transparent;
  color: var(--color-secondary);
  border-color: var(--color-secondary);
}
.btn-outline-secondary:hover { background: var(--color-secondary); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover { background: #a93226; border-color: #a93226; }

.btn-danger-outline {
  background: transparent;
  color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-danger-outline:hover { background: var(--color-danger); color: #fff; }

/* Button sizes */
.btn-xs { padding: 3px 8px; font-size: var(--text-xs); gap: var(--sp-1); }
.btn-sm { padding: 5px 10px; font-size: var(--text-xs); }
.btn-lg { padding: 9px 20px; font-size: var(--text-md); }
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--border-radius);
}
.btn-icon-xs { width: 24px; height: 24px; }
.btn-icon-lg { width: 40px; height: 40px; }
.btn-block { width: 100%; }

/* Button group */
.btn-group {
  display: inline-flex;
  border-radius: var(--border-radius);
  overflow: hidden;
}
.btn-group .btn {
  border-radius: 0;
  border-right-width: 0;
}
.btn-group .btn:first-child { border-radius: var(--border-radius) 0 0 var(--border-radius); }
.btn-group .btn:last-child  { border-radius: 0 var(--border-radius) var(--border-radius) 0; border-right-width: 1px; }

/* ── 11. Form Components ────────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}
.form-label.required::after {
  content: ' *';
  color: var(--color-danger);
}
.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}
.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  margin-top: var(--sp-1);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.form-control {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 var(--sp-3);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(46,134,193,0.12);
}
.form-control:disabled {
  background: var(--bg-card-alt);
  color: var(--text-disabled);
  cursor: not-allowed;
}
.form-control.error {
  border-color: var(--color-danger);
}
.form-control.error:focus {
  box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}

textarea.form-control {
  height: auto;
  padding: var(--sp-2) var(--sp-3);
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23718096' stroke-width='2' d='M4 6l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: var(--sp-8);
}

/* Inline form group */
.form-inline { display: flex; align-items: flex-end; gap: var(--sp-3); }
.form-inline .form-group { margin-bottom: 0; flex: 1; }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-alt);
  flex-wrap: wrap;
}
.filter-bar .form-control { height: 30px; font-size: var(--text-xs); }
.filter-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Checkbox / Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--text-sm);
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--color-secondary);
  flex-shrink: 0;
}

/* ── 12. Modal Component ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: calc(var(--z-modal) - 1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(-10px);
  transition: transform var(--transition-base);
  overflow: hidden;
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1000px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--border-radius);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body {
  padding: var(--sp-5);
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  flex-shrink: 0;
  background: var(--bg-card-alt);
}

/* ── 13. Toast Notifications ────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--sp-3));
  right: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: 380px;
  width: 100%;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  pointer-events: all;
  transform: translateX(calc(100% + var(--sp-4)));
  opacity: 0;
  transition: transform var(--transition-base), opacity var(--transition-base);
  border-left: 3px solid var(--border-color);
}
.toast.visible {
  transform: translateX(0);
  opacity: 1;
}
.toast.removing {
  transform: translateX(calc(100% + var(--sp-4)));
  opacity: 0;
}
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}
.toast-message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
}
.toast-close {
  flex-shrink: 0;
  color: var(--text-muted);
  padding: 2px;
  border-radius: var(--border-radius-sm);
}
.toast-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.toast-success  { border-left-color: var(--color-success); }
.toast-error    { border-left-color: var(--color-danger);  }
.toast-warning  { border-left-color: var(--color-warning); }
.toast-info     { border-left-color: var(--color-info);    }
.toast-success  .toast-icon { color: var(--color-success); }
.toast-error    .toast-icon { color: var(--color-danger);  }
.toast-warning  .toast-icon { color: var(--color-warning); }
.toast-info     .toast-icon { color: var(--color-info);    }

/* ── 14. Loading States ─────────────────────────────────────────────────────── */
/* Full-page spinner overlay */
.page-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  z-index: 10;
}

/* Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-color);
  border-top-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Button spinner */
.btn .spinner { border-color: rgba(255,255,255,0.3); border-top-color: #fff; }
.btn-ghost .spinner, .btn-outline .spinner {
  border-color: rgba(0,0,0,0.15);
  border-top-color: var(--color-secondary);
}

/* Skeleton screen */
.skeleton {
  border-radius: var(--border-radius);
  background: linear-gradient(90deg, var(--bg-card-alt) 25%, var(--border-color-l) 50%, var(--bg-card-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 13px; margin: 4px 0; }
.skeleton-text.w-1-2 { width: 50%; }
.skeleton-text.w-3-4 { width: 75%; }
.skeleton-text.w-1-4 { width: 25%; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: var(--sp-2); }
.skeleton-badge { height: 20px; width: 60px; border-radius: var(--border-radius-full); display: inline-block; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-block; }
.skeleton-btn { height: 32px; width: 90px; border-radius: var(--border-radius); display: inline-block; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--text-muted);
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--sp-4);
  opacity: 0.4;
}
.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}
.empty-state-desc { font-size: var(--text-sm); max-width: 320px; margin: 0 auto var(--sp-4); }

/* ── 15. Pagination ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-sm);
}
.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-card);
}
.page-btn:hover { border-color: var(--color-secondary); color: var(--color-secondary); }
.page-btn.active { background: var(--color-secondary); border-color: var(--color-secondary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }

/* ── 16. Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  gap: 0;
  margin-bottom: var(--sp-4);
}
.tab-item {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--color-secondary); border-bottom-color: var(--color-secondary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 17. Utility Classes ────────────────────────────────────────────────────── */
/* Display */
.d-flex   { display: flex; }
.d-grid   { display: grid; }
.d-block  { display: block; }
.d-none   { display: none; }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }

/* Flex */
.align-center   { align-items: center; }
.align-start    { align-items: flex-start; }
.align-end      { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-end    { justify-content: flex-end; }
.justify-between{ justify-content: space-between; }
.flex-1  { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

/* Spacing */
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.ms-auto { margin-left: auto; }
.me-auto { margin-right: auto; }
.p-0 { padding: 0; }

/* Text */
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md   { font-size: var(--text-md); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger); }
.text-warning   { color: var(--color-warning); }
.text-info      { color: var(--color-info); }
.text-white     { color: #ffffff; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-mono   { font-family: var(--font-mono); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold   { font-weight: var(--weight-bold); }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Border */
.border       { border: 1px solid var(--border-color); }
.border-top   { border-top: 1px solid var(--border-color); }
.rounded      { border-radius: var(--border-radius); }
.rounded-full { border-radius: var(--border-radius-full); }

/* Background */
.bg-card    { background: var(--bg-card); }
.bg-page    { background: var(--bg-page); }
.bg-primary { background: var(--color-primary); }

/* Width / Height */
.w-full    { width: 100%; }
.h-full    { height: 100%; }
.min-w-0   { min-width: 0; }
.max-w-400 { max-width: 400px; }
.max-w-600 { max-width: 600px; }

/* Misc */
.cursor-pointer { cursor: pointer; }
.select-none    { user-select: none; }
.overflow-hidden { overflow: hidden; }
.position-relative { position: relative; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ── 18. Responsive Breakpoints ─────────────────────────────────────────────── */

/* Tablet: collapse sidebar to icon-only */
@media (max-width: 1024px) {
  #app { }
  #sidebar {
    width: var(--sidebar-width-sm);
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: var(--z-sticky);
  }
  #main-container {
    margin-left: var(--sidebar-width-sm);
  }
  .sidebar-brand-text,
  .nav-label,
  .nav-badge,
  .nav-chevron,
  .nav-group-label,
  .sidebar-footer { display: none !important; }
  .nav-item { justify-content: center; padding: 8px !important; gap: 0 !important; }
  .nav-item.sub-item { display: none !important; }
  .nav-section { max-height: 0 !important; }
  .sidebar-brand { justify-content: center; }
  .sidebar-brand-icon { margin: 0; }
}

/* Mobile: hidden sidebar + hamburger */
@media (max-width: 768px) {
  #sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }
  #sidebar-overlay { display: none; }
  #sidebar.mobile-open ~ #sidebar-overlay,
  body.sidebar-open #sidebar-overlay { display: block; }
  #main-container { margin-left: 0; }
  .header-hamburger { display: flex; }

  /* Restore all sidebar text on mobile (shown as full overlay) */
  .sidebar-brand-text,
  .nav-label,
  .nav-badge,
  .nav-chevron,
  .nav-group-label,
  .sidebar-footer { display: flex !important; }
  .nav-item { justify-content: flex-start !important; padding: 7px var(--sp-4) !important; gap: var(--sp-3) !important; }
  .nav-item.sub-item { display: flex !important; }

  /* Content padding */
  #page-content { padding: var(--sp-4); }
  .page-title { font-size: var(--text-lg); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .header-search-input { width: 160px; }
  .header-search-input:focus { width: 200px; }
  .user-name { display: none; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  #page-content { padding: var(--sp-3); }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ── 19. Misc Components ────────────────────────────────────────────────────── */

/* Pill tabs (for filter toggles) */
.pill-tabs {
  display: inline-flex;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-full);
  padding: 2px;
  gap: 2px;
}
.pill-tab {
  padding: 3px 12px;
  border-radius: var(--border-radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.pill-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  font-weight: var(--weight-semibold);
}
.pill-tab:hover:not(.active) { color: var(--text-primary); }

/* Tooltips (CSS-only hover) */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,25,35,0.92);
  color: #fff;
  font-size: var(--text-xs);
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
}
[data-tooltip]:hover::after { opacity: 1; }

/* Divider with label */
.divider-label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: var(--sp-4) 0;
}
.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* Progress bar */
.progress {
  height: 6px;
  background: var(--border-color);
  border-radius: var(--border-radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--color-secondary);
  border-radius: var(--border-radius-full);
  transition: width var(--transition-slow);
}
.progress-bar.success { background: var(--color-success); }
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.danger  { background: var(--color-danger); }

/* Alert */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  border: 1px solid transparent;
  margin-bottom: var(--sp-4);
}
.alert-title { font-weight: var(--weight-semibold); margin-bottom: 2px; }
.alert-info    { background: var(--badge-info-bg);     color: var(--badge-info-fg);     border-color: rgba(30,64,175,0.2); }
.alert-success { background: var(--badge-success-bg);  color: var(--badge-success-fg);  border-color: rgba(6,95,70,0.2);   }
.alert-warning { background: var(--badge-high-bg);     color: var(--badge-high-fg);     border-color: rgba(146,64,14,0.2); }
.alert-error   { background: var(--badge-critical-bg); color: var(--badge-critical-fg); border-color: rgba(155,28,28,0.2); }

/* ── 20. Dashboard layout ────────────────────────────────────────────────────── */

/* Main two-column dashboard grid */
.dash-main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.dash-left, .dash-right { display: flex; flex-direction: column; gap: var(--sp-4); }
@media (max-width: 1200px) { .dash-main { grid-template-columns: 1fr; } }

/* KPI card enhancements */
.kpi-header-row  { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi-spark       { flex: 0 0 64px; height: 32px; }
.kpi-badges      { display: flex; gap: 4px; flex-wrap: wrap; margin-top: var(--sp-1); }
.kpi-badges .badge { font-size: var(--font-size-xs); }

/* Stats row / chips */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-subtle);
  border-radius: var(--border-radius-md);
}
.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
}
.stat-chip-label { color: var(--text-muted); }
.stat-chip-value { font-weight: var(--weight-semibold); }

/* Stat items (used in card footers) */
.stat-item  { text-align: center; }
.stat-value { font-weight: var(--weight-bold); font-size: var(--text-lg); display: block; }
.stat-label { font-size: var(--font-size-xs); color: var(--text-muted); }

/* Deadlines */
.deadline-section       { margin-bottom: var(--sp-3); }
.deadline-section-title { font-weight: var(--weight-semibold); font-size: var(--text-sm); margin-bottom: var(--sp-1); color: var(--text-secondary); }
.deadline-item          { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border-color); font-size: var(--text-sm); }
.deadline-item:last-child { border-bottom: none; }
.deadline-name          { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deadline-date          { flex: 0 0 auto; margin-left: var(--sp-2); }

/* Mini progress bar (inline in tables) */
.mini-progress {
  display: inline-block;
  width: 80px;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
}
.mini-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-primary);
  transition: width 0.3s ease;
}

/* Progress bar rows (chart-style, used in budget bars) */
.progress-bar-row    { margin-bottom: var(--sp-2); }
.progress-bar-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; font-size: var(--text-sm); }
.progress-bar-label  { color: var(--text-secondary); }
.progress-bar-value  { font-weight: var(--weight-semibold); }
.progress-bar-track  { height: 10px; background: var(--bg-subtle); border-radius: 5px; overflow: hidden; }
.progress-bar-fill   { height: 100%; border-radius: 5px; transition: width 0.3s ease; }
.progress-bar-legend { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 2px; }

/* ── 21. Spatial hierarchy cards ─────────────────────────────────────────────── */

/* Portfolio cards */
.portfolio-card-icon   { font-size: 2rem; margin-bottom: var(--sp-2); }
.portfolio-card-name   { font-weight: var(--weight-semibold); font-size: var(--text-lg); margin-bottom: var(--sp-1); }
.portfolio-card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--sp-2); }
.portfolio-card-stats  { display: flex; gap: var(--sp-4); margin-top: auto; padding-top: var(--sp-2); border-top: 1px solid var(--border-color); }

/* Site cards */
.site-card-info   { flex: 1; min-width: 0; }
.site-card-name   { font-weight: var(--weight-semibold); font-size: var(--text-md); margin-bottom: var(--sp-1); }
.site-card-addr   { font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--sp-2); }
.site-card-stats  { display: flex; gap: var(--sp-4); margin-top: auto; padding-top: var(--sp-2); border-top: 1px solid var(--border-color); }

/* Site header bar */
.site-header-bar   { display: flex; gap: var(--sp-4); align-items: flex-start; margin-bottom: var(--sp-4); }
.site-header-info  { flex: 1; }
.site-header-score { flex: 0 0 auto; }

/* Building cards */
.building-card-top    { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--sp-2); }
.building-card-name   { font-weight: var(--weight-semibold); font-size: var(--text-md); }
.building-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.building-card-stats  { display: flex; gap: var(--sp-4); margin-top: auto; padding-top: var(--sp-2); border-top: 1px solid var(--border-color); }

/* Building meta bar */
.building-meta-bar { margin-bottom: var(--sp-4); }

/* Energy class badges */
.energy-badge   { font-weight: var(--weight-bold); padding: 2px 8px; border-radius: var(--border-radius-sm); font-size: var(--font-size-xs); }
.energy-badge-A { background: #15803d; color: #fff; }
.energy-badge-B { background: #65a30d; color: #fff; }
.energy-badge-C { background: #ca8a04; color: #fff; }
.energy-badge-D { background: #ea580c; color: #fff; }
.energy-badge-E { background: #dc2626; color: #fff; }
.energy-badge-F { background: #991b1b; color: #fff; }
.energy-badge-G { background: #7f1d1d; color: #fff; }

/* Map placeholder (used in site cards) */
.map-placeholder {
  width: 100%;
  height: 100px;
  background: var(--bg-subtle);
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}
.map-pin   { font-size: 1.5rem; margin-bottom: 2px; }
.map-label { font-size: var(--font-size-xs); }

/* ── 22. Tabs component ──────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: var(--sp-4);
  overflow-x: auto;
}
.tab-btn {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ── 23. Space detail components ─────────────────────────────────────────────── */

/* Sensor grid */
.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-3);
}
.sensor-card {
  padding: var(--sp-3);
  background: var(--bg-subtle);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
}
.sensor-header    { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-1); }
.sensor-type      { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.sensor-value-lg  { font-size: var(--text-xl); font-weight: var(--weight-bold); margin-bottom: var(--sp-1); }
.sensor-sparkline { height: 28px; margin-bottom: var(--sp-1); }

/* Hazard list */
.hazard-list { list-style: none; padding: 0; margin: 0; }
.hazard-item { display: flex; align-items: center; gap: var(--sp-2); padding: 6px 0; border-bottom: 1px solid var(--border-color); font-size: var(--text-sm); }
.hazard-item:last-child { border-bottom: none; }

/* Filter bar */
.filter-bar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-3); }

/* ── 24. Asset management components ─────────────────────────────────────────── */

/* Health dot */
.health-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
}
.health-dot--good { background: var(--color-success); }
.health-dot--warn { background: var(--color-warning); }
.health-dot--bad  { background: var(--color-danger); }
.health-dot--none { background: var(--text-muted); opacity: 0.3; }

/* Asset tree */
.asset-tree { padding: var(--sp-2) 0; }
.tree-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 8px;
  font-size: var(--text-sm);
  border-radius: var(--border-radius-sm);
}
.tree-item:hover { background: var(--bg-subtle); }
.tree-toggle {
  cursor: pointer;
  user-select: none;
  width: 18px;
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.tree-label { text-decoration: none; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.tree-label:hover { color: var(--color-primary); }
.tree-children.collapsed { display: none; }

/* Bulk actions bar */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--badge-info-bg);
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-3);
}

/* View toggle (table/tree/kanban) */
.view-toggle { display: flex; gap: 0; }
.view-toggle .btn { border-radius: 0; }
.view-toggle .btn:first-child { border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm); }
.view-toggle .btn:last-child  { border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0; }

/* Sortable column header */
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--color-primary); }

/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); flex-wrap: wrap; }
.breadcrumb-link { color: var(--color-secondary); text-decoration: none; }
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); }

/* Criticality stars */
.criticality-stars { color: var(--color-warning); font-size: var(--text-lg); letter-spacing: 2px; }

/* Anomaly list */
.anomaly-list { list-style: none; padding: 0; margin: 8px 0 0; }
.anomaly-item { display: flex; align-items: center; gap: var(--sp-2); padding: 4px 0; font-size: var(--text-sm); }

/* QR placeholder */
.qr-placeholder {
  width: 180px; height: 180px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-subtle);
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius-md);
  font-family: monospace;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Hierarchy visual */
.hierarchy-visual { padding: var(--sp-2) 0; }
.hier-node {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  margin-bottom: 2px;
}
.hier-node--parent { background: transparent; }
.hier-node--current { background: var(--badge-info-bg); border: 1px solid var(--color-secondary); font-weight: var(--weight-semibold); }
.hier-node--child { background: var(--bg-subtle); }
.hier-node-link { color: var(--color-secondary); text-decoration: none; }
.hier-node-link:hover { text-decoration: underline; }
.hier-connector { width: 1px; height: 12px; background: var(--border-color); }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border-color); }
.timeline-item { position: relative; margin-bottom: var(--sp-3); }
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--bg-primary);
  z-index: 1;
}
.timeline-content { padding-bottom: var(--sp-1); }
.timeline-header  { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* ── 25. Kanban board ────────────────────────────────────────────────────────── */

.kanban-board {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
  min-height: 400px;
}
.kanban-col {
  flex: 1 0 220px;
  min-width: 220px;
  max-width: 320px;
  background: var(--bg-subtle);
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
}
.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-2) var(--sp-3);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-color);
}
.kanban-col-title { text-transform: capitalize; }
.kanban-col-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--bg-primary);
  font-size: var(--font-size-xs);
  font-weight: var(--weight-semibold);
}
.kanban-col-body {
  flex: 1;
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  overflow-y: auto;
  min-height: 80px;
}
.kanban-col-body.drag-over { background: rgba(46, 134, 193, 0.05); outline: 2px dashed var(--color-secondary); outline-offset: -2px; }
.kanban-empty { text-align: center; color: var(--text-muted); font-size: var(--text-sm); padding: var(--sp-4) 0; }

.kanban-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: var(--sp-2) var(--sp-3);
  cursor: grab;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.kanban-card:hover { box-shadow: var(--shadow-sm); }
.kanban-card.dragging { opacity: 0.5; transform: rotate(2deg); }
.kanban-card-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.kanban-card-title {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  text-decoration: none;
  line-height: 1.4;
  margin-bottom: 4px;
}
.kanban-card-title:hover { color: var(--color-primary); }
.kanban-card-meta { font-size: var(--font-size-xs); color: var(--text-muted); margin-bottom: 4px; }
.kanban-card-footer { display: flex; justify-content: space-between; font-size: var(--font-size-xs); }

/* ── 26. Calendar (maintenance) ──────────────────────────────────────────────── */

.cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.cal-title { font-weight: var(--weight-semibold); font-size: var(--text-lg); min-width: 180px; text-align: center; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border-color);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}
.cal-dow {
  background: var(--bg-subtle);
  padding: var(--sp-1) var(--sp-2);
  text-align: center;
  font-size: var(--font-size-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
}
.cal-day {
  background: var(--bg-primary);
  min-height: 80px;
  padding: var(--sp-1);
  position: relative;
}
.cal-day--empty { background: var(--bg-subtle); }
.cal-day--today { background: rgba(46, 134, 193, 0.05); }
.cal-day--today .cal-day-num { color: var(--color-primary); font-weight: var(--weight-bold); }
.cal-day-num { font-size: var(--text-sm); display: block; margin-bottom: 2px; }
.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event {
  font-size: var(--font-size-xs);
  padding: 1px 4px;
  border-radius: 2px;
  background: var(--badge-info-bg);
  color: var(--badge-info-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-event--overdue { background: var(--badge-critical-bg); color: var(--badge-critical-fg); }

/* ── 27. Work order form components ──────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3) var(--sp-4);
}
.form-group-full { grid-column: 1 / -1; }

.form-hint {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Asset picker dropdown */
.asset-picker { position: relative; }
.dropdown-results {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}
.dropdown-item {
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dropdown-item:hover { background: var(--bg-subtle); }

/* File chips */
.file-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: var(--text-sm);
}
.file-chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  padding: 0;
  line-height: 1;
}
.file-chip-remove:hover { color: var(--color-danger); }

/* AI insight card */
.card--ai { border-left: 3px solid var(--color-secondary); }
.ai-recommendation { padding: var(--sp-2) var(--sp-3); background: var(--bg-subtle); border-radius: var(--border-radius-sm); font-size: var(--text-sm); }

/* WO description */
.wo-description { white-space: pre-wrap; line-height: 1.6; }

/* Overdue row highlight */
.row-overdue { background: rgba(192, 57, 43, 0.04); }
.row-overdue td { border-bottom-color: rgba(192, 57, 43, 0.15); }

/* Sensor card clickable + selected */
.sensor-card--clickable { cursor: pointer; transition: border-color 0.15s ease; }
.sensor-card--clickable:hover { border-color: var(--color-secondary); }
.sensor-card.selected { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(27, 79, 114, 0.15); }

/* Text link utility */
.text-link { color: var(--color-secondary); text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-3) 0;
  font-size: var(--text-sm);
}
.pagination-dots { color: var(--text-muted); padding: 0 4px; }

/* Responsive form grid */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .kanban-board { flex-direction: column; }
  .kanban-col { max-width: none; min-width: 0; }
}

/* ── 28. Ticket / Service-Desk ───────────────────────────────────────────── */
.ticket-row--unread td { font-weight: 600; }
.ticket-row--unread td:first-child { border-left: 3px solid var(--color-primary); }
.ticket-subject { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-bubble {
  background: var(--color-bg-muted); border-radius: var(--radius-lg);
  padding: 16px 20px; margin: 12px 0; white-space: pre-wrap; line-height: 1.55;
}
.card--ai { border-left: 3px solid var(--color-info); }

/* ── 29. Contracts – deadline rows ──────────────────────────────────────── */
.row-deadline-red td  { background: rgba(220,53,69,.07); }
.row-deadline-amber td { background: rgba(255,193,7,.08); }

/* ── 30. Confidence bar (AI / contracts / insights) ─────────────────────── */
.confidence-bar {
  display: inline-block; width: 80px; height: 8px; border-radius: 4px;
  background: var(--color-border); overflow: hidden; vertical-align: middle;
}
.confidence-fill {
  height: 100%; border-radius: 4px; background: var(--color-primary);
  transition: width .3s ease;
}

/* ── 31. Energy – KPI row ───────────────────────────────────────────────── */
.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi-card {
  flex: 1 1 180px; background: var(--color-bg-card); border-radius: var(--radius-md);
  padding: 16px; box-shadow: var(--shadow-xs); text-align: center; min-width: 150px;
}
.kpi-value { font-size: 1.6rem; font-weight: 700; margin-bottom: 2px; }
.kpi-label { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* ── 32. Budget ─────────────────────────────────────────────────────────── */
.budget-summary-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.budget-bar {
  position: relative; height: 28px; background: var(--color-border);
  border-radius: var(--radius-sm); overflow: visible; margin: 12px 0;
}
.budget-bar-fill {
  height: 100%; border-radius: var(--radius-sm); transition: width .4s ease;
}
.budget-bar-marker {
  position: absolute; top: -4px; bottom: -4px; width: 2px;
  background: var(--color-text-muted); z-index: 1;
}
.budget-bar-marker::after {
  content: attr(data-label); position: absolute; bottom: -18px; left: 50%;
  transform: translateX(-50%); font-size: 10px; color: var(--color-text-muted);
  white-space: nowrap;
}
.budget-ok .budget-bar-fill   { background: var(--color-success); }
.budget-warning .budget-bar-fill { background: var(--color-warning); }
.budget-over .budget-bar-fill { background: var(--color-danger); }
.tree-toggle { cursor: pointer; user-select: none; }
.tree-toggle::before { content: '▶'; display: inline-block; width: 1em; transition: transform .15s; }
.tree-toggle.open::before { transform: rotate(90deg); }
.tree-child { display: none; }
.tree-child.visible { display: table-row; }

/* ── 33. Workplaces – floorplan grid ────────────────────────────────────── */
.wp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; padding: 16px;
}
.wp-cell {
  background: var(--color-bg-card); border: 2px solid var(--color-border);
  border-radius: var(--radius-md); padding: 12px; text-align: center;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.wp-cell:hover { box-shadow: var(--shadow-md); }
.wp-cell.available  { border-color: var(--color-success); }
.wp-cell.booked     { border-color: var(--color-warning); }
.wp-cell.occupied   { border-color: var(--color-text-muted); }
.wp-cell.blocked    { border-color: var(--color-border); opacity: .55; cursor: not-allowed; }
.wp-cell-icon { font-size: 1.5rem; margin-bottom: 4px; }
.wp-cell-name { font-weight: 600; font-size: var(--font-size-sm); }
.wp-cell-status { font-size: var(--font-size-xs); margin-top: 2px; }
.wp-cell-meta { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 4px; }
.wp-legend { display: flex; gap: 16px; align-items: center; padding: 8px 16px; }
.wp-legend-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 4px; vertical-align: middle;
}

/* ── 34. Insights – feed cards ──────────────────────────────────────────── */
.insight-card {
  background: var(--color-bg-card); border-radius: var(--radius-md);
  padding: 16px 20px; margin-bottom: 12px; border-left: 4px solid var(--color-border);
  box-shadow: var(--shadow-xs); transition: border-color .15s;
}
.insight-card--unread { border-left-color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 3%, var(--color-bg-card)); }
.insight-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.insight-card-title { font-weight: 600; flex: 1; }
.insight-card-ref { font-size: var(--font-size-xs); }
.insight-card-ref a { color: var(--color-primary); text-decoration: none; }
.insight-card-ref a:hover { text-decoration: underline; }
.insight-card-confidence { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: var(--font-size-sm); }
.insight-card-actions { display: flex; gap: 8px; margin-top: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }

/* ── 35. Reports – template tiles ───────────────────────────────────────── */
.report-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.report-tile {
  background: var(--color-bg-card); border: 2px solid var(--color-border);
  border-radius: var(--radius-md); padding: 16px; text-align: center;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.report-tile:hover { box-shadow: var(--shadow-md); }
.report-tile.selected { border-color: var(--color-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 25%, transparent); }
.report-tile-icon { font-size: 2rem; margin-bottom: 6px; }
.report-tile-name { font-weight: 600; font-size: var(--font-size-sm); margin-bottom: 4px; }
.report-tile-desc { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.report-params { background: var(--color-bg-muted); border-radius: var(--radius-md); padding: 16px; margin-bottom: 16px; }

/* ── 36. Settings – permission matrix & misc ────────────────────────────── */
.perm-table th, .perm-table td { padding: 6px 10px; }
.perm-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.section-title { font-size: var(--font-size-lg); font-weight: 700; margin: 24px 0 12px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ── 37. Sensor status dots ─────────────────────────────────────────────── */
.sensor-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.sensor-status.online  { background: var(--color-success); }
.sensor-status.offline { background: var(--color-danger); }
.sensor-status.warning { background: var(--color-warning); }

/* ── Responsive – Phase 15 additions ────────────────────────────────────── */
@media (max-width: 768px) {
  .grid-3 { grid-template-columns: 1fr; }
  .wp-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .report-templates { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .kpi-row { flex-direction: column; }
  .budget-summary-grid { grid-template-columns: 1fr 1fr; }
}

/* ── 38. AJAX Select / Autocomplete widget ───────────────────────────────── */
.ajax-select { position: relative; }
.ajax-select-dropdown {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color-d);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  max-height: 220px; overflow-y: auto;
  z-index: calc(var(--z-modal) + 10);
}
.ajax-select-item {
  padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  font-size: var(--text-md); line-height: var(--leading-normal);
  transition: background var(--transition-fast);
}
.ajax-select-item:last-child { border-bottom: none; }
.ajax-select-item:hover { background: var(--bg-hover); }
.ajax-select-empty {
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-style: italic;
}

/* ── 39. Print styles ───────────────────────────────────────────────────────── */
@media print {
  #sidebar, #header, #toast-container { display: none !important; }
  #main-container { margin: 0 !important; }
  #page-content { overflow: visible !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  .btn { display: none !important; }
}
