/* Font hệ thống hỗ trợ tiếng Việt cho bản 3D tĩnh; Inter chưa được đóng gói cùng project. */
:root {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  color: #e8edf0;
  background: #0c1318;
  --muted: #94a2a9;
  --line: #27343b;
  --gold: #d8b16a;
  --green: #5be0a2;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: #0b1115;
}
button {
  font: inherit;
  color: inherit;
  background: #19242a;
  border: 1px solid #304049;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  transition: 0.16s;
}
button:hover {
  border-color: #d8b16a;
  background: #26343a;
}
button.primary {
  background: #d0a95f;
  color: #101519;
  border-color: #d0a95f;
  font-weight: 700;
}
input {
  width: 100%;
  margin-top: 7px;
  background: #0b1216;
  color: #fff;
  border: 1px solid #35434a;
  border-radius: 7px;
  padding: 10px;
}
select {
  max-width: 100%;
  width: 100%;
  background: #0d161c;
  color: #edf1f3;
  border: 1px solid #364a55;
  border-radius: 6px;
  padding: 8px;
  font: inherit;
  font-size: 12px;
}
.top {
  height: 72px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #28343a;
  background: #10181d;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}
.brand b {
  display: block;
  font-size: 13px;
  letter-spacing: 0.09em;
}
.brand small,
.customer small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}
.actions {
  display: flex;
  gap: 7px;
}
.actions button {
  font-size: 12px;
}
main {
  height: calc(100vh - 72px);
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(355px, 34%);
}

/* Three.js viewport and camera controls. */
.stage-wrap {
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.stage-head,
.stage-foot {
  height: 38px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #d6dddf;
}
.stage-head {
  gap: 12px;
}
.live {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  margin-right: 6px;
  box-shadow: 0 0 10px var(--green);
}
#badge {
  color: #b0bbc0;
  font-size: 11px;
  letter-spacing: 0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}
