:root {
  --se-primary: #1a4d3e;
  --se-primary-dark: #0f3329;
  --se-accent: #c4a35a;
  --se-bg: #f0f2f5;
  --se-sidebar: #14261f;
  --se-sidebar-hover: #1e3a2f;
  --se-text: #1e293b;
  --se-muted: #64748b;
  --se-card: #ffffff;
  --se-border: #e2e8f0;
  --se-radius: 10px;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--se-bg);
  color: var(--se-text);
  min-height: 100vh;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 transparent;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---------- Auth ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(20, 38, 31, 0.92), rgba(26, 77, 62, 0.85)),
    radial-gradient(ellipse at top right, #c4a35a33, transparent 50%),
    #14261f;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.auth-card .auth-brand {
  background: var(--se-primary);
  color: #fff;
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
}

.auth-card .auth-brand .brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--se-accent), #a8843d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.35rem;
  color: #14261f;
}

.auth-card .auth-brand h1 {
  font-size: 1.35rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.auth-card .auth-brand p {
  margin: 0.35rem 0 0;
  opacity: 0.85;
  font-size: 0.85rem;
}

.auth-card .auth-body { padding: 1.5rem; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--se-sidebar) 0%, #0d1a15 100%);
  color: #e8efeB;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    transform: none;
  }
  body.sidebar-collapsed .main-wrap {
    margin-left: var(--sidebar-collapsed-width);
  }
  body.sidebar-collapsed .sidebar-brand-text,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .nav-text {
    display: none;
  }
  body.sidebar-collapsed .sidebar-brand {
    padding: 0.9rem 0.45rem;
  }
  body.sidebar-collapsed .sidebar-brand-link {
    justify-content: center;
  }
  body.sidebar-collapsed .sidebar-nav {
    padding: 0.5rem 0.35rem 1.25rem;
  }
  body.sidebar-collapsed .sidebar-nav a {
    justify-content: center;
    padding: 0.7rem 0.35rem;
  }
  body.sidebar-collapsed .sidebar-nav a .ico {
    width: auto;
    font-size: 1.2rem;
    opacity: 1;
  }
}

.sidebar-brand {
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.sidebar-logo-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--se-accent), #a8843d);
  color: #14261f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
}

.sidebar-logo-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-brand .name {
  font-weight: 700;
  font-size: 0.98rem;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.sidebar-brand .tag {
  font-size: 0.72rem;
  color: var(--se-accent);
  margin-top: 0.15rem;
  text-transform: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.65rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 163, 90, 0.45) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(196, 163, 90, 0.4);
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(196, 163, 90, 0.75);
}

.sidebar-nav .nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a9488;
  padding: 0.85rem 0.75rem 0.35rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  color: #c5d5cc;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: var(--se-sidebar-hover);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--se-primary);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav a .ico {
  width: 1.25rem;
  text-align: center;
  opacity: 0.9;
}

.topbar {
  background: var(--se-card);
  border-bottom: 1px solid var(--se-border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .page-title {
  font-size: 1.1rem;
  font-weight: 650;
  margin: 0;
}

.topbar-collapse {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--se-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--se-text);
  background: #fff;
  flex-shrink: 0;
  padding: 0;
}
.topbar-collapse:hover {
  background: #f8fafc;
  color: var(--se-primary);
}
.topbar-collapse .bi {
  transition: transform 0.2s ease;
}
body.sidebar-collapsed .topbar-collapse .bi {
  transform: rotate(180deg);
}
.topbar-profile {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-align: left;
  box-shadow: none !important;
}
.topbar-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  background: var(--se-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  overflow: hidden;
}
.topbar-profile-meta {
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}
.topbar-profile-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--se-text);
}
.topbar-profile-email {
  font-size: 0.75rem;
  color: var(--se-muted);
}
.profile-dropdown {
  min-width: 240px;
  padding: 0.75rem 0 0.4rem;
  border: 1px solid var(--se-border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  margin-top: 0.45rem !important;
}
.profile-dropdown-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.15rem 1rem 0.75rem;
  border-bottom: 1px solid var(--se-border);
  margin-bottom: 0.35rem;
}
.profile-dropdown .dropdown-item {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}
.profile-dropdown-logout {
  color: #dc2626 !important;
  font-weight: 600;
}

