/* ============================================================
   ZENI FLOW — Design System
   Operational Intelligence Platform
   Light Mode Default · Zeni Family Theme
   ============================================================ */

/* ---------- RESET ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- DESIGN TOKENS — LIGHT (default) ---------- */
:root {
  /* Backgrounds */
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --bg-card-hover: #fafbfc;
  --bg-input: #f8fafc;
  --bg-sidebar: #1e293b;
  --bg-sidebar-hover: #273548;
  --bg-topbar: #ffffff;

  /* Borders */
  --border: #e2e8f0;
  --border-light: #cbd5e1;

  /* Text */
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-dim: #cbd5e1;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;

  /* Brand */
  --accent: #ffcc00;
  --accent-hover: #f0bf00;
  --accent-text: #1e293b;
  --accent-secondary: #3b82f6;

  /* Status */
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.1);
  --orange: #f97316;
  --orange-bg: rgba(249, 115, 22, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.1);
  --cyan: #06b6d4;
  --cyan-bg: rgba(6, 182, 212, 0.1);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.1);
  --pink: #ec4899;

  /* Geometry */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --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.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --transition: 0.18s ease;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- DARK MODE OVERRIDES ---------- */
[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #181b23;
  --bg-card-hover: #1e2230;
  --bg-input: #1a1d27;
  --bg-sidebar: #111318;
  --bg-sidebar-hover: #1a1d25;
  --bg-topbar: #111318;
  --border: #252831;
  --border-light: #2a2e3a;
  --text: #e4e7ef;
  --text-secondary: #a1a8bf;
  --text-muted: #7a8199;
  --text-dim: #4a5068;
  --text-sidebar: #7a8199;
  --text-sidebar-active: #ffffff;
  --accent: #ffcc00;
  --accent-hover: #f0bf00;
  --accent-text: #1e293b;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
  --green-bg: rgba(34, 197, 94, 0.15);
  --yellow-bg: rgba(234, 179, 8, 0.15);
  --orange-bg: rgba(249, 115, 22, 0.15);
  --red-bg: rgba(239, 68, 68, 0.15);
  --blue-bg: rgba(59, 130, 246, 0.15);
  --cyan-bg: rgba(6, 182, 212, 0.15);
  --purple-bg: rgba(139, 92, 246, 0.15);
}

/* ---------- BASE ---------- */
html {
  font-size: 14px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

/* ---------- APP SHELL ---------- */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: relative;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 24px;
}

.brand-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
  display: block;
}

.brand-sub {
  font-size: 0.62rem;
  color: var(--text-sidebar);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 16px 14px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  font-size: 0.82rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: var(--transition);
}

.nav-item:hover {
  color: #e2e8f0;
  background: var(--bg-sidebar-hover);
}

.nav-item:hover svg {
  opacity: 1;
}

.nav-item.active {
  color: var(--text-sidebar-active);
  background: rgba(255, 204, 0, 0.12);
}

.nav-item.active svg {
  opacity: 1;
  stroke: var(--accent);
}

.nav-badge {
  position: absolute;
  right: 10px;
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

.nav-badge:empty {
  display: none;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  font-size: 0.75rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.theme-toggle:hover {
  color: #e2e8f0;
  background: var(--bg-sidebar-hover);
}

.theme-toggle svg {
  flex-shrink: 0;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
}

.user-role {
  font-size: 0.65rem;
  color: var(--text-sidebar);
}

/* ---------- MAIN CONTENT ---------- */
.main-content {
  flex: 1;
  min-width: 0;
  /* KEY: prevents flex child from overflowing */
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  background: var(--bg-topbar);
}

.page-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.breadcrumb {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* CRITICAL: prevent horizontal overflow */
  padding: 20px 24px;
}

.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  transition: var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-xs);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.72rem;
}

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

