:root {
  /* Palette derived from zenpump.vn */
  --primary: #00aaad;
  --primary-dark: #008a8d;
  --primary-soft: #e6f7f7;
  --teal-muted: #569ba3;
  --blue: #2489db;
  --blue-dark: #125c9e;
  --sidebar-bg: #0f2937;
  --sidebar-hover: #1a3b4d;
  --sidebar-active: #00aaad;
  --bg: #f3f7f9;
  --surface: #ffffff;
  --border: #dfe7ec;
  --text: #111827;
  --text-muted: #5b6b79;
  --success: #0d9488;
  --success-bg: #e6f7f4;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 41, 55, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 41, 55, 0.14);
}

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

body {
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.center {
  text-align: center;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12px;
}

/* ---------- Login Screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f2937 0%, #164857 52%, #00aaad 100%);
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  height: 54px;
  object-fit: contain;
  margin-bottom: 12px;
}

.login-brand h1 {
  font-size: 19px;
  color: var(--sidebar-bg);
  font-weight: 700;
}

.login-company {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-top: 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.login-footer {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}

/* ---------- App Layout ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 256px;
  background: var(--sidebar-bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.sidebar-logo {
  height: 36px;
  width: auto;
  background: #ffffff;
  border-radius: 8px;
  padding: 3px 6px;
  object-fit: contain;
}

.brand-text strong {
  display: block;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: #ffffff;
}

.brand-text span {
  font-size: 11px;
  color: #7dd3d5;
}

.warehouse-pill {
  margin: 14px 14px 8px;
  padding: 10px 12px;
  background: rgba(0, 170, 173, 0.14);
  border: 1px solid rgba(0, 170, 173, 0.35);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot-online {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #34d399;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

.wp-title {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}

.wp-sub {
  font-size: 11px;
  color: #b7d7dc;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #7c97a6;
  padding: 12px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #d2e0e7;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 170, 173, 0.35);
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.ext-link {
  color: #7dd3d5;
  text-decoration: none;
  font-weight: 600;
  display: block;
}

.ext-link:hover {
  text-decoration: underline;
}

.sf-meta {
  color: #8ea7b5;
  margin-top: 3px;
  font-size: 11px;
}

.main-wrap {
  margin-left: 256px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

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

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

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--sidebar-bg);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 6px;
  background: var(--bg);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.15;
}

.user-role {
  font-size: 11px;
  color: var(--primary-dark);
  font-weight: 600;
}

.main-content {
  padding: 22px 24px 40px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* ---------- Cards, KPIs, Grids ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.kpi-card.blue::before { background: var(--blue); }
.kpi-card.amber::before { background: var(--warning); }
.kpi-card.green::before { background: var(--success); }
.kpi-card.red::before { background: var(--danger); }

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--sidebar-bg);
  margin: 6px 0 4px;
  font-variant-numeric: tabular-nums;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--sidebar-bg);
}

.card-body {
  padding: 16px 18px;
}

/* ---------- Toolbar & Filters ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-blue {
  background: var(--blue);
  color: #ffffff;
}
.btn-blue:hover:not(:disabled) {
  background: var(--blue-dark);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}
.btn-success:hover:not(:disabled) {
  background: #0f766e;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg);
  border-color: #b7c6d1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

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

.btn-xs {
  padding: 3px 8px;
  font-size: 11.5px;
  border-radius: 5px;
}

.btn-block {
  width: 100%;
  padding: 11px 16px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.icon-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 13px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 5px;
}

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

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

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 170, 173, 0.16);
}

.input-inline {
  width: auto;
  min-width: 160px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group input {
  flex: 1;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 60px;
}

.icon-btn-inline {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  width: 100%;
}

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

thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  padding: 10px 9px;
  border-bottom: 2px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 9px 9px;
  border-bottom: 1px solid #edf2f6;
  vertical-align: middle;
}

tbody tr:hover {
  background: #f9fcfd;
}

tfoot td {
  padding: 10px 9px;
  background: #f1f5f9;
  font-weight: 700;
  border-top: 2px solid var(--border);
}

.prod-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 210px;
  max-width: 300px;
}

.prod-thumb {
  width: 42px;
  height: 42px;
  border-radius: 7px;
  object-fit: contain;
  background: #f8fafc;
  border: 1px solid var(--border);
  flex-shrink: 0;
  padding: 2px;
}

.prod-sku {
  font-weight: 700;
  color: var(--sidebar-bg);
  font-size: 13px;
}

.prod-name {
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 340px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: #0f766e; }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-danger  { background: var(--danger-bg);  color: #b91c1c; }
.badge-info    { background: var(--info-bg);    color: #1d4ed8; }
.badge-neutral { background: #e2e8f0; color: #334155; }
.badge-teal    { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Alerts & Bars ---------- */
.alert-error {
  background: var(--danger-bg);
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

.alert-info {
  background: var(--primary-soft);
  color: #0e5a5c;
  border: 1px solid #b6e3e4;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-warn {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fcd34d;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.cat-bar-row {
  margin-bottom: 11px;
}
.cat-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 4px;
}
.cat-bar-track {
  height: 8px;
  background: #e6eff3;
  border-radius: 99px;
  overflow: hidden;
}
.cat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--blue));
  border-radius: 99px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 41, 55, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-dialog {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-dialog.modal-lg {
  max-width: 980px;
}

.modal-dialog.modal-sm {
  max-width: 460px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--sidebar-bg);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* Line items editor inside modal */
.line-items-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 10px;
}

.line-items-table th {
  padding: 8px 8px;
  font-size: 11.5px;
}

.line-items-table td {
  padding: 6px 6px;
}

.line-items-table input,
.line-items-table select {
  padding: 6px 8px;
  font-size: 13px;
}

.summary-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 12px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13.5px;
}

.summary-row.grand {
  border-top: 1px dashed #cbd5e1;
  margin-top: 6px;
  padding-top: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  padding: 12px 16px;
  border-radius: 9px;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  animation: fadeInToast 0.2s ease;
}

.toast.success { background: #0f766e; }
.toast.error   { background: #dc2626; }
.toast.info    { background: #1e40af; }

@keyframes fadeInToast {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 9px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

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

.actions-cell {
  display: flex;
  gap: 5px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

/* ---------- Mobile ---------- */
.mobile-only {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 35;
}

@media (max-width: 960px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrap {
    margin-left: 0;
  }
  .grid-2,
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 0 14px;
  }
  .main-content {
    padding: 16px 14px 36px;
  }
  .user-meta,
  #btn-change-pwd {
    display: none;
  }
}
