/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; overflow-x: hidden; }

/* ── Sidebar ── */
:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1a1d2e;
  --topbar-h: 56px;
  --primary: #4f6ef7;
}

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1030;
  transition: transform .25s ease;
  overflow-y: auto;
}

.sidebar-brand { border-bottom: 1px solid rgba(255,255,255,.08); min-height: var(--topbar-h); }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #6c7293;
  padding: .25rem .5rem;
  text-transform: uppercase;
}

/* ── Sidebar nav links — scoped to .sidebar to beat Bootstrap specificity ── */
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .75rem;
  border-radius: .375rem;
  color: #a0aabf !important;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none !important;
  border-left: 3px solid transparent;
  transition: background .18s ease, color .18s ease,
              border-left-color .18s ease, transform .18s ease,
              box-shadow .18s ease;
  position: relative;
}
.sidebar .nav-link:hover {
  background: rgba(79,110,247,.22) !important;
  color: #ffffff !important;
  border-left-color: #4f6ef7;
  transform: translateX(4px);
  box-shadow: 3px 0 14px rgba(79,110,247,.2);
}
.sidebar .nav-link:hover i {
  color: #7b96ff !important;
  filter: drop-shadow(0 0 5px rgba(79,110,247,.6));
}
.sidebar .nav-link.active {
  background: var(--primary) !important;
  color: #ffffff !important;
  border-left-color: rgba(255,255,255,.8);
  box-shadow: 0 2px 12px rgba(79,110,247,.45);
}
.sidebar .nav-link.active i { color: #fff !important; }
.sidebar .nav-link i {
  font-size: 1rem;
  flex-shrink: 0;
  transition: color .18s ease, filter .18s ease;
}
.sidebar .nav-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0;
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  height: var(--topbar-h);
  z-index: 1020;
}

/* ── Main Content ── */
#main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin .25s ease;
}
#main-content.expanded { margin-left: 0; }

/* ── Sidebar collapsed ── */
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }

.page-content { min-height: calc(100vh - var(--topbar-h)); }

