:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --primary: #0f4c81;
  --primary-hover: #0c3b66;
  --accent: #0284c7;
  --success: #15803d;
  --warning: #d97706;
  --danger: #dc2626;
  --text: #0f172a;
  --muted: #64748b;
  --border: #cbd5e1;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  padding-bottom: 48px;
}

.hidden {
  display: none !important;
}

/* AUTH SCREEN */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: linear-gradient(145deg, #0f172a 0%, #0f4c81 55%, #0369a1 100%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.auth-logo {
  font-size: 46px;
  margin-bottom: 8px;
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
}

.auth-subtitle {
  color: var(--muted);
  font-size: 13.5px;
  margin: 8px 0 20px;
}

.auth-divider {
  margin: 18px 0;
  border-top: 1px solid #e2e8f0;
  position: relative;
}

.auth-divider span {
  position: relative;
  top: -10px;
  background: #fff;
  padding: 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.qr-panel {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  padding: 14px;
}

.qr-code-digits {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--primary);
  margin: 10px 0;
  font-family: monospace;
}

.qr-status {
  font-size: 12.5px;
  color: var(--accent);
}

.auth-footer-note {
  margin-top: 20px;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
  padding: 10px;
  border-radius: 8px;
}

/* TOP BAR */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.bridge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fbbf24;
  flex-shrink: 0;
}

.status-dot.online {
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.role-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

/* KPI STRIP & MAIN TABS */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px 16px 4px;
  max-width: 1480px;
  margin: 0 auto;
}

.kpi-tile {
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  cursor: pointer;
}

.kpi-tile.warn {
  border-left-color: var(--warning);
}

.kpi-tile.danger {
  border-left-color: var(--danger);
}

.kpi-tile.success {
  border-left-color: var(--success);
}

.kpi-tile-label {
  font-size: 12px;
  color: var(--muted);
}

.kpi-tile-val {
  font-size: 20px;
  font-weight: 800;
  margin-top: 2px;
}

.main-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px;
  max-width: 1480px;
  margin: 0 auto;
  scrollbar-width: thin;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tab-badge {
  background: #e2e8f0;
  color: #0f172a;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

.tab-btn.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.badge-urgent {
  background: #fee2e2 !important;
  color: #b91c1c !important;
}

/* PANELS & CARDS */
.tab-panel {
  max-width: 1480px;
  margin: 0 auto;
  padding: 4px 16px 24px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.highlight-card {
  border: 2px solid var(--accent);
  background: #f0f9ff;
  margin-bottom: 14px;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sub-note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.meta-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.flex-1 { flex: 1; min-width: 220px; }
.cursor-pointer { cursor: pointer; }

/* FORMS & BUTTONS */
.toolbar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  align-items: end;
}

.b3-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 10px;
  background: #f8fafc;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.field-group label,
.form-row-2 label,
.form-row-3 label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}

.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.16);
}

.input-sm {
  padding: 5px 7px;
  font-size: 12.5px;
  width: 78px;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.input-wide {
  width: 105px;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.field-actions,
.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13.5px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  max-width: 100%;
  white-space: normal;
  text-wrap: balance;
  text-align: center;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 11px 18px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  border-color: rgba(148, 163, 184, 0.4);
}

/* TABLES & CARDS */
.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  text-align: left;
  padding: 9px 8px;
  border-bottom: 2px solid #cbd5e1;
  white-space: nowrap;
}

.data-table td {
  padding: 8px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #f8fafc;
}

.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue { background: #e0f2fe; color: #075985; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* STAGE PILLS & KANBAN CARDS */
.stage-pills,
.quick-voucher-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.stage-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.stage-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pill-urgent {
  border-color: #fca5a5;
  color: #b91c1c;
}

.voucher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.voucher-card {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.voucher-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  border-color: var(--accent);
}

.voucher-card.urgent {
  border-left: 4px solid var(--danger);
}

/* BẢNG 3 MOBILE CARDS & STICKY FOOTER */
.b3-action-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.b3-mobile-card {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: #ffffff;
}

.b3-mobile-card.price-changed {
  border-left: 4px solid var(--warning);
  background: #fffbeb;
}

.b3-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 8px;
}

.b3-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
  background: #f8fafc;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.b3-sticky-footer {
  position: sticky;
  bottom: 0;
  background: #0f172a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.18);
}

.b3-balance-metrics {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
}

/* CAMERA SCANNER */
.camera-box {
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  max-width: 480px;
}

.camera-box video {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  display: block;
}

.camera-overlay-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #0f172a;
  color: #fff;
  font-size: 12.5px;
}

.search-results-strip {
  margin-top: 8px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.action-bar-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-strong {
  font-weight: 800;
  color: var(--primary);
}

/* ALERTS, MODALS, TOASTS & SPOTLIGHT */
.alert-box {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
  text-align: left;
}
.alert-danger { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-wide {
  max-width: 680px;
}

.code-input-big {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 5px;
  text-transform: uppercase;
}

.guide-topic-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: #f8fafc;
}

.guide-spotlight-pulse {
  animation: guidePulse 2.2s ease-out 2;
  outline: 3px solid #f59e0b !important;
  outline-offset: 3px;
}

@keyframes guidePulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { box-shadow: 0 0 0 14px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.toast.ok { border-left: 4px solid #4ade80; }
.toast.err { border-left: 4px solid #f87171; }

.kpi-staff-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 640px) {
  .top-bar { padding: 8px 10px; }
  .tab-panel { padding: 4px 10px 24px; }
  .card { padding: 12px; }
  .b3-sticky-footer { position: static; }
}
