/* ================= ERP Software – Application Styles ================= */
:root {
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1d4ed8;
  --content-bg: #f1f5f9;
  --card-border: #e2e8f0;
  --bs-primary: #1d4ed8;
  --bs-primary-rgb: 29, 78, 216;
}
[data-bs-theme="dark"] {
  --content-bg: #0b1220;
  --card-border: #1e293b;
  --sidebar-bg: #070d1a;
}
html, body { height: 100%; }
body { background: var(--content-bg); font-size: 14px; font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; overflow-x: hidden; }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: #1d4ed8; --bs-btn-border-color: #1d4ed8; --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; }
.text-primary { color: #1d4ed8 !important; }
.bg-primary { background: #1d4ed8 !important; }

/* Layout */
.app-wrapper { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text); position: fixed; top: 0; bottom: 0; left: 0; z-index: 1040; display: flex; flex-direction: column; transition: transform .25s ease; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { width: 36px; height: 36px; border-radius: 10px; background: #1d4ed8; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.brand-logo { height: 36px; max-width: 40px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; }
.brand-text { color: #fff; font-weight: 700; font-size: 15px; max-width: 170px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0 20px; scrollbar-width: thin; }
.sidebar-nav::-webkit-scrollbar { width: 5px; } .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
.sidebar .nav-header { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 16px 20px 6px; font-weight: 600; }
.sidebar .nav-link { color: var(--sidebar-text); padding: 9px 18px; display: flex; align-items: center; gap: 12px; font-size: 13.5px; border-left: 3px solid transparent; border-radius: 0; }
.sidebar .nav-link i:first-child { font-size: 16px; width: 20px; text-align: center; opacity: .85; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar .nav-link.active { color: #fff; background: rgba(29,78,216,.25); border-left-color: #3b82f6; }
.sidebar .nav-link .arrow { margin-left: auto; font-size: 11px; transition: transform .2s; }
.sidebar .nav-link.has-sub:not(.collapsed) .arrow { transform: rotate(180deg); }
.sidebar .sub-nav { background: rgba(0,0,0,.2); }
.sidebar .sub-nav .nav-link { padding: 7px 18px 7px 50px; font-size: 13px; }
.sidebar .sub-nav .nav-link.active { background: transparent; color: #93c5fd; border-left-color: transparent; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1035; }

.main-wrapper { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin .25s ease; }
.topbar { height: var(--topbar-h); background: var(--bs-body-bg); border-bottom: 1px solid var(--card-border); display: flex; align-items: center; gap: 10px; padding: 0 16px; position: sticky; top: 0; z-index: 1030; }
.btn-icon { border: 0; background: transparent; padding: 6px 10px; border-radius: 8px; color: var(--bs-body-color); }
.btn-icon:hover { background: rgba(0,0,0,.05); }
[data-bs-theme="dark"] .btn-icon:hover { background: rgba(255,255,255,.08); }
.global-search { position: relative; flex: 0 1 460px; align-items: center; }
.global-search > i { position: absolute; left: 12px; color: #94a3b8; }
.global-search input { padding-left: 36px; border-radius: 10px; background: var(--content-bg); border-color: transparent; }
.global-search input:focus { background: var(--bs-body-bg); }
.search-results { display: none; position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; background: var(--bs-body-bg); border: 1px solid var(--card-border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 420px; overflow-y: auto; z-index: 2000; }
.search-results.show { display: block; }
.search-results .sr-group { font-size: 11px; text-transform: uppercase; color: #94a3b8; padding: 8px 12px 2px; letter-spacing: .05em; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 12px; color: var(--bs-body-color); }
.search-results a:hover { background: rgba(29,78,216,.08); }
.notif-badge { position: absolute; top: 2px; right: 2px; font-size: 9px; padding: 3px 5px; }
.notif-menu { width: 340px; max-width: 92vw; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--card-border); color: var(--bs-body-color); }
.notif-item.unread { background: rgba(29,78,216,.06); }
.notif-item .ni-icon { width: 34px; height: 34px; border-radius: 50%; background: rgba(29,78,216,.12); color: #1d4ed8; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.avatar-initials { background: #1d4ed8; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; font-size: 24px; }

.content { flex: 1; padding: 20px; }
.footer { padding: 10px 20px; border-top: 1px solid var(--card-border); font-size: 12px; display: flex; justify-content: space-between; }

/* Page header */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.page-header h1 { font-size: 20px; font-weight: 700; margin: 0; }
.page-header .breadcrumb { margin: 0; font-size: 12px; }

/* Cards */
.card { border: 1px solid var(--card-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-header { background: transparent; border-bottom: 1px solid var(--card-border); font-weight: 600; padding: 12px 18px; }
.stat-card { border-radius: 12px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; background: var(--bs-body-bg); border: 1px solid var(--card-border); height: 100%; }
.stat-card .stat-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-card .stat-label { font-size: 12px; color: #64748b; margin-bottom: 2px; }
.stat-card .stat-value { font-size: 19px; font-weight: 700; line-height: 1.2; }
.stat-card .stat-sub { font-size: 11px; color: #94a3b8; }
.bg-soft-primary { background: rgba(29,78,216,.12); color: #1d4ed8; }
.bg-soft-success { background: rgba(22,163,74,.12); color: #16a34a; }
.bg-soft-danger { background: rgba(220,38,38,.12); color: #dc2626; }
.bg-soft-warning { background: rgba(217,119,6,.12); color: #d97706; }
.bg-soft-info { background: rgba(2,132,199,.12); color: #0284c7; }
.bg-soft-purple { background: rgba(124,58,237,.12); color: #7c3aed; }
.bg-soft-dark { background: rgba(51,65,85,.12); color: #334155; }
.bg-soft-secondary { background: rgba(100,116,139,.12); color: #64748b; }

/* Tables */
.table-card .table { margin-bottom: 0; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: #64748b; font-weight: 600; background: rgba(0,0,0,.02); white-space: nowrap; border-bottom-width: 1px; }
[data-bs-theme="dark"] .table thead th { background: rgba(255,255,255,.03); }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: rgba(29,78,216,.04); }
.table .actions { white-space: nowrap; }
.table .actions .btn { padding: 2px 7px; font-size: 13px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }
.table-responsive { border-radius: 12px; }
.badge { font-weight: 500; }
.text-amount { font-variant-numeric: tabular-nums; }

/* Forms */
.form-label { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.form-label.required::after { content: " *"; color: #dc2626; }
.form-control, .form-select { font-size: 14px; }
.form-section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; font-weight: 600; border-bottom: 1px solid var(--card-border); padding-bottom: 6px; margin: 16px 0 12px; }
.is-invalid ~ .invalid-feedback { display: block; }
.items-table input, .items-table select { min-width: 70px; }
.items-table td { padding: 4px; }
.items-table .form-control, .items-table .form-select { padding: 4px 8px; font-size: 13px; }
.product-search-wrap { position: relative; }
.product-suggest { position: absolute; top: 100%; left: 0; min-width: 320px; z-index: 1100; background: var(--bs-body-bg); border: 1px solid var(--card-border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 260px; overflow-y: auto; display: none; }
.product-suggest.show { display: block; }
.product-suggest div { padding: 7px 12px; cursor: pointer; font-size: 13px; }
.product-suggest div:hover, .product-suggest div.active { background: rgba(29,78,216,.08); }
.totals-box { background: rgba(0,0,0,.02); border-radius: 10px; padding: 12px 16px; }
[data-bs-theme="dark"] .totals-box { background: rgba(255,255,255,.03); }
.totals-box .row + .row { margin-top: 6px; }

/* Detail view */
.detail-list dt { font-weight: 500; color: #64748b; font-size: 12.5px; }
.detail-list dd { margin-bottom: 8px; }
.nav-tabs .nav-link { font-size: 13.5px; }
.timeline { list-style: none; padding-left: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 12px; top: 6px; bottom: 6px; width: 2px; background: var(--card-border); }
.timeline li { position: relative; padding-left: 36px; margin-bottom: 14px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #1d4ed8; border: 2px solid var(--bs-body-bg); }

/* Kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { min-width: 240px; flex: 1; background: rgba(0,0,0,.03); border-radius: 10px; padding: 10px; }
[data-bs-theme="dark"] .kanban-col { background: rgba(255,255,255,.04); }
.kanban-col h6 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; }
.kanban-card { background: var(--bs-body-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 13px; }

/* Auth pages */
.auth-body { background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; border-radius: 16px; border: 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card .brand-icon { width: 54px; height: 54px; font-size: 26px; border-radius: 14px; }

/* Loader */
.page-loader { position: fixed; inset: 0; background: rgba(255,255,255,.6); z-index: 3000; display: none; align-items: center; justify-content: center; }
[data-bs-theme="dark"] .page-loader { background: rgba(0,0,0,.5); }
.page-loader.show { display: flex; }

/* Permission matrix */
.perm-table td, .perm-table th { text-align: center; padding: 4px 6px; font-size: 12.5px; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; white-space: nowrap; }

/* Misc */
.cursor-pointer { cursor: pointer; }
.fs-13 { font-size: 13px; } .fs-12 { font-size: 12px; }
.w-120 { width: 120px; } .w-90 { width: 90px; }
.mw-0 { min-width: 0; }
.sortable a { color: inherit; }
.empty-state { text-align: center; padding: 40px 20px; color: #94a3b8; }
.empty-state i { font-size: 40px; display: block; margin-bottom: 8px; }
.progress { height: 8px; }
.chart-box { position: relative; height: 300px; }
.chart-box-sm { position: relative; height: 220px; }
.toast-container { z-index: 4000; }

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main-wrapper { margin-left: 0; }
  .content { padding: 14px; }
  .page-header h1 { font-size: 18px; }
  .stat-card .stat-value { font-size: 17px; }
}
@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .main-wrapper { margin-left: 0; }
}
@media (max-width: 575.98px) {
  .filter-bar .form-control, .filter-bar .form-select { min-width: 100%; }
  .table td, .table th { font-size: 13px; }
}
@media print {
  .sidebar, .topbar, .footer, .no-print, .page-header .btn, .filter-bar { display: none !important; }
  .main-wrapper { margin: 0; } .content { padding: 0; }
  .card { border: 0; box-shadow: none; }
}
