﻿[hidden] { display: none !important; }
:root {
  /* palette shared with the admin panel (css/admin.css) */
  --bg: #f4f6fb; --panel: #ffffff; --panel-2: #f8f9fc; --border: #d9deea; --border-soft: #e7eaf2; --line: #edf0f6;
  --sel: #e4e6ff; --selb: #c5c8ff; --accent: #4f46e5; --accent-2: #6366f1; --accent-soft: #eef0ff; --accent-text: #ffffff;
  --result: #eef6f8; --text: #171b26; --gray: #8a93a6; --dim: #667085; --err: #c4320a;
  --ok: #12805c; --warn: #a15c07;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-pop: 0 12px 32px -8px rgba(16,24,40,.28), 0 0 0 1px rgba(16,24,40,.05);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 12.5px; color: var(--text);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; -webkit-font-smoothing: antialiased; }
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- controls ---------- */
button { font: inherit; font-weight: 550; padding: 4px 12px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; border-radius: var(--radius-sm); transition: background .12s, border-color .12s, box-shadow .12s; }
button:hover:not(:disabled) { background: var(--panel-2); border-color: #b7bfd3; }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
button:disabled { color: #a8afc0; cursor: default; background: var(--panel-2); }
button.sq { width: 28px; padding: 4px 0; }
button.w44 { width: 44px; padding: 4px 0; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
button.bold, .bold { font-weight: 650; }
input, select, textarea { font: inherit; border: 1px solid var(--border); padding: 4px 7px; background: var(--panel); color: var(--text); border-radius: var(--radius-sm); outline: none; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { margin: 0 6px 0 0; vertical-align: middle; accent-color: var(--accent); width: 14px; height: 14px; padding: 0; }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); box-shadow: none; }
input.invalid { border: 1px solid #e5484d; background: #fff1f1; }
input:disabled, select:disabled, textarea:disabled { background: var(--panel-2); color: var(--dim); }
h2 { font-size: 18px; font-weight: 650; margin: 2px 0 8px; letter-spacing: -.01em; }
b { font-weight: 650; }
.gray { color: var(--gray); } .dim { color: var(--dim); margin: 4px 0 8px; }
.pre { white-space: pre-wrap; } .mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.grow { flex: 1 1 auto; min-height: 0; min-width: 0; }
.col { display: flex; flex-direction: column; min-height: 0; }
.hsplit { display: flex; flex-direction: row; min-height: 0; flex: 1 1 auto; }
.pane { min-width: 0; min-height: 0; position: relative; }
.pad4 { padding: 4px; } .pad6 { padding: 6px; } .pad8 { padding: 8px; } .pad16 { padding: 16px; }
.mb6 { margin-bottom: 6px; } .mb8 { margin-bottom: 8px; } .mt8 { margin-top: 8px; margin-bottom: 8px; } .mt12 { margin-top: 12px; } .mt14 { margin-top: 14px; padding: 6px 10px; }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; flex: none; }
.toolbar.wrap { flex-wrap: wrap; } .toolbar.between { justify-content: space-between; }
.toolbar .chk { margin: 0 8px; }
.hint { color: var(--dim); padding: 2px 8px; flex: none; }
.summary { padding: 4px 8px; flex: none; }
.scroll { overflow: auto; min-height: 0; }
.chart-host { position: relative; overflow: hidden; background: #fff; }
.chk, .radio { display: inline-flex; align-items: center; white-space: nowrap; user-select: none; cursor: pointer; }
.radio { margin: 6px; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #cfd4e2; border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #aab2c8; background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- menu bar ---------- */
.menubar { display: flex; align-items: center; background: var(--panel); border-bottom: 1px solid var(--border-soft); flex: none; user-select: none; padding: 0 8px; height: 38px; gap: 2px; }
.menu { position: relative; padding: 6px 11px; cursor: default; border-radius: var(--radius-sm); font-weight: 550; }
.menu:hover, .menu.open { background: var(--accent-soft); color: var(--accent); }
.dropdown { display: none; position: absolute; left: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-pop); z-index: 50; min-width: 270px; padding: 5px; font-weight: 400; color: var(--text); }
.menu.open > .dropdown { display: block; }
.dropdown button { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 7px 12px; white-space: nowrap; border-radius: 6px; font-weight: 450; }
.dropdown button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); border: 0; }
.dropdown button:disabled { background: none; }
.dropdown kbd { font: inherit; font-size: 11.5px; color: var(--gray); margin-left: 34px; background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 5px; padding: 0 6px; }
.dropdown hr { border: 0; border-top: 1px solid var(--border-soft); margin: 4px 6px; }
.submenu { position: relative; padding: 7px 28px 7px 12px; border-radius: 6px; }
.submenu::after { content: "›"; position: absolute; right: 12px; color: var(--gray); }
.submenu:hover { background: var(--accent-soft); color: var(--accent); }
.submenu > .dropdown.sub { left: 100%; top: -6px; min-width: 150px; }
.submenu:hover > .dropdown.sub { display: block; }
.admin-link { margin-left: auto; color: var(--accent); font-weight: 650; cursor: pointer; }
.admin-link + .user-menu { margin-left: 4px; }
.user-menu { margin-left: auto; color: var(--accent); background: var(--accent-soft); }
.user-menu:hover, .user-menu.open { background: #e0e3ff; }
.dropdown.right { left: auto; right: 0; }

/* ---------- layout ---------- */
#main { flex: 1 1 auto; display: flex; min-height: 0; padding: 8px 8px 0; gap: 0; }
#treePane { width: 230px; min-width: 140px; background: var(--panel); overflow: auto; flex: none; border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 4px; }
.splitter.v { width: 8px; background: transparent; cursor: col-resize; flex: none; position: relative; }
.splitter.v::after { content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px; border-radius: 2px; background: transparent; transition: background .12s; }
.splitter.v:hover::after { background: var(--selb); }
.splitter.v.thick { width: 10px; }
#tabsPane { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.tabbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 4px; flex: none; margin-bottom: -1px; position: relative; z-index: 1; }
.tabbar button { border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 7px 13px; font-size: 12.5px; font-weight: 550; color: var(--dim); border-radius: 9px 9px 0 0; }
.tabbar button:hover:not(:disabled) { background: rgba(79,70,229,.06); color: var(--accent); border-color: transparent; }
.tabbar button.active { background: var(--panel); color: var(--accent); border-color: var(--border-soft); position: relative; box-shadow: 0 -2px 0 var(--accent) inset; }
.tab { display: none; flex: 1 1 auto; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tabbar + .tab { border-top-left-radius: 0; }
.tab.active { display: flex; }
#statusbar { flex: none; display: flex; align-items: center; background: var(--panel); border-top: 1px solid var(--border-soft); padding: 0 12px; height: 28px; white-space: nowrap; overflow: hidden; color: var(--dim); margin-top: 8px; font-size: 12px; }
#statusbar .sep { width: 1px; height: 14px; background: var(--border); margin: 0 12px; }
#busyPanel { display: inline-flex; align-items: center; gap: 8px; }
#busyPanel[hidden] { display: none; }
#busyBar { width: 160px; height: 8px; accent-color: var(--accent); }

/* ---------- tree ---------- */
.tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree > ul { padding-left: 4px; }
.tree li > span { display: inline-block; padding: 3px 8px; cursor: default; white-space: nowrap; border-radius: 6px; }
.tree li > span:hover { background: var(--panel-2); }
.tree li > span.sel { background: var(--sel); color: var(--accent); font-weight: 600; outline: 0; }
.tree .tog { width: 14px; display: inline-block; color: var(--gray); cursor: pointer; }

/* ---------- list box ---------- */
.listbox { border: 1px solid var(--border); background: var(--panel); overflow: auto; outline: none; border-radius: var(--radius-sm); margin: 0 4px; }
.listbox:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.listbox div { padding: 3px 8px; white-space: nowrap; cursor: default; }
.listbox div:hover { background: var(--panel-2); }
.listbox div.sel { background: var(--sel); color: var(--accent); font-weight: 600; }
.listbox:focus div.sel { background: var(--accent); color: #fff; }

/* ---------- grid (row height 22 px is fixed in js/grid.js) ---------- */
.grid { display: flex; flex-direction: column; border: 1px solid var(--border-soft); background: var(--panel); outline: none; min-height: 60px; position: relative; }
.grid:focus-within { border-color: var(--selb); }
.grid-head { overflow: hidden; flex: none; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.grid-body { overflow: auto; position: relative; flex: 1 1 auto; min-height: 0; }
.grid-spacer { position: absolute; left: 0; top: 0; width: 1px; }
.grid-rows { position: absolute; left: 0; top: 0; }
.grid-row { display: grid; position: absolute; left: 0; height: 22px; border-bottom: 1px solid var(--line); }
.grid-body .grid-row:hover:not(.sel) { background: #fafbff; }
.grid-header-row { position: relative; height: 24px; border-bottom: 0; }
.grid-cell { padding: 3px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid transparent; line-height: 15px; }
.grid-cell.center { text-align: center; padding-top: 2px; }
.grid-hcell { border-right: 1px solid var(--border-soft); font-weight: 650; padding-top: 4px; color: var(--dim); }
.grid-row.sel { background: var(--sel); }
.grid-sink { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }
.grid:focus-within .grid-row.sel { background: var(--accent); color: #fff; }
.grid:focus-within .grid-row.sel .result { background: #6a63ee; }
.grid-row.newrow { background: var(--panel); }
.grid-cell.cur { outline: 2px solid var(--accent-2); outline-offset: -2px; border-radius: 3px; }
.grid:focus-within .grid-row.sel .grid-cell.cur { outline-color: #fff; }
.grid-cell.result { background: var(--result); }
.grid-cell.invalid { outline: 1px solid #e5484d; outline-offset: -1px; }
.grid-editor { position: absolute; border: 2px solid var(--accent); padding: 2px 5px; z-index: 5; outline: none; border-radius: 4px; box-shadow: none; background: #fff; color: var(--text); }
.grid-editor.invalid { border-color: #e5484d; background: #fff1f1; }

/* ---------- dialogs ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10,13,25,.42); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 100; animation: fadeIn .12s ease-out; }
.modal-back.nonmodal { background: transparent; backdrop-filter: none; pointer-events: none; }
.modal-back.nonmodal .modal { pointer-events: auto; }
.modal { background: var(--panel); border: 1px solid var(--border-soft); border-radius: 14px; box-shadow: 0 24px 56px -12px rgba(16,24,40,.4); max-width: 96vw; max-height: 94vh; display: flex; flex-direction: column; min-width: 300px; animation: popIn .14s ease-out; }
.modal-title { display: flex; justify-content: space-between; align-items: center; padding: 16px 14px 4px 20px; font-size: 15px; font-weight: 650; cursor: move; user-select: none; letter-spacing: -.01em; }
.modal-x { border: 0; background: none; font-size: 22px; padding: 0 9px; line-height: 26px; color: var(--gray); border-radius: 7px; }
.modal-x:hover { background: #f1f2f7 !important; color: var(--text); border: 0; }
.modal-body { padding: 10px 20px 12px; overflow: auto; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 20px 18px; }
.modal-foot button { min-width: 88px; padding: 7px 16px; }
.modal-foot button.primary { box-shadow: 0 6px 14px -6px var(--accent); }
.msg { white-space: pre-wrap; max-width: 600px; padding-left: 44px; min-height: 34px; position: relative; line-height: 1.5; }
.msg::before { content: "i"; position: absolute; left: 0; top: -2px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); text-align: center; font: italic 700 17px/32px Georgia, serif; }
.msg.error::before { content: "✕"; background: #fdeceb; color: #d92d20; font: 700 14px/32px system-ui; font-style: normal; }
.msg.warn::before { content: "!"; background: #fff4dc; color: #b54708; font: 800 17px/32px system-ui; font-style: normal; }
.form { display: flex; flex-direction: column; gap: 6px; }
.frow { display: grid; grid-template-columns: 210px 1fr; align-items: center; gap: 8px; margin: 3px 0; }
.frow > span { color: var(--dim); font-weight: 550; }
.form2 { display: grid; grid-template-columns: 170px 1fr; align-items: center; row-gap: 6px; }
.form2 [hidden] { display: none; }
fieldset.group { border: 1px solid var(--border-soft); border-radius: var(--radius); margin: 10px 0 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; background: var(--panel-2); }
fieldset.group legend { font-weight: 650; color: var(--dim); padding: 0 6px; }
fieldset.group input:not([type]) { margin: 2px 0 6px; }
.indent { margin-left: 18px !important; }
details summary { cursor: pointer; padding: 8px 0; font-weight: 600; color: var(--accent); }
.wrapline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 3px 0; }
.wrapline input:not([type]) { width: 65px; }
.orange { color: #d9730d; font-weight: 600; } .err { color: var(--err); }
.all-chart { margin: 8px; background: #fff; border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.all-chart .title { font-weight: 650; padding: 8px 12px 0; }
.all-chart .nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 12px 0; }
.all-chart .nav input:not([type]) { width: 75px; }
.all-chart .chart-host { height: 240px; }
.tip { position: fixed; background: #1b2033; color: #f4f6fb; border-radius: 8px; padding: 6px 10px; white-space: pre-wrap; pointer-events: none; z-index: 200; max-width: 520px; box-shadow: var(--shadow-pop); font-size: 12px; }
.ctxmenu { position: fixed; z-index: 150; background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 5px; min-width: 160px; }
.ctxmenu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 14px; border-radius: 6px; font-weight: 450; }
.ctxmenu button:hover { background: var(--accent-soft); color: var(--accent); border: 0; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (max-width: 760px) { #treePane { width: 150px; } .menubar { overflow-x: auto; } }

/* ---------- DWG survey import (js/dwgimport.js) ---------- */
.menu-new { font-size: 9.5px; font-weight: 700; letter-spacing: .04em; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 1px 5px; margin-left: 14px; }
.modal.dwg-modal { width: min(1500px, 96vw); height: min(940px, 92vh); }
.dwg-modal .modal-body { padding: 6px 16px 8px; }
.dwg { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; }
.dwg-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.dwg-field { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dwg-field > span:first-child { color: var(--dim); font-weight: 550; }
.dwg-field select { max-width: 300px; }
.dwg-field input.num { width: 72px; text-align: right; }
.dwg-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.dwg-chip { padding: 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border-soft); font-weight: 600; color: var(--dim); white-space: nowrap; }
.dwg-chip.accent { background: var(--accent-soft); border-color: var(--selb); color: var(--accent); }
.dwg-chip.warn { background: #fff4e0; border-color: #f3d39b; color: var(--warn); }
.dwg-main { display: flex; gap: 10px; flex: 1 1 auto; min-height: 0; }
.dwg-plan { position: relative; flex: 1 1 auto; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(circle at 1px 1px, #e3e7f0 1px, transparent 0) 0 0 / 22px 22px, #fbfcfe; }
.dwg-plan canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.dwg-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 4px; }
.dwg-zoom button { width: 32px; height: 32px; padding: 0; font-size: 16px; box-shadow: var(--shadow); background: rgba(255,255,255,.94); }
.dwg-legend { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 12px; padding: 6px 10px; background: rgba(255,255,255,.92); border: 1px solid var(--border-soft); border-radius: 8px; box-shadow: var(--shadow); color: var(--dim); font-size: 11.5px; }
.dwg-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dwg-legend i { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.dwg-legend i.dash { background: repeating-linear-gradient(90deg, #9aa3b5 0 5px, transparent 5px 9px); }
.dwg-tip { position: absolute; pointer-events: none; background: rgba(23,27,38,.92); color: #fff; padding: 6px 9px; border-radius: 7px; font-size: 11.5px; line-height: 1.45; box-shadow: var(--shadow-pop); white-space: nowrap; }
.dwg-tip span { color: #c7cbe0; }
.dwg-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; background: rgba(251,252,254,.72); color: var(--dim); font-weight: 600; }
.dwg-loading i { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--selb); border-top-color: var(--accent); animation: dwgSpin .8s linear infinite; }
@keyframes dwgSpin { to { transform: rotate(360deg); } }
.dwg-side { width: 360px; flex: none; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.dwg-quick { display: flex; gap: 6px; }
.dwg-quick button { flex: 1; }
.dwg-list { flex: 1 1 auto; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.dwg-row { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .1s; }
.dwg-row:hover { background: var(--panel-2); }
.dwg-row.on { background: #f6f6ff; }
.dwg-row.on:hover { background: var(--accent-soft); }
.dwg-row.active { box-shadow: inset 3px 0 0 #f59e0b; }
.dwg-row:not(.on) .dwg-pk, .dwg-row:not(.on) .dwg-meta { color: var(--gray); }
.dwg-pk { width: 84px; font-weight: 650; font-variant-numeric: tabular-nums; padding: 2px 6px; border-color: transparent; background: transparent; }
.dwg-pk:hover { border-color: var(--border); background: var(--panel); }
.dwg-meta { color: var(--dim); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dwg-badge { margin-left: auto; font-size: 10.5px; font-weight: 650; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }
.dwg-badge:empty { display: none; }
.dwg-badge.muted { color: var(--gray); background: var(--panel-2); }
.dwg-badge.warn { color: var(--warn); background: #fff4e0; }
.dwg-prev-head { display: flex; align-items: baseline; gap: 4px; padding: 2px 2px 0; }
.dwg-prev { width: 100%; height: 170px; flex: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.dwg-hint { color: var(--gray); font-size: 11.5px; }

.dwg-legend i.dot { width: 9px; height: 9px; border-radius: 50%; }
.dwg-field input.num::placeholder { color: #aab1c2; }
