/* ====================================================================
   NEXUS — App-specific stylesheet
   Loaded after /assets/css/nexus-theme.css which provides the design
   tokens, app shell, and shared component base styles.
   This file handles dynamic component classes generated by app.js
   and app-specific layout overrides.
   ==================================================================== */

/* ------------------------------------------------------------------
   1. CSS variable aliases  (backward-compat with inline styles in app.js)
   ------------------------------------------------------------------ */
:root {
  --teal-mid:       var(--teal);
  --radius-md:      var(--r-md);
  --text-secondary: var(--text-2);
  --red-800:        #7f1d1d;
}

/* ------------------------------------------------------------------
   2. Sidebar nav buttons — reset button defaults, apply nav-item style
   ------------------------------------------------------------------ */
.sidebar-nav {
  padding: 2px 8px;
}
.sidebar-nav button {
  width: 100%;
  border: none;
  text-align: left;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text-2);
  background: transparent;
  cursor: pointer;
  position: relative;
  margin: 1px 0;
  border-radius: 0;
  transition: background .12s, color .12s;
}
.sidebar-nav button i { font-size: 17px; flex-shrink: 0; }
.sidebar-nav button:hover { background: var(--surface-2); color: var(--text-1); }
.sidebar-nav button.active { color: var(--teal); background: var(--teal-50); font-weight: 500; }
.sidebar-nav button.active::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--teal); border-radius: 0 2px 2px 0;
}
.sidebar-nav button.hidden { display: none !important; }

/* Scan widget */
.sidebar-scan {
  padding: 10px 12px;
  margin: 6px 8px 0;
  background: var(--bg);
  border-radius: var(--r-md);
}
.sidebar-scan .scan-label {
  font-size: 10.5px; color: var(--text-2); margin-bottom: 6px;
}
.sidebar-scan input {
  flex: 1; font-size: 12px; padding: 4px 8px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-1); outline: none; height: 28px;
  font-family: var(--font-sans);
}
.sidebar-scan input:focus { border-color: var(--teal); }
#scan-go-btn {
  padding: 4px 9px; font-size: 12px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer; color: var(--teal); font-weight: 600; height: 28px;
}

/* ------------------------------------------------------------------
   3. Topbar
   ------------------------------------------------------------------ */
.topbar-spacer { flex: 1; }

/* ------------------------------------------------------------------
   4. Main content area
   ------------------------------------------------------------------ */
.main > main { flex: 1; overflow-y: auto; padding: 8px 28px 20px; }
.content { padding: 28px 24px 20px; }

/* Settings tables centered */


/* Tom Select - Clean searchable dropdowns */
.ts-wrapper { width: 100%; }
.ts-wrapper .ts-control {
  height: 36px;
  min-height: 36px;
  padding: 0 8px;
  border: 0.5px solid var(--border-strong) !important;
  border-radius: 6px !important;
  background: var(--surface) !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  cursor: text;
  gap: 0;
}
.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.focus .ts-control {
  border-color: var(--teal) !important;
  box-shadow: 0 0 0 2px rgba(0,178,172,0.10) !important;
}
.ts-wrapper .ts-control .item {
  font-size: 13.5px;
  font-family: var(--font-sans);
  color: var(--text-1);
  line-height: 36px;
  padding: 0 2px;
  margin: 0;
}
.ts-wrapper .ts-control input {
  font-size: 13.5px !important;
  font-family: var(--font-sans) !important;
  color: var(--text-1) !important;
  height: 34px !important;
  line-height: 34px !important;
  padding: 0 2px !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  text-align: left !important;
  caret-color: var(--teal);
  flex: 1;
}
.ts-wrapper.single .ts-control::after { display: none !important; }
.ts-dropdown {
  border: 0.5px solid var(--border-strong) !important;
  border-radius: 6px !important;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08) !important;
  background: var(--surface) !important;
  font-family: var(--font-sans);
  font-size: 13.5px;
  z-index: 9999;
  margin-top: 3px;
  overflow: hidden;
}
.ts-dropdown .ts-dropdown-content { max-height: 220px; overflow-y: auto; }
.ts-dropdown .option {
  padding: 9px 14px;
  color: var(--text-1);
  font-size: 13.5px;
  cursor: pointer;
}
.ts-dropdown .option:hover,
.ts-dropdown .option.active { background: var(--surface-2); color: var(--teal); }
.ts-dropdown .option.selected { background: var(--teal); color: #fff; }

/* Global table font size */
.reg-table td, .reg-table th { font-size: 14px; }

/* Scrollable tables in Settings */
#view-settings .subview > .reg-table { display:block; overflow-y:auto; max-height:calc(100vh - 220px); }
#view-settings .subview .reg-table thead th { position:sticky; top:0; z-index:2; background:var(--surface); }

/* page-title / page-sub used in views */
.page-title { font-size: 20px; font-weight: 600; color: var(--text-1); line-height: 1.1; }
.page-sub   { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

/* ------------------------------------------------------------------
   5. Dash header (page header row with title + filters/actions)
   ------------------------------------------------------------------ */
.dash-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.dash-filters {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-2);
}
.dash-filters input[type="date"] {
  height: 32px; font-size: 12px; padding: 0 8px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-1); outline: none;
}
.dash-filters button {
  height: 32px; padding: 0 11px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-1); font-size: 12.5px; cursor: pointer;
}
.dash-filters button:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------
   6. KPI / Metric cards
   ------------------------------------------------------------------ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.metric-card {
  background: var(--surface-2); border: 0.5px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
  position: relative; overflow: hidden;
}
.metric-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--teal); border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.metric-label { font-size: 11.5px; color: var(--text-2); margin-bottom: 4px; }
.metric-value { font-size: 21px; font-weight: 600; color: var(--text-1); line-height: 1; margin-bottom: 4px; }
.metric-trend { font-size: 11px; color: var(--text-3); }
.metric-trend.up { color: var(--green); }
.metric-trend.down { color: var(--red); }

