/* =====================================================================
   OrderFlow UI  —  modern, responsive, light/dark
   ===================================================================== */
:root {
  --of-primary: #4f46e5;
  --of-primary-600: #4338ca;
  --of-primary-soft: #eef2ff;
  --of-bg: #f4f6fb;
  --of-surface: #ffffff;
  --of-border: #e6e9f2;
  --of-text: #111827;
  --of-muted: #6b7280;
  --of-sidebar: #0f172a;
  --of-sidebar-text: #cbd5e1;
  --of-radius: 14px;
  --of-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-border-radius: 10px;
}
[data-bs-theme="dark"] {
  --of-bg: #0b1020;
  --of-surface: #121a2e;
  --of-border: #233050;
  --of-text: #e5e7eb;
  --of-muted: #94a3b8;
  --of-primary-soft: rgba(99, 102, 241, .16);
  --of-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --bs-body-bg: #0b1020;
  --bs-body-color: #e5e7eb;
  --bs-border-color: #233050;
}
html, body { background: var(--of-bg); color: var(--of-text); }
body { font-size: .925rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: var(--of-primary); --bs-btn-border-color: var(--of-primary); --bs-btn-hover-bg: var(--of-primary-600); --bs-btn-hover-border-color: var(--of-primary-600); --bs-btn-active-bg: var(--of-primary-600); --bs-btn-disabled-bg: var(--of-primary); --bs-btn-disabled-border-color: var(--of-primary); }
.btn-outline-primary { --bs-btn-color: var(--of-primary); --bs-btn-border-color: var(--of-primary); --bs-btn-hover-bg: var(--of-primary); --bs-btn-hover-border-color: var(--of-primary); --bs-btn-active-bg: var(--of-primary); }
.btn { font-weight: 600; border-radius: 10px; }
.text-primary { color: var(--of-primary) !important; }
.bg-primary-soft { background: var(--of-primary-soft); }
.form-control, .form-select { border-radius: 10px; border-color: var(--of-border); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--of-primary); box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15); }
.form-label { font-weight: 600; font-size: .82rem; color: var(--of-muted); margin-bottom: .3rem; }
.form-label .req { color: #ef4444; }

/* ----------------------------- Layout ----------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar, .sidebar.offcanvas-lg { width: 264px; background: var(--of-sidebar) !important; background-color: var(--of-sidebar) !important; color: var(--of-sidebar-text); flex-shrink: 0; border-right: 1px solid #1e293b; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
@media (max-width: 991.98px) { .sidebar { --bs-offcanvas-width: 280px; background: var(--of-sidebar) !important; } }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 1.2rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 6px 16px rgba(99, 102, 241, .45); }
.brand-name { color: #fff; font-weight: 800; font-size: 1.1rem; letter-spacing: -.01em; }
.brand-sub { font-size: .72rem; color: var(--of-sidebar-text); max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { padding: .5rem .75rem 2rem; display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; font-weight: 700; padding: 1rem .75rem .35rem; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 10px; color: var(--of-sidebar-text) !important; font-weight: 600; transition: background .15s, color .15s, transform .15s; }
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .1); color: #fff !important; transform: translateX(2px); }
.sidebar-nav .nav-link:hover i { color: #a5b4fc; }
.sidebar-nav .nav-link.active { background: linear-gradient(90deg, #4f46e5, #6366f1); color: #fff !important; box-shadow: 0 6px 16px rgba(79, 70, 229, .45); }
.sidebar-nav .nav-link.active i { color: #fff; }
.sidebar .brand-name { color: #fff !important; }
.sidebar::-webkit-scrollbar { width: 6px; } .sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .75rem 1.5rem;
  background: color-mix(in srgb, var(--of-bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--of-border); }
.page-title { font-size: 1.2rem; font-weight: 800; margin: 0; letter-spacing: -.02em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .35rem; }
.btn-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; padding: 0; font-size: 1.15rem; color: var(--of-text); background: transparent; border: 0; }
.btn-icon:hover { background: var(--of-surface); }
.user-chip { display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem .25rem .25rem; border-radius: 30px; border: 1px solid var(--of-border); background: var(--of-surface); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7); flex-shrink: 0; }
.notif-dot { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 10px; background: #ef4444; color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; }
.notif-menu { width: 340px; max-width: 92vw; padding: 0; border-radius: 14px; overflow: hidden; }
#notifList { max-height: 380px; overflow-y: auto; }
.notif-item { display: block; padding: .7rem 1rem; border-bottom: 1px solid var(--of-border); color: var(--of-text); }
.notif-item.unread { background: var(--of-primary-soft); }
.notif-item:hover { background: var(--of-bg); }
.content { padding: 1.5rem; flex: 1; }
.app-footer { padding: 1rem 1.5rem 1.5rem; color: var(--of-muted); font-size: .78rem; }
.impersonate-bar { background: linear-gradient(90deg, #f59e0b, #f97316); color: #fff; padding: .5rem 1.25rem; font-size: .85rem; }

@media (max-width: 991.98px) {
  .content { padding: 1rem .85rem 6.5rem; }
  .topbar { padding: .6rem .85rem; }
  .app-footer { display: none; }
}

/* ----------------------------- Cards ----------------------------- */
.card { border: 1px solid var(--of-border); border-radius: var(--of-radius); background: var(--of-surface); box-shadow: var(--of-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--of-border); padding: 1rem 1.25rem; font-weight: 700; }
.card-body { padding: 1.25rem; }
.stat-card { padding: 1.1rem 1.2rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-value { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { color: var(--of-muted); font-size: .8rem; font-weight: 500; }
.si-indigo { background: #eef2ff; color: #4f46e5; } .si-amber { background: #fef3c7; color: #d97706; }
.si-green { background: #dcfce7; color: #16a34a; } .si-rose { background: #ffe4e6; color: #e11d48; }
.si-sky { background: #e0f2fe; color: #0284c7; } .si-violet { background: #f3e8ff; color: #9333ea; }
[data-bs-theme="dark"] .stat-icon { filter: saturate(1.2); background-color: rgba(255,255,255,.06); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }

/* ----------------------------- Tables ----------------------------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--of-muted); font-weight: 700; background: var(--of-bg); border-bottom: 1px solid var(--of-border); white-space: nowrap; padding: .7rem .9rem; }
.table > tbody td { padding: .75rem .9rem; vertical-align: middle; border-color: var(--of-border); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--of-primary-soft); }
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--of-bg); border: 1px solid var(--of-border); }
.thumb-lg { width: 96px; height: 96px; border-radius: 14px; object-fit: cover; border: 1px solid var(--of-border); }

/* Mobile: table -> cards */
@media (max-width: 767.98px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border: 1px solid var(--of-border); border-radius: 12px; margin-bottom: .75rem; padding: .5rem .25rem; background: var(--of-surface); }
  .table-cards td { border: 0 !important; padding: .3rem .75rem !important; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table-cards td::before { content: attr(data-label); font-weight: 600; color: var(--of-muted); font-size: .78rem; text-align: left; }
  .table-cards td[data-label=""]::before { display: none; }
  .table-cards td.td-main { font-size: 1rem; justify-content: flex-start; text-align: left; }
  .table-cards td.td-main::before { display: none; }
  .card .table-responsive { border: 0; }
  .card-table-mobile { background: transparent; border: 0; box-shadow: none; }
  .card-table-mobile > .card-body, .card-table-mobile .table-responsive { padding: 0; }
}

/* ----------------------------- Status ----------------------------- */
.badge-status { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .65rem; border-radius: 30px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.bs-warning { background: #fef3c7; color: #b45309; } .bs-info { background: #e0f2fe; color: #0369a1; }
.bs-primary { background: #e0e7ff; color: #4338ca; } .bs-indigo { background: #ede9fe; color: #6d28d9; }
.bs-success { background: #dcfce7; color: #15803d; } .bs-danger { background: #fee2e2; color: #b91c1c; }
.bs-secondary { background: #e5e7eb; color: #4b5563; }
.bs-orange { background: #ffedd5; color: #c2410c; }
[data-bs-theme="dark"] .badge-status { filter: brightness(.9); }
.badge-soft { background: var(--of-primary-soft); color: var(--of-primary); font-weight: 600; border-radius: 6px; padding: .25rem .5rem; font-size: .75rem; }
.flash-update { animation: flash 1.6s ease; }
@keyframes flash { 0%, 100% { box-shadow: none; } 30% { box-shadow: 0 0 0 4px rgba(79, 70, 229, .35); } }

/* Timeline (order tracking) */
.tracker { display: flex; justify-content: space-between; position: relative; margin: .5rem 0 1rem; }
.tracker::before { content: ''; position: absolute; top: 18px; left: 6%; right: 6%; height: 3px; background: var(--of-border); }
.tracker .bar { position: absolute; top: 18px; left: 6%; height: 3px; background: linear-gradient(90deg, #6366f1, #22c55e); transition: width .6s; }
.tracker .step { position: relative; z-index: 1; text-align: center; flex: 1; font-size: .72rem; color: var(--of-muted); font-weight: 600; }
.tracker .dot { width: 38px; height: 38px; border-radius: 50%; margin: 0 auto .35rem; display: grid; place-items: center; background: var(--of-surface); border: 3px solid var(--of-border); font-size: 1rem; }
.tracker .step.done { color: var(--of-text); } .tracker .step.done .dot { background: #6366f1; border-color: #6366f1; color: #fff; }
.tracker .step.current .dot { box-shadow: 0 0 0 5px rgba(99, 102, 241, .2); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.6rem; }
.timeline li::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: -4px; width: 2px; background: var(--of-border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ''; position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--of-primary); border: 3px solid var(--of-primary-soft); }

/* ----------------------------- Order form ----------------------------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; max-height: 62vh; overflow-y: auto; padding: 2px; }
.p-card { border: 1px solid var(--of-border); border-radius: 12px; background: var(--of-surface); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: .15s; }
.p-card:hover { border-color: var(--of-primary); transform: translateY(-2px); }
.p-card.in-cart { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, .25); }
.p-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--of-bg); }
.p-card .p-body { padding: .55rem .65rem .65rem; font-size: .8rem; }
.p-card .p-name { font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2em; }
.p-card .p-price { color: var(--of-primary); font-weight: 800; }
.cat-pills { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; scrollbar-width: none; }
.cat-pills .btn { white-space: nowrap; border-radius: 30px; font-size: .78rem; padding: .3rem .8rem; }
.cart-line { display: flex; gap: .65rem; align-items: center; padding: .7rem 0; border-bottom: 1px dashed var(--of-border); }
.cart-line:last-child { border-bottom: 0; }
.qty-box { display: inline-flex; align-items: center; border: 1px solid var(--of-border); border-radius: 10px; overflow: hidden; }
.qty-box button { border: 0; background: var(--of-bg); width: 30px; height: 32px; font-weight: 700; color: var(--of-text); }
.qty-box input { width: 56px; border: 0; text-align: center; height: 32px; background: var(--of-surface); color: var(--of-text); font-weight: 700; }
.qty-box input:focus { outline: none; }
.sticky-summary { position: sticky; top: 80px; }
.mobile-cart-bar { display: none; }
@media (max-width: 991.98px) {
  .sticky-summary { position: static; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); max-height: none; }
  .mobile-cart-bar { display: flex; position: fixed; left: .75rem; right: .75rem; bottom: 76px; z-index: 1030; background: var(--of-primary); color: #fff; border-radius: 14px; padding: .7rem 1rem; align-items: center; justify-content: space-between; box-shadow: 0 10px 30px rgba(79, 70, 229, .4); }
}

/* ----------------------------- Bottom nav ----------------------------- */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; display: flex; justify-content: space-around; align-items: center;
  background: var(--of-surface); border-top: 1px solid var(--of-border); padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 20px rgba(0, 0, 0, .06); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .68rem; color: var(--of-muted); font-weight: 600; gap: 2px; padding: .25rem 0; }
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--of-primary); }
.bottom-nav a.fab { flex: 0 0 56px; height: 56px; border-radius: 18px; margin-top: -28px; color: #fff; background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 8px 20px rgba(99, 102, 241, .5); justify-content: center; }
.bottom-nav a.fab i { font-size: 1.6rem; }

/* ----------------------------- Misc ----------------------------- */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state i { font-size: 3rem; color: var(--of-muted); display: block; margin-bottom: .5rem; opacity: .6; }
.perm-group { border: 1px solid var(--of-border); border-radius: 12px; padding: .9rem 1rem; margin-bottom: .75rem; }
.perm-group h6 { font-weight: 700; font-size: .85rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-bar .form-control, .filter-bar .form-select { max-width: 220px; }
@media (max-width: 575.98px) { .filter-bar .form-control, .filter-bar .form-select { max-width: none; flex: 1 1 45%; } }
.status-tabs { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; margin-bottom: 1rem; }
.status-tabs a { white-space: nowrap; padding: .45rem .85rem; border-radius: 30px; border: 1px solid var(--of-border); background: var(--of-surface); color: var(--of-text); font-size: .8rem; font-weight: 600; }
.status-tabs a.active { background: var(--of-primary); border-color: var(--of-primary); color: #fff; }
.status-tabs a .count { opacity: .7; margin-left: .2rem; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: .35rem .75rem; font-size: .88rem; }
.kv dt { color: var(--of-muted); font-weight: 500; } .kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.img-preview { display: flex; flex-wrap: wrap; gap: .5rem; }
.img-preview .ip { position: relative; }
.img-preview .ip .btn { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; padding: 0; border-radius: 50%; font-size: .7rem; }
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0 !important; }
.ts-control { border-radius: 10px !important; padding: .5rem .8rem !important; border-color: var(--of-border) !important; }
[data-bs-theme="dark"] .ts-control, [data-bs-theme="dark"] .ts-dropdown { background: var(--of-surface) !important; color: var(--of-text) !important; }
[data-bs-theme="dark"] .ts-dropdown .active { background: var(--of-primary-soft) !important; color: #fff !important; }
.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .55rem; font-size: .82rem; }
.bar-row .bar-label { width: 38%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { flex: 1; height: 10px; background: var(--of-bg); border-radius: 10px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #a855f7); border-radius: 10px; }
.bar-row .bar-val { width: 90px; text-align: right; font-weight: 700; }

/* ----------------------------- Auth ----------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(circle at 20% 20%, #6366f1 0, transparent 45%), radial-gradient(circle at 80% 70%, #a855f7 0, transparent 45%), #0f172a; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { font-weight: 800; font-size: 2.4rem; letter-spacing: -.03em; line-height: 1.1; }
.auth-hero .feat { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; color: #cbd5e1; }
.auth-hero .feat i { font-size: 1.2rem; color: #a5b4fc; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: var(--of-surface); }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }
