/* ============================================
   TÔN ĐỨC TRÍ — Quản Lý Bán Hàng
   Design System
   ============================================ */

:root {
  /* Brand colors */
  --navy: #0A326E;
  --navy-900: #071F47;
  --navy-700: #123f85;
  --navy-500: #2d5aa8;
  --navy-100: #E5EBF5;
  --blue: #0758B3;
  --blue-hover: #0847a0;
  --blue-50: #E8F1FB;
  --yellow: #EB8E04;
  --yellow-hover: #C77505;
  --yellow-light: #FFC247;
  --yellow-50: #FFF7E5;

  /* Neutrals */
  --white: #FFFFFF;
  --bg-soft: #F7F9FC;
  --bg-softer: #FBFCFE;
  --border: #E5EAF2;
  --border-strong: #D1D9E6;

  /* Text */
  --ink: #0B1730;
  --ink-2: #3A4A6B;
  --ink-3: #6B7A96;
  --ink-4: #94A0B8;

  /* Semantic */
  --success: #16A34A;
  --success-bg: #E7F6EC;
  --danger: #DC2626;
  --danger-bg: #FDEAEA;
  --warning: var(--yellow);
  --warning-bg: var(--yellow-50);

  /* Radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(10, 50, 110, .04);
  --shadow-sm: 0 1px 2px rgba(10, 50, 110, .04), 0 2px 6px rgba(10, 50, 110, .05);
  --shadow-md: 0 2px 4px rgba(10, 50, 110, .04), 0 8px 24px rgba(10, 50, 110, .08);

  /* Layout */
  --sidebar-w: 248px;
  --header-h: 68px;
  --content-max: 1440px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
.font-display {
  font-family: 'Montserrat', 'Inter', sans-serif;
  color: var(--navy);
  letter-spacing: -0.01em;
}

h1 { font-size: 24px; font-weight: 700; margin: 0; }
h2 { font-size: 18px; font-weight: 700; margin: 0; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); }

button { font-family: inherit; cursor: pointer; }

/* ============================================
   LAYOUT
   ============================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { display: flex; flex-direction: column; gap: 2px; }
.topbar-title .crumb {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}
.topbar-title h1 { font-size: 20px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.content {
  padding: 28px 32px 60px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  background: var(--navy);
  color: var(--white);
  padding: 20px 14px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: 16px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--yellow-light), var(--yellow));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--white);
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.brand-slogan {
  font-size: 11px;
  color: var(--yellow-light);
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, .4);
  padding: 12px 10px 8px;
  font-weight: 600;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, .82);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover {
  background: rgba(255, 255, 255, .06);
  color: var(--white);
}
.nav-item.active {
  background: var(--blue);
  color: var(--white);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(7, 88, 179, .4);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--yellow);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--yellow);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-footer .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--yellow-light);
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar-footer .who {
  font-size: 12.5px;
  color: var(--white);
  font-weight: 600;
  line-height: 1.2;
}
.sidebar-footer .role {
  font-size: 11px;
  color: rgba(255,255,255,.55);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all .15s;
  background: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn-yellow {
  background: var(--yellow);
  color: var(--white);
  border-color: var(--yellow);
}
.btn-yellow:hover { background: var(--yellow-hover); }
.btn-ghost {
  background: var(--white);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-soft); border-color: var(--ink-4); }
.btn-navy {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.btn-navy:hover { background: var(--navy-700); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { padding: 8px; }

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card-header {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 15px; }
.card-header .subtitle {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.card-body { padding: 20px 22px; }

/* ============================================
   KPI CARDS
   ============================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.kpi {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 500;
}
.kpi-label .icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--blue-50);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
}
.kpi-value {
  font-family: 'Montserrat', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.kpi-value .unit { font-size: 14px; color: var(--ink-3); font-weight: 500; margin-left: 3px; }
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--ink-3); }
.kpi-sub {
  font-size: 11.5px;
  color: var(--ink-3);
}

/* Hero KPI (profit/loss) */
.kpi-hero {
  grid-column: span 6;
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 5px solid var(--yellow);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.kpi-hero.loss { border-left-color: var(--danger); }
.kpi-hero::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 40%;
  background: radial-gradient(circle at right, rgba(255, 194, 71, .12), transparent 60%);
  pointer-events: none;
}
.kpi-hero.loss::after {
  background: radial-gradient(circle at right, rgba(220, 38, 38, .10), transparent 60%);
}
.kpi-hero-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi-hero-label .icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--yellow-50);
  color: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
}
.kpi-hero.loss .kpi-hero-label .icon { background: var(--danger-bg); color: var(--danger); }
.kpi-hero-value {
  font-family: 'Montserrat', sans-serif;
  font-size: 52px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 10px 0 8px;
}
.kpi-hero.loss .kpi-hero-value { color: var(--danger); }
.kpi-hero-meta {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 12.5px;
  color: var(--ink-3);
}
.kpi-hero-meta strong { color: var(--ink); font-weight: 700; }
.kpi-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--success-bg);
  color: var(--success);
}
.kpi-hero.loss .kpi-hero-badge {
  background: var(--danger-bg);
  color: var(--danger);
}

.kpi-hero-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  min-width: 140px;
  z-index: 1;
}
.kpi-hero-side .mini {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

/* KPI variants for grid slots */
.kpi.span-2 { grid-column: span 2; }
.kpi.span-3 { grid-column: span 3; }
.kpi.span-4 { grid-column: span 4; }
.kpi.span-6 { grid-column: span 6; }

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-navy { background: var(--navy-100); color: var(--navy); }
.badge-blue { background: var(--blue-50); color: var(--blue); }
.badge-yellow { background: var(--yellow-50); color: var(--yellow); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: var(--bg-soft); color: var(--ink-2); border-color: var(--border); }
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================
   TABLES
   ============================================ */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data thead th {
  background: var(--bg-soft);
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--ink-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-softer); }
table.data .num { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
table.data .num-strong { font-weight: 700; color: var(--navy); }
table.data .profit { color: var(--success); font-weight: 700; }
table.data .loss { color: var(--danger); font-weight: 700; }
table.data th.num, table.data td.num { text-align: right; }
table.data .mono { font-family: 'JetBrains Mono', 'Menlo', monospace; font-size: 12.5px; color: var(--ink-2); }

/* ============================================
   FORMS
   ============================================ */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.field .hint { font-size: 11.5px; color: var(--ink-3); }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(7, 88, 179, .12);
}
.input::placeholder { color: var(--ink-4); }
.textarea { resize: vertical; min-height: 80px; }

.input-group {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--white);
  padding: 0 12px;
  gap: 8px;
}
.input-group:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7, 88, 179, .12); }
.input-group svg { color: var(--ink-3); flex-shrink: 0; }
.input-group input {
  border: none;
  outline: none;
  padding: 9px 0;
  flex: 1;
  font: inherit;
  font-size: 13.5px;
  background: transparent;
  color: var(--ink);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--white);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  background: none;
  color: var(--ink-2);
  border-radius: 6px;
}
.segmented button.active {
  background: var(--navy);
  color: var(--white);
}
.segmented button:hover:not(.active) { background: var(--bg-soft); }

/* ============================================
   MODALS
   ============================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 23, 48, .5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(10, 23, 48, .3);
}
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-soft);
}
.close-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-btn:hover { background: var(--bg-soft); color: var(--ink); }

/* ============================================
   UTILS
   ============================================ */

.row-gap { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.spacer { flex: 1; }
.mt-6 { margin-top: 24px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.text-muted { color: var(--ink-3); }
.text-navy { color: var(--navy); }
.text-blue { color: var(--blue); }
.text-yellow { color: var(--yellow); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-mono { font-family: 'JetBrains Mono', monospace; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.tabular { font-variant-numeric: tabular-nums; }

.chart-wrap { width: 100%; }

.page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--border-strong);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.pill.active { background: var(--navy); color: var(--white); border-color: var(--navy); }
.pill.yellow { background: var(--yellow-50); color: var(--yellow); border-color: transparent; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-3);
}
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 6px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12.5px;
}
.pagination .pages button.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.pagination .pages button:disabled { opacity: .4; }

/* Stock badge */
.stock-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stock-bar .bar {
  flex: 1;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  overflow: hidden;
  max-width: 100px;
}
.stock-bar .bar-fill { height: 100%; border-radius: 3px; }

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .app { grid-template-columns: 1fr; padding-bottom: 68px; }
  .content { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
  .kpi-hero { grid-column: span 12; }
  .kpi.span-2, .kpi.span-3 { grid-column: span 6; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .bottom-nav { display: flex !important; }
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--navy);
  padding: 8px 4px;
  z-index: 40;
  justify-content: space-around;
  border-top: 1px solid rgba(255,255,255,.1);
}
.bottom-nav a, .bottom-nav .bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  color: rgba(255,255,255,.7);
  font-size: 10px;
  font-weight: 500;
  border-radius: 6px;
  min-width: 48px;
}
.bottom-nav a.active, .bottom-nav .bn-item.active { color: var(--yellow-light); background: rgba(255,255,255,.06); }

/* ============================================
   APP EXTRAS (merged from screen mockups)
   ============================================ */

.hidden { display: none !important; }

/* Stepper (Hàng hoàn) */
.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 20px;
  position: relative;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0 12px;
  cursor: pointer;
}
.step-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 18px;
  transition: all .2s;
}
.step.done .step-icon { background: var(--success); border-color: var(--success); color: white; }
.step.active .step-icon { background: var(--yellow); border-color: var(--yellow); color: white; box-shadow: 0 0 0 5px var(--yellow-50); }
.step-label { font-weight: 700; font-size: 13.5px; color: var(--navy); }
.step-count { font-size: 12px; color: var(--ink-3); }
.step.active .step-label { color: var(--yellow); }
.step-line {
  position: absolute;
  top: 52px;
  left: 8%;
  right: 8%;
  height: 2px;
  background: var(--border);
  z-index: 1;
}
.step-line-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--success);
}

/* Scan (Quét hoàn) */
.scan-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
}
@media (max-width: 1024px) { .scan-layout { grid-template-columns: 1fr; } }
.scan-hero {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.barcode-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-soft);
  border: 2px dashed var(--navy-100);
  border-radius: 14px;
  padding: 4px;
  transition: all .2s;
}
.barcode-input-wrap:focus-within {
  background: var(--yellow-50);
  border-color: var(--yellow);
  border-style: solid;
  box-shadow: 0 0 0 6px rgba(235, 142, 4, .1);
}
.barcode-input-icon {
  width: 60px;
  height: 60px;
  background: var(--navy);
  color: var(--white);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.barcode-input-wrap:focus-within .barcode-input-icon { background: var(--yellow); }
.barcode-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 0 20px;
  font-size: 22px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.06em;
  height: 60px;
  min-width: 0;
}
.barcode-input::placeholder { color: var(--ink-4); letter-spacing: 0; font-family: 'Inter', sans-serif; font-size: 16px; font-weight: 500; }

.camera-frame {
  position: relative;
  min-height: 180px;
  background: linear-gradient(135deg, #0B1730, #1a2b52);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-frame video { width: 100% !important; border-radius: 14px; }
.camera-scan-line {
  position: absolute;
  left: 12%;
  right: 12%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--yellow-light), transparent);
  top: 50%;
  box-shadow: 0 0 24px var(--yellow-light);
  animation: scan 2s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 3;
}
@keyframes scan {
  from { transform: translateY(-40px); }
  to { transform: translateY(40px); }
}
.camera-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid var(--yellow);
  z-index: 3;
  pointer-events: none;
}
.cc-tl { top: 20px; left: 12%; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.cc-tr { top: 20px; right: 12%; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.cc-bl { bottom: 20px; left: 12%; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.cc-br { bottom: 20px; right: 12%; border-left: none; border-top: none; border-radius: 0 0 6px 0; }
.camera-label {
  color: rgba(255, 255, 255, .75);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.camera-label .status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(22, 163, 74, .2);
  color: #4ade80;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.camera-label .status-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .4; } }

.progress-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
}
.progress-bar-outer {
  height: 12px;
  background: var(--bg-soft);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--yellow-light));
  border-radius: 6px;
  transition: width .3s;
}
.progress-bar-inner.full { background: linear-gradient(90deg, var(--success), #4ade80); }

.scan-result {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid;
}
.scan-result.success { background: var(--success-bg); border-color: rgba(22, 163, 74, .25); }
.scan-result.error { background: var(--danger-bg); border-color: rgba(220, 38, 38, .25); }
.scan-result.warn { background: var(--yellow-50); border-color: rgba(235, 142, 4, .3); }
.scan-result .icon-badge {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}
.scan-result.success .icon-badge { background: var(--success); }
.scan-result.error .icon-badge { background: var(--danger); }
.scan-result.warn .icon-badge { background: var(--yellow); }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  transition: background .15s;
}
.checklist-item:hover { background: var(--bg-softer); }
.checklist-item.done { opacity: .55; }
.checklist-item.done .code { text-decoration: line-through; }
.checkbox-big {
  width: 26px; height: 26px;
  border: 2px solid var(--border-strong);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  background: var(--white);
  flex-shrink: 0;
  color: var(--white);
  transition: all .15s;
}
.checklist-item.done .checkbox-big { background: var(--success); border-color: var(--success); }

/* Mini KPI (Quảng cáo) */
.mini-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.mini-kpi {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mini-kpi-label {
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mini-kpi-value {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: var(--navy);
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.mini-kpi-value .unit { font-size: 13px; color: var(--ink-3); font-weight: 500; margin-left: 2px; }
@media (max-width: 900px) { .mini-kpi-grid { grid-template-columns: repeat(2, 1fr); } }

/* Sync (Đồng bộ) */
.sync-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 1024px) { .sync-grid { grid-template-columns: 1fr; } }
.integration-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.integration-logo {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 3px currentColor;
  opacity: .3;
}
.status-pill.connected { background: var(--success-bg); color: var(--success); }
.status-pill.disconnected { background: var(--bg-soft); color: var(--ink-3); }

.drop-zone {
  border: 2px dashed var(--navy-100);
  border-radius: 14px;
  padding: 36px 24px;
  text-align: center;
  background: linear-gradient(to bottom, var(--bg-softer), var(--white));
  transition: all .2s;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--yellow);
  background: var(--yellow-50);
}
.drop-icon {
  width: 64px;
  height: 64px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.drop-zone:hover .drop-icon { color: var(--yellow); border-color: var(--yellow); }

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 18px;
  border-radius: 10px;
  color: white;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(10,23,48,.25);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in .2s ease-out;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Loading spinner */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--ink-4);
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Sidebar nav as buttons */
.nav-item { border: none; background: none; width: 100%; text-align: left; font-family: inherit; cursor: pointer; }
.bottom-nav a, .bottom-nav button { border: none; background: none; font-family: inherit; cursor: pointer; }

/* Nested table inside modal */
.item-list-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* bn-item icon sizing */
.bottom-nav .bn-item i, .bottom-nav .bn-item svg { width: 20px; height: 20px; }