/* ------------------------------------------------------------------
   7. Panel grids
   ------------------------------------------------------------------ */
.panel-grid   { display: grid; grid-template-columns: 1fr 1fr;        gap: 12px; margin-bottom: 12px; }
.panel-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }

/* override panel margin from nexus-theme.css for grids */
.panel-grid   > .panel,
.panel-grid-3 > .panel { margin-bottom: 0; }

.panel { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { font-size: 13.5px; font-weight: 600; color: var(--text-1); margin: 0; }
.panel > h3    { font-size: 13.5px; font-weight: 600; color: var(--text-1); margin: 0 0 12px; }

/* Segmented control inside panels */
.panel-toggle {
  display: flex; background: var(--bg); border-radius: 7px; padding: 2px; gap: 2px;
}
.panel-toggle button {
  font-size: 11px; padding: 3px 9px; border-radius: 5px; border: none;
  background: transparent; color: var(--text-2); cursor: pointer; font-family: var(--font-sans);
}
.panel-toggle button.active { background: var(--surface); color: var(--teal); font-weight: 500; }

/* ------------------------------------------------------------------
   8. Sub-tabs
   ------------------------------------------------------------------ */
.sub-tabs {
  display: flex; gap: 0; margin-bottom: 16px;
  border-bottom: 0.5px solid var(--border);
}
.sub-tab {
  font-size: 14px; padding: 8px 14px;
  border: none; background: transparent;
  color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -0.5px;
  font-family: var(--font-sans);
  transition: color .12s, border-color .12s;
  white-space: nowrap;
}
.sub-tab:hover { color: var(--text-1); }
.sub-tab.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 500; }

/* ------------------------------------------------------------------
   9. Toolbar (row of filters + action buttons above tables)
   ------------------------------------------------------------------ */
