/* ── Design Tokens & Functional Variables ──
   DEFAULTS ONLY. The real brand palette is injected at runtime from
   public/js/brand.js (see the inline <script> in index.html / login.html),
   which overrides --interactive, --interactive-dark, --accent and the
   --side-* rail colours. To rebrand a partner, edit brand.js — not this file. */
:root {
  --radius:       2px;     /* Near-square, terminal corners */
  --primary:      #f7f8f9;
  --surface:      #ffffff; /* Card / panel backgrounds */
  --interactive:  #573960; /* Brand primary (default GSB purple) */
  --accent:       #ff3154;
  --interactive-dark: #3d2743;
  --sidebar-w:    244px;
  --bg:           #f6f7f8; /* Near-white cool canvas */
  --border:       #e4e7eb; /* Hairline borders */
  --text-main:    #0f172a; /* Ink text */
  --text-muted:   #64748b; /* Slate muted */

  --font-ui:  "Chakra Petch", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-num: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Dark brand rail */
  --side-bg:      #231a29;
  --side-surface: #31243a;
  --side-border:  #3d2f47;
  --side-text:    #d6ccde;
  --side-muted:   #8a7d94;
}

/* Sidebar nav icons */
.nav-ico { width: 18px; text-align: center; font-size: .95rem; opacity: .85; }
.nav-link.active .nav-ico { opacity: 1; }

/* ── Base Structural Adjustments ── */
*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text-main);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.1px;
}

/* Clean tabular figures for money/quantities */
.fig { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.table td, .table th { font-variant-numeric: tabular-nums; }

/* Thin uppercase section labels instead of big icon headings */
.section-label {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.9px; color: var(--text-muted); margin: 0 0 0.6rem;
}

/* ── 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;
  transition: all 0.3s ease;
  z-index: 1000;
  border-right: 1px solid var(--side-border);
}

#sidebar h4 { color: #ffffff; font-weight: 700; letter-spacing: -0.3px; }

#sidebar .brand-text-node { padding-left: 2px; }

.nav-link {
  color: var(--side-text);
  padding: 10px 16px;
  font-weight: 500;
  border-radius: var(--radius);
  margin: 1px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  font-size: 0.9rem;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.nav-link.active {
  background: var(--side-surface) !important;
  color: #ffffff !important;
  box-shadow: inset 2px 0 0 #64748b;
}

/* ── 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: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
header h2 { font-size: 1.15rem; letter-spacing: -0.4px; font-weight: 600; }

/* ── KPI boxes — full border ── */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  height: 100%;
}
.kpi-label {
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--text-muted); margin-bottom: 0.15rem;
}
.kpi-value {
  font-family: var(--font-num); font-weight: 600; font-size: 1.35rem;
  letter-spacing: 0; color: var(--text-main); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ── Price board — full-bordered boxes, sector colour on the border ── */
.price-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  height: 100%;
  transition: background 0.12s;
}
.price-cell:hover { background: rgba(15, 23, 42, 0.03); }
.price-cell .pc-name { font-weight: 600; font-size: 0.82rem; line-height: 1.2; }
.price-cell .pc-price { font-family: var(--font-num); font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.price-cell .pc-meta { font-size: 0.68rem; color: var(--text-muted); }
.sector-dot { display:inline-block; width:7px; height:7px; border-radius:50%; margin-right:5px; vertical-align: middle; }

/* ── Content Panels — soft, borderless (less "boxed") ── */
.card {
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
}

/* ── Data Tables ── */
.table-responsive { border-radius: var(--radius); overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  background: #f9fafb;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}

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

.table-hover tbody tr:hover { background: rgba(37, 99, 235, 0.035); }

/* ── 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; }

/* Form inputs */
.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--radius);
}

