/* HUCE Struct – phần mềm mẫu (prototype) theo đặc tả HS-BA-F00, F01, F02. */
:root {
  --brand: #1F4E79; --brand-d: #163A5B; --brand-l: #DCE6F1; --brand-b: #9DB6D1;
  --sel: #C46A12; --sel-l: #FCEBD7; --warn: #8A4B0C;
  --bg: #EEF1F4; --panel: #FFFFFF; --bar: #F7F9FB; --line: #D3D9E0; --line-l: #E3E8EE; --input: #B7C2CE;
  --text: #1B2430; --text-2: #2B3644; --muted: #5A6675; --dim: #6B7684;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.35 'IBM Plex Sans', system-ui, sans-serif; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); }
.mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#app { height: 100%; display: flex; flex-direction: column; }

/* Title bar */
.titlebar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 5px 12px; background: var(--brand); color: #fff; }
.logo { width: 26px; height: 26px; border-radius: 5px; background: #fff; color: var(--brand); font-weight: 600; font-size: 12px; display: flex; align-items: center; justify-content: center; border: 0; cursor: pointer; }
.appname { font-weight: 600; }
.modelname { background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 3px 6px; color: #fff; cursor: text; max-width: 320px; }
.modelname:hover { border-color: rgba(255,255,255,.45); }
input.modelname { background: #fff; color: var(--text); border-color: #fff; outline: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 10px; background: rgba(255,255,255,.14); font-size: 12px; }
.chip.lock { background: #E8912D; color: #1B2430; }
.grow { flex: 1 1 auto; }
.avatar { width: 26px; height: 26px; border-radius: 50%; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--brand); color: #1B2430; }
.btn-light { background: #fff; color: var(--brand); border: 0; border-radius: 4px; padding: 5px 14px; font-weight: 600; cursor: pointer; }

/* Menu bar */
.menubar { display: flex; flex-wrap: wrap; gap: 1px; padding: 2px 8px; background: var(--bar); border-bottom: 1px solid var(--line); position: relative; z-index: 30; }
.menubar > .mtop { position: relative; }
.mbtn { padding: 4px 9px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; }
.mbtn:hover, .mbtn.open { background: #E3E8EE; }
.dropdown { position: absolute; top: 100%; left: 0; min-width: 280px; padding: 4px 0; background: #fff; border: 1px solid var(--input); border-radius: 6px; box-shadow: 0 8px 24px rgba(20,30,45,.18); z-index: 40; }
.dropdown .dropdown { top: -5px; left: 100%; }
.mitem { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 12px 5px 28px; border: 0; background: transparent; text-align: left; cursor: pointer; white-space: nowrap; }
.mitem:hover, .mitem:focus-visible { background: var(--brand-l); outline: none; }
.mitem[disabled] { color: var(--dim); cursor: default; background: transparent; }
.mitem .k { margin-left: auto; padding-left: 24px; color: var(--muted); font-size: 12px; }
.mitem .arrow { margin-left: auto; padding-left: 16px; color: var(--muted); }
.mitem .check { position: absolute; left: 10px; color: var(--brand); }
.mitem.todo { color: var(--text-2); }
.mitem.todo::after { content: ''; position: absolute; left: 12px; top: 50%; width: 5px; height: 5px; margin-top: -2px; border-radius: 50%; background: #C3CCD6; }
.msep { height: 1px; margin: 4px 0; background: var(--line-l); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 3px 8px; background: var(--bar); border-bottom: 1px solid var(--line); }
.tb { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 30px; height: 30px; padding: 0 6px; border: 1px solid transparent; border-radius: 4px; background: transparent; cursor: pointer; color: var(--text-2); }
.tb:hover { background: #E3E8EE; border-color: #CBD3DC; }
.tb.on { background: var(--brand-l); border-color: var(--brand-b); }
.tb.draw-on { background: var(--sel-l); border-color: #E8912D; }
.tb.primary { background: var(--brand); color: #fff; padding: 0 10px; }
.tb.primary:hover { background: var(--brand-d); }
.tb[disabled] { opacity: .45; cursor: default; background: transparent; border-color: transparent; }
.tb.txt { font-family: var(--mono); font-size: 11px; }
.vsep { width: 1px; height: 20px; background: #CBD3DC; margin: 0 4px; }
.hsep { height: 1px; background: #CBD3DC; margin: 3px 2px; }

/* Body */
.body { flex: 1 1 auto; min-height: 0; display: flex; gap: 6px; padding: 6px; }
.drawbar { display: flex; flex-direction: column; gap: 2px; padding: 4px; background: var(--bar); border: 1px solid var(--line); border-radius: 6px; }
.side { width: 290px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.panel-h { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-bottom: 1px solid var(--line-l); font-weight: 600; }
.xbtn { width: 24px; height: 24px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.xbtn:hover { background: #E3E8EE; }
.tabs { display: flex; gap: 2px; padding: 4px 6px 0; border-bottom: 1px solid var(--line-l); }
.tab { padding: 5px 9px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.tab.on { border-bottom-color: var(--brand); color: var(--text); font-weight: 600; }
.tree { list-style: none; margin: 0; padding: 0 0 0 14px; }
.tree li { padding: 2px 0; }
.tree .node { border: 0; background: transparent; padding: 1px 4px; border-radius: 3px; cursor: pointer; text-align: left; }
.tree .node:hover { background: var(--brand-l); }
.tree .muted { color: var(--muted); }
.props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); font-size: 12px; }
.props > div { padding: 5px 10px; border-bottom: 1px solid #EEF1F4; }
.props > div:nth-child(odd) { color: var(--muted); }
.views { flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; }
.vwin { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.vwin.active { border: 2px solid var(--brand); }
.vwin-h { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; background: var(--bar); border-bottom: 1px solid var(--line-l); font-weight: 500; }
.vwin.active .vwin-h { background: var(--brand-l); border-bottom-color: #C3D2E3; }
.canvas { flex: 1 1 auto; position: relative; background: #FBFCFD; }
.canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lockbanner { padding: 4px 10px; background: var(--sel-l); color: var(--warn); font-size: 12px; border-bottom: 1px solid #F0C894; }

/* Status bar */
.statusbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 3px 12px; background: var(--bar); border-top: 1px solid var(--line); font-size: 12px; }
.statusbar select, .sbtn { padding: 2px 6px; border: 1px solid #CBD3DC; border-radius: 4px; background: #fff; cursor: pointer; }

/* Model Manager */
.mm { flex: 1 1 auto; overflow: auto; display: flex; flex-wrap: wrap; gap: 20px; padding: 20px; align-content: flex-start; }
.mm-nav { flex: 0 0 230px; display: flex; flex-direction: column; gap: 3px; }
.mm-new { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; margin-bottom: 12px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
.mm-new span { font-weight: 400; opacity: .8; font-size: 12px; }
.navb { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; font-size: 14px; }
.navb:hover { background: #E3E8EE; }
.navb.on { background: var(--brand-l); font-weight: 600; }
.mm-main { flex: 1 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 12px; font-size: 14px; }
.mm-main h1 { margin: 0; font-size: 22px; font-weight: 600; }
.tablebox { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; padding: 10px 16px; font-weight: 500; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line-l); }
table.list td { padding: 10px 16px; border-bottom: 1px solid #EEF1F4; }
table.list tr:hover td { background: #F3F6F9; }
.linkbtn { border: 0; background: transparent; color: var(--brand); font-weight: 500; cursor: pointer; padding: 0; text-align: left; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--bg); }
.badge.Locked { background: var(--sel-l); color: #7A420A; }
.badge.Editing { background: var(--brand-l); color: var(--brand-d); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 9px 20px; background: var(--sel-l); border-bottom: 1px solid #F0C894; color: #5C3208; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* Dialogs */
.overlay { position: fixed; inset: 0; background: rgba(20,30,45,.28); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.dialog { background: var(--bar); border: 1px solid var(--input); border-radius: 8px; box-shadow: 0 18px 48px rgba(20,30,45,.3); display: flex; flex-direction: column; max-width: 100%; max-height: 100%; }
.dlg-h { display: flex; align-items: center; padding: 9px 10px 9px 16px; background: #fff; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; cursor: default; }
.dlg-h h2 { margin: 0; font-size: 15px; font-weight: 600; }
.dlg-b { padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.dlg-f { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #fff; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.dlg-f .note { color: var(--muted); font-size: 12px; }
.b { min-width: 84px; padding: 6px 14px; border: 1px solid var(--input); border-radius: 5px; background: #fff; cursor: pointer; }
.b:hover { background: #F3F6F9; }
.b.ok { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.b.ok:hover { background: var(--brand-d); }
.b[disabled] { color: var(--dim); border-color: var(--line); background: #F3F5F7; cursor: default; }
.b.sm { min-width: 0; padding: 4px 10px; }
fieldset { margin: 0; padding: 8px 14px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
legend { padding: 0 6px; font-weight: 600; color: var(--brand); }
.fld { display: grid; grid-template-columns: minmax(0, 1fr) auto 26px; align-items: center; column-gap: 8px; padding: 3px 0 3px 24px; }
.fld.off { color: var(--dim); }
.radio { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.num { font-family: var(--mono); font-size: 13px; width: 100px; padding: 4px 8px; border: 1px solid var(--input); border-radius: 4px; background: #fff; text-align: right; }
.txt { padding: 4px 8px; border: 1px solid var(--input); border-radius: 4px; background: #fff; }
.num:disabled, .txt:disabled, select:disabled { background: #EEF1F4; color: var(--dim); border-color: var(--line); }
.num.err, .txt.err { border-color: #B3261E; background: #FCEEEE; }
.errmsg { color: #B3261E; font-size: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lst { margin: 0; padding: 4px; list-style: none; border: 1px solid var(--input); border-radius: 4px; background: #fff; overflow: auto; }
.lst li button { display: block; width: 100%; padding: 3px 8px; border: 0; border-radius: 3px; background: transparent; text-align: left; cursor: pointer; }
.lst li button.on { background: var(--brand-l); }
.col { display: flex; flex-direction: column; gap: 7px; }
.col .b { text-align: left; }
.sheet { border: 1px solid var(--input); border-radius: 4px; background: #fff; overflow: auto; }
.sheet table { border-collapse: collapse; width: 100%; font-size: 12px; }
.sheet th { position: sticky; top: 0; background: #F3F5F7; font-weight: 500; padding: 5px 6px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-l); white-space: nowrap; }
.sheet td { border-bottom: 1px solid #EEF1F4; border-right: 1px solid #EEF1F4; padding: 0; }
.sheet td.ro { background: #F3F5F7; color: var(--muted); padding: 4px 8px; text-align: center; }
.sheet td input, .sheet td select { width: 100%; border: 0; padding: 4px 8px; background: transparent; text-align: center; font-family: var(--mono); font-size: 12px; }
.sheet td input:focus, .sheet td select:focus { outline: 2px solid var(--brand-b); outline-offset: -2px; background: #fff; }
.sheet tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.swatch { width: 100%; height: 22px; border: 0; padding: 0; cursor: pointer; }
.ctx { position: fixed; z-index: 120; min-width: 260px; padding: 4px 0; background: #fff; border: 1px solid var(--input); border-radius: 6px; box-shadow: 0 8px 24px rgba(20,30,45,.18); }
.preview { border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.changes { border: 1px solid var(--line-l); border-radius: 6px; overflow: hidden; }
.changes > div { display: grid; grid-template-columns: 120px minmax(0, 1fr) 22px minmax(0, 1fr); gap: 4px; padding: 7px 12px; border-top: 1px solid #EEF1F4; }
.changes > div:first-child { border-top: 0; background: var(--bar); color: var(--muted); font-size: 12px; }
.alert-ico { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; background: var(--sel-l); display: flex; align-items: center; justify-content: center; }

/* Toast */
.toasts { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-radius: 6px; background: #1B2430; color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.25); max-width: 560px; }
.toast button { border: 0; background: transparent; color: #9CC3E6; font-weight: 600; cursor: pointer; }

/* Version History */
.vh { width: 320px; flex: 0 0 auto; }
.vh-item { padding: 8px 10px; border-bottom: 1px solid #EEF1F4; font-size: 12px; }
.vh-item b { font-size: 13px; }

/* ViewCube (khung 3D) – hình vẽ tự thiết kế */
.viewcube { position: absolute; top: 6px; right: 6px; width: 132px; display: flex; flex-direction: column; align-items: center; user-select: none; -webkit-user-select: none; touch-action: none; }
.canvas .viewcube svg.vc-svg { position: static; width: 132px; height: 144px; inset: auto; overflow: visible; }
.vc-home, .vc-menu { position: absolute; top: 2px; width: 28px; height: 28px; border: 1px solid transparent; border-radius: 6px; background: rgba(255,255,255,.85); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1; }
.vc-home { left: 2px; } .vc-menu { right: 2px; }
.vc-home:hover, .vc-menu:hover { border-color: var(--brand-b); background: var(--brand-l); }
.vc-face { fill: #E9EEF4; stroke: #7C8A9A; stroke-width: 1; }
.vc-hit { cursor: pointer; }
.vc-hit:hover .vc-face { fill: #CFE0F2; stroke: var(--brand); }
.vc-label { fill: #2B3644; font-family: 'IBM Plex Sans', sans-serif; font-weight: 600; letter-spacing: .5px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.vc-spot { fill: rgba(31,78,121,0); stroke: none; }
.vc-spot:hover { fill: rgba(31,78,121,.55); }
.vc-ring { fill: none; stroke: #B7C2CE; stroke-width: 6; stroke-opacity: .55; }
.vc-cdot { fill: #fff; stroke: #9AA7B5; }
.vc-hit:hover .vc-cdot { fill: var(--brand-l); stroke: var(--brand); }
.vc-ctext { font: 600 8px 'IBM Plex Sans', sans-serif; fill: #2B3644; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.vc-mode { margin-top: -4px; font-size: 10px; color: var(--muted); background: rgba(255,255,255,.8); padding: 0 6px; border-radius: 8px; }

/* Model Manager – danh sách kiểu Google Drive */
.mm-search { flex: 1 1 260px; max-width: 560px; display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 8px; background: rgba(255,255,255,.14); }
.mm-search input { flex: 1 1 auto; min-width: 0; border: 0; outline: none; background: transparent; color: #fff; }
.mm-list tbody tr { cursor: default; outline: none; }
.mm-list tbody tr.sel td { background: #D6E4F3; }
.mm-list tbody tr:focus-visible td { box-shadow: inset 0 0 0 2px var(--brand-b); }
.c-name { min-width: 220px; }
.nm { display: flex; align-items: center; gap: 10px; }
.mi-ico { color: var(--brand); display: inline-flex; }
.starmark, .offmark { display: inline-flex; color: #B07A12; }
.offmark { color: var(--muted); }
.starmark svg, .offmark svg { width: 14px; height: 14px; }
.c-act { text-align: right; white-space: nowrap; width: 1%; }
.ra { width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; vertical-align: middle; }
.ra:hover, .ra:focus-visible { background: rgba(31,78,121,.12); outline: none; }
.ras { display: inline-flex; gap: 2px; visibility: hidden; }
.mm-list tbody tr:hover .ras, .mm-list tbody tr.sel .ras, .mm-list tbody tr:focus-within .ras { visibility: visible; }
.badge.Locked { margin-left: 2px; }
/* Menu ngữ cảnh kiểu Drive */
.gmenu { min-width: 300px; padding: 6px 0; border-radius: 8px; border: 1px solid #DDE2E8; box-shadow: 0 2px 6px rgba(20,30,45,.15), 0 8px 24px rgba(20,30,45,.12); }
.gitem { display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px 16px; border: 0; background: transparent; text-align: left; cursor: pointer; color: var(--text); font-size: 14px; }
.gitem:hover, .gitem:focus-visible { background: #EEF2F6; outline: none; }
.gitem[disabled] { color: var(--dim); cursor: default; }
.gi { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); flex: 0 0 auto; }
.gl { flex: 1 1 auto; }
.gk { color: var(--muted); font-size: 12px; padding-left: 18px; }
.sh-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.sh-row .avatar { border-color: #fff; }

/* Màn hình cảm ứng: vùng bấm đủ lớn */
@media (pointer: coarse) {
  .tb { min-width: 40px; height: 40px; }
  .ras { visibility: visible; }
  .ra { width: 40px; height: 40px; }
  .gitem { padding: 12px 18px; }
  .mbtn { padding: 8px 12px; }
  .mitem { padding: 10px 14px 10px 30px; }
  .b { min-height: 40px; }
  .vc-home, .vc-menu { width: 36px; height: 36px; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100%; }
  .titlebar { gap: 6px 10px; }
  .modelname { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menubar { padding: 2px 4px; }
  .dropdown { min-width: 0; width: max-content; max-width: calc(100vw - 16px); max-height: 70vh; overflow: auto; }
  .dropdown .dropdown { position: static; box-shadow: none; border: 0; border-left: 2px solid var(--brand-l); border-radius: 0; margin-left: 14px; padding: 0; }
  .mitem { white-space: normal; }
  .body { flex-wrap: wrap; padding: 4px; gap: 4px; }
  .drawbar { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .drawbar .hsep { width: 1px; height: 22px; margin: 0 3px; }
  .side { width: 100%; }
  .side .panel:first-child { max-height: 260px; }
  .views { flex-direction: column; width: 100%; }
  .vwin { flex: 0 0 auto; min-height: 380px; }
  .vh { width: 100%; }
  .statusbar { gap: 6px 10px; }
  .statusbar #cursor { display: none; }
  .mm { padding: 12px; gap: 12px; }
  .mm-nav { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; }
  .mm-new { flex: 1 1 100%; margin-bottom: 4px; }
  .navb { width: auto; flex: 1 1 auto; justify-content: center; }
  .overlay { padding: 8px; align-items: flex-start; overflow: auto; }
  .dialog { width: 100% !important; max-height: none; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .dlg-f { flex-wrap: wrap; }
  .dlg-f .note { flex: 1 1 100%; }
  .row { flex-wrap: wrap; }
  .mm-list .c-owner, .mm-list .c-size, .mm-list .c-units { display: none; }
  .c-name { min-width: 0; }
  .ras { visibility: visible; }
  .mm-cur { display: none; }
  .gmenu { min-width: 0; width: calc(100vw - 16px); max-width: 360px; }
}
@media (max-width: 520px) {
  .fld { grid-template-columns: minmax(0, 1fr) auto 22px; padding-left: 8px; font-size: 12px; }
  .num { width: 84px; }
  .banner { padding: 8px 12px; font-size: 13px; }
  .appname { display: none; }
  .chip { font-size: 11px; }
  .toasts { left: 8px; right: 8px; transform: none; }
  .toast { max-width: 100%; }
  .viewcube { transform: scale(.85); transform-origin: top right; }
  .mm-list .c-mod { display: none; }
  .ras .ra:not([data-act="rowShare"]) { display: none; }
}