.toolbar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.toolbar input[type="text"] {
  height: 34px; min-width: 180px; padding: 0 10px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 14px; color: var(--text-1); background: var(--surface); outline: none;
  font-family: var(--font-sans);
}
.toolbar input[type="text"]:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }
.toolbar select {
  height: 34px; padding: 0 10px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 14px; color: var(--text-1); background: var(--surface); outline: none;
  cursor: pointer; font-family: var(--font-sans);
}
.toolbar button {
  height: 34px; padding: 0 13px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 14px; background: var(--surface); color: var(--text-1);
  cursor: pointer; font-family: var(--font-sans); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.toolbar button:hover { background: var(--surface-2); }
/* Small inline action buttons (table row actions, "+ Add item", etc.) */
.btn-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 28px; padding: 0 10px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 12px; font-weight: 500; background: var(--surface); color: var(--text-1);
  cursor: pointer; font-family: var(--font-sans); white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn-sm:hover { background: var(--surface-2); border-color: var(--teal); color: var(--teal); }
.btn-sm[style*="color: var(--red)"], .btn-sm[style*="color:var(--red)"] { border-color: var(--red-tint, #f3d0d0); }
.btn-sm[style*="color: var(--red)"]:hover, .btn-sm[style*="color:var(--red)"]:hover { background: var(--red-tint, #fbeaea); border-color: var(--red); }

/* ------------------------------------------------------------------
   10. Primary button (used everywhere as class="primary")
   ------------------------------------------------------------------ */
button.primary, .btn-primary-app {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  background: var(--teal); color: #fff;
  border: none; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500; cursor: pointer;
  font-family: var(--font-sans); white-space: nowrap;
  transition: background .12s;
}
button.primary:hover { background: var(--teal-dark); }
button.primary:active { transform: scale(.99); }

/* Toolbar primary */
.toolbar button.primary { border-color: var(--teal); }

/* ------------------------------------------------------------------
   11. Data tables
   ------------------------------------------------------------------ */
.reg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.reg-table th {
  text-align: left; font-size: 11.5px; font-weight: 500; color: var(--text-2);
  padding: 8px 10px; border-bottom: 0.5px solid var(--border);
  white-space: nowrap; background: var(--surface);
}
.reg-table td {
  padding: 10px; border-bottom: 0.5px solid var(--border);
  color: var(--text-1); vertical-align: middle;
}
.reg-table tr:last-child td { border-bottom: none; }
.reg-table tbody tr:hover  { background: var(--teal-50); }
.reg-table input[type="checkbox"] { accent-color: var(--teal); cursor: pointer; }
/* Sticky first column so row identity stays visible while scrolling horizontally */
.reg-table th:first-child, .reg-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}
.reg-table thead th:first-child { z-index: 3; }
.reg-table tbody tr:hover td:first-child { background: var(--teal-50); }
/* Click-to-select row: stays highlighted (incl. sticky column) while scrolling, until another row is clicked */
.reg-table tbody tr.row-selected { background: var(--teal-50); }
.reg-table tbody tr.row-selected td:first-child { background: var(--teal-50); }
input[type="checkbox"] { accent-color: var(--teal); }
input[type="radio"] { accent-color: var(--teal); }

/* ------------------------------------------------------------------
   12. Badges  (base from nexus-theme.css; extra variants here)
   ------------------------------------------------------------------ */
.badge { display: inline-block; font-size: 10.5px; font-weight: 500; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-teal   { background: var(--teal-light); color: var(--teal-darker); }
.badge-red    { background: var(--red-light); color: var(--red-dark); }
.badge-gray   { background: var(--bg); color: var(--text-2); border: 0.5px solid var(--border); }
.badge-amber  { background: var(--amber-light); color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-coral  { background: #ffe4e6; color: #9f1239; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-fulfilled { background: #d1fae5; color: #065f46; }
.status-under-repair { background: #fef3c7; color: #78350f; display:inline-block; font-size:10.5px; font-weight:500; padding:2px 8px; border-radius:10px; white-space:nowrap; }

/* ------------------------------------------------------------------
   13. Avatar
   ------------------------------------------------------------------ */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0;
  text-transform: uppercase;
}
.avatar.badge-purple { background: #7f77dd; }
.avatar.badge-gray   { background: var(--text-3); }

/* ------------------------------------------------------------------
   14. Form fields
   ------------------------------------------------------------------ */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 500; color: var(--text-1); margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%; height: 36px; padding: 0 10px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 14px; color: var(--text-1); background: var(--surface); outline: none;
  font-family: var(--font-sans);
}
.field textarea { height: auto; padding: 8px 10px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint);
}
.field input[type="checkbox"] { width: auto; height: auto; accent-color: var(--teal); }
.reg-table input[type="text"], .reg-table input[type="number"], .reg-table select {
  height: 32px; padding: 0 8px;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  font-size: 13px; color: var(--text-1); background: var(--surface); outline: none;
  font-family: var(--font-sans);
}
.reg-table input[type="text"]:focus, .reg-table input[type="number"]:focus, .reg-table select:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint);
}

/* ------------------------------------------------------------------
   15. Modals
   ------------------------------------------------------------------ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.35);
  display: flex; align-items: flex-start; justify-content: flex-end;
  z-index: 200; padding: 32px;
}
/* Themed dialogs (nexusAlert/nexusConfirm/nexusPrompt) must always render above
   any regular modal - including ones that set an inline z-index override (e.g.
   the petty cash / direct purchase form uses z-index:1100) - otherwise the
   dialog paints invisibly behind the open modal and looks like a dead button.
   They also stay centered rather than adopting the pop-out panel's right-docked
   position, since they are small confirmation/alert prompts, not module dialogs. */
#nexus-dialog-layer .modal-overlay { z-index: 5000; align-items: center; justify-content: center; padding: 24px; }
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  padding: 24px; width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
  animation: modal-slide-in .22s cubic-bezier(.16,1,.3,1);
}
#nexus-dialog-layer .modal { animation: modal-pop-in .16s ease-out; }
@keyframes modal-slide-in {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes modal-pop-in {
  from { opacity: 0; transform: scale(.97); }
  to { opacity: 1; transform: scale(1); }
}
.modal h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text-1); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions button {
  height: 34px; padding: 0 14px; border-radius: var(--r-md);
  font-size: 14px; cursor: pointer; font-family: var(--font-sans);
  border: 0.5px solid var(--border-strong); white-space: nowrap;
}
.modal-actions button.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.modal-actions button:not(.primary) { background: var(--surface); color: var(--text-1); }
.modal-breadcrumb {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-1); opacity: .65;
  margin: -24px -24px 16px -24px; padding: 12px 24px;
  border-bottom: 0.5px solid var(--border-strong);
  border-top-left-radius: var(--r-xl); border-top-right-radius: var(--r-xl);
}
.modal-breadcrumb i { font-size: 13px; }
.modal-breadcrumb .modal-breadcrumb-current { opacity: 1; font-weight: 600; }
.nav-home-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 0.5px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; font-weight: 500; color: var(--text-1);
  cursor: pointer; font-family: var(--font-sans);
  transition: border-color .15s ease, color .15s ease;
}
.nav-home-chip:hover { border-color: var(--teal); color: var(--teal); }
.nav-home-chip i { font-size: 14px; }

/* ------------------------------------------------------------------
   16. Toast notifications
   ------------------------------------------------------------------ */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 400;
  background: var(--text-1); color: #fff; padding: 10px 16px;
  border-radius: var(--r-md); font-size: 13px;
  box-shadow: var(--shadow-md); animation: toast-in .2s ease;
  max-width: 320px;
}
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ------------------------------------------------------------------
   17. Empty state
   ------------------------------------------------------------------ */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-3); font-size: 13.5px;
}