/* ── Stat Cards ── */
.stat-card {
  background: #fff;
  border-radius: .75rem;
  padding: 1.25rem;
  border: 1px solid #e9ecef;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .8rem; color: #6c757d; font-weight: 500; }
.stat-change { font-size: .75rem; }

/* ── Status Pills ── */
.status-pill {
  display: inline-block;
  padding: .2em .65em;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: .02em;
}
.status-active   { background: #d1fae5; color: #065f46; }
.status-draft    { background: #f3f4f6; color: #374151; }
.status-pending  { background: #fef3c7; color: #92400e; }
.status-new      { background: #dbeafe; color: #1e40af; }
.status-cancelled{ background: #fee2e2; color: #991b1b; }
.status-converted{ background: #ede9fe; color: #5b21b6; }

/* ── Card ── */
.card { border: 1px solid #e7eaf3; border-radius: .85rem; box-shadow: 0 1px 4px rgba(17,24,39,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f7; font-weight: 600; }
.card-body.py-2 { padding-top: .75rem !important; padding-bottom: .75rem !important; }

/* ── Page header pattern (used site-wide via <h5 class="fw-bold mb-0">) ── */
h5.fw-bold.mb-0 {
  font-size: 1.1rem;
  letter-spacing: -.01em;
  color: #111827;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}
h5.fw-bold.mb-0 .bi { color: var(--primary); }

/* ── Table (modernized site-wide) ── */
.table { margin-bottom: 0; }
.table thead th {
  background: #f5f7fb;
  color: #374151 !important;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-top: none;
  border-bottom: 1px solid #e7eaf3;
  padding: .8rem 1rem;
  white-space: nowrap;
}
.table tbody td {
  vertical-align: middle;
  font-size: .88rem;
  padding: .75rem 1rem;
  border-color: #f1f3f9;
  color: #1f2937;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: #fafbff; }

/* Alignment helpers (opt-in per cell) */
.col-num, td.col-num, th.col-num { text-align: right;  font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-cen, td.col-cen, th.col-cen { text-align: center; }
.col-mut { color: #6b7280; font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.col-name { font-weight: 600; color: #111827; }
.col-strong { font-weight: 700; color: #111827; }

/* Compact icon-only action buttons (used in row Actions column) */
.row-actions { display: inline-flex; gap: .35rem; align-items: center; }
.row-actions .btn,
.row-actions form .btn {
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.row-actions form { display: inline; margin: 0; }

/* Yes/No icon (e.g. PF, ESI, applicable flags) */
.yn-icon { font-size: 1.05rem; line-height: 1; }
.yn-icon.on  { color: #16a34a; }
.yn-icon.off { color: #cbd5e1; }

/* Gender pill (consistent visual everywhere) */
.gender-pill {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.gender-pill.male   { background: #eef1ff; color: #3a4cc7; }
.gender-pill.female { background: #fdeaf3; color: #b91466; }
.gender-pill.other  { background: #eef2f6; color: #4b5563; }

/* Filter card (existing pattern: .card.mb-3 > .card-body.py-2 > form) */
.card.mb-3 > .card-body .form-control,
.card.mb-3 > .card-body .form-select {
  border-radius: 8px;
  border-color: #e7eaf3;
}
.card.mb-3 > .card-body .form-control:focus,
.card.mb-3 > .card-body .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .15rem rgba(79,110,247,.15);
}
.card.mb-3 > .card-body .input-group-text {
  background: #fff;
  border-color: #e7eaf3;
  color: #6b7280;
}
.card.mb-3 > .card-body .btn { border-radius: 8px; }

/* Header action buttons (slightly bigger, rounder) */
.d-flex.gap-2 > .btn,
.d-flex.justify-content-between .btn-sm.btn-success,
.d-flex.justify-content-between .btn-sm.btn-primary {
  border-radius: 8px;
  padding: .42rem .85rem;
  font-weight: 500;
}

/* ── Avatar ── */
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Sidebar footer ── */
.sidebar-footer { background: rgba(0,0,0,.2); }

/* ── Forms ── */
.form-label { font-weight: 500; font-size: .875rem; }
.form-control, .form-select { font-size: .875rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(79,110,247,.2); }

/* ── Buttons ── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #3d5ce5; border-color: #3d5ce5; }

/* ── Invoice/Document print ── */
.doc-header { border-bottom: 3px solid var(--primary); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.doc-title { font-size: 2rem; font-weight: 700; color: var(--primary); }
.doc-table th { background: var(--sidebar-bg); color: #fff; }

/* ── Item rows (for quotation/order forms) ── */
.item-row td { padding: .35rem .5rem; }
.item-row input, .item-row select { border-radius: .375rem; border: 1px solid #dee2e6; padding: .3rem .5rem; width: 100%; font-size: .85rem; }
.item-row .amount-cell { font-weight: 600; text-align: right; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
  .sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; }
}

/* ── Breadcrumb ── */
.breadcrumb { font-size: .8rem; }

/* ── Totals box ── */
.totals-box { background: #f8f9ff; border-radius: .5rem; padding: 1rem; border: 1px solid #dee2e6; }
.totals-box .row { margin-bottom: .3rem; font-size: .875rem; }
.totals-box .total-row { font-size: 1.1rem; font-weight: 700; border-top: 2px solid #dee2e6; padding-top: .5rem; margin-top: .5rem; }

/* ── Login page ── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1d2e 0%, #2d3361 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { font-size: 2rem; font-weight: 800; color: var(--primary); }

/* ── Dashboard chart containers ── */
.chart-container { position: relative; height: 280px; }

/* ── Scrollable table wrapper ── */
.table-responsive { border-radius: .5rem; overflow: hidden; }

/* ── Dashboard module cards ── */
.section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6b7280;
  margin: 1.25rem 0 .65rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e7eaf3;
  margin-left: .5rem;
}

.module-card {
  background: #fff;
  border: 1px solid #e7eaf3;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(17,24,39,.08);
  border-color: #d6dbed;
}

.module-card-head {
  padding: 1rem 1.1rem .9rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  border-bottom: 1px solid #f1f3f9;
}
.module-card-head .ico {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.module-card-head h6 {
  margin: 0; font-weight: 700; color: #111827;
  font-size: 1rem; letter-spacing: -.005em;
}
.module-card-head small {
  color: #6b7280; font-size: .73rem; display: block; margin-top: 1px;
}

/* Per-module accent gradients */
.mod-crm    .ico { background: linear-gradient(135deg, #4f6ef7, #6c8aff); }
.mod-sales  .ico { background: linear-gradient(135deg, #16a34a, #22c55e); }
.mod-purch  .ico { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.mod-inv    .ico { background: linear-gradient(135deg, #06b6d4, #0ea5e9); }
.mod-acct   .ico { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.mod-hr     .ico { background: linear-gradient(135deg, #ec4899, #f472b6); }
.mod-mfg    .ico { background: linear-gradient(135deg, #ef4444, #f87171); }
.mod-admin  .ico { background: linear-gradient(135deg, #475569, #64748b); }

.module-links {
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  flex: 1;
}
.module-links a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .65rem;
  border-radius: 8px;
  color: #374151;
  text-decoration: none;
  font-size: .87rem;
  font-weight: 500;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.module-links a:hover {
  background: #f5f7fb;
  color: var(--primary);
  transform: translateX(2px);
}
.module-links a i {
  color: #9ca3af;
  font-size: 1rem;
  width: 18px; text-align: center;
  transition: color .15s ease;
}
.module-links a:hover i { color: var(--primary); }
.module-links a .badge-count {
  margin-left: auto;
  background: #eef1ff;
  color: #4f6ef7;
  font-size: .7rem;
  font-weight: 600;
  padding: .12rem .45rem;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: #9ca3af; }
.empty-state i { font-size: 2.6rem; margin-bottom: .5rem; display: block; opacity: .45; }
.empty-state p { margin: 0; font-size: .92rem; }

/* ── Status pills — extra states for completeness ── */
.status-paid       { background: #d1fae5; color: #065f46; }
.status-unpaid     { background: #fee2e2; color: #991b1b; }
.status-partial    { background: #fef3c7; color: #92400e; }
.status-overdue    { background: #fee2e2; color: #991b1b; }
.status-completed  { background: #d1fae5; color: #065f46; }
.status-in-progress{ background: #dbeafe; color: #1e40af; }
.status-on-hold    { background: #fef3c7; color: #92400e; }
.status-rejected   { background: #fee2e2; color: #991b1b; }
.status-approved   { background: #d1fae5; color: #065f46; }
.status-inactive   { background: #f3f4f6; color: #6b7280; }
.status-terminated { background: #fee2e2; color: #991b1b; }
.status-closed     { background: #f3f4f6; color: #6b7280; }
.status-open       { background: #dbeafe; color: #1e40af; }
.status-sent       { background: #ede9fe; color: #5b21b6; }
.status-accepted   { background: #d1fae5; color: #065f46; }
