:root {
  --brand: #d97706;
  --brand-hover: #b45309;
  --brand-soft: rgba(217, 119, 6, 0.13);
  --brand-text: #92400e;
  --sidebar-bg: #1e2128;
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #94a3b8;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-surface: rgba(255, 255, 255, 0.05);
  --sidebar-active-parent: rgba(255, 255, 255, 0.1);
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.w-68 { width: 17rem; }

.bg-brand { background-color: var(--brand); color: #ffffff; transition: background-color 0.15s ease; }
.bg-brand:hover { background-color: var(--brand-hover); }
.bg-brand-static { background-color: var(--brand); color: #ffffff; }
.bg-brand-soft { background-color: var(--brand-soft); color: var(--brand-text); }
.text-brand { color: var(--brand); }
.border-brand { border-color: var(--brand); }
.focus-brand:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Sidebar styling (Bukutansi hover-expand slide-out icon rail + clean accordion) */
.erp-sidebar {
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-color: var(--sidebar-border);
  width: 16.5rem;
}
.erp-sidebar-muted { color: var(--sidebar-muted); }
.erp-sidebar-border { border-color: var(--sidebar-border); }
.erp-sidebar-surface { background-color: var(--sidebar-surface); }
.erp-sidebar-hover-btn { color: var(--sidebar-muted); }
.erp-sidebar-hover-btn:hover { background-color: var(--sidebar-hover); color: var(--sidebar-text); }

.erp-nav-group-btn {
  color: var(--sidebar-text);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.erp-nav-group-btn:hover { background-color: var(--sidebar-hover); }
.erp-nav-group-btn.active-parent {
  background-color: var(--sidebar-active-parent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
}

.erp-nav-item {
  color: var(--sidebar-text);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.erp-nav-item:hover { background-color: var(--sidebar-hover); }
.erp-nav-item.active {
  background-color: var(--brand) !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.erp-sub-item {
  color: var(--sidebar-muted);
  transition: all 0.15s ease;
}
.erp-sub-item:hover {
  color: var(--sidebar-text);
  background-color: var(--sidebar-hover);
}
.erp-sub-item.active {
  color: #ffffff !important;
  background-color: var(--brand) !important;
  font-weight: 700;
}

.erp-rail-slot {
  width: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.erp-sub-abbr {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0.72;
}
.erp-sub-item.active .erp-sub-abbr {
  opacity: 1;
}

@media (min-width: 1024px) {
  /* Default: compact icon-rail (4.25rem) that slides smoothly over content on hover (16.5rem) */
  #sidebar-rail-spacer {
    width: 4.25rem;
  }
  #sidebar-rail-spacer.pinned {
    width: 16.5rem;
  }

  #app-sidebar {
    width: 4.25rem;
    transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease;
  }
  #app-sidebar.sidebar-pinned,
  #app-sidebar:hover {
    width: 16.5rem;
  }
  #app-sidebar:not(.sidebar-pinned):hover {
    box-shadow: 10px 0 32px -6px rgba(15, 23, 42, 0.35);
  }

  /* Collapsed rail state (neither pinned nor hovered) */
  #app-sidebar:not(.sidebar-pinned):not(:hover) .sidebar-hide-collapsed {
    display: none !important;
  }
  #app-sidebar:not(.sidebar-pinned):not(:hover) .erp-submenu-list {
    display: none !important;
  }
  #app-sidebar:not(.sidebar-pinned):not(:hover) .erp-nav-item,
  #app-sidebar:not(.sidebar-pinned):not(:hover) .erp-nav-group-btn {
    justify-content: center !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    gap: 0 !important;
  }
  #app-sidebar:not(.sidebar-pinned):not(:hover) .sidebar-brand-wrap,
  #app-sidebar:not(.sidebar-pinned):not(:hover) .sidebar-brand-main {
    justify-content: center !important;
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
  }
}

/* Status badges & cards */
.card-erp {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -12px rgba(15, 23, 42, 0.16);
}

.card-hero-brand {
  background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
  border-color: #fde68a;
}

.pill-tab {
  padding: 0.35rem 0.75rem;
  border-radius: 0.65rem;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  background: transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.pill-tab:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.pill-tab.active {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 3px 10px -2px rgba(217, 119, 6, 0.4);
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

@keyframes dashFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.dash-animate {
  animation: dashFadeUp 0.24s ease-out;
}

.table-erp {
  border-collapse: separate;
  border-spacing: 0;
}

.table-erp th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #475569;
  background: #f8fafc;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.table-erp td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.table-erp td.text-right,
.table-erp td .font-mono {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table-erp tbody tr:hover {
  background-color: #f8fafc;
}

/* Sticky locked table headers + smooth scroll container across ALL non-dashboard modules */
#main-content:not([data-route="dashboard/overview"]) .overflow-x-auto:has(> .table-erp),
#main-content:not([data-route="dashboard/overview"]) .table-scroll {
  max-height: min(62vh, 600px);
  overflow: auto;
  position: relative;
}

#main-content:not([data-route="dashboard/overview"]) .table-erp thead th {
  position: sticky;
  top: 0;
  z-index: 15;
  background-color: #f8fafc;
  box-shadow: inset 0 -1px 0 #cbd5e1, 0 2px 4px rgba(15, 23, 42, 0.05);
}

#main-content:not([data-route="dashboard/overview"]) .table-erp tbody tr:nth-child(even) {
  background-color: rgba(248, 250, 252, 0.55);
}

#main-content:not([data-route="dashboard/overview"]) .table-erp tbody tr:hover {
  background-color: #fffbeb;
}

/* Responsive chart container (fixes Bukutansi mobile chart squash bug) */
.chart-box {
  position: relative;
  width: 100%;
  min-height: 260px;
  height: 290px;
}

@media (max-width: 640px) {
  .chart-box {
    height: 310px;
  }
}

/* Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
::-webkit-scrollbar-track { background: transparent; }

/* Print layout */
@media print {
  body { background: #ffffff !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .no-print, #app-sidebar, #sidebar-rail-spacer, #sidebar-backdrop, header, footer, #toast-container { display: none !important; }
  #app-shell { display: block !important; height: auto !important; overflow: visible !important; }
  #main-content { padding: 0 !important; overflow: visible !important; }
  #dash-sticky-header { position: static !important; margin: 0 0 1rem 0 !important; padding: 0 !important; border: none !important; box-shadow: none !important; background: transparent !important; }
  .overflow-x-auto, .table-scroll { max-height: none !important; overflow: visible !important; }
  .table-erp thead th { position: static !important; box-shadow: none !important; }
  .card-erp { box-shadow: none !important; border: 1px solid #cbd5e1 !important; break-inside: avoid; }
  body:has(#global-modal:not(.hidden)) #app-shell { display: none !important; }
  body:has(#global-modal:not(.hidden)) #global-modal {
    position: static !important;
    background: #ffffff !important;
    padding: 0 !important;
    display: block !important;
  }
  body:has(#global-modal:not(.hidden)) #modal-panel {
    max-width: 100% !important;
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    overflow: visible !important;
  }
  body:has(#global-modal:not(.hidden)) #modal-panel > div:first-child { display: none !important; }
  body:has(#global-modal:not(.hidden)) #modal-body { padding: 0 !important; overflow: visible !important; }
}