/* ------------------------------------------------------------------
   18. Maintenance reminder banner
   ------------------------------------------------------------------ */
#maint-reminder {
  display: flex; align-items: center; gap: 10px;
  background: var(--red-light); border: 0.5px solid #fca5a5;
  border-radius: var(--r-md); padding: 10px 14px;
  margin-bottom: 14px; font-size: 13px; color: #7f1d1d; cursor: pointer;
}

/* ------------------------------------------------------------------
   19. Portal — my assets + requestable grids
   ------------------------------------------------------------------ */
.my-assets-grid, .requestable-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.asset-card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--r-lg); padding: 14px; cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.asset-card:hover { box-shadow: var(--shadow-md); border-color: var(--teal); }
.asset-card .card-title { font-size: 14px; font-weight: 500; color: var(--text-1); margin-bottom: 4px; }
.asset-card .card-sub   { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.asset-card .card-meta  { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------------
   20. Repair / Replace analysis cards
   ------------------------------------------------------------------ */
.analysis-grid { display: flex; flex-direction: column; gap: 8px; }
.analysis-card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--r-lg); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  border-left-width: 3px; border-left-style: solid;
}
.analysis-card.replace { border-left-color: var(--red); background: var(--red-light); }
.analysis-card.monitor { border-left-color: var(--amber); background: var(--amber-light); }
.analysis-card.ok      { border-left-color: var(--teal); background: var(--teal-50); }
.analysis-verdict { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.verdict-replace { background: #fee2e2; color: #991b1b; }
.verdict-monitor { background: #fef3c7; color: #92400e; }
.verdict-ok      { background: var(--teal-light); color: var(--teal-darker); }

/* ------------------------------------------------------------------
   21. Asset Map dependency tree
   ------------------------------------------------------------------ */
#view-assetmap > div.assetmap-grid {
  display: grid; grid-template-columns: 280px 1fr; gap: 16px; min-height: 400px;
}
#assetmap-list .asset-map-item {
  padding: 8px 10px; border-radius: var(--r-md); cursor: pointer;
  font-size: 14px; margin-bottom: 2px; border: 0.5px solid transparent;
}
#assetmap-list .asset-map-item:hover { background: var(--surface-2); }
#assetmap-list .asset-map-item.selected {
  background: var(--teal-50); border-color: var(--teal); color: var(--teal);
}
.dep-tree { padding: 4px 0; }
.dep-node {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-sm); font-size: 12.5px;
}
.dep-node:hover { background: var(--surface-2); }
.dep-children { margin-left: 18px; padding-left: 12px; border-left: 2px solid var(--border); }
.rel-chip {
  font-size: 10px; padding: 2px 7px; border-radius: 10px; white-space: nowrap;
  background: var(--teal-light); color: var(--teal-darker);
}

