:root {
  --bs-primary: #5955D1;
  --bs-primary-rgb: 89, 85, 209;
  --bs-secondary: #29294B;
  --bs-success: #009966;
  --bs-info: #7008E7;
  --bs-warning: #F5A70D;
  --bs-danger: #F83636;
  --bs-light: #F2F2F6;
  --bs-dark: #0C243C;
  --heading: #0C243C;
  --body-text: #696981;
  --page-bg: #FDFDFF;
  --sidebar-bg: #ffffff;
  --header-bg: #FDFDFF;
  --card-bg: #ffffff;
  --border: #EEEEF3;
  --sidebar-w: 272px;
  --header-h: 72px;
}

[data-bs-theme="dark"] {
  --heading: #ececf3;
  --body-text: #b3b3c4;
  --page-bg: #151521;
  --sidebar-bg: #1c1c2b;
  --header-bg: #151521;
  --card-bg: #1c1c2b;
  --border: #2b2b3d;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: "Instrument Sans", sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--body-text);
  background: var(--page-bg);
}

h1, h2, h3, h4, h5, h6, .page-title { color: var(--heading); font-weight: 700; }

a { color: var(--bs-primary); text-decoration: none; }
a:hover { color: #4744a7; }

.page-layout { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-brand { padding: 1.15rem 1.25rem 1rem; }
.brand-link { display: flex; align-items: center; gap: 0.75rem; color: inherit; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #5955D1, #7008E7);
  color: #fff; display: grid; place-items: center; font-weight: 800;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: var(--heading); font-size: 0.95rem; }
.brand-text small { color: var(--body-text); font-size: 0.75rem; }

.sidebar-nav { padding: 0.25rem 0.9rem 1rem; overflow: auto; flex: 1; }
.nav-label {
  font-size: 0.7rem; letter-spacing: .08em; text-transform: uppercase;
  color: #97A1C0; padding: 0.85rem 0.75rem 0.35rem;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.62rem 0.8rem; border-radius: 10px; color: var(--heading);
  margin-bottom: 2px;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; color: #8b8ba3; }
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active {
  background: #f5f5fc; color: var(--bs-primary);
}
.sidebar-nav .nav-link.active i { color: var(--bs-primary); }

.sidebar-foot { padding: 0.75rem 1rem 1.1rem; }
.upgrade-card {
  background: #f5f5fc; border-radius: 14px; padding: 1rem;
}
.upgrade-card h6 { color: var(--heading); margin-bottom: 0.35rem; }
.upgrade-card p { font-size: 0.78rem; margin-bottom: 0.75rem; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  height: var(--header-h);
  display: flex; align-items: center; padding: 0 1.25rem; gap: 1rem;
}
.app-toggler {
  width: 38px; height: 38px; border: 1px solid var(--border); background: #fff;
  border-radius: 10px; display: none;
}
.app-header-start { display: flex; align-items: center; gap: 1rem; flex: 1; }
.header-search { position: relative; width: min(320px, 100%); }
.header-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #97A1C0; }
.header-search .form-control {
  padding-left: 2.1rem; background: #F2F2F6; border: 0; height: 42px; border-radius: 10px;
}
.badge-standard {
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: 0.4rem 0.75rem; font-size: 0.8rem; color: var(--heading);
}
.app-header-end { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.btn-icon {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: #F2F2F6; color: var(--heading);
}
.theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: inline; }
.profile-btn {
  display: flex; align-items: center; gap: 0.6rem; border: 0; background: transparent; padding: 0;
}
.profile-btn strong, .profile-btn small { display: block; text-align: left; }
.profile-btn strong { color: var(--heading); font-size: 0.85rem; }
.profile-btn small { color: var(--body-text); font-size: 0.72rem; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: #5955D1; color: #fff; display: grid; place-items: center; font-weight: 700;
}
.profile-menu { min-width: 240px; border: 1px solid var(--border); border-radius: 12px; }
.notify-btn { position: relative; }
.notify-dot {
  position: absolute; top: 6px; right: 6px; width: 9px; height: 9px;
  background: #5955D1; border: 2px solid #fff; border-radius: 50%;
}
.notify-menu {
  width: min(340px, calc(100vw - 1.5rem)); padding: 0;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
}
.notify-head, .notify-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--border);
}
.notify-head h6 { color: var(--heading); }
.notify-foot {
  border-bottom: 0; border-top: 1px solid var(--border); justify-content: center;
  color: #5955D1; font-weight: 600; font-size: 0.82rem;
}
.notify-list { max-height: 320px; overflow: auto; }
.notify-item {
  display: flex; gap: 0.7rem; padding: 0.8rem 1rem; position: relative;
  border-bottom: 1px solid var(--border); color: inherit;
}
.notify-item:last-child { border-bottom: 0; }
.notify-item.unread { background: #f5f5fc; }
.notify-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: grid; place-items: center;
}
.notify-body { min-width: 0; flex: 1; padding-right: 3.2rem; }
.notify-body strong, .notify-body small { display: block; }
.notify-body strong { color: var(--heading); font-size: 0.82rem; }
.notify-body small { color: var(--body-text); }
.notify-time {
  position: absolute; top: 0.8rem; right: 0.9rem;
  font-size: 0.7rem; color: #97A1C0;
}
.notify-empty { padding: 1.4rem 1rem; text-align: center; color: #97A1C0; }
.notify-push {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #f5f5fc;
  font-size: 0.78rem;
  color: var(--body-text);
}
.notify-push.is-on {
  background: transparent;
  color: #009966;
  font-weight: 600;
}
.push-help-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  display: grid; place-items: center;
  background: #5955D1; color: #fff; font-size: 1.1rem;
}
.push-help ul { padding-left: 1.1rem; }

.app-content { padding: 1.25rem 1.4rem 5.5rem; flex: 1; }
.page-head { margin-bottom: 1.15rem; }
.page-title { font-size: 1.45rem; }
.breadcrumb { font-size: 0.78rem; }
.breadcrumb-item a { color: var(--body-text); }

.nl-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 16px; padding: 1rem 1.1rem; box-shadow: 0 8px 24px rgba(45, 42, 60, 0.04);
}
.nl-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.85rem;
}
.nl-card-head h5 { margin: 0; font-size: 1rem; }

