:root {
  --app-font-family: 'Inter', sans-serif;
  --app-font-xs: 0.72rem;
  --app-font-sm: 0.78rem;
  --app-font-table-th: 0.75rem;
  --app-font-base: 0.875rem;
  --app-font-md: 0.85rem;
  --app-font-lg: 0.95rem;
  --app-font-xl: 1.1rem;
  --app-font-page-title: 1.45rem;
  --app-font-kpi-value: 1.35rem;
  --app-color-text: #1a2035;
  --app-color-muted: #6c757d;
}

body {
  font-family: var(--app-font-family);
  font-size: var(--app-font-base);
  background: #f4f6f9;
  color: var(--app-color-text);
  line-height: 1.45;
}

.main-content {
  font-size: var(--app-font-base);
  color: var(--app-color-text);
}

.main-content .page-title-row h4,
.main-content .page-title-row h5 {
  font-size: var(--app-font-page-title);
  font-weight: 700;
  color: var(--app-color-text);
}

.main-content .content-card h5,
.main-content .content-card h6,
.main-content .panel-card h5,
.main-content .panel-card h6,
.main-content .section-title {
  font-size: var(--app-font-lg);
  font-weight: 700;
  color: var(--app-color-text);
}

.main-content .form-control,
.main-content .form-select,
.main-content .btn,
.main-content .input-group-text {
  font-size: var(--app-font-md);
}

.main-content .form-control-sm,
.main-content .form-select-sm,
.main-content .btn-sm {
  font-size: var(--app-font-sm);
}