/* ------------------------------------------------------------------
   22. Donut/chart containers (app.js renders SVG into these)
   ------------------------------------------------------------------ */
#class-donut, #ownership-donut, #status-donut { min-height: 130px; }
#age-chart, #locations-list, #cond-bars, #site-dept-treemap, #profit-table { min-height: 80px; }

/* ------------------------------------------------------------------
   23. Import/export wizard
   ------------------------------------------------------------------ */
.wizard-step-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; }
.wizard-step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.wizard-step.active { color: var(--teal); font-weight: 500; }
.wizard-step.done   { color: var(--green); }
.wizard-step-num {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; flex-shrink: 0;
}
.wizard-connector { flex: 1; height: 1px; background: var(--border); }

/* ------------------------------------------------------------------
   24. People search overlay
   ------------------------------------------------------------------ */
.people-overlay { /* used in SharePoint; no-op here */ }

/* ------------------------------------------------------------------
   25. Misc utilities
   ------------------------------------------------------------------ */
.hidden { display: none !important; }

/* ------------------------------------------------------------------
   26. Scrollbars
   ------------------------------------------------------------------ */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--surface-2); }
::-webkit-scrollbar-thumb:hover { background: var(--teal); }

/* ------------------------------------------------------------------
   27. Responsive
   ------------------------------------------------------------------ */
@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .panel-grid, .panel-grid-3 { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Fix flatpickr prev/next month arrows being clicked-through to the day grid underneath */
.flatpickr-calendar { z-index: 100000; }
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
  z-index: 10 !important;
}
.flatpickr-innerContainer, .flatpickr-days, .dayContainer {
  position: relative;
  z-index: 1;
}

/* Dashboard chart visuals: donut legend, vertical bar chart, horizontal bar list.
   These classes are referenced by renderDonut/renderAgeChart/renderLocationsList/
   renderBars in app.js but had no matching CSS, causing those panels to render
   as plain unstyled text instead of visuals. */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
}
.donut-legend {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
}
.donut-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-legend-name {
  flex: 1;
  min-width: 0;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.donut-legend-val {
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.vbar-chart {
  display: flex;
  gap: 14px;
  padding: 8px 4px 0;
  border-bottom: 1px solid var(--border);
}
.vbar-col {
  flex: 1;
  height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}
.vbar-fill {
  width: 60%;
  max-width: 36px;
  background: linear-gradient(180deg, var(--teal), var(--teal-dark));
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  transition: height .3s var(--ease);
}
.vbar-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
}
.vbar-axis {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}
.bar-label {
  width: 110px;
  flex-shrink: 0;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: var(--r-sm);
  transition: width .3s var(--ease);
}
.bar-count {
  width: 36px;
  text-align: right;
  flex-shrink: 0;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* Assets by Site & Department: grid of per-site cards, each with a single
   segmented bar (departments proportional within that site only), plus a
   single shared legend above the grid (one color per department, consistent
   everywhere), an Unassigned data-quality callout, and an "as of" timestamp.
   See renderTreemap() in app.js for why this replaced a literal area-treemap
   (site sizes vary too widely for that to be legible). */
.site-dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.site-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.site-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.site-card-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-card-total {
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.site-seg-bar {
  display: flex;
  height: 10px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  margin-bottom: 10px;
}
.site-seg {
  height: 100%;
}
.site-dept-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 14px;
}
.site-dept-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.site-dept-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.site-dept-chip-name {
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-1);
}
.site-dept-chip-count {
  color: var(--text-3);
}
.site-dept-chip-warn .site-dept-chip-name,
.site-dept-chip-warn .site-dept-chip-count {
  color: var(--red);
  font-weight: 600;
}
.site-dept-warn-banner {
  background: var(--amber-light);
  border: 1px solid rgba(217, 119, 6, 0.25);
  color: var(--amber);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.site-dept-asof {
  text-align: right;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 10px;
}

.site-card-value {
  font-size: 11.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.site-card-clickable {
  cursor: pointer;
  transition: box-shadow .15s var(--ease), border-color .15s var(--ease);
}
.site-card-clickable:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}
.site-seg-clickable {
  cursor: pointer;
}
.site-seg-clickable:hover {
  filter: brightness(1.12);
}

/* Service Desk admin buttons: larger, easier-to-hit size, one row */
#sd-filters { gap: 10px !important; }
#sd-admin-btns > button.btn-sm {
  height: 36px !important;
  padding: 0 10px !important;
  font-size: 13px !important;
  gap: 6px !important;
}
#sd-admin-btns > button.btn-sm .ti { font-size: 16px; }

/* NEXUS-GRID: global table colour + alignment (reg-table) */
.reg-table thead th, .reg-table thead th:first-child {
  background: linear-gradient(rgba(0,178,172,.10), rgba(0,178,172,.10)), var(--surface) !important;
  color: #0b6f6a; font-weight: 600; border-bottom: 1px solid rgba(0,178,172,.35);
}
.reg-table tbody td:nth-child(even):not(:first-child) { background: rgba(120,130,135,.05); }
.reg-table tbody td.gal-num:not(:first-child) { background: rgba(0,178,172,.06); }
.reg-table tbody tr:hover td:not(:first-child) { background: rgba(0,178,172,.10); }
.reg-table tbody tr.row-selected td:not(:first-child) { background: rgba(0,178,172,.14); }
.reg-table .gal-c { text-align: center !important; }
.reg-table .gal-l { text-align: left !important; }
.reg-table .gal-r { text-align: right !important; }
.reg-table td.gal-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* NEXUS-REGISTER: asset register table colour + alignment */
#asset-register-table thead th {
  background: linear-gradient(rgba(0,178,172,.10), rgba(0,178,172,.10)), var(--surface) !important;
  color: #0b6f6a !important; font-weight: 600 !important;
  border-bottom: 1px solid rgba(0,178,172,.35) !important;
}
#asset-register-table tbody td:nth-child(even):not(:first-child) { background: rgba(120,130,135,.05); }
#asset-register-table tbody td[data-col="cost"] { background: rgba(0,178,172,.07); font-variant-numeric: tabular-nums; }
#asset-register-table tbody tr:hover td:not(:first-child) { background: rgba(0,178,172,.12); }
#asset-register-table tbody tr.asset-row-selected td:not(:first-child) { background: rgba(0,178,172,.16); }
#asset-register-table [data-col="serial"],
#asset-register-table [data-col="department"],
#asset-register-table [data-col="company"],
#asset-register-table [data-col="assigned"] { text-align: left !important; }
#asset-register-table [data-col="class"],
#asset-register-table [data-col="checkinout"],
#asset-register-table [data-col="state"],
#asset-register-table [data-col="cost"],
#asset-register-table [data-col="condition"],
#asset-register-table thead th:last-child,
#asset-register-table tbody td:last-child { text-align: center !important; }
#asset-register-table th, #asset-register-table td { padding-left: 14px; padding-right: 14px; }

