* { box-sizing: border-box; }
body { font-family: Segoe UI, system-ui, sans-serif; margin: 0; background: #eef1f5; color: #222; }
header { background: #1f3a5f; color: #fff; padding: 12px 20px; }
header h1 { margin: 0; font-size: 20px; font-weight: 600; }
header h1 span { color: #7fb0e6; font-weight: 400; }
header .sub { color: #c6d3e4; font-size: 12px; }

nav#tabs { background: #2b4a72; display: flex; gap: 2px; padding: 0 12px; }
nav#tabs button { background: transparent; border: none; color: #cdd9e8; padding: 10px 16px; cursor: pointer; font-size: 14px; border-bottom: 3px solid transparent; }
nav#tabs button:hover { color: #fff; }
nav#tabs button.active { color: #fff; border-bottom-color: #7fb0e6; font-weight: 600; }

main { max-width: 1040px; margin: 16px auto; padding: 0 12px; }
.tab { display: none; }
.tab.active { display: block; }

.card { background: #fff; border: 1px solid #dde3ea; border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; font-size: 15px; color: #1f3a5f; }
button { font-size: 14px; padding: 8px 14px; margin: 3px 4px 3px 0; border: 1px solid #2c5d99; background: #3b78c3; color: #fff; border-radius: 5px; cursor: pointer; }
button:hover { background: #336bb0; }
button.sec { background: #fff; color: #2c5d99; }
button.sec:hover { background: #eef4fb; }
button:disabled { background: #9bb4d0; border-color: #9bb4d0; color: #fff; cursor: default; }

.status { margin-top: 10px; font-weight: 600; color: #1f3a5f; }
.muted { color: #667; font-size: 12px; }
.hint { color: #1f7a4d; font-size: 13px; font-weight: 600; margin: 4px 0; }
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.filterbar label { color: #445; font-size: 13px; }
.filterbar select { padding: 5px 8px; border: 1px solid #c3ccd6; border-radius: 4px; font-size: 13px; min-width: 160px; }
.warn { background: #fff6e5; border: 1px solid #e3c97a; padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }

table.kv td { padding: 2px 14px 2px 0; }
table.kv td:first-child { color: #667; }

.form { display: grid; grid-template-columns: 140px 1fr; gap: 8px 10px; align-items: center; max-width: 480px; margin-bottom: 10px; }
.form label { color: #445; font-size: 13px; }
.form input, .form select { padding: 6px 8px; border: 1px solid #c3ccd6; border-radius: 4px; font-size: 14px; }

.progress { height: 10px; background: #e3e9ef; border-radius: 5px; margin-top: 10px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: #3b78c3; transition: width .2s; }

table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th, table.grid td { border: 1px solid #e1e6ec; padding: 5px 8px; text-align: left; }
table.grid th { background: #f3f6f9; }
.tablewrap { max-height: 460px; overflow: auto; margin-top: 8px; }
.cellinput { width: 100%; min-width: 90px; border: 1px solid transparent; background: transparent; padding: 3px 4px; font: inherit; border-radius: 3px; }
.cellinput:hover { border-color: #d4dbe3; }
.cellinput:focus { border-color: #3b78c3; background: #fff; outline: none; }

.charttools { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.charttools label { color: #445; font-size: 13px; }
.unitsel { padding: 5px 8px; border: 1px solid #c3ccd6; border-radius: 4px; font-size: 13px; }
#cursorInfo { margin-left: 8px; font-family: Consolas, monospace; }
canvas { width: 100%; height: 430px; background: #fff; border: 1px solid #e1e6ec; border-radius: 6px; cursor: crosshair; }

/* virtualized value list (sticky header + padding rows) */
.vscroll { height: 460px; overflow-y: auto; margin-top: 8px; border: 1px solid #e1e6ec; border-radius: 6px; }
.vscroll table.grid th { position: sticky; top: 0; z-index: 1; }
.vscroll table.grid td { height: 24px; }
.legend { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.legend span { cursor: pointer; }
.legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

pre.log { background: #0f1b2a; color: #cfe3ff; padding: 10px; border-radius: 6px; overflow: auto; white-space: pre-wrap; }
pre.log.small { max-height: 130px; font-size: 12px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; }
.modal-box { background: #fff; border-radius: 8px; padding: 18px; width: 540px; max-width: 92vw; }
.modal-box h3 { margin: 0 0 12px; }
.recordlist { max-height: 320px; overflow: auto; border: 1px solid #e1e6ec; border-radius: 6px; }
.recordlist .row { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #eef1f5; font-family: Consolas, monospace; font-size: 13px; }
.recordlist .row:hover { background: #f1f6fc; }
.recordlist .row.sel { background: #d9e8fb; }
.modal-actions { text-align: right; margin-top: 12px; }