.page-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.page-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--se-primary);
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.page-greeting {
  font-size: 1.45rem;
  font-weight: 750;
  margin: 0;
  color: #14261f;
}
.page-hero-sub {
  color: var(--se-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}
.live-clock {
  background: var(--se-card);
  border: 1px solid var(--se-border);
  border-radius: var(--se-radius);
  padding: 0.7rem 0.95rem;
  min-width: 220px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.live-clock-head {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #15803d;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}
.live-clock-when {
  font-size: 0.86rem;
  font-weight: 600;
  margin-top: 0.25rem;
}
.live-clock-tz {
  font-size: 0.72rem;
  color: var(--se-muted);
}

.content-area { padding: 1.25rem; flex: 1; overflow-x: auto; }

.crumb-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.35rem 0.4rem;
  background: #fff;
  border: 1px solid var(--se-border);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.crumb-home {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--se-primary);
  color: #fff !important;
  text-decoration: none;
  flex-shrink: 0;
}
.crumb-home:hover {
  background: var(--se-primary-dark);
  color: #fff !important;
}
.crumb-sep {
  color: #94a3b8;
  font-size: 0.7rem;
  display: inline-flex;
}
.crumb-link {
  color: var(--se-primary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}
.crumb-link:hover {
  background: #eef6f2;
}
.crumb-now {
  font-size: 0.82rem;
  font-weight: 650;
  color: #0f172a;
  background: #f1f5f9;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}

.breadcrumb {
  display: none;
}

.card-panel {
  background: var(--se-card);
  border: 1px solid var(--se-border);
  border-radius: var(--se-radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card-panel .card-panel-header {
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--se-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-panel .card-panel-body { padding: 1.15rem; }

.stat-card {
  background: var(--se-card);
  border: 1px solid var(--se-border);
  border-radius: var(--se-radius);
  padding: 1.15rem;
  height: 100%;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--se-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--se-primary);
  margin-top: 0.25rem;
}

.btn-primary {
  --bs-btn-bg: var(--se-primary);
  --bs-btn-border-color: var(--se-primary);
  --bs-btn-hover-bg: var(--se-primary-dark);
  --bs-btn-hover-border-color: var(--se-primary-dark);
  --bs-btn-active-bg: var(--se-primary-dark);
  --bs-btn-active-border-color: var(--se-primary-dark);
}

.table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--se-muted);
  font-weight: 600;
  background: #f8fafc;
  white-space: nowrap;
}

.table td { vertical-align: middle; font-size: 0.92rem; }

.color-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  vertical-align: middle;
  margin-right: 6px;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}

.variant-attr-chip {
  display: inline-block;
  background: #eef6f2;
  color: var(--se-primary);
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  margin: 0.1rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1035;
}

.variant-card {
  background: #fafbfc;
  border-color: var(--se-border) !important;
}
.variant-card .variant-title {
  color: var(--se-primary);
}

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .main-wrap { margin-left: 0; }
  .topbar { flex-wrap: wrap; }
  .pos-qty-wrap { width: 110px; }
}

@media print {
  .no-print, .doc-toolbar, .invoice-toolbar { display: none !important; }
  .sidebar, .sidebar-backdrop, .topbar, footer, .breadcrumb, .crumb-bar, .filters-bar { display: none !important; }
  .btn { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  .print-report-head { display: block !important; }
  .card-panel { box-shadow: none !important; border: 0 !important; }
  body, body.invoice-print-page, body.doc-print-page { background: #fff !important; }
  .invoice-sheet, .doc-a4 { box-shadow: none !important; margin: 0 !important; max-width: none !important; }
  .doc-page-footer { position: fixed; bottom: 0; left: 0; right: 0; }
}

@page {
  size: A4;
  margin: 12mm 12mm 16mm 12mm;
}

.print-report-head { display: none; }

.invoice-print-page, .doc-print-page { background: #e8eaed; }
.invoice-sheet, .doc-a4 {
  max-width: 210mm;
  margin: 1rem auto 2rem;
  background: #fff;
  padding: 14mm 14mm 18mm;
  box-shadow: 0 1px 8px rgba(0,0,0,.08);
  position: relative;
  color: #1e293b;
}
.doc-toolbar {
  max-width: 210mm;
  margin: 0.75rem auto 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem;
}
.doc-letterhead {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 2px solid #1a4d3e;
  padding-bottom: 0.75rem;
  margin-bottom: 0.85rem;
}
.doc-brand { display: flex; gap: 0.85rem; }
.doc-logo { max-height: 72px; max-width: 130px; object-fit: contain; }
.doc-legal { font-size: 1.25rem; font-weight: 700; color: #14261f; }
.doc-trade { font-size: 0.9rem; color: #64748b; }
.doc-meta { font-size: 0.78rem; color: #475569; line-height: 1.35; }
.doc-badge { text-align: right; min-width: 180px; }
.doc-kind { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: #1a4d3e; font-weight: 700; }
.doc-no { font-size: 1.1rem; font-weight: 700; }
.doc-party { margin-bottom: 0.85rem; font-size: 0.9rem; }
.doc-sample { background: #fff3cd; border: 1px solid #ffc107; padding: 0.35rem 0.6rem; margin-bottom: 0.75rem; font-size: 0.8rem; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.doc-table th, .doc-table td { border: 1px solid #cbd5e1; padding: 0.32rem 0.4rem; vertical-align: top; }
.doc-table thead { display: table-header-group; }
.doc-table thead th { background: #1a4d3e; color: #fff; font-weight: 600; }
.doc-table tbody tr { page-break-inside: avoid; break-inside: avoid; }
.doc-table .num { text-align: right; white-space: nowrap; }
.doc-bottom { display: flex; gap: 1.25rem; margin-top: 0.85rem; align-items: flex-start; }
.doc-notes { flex: 1; font-size: 0.82rem; }
.doc-words { margin-top: 0.75rem; padding: 0.5rem 0.6rem; background: #f8fafc; border: 1px solid #e2e8f0; }
.doc-terms { margin-top: 0.75rem; color: #64748b; font-size: 0.75rem; }
.doc-totals { width: 260px; font-size: 0.85rem; border-collapse: collapse; }
.doc-totals td { padding: 0.28rem 0.4rem; border-bottom: 1px solid #e2e8f0; }
.doc-totals .grand { font-weight: 700; background: #f0f7f4; }
.doc-page-footer {
  margin-top: 1.25rem;
  padding-top: 0.4rem;
  border-top: 1px solid #cbd5e1;
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
}
.doc-receipt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem 1.5rem; font-size: 0.9rem; margin: 1rem 0; }
@media (max-width: 700px) {
  .doc-letterhead, .doc-bottom { flex-direction: column; }
  .doc-badge { text-align: left; }
  .doc-totals { width: 100%; }
  .doc-receipt-grid { grid-template-columns: 1fr; }
}

/* ---------- POS ---------- */
.pos-suggest { z-index: 30; max-height: 320px; overflow: auto; top: 100%; left: 0; }
.pos-cart th { white-space: nowrap; font-size: 0.8rem; }
.pos-qty-wrap { width: 140px; }
.pos-qty-wrap .pos-qty { text-align: center; }
@media (min-width: 992px) {
  .pos-layout > .col-lg-4 { position: sticky; top: 0.75rem; }
}

.se-toast-host {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  width: min(520px, calc(100% - 1.5rem));
  pointer-events: none;
}
.se-toast-host .se-app-toast {
  pointer-events: auto;
  margin-bottom: 0.5rem;
}

.dash-chart-wrap {
  position: relative;
  height: 240px;
  max-width: 100%;
  overflow: hidden;
}
.dash-table {
  max-width: 100%;
}
.bg-success-subtle {
  background: #e8f5ef !important;
}