.form-control:focus, .form-select:focus {
  border-color: var(--interactive);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control::placeholder {
  color: #9ca3af;
  opacity: 1;
}

/* ── Native Slide Toasts ── */
.custom-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1060;
  min-width: 320px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
  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 ── */
/* Off-canvas drawer: sidebar slides in over the content, toggled by the
   header hamburger. A tap on the dimmed backdrop closes it. */
@media (max-width: 991.98px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
    max-width: var(--sidebar-w) !important;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    z-index: 1050;
    overflow-y: auto;
  }
  body.nav-open #sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
  }
  body.nav-open { overflow: hidden; }
  header {
    padding: calc(0.9rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) 0.9rem calc(1rem + env(safe-area-inset-left));
  }
  header h2 { font-size: 1.35rem; }
  /* Keep the drawer + content clear of notches / rounded corners */
  #sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  #main-content { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

/* Fixed overlays respect the home-indicator / notch on all viewports */
#pwa-install-btn {
  bottom: max(18px, env(safe-area-inset-bottom)) !important;
  right: max(18px, env(safe-area-inset-right)) !important;
}
.custom-toast {
  bottom: max(24px, env(safe-area-inset-bottom));
  right: max(24px, env(safe-area-inset-right));
}

@media (max-width: 575.98px) {
  #main-content .p-4 { padding: 1rem !important; }
  #main-content .px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
  header { padding: 0.75rem 0.9rem; }
  header h2 { font-size: 1.2rem; margin-bottom: 0 !important; }
  header .breadcrumb { display: none; }
  .stat-card, .card .card-body { }
}

/* ── 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;
}

/* ── Squared, professional overrides ──
   Neutralises Bootstrap's heavy corner-rounding for a crisp business-tool feel. */
.rounded, .rounded-1, .rounded-2, .rounded-3, .rounded-4, .rounded-pill,
.btn, .badge, .modal-content, .dropdown-menu, .list-group, .alert, .form-select,
.input-group, .input-group > * {
  border-radius: var(--radius) !important;
}

.btn { font-weight: 500; }

/* Align Bootstrap primary to the brand accent */
.btn-primary {
  background-color: var(--interactive);
  border-color: var(--interactive);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--interactive-dark) !important;
  border-color: var(--interactive-dark) !important;
}
.btn-outline-primary { color: var(--interactive); border-color: var(--interactive); }
.btn-outline-primary:hover { background-color: var(--interactive); border-color: var(--interactive); }
.text-primary { color: var(--interactive) !important; }
.bg-primary { background-color: var(--interactive) !important; }
a { color: var(--interactive); }

/* Modals: flatter, squared, lighter header */
.modal-content { border: 1px solid var(--border); box-shadow: 0 12px 32px rgba(17,24,39,.16); }
.modal-header, .modal-footer { background: var(--surface) !important; border-color: var(--border) !important; }

/* Avatars stay circular even with the squared override */
.avatar-circle { border-radius: 50% !important; }

/* Tighten breadcrumb + generally calmer type */
.breadcrumb { --bs-breadcrumb-divider-color: var(--text-muted); }
body { -webkit-font-smoothing: antialiased; }

/* ── Density: minimise spacing between components ── */
#main-content .p-4 { padding: 0.85rem 1rem !important; }
#main-content .px-4 { padding-left: 1rem !important; padding-right: 1rem !important; }
#main-content .pt-4 { padding-top: 0.85rem !important; }
.card .card-body { padding: 0.75rem 0.9rem; }
.card { margin-bottom: 0 !important; }
.section-label { margin-bottom: 0.4rem; margin-top: 0; }
.mb-4 { margin-bottom: 0.9rem !important; }
.g-4 { --bs-gutter-y: 0.75rem; --bs-gutter-x: 0.75rem; }
.g-3 { --bs-gutter-y: 0.6rem; --bs-gutter-x: 0.6rem; }
.modal-body { padding: 0.9rem 1rem; }
.form-label { margin-bottom: 0.2rem; }
.mb-3 { margin-bottom: 0.6rem !important; }
