/* ── Design Tokens & Functional Variables ── */
:root {
  --primary:      #f5f5f4; /* Warm stone app-shell background */
  --surface:      #ffffff; /* Elevated white card backgrounds */
  --interactive:  #ea580c; /* Safety-orange primary accent (construction) */
  --accent:       #f97316; /* Brighter orange secondary accent */
  --interactive-dark: #c2410c; /* Deep burnt-orange for pressed/hover */
  --sidebar-w:    280px;
  --bg:           #f1f0ee; /* Warm grey-stone underlying body canvas */
  --border:       #e7e5e4; /* Stone structural borders */
  --text-main:    #1c1917; /* Stone-900 near-black text */
  --text-muted:   #78716c; /* Warm muted stone text */

  /* Dark industrial sidebar palette */
  --side-bg:      #1c1f24; /* Charcoal steel sidebar */
  --side-surface: #23272e; /* Slightly lifted panel within sidebar */
  --side-border:  #32383f; /* Subtle sidebar dividers */
  --side-text:    #d6d3d1; /* Soft warm-grey nav text */
  --side-muted:   #8a8f98; /* Dim section labels */
}

/* ── Base Structural Adjustments ── */
*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-main);
  overflow-x: hidden;
}

/* ── Blur Loader Sheet Layer ── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(241, 240, 238, 0.85); /* Lightened overlay matching --bg */
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── Enterprise App Shell Core Grid Layout ── */
#wrapper {
  display: flex;
  width: 100%;
  overflow-x: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ── Collapsible Navigation Sidebar Structure ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  background: var(--side-bg);
  color: var(--side-text);
  min-height: 100vh;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18); /* Grounded industrial shadow */
  transition: all 0.3s ease;
  z-index: 1000;
  border-right: 1px solid var(--side-border);
}

#sidebar h4 { color: #ffffff; font-weight: 800; letter-spacing: -0.5px; }

/* Orange brand bar accent under the logo/brand */
#sidebar .brand-text-node { border-left: 3px solid var(--interactive); padding-left: 10px; }

.nav-link {
  color: var(--side-text);
  padding: 11px 20px;
  font-weight: 500;
  border-radius: 8px;
  margin: 3px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  cursor: pointer;
  font-size: 0.925rem;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06); /* Subtle lift on dark steel */
  color: #ffffff;
}

.nav-link.active {
  background: var(--interactive) !important;
  color: #ffffff !important; /* White text on orange for hard-hat contrast */
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35); /* Warm orange glow */
}

/* ── Main Viewport Content Spaces ── */
#main-content {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  transition: all 0.3s ease;
}

header {
  background: var(--surface);
  padding: 1.4rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ── Metrics Accent Borders ── */
.stat-card {
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  background: var(--surface);
  border-left: 5px solid var(--interactive);
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.05);
}

.stat-card.budget-accent { border-left-color: #16a34a; } /* Green — on budget */
.stat-card.burn-accent   { border-left-color: #dc2626; } /* Red — burn / overrun */

/* ── Content Card Blocks ── */
.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.05);
}

/* ── Responsive Data Tables ── */
.table-responsive { border-radius: 10px; overflow: hidden; }

.table th {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #faf9f7; /* Warm off-white header */
  padding: 14px 16px;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 13px 16px;
  vertical-align: middle;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
}

.table-hover tbody tr:hover { background: rgba(234, 88, 12, 0.04); }

/* ── Access Restriction Warnings ── */
.role-access-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 10px;
  background: #fef3c7; /* Soft amber/yellow warning background */
  border: 1px solid #f59e0b; /* Defined amber border */
  color: #b45309; /* Dark amber text for clear contrast */
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