.btn-ghost:hover {
  background: var(--bg-card);
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

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

/* ---------- CARDS ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  overflow: hidden;
  /* contain everything inside */
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.card-subtitle {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.card-body {
  padding: 14px 18px;
}

/* ---------- GRIDS ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

/* ---------- FLOW PIPELINE ---------- */
.flow-pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.flow-step {
  padding: 14px 12px;
  text-align: center;
  position: relative;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.flow-step:last-child {
  border-right: none;
}

.flow-step:hover {
  background: var(--bg-card-hover);
}

.flow-count {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.flow-label {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
}

/* ---------- KPI ROW ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}

.kpi-sub {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ---------- KANBAN BOARD ---------- */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  height: calc(100vh - var(--topbar-h) - 64px);
}

.kanban-column {
  min-width: 0;
  /* prevent overflow */
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.kanban-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.kanban-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.kanban-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.kanban-count {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-muted);
  flex-shrink: 0;
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kanban-card {
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.kanban-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kanban-card.priority-critical {
  border-left-color: var(--red);
}

.kanban-card.priority-high {
  border-left-color: var(--orange);
}

.kanban-card.priority-medium {
  border-left-color: var(--yellow);
}

.kanban-card.priority-low {
  border-left-color: var(--blue);
}

.kanban-card-title {
  font-size: 0.76rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
  word-break: break-word;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 0;
}

.kanban-sla {
  font-size: 0.62rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kanban-sla.breached {
  color: var(--red);
  font-weight: 700;
}

.kanban-sla.warning {
  color: var(--orange);
}

.kanban-assignee {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.mini-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.48rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- WORK ORDER CARDS ---------- */
.wo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.wo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  border-top: 3px solid transparent;
  cursor: pointer;
  overflow: hidden;
}

.wo-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.wo-card.priority-critical {
  border-top-color: var(--red);
}

.wo-card.priority-high {
  border-top-color: var(--orange);
}

.wo-card.priority-medium {
  border-top-color: var(--yellow);
}

.wo-card.priority-low {
  border-top-color: var(--blue);
}

.wo-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.wo-card-id {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.wo-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
  word-break: break-word;
}

.wo-card-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.wo-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wo-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------- PM GRID ---------- */
.pm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.pm-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  overflow: hidden;
}

.pm-card:hover {
  box-shadow: var(--shadow-sm);
}

.pm-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 3px;
  word-break: break-word;
}

.pm-card-asset {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.pm-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  margin-bottom: 4px;
  gap: 8px;
}

.pm-card-row .label {
  color: var(--text-muted);
  flex-shrink: 0;
}

.pm-progress {
  height: 5px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}

.pm-progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ---------- ASSET GRID ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 12px;
  border-radius: var(--radius-xl);
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--border-light);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.asset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  overflow: hidden;
}

.asset-card:hover {
  box-shadow: var(--shadow-sm);
}

.asset-card-name {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 2px;
  word-break: break-word;
}

.asset-card-id {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-bottom: 10px;
}

.asset-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  margin-bottom: 4px;
  gap: 8px;
}

.asset-card-row .label {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---------- FIRE SAFETY GRID ---------- */
.fire-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.fire-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
  overflow: hidden;
}

.fire-card:hover {
  box-shadow: var(--shadow-sm);
}

.fire-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.fire-card-title {
  font-size: 0.78rem;
  font-weight: 600;
  word-break: break-word;
}

.fire-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  margin-bottom: 4px;
  gap: 8px;
}

