:root {
  --brand: #0b5bd3;
  --brand-dark: #08449f;
  --accent: #f26b1d;
  --text: #1c2430;
  --muted: #667085;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e3e7ee;
  --ok: #138a4b;
  --danger: #d0342c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
img, svg { max-width: 100%; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.container { padding-top: 20px; padding-bottom: 40px; min-height: 60vh; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #d95a10; }
.btn-outline { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn-outline:hover { background: #eef4ff; }
.btn-outline-light { color: #fff; border-color: rgba(255,255,255,.7); }
.btn-outline-light:hover { background: rgba(255,255,255,.12); }
.btn-block { width: 100%; }
.btn:disabled { background: #c5cbd5; color: #fff; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; }

/* Header */
.topbar { background: var(--brand-dark); color: #dbe6fb; font-size: .85rem; }
.topbar .container { display: flex; justify-content: space-between; gap: 12px; padding-top: 6px; padding-bottom: 6px; flex-wrap: wrap; }
.topbar a { color: #fff; font-weight: 600; }
.header-main { background: var(--brand); }
.header-main .container { display: flex; align-items: center; gap: 20px; padding-top: 14px; padding-bottom: 14px; }
.logo { font-size: 1.6rem; font-weight: 800; color: #fff; letter-spacing: .5px; display: inline-flex; align-items: center; text-decoration: none !important; }
.logo-mark { background: var(--accent); color: #fff; border-radius: 6px; padding: 0 6px; margin-right: 2px; }
.logo-tld { font-weight: 500; font-size: 1rem; opacity: .85; margin-left: 1px; }
.search { flex: 1; display: flex; min-width: 0; }
.search input { flex: 1; min-width: 0; padding: 10px 12px; border: 0; border-radius: 8px 0 0 8px; font: inherit; }
.search .btn { border-radius: 0 8px 8px 0; }
.cart-link { color: #fff; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; position: relative; }
.cart-count { background: var(--accent); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; font-size: .75rem; display: inline-flex; align-items: center; justify-content: center; }
.cart-count[hidden] { display: none; }
.catnav { background: var(--surface); border-bottom: 1px solid var(--border); }
.catnav .container { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.catnav a { padding: 11px 12px; color: var(--text); white-space: nowrap; font-weight: 500; border-bottom: 2px solid transparent; }
.catnav a:hover, .catnav a.active { color: var(--brand); border-bottom-color: var(--brand); text-decoration: none; }

/* Hero */
.hero {
  background: linear-gradient(120deg, var(--brand-dark), var(--brand) 60%, #2f86ff);
  color: #fff; border-radius: 14px; padding: 36px 32px; display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: center;
}
.hero h1 { font-size: 2rem; }
.hero p { color: #dbe6fb; max-width: 560px; }
.hero-perks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hero-perks li { background: rgba(255,255,255,.12); border-radius: 10px; padding: 12px 14px; }
.hero-perks strong { color: #ffd2b5; }

/* Sections */
.section { margin-top: 32px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.cat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px; color: var(--text); box-shadow: var(--shadow);
}
.cat-tile:hover { border-color: var(--brand); text-decoration: none; }
.cat-tile .icon { width: 40px; height: 40px; color: var(--brand); margin-bottom: 6px; }
.cat-tile span { font-size: .82rem; color: var(--muted); }

/* Product cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.card:hover { border-color: #bcd0f3; }
.card-media { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; }
.icon-lg { width: 72px; height: 72px; }
.icon-xl { width: 140px; height: 140px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: .95rem; font-weight: 600; margin: 0; flex: 1; }
.card-title a { color: var(--text); }
.brand { font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.card-price { margin-bottom: 6px; }
.price { color: var(--danger); font-weight: 700; font-size: 1.05rem; }
.old-price { color: var(--muted); text-decoration: line-through; font-size: .85rem; }
.badge-sale { background: #fde7e5; color: var(--danger); font-size: .75rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; }

/* Màu nền theo danh mục cho ảnh minh hoạ */
.cat-laptop { background: #e8f0ff; color: #2459c6; }
.cat-pc { background: #fff0e6; color: #c4561a; }
.cat-linh-kien { background: #e9f7ef; color: #1d7a48; }
.cat-man-hinh { background: #f1ebff; color: #6a3fc0; }
.cat-gaming-gear { background: #ffe9ef; color: #c0365d; }
.cat-mang { background: #e6f7f8; color: #18808a; }
.cat-phu-kien { background: #f3f4f6; color: #4b5563; }
.cat-tile[class*="cat-"] { background: var(--surface); }

/* Listing */
.list-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.list-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; position: sticky; top: 12px; }
.filters label, .form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.filters fieldset, .form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.filters legend, .form legend { font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.filters fieldset { grid-template-columns: 1fr 1fr; }
.filters legend { grid-column: 1 / -1; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea { font: inherit; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); width: 100%; min-width: 0; }
input[type="checkbox"], input[type="radio"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a9c5f5; border-color: var(--brand); }
.empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; grid-column: 1 / -1; }

/* Product detail */
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
.detail { display: grid; grid-template-columns: 1fr 1.1fr; gap: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.detail-media { border-radius: 12px; display: flex; align-items: center; justify-content: center; min-height: 320px; }
.detail-price .price { font-size: 1.6rem; }
.stock.in { color: var(--ok); font-weight: 600; }
.stock.out { color: var(--danger); font-weight: 600; }
.perks { padding-left: 18px; color: #344054; }
.buy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.buy-row input { width: 80px; }
.specs { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.specs th, .specs td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.specs th { width: 35%; background: #f8fafc; font-weight: 600; }
.specs tr:last-child th, .specs tr:last-child td { border-bottom: 0; }

/* Cart & checkout */
.cart-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.cart-items { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cart-item { display: grid; grid-template-columns: 64px 1fr 80px 120px auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: 0; }
.thumb { width: 64px; height: 64px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.thumb .icon { width: 36px; height: 36px; }
.ci-info a { color: var(--text); font-weight: 600; }
.ci-total { font-weight: 700; text-align: right; }
.summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; position: sticky; top: 12px; }
.summary dl { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 0 0 12px; }
.summary dd { margin: 0; text-align: right; }
.summary .total { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--border); padding-top: 8px; }
.summary dd.total { color: var(--danger); }
.order-lines { list-style: none; padding: 0; margin: 0; font-size: .88rem; display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.order-lines li { display: flex; justify-content: space-between; gap: 10px; }
.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.success { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; max-width: 760px; }
.success textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88rem; }

/* Footer */
footer { background: #101828; color: #c3cad6; margin-top: 20px; }
.footer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; padding-top: 32px; padding-bottom: 20px; }
footer h4 { color: #fff; margin: 0 0 8px; }
footer p { margin: 0; font-size: .9rem; }
.logo-footer { margin-bottom: 8px; }
.copyright { border-top: 1px solid #1f2a3d; padding-top: 14px; padding-bottom: 18px; font-size: .82rem; color: #8b95a7; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #101828; color: #fff; padding: 10px 16px; border-radius: 8px; transition: .2s; max-width: calc(100% - 32px); z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 24px 20px; }
  .hero h1 { font-size: 1.5rem; }
  .list-layout, .cart-layout, .detail { grid-template-columns: 1fr; }
  .filters, .summary { position: static; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .detail-media { min-height: 220px; }
}
@media (max-width: 600px) {
  .header-main .container { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; flex-basis: 100%; }
  .cart-link { margin-left: auto; }
  .cart-link span:not(.cart-count) { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .icon-lg { width: 52px; height: 52px; }
  .card-body { padding: 10px; }
  .card-title { font-size: .88rem; }
  .cart-item { grid-template-columns: 56px 1fr auto; }
  .cart-item input { grid-column: 2; width: 80px; }
  .cart-item .ci-total { grid-column: 3; grid-row: 2; }
  .cart-item .link-btn { grid-column: 3; grid-row: 1; justify-self: end; }
  .thumb { width: 56px; height: 56px; }
  .footer-grid { grid-template-columns: 1fr; }
  .topbar .container { justify-content: center; text-align: center; }
}