.stat-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.05rem 1.1rem; min-height: 132px; position: relative;
  box-shadow: 0 8px 24px rgba(45, 42, 60, 0.04);
}
.stat-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  margin-bottom: 0.7rem; font-size: 1.05rem;
}
.stat-label { font-size: 0.8rem; margin-bottom: 0.15rem; }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--heading); line-height: 1.2; }
.stat-meta { font-size: 0.75rem; margin-top: 0.35rem; }

.table { --bs-table-bg: transparent; color: var(--heading); }
.table thead th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em;
  color: #97A1C0; border-bottom-color: var(--border); font-weight: 600;
}
.table td { border-color: var(--border); }
.badge { font-weight: 600; }

.soft-list { list-style: none; padding: 0; margin: 0; }
.soft-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 0; border-bottom: 1px solid var(--border); gap: 0.75rem;
}
.soft-list li:last-child { border-bottom: 0; }
.soft-list small { display: block; color: var(--body-text); }

.info-list { display: grid; grid-template-columns: 110px 1fr; gap: 0.45rem 0.75rem; margin: 0; }
.info-list-wide { grid-template-columns: 140px 1fr; }
.info-list dt { color: #97A1C0; font-weight: 500; }
.info-list dd { margin: 0; color: var(--heading); }

.dealer-tabs {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  border-bottom: 1px solid var(--border); padding: 0.15rem 0.15rem 0;
}
.dealer-tabs .nav-link {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--body-text); padding: 0.75rem 0.95rem; font-weight: 600;
}
.dealer-tabs .nav-link:hover { color: var(--bs-primary); }
.dealer-tabs .nav-link.active {
  color: #5955D1; border-bottom-color: #5955D1; background: transparent;
}
.tab-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 999px; background: #f5f5fc; color: #5955D1;
  font-size: 0.7rem; margin-left: 0.25rem;
}
.dealer-tab-body { padding-top: 1.15rem; }