/* NEXUS-THEME2: Companies look applied to every reg-table */
.reg-table thead th, .reg-table thead th:first-child { background: linear-gradient(rgba(0,178,172,.10),rgba(0,178,172,.10)),var(--surface-2) !important; color:#0b6f6a !important; font-weight:600 !important; border-bottom:1px solid rgba(0,178,172,.35) !important; }
.reg-table tbody td { background: var(--surface-2); }
.reg-table tbody td:first-child { background: var(--surface-2); }
.reg-table tbody td:nth-child(even):not(:first-child) { background: linear-gradient(rgba(120,130,135,.06),rgba(120,130,135,.06)),var(--surface-2); }
.reg-table tbody td.gal-num:not(:first-child), .reg-table tbody td[data-col="cost"] { background: linear-gradient(rgba(0,178,172,.08),rgba(0,178,172,.08)),var(--surface-2); }
.reg-table tbody tr:hover td:not(:first-child) { background: linear-gradient(rgba(0,178,172,.13),rgba(0,178,172,.13)),var(--surface-2); }
.reg-table tbody tr.row-selected td:not(:first-child), .reg-table tbody tr.asset-row-selected td:not(:first-child) { background: linear-gradient(rgba(0,178,172,.17),rgba(0,178,172,.17)),var(--surface-2); }
.reg-table th:not(:first-child), .reg-table td:not(:first-child) { border-left: 1px solid rgba(120,130,135,.18); }
.reg-table td { padding-top: 12px; padding-bottom: 12px; }
#asset-register-table thead th, #asset-register-table thead th:first-child { background: linear-gradient(rgba(0,178,172,.10),rgba(0,178,172,.10)),var(--surface-2) !important; color:#0b6f6a !important; font-weight:600 !important; border-bottom:1px solid rgba(0,178,172,.35) !important; }
#asset-register-table tbody td { background: var(--surface-2); }
#asset-register-table tbody td:first-child { background: var(--surface-2); }
#asset-register-table tbody td:nth-child(even):not(:first-child) { background: linear-gradient(rgba(120,130,135,.06),rgba(120,130,135,.06)),var(--surface-2); }
#asset-register-table tbody td.gal-num:not(:first-child), #asset-register-table tbody td[data-col="cost"] { background: linear-gradient(rgba(0,178,172,.08),rgba(0,178,172,.08)),var(--surface-2); }
#asset-register-table tbody tr:hover td:not(:first-child) { background: linear-gradient(rgba(0,178,172,.13),rgba(0,178,172,.13)),var(--surface-2); }
#asset-register-table tbody tr.row-selected td:not(:first-child), #asset-register-table tbody tr.asset-row-selected td:not(:first-child) { background: linear-gradient(rgba(0,178,172,.17),rgba(0,178,172,.17)),var(--surface-2); }
#asset-register-table th:not(:first-child), #asset-register-table td:not(:first-child) { border-left: 1px solid rgba(120,130,135,.18); }
#asset-register-table td { padding-top: 12px; padding-bottom: 12px; }

/* NEXUS-GRID2: even column grid for tables that fit the screen */
.reg-table.gal-grid { table-layout: fixed; }
.reg-table.gal-grid th { white-space: normal; }
.reg-table.gal-grid td { overflow-wrap: anywhere; }
.reg-table.gal-grid td.gal-num { white-space: nowrap; }

/* NEXUS-INPUTS: unstyled search boxes on Maintenance and Asset Map */
#assetmap-search, input[placeholder^="Search tickets"] {
  height: 34px; padding: 0 12px; box-sizing: border-box;
  border: 0.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-1);
  font-family: var(--font-sans); font-size: 13px; outline: none;
}
#assetmap-search:focus, input[placeholder^="Search tickets"]:focus { border-color: var(--teal); }