tr.row-readonly td { color: #a8a29e !important; } /* Warm stone for disabled states */
tr.row-readonly td strong { color: #a8a29e !important; }

/* Custom utility override to blend form input placeholder text */
.form-control {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.form-control:focus {
  border-color: var(--interactive);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.form-control::placeholder {
  color: #a8a29e; /* Muted warm-stone placeholder text */
  opacity: 1;
}

/* ── Native Slide Toasts ── */
.custom-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1060;
  min-width: 320px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  box-shadow: 0 12px 30px rgba(28, 25, 23, 0.14);
  transform: translateY(130%);
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
}

.custom-toast.show { transform: translateY(0); }
.progress {
  border-radius: 99px;
  background: #e7e5e4;
}
.progress-bar { border-radius: 99px; transition: width 0.4s ease; background: var(--interactive); }

/* ── Shimmering Placeholder Loading Grids ── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.placeholder-glow .placeholder {
  background: linear-gradient(90deg, #f0eeec 25%, #e7e5e4 50%, #f0eeec 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  display: inline-block;
}

/* ── Responsive Mobile Viewport Overrides ── */
@media (max-width: 991.98px) {
  #wrapper { flex-direction: column; }
  #sidebar { width: 100% !important; min-width: 100% !important; max-width: 100% !important; min-height: auto; }
}

/* ── Sidebar Section Labels ── */
.nav-section-label {
  list-style: none;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--side-muted);
  padding: 14px 20px 4px;
}
#wrapper.sidebar-collapsed #sidebar .nav-section-label { display: none; }

/* ── Sales Pipeline (Kanban) ── */
.pipeline-scroll { overflow-x: auto; padding-bottom: 8px; }
.pipeline-board { display: flex; gap: 14px; min-width: max-content; }
.pipeline-col {
  flex: 0 0 240px;
  width: 240px;
  background: #f5f5f4;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.pipeline-col-head { font-size: 0.85rem; }
.pipeline-dropzone { min-height: 80px; border-radius: 8px; transition: background 0.15s; }
.pipeline-dropzone.drop-hover { background: rgba(234, 88, 12, 0.08); outline: 2px dashed var(--interactive); }
.pipeline-card { cursor: grab; border-radius: 10px; }
.pipeline-card:active { cursor: grabbing; }
.pipeline-card.dragging { opacity: 0.4; }

/* ── Contact Avatars ── */
.avatar-circle {
  width: 36px; height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--interactive);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ── Activity Timeline ── */
.activity-item:last-child .border-bottom { border-bottom: 0 !important; }
.activity-dot {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* ── Analyser clickable rows ── */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: rgba(234, 88, 12, 0.05); }
.selected-project-row { background: rgba(234, 88, 12, 0.09) !important; box-shadow: inset 3px 0 0 var(--interactive); }

/* ── Nav pills (Contacts sub-tabs) ── */
.nav-pills .nav-link { color: var(--text-muted); border-radius: 8px; font-weight: 600; }
.nav-pills .nav-link:hover { background: rgba(234, 88, 12, 0.06); color: var(--interactive-dark); }
.nav-pills .nav-link.active { background: var(--interactive); color: #fff; box-shadow: none; }

/* ── Collapsed Sidebar Layout Modifications ── */
#wrapper.sidebar-collapsed #sidebar {
  min-width: 75px !important;
  max-width: 75px !important;
  width: 75px !important;
}

/* Completely dismiss labeled text strings during collapsed views */
#wrapper.sidebar-collapsed #sidebar .brand-text-node div,
#wrapper.sidebar-collapsed #sidebar .nav-text,
#wrapper.sidebar-collapsed #sidebar .footer-badge-node .card {
  display: none !important;
}

#wrapper.sidebar-collapsed #sidebar #sidebar-toggle {
  margin: 0 auto;
}

#wrapper.sidebar-collapsed #sidebar .nav-link {
  justify-content: center;
  padding: 12px 0;
}

#wrapper.sidebar-collapsed #sidebar .nav-link i {
  font-size: 1.25rem;
}

#wrapper.sidebar-collapsed #sidebar .footer-badge-node {
  padding: 0 0.5rem !important;
}