.btn {
  --bs-btn-font-weight: 500;
  border-radius: 0.375rem;
}
.btn-outline-primary {
  --bs-btn-color: #5955D1;
  --bs-btn-border-color: #5955D1;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #5955D1;
  --bs-btn-hover-border-color: #5955D1;
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: #5955D1;
  --bs-btn-active-border-color: #5955D1;
}
.btn-outline-secondary {
  --bs-btn-color: #29294B;
  --bs-btn-border-color: #29294B;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #29294B;
  --bs-btn-hover-border-color: #29294B;
}
.btn-outline-success {
  --bs-btn-color: #009966;
  --bs-btn-border-color: #009966;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #009966;
  --bs-btn-hover-border-color: #009966;
}
.btn-outline-danger {
  --bs-btn-color: #F83636;
  --bs-btn-border-color: #F83636;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #F83636;
  --bs-btn-hover-border-color: #F83636;
}
.btn-outline-warning {
  --bs-btn-color: #F5A70D;
  --bs-btn-border-color: #F5A70D;
  --bs-btn-hover-color: #0C243C;
  --bs-btn-hover-bg: #F5A70D;
  --bs-btn-hover-border-color: #F5A70D;
}
.btn-outline-info {
  --bs-btn-color: #7008E7;
  --bs-btn-border-color: #7008E7;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #7008E7;
  --bs-btn-hover-border-color: #7008E7;
}
.btn-outline-dark {
  --bs-btn-color: #0C243C;
  --bs-btn-border-color: #0C243C;
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: #0C243C;
  --bs-btn-hover-border-color: #0C243C;
}
.form-control, .form-select {
  border-color: var(--border); min-height: 42px; border-radius: 10px;
}
.form-control:focus, .form-select:focus {
  border-color: #5955D1; box-shadow: 0 0 0 .2rem rgba(89,85,209,.15);
}
.form-label { color: var(--heading); font-weight: 600; font-size: 0.8rem; }

.app-footer {
  padding: 0.9rem 1.4rem 5.2rem; color: #97A1C0; font-size: 0.78rem;
}

