* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f4f6f9;
  color: #1f2937;
}
.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.topbar {
  background: #111827;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.topbar-inner { display: flex; justify-content: space-between; align-items: center; height: 56px; }
.logo { color: #fff; font-weight: 800; font-size: 19px; text-decoration: none; }
.link { color: #9ca3af; text-decoration: none; font-size: 14px; }
.link:hover { color: #fff; }

.cart-btn {
  background: #4f46e5;
  color: #fff;
  border: 0;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.cart-btn:hover { background: #4338ca; }

.cats { display: flex; gap: 8px; flex-wrap: wrap; padding: 18px 0 6px; }
.cat-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: #374151;
}
.cat-btn.active { background: #111827; color: #fff; border-color: #111827; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 14px 0 60px;
}
.card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  transition: transform .15s;
}
.card:hover { transform: translateY(-2px); }
.thumb {
  height: 150px;
  background: #eef0f4;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.ph { font-size: 44px; }
.info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.info h3 { font-size: 15px; font-weight: 600; }
.desc {
  font-size: 12px;
  color: #6b7280;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.price { font-size: 16px; font-weight: 700; color: #dc2626; }
.stock { font-size: 12px; }
.stock.ok { color: #16a34a; }
.stock.out { color: #dc2626; }
.add-btn {
  margin-top: auto;
  background: #4f46e5;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.add-btn:hover:not(:disabled) { background: #4338ca; }
.add-btn:disabled { background: #d1d5db; cursor: not-allowed; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 90;
}
.cart {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 92vw);
  height: 100%;
  background: #fff;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,.15);
}
.cart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.cart-head h2 { font-size: 17px; }
.x { border: 0; background: none; font-size: 24px; cursor: pointer; color: #6b7280; }
#cartItems { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.ci {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
}
.ci-info { flex: 1; }
.ci-name { font-size: 13px; font-weight: 600; }
.ci-price { font-size: 12px; color: #6b7280; }
.ci-qty { display: flex; align-items: center; gap: 8px; }
.ci-qty button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.ci-qty span { min-width: 22px; text-align: center; font-weight: 600; }
.ci-del { border: 0; background: none; color: #ef4444; font-size: 16px; cursor: pointer; }
.cart-foot { padding: 14px 16px; border-top: 1px solid #e5e7eb; }
.total { font-size: 16px; margin-bottom: 10px; }
.total b { color: #dc2626; }
.cta {
  width: 100%;
  background: #4f46e5;
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.cta:hover { background: #4338ca; }
.cta.small { width: auto; padding: 8px 16px; font-size: 13px; }
.ghost {
  width: 100%;
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  width: min(420px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box.wide { width: min(520px, 100%); }
.modal-box h2 { font-size: 18px; margin-bottom: 4px; }
.muted { color: #6b7280; font-size: 13px; margin-bottom: 12px; }
.modal-box input, .modal-box textarea, .modal-box select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  margin-bottom: 10px;
  font-family: inherit;
}
.modal-box textarea { min-height: 60px; resize: vertical; }
.modal-box .cta, .modal-box .ghost { margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 10px; }
.check input { width: auto; margin: 0; }
.ok { color: #16a34a; font-weight: 600; font-size: 15px; margin: 12px 0; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
}

/* Admin */
.admin { padding-bottom: 60px; }
.tabs { display: flex; gap: 6px; padding: 18px 0; border-bottom: 1px solid #e5e7eb; }
.tab {
  border: 0;
  background: none;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
}
.tab.active { color: #4f46e5; border-bottom: 2px solid #4f46e5; }
.tab-pane { display: none; padding-top: 16px; }
.tab-pane.active { display: block; }
.tbl {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
  margin-top: 12px;
}
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eef0f4; }
.tbl th { background: #f9fafb; font-weight: 600; color: #374151; white-space: nowrap; }
.tbl tr:hover td { background: #fafafa; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.moi { background: #fef3c7; color: #92400e; }
.badge.xac-nhan { background: #dbeafe; color: #1e40af; }
.badge.dang-giao { background: #e0e7ff; color: #3730a3; }
.badge.hoan-thanh { background: #dcfce7; color: #166534; }
.badge.huy { background: #fee2e2; color: #991b1b; }
.small-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.small-btn.danger { color: #dc2626; border-color: #fecaca; }
.small-btn:hover { background: #f3f4f6; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }
select.status { padding: 4px 8px; border-radius: 6px; border: 1px solid #d1d5db; font-size: 12px; }
#orderDetail { margin-top: 14px; background: #fff; border-radius: 10px; padding: 16px; font-size: 14px; }
#orderDetail h3 { margin-bottom: 8px; }
#orderDetail table { width: 100%; border-collapse: collapse; margin: 8px 0; }
#orderDetail td, #orderDetail th { padding: 6px 8px; border-bottom: 1px solid #eef0f4; text-align: left; font-size: 13px; }
