:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-d: #1d4ed8;
  --ok: #16a34a;
  --bad: #dc2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "Noto Sans CJK",
    "Hiragino Sans", "Malgun Gothic", "Noto Sans", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
#app { display: flex; height: 100vh; }

/* Sidebar */
#sidebar {
  width: 248px; flex: 0 0 248px; background: var(--sidebar); color: #e2e8f0;
  display: flex; flex-direction: column; padding: 16px 12px; overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 6px 14px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.brand-text strong { font-size: 15px; color: #fff; }
.brand-text small { display: block; color: #94a3b8; font-size: 11px; }
#module-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
/* Dark-themed scrollbar for sidebar nav */
#module-nav::-webkit-scrollbar { width: 6px; }
#module-nav::-webkit-scrollbar-track { background: transparent; }
#module-nav::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
#module-nav::-webkit-scrollbar-thumb:hover { background: #475569; }
#module-nav { scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.nav-item {
  display: flex; align-items: center; gap: 9px; text-align: left; width: 100%;
  background: transparent; border: 0; color: #cbd5e1; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13px; transition: background .15s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: #94a3b8; }
/* Two-level categorized nav */
.nav-cat-head {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; border: 0; color: #e2e8f0; cursor: pointer;
  padding: 9px 8px 9px 2px; border-radius: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
}
.nav-cat-head:hover { background: var(--sidebar-2); }
.nav-caret { width: 12px; flex: 0 0 12px; text-align: center; color: #94a3b8; font-size: 10px; transition: transform .15s; }
.nav-cat-count { margin-left: auto; font-size: 10px; color: #64748b; background: rgba(255,255,255,.06); padding: 1px 7px; border-radius: 10px; }
.nav-sub { display: none; flex-direction: column; gap: 2px; margin: 1px 0 8px 5px; padding-left: 11px; border-left: 1px solid var(--sidebar-2); }
.nav-sub.open { display: flex; }
.nav-sub .nav-item { font-size: 12.5px; padding: 7px 10px 7px 12px; font-weight: 400; }
.nav-sub .nav-item.active { font-weight: 600; }
.dot-full { background: #22d3ee; }
.dot-ieee80 { background: #34d399; }
.dot-carson { background: #fbbf24; }
.dot-basic { background: #f472b6; }
.dot-circuit { background: #a78bfa; }
.sidebar-foot { margin-top: auto; }

/* Methodology modal */
#method-btn {
  margin-left: 10px; padding: 6px 12px; font-size: 12px; cursor: pointer;
  background: var(--sidebar-2); color: var(--txt); border: 1px solid var(--border); border-radius: 6px;
}
#method-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 14, 22, 0.55); display: flex;
  align-items: center; justify-content: center; z-index: 1000; padding: 24px;
}
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  width: min(880px, 96vw); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 15px; }
.modal-x { background: none; border: none; color: var(--txt); font-size: 22px; line-height: 1; cursor: pointer; }
.method-intro { font-size: 12.5px; color: var(--txt-2); margin: 0; padding: 12px 18px 0; }
.method-scroll { overflow: auto; padding: 8px 18px; }
.method-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.method-table th, .method-table td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
.method-table th { background: var(--sidebar-2); position: sticky; top: 0; }
.method-table .m-model { color: var(--txt-2); }
.method-table .m-ref { white-space: nowrap; color: var(--accent); }
.method-note { font-size: 11px; color: var(--txt-2); margin: 0; padding: 10px 18px 16px; border-top: 1px solid var(--border); }
.badge {
  font-size: 11px; color: #cbd5e1; background: var(--sidebar-2); border-radius: 6px; padding: 6px 8px;
}
.badge-ieee80 { color: #6ee7b7; }
.badge-carson { color: #fcd34d; }
.badge-full { color: #67e8f9; }
.badge-basic { color: #f9a8d4; }
.badge-circuit { color: #c4b5fd; }

/* Main */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  height: 56px; flex: 0 0 56px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
}
#module-title { font-size: 16px; font-weight: 700; }
#lang-switch { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbtn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  border: 1px solid var(--border); background: #f8fafc; color: var(--muted);
  border-radius: 6px; padding: 5px 11px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.topbtn:hover { border-color: var(--accent); color: var(--accent); }
.topbtn::before { font-size: 12px; line-height: 1; }
#btn-home::before { content: '🏠'; }
#btn-email::before { content: '✉'; }
.project-controls { display: flex; gap: 4px; flex-wrap: wrap; margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--border); }
.lang-btn {
  border: 1px solid var(--border); background: #f8fafc; color: var(--muted); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; font-size: 12px;
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
.lang-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

#module-body { flex: 1; overflow: auto; padding: 20px 22px; }
h2 { margin: 0 0 4px; font-size: 20px; }
.desc { color: var(--muted); margin: 0 0 16px; max-width: 760px; line-height: 1.5; }
h3 { margin: 18px 0 8px; font-size: 14px; color: #334155; }

.controls { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.fields { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 14px; }
.field-col { display: flex; flex-direction: column; gap: 10px; min-width: 220px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field-label { font-size: 12px; color: var(--muted); }
.field-unit { color: #94a3b8; font-style: normal; font-size: 11px; }
.field input, .field select, textarea.ta {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, textarea.ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.field-block { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; max-width: 560px; }
textarea.ta { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 12px; width: 100%; }

.btn-row { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.btn { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-d); color: #fff; }
.btn-mini { border: 1px solid var(--border); background: #fff; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; color: var(--bad); }

.module-out { margin-top: 14px; }
.results-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; max-width: 640px; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.result-table { width: 100%; border-collapse: collapse; }
.result-table td { padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.result-table tr:last-child td { border-bottom: 0; }
.rk { color: var(--muted); font-size: 13px; }
.rv { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.rv-u { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 3px; }
.rv.ok { color: var(--ok); }
.rv.bad { color: var(--bad); }

.verdict { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 8px; }
.verdict.ok { background: #dcfce7; color: var(--ok); }
.verdict.fail { background: #fee2e2; color: var(--bad); }

.data-table { border-collapse: collapse; margin-bottom: 8px; }
.data-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 4px 8px; border-bottom: 2px solid var(--border); }
.data-table td { padding: 3px 6px; }
.data-table input { width: 110px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; }

.chart { width: 100%; max-width: 620px; height: 280px; margin-top: 14px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.note { color: var(--muted); font-size: 12px; margin: 8px 0 0; max-width: 640px; line-height: 1.5; }
.warn { color: var(--bad); font-size: 13px; }

#app-footer { padding: 10px 22px; border-top: 1px solid var(--border); background: var(--panel); color: var(--muted); font-size: 11px; line-height: 1.5; }

/* Export buttons */
.export-row { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }

/* Visual grounding grid editor */
.grid-editor { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; max-width: 460px; margin-bottom: 14px; }
.grid-editor .ge-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.grid-editor .ge-head strong { font-size: 13px; color: #334155; }
.grid-svg { width: 100%; height: auto; background: #f8fafc; border-radius: 8px; touch-action: manipulation; }
.grid-svg line.conductor { stroke: #2563eb; stroke-width: 1.4; }
.grid-svg rect.area { fill: #eff6ff; stroke: #bfdbfe; stroke-width: 1; }
.grid-svg circle.rod { fill: #dc2626; stroke: #fff; stroke-width: 1.5; pointer-events: none; }
.grid-svg circle.rod.hot { fill: #f87171; }
.grid-svg .cell { fill: transparent; cursor: pointer; pointer-events: all; }
.grid-svg text.dim { fill: #94a3b8; font-size: 9px; }
.rod-count { font-size: 12px; color: var(--muted); }
.rod-count b { color: var(--text); }

/* Nodal solver contour (MALT-style earth surface potential / touch / step) */
.contour-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 14px; max-width: 780px; }
.contour-box h3 { font-size: 14px; margin: 0 0 8px; color: #334155; }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn.small.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.canvas-wrap { display: flex; align-items: stretch; gap: 12px; margin: 10px 0; }
.contour-canvas { width: 100%; max-width: 520px; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; image-rendering: auto; }
.legend { flex: 1; min-width: 90px; display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); }
.legend span:last-child { text-align: right; }
.nodal-out { margin-top: 6px; }

/* AutoGrid candidate table + recommended card */
.rec-card { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 12px 14px; margin: 12px 0; max-width: 560px; }
.rec-card h3 { margin: 0 0 8px; font-size: 14px; color: #166534; }
.ag-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.ag-table th, .ag-table td { border: 1px solid var(--border); padding: 4px 6px; text-align: center; }
.ag-table th { background: #f1f5f9; color: #334155; font-weight: 600; }
.ag-table tr.feas td { background: #f0fdf4; }
.ag-table tr.infeas td { background: #fef2f2; }
.ag-table td.ok { color: #15803d; }
.ag-table td.bad { color: #b91c1c; }
.scroll-x { max-width: 780px; overflow-x: auto; margin-top: 6px; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); margin: 4px 0; }

/* Generic result grids (corrpro network, tralin sequence, grdimpulse) */
.tbl, .results-table { border-collapse: collapse; width: 100%; max-width: 900px; font-size: 12px; margin: 6px 0 10px; }
.tbl th, .tbl td,
.results-table th, .results-table td { border: 1px solid var(--border); padding: 5px 8px; text-align: center; font-variant-numeric: tabular-nums; }
.tbl th, .results-table th { background: #f1f5f9; color: #334155; font-weight: 600; white-space: nowrap; }
.tbl tbody tr:nth-child(even) td,
.results-table tbody tr:nth-child(even) td { background: #fafbfc; }
.tbl td.ok, .results-table td.ok { color: var(--ok); font-weight: 600; }
.tbl td.warn, .results-table td.warn { color: #b45309; font-weight: 600; }
.tbl td.bad, .results-table td.bad { color: var(--bad); font-weight: 600; }

/* Repeatable inline row editors (rowpro tracks, corrpro pipes) */
.src-host { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 4px; max-width: 100%; overflow-x: auto; padding-bottom: 4px; }
.track-row { display: flex; align-items: center; gap: 6px; }
.track-row input { width: 76px; flex: 0 0 76px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; text-align: right; }
.track-row .track-idx { width: 36px; flex: 0 0 36px; font-size: 12px; font-weight: 600; color: var(--muted); }
.track-row.track-hdr { font-size: 11px; color: var(--muted); }
.track-row.track-hdr .th { width: 76px; flex: 0 0 76px; text-align: center; line-height: 1.2; }

/* SES-Vis 3-D view */
.vis3d-wrap { display: flex; gap: 12px; margin: 12px 0; align-items: stretch; }
.vis3d-canvas { width: 100%; max-width: 660px; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #0b1220; cursor: grab; touch-action: none; }
.vis3d-canvas:active { cursor: grabbing; }
.legend3d { flex: 1; min-width: 70px; display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--muted); text-align: center; }
.legend3d span:last-child { transform: rotate(0deg); }

/* New fidelity dots / badges */
.dot-image { background: #38bdf8; }
.badge-image { color: #7dd3fc; }
.dot-fd { background: #f59e0b; }
.badge-fd { color: #fcd34d; }

/* MALZ / FFTSES fidelity dots / badges */
.dot-malz { background: #8b5cf6; }
.badge-malz { color: #c4b5fd; }
.dot-fftses { background: #ec4899; }
.badge-fftses { color: #f9a8d4; }

/* Soil model status note (RESAP -> modules linkage) */
.soil-note { font-size: 12px; padding: 6px 10px; border-radius: 8px; margin: 6px 0 12px; }
.soil-note.ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.soil-note.warn { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

.chart-cap { font-size: 12px; color: var(--muted); margin: 10px 0 2px; }

/* Section heading inside a module form (groups related input fields) */
.sec-h {
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 18px 0 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--border); max-width: 760px;
}

/* P1 module fidelity badges */
.dot-condimp { background: #14b8a6; }
.badge-condimp { color: #5eead4; }
.dot-vertsoil { background: #a855f7; }
.badge-vertsoil { color: #c4b5fd; }
.dot-f05 { background: #f59e0b; }
.badge-f05 { color: #fcd34d; }
.dot-tralin { background: #0ea5e9; }
.badge-tralin { color: #7dd3fc; }
.dot-rowpro { background: #f97316; }
.badge-rowpro { color: #fdba74; }
.dot-sysview { background: #14b8a6; }
.badge-sysview { color: #5eead4; }

/* P2 module fidelity badges */
.dot-seshield2d { background: #6366f1; }
.badge-seshield2d { color: #a5b4fc; }
.dot-accorrosion { background: #eab308; }
.badge-accorrosion { color: #fde047; }
.dot-enviro { background: #10b981; }
.badge-enviro { color: #6ee7b7; }
.dot-ampacity { background: #f43f5e; }
.badge-ampacity { color: #fda4af; }

/* mitigation list (AC corrosion) */
.mitig { margin: 6px 0 0 18px; padding: 0; }
.mitig li { font-size: 13px; color: #334155; margin: 2px 0; }

/* Geometry / system diagrams (TRALIN, Right-of-Way Pro, 3-D viewer) */
.sys-view { max-width: 600px; margin: 10px 0 6px; }
.sys-svg { width: 100%; height: auto; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; }
.sys-svg .ground-line { stroke: #475569; stroke-width: 1.5; }
.sys-svg .dim { fill: #94a3b8; font-size: 11px; }
.sys-svg .cond { fill: #2563eb; }
.sys-svg .cond.gnd { fill: #16a34a; }
.sys-svg .cond-label { fill: #1e293b; font-size: 11px; font-weight: 600; }
.sys-svg .drop { stroke: #16a34a; stroke-width: 1; stroke-dasharray: 2 2; }
.sys-svg .tower { stroke: #334155; stroke-width: 2; }
.sys-svg .pipe { stroke: #b45309; stroke-width: 3; }
.sys-svg .sep-line { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 4 3; }
.sys-svg .grid { stroke: #e2e8f0; stroke-width: 1; }
.sys-svg .seg { stroke: #64748b; stroke-width: 2; }
.sys-svg .seg.live { stroke: #dc2626; }
.sys-svg .seg.pipe { stroke: #b45309; stroke-width: 3; }
.sys-svg .node { fill: #64748b; }
.sys-svg .node.live { fill: #dc2626; }
.sys-svg .node.pipe { fill: #b45309; }

/* result & source tables */
.matrix td, .matrix th { text-align: right; }
.matrix .reim { display: block; font-size: 10px; color: var(--muted); }
.src-table input[type="text"] { width: 78px; }
.src-table input[type="number"] { width: 70px; }

/* field colour map (3-D viewer) */
.field-map { width: 100%; max-width: 600px; height: auto; border: 1px solid var(--border); border-radius: 8px; }
.colorbar { border: 1px solid var(--border); border-radius: 4px; vertical-align: middle; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.bar-label { font-size: 11px; color: var(--muted); }
.readout { font-size: 12px; color: #334155; margin: 8px 0; padding: 6px 10px; background: #f1f5f9; border-radius: 6px; }

/* SESCAD geometry modeler */
.dot-sescad { background: #0ea5e9; }
.badge-sescad { color: #7dd3fc; }

/* SESBatch / SHORT */
.dot-sesbatch { background: #f59e0b; }
.badge-sesbatch { color: #fcd34d; }
.dot-short { background: #8b5cf6; }
.badge-short { color: #c4b5fd; }
.dot-grsplits3d { background: #14b8a6; }
.badge-grsplits3d { color: #5eead4; }
.dot-sesplot { background: #f43f5e; }
.badge-sesplot { color: #fda4af; }
.dot-multiground { background: #6366f1; }
.badge-multiground { color: #a5b4fc; }
.dot-autogrid { background: #84cc16; }
.badge-autogrid { color: #bef264; }
.dot-sesvis { background: #d946ef; }
.badge-sesvis { color: #f0abfc; }
.dist-chart { width: 100%; max-width: 480px; height: auto; margin: 6px 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.plot-canvas { width: 100%; max-width: 560px; height: 300px; background: #fff; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; }
.sescad { margin-top: 8px; }
.sescad-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.sescad-tools .tool-btn { padding: 6px 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; font-size: 12px; cursor: pointer; }
.sescad-tools .tool-btn.active { background: #0ea5e9; border-color: #0ea5e9; color: #fff; font-weight: 600; }
.sescad-tools .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.sescad-tools .zoom { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sescad-main { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.sescad-canvas { flex: 1 1 460px; min-width: 320px; }
.sescad-svg { width: 100%; height: auto; aspect-ratio: 600 / 450; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; cursor: crosshair; touch-action: none; }
.sescad-svg .sc-grid { stroke: #e2e8f0; stroke-width: 1; }
.sescad-svg .sc-axis { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 4 4; }
.sescad-svg .sc-mesh { stroke: #bfdbfe; stroke-width: 1; }
.sescad-svg text { font-family: system-ui, sans-serif; }
.sescad-status { font-size: 11px; color: var(--muted); margin-top: 4px; padding: 2px 6px; }
.sescad-side { flex: 1 1 240px; min-width: 220px; max-width: 320px; }
.sescad-side h3 { margin: 4px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sescad-list { border: 1px solid var(--border); border-radius: 8px; padding: 6px; margin-bottom: 12px; max-height: 220px; overflow: auto; }
.sescad-list .note { color: var(--muted); font-size: 12px; }
.sescad-list .li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.sescad-list .li:hover { background: #f1f5f9; }
.sescad-list .li.sel { background: #e0f2fe; }
.sescad-list .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.sescad-list .li-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sescad-list .li-del { border: none; background: transparent; color: #cbd5e1; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.sescad-list .li-del:hover { color: #ef4444; }
.sescad-props { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.sescad-props h3 { margin: 0 0 8px; font-size: 14px; }
.sescad-props .text-in { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.sescad-props .note { font-size: 12px; color: var(--muted); margin: 8px 0; }

/* SESKML — geographic export */
.dot-seskml { background: #16a34a; }
.badge-seskml { color: #4ade80; }
.json-in {
  width: 100%; box-sizing: border-box; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.5; resize: vertical;
}
.kml-preview {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; margin-top: 10px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; line-height: 1.5; color: #334155; white-space: pre-wrap; word-break: break-all;
}

/* SESLibrary — reference tables */
.dot-seslib { background: #d97706; }
.badge-seslib { color: #fbbf24; }
.lib-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.lib-tab {
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--muted); font-size: 12px; cursor: pointer;
}
.lib-tab:hover { background: #f1f5f9; }
.lib-tab.active { background: #0f172a; border-color: #0f172a; color: #fff; }
.lib-search {
  width: 100%; max-width: 340px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.lib-table-wrap { overflow-x: auto; }
.lib-table { width: 100%; font-size: 12px; }
.lib-table td { border-bottom: 1px solid var(--border); white-space: nowrap; }
.lib-table tr:hover td { background: #f8fafc; }

/* SESCurveFit — curve fitting */
.dot-curvefit { background: #0891b2; }
.badge-curvefit { color: #22d3ee; }
.eq-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0; padding: 10px 12px;
  background: #ecfeff; border: 1px solid #a5f3fc; border-radius: 8px;
}
.eq-label { font-size: 12px; font-weight: 600; color: #0e7490; }
.eq-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; color: #0f172a; word-break: break-all;
}
.lib-table tr.row-best td { background: #ecfeff; font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
p.warn { color: #b45309; font-size: 13px; }

/* ---- Engineering report (计算书) modal + print ---- */
.btn-report { margin: 14px 0 4px; background: #1e3a5f; color: #e2e8f0; border: 1px solid #2b5278; border-radius: 6px; padding: 8px 14px; cursor: pointer; font-size: 13px; }
.btn-report:hover { background: #254b78; }
.report-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.78); z-index: 1000; display: flex; flex-direction: column; align-items: center; padding: 24px; overflow: auto; }
.report-paper { background: #fff; color: #0f172a; width: 794px; max-width: 96vw; padding: 36px 44px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); border-radius: 4px; }
.report-paper h1 { font-size: 22px; margin: 0 0 4px; border-bottom: 2px solid #1e3a5f; padding-bottom: 8px; }
.report-paper h3 { font-size: 15px; margin: 18px 0 6px; color: #1e3a5f; }
.report-meta { font-size: 12px; color: #64748b; margin: 0 0 8px; }
.report-tbl { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.report-tbl td { border: 1px solid #cbd5e1; padding: 5px 10px; font-size: 13px; }
.report-tbl td.k { width: 55%; color: #334155; }
.report-tbl td.v { font-weight: 600; }
.report-note { font-size: 12px; color: #64748b; }
.report-foot { margin-top: 20px; font-size: 11px; color: #94a3b8; border-top: 1px solid #e2e8f0; padding-top: 8px; }
.report-bar { margin-top: 16px; display: flex; gap: 10px; }
.btn-secondary { background: #475569; color: #e2e8f0; border: none; border-radius: 6px; padding: 8px 16px; cursor: pointer; }
@media print {
  body > *:not(.report-overlay) { display: none !important; }
  .report-overlay { position: static; background: #fff; padding: 0; }
  .report-paper { box-shadow: none; width: auto; max-width: 100%; }
  .report-bar { display: none !important; }
}

/* ---- SESShield-3D (LPM) fidelity dot + true-3D viewer ---- */
.dot-lpm { background: #f43f5e; }
.badge-lpm { color: #fda4af; }
.chart3d { width: 100%; max-width: 760px; height: 440px; background: #0b1220; border-radius: 8px; display: block; margin: 6px 0; cursor: grab; touch-action: none; }
.chart3d:active { cursor: grabbing; }
.legend3d { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: #cbd5e1; margin: 4px 0 10px; }
.legend3d .lg-shield::before, .legend3d .lg-phase::before, .legend3d .lg-fail::before {
  content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px;
}
.legend3d .lg-shield::before { background: #38bdf8; }
.legend3d .lg-phase::before { background: #facc15; }
.legend3d .lg-fail::before { background: #ef4444; }

/* ---- SES-Vis 3D generic geometry viewer ---- */
.sesvis3d-layout { display: flex; gap: 16px; flex-wrap: wrap; }
.sesvis3d-left { flex: 1 1 520px; min-width: 320px; }
.sesvis3d-right { flex: 0 0 240px; max-width: 280px; }
.sesvis3d-canvas { width: 100%; height: 480px; background: #0b1220; border-radius: 8px; display: block; cursor: grab; touch-action: none; }
.sesvis3d-canvas:active { cursor: grabbing; }
.sesvis3d-hint { color: #94a3b8; font-size: 12px; margin-top: 6px; }
.sesvis3d-legend, .sesvis3d-list { background: #0f172a; border: 1px solid #1e293b; border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.sesvis3d-legend-title { font-weight: 600; margin-bottom: 8px; color: #e2e8f0; }
.sesvis3d-legend-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: #cbd5e1; font-size: 13px; }
.sesvis3d-sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.sesvis3d-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; color: #cbd5e1; font-size: 13px; }
.sesvis3d-item:hover { background: #1e293b; }
.sesvis3d-item.sel { background: #1d4ed8; color: #fff; }
.sesvis3d-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.sesvis3d-empty { color: #94a3b8; padding: 18px 0; }