.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  border: 1px solid #344047;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 35%, #34444a, #1b282e 55%, #10171b);
  touch-action: none;
}
#scene3d {
  position: absolute;
  inset: 0;
  z-index: 1;
}
#scene3d canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
.view-tabs,
.stage-tools {
  z-index: 2;
  position: absolute;
  display: flex;
  gap: 6px;
}
.view-tabs {
  top: 12px;
  left: 12px;
  right: 12px;
  flex-wrap: wrap;
  align-content: flex-start;
  pointer-events: none;
}
.view-tabs button {
  font-size: 11px;
  padding: 7px 9px;
  background: #111b20dc;
  white-space: nowrap;
}
.view-tabs button,
.stage-tools button {
  pointer-events: auto;
}
.view-tabs button.selected {
  border-color: var(--gold);
  color: #f0d291;
}
.view-tabs button:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}
.stage-tools {
  right: 13px;
  bottom: 44px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.stage-tools button {
  font-size: 11px;
  background: #111b20e8;
}
.stage-tools .tool-icon {
  margin-right: 4px;
}
.stage-tools .door-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  vertical-align: middle;
  color: #194b80;
}
#door .door-close-glyph,
#door[data-action="close"] .door-open-glyph {
  display: none;
}
#door[data-action="close"] .door-close-glyph {
  display: inline;
}
.mobile-hint,
.mobile-resources-toggle {
  display: none;
}
#closeResourcePanel {
  display: none;
}
.customer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hint {
  position: absolute;
  z-index: 2;
  bottom: 14px;
  left: 12px;
  right: 12px;
  color: #aab6bb;
  font-size: 10px;
  line-height: 1.4;
  pointer-events: none;
  background: #111b20d9;
  border-radius: 5px;
  padding: 5px 8px;
  width: fit-content;
  max-width: calc(100% - 24px);
}
.stage-foot {
  height: 32px;
  color: #9eaaaf;
}
.stage-foot span:first-child {
  color: #d7b671;
}
.stage:fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  background: #dadfe4;
}
.stage.is-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 9999;
  border-radius: 0;
}
.scene-status {
  position: absolute;
  z-index: 3;
  left: 12px;
  bottom: 105px;
  max-width: calc(100% - 24px);
  padding: 8px 12px;
  border: 1px solid #53656e;
  border-radius: 7px;
  color: #f0f4f5;
  background: #16242eea;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}
.scene-status[hidden] {
  display: none;
}
.scene-status.error {
  color: #ffdcc6;
  border-color: #d59371;
}
.scene-status.file-notice {
  top: 35%;
  bottom: auto;
  right: 12px;
  padding: 20px;
  pointer-events: auto;
}
.file-notice a {
  display: block;
  width: fit-content;
  margin-top: 12px;
  color: #f2ca7b;
  font-weight: 600;
}
.file-notice p {
  margin: 12px 0 0;
}

/* Configuration categories, material cards, and dimensions. */
.controls {
  background: #10191f;
  border-left: 1px solid #2b3940;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.customer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
}
.customer b {
  font-size: 12px;
  letter-spacing: 0.1em;
}
.customer button {
  font-size: 11px;
}
nav {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: 3px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
nav button {
  flex: none;
  padding: 7px 8px;
  font-size: 11px;
  color: #aab5ba;
  border-color: transparent;
  background: transparent;
}
nav button.active {
  background: #263238;
  color: #f0d291;
  border-color: #4c5a5e;
}
.pane {
  padding: 12px;
  overflow: auto;
  flex: 1;
}
.pane-title {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 12px;
}
.pane-title h2 {
  font-size: 16px;
  margin: 0 0 5px;
}
.pane-title p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
}
.pane-title > span {
  font-size: 11px;
  color: var(--muted);
}
.config-options {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141f26;
}
.config-options[hidden] {
  display: none;
}
.config-options .option-row {
  display: grid;
  gap: 6px;
  align-items: center;
  color: #b9c6cc;
  font-size: 12px;
}
.option-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.option-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.card {
  min-width: 0;
  padding: 6px;
  background: #172127;
  border: 1px solid #29383f;
  border-radius: 9px;
  cursor: pointer;
  transition: 0.15s;
  text-align: left;
  font-weight: 400;
  white-space: normal;
}
.card:hover {
  border-color: #a48b5b;
  transform: translateY(-1px);
}
.card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px #d8b16a50;
}
.card img,
.swatch {
  display: block;
  width: 100%;
  height: 92px;
  border-radius: 6px;
}
.card img {
  object-fit: contain;
  background: #e7e5e1;
}
.swatch {
  background: #263238;
}
.card b {
  display: block;
  margin: 7px 2px 3px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card small {
  display: block;
  margin: 0 2px 2px;
  color: #9caaae;
  font-size: 10px;
  white-space: normal;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dimension-form {
  display: none;
  gap: 10px;
}
.dimension-form.show {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.dimension-form label {
  font-size: 11px;
  color: var(--muted);
}
.bottom {
  min-height: 66px;
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bottom > div {
  min-width: 0;
  padding-right: 10px;
}
.bottom b,
.bottom span {
  display: block;
}
.bottom b {
  font-size: 12px;
}
.bottom span {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* Project dialogs and printable configuration sheet. */
dialog {
  width: min(600px, 90vw);
  border: 1px solid #43525a;
  border-radius: 12px;
  background: #141e24;
  color: #ebeff1;
  box-shadow: 0 20px 80px #000a;
}
dialog::backdrop {
  background: #0009;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.modal-head h2 {
  font-size: 17px;
}
.modal-head button {
  font-size: 20px;
  padding: 2px 10px;
}
#modalBody {
  padding: 14px 2px;
  max-height: 60vh;
  overflow: auto;
  line-height: 1.7;
  font-size: 13px;
}
#modalBody table {
  width: 100%;
  border-collapse: collapse;
}
#modalBody td {
  border-bottom: 1px solid #2e3c43;
  padding: 8px 4px;
}
.share-link {
  width: 100%;
  min-height: 130px;
}

@media (max-width: 920px) {
  main {
    height: auto;
    min-height: calc(100vh - 72px);
    grid-template-columns: 1fr;
  }
  .stage-wrap {
    height: 65vh;
    min-height: 480px;
  }
  .controls {
    min-height: 650px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .pane {
    padding: 15px 16px;
  }
  .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
  }
  .actions {
    gap: 3px;
  }
  .actions button {
    padding: 8px;
    font-size: 10px;
  }
}
@media (max-width: 600px) {
  /* Khung xem cao gần 900px trên điện thoại phổ biến và co lại ở máy rất hẹp. */
  body,
  main {
    min-height: 0;
  }
  .top {
    padding: 6px;
    gap: 0;
  }
  /* Trên điện thoại, header chỉ giữ các thao tác; thương hiệu đã có ở header trang chính. */
  .top .brand {
    display: none;
  }
  .pane {
    padding-inline: 8px;
  }
  .top {
    height: auto;
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }
  .actions {
    overflow-x: auto;
    width: 100%;
  }
  .actions button {
    white-space: nowrap;
  }
  .stage-wrap {
    padding: 6px;
    height: clamp(720px, 240vw, 900px);
    min-height: 0;
  }
  .stage,
  #scene3d,
  #scene3d canvas {
    touch-action: none !important;
  }
  .view-tabs {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 4px;
  }
  .view-tabs button {
    font-size: 10px;
    padding: 6px 8px;
  }
  .stage-tools {
    top: 132px;
    bottom: auto;
    right: 6px;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 6px;
  }
  .stage-tools button {
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 20px;
    box-shadow: 0 3px 12px #102d4b33;
  }
  .stage-tools .tool-icon {
    margin: 0;
  }
  .stage-tools .door-icon {
    width: 28px;
    height: 28px;
  }
  .stage-tools .tool-label,
  .desktop-hint {
    display: none;
  }
  .mobile-hint {
    display: inline;
  }
  .mobile-resources-toggle {
    display: flex;
    position: absolute;
    z-index: 3;
    left: 8px;
    top: 132px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
    color: #fff;
    background: #194b80;
    border-color: #194b80;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 3px 12px #102d4b33;
  }
  .mobile-resources-toggle:hover {
    color: #fff;
    background: #246098;
  }
  body.resources-open::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 14;
    background: #102d4b99;
  }
  .controls {
    display: none;
    min-height: 0;
  }
  .controls.is-open {
    display: flex;
    position: fixed;
    z-index: 15;
    top: 8px;
    right: 8px;
    bottom: auto;
    left: 8px;
    height: min(660px, calc(100% - 16px));
    overflow: hidden;
    border: 1px solid #c7d1d8;
    border-radius: 12px;
    box-shadow: 0 16px 36px #102d4b55;
  }
  .pane {
    overflow: auto;
    min-height: 0;
    flex: 1;
  }
  #closeResourcePanel {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #102d4b;
    background: #f1f4f6;
    font-size: 26px;
  }
  .stage-head {
    font-size: 9px;
  }
  .hint {
    font-size: 9px;
  }
  .stage-foot {
    font-size: 9px;
    letter-spacing: 0;
  }
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card img {
    height: 110px;
  }
  .dimension-form.show {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media print {
  body > header,
  body > main {
    display: none;
  }
  dialog {
    position: static;
    display: block !important;
    width: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    color: #111;
    background: white;
  }
  dialog::backdrop,
  .modal-head button,
  #printSheet {
    display: none;
  }
  #modalBody {
    max-height: none;
    overflow: visible;
  }
  #modalBody td {
    border-color: #ccc;
  }
}