/* NEXUS-USERS: Users directory table on the shared design */
#users-v2 .uv-table { table-layout: fixed; width: 100%; }
#users-v2 .uv-table thead th {
  background: linear-gradient(rgba(0,178,172,.10), rgba(0,178,172,.10)), var(--surface-2);
  color: #0b6f6a; font-weight: 600; border-bottom: 1px solid rgba(0,178,172,.35);
}
#users-v2 .uv-table th:nth-child(1), #users-v2 .uv-table td:nth-child(1) { width: 44px; text-align: center; }
#users-v2 .uv-table th:nth-child(2) { width: 26%; }
#users-v2 .uv-table th:nth-child(3) { width: 10%; }
#users-v2 .uv-table th:nth-child(4) { width: 20%; }
#users-v2 .uv-table th:nth-child(5) { width: 20%; }
#users-v2 .uv-table th:nth-child(6) { width: 12%; }
#users-v2 .uv-table th:nth-child(7) { width: 12%; }
#users-v2 .uv-table th:not(:first-child), #users-v2 .uv-table td:not(:first-child) {
  padding-left: 16px; padding-right: 16px; border-left: 1px solid rgba(120,130,135,.14);
}
#users-v2 .uv-table th:nth-child(3), #users-v2 .uv-table td:nth-child(3),
#users-v2 .uv-table th:nth-child(6), #users-v2 .uv-table td:nth-child(6),
#users-v2 .uv-table th:nth-child(7), #users-v2 .uv-table td:nth-child(7) { text-align: center; }
#users-v2 .uv-table td { overflow-wrap: anywhere; }
#users-v2 .uv-table tbody td:nth-child(even) { background: rgba(120,130,135,.06); }
#users-v2 .uv-table tbody .uv-row:hover td { background: rgba(0,178,172,.12); }
#users-v2 .uv-table tbody .uv-row.sel td { background: rgba(0,178,172,.16); }

/* NEXUS-MODALTABLE: tables inside popups size to their content instead of being squeezed */
.modal table.reg-table { table-layout: auto !important; width: 100%; }
.modal table.reg-table th { white-space: nowrap; }
.modal table.reg-table td { overflow-wrap: break-word; word-break: normal; vertical-align: middle; }
.modal table.reg-table th:not(:first-child), .modal table.reg-table td:not(:first-child) { min-width: 96px; }
.modal table.reg-table td.gal-num { white-space: nowrap; }
.modal :has(> table.reg-table) { overflow-x: auto; }

/* NEXUS-INV-FIT: inventory tabs size their tables to the content (scroll sideways on narrow windows), actions stay on one line */
[id^="inv-"].subview { overflow-x: auto; }
[id^="inv-"].subview > table.reg-table { width: max-content; min-width: 0; }
[id^="inv-"].subview > table.reg-table td:last-child { white-space: nowrap; }

