/* Sơ đồ tầng · Tòa 104 */
:root {
  --navy: #0f2747;
  --navy-2: #1b3a63;
  --gold: #c8a35a;
  --bg: #f3f5f9;
  --card: #fff;
  --line: #e1e6ef;
  --text: #1c2533;
  --muted: #667085;
  --a: #0e9384;
  --a-soft: rgba(14, 147, 132, .14);
  --b: #7a5af8;
  --b-soft: rgba(122, 90, 248, .14);
  --hl: #f04438;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}
button { font: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }

/* ---------- header ---------- */
.sd-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(90deg, var(--navy), var(--navy-2));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.sd-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sd-logo {
  flex: none; width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gold); color: var(--navy); font-weight: 800; font-size: 16px;
}
.sd-back {
  flex: none; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; font-size: 18px;
}
.sd-back:hover { background: rgba(255, 255, 255, .25); }
.sd-brand h1 { font-size: 18px; letter-spacing: .2px; }
.sd-brand p { margin: 2px 0 0; font-size: 12.5px; opacity: .8; }
.sd-search { position: relative; width: min(380px, 45vw); }
.sd-search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 0; border-radius: 10px; outline: none;
  font-size: 15px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23667085' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 12px center;
}
.sd-search input::placeholder { text-transform: none; font-weight: 400; letter-spacing: 0; }
.sd-search input:focus { box-shadow: 0 0 0 3px rgba(200, 163, 90, .55); }
.sd-suggest {
  position: absolute; top: 46px; left: 0; right: 0; margin: 0; padding: 6px;
  list-style: none; background: #fff; color: var(--text);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  max-height: 360px; overflow: auto;
}
.sd-suggest li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.sd-suggest li b { font-size: 15px; }
.sd-suggest li span { color: var(--muted); font-size: 12.5px; }
.sd-suggest li.on, .sd-suggest li:hover { background: #eef2f8; }
.sd-suggest li.none { color: var(--muted); cursor: default; }

/* ---------- layout ---------- */
.sd-layout { display: grid; grid-template-columns: 210px 1fr; gap: 18px; padding: 18px 20px 40px; }
.sd-side {
  position: sticky; top: 82px; align-self: start;
  max-height: calc(100vh - 100px); display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px;
}
.sd-towers { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sd-tower {
  height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 700;
}
.sd-tower[data-toa="A"].on { background: var(--a); border-color: var(--a); color: #fff; }
.sd-tower[data-toa="B"].on { background: var(--b); border-color: var(--b); color: #fff; }
.sd-floors-title { margin: 12px 2px 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.sd-floors { overflow: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding-right: 2px; }
.sd-floor {
  position: relative; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd;
  font-weight: 700; font-size: 14px; line-height: 1.05;
}
.sd-floor small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); }
.sd-floor:hover { border-color: var(--navy-2); }
.sd-floor.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.sd-floor.on small { color: #cdd6e4; }
.sd-floor.wide { grid-column: span 3; }
.sd-side-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.sd-main { min-width: 0; }
.sd-floorhead {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.sd-floorname h2 { font-size: 22px; }
.sd-floorname span { color: var(--muted); font-size: 13px; }
.sd-legend { margin-left: auto; display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.sd-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.dot.a { background: var(--a); } .dot.b { background: var(--b); }
.sd-legend .hint { font-style: italic; }
.sd-icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--navy);
  display: inline-grid; place-items: center; font-size: 13px;
}
.sd-icon-btn:hover:not(:disabled) { background: #eef2f8; }
.sd-icon-btn:disabled { opacity: .35; cursor: default; }

/* ---------- đăng nhập ---------- */
.sd-layout[hidden], .sd-search[hidden], .sd-gate[hidden] { display: none; }
.sd-gate { display: grid; place-items: center; min-height: calc(100vh - 70px); padding: 24px 16px; }
.sd-gate-card {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 6px;
  background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(16, 24, 40, .12); padding: 26px 24px;
}
.sd-gate-icon { font-size: 30px; text-align: center; }
.sd-gate-card h2 { font-size: 19px; text-align: center; color: var(--navy); }
.sd-gate-card p { margin: 0 0 8px; text-align: center; color: var(--muted); font-size: 13px; }
.sd-gate-card label { font-size: 13px; font-weight: 600; margin-top: 6px; }
.sd-gate-card input { height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font: inherit; }
.sd-gate-card input:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(27, 58, 99, .15); }
.sd-gate-card .btn { justify-content: center; margin-top: 12px; height: 42px; }
.sd-gate-card .btn:disabled { opacity: .6; }
.sd-gate-err { padding: 8px 10px; border-radius: 8px; background: #fef3f2; color: #b42318; font-size: 13px; margin-top: 6px; }
.sd-gate-back { text-align: center; margin-top: 10px; font-size: 13px; color: var(--navy-2); }

/* ---------- view tabs ---------- */
.sd-views { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: #e6ebf3; border-radius: 10px; }
.sd-views button { height: 34px; padding: 0 16px; border: 0; border-radius: 8px; background: transparent; font-weight: 700; color: var(--muted); }
.sd-views button.on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

/* ---------- stacking plan ---------- */
.sd-stackhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.sd-colorby { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.sd-colorby select { height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; color: var(--text); background: #fff; }
.sd-stack-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 2px 10px; font-size: 12.5px; color: var(--text); }
.sd-stack-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .08); }
.sd-stack-legend em { font-style: normal; color: var(--muted); }
.sd-stack-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.sd-stack-scroll { overflow: auto; max-height: calc(100vh - 260px); }
.sd-stack { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.sd-stack thead th {
  position: sticky; top: 0; z-index: 2; background: var(--card);
  padding: 4px 2px; font-weight: 700; color: var(--muted); min-width: 66px;
}
.sd-stack th.fl, .sd-stack th.corner {
  position: sticky; left: 0; z-index: 1; background: var(--card);
  min-width: 46px; padding: 0 6px; text-align: center; font-size: 13px; font-weight: 800; color: var(--navy);
}
.sd-stack thead th.corner { z-index: 3; font-size: 11px; color: var(--muted); }
.sd-stack th.end { position: static; }
.sd-stack th.fl { cursor: pointer; border-radius: 6px; }
.sd-stack th.fl:hover { background: #eef2f8; }
.sd-stack td { padding: 0; }
.sd-stack td.empty { background: repeating-linear-gradient(45deg, #f6f7f9, #f6f7f9 4px, #fff 4px, #fff 8px); border-radius: 6px; }
.sd-stack .cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  width: 100%; min-width: 66px; height: 50px; padding: 2px 4px;
  border: 1px solid rgba(15, 39, 71, .08); border-radius: 6px; background: var(--c); color: var(--text);
  line-height: 1.15; transition: transform .08s, box-shadow .08s;
}
.sd-stack .cell b { font-size: 12.5px; }
.sd-stack .cell span { font-size: 11.5px; font-variant-numeric: tabular-nums; }
.sd-stack .cell small { font-size: 10px; opacity: .75; }
.sd-stack .cell.dark { color: #fff; }
.sd-stack .cell:hover { transform: scale(1.06); box-shadow: 0 4px 12px rgba(16, 24, 40, .2); position: relative; z-index: 1; }
.sd-stack .cell.on { outline: 3px solid var(--hl); outline-offset: 1px; }
.sd-stack-note { margin: 10px 2px 0; font-size: 12px; color: var(--muted); }

/* ---------- floor plan ---------- */
.sd-plan-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; margin-bottom: 18px; }
.sd-plan { position: relative; margin: 0 auto; max-width: 1150px; }
.sd-plan img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.sd-plan .noplan { padding: 40px 16px; text-align: center; color: var(--muted); }
.spot {
  position: absolute; padding: 0; border: 2px solid transparent; border-radius: 4px; background: transparent;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.spot.a { border-color: rgba(14, 147, 132, .55); }
.spot.b { border-color: rgba(122, 90, 248, .55); }
.spot.other { border-style: dashed; opacity: .75; }
.spot:hover, .spot:focus-visible { outline: none; background: rgba(255, 214, 102, .35); border-color: #f79009; box-shadow: 0 0 0 3px rgba(247, 144, 9, .25); }
.spot.hl { border-color: var(--hl); background: rgba(240, 68, 56, .18); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240, 68, 56, .55); } 50% { box-shadow: 0 0 0 10px rgba(240, 68, 56, 0); } }
.spot .tip {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: var(--navy); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px;
}
.spot:hover .tip { opacity: 1; }

/* ---------- unit grid ---------- */
.sd-sec-title { font-size: 15px; margin: 0 2px 10px; color: var(--navy); }
.sd-sec-title small { color: var(--muted); font-weight: 400; }
.sd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.sd-unit {
  text-align: left; border: 1px solid var(--line); border-left: 4px solid var(--a);
  background: var(--card); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .1s;
}
.sd-unit.b { border-left-color: var(--b); }
.sd-unit:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(16, 24, 40, .12); }
.sd-unit .code { font-size: 18px; font-weight: 800; color: var(--navy); }
.sd-unit .area { font-size: 13.5px; margin-top: 2px; }
.sd-unit .area b { font-size: 15px; }
.sd-unit .meta { margin-top: 4px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.sd-unit .miss { color: #b54708; }
.sd-group-title { grid-column: 1 / -1; margin: 6px 2px 0; font-weight: 700; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; }

/* ---------- modal ---------- */
.sd-modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.sd-modal[hidden] { display: none; }
.sd-modal-bg { position: absolute; inset: 0; background: rgba(15, 23, 42, .6); backdrop-filter: blur(2px); }
.sd-dialog {
  position: relative; width: min(1380px, 96vw); height: min(900px, 94vh);
  background: #fff; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.sd-dialog-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: #f8fafc;
}
.sd-mtitle { min-width: 0; }
.sd-mtitle h2 { font-size: 22px; color: var(--navy); }
.sd-mtitle span { font-size: 13px; color: var(--muted); }
.sd-close { margin-left: auto; }
.sd-dialog-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px 1fr; }
.sd-specs { overflow: auto; padding: 14px 16px 20px; border-right: 1px solid var(--line); }
.sd-media { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px 10px; }

.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th, .kv td { padding: 6px 4px; border-bottom: 1px dashed var(--line); vertical-align: top; }
.kv th { text-align: left; font-weight: 500; color: var(--muted); width: 50%; }
.kv td { font-weight: 700; text-align: right; }
.kv td.big { font-size: 17px; color: var(--navy); }
.spec-h { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--navy); }
.rooms { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rooms td { padding: 5px 4px; border-bottom: 1px solid #f0f2f6; }
.rooms td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rooms tr:nth-child(even) td { background: #fafbfd; }
.note { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #fffaeb; color: #93370d; font-size: 12.5px; }
.note.info { background: #eff8ff; color: #175cd3; }
.txtbox { margin-top: 6px; position: relative; }
.txtbox textarea {
  width: 100%; min-height: 190px; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 8px;
  font: 13px/1.5 ui-monospace, Consolas, "Courier New", monospace; color: var(--text); background: #fbfcfe;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font-weight: 600;
}
.btn.ghost { background: #fff; color: var(--navy); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.sd-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.sd-tabs button {
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-weight: 600; color: var(--muted);
}
.sd-tabs button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.sd-tabs button:disabled { opacity: .4; cursor: not-allowed; }
.sd-lvl { display: flex; gap: 6px; margin-top: 8px; }
.sd-lvl[hidden] { display: none; }
.sd-lvl button { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.sd-lvl button.on { border-color: var(--gold); background: #fdf6e7; font-weight: 700; }
.sd-viewer {
  position: relative; flex: 1; min-height: 0; margin-top: 8px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: #f6f7f9; cursor: grab; touch-action: none;
}
.sd-viewer.drag { cursor: grabbing; }
.sd-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.sd-stage img { display: block; user-select: none; -webkit-user-drag: none; max-width: none; }
.sd-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.sd-zoom button, .sd-zoom a {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center; font-size: 17px; color: var(--navy); text-decoration: none; box-shadow: var(--shadow);
}
.sd-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; background: #f6f7f9; }
.sd-empty[hidden] { display: none; }
.sd-media-src { margin-top: 6px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-loading::after { content: "Đang tải ảnh…"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); }

.sd-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .sd-dialog-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; overflow: auto; }
  .sd-specs { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; overflow: visible; }
  .sd-media { min-height: 70vh; }
}
@media (max-width: 760px) {
  .sd-top { flex-wrap: wrap; padding: 10px 12px; }
  .sd-brand p { display: none; }
  .sd-search { width: 100%; }
  .sd-layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .sd-side { position: static; max-height: none; }
  .sd-floors { grid-template-columns: repeat(6, 1fr); max-height: 170px; }
  .sd-floor.wide { grid-column: span 6; }
  .sd-legend .hint { display: none; }
  .sd-dialog { width: 100vw; height: 100vh; border-radius: 0; }
  .sd-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