/* Gia Phat brand system: navy, architectural blue, and red accents. */
:root {
  color: #172c40;
  background: #f6f7f5;
  --muted: #546678;
  --line: #d8dfe3;
  --gold: #c52332;
  --green: #194b80;
}
body { color: #172c40; background: #f6f7f5; }
button { color: #172c40; background: #fff; border-color: #c7d1d8; }
button:hover { color: #102d4b; border-color: #c52332; background: #fbf1f2; }
button.primary { color: #fff; background: #c52332; border-color: #c52332; }
button.primary:hover { color: #fff; background: #a91f2c; border-color: #a91f2c; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #194b80;
  outline-offset: 2px;
}
input, select { color: #172c40; background: #fff; border-color: #b8c6cf; }
.top { color: #fff; background: #102d4b; border-color: #194b80; }
.brand small { color: #d8e3ec; }
.actions button { color: #fff; background: #194b80; border-color: #47729a; }
.actions button:hover { color: #fff; background: #246098; border-color: #d9e4ed; }
.actions button.primary { color: #fff; background: #c52332; border-color: #c52332; }
.stage-head, .stage-foot { color: #344e63; }
#badge, .stage-foot { color: #546678; }
.stage-foot span:first-child { color: #c52332; font-weight: 700; }
.stage { border-color: #c7d1d8; background: radial-gradient(ellipse at 50% 35%, #edf1f3, #dce4e8 58%, #cbd7df); }
.view-tabs button, .stage-tools button { color: #172c40; background: #ffffffed; border-color: #c7d1d8; }
.view-tabs button:hover, .stage-tools button:hover { color: #102d4b; background: #fff; }
.view-tabs button.selected { color: #fff; background: #194b80; border-color: #194b80; }
.view-tabs button:focus-visible, .card:focus-visible { outline-color: #c52332; }
.hint { color: #172c40; background: #ffffffeb; }
.controls { background: #fff; border-color: #d8dfe3; }
.customer, nav { border-color: #d8dfe3; }
.customer b { color: #102d4b; }
nav button { color: #344e63; }
nav button:hover { color: #102d4b; background: #f1f4f6; }
nav button.active { color: #fff; background: #194b80; border-color: #194b80; }
.pane-title h2 { color: #102d4b; }
.config-options { background: #f6f7f5; }
.config-options .option-row { color: #344e63; }
.card { color: #172c40; background: #fff; border-color: #d8dfe3; }
.card:hover { border-color: #194b80; }
.card.selected { border-color: #c52332; box-shadow: 0 0 0 1px #c5233240; }
.card small { color: #546678; }
.swatch { background: #e7edf1; }
.dimension-form label { color: #344e63; }
.bottom { background: #fff; }
dialog { color: #172c40; background: #fff; border-color: #d8dfe3; }
#modalBody td { border-color: #e2e7ea; }
.scene-status { color: #fff; background: #102d4bed; border-color: #47729a; }
.scene-status.error { color: #fff; background: #a91f2c; border-color: #c52332; }
.file-notice a { color: #d7e8f5; }
@media (max-width: 920px) {
  body.embedded-viewer .stage-wrap { height: 55vh; }
}
@media (max-width: 600px) {
  body.embedded-viewer .stage-wrap { height: clamp(720px, 240vw, 900px); }
  .actions button { min-height: 44px; }
  .view-tabs button, .stage-tools button { min-height: 44px; }
  nav button { min-height: 44px; }
}
