:root {
  --red: #be1e2d;      /* đỏ của logo */
  --red-dark: #9e1824;
  --gray: #4b4f52;     /* xám của logo */
  --gray-dark: #33363a;
  --blue: #1f4f9c;
  --blue-dark: #163b78;
  --green: #1a9b3b;
  --text: #222;
  --muted: #666;
  --line: #e3e3e3;
  --bg: #f2f3f5;
  --card: #fff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header */
.topbar { background: #fff; border-bottom: 3px solid var(--red); }
.topbar-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 16px; }
.logo img { display: block; height: 100px; width: auto; max-width: 100%; }
.hotline { font-size: 20px; font-weight: 700; color: var(--red); }
main.container { padding-top: 20px; }

.card { background: var(--card); border-radius: 8px; padding: 20px; }
.builder h1 { text-align: center; font-size: 22px; margin: 4px 0 20px; color: #111; }
.builder-head, .builder-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.builder-foot { margin: 12px 0 0; }
.total { font-size: 16px; }
.total-value { color: var(--red); font-size: 20px; }
.watt { color: var(--muted); font-size: 13px; }
.watt b { color: var(--blue); }

.btn { border: 0; color: #fff; border-radius: 5px; padding: 10px 16px; font-weight: 600; font-size: 13px; }
.btn-red { background: var(--red); }
.btn-red:hover { background: var(--red-dark); }
.btn-blue { background: var(--blue); }
.btn-blue:hover { background: var(--blue-dark); }
.btn-gray { background: var(--gray); }
.btn-gray:hover { background: var(--gray-dark); }
.btn-pick { background: var(--red); }
.btn-pick:hover { background: var(--red-dark); }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.data-source { text-align: center; font-size: 12px; margin: -12px 0 16px; color: #8a5a00; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.loading.error { color: var(--red); }
.result-count { color: var(--muted); font-size: 13px; }
.p-summary { margin-top: 2px; font-size: 12px; color: #888; }
.p-price s { color: #999; font-weight: 400; font-size: 13px; margin-left: 6px; }

.warnings:empty { display: none; }
.warnings { background: #fff6e5; border: 1px solid #ffd27a; color: #8a5a00; border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.warnings div::before { content: "⚠ "; }

/* Bảng cấu hình */
.build-table { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.row { display: grid; grid-template-columns: 200px 1fr; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-label { padding: 16px; font-weight: 700; display: flex; align-items: center; background: #fafafa; border-right: 1px solid var(--line); }
.row-content { padding: 12px 16px; display: flex; align-items: center; }

.selected { display: grid; grid-template-columns: 80px 1fr auto; gap: 14px; align-items: center; width: 100%; }
.selected img, .p-img { width: 80px; height: 80px; object-fit: contain; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.sel-name { font-weight: 600; margin-bottom: 4px; }
.sel-meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.sel-meta .ok { color: var(--green); font-weight: 600; }
.sel-meta .no { color: var(--red); font-weight: 600; }
.sel-right { display: flex; align-items: center; gap: 10px; }
.qty { width: 56px; padding: 6px; border: 1px solid var(--line); border-radius: 4px; text-align: center; }
.sel-price { color: var(--red); font-weight: 700; min-width: 120px; text-align: right; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 4px; width: 32px; height: 32px; }
.icon-btn:hover { border-color: var(--blue); color: var(--blue); }
.icon-btn.del:hover { border-color: var(--red); color: var(--red); }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

.perks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.perks div { background: #fff; border-radius: 8px; padding: 14px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.perks b { color: var(--red); font-size: 13px; }
.perks span { color: var(--muted); font-size: 13px; }
.footer { background: #1b2433; color: #aab; padding: 18px 0; font-size: 13px; text-align: center; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; width: 100%; max-width: 1100px; height: 90vh; border-radius: 6px; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { background: var(--red); color: #fff; display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.modal-head h2 { margin: 0; font-size: 18px; white-space: nowrap; }
.modal-head input { flex: 1; padding: 9px 12px; border: 0; border-radius: 4px; font-size: 14px; }
.modal-close { background: transparent; border: 0; color: #fff; font-size: 20px; }
.modal-body { flex: 1; display: grid; grid-template-columns: 260px 1fr; min-height: 0; }

.filters { border-right: 1px solid var(--line); overflow-y: auto; padding: 12px; }
.filters-title { border: 1px solid var(--line); text-align: center; padding: 9px; font-weight: 700; margin-bottom: 12px; border-radius: 4px; }
.f-group { margin-bottom: 16px; }
.f-group h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; }
.f-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.f-opts label { font-size: 13px; display: flex; gap: 5px; align-items: flex-start; cursor: pointer; }
.f-opts label.on { color: var(--red); }

.list-wrap { display: flex; flex-direction: column; min-height: 0; }
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.list-toolbar select { padding: 5px; border: 1px solid var(--line); border-radius: 4px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 5px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip-red { background: var(--red); color: #fff; border-color: var(--red); }
.pager { margin-left: auto; display: flex; flex-wrap: wrap; gap: 4px; }
.pager button { min-width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 4px; }
.pager button.on { background: var(--red); border-color: var(--red); color: #fff; }

.product-list { overflow-y: auto; flex: 1; }
.p-item { display: grid; grid-template-columns: 90px 1fr auto; gap: 14px; padding: 14px; border-bottom: 1px solid var(--line); align-items: start; }
.p-item:hover { background: #fafcff; }
.p-img { width: 90px; height: 90px; }
.p-name { font-weight: 600; margin-bottom: 6px; }
.p-meta { color: var(--muted); font-size: 13px; line-height: 1.6; }
.p-meta b { color: var(--text); }
.p-price { color: var(--red); font-weight: 700; font-size: 17px; margin-top: 4px; }
.p-incompat { color: #b36b00; font-size: 12px; margin-top: 4px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: #222; color: #fff; padding: 10px 18px; border-radius: 6px; opacity: 0; transition: .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Khung xuất ảnh / in */
.print-area { position: fixed; left: -10000px; top: 0; width: 900px; background: #fff; padding: 24px; color: #000; }
.print-area h2 { text-align: center; margin: 0 0 4px; }
.print-area .pa-date { text-align: center; color: #555; margin-bottom: 16px; font-size: 13px; }
.print-area table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-area th, .print-area td { border: 1px solid #999; padding: 6px 8px; }
.print-area th { background: #eee; }
.print-area td.num { text-align: right; white-space: nowrap; }
.print-area tfoot td { font-weight: 700; font-size: 15px; }

@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { position: static; width: auto; padding: 0; }
}

/* Responsive */
@media (max-width: 900px) {
  .logo img { height: 76px; }
  .hotline { font-size: 18px; }
  .perks { grid-template-columns: 1fr 1fr; }
  .modal { padding: 0; }
  .modal-box { height: 100vh; border-radius: 0; }
  .modal-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .filters { max-height: 32vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .modal-head h2 { display: none; }
}
@media (max-width: 640px) {
  .row { grid-template-columns: 1fr; }
  .row-label { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 14px; }
  .selected { grid-template-columns: 60px 1fr; }
  .selected img { width: 60px; height: 60px; }
  .sel-right { grid-column: 1 / -1; justify-content: flex-end; flex-wrap: wrap; }
  .builder-head, .builder-foot { flex-direction: column; align-items: stretch; }
  .actions .btn { flex: 1 1 100%; }
  .p-item { grid-template-columns: 64px 1fr; }
  .p-img { width: 64px; height: 64px; }
  .p-item .btn { grid-column: 1 / -1; }
  .pager { margin-left: 0; }
}