/* NEXUS-INV-CENTER: centre the inventory tables on the page */
[id^="inv-"].subview > table.reg-table, #inv-simcards table.reg-table { margin-left: auto; margin-right: auto; }

/* NEXUS-WIZARD-CSS: styles for the asset import wizard */
.wizard-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.wizard-box { background: var(--surface, #fff); border-radius: 12px; width: min(920px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.wizard-head { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 0.5px solid var(--border); flex-wrap: wrap; }
.wizard-head h2 { margin: 0; font-size: 16px; }
.wizard-steps { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
.wizard-body { padding: 20px; overflow: auto; flex: 1; }
.wizard-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 20px; border-top: 0.5px solid var(--border); }
.drop-zone { border: 1.5px dashed var(--border-strong, #bbb); border-radius: 10px; padding: 36px 20px; text-align: center; cursor: pointer; color: var(--text-2); }
.drop-zone:hover, .drop-zone.over { border-color: var(--teal); }
.drop-icon { font-size: 32px; margin-bottom: 8px; }

/* NEXUS-WIZARD-CSS2: asset import wizard tables, badges and buttons */
.map-table, .preview-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.map-table th, .preview-table th { text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); background: var(--bg, #f6f8f8); border-bottom: 0.5px solid var(--border); position: sticky; top: 0; }
.map-table td, .preview-table td { padding: 8px 10px; border-bottom: 0.5px solid var(--border); vertical-align: top; }
.map-sample { color: var(--text-2); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-map-select { height: 30px; padding: 0 8px; border: 0.5px solid var(--border-strong, #ccc); border-radius: var(--r-sm); background: #fff; min-width: 190px; }
.update-mode-toggle { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; font-size: 12.5px; }
.update-mode-toggle label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.preview-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .03em; }
.pb-create { background: #e6f6f1; color: #0f6b52; }
.pb-update { background: #e7eefb; color: #1e4fa8; }
.pb-skip { background: #eef0f0; color: #5f6b6b; }
.pb-error { background: #fde8e8; color: #a12b2b; }
.preview-table tr.action-error td { background: #fff7f7; }
.import-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.import-summary-card { border: 0.5px solid var(--border); border-radius: var(--r-md); padding: 12px; text-align: center; }
.isc-num { font-size: 22px; font-weight: 600; }
.isc-lbl { font-size: 11.5px; color: var(--text-2); margin-top: 2px; }
.isc-errors .isc-num { color: #a12b2b; }
.wizard-foot button:not(.primary) { height: 34px; padding: 0 14px; border: 0.5px solid var(--border-strong, #ccc); border-radius: var(--r-md); background: #fff; cursor: pointer; font-size: 13px; }

/* NEXUS-WIZARD-CSS3: wizard dropdowns and column wrapping */
.map-table select.field-map-select { -webkit-appearance: none; appearance: none; height: 32px; padding: 0 28px 0 10px; border: 0.5px solid var(--border-strong, #ccc); border-radius: var(--r-sm); background: #fff url("data:image/svg+xml;utf8,<svg xmlns=%27http://www.w3.org/2000/svg%27 width=%2712%27 height=%277%27 viewBox=%270 0 12 7%27><path d=%27M1 1l5 5 5-5%27 fill=%27none%27 stroke=%27%23777%27 stroke-width=%271.5%27/></svg>") no-repeat right 10px center; font-size: 12.5px; min-width: 200px; cursor: pointer; }
.preview-table td:nth-child(1), .preview-table td:nth-child(3), .preview-table td:nth-child(5), .preview-table td:nth-child(6) { white-space: nowrap; }

/* NEXUS-WIZARD-CSS4: give the wizard the same input styling as .modal */
.wizard-box input[type="text"], .wizard-box input[type="search"], .wizard-box input[type="number"], .wizard-box select { height: 34px; padding: 0 10px; border: 0.5px solid var(--border-strong, #ccc); border-radius: var(--r-md); background: var(--surface, #fff); color: var(--text-1); font-size: 13px; font-family: inherit; box-sizing: border-box; outline: none; transition: border-color .15s, box-shadow .15s; }
.wizard-box input[type="text"]:focus, .wizard-box input[type="search"]:focus, .wizard-box input[type="number"]:focus, .wizard-box select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20,184,166,.15); }
.map-table td:last-child { min-width: 230px; }

/* NEXUS-WIZARD-CSS5: preview table - data cells stay on one line, Issues wraps */
.wizard-box .preview-table td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.wizard-box .preview-table td:last-child { white-space: normal; max-width: none; min-width: 240px; overflow: visible; }