.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.product-tile {
  border: 1px solid var(--border); border-radius: 12px; padding: 0.85rem;
  background: #fbfbfe;
}
.product-tile-image {
  height: 140px; border-radius: 10px; overflow: hidden; margin-bottom: 0.7rem;
  background: #eef0f7; display: grid; place-items: center;
}
.product-tile-image img { width: 100%; height: 100%; object-fit: cover; }
.product-thumb {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover;
  background: #eef0f7; display: inline-grid; place-items: center; color: #97A1C0;
}
.product-thumb-empty { font-size: 1.1rem; }
.image-upload { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.image-preview {
  width: 140px; height: 140px; border-radius: 12px; overflow: hidden;
  background: #eef0f7; display: grid; place-items: center; border: 1px solid var(--border);
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-placeholder { color: #97A1C0; font-size: 1.6rem; }
.product-tile-top { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.25rem; }
.product-tile-top strong { color: var(--heading); }
.qty-row { display: flex; gap: 0.4rem; margin-top: 0.65rem; }
.sticky-card { position: sticky; top: 90px; }
.cart-line {
  display: flex; justify-content: space-between; gap: 0.5rem;
  padding: 0.65rem 0; border-bottom: 1px solid var(--border);
}
.cart-line small { display: block; color: var(--body-text); }
.cart-totals { padding: 0.85rem 0; }
.cart-totals > div { display: flex; justify-content: space-between; margin-bottom: 0.35rem; }
.cart-totals .total { color: var(--heading); font-size: 1.05rem; }
.pay-method-list { display: grid; gap: 0.55rem; }
.pay-method {
  display: flex; align-items: flex-start; gap: 0.65rem;
  border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.85rem;
  cursor: pointer; background: #fff;
}
.pay-method:has(input:checked) { border-color: #5955D1; box-shadow: 0 0 0 3px rgba(89, 85, 209, 0.12); }
.pay-method input { margin-top: 0.2rem; }
.pay-method strong { display: block; color: var(--heading); font-size: 0.92rem; }
.pay-method small { display: block; color: var(--body-text); line-height: 1.35; }
.pay-method-list { display: grid; gap: 0.55rem; }
.pay-method {
  display: flex; align-items: flex-start; gap: 0.65rem;
  border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.85rem;
  cursor: pointer; background: #fff;
}
.pay-method:has(input:checked) { border-color: #5955D1; box-shadow: 0 0 0 3px rgba(89, 85, 209, 0.12); }
.pay-method input { margin-top: 0.2rem; }
.pay-method strong { display: block; color: var(--heading); font-size: 0.92rem; }
.pay-method small { display: block; color: var(--body-text); line-height: 1.35; }

.mobile-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #fff; border-top: 1px solid var(--border);
  padding: 0.4rem 0.4rem calc(0.4rem + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.mobile-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
  font-size: 0.68rem; color: #8b8ba3; min-width: 56px; padding: 0.25rem;
}
.mobile-nav a i { font-size: 1.15rem; }
.mobile-nav a.active { color: #5955D1; }

.auth-body { min-height: 100vh; background: linear-gradient(180deg, #f5f5fc 0%, #FDFDFF 100%); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
  width: min(440px, 100%); background: #fff; border: 1px solid var(--border);
  border-radius: 20px; padding: 2rem 1.6rem; box-shadow: 0 18px 50px rgba(41, 41, 75, 0.08);
}
.auth-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.4rem; }
.auth-brand strong, .auth-card h1 { color: var(--heading); }
.auth-brand small, .auth-lead, .auth-note { color: var(--body-text); display: block; }
.auth-card h1 { font-size: 1.45rem; margin-bottom: 0.35rem; }
.auth-lead { margin-bottom: 1.25rem; }
.auth-note { margin-top: 1.1rem; font-size: 0.78rem; text-align: center; }

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 12px 0 40px rgba(0,0,0,.08);
  }
  .page-layout.sidebar-open .app-sidebar { transform: none; }
  .app-toggler { display: inline-grid; place-items: center; }
  .mobile-nav { display: flex; }
  .product-grid { grid-template-columns: 1fr; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(12,36,60,.28); z-index: 35;
  }
  .page-layout.sidebar-open .sidebar-backdrop { display: block; }
  .app-content { padding: 1rem 0.85rem 6.2rem; }
  .page-title { font-size: 1.2rem; }
  .stat-value { font-size: 1.05rem; word-break: break-word; }
  .stat-card { min-height: 0; padding: 0.9rem; }
  .nl-card { padding: 0.85rem; }
  .nl-card-head { flex-wrap: wrap; }
  .nl-card-head form { width: 100%; flex-wrap: wrap; }
  .nl-card-head .form-control,
  .nl-card-head .form-select { width: 100%; max-width: none !important; }
  .info-list,
  .info-list-wide { grid-template-columns: 1fr; }
  .dealer-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .dealer-tabs .nav-link { white-space: nowrap; padding: 0.7rem 0.7rem; }

  .table-responsive { overflow: visible; }
  table.mobile-cards thead { display: none; }
  table.mobile-cards,
  table.mobile-cards tbody,
  table.mobile-cards tfoot { display: block; width: 100%; }
  table.mobile-cards tbody tr {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.7rem;
    box-shadow: 0 8px 20px rgba(45, 42, 60, 0.04);
  }
  table.mobile-cards tbody tr:last-child { margin-bottom: 0; }
  table.mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    border: 0 !important;
    padding: 0.36rem 0 !important;
    text-align: right;
    white-space: normal;
  }
  table.mobile-cards td[data-label]::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--heading);
    text-align: left;
  }
  table.mobile-cards td.card-title {
    display: block;
    text-align: left;
    padding-bottom: 0.55rem !important;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border) !important;
  }
  table.mobile-cards td.card-title::before { display: none; }
  table.mobile-cards td.card-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 0.7rem !important;
    margin-top: 0.35rem;
    border-top: 1px solid var(--border) !important;
  }
  table.mobile-cards td.card-actions::before { display: none; }
  table.mobile-cards td.card-empty {
    display: block;
    text-align: center;
    justify-content: center;
  }
  table.mobile-cards td.card-empty::before { display: none; }
  table.mobile-cards tfoot tr {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0.15rem;
  }
  table.mobile-cards tfoot td { border: 0 !important; padding: 0 !important; }
  table.mobile-cards tfoot td[colspan] { display: block; }
}

[data-bs-theme="dark"] .app-toggler,
[data-bs-theme="dark"] .btn-icon,
[data-bs-theme="dark"] .header-search .form-control,
[data-bs-theme="dark"] .upgrade-card,
[data-bs-theme="dark"] .product-tile,
[data-bs-theme="dark"] .mobile-nav,
[data-bs-theme="dark"] .auth-card {
  background: #232336;
  color: var(--heading);
}
[data-bs-theme="dark"] .sidebar-nav .nav-link:hover,
[data-bs-theme="dark"] .sidebar-nav .nav-link.active { background: #26263a; }