.fire-card-row .label {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---------- BADGES & TAGS ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-critical {
  background: var(--red-bg);
  color: var(--red);
}

.badge-high {
  background: var(--orange-bg);
  color: var(--orange);
}

.badge-medium {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-low {
  background: var(--blue-bg);
  color: var(--blue);
}

.badge-green {
  background: var(--green-bg);
  color: var(--green);
}

.badge-red {
  background: var(--red-bg);
  color: var(--red);
}

.badge-yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.badge-muted {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
}

.dept-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- SLA BAR ---------- */
.sla-bar-wrap {
  margin-bottom: 10px;
}

.sla-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  gap: 8px;
}

.sla-bar-title {
  font-size: 0.72rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sla-bar-time {
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sla-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.sla-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ---------- PRIORITY QUEUE ---------- */
.pq-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.pq-item:last-child {
  border-bottom: none;
}

.pq-item:hover {
  background: var(--bg-card-hover);
  margin: 0 -18px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
}

.pq-priority {
  width: 3px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}

.pq-content {
  flex: 1;
  min-width: 0;
}

.pq-title {
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pq-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* ---------- DEPT LOAD ---------- */
.dept-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.dept-bar-item:last-child {
  margin-bottom: 0;
}

.dept-bar-label {
  width: 85px;
  font-size: 0.72rem;
  font-weight: 500;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dept-bar {
  flex: 1;
  height: 24px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  min-width: 0;
}

.dept-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  padding-left: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  min-width: 16px;
}

.dept-bar-value {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- CREW WORKLOAD ---------- */
.crew-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.crew-row:last-child {
  border-bottom: none;
}

.crew-avatar-lg {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.crew-info {
  flex: 1;
  min-width: 0;
}

.crew-name-text {
  font-size: 0.78rem;
  font-weight: 600;
}

.crew-role-text {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.crew-stat {
  text-align: center;
  min-width: 40px;
}

.crew-stat-value {
  font-size: 0.88rem;
  font-weight: 700;
}

.crew-stat-label {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

/* ---------- ACTIVITY FEED ---------- */
.activity-item {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

.activity-text {
  font-size: 0.72rem;
  line-height: 1.4;
  min-width: 0;
  word-break: break-word;
}

.activity-time {
  font-size: 0.62rem;
  color: var(--text-dim);
}

/* ---------- CHARTS (CSS-only) ---------- */
.chart-bar-group {
  margin-bottom: 8px;
}

.chart-bar-group:last-child {
  margin-bottom: 0;
}

.chart-bar-label {
  font-size: 0.7rem;
  margin-bottom: 3px;
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  gap: 8px;
}

.chart-bar {
  height: 18px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
}

/* ---------- SETTINGS ---------- */
.settings-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
}

.stab {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
  white-space: nowrap;
}

.stab:hover {
  color: var(--text);
}

.stab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.settings-table th,
.settings-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  white-space: nowrap;
}

.settings-table td {
  white-space: normal;
  word-break: break-word;
}

.settings-table th {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 700;
  background: var(--bg);
  position: sticky;
  top: 0;
}

.settings-table tr:hover td {
  background: var(--bg-card-hover);
}

/* Table wrapper for horizontal scroll on narrow screens */
.card-body:has(.settings-table) {
  overflow-x: auto;
  padding: 0;
}

.card-body .settings-table {
  min-width: 500px;
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.65);
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg);
}

.modal-body {
  padding: 20px;
}

/* ---------- FORMS ---------- */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font);
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 204, 0, 0.15);
}

.form-select {
  appearance: none;
  cursor: pointer;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-select option {
  background: var(--bg-card);
  color: var(--text);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ---------- ATTACHMENTS ---------- */
.attachment-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.attachment-section h4 {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  transition: var(--transition);
}

.attachment-item:hover {
  border-color: var(--border-light);
}

.attachment-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.attachment-name {
  font-weight: 500;
  word-break: break-all;
}

.attachment-meta {
  font-size: 0.62rem;
  color: var(--text-muted);
}

.attachment-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
}

.attachment-upload:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(255, 204, 0, 0.04);
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1200px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .kanban-board {
    grid-template-columns: repeat(5, minmax(180px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 60px;
    min-width: 60px;
  }

  .sidebar .brand-text,
  .sidebar .nav-item span,
  .sidebar .nav-group-label,
  .sidebar .sidebar-footer .user-name,
  .sidebar .sidebar-footer .user-role,
  .sidebar .theme-toggle span {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 10px;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 16px 8px;
  }

  .content-area {
    padding: 16px;
  }
}

/* ---------- BENTO DASHBOARD ---------- */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.bento-grid .card {
  margin: 0;
}

.bento-6 {
  grid-column: span 6;
}

.bento-4 {
  grid-column: span 4;
}

.bento-3 {
  grid-column: span 3;
}

.bento-8 {
  grid-column: span 8;
}

.bento-12 {
  grid-column: span 12;
}

@media (max-width: 1200px) {

  .bento-6,
  .bento-4,
  .bento-3,
  .bento-8 {
    grid-column: span 6;
  }
}

@media (max-width: 900px) {

  .bento-6,
  .bento-4,
  .bento-3,
  .bento-8,
  .bento-12 {
    grid-column: span 12;
  }
}

/* ---------- AREA GRAPH ---------- */
.area-graph {
  width: 100%;
  height: 120px;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.area-graph svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- ROOM GRID ---------- */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 4px;
}

.room-cell {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 7px 4px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.room-cell:hover {
  transform: scale(1.06);
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.room-num {
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1;
  margin-bottom: 2px;
}

.room-type {
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.7;
}

.room-battery {
  position: absolute;
  top: 2px;
  right: 3px;
  display: flex;
  align-items: center;
  gap: 1px;
}

.room-battery svg {
  width: 10px;
  height: 10px;
}

.room-battery span {
  font-size: 0.48rem;
  font-weight: 700;
}

.room-legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  padding: 8px 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.room-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.room-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ---------- CHECKLIST ---------- */
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.check-item:last-child {
  border-bottom: none;
}

.check-item:hover {
  background: var(--bg-card-hover);
}

.check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.check-task {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
}

.check-cat {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ---------- ESCALATION CARDS ---------- */
.esc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.esc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}

.esc-card:hover {
  box-shadow: var(--shadow-sm);
}

.esc-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.esc-icon svg {
  width: 18px;
  height: 18px;
}

.esc-body {
  flex: 1;
  min-width: 0;
}

.esc-scenario {
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.esc-action {
  font-size: 0.62rem;
  color: var(--text-muted);
}

.esc-time {
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  text-align: right;
}

/* ---------- ENHANCED KPI ---------- */
.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  border-radius: 0 0 0 60px;
  opacity: 0.04;
  background: currentColor;
  pointer-events: none;
}

/* ---------- GLASS STAT PILL ---------- */
.stat-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-xl);
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.stat-pill svg {
  width: 12px;
  height: 12px;
  opacity: 0.6;
}

/* --- Enterprise Key Management UI --- */
.cabinet-board {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.cabinet-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cabinet-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.cabinet-header .cab-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
}

.cabinet-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
}

.cabinet-peg {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.cabinet-peg::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  opacity: 0.7;
}

.cabinet-peg:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.peg-in {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green);
}

.peg-in::before {
  background: var(--green);
}

.peg-out {
  background: rgba(245, 158, 11, 0.1);
  border: 1px dashed rgba(245, 158, 11, 0.5);
  color: var(--yellow);
}

.peg-out::before {
  background: var(--yellow);
}

.peg-lost {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: var(--red);
  animation: pulse-red 2s infinite;
}

.peg-lost::before {
  background: var(--red);
}

@keyframes pulse-red {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Scanner Console */
.scanner-console {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 2px 20px rgba(0, 0, 0, 0.5);
}

.scanner-screen {
  padding: 40px;
  text-align: center;
  position: relative;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(16, 185, 129, 0.8);
  box-shadow: 0 0 10px var(--green), 0 0 20px var(--green);
  animation: scan-laser 3s linear infinite;
  pointer-events: none;
  opacity: 0;
}

@keyframes scan-laser {
  0% {
    top: 10%;
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    top: 90%;
    opacity: 1;
  }

  100% {
    top: 100%;
    opacity: 0;
  }
}

.scanner-input {
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 8px;
  padding: 16px 24px;
  font-size: 1.5rem;
  font-family: monospace;
  color: #10b981;
  text-align: center;
  width: 100%;
  max-width: 400px;
  margin: 20px auto;
  outline: none;
  transition: all 0.2s;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.scanner-input:focus {
  border-color: #10b981;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2), 0 0 15px rgba(16, 185, 129, 0.2);
}

.scanner-input::placeholder {
  color: #475569;
}

.scanner-log {
  background: #020617;
  border-top: 1px solid #1e293b;
  padding: 16px;
  max-height: 200px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.8rem;
}

.scan-event {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed #1e293b;
}

.scan-time {
  color: #64748b;
}

.scan-success {
  color: #10b981;
}

.scan-error {
  color: #ef4444;
}

/* --- POGH Rooms Grid UI --- */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .room-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
  }
}

.room-cell {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
  cursor: pointer;
  overflow: hidden;
}

.room-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: rgba(255, 255, 255, 0.2) !important;
}

.room-num {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-type {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.room-battery {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.room-battery svg {
  width: 12px;
  height: 12px;
}

.room-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  justify-content: center;
}

.room-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.room-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}