.main-content .table thead th,
.main-content .table thead.table-dark th {
  font-size: var(--app-font-table-th);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.main-content .table tbody td,
.main-content .table tbody th {
  font-size: var(--app-font-base);
}

.main-content .pagination .page-link {
  font-size: var(--app-font-base);
}

.main-content .badge {
  font-size: var(--app-font-xs);
  font-weight: 600;
}

.main-content .small,
.main-content small,
.main-content .text-muted {
  font-size: var(--app-font-sm);
  color: var(--app-color-muted);
}

.main-content p {
  font-size: var(--app-font-base);
}

.bg-page { background: #f4f6f9; }
.bg-login { background: #1a2035; }

.btn-navy {
  background: #1a2035 !important;
  border-color: #1a2035 !important;
  color: #fff !important;
}

.btn-navy:hover { background: #243055 !important; border-color: #243055 !important; }

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 250px;
  background: #1a2035;
  overflow: hidden;
  z-index: 1030;
  box-shadow: 0 0 24px rgba(17, 24, 39, 0.24);
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-tagline {
  font-size: var(--app-font-xs);
}

.side-link {
  display: block;
  color: #ffffff;
  text-decoration: none;
  padding: 0.65rem 1rem;
  margin: 0.1rem 0.35rem;
  border-radius: 0.4rem;
  transition: all 0.2s ease;
}

.side-link:hover {
  background: #243055;
  color: #ffffff;
}

.side-link.active {
  background: #3d5afe;
  border-left: 0;
  border-radius: 0.4rem;
}

.side-sublink {
  display: block;
  color: #cfd6e6;
  text-decoration: none;
  padding: 0.35rem 1.8rem;
  margin: 0 0.35rem;
  border-radius: 0.35rem;
  font-size: 0.85rem;
}

.side-sublink:hover,
.side-sublink.active {
  background: #243055;
  color: #fff;
}

.side-sublink.active {
  font-weight: 600;
}

.side-icon {
  margin-right: 0.45rem;
  opacity: 0.9;
  width: 1.1rem;
  display: inline-block;
  text-align: center;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 1rem;
}

.sidebar-accordion {
  --bs-accordion-bg: transparent;
  --bs-accordion-border-color: transparent;
  --bs-accordion-btn-padding-x: 0.75rem;
  --bs-accordion-btn-padding-y: 0.55rem;
  --bs-accordion-body-padding-x: 0.35rem;
  --bs-accordion-body-padding-y: 0.25rem;
  margin: 0.15rem 0.35rem;
}

.sidebar-accordion .accordion-item {
  background: transparent;
  border: 0;
}

.sidebar-accordion .accordion-button {
  background: transparent;
  color: #e8ecf5;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: none;
  border-radius: 0.4rem !important;
  padding-left: 0.85rem;
}

.sidebar-accordion .accordion-button:not(.collapsed) {
  background: rgba(61, 90, 254, 0.22);
  color: #fff;
}

.sidebar-accordion .accordion-button::after {
  filter: brightness(0) invert(1);
  opacity: 0.75;
  transform: scale(0.85);
}

.sidebar-accordion .accordion-button:focus {
  box-shadow: none;
  border-color: transparent;
}

.sidebar-accordion .accordion-body {
  padding-top: 0.15rem;
  padding-bottom: 0.35rem;
}

.sidebar-accordion .side-sublink {
  padding-left: 2.2rem;
  margin-left: 0.35rem;
  margin-right: 0.35rem;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: auto;
}

.main-content {
  margin-left: 250px;
  min-height: 100vh;
}

.page-shell {
  padding: 1.1rem 1.2rem;
}

.stat-card {
  border: 0;
  border-radius: 0.75rem;
  box-shadow: 0 8px 20px rgba(31, 42, 68, 0.08);
}

.stat-card .card-body {
  padding: 1rem 1.1rem;
}

.stat-card .stat-title {
  color: var(--app-color-muted);
  font-size: var(--app-font-sm);
  font-weight: 600;
}

.stat-card .stat-num {
  font-size: var(--app-font-kpi-value);
  font-weight: 700;
  line-height: 1.1;
  margin-top: 0.2rem;
}

.panel-card {
  border: 0;
  border-radius: 0.75rem;
  box-shadow: 0 8px 22px rgba(31, 42, 68, 0.08);
}

.panel-card .card-body {
  padding: 1rem;
}

.section-title {
  font-weight: 700;
  color: #1f2a44;
  margin-bottom: 0.75rem;
}

.products-toolbar {
  background: #f7f9fc;
  border: 1px solid #e5e9f2;
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
}

#productRows .product-row {
  background: #fafbfe;
  border: 1px solid #e8ecf3;
  border-radius: 0.45rem;
  padding: 0.35rem;
}

.live-toolbar {
  background: #f7f9fc;
  border: 1px solid #e5e9f2;
  border-radius: 0.5rem;
  padding: 0.5rem;
}

#liveOrders {
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding-right: 0.2rem;
}

.customer-name {
  font-size: var(--app-font-xl);
  font-weight: 600;
}

.badge.bg-purple {
  background: #6f42c1 !important;
}

.order-card {
  border: 0;
  border-radius: 0.65rem;
  box-shadow: 0 4px 14px rgba(26, 32, 53, 0.08);
}

.order-card.status-pending { border-left: 4px solid #fd7e14; }
.order-card.status-in-process { border-left: 4px solid #0d6efd; }
.order-card.status-ready { border-left: 4px solid #28a745; }
.order-card.status-dispatched { border-left: 4px solid #6f42c1; }
.order-card.status-hold { border-left: 4px solid #dc3545; }

.role-admin { background: #dc3545; }
.role-sub_admin { background: #fd7e14; }
.role-sales { background: #0d6efd; }
.role-plant { background: #198754; }
.role-dispatch { background: #6f42c1; }
.role-tele_caller { background: #0dcaf0; color: #102a43; }

.mobile-menu-btn {
  position: fixed;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 1041;
  display: none;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
  }

  .main-content {
    margin-left: 0;
    padding-top: 3rem;
  }

  #liveOrders {
    max-height: none;
  }
}


.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.page-title-row h4,
.page-title-row h5 {
  margin: 0;
}

.content-card {
  border: 0;
  border-radius: 0.75rem;
  box-shadow: 0 8px 22px rgba(31, 42, 68, 0.08);
}

.content-card .card-body {
  padding: 1rem;
}

.filters-strip {
  background: #f7f9fc;
  border: 1px solid #e5e9f2;
  border-radius: 0.5rem;
  padding: 0.7rem;
  margin-bottom: 0.85rem;
}

.table-wrap {
  background: #fff;
  border-radius: 0.75rem;
  border: 1px solid #e8ecf3;
  overflow: hidden;
  box-shadow: 0 5px 14px rgba(31, 42, 68, 0.05);
}

.table-wrap .table {
  margin-bottom: 0;
}

.orders-page #liveOrders {
  max-height: 520px;
}

.orders-page .card.panel-card {
  min-height: 100%;
}

.table thead.table-dark th {
  background: #1f2a44 !important;
}

.form-floating > .form-control,
.form-floating > .form-select,
.form-control,
.form-select {
  border-radius: 0.5rem;
  border-color: #dfe4ee;
}

.login-card {
  border: 0;
  border-radius: 0.95rem;
  box-shadow: 0 14px 34px rgba(12, 19, 41, 0.35);
}

.leads-table-wrap {
  overflow: auto;
}

.leads-table-wrap table {
  min-width: 1080px;
}

.leads-table-wrap th,
.leads-table-wrap td {
  vertical-align: top;
}

.lead-status-form .form-select {
  min-width: 140px;
}

.lead-remark-form .form-control {
  min-width: 240px;
}

.leads-table .lead-main-row td {
  border-bottom: 0;
}

.lead-remarks-panel {
  border: 1px solid #e5e9f2;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.55rem;
}

.lead-history-list {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.lead-history-item {
  border: 1px solid #e9edf4;
  border-radius: 0.4rem;
  background: #f9fbff;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.35rem;
  font-size: var(--app-font-base);
}

.lead-history-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.15rem;
}

.lead-actions-cell {
  white-space: nowrap;
}

.lead-remarks-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 1055;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lead-remarks-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.lead-remarks-drawer {
  position: fixed;
  top: 0;
  right: -440px;
  width: 420px;
  max-width: calc(100vw - 24px);
  height: 100vh;
  background: #fff;
  box-shadow: -8px 0 20px rgba(15, 23, 42, 0.2);
  z-index: 1060;
  padding: 0.85rem;
  transition: right 0.22s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.lead-remarks-drawer.open {
  right: 0;
}

.lead-remarks-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  border-bottom: 1px solid #e9edf4;
  padding-bottom: 0.55rem;
  margin-bottom: 0.55rem;
}

.bulk-card .card-body {
  padding: 1rem 1.05rem;
}

.bulk-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.bulk-preview-wrap {
  border-radius: 0.55rem;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn i {
  font-size: var(--app-font-md);
  line-height: 1;
}

.icon-btn.with-count {
  width: auto;
  min-width: 30px;
  padding: 0 0.35rem;
  gap: 0.28rem;
}

.icon-btn-count {
  font-size: var(--app-font-xs);
  font-weight: 700;
  line-height: 1;
}

/* Dashboard topbar has its own notification + profile stack */
body:has(.erp-dashboard) .app-top-right-stack {
  display: none !important;
}

/* Fixed top-right: notification above profile */
.app-top-right-stack {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.app-top-notif-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #1a2035;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(26, 32, 53, 0.28);
  flex-shrink: 0;
}

.app-top-notif-btn:hover {
  color: #fff;
  background: #2a3355;
}

.app-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem 0.3rem 0.3rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e6eaf0;
  box-shadow: 0 2px 10px rgba(26, 32, 53, 0.08);
  text-decoration: none;
  color: var(--app-color-text);
  max-width: 180px;
}

.app-profile-chip:hover {
  color: var(--app-color-text);
  border-color: #c5cee0;
}

.app-profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a2035, #3d5afe);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--app-font-sm);
  flex-shrink: 0;
}

.app-profile-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.app-profile-name {
  font-size: var(--app-font-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-profile-role {
  font-size: var(--app-font-xs);
  color: var(--app-color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Keep page actions clear of the top-right stack */
body:not(:has(.erp-dashboard)) .main-content .page-title-row {
  padding-right: 11rem;
}

@media (max-width: 575.98px) {
  .app-profile-meta {
    display: none;
  }

  body:not(:has(.erp-dashboard)) .main-content .page-title-row {
    padding-right: 3.5rem;
  }
}

.notif-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #dc3545;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.workflow-timeline {
  position: relative;
  padding-left: 28px;
}

.workflow-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: #dee2e6;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1a2035;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #dee2e6;
}

.timeline-status .timeline-dot { background: #0d6efd; }
.timeline-remark .timeline-dot { background: #6c757d; }
.timeline-quotation .timeline-dot { background: #fd7e14; }
.timeline-invoice .timeline-dot { background: #198754; }
.timeline-activity .timeline-dot { background: #6f42c1; }

.timeline-content {
  background: #f8f9fb;
  border: 1px solid #e9edf4;
  border-radius: 8px;
  padding: 10px 12px;
}
