:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #667085;
  --line: #d6dce6;
  --line2: #eceff4;
  --accent: #1d5fa6;
  --accent-weak: #e7eef8;
  --g: #4a5e80;
  --q: #c2661c;
  --pos: #1d5fa6;
  --pos-fill: rgba(29, 95, 166, .16);
  --neg: #c0392b;
  --neg-fill: rgba(192, 57, 43, .15);
  --tens: #c8362c;
  --comp: #2864af;
  --warn-bg: #fff5dc;
  --warn: #7d5300;
  --err-bg: #fde8e6;
  --err: #a3271b;
  --info-bg: #eef3f9;
  --ok: #1e7b45;
  --bad: #b3261e;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 13px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select { font: inherit; color: inherit; }
sub { font-size: .75em; line-height: 0; }

/* ---------- top bar ---------- */
.topbar {
  height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; background: #16223a; color: #fff; position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .02em; white-space: nowrap; }
.brand .logo { display: inline-block; width: 24px; color: #8fb6ec; }
.brand small { font-weight: 400; opacity: .65; margin-left: 10px; font-size: 12px; }
.tb-actions { display: flex; gap: 8px; }
.tb-actions button, .tb-actions select {
  background: #24324d; color: #fff; border: 1px solid #3a4b6c; border-radius: 6px; padding: 5px 11px; cursor: pointer;
}
.tb-actions button:hover, .tb-actions select:hover { background: #2e3f60; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 372px minmax(0, 1fr) 400px; height: calc(100vh - 50px); }
.inputs, .results, .sectionpanel { overflow: auto; min-height: 0; }
.inputs { background: var(--panel); border-right: 1px solid var(--line); }
.results { padding: 14px 16px 24px; }
.sectionpanel { background: var(--panel); border-left: 1px solid var(--line); padding: 12px 16px 20px; }

@media (max-width: 1420px) {
  .layout { grid-template-columns: 356px minmax(0, 1fr); height: auto; }
  .inputs { position: sticky; top: 50px; height: calc(100vh - 50px); align-self: start; }
  .results { overflow: visible; }
  .sectionpanel { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .inputs { position: static; height: auto; border-right: 0; }
  .sectionpanel { grid-column: 1; }
  .brand small { display: none; }
  .tb-actions { gap: 4px; }
  .tb-actions button { padding: 5px 7px; }
}

/* ---------- input panels ---------- */
details.panel { border-bottom: 1px solid var(--line); }
details.panel > summary {
  list-style: none; cursor: pointer; padding: 10px 16px; font-weight: 650; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em; color: #33405a; background: #f6f8fb; user-select: none;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: '▸'; display: inline-block; width: 14px; color: var(--muted); }
details.panel[open] > summary::before { content: '▾'; }
.pbody { padding: 10px 16px 14px; display: flex; flex-direction: column; gap: 7px; }

.field { display: grid; grid-template-columns: minmax(0, 1fr) 148px; align-items: center; gap: 8px; margin: 0; }
.field.wide { grid-template-columns: minmax(0, 1fr); }
.field .lbl { color: var(--muted); }
.field.wide .lbl { margin-bottom: -3px; }
.inp { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 5px; background: #fff; min-width: 0; }
.inp:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.inp input { border: 0; padding: 5px 7px; width: 100%; text-align: right; background: transparent; min-width: 0; outline: none; }
.inp input.txt { text-align: left; }
.inp .unit { padding: 0 8px 0 2px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.inp input.bad { background: var(--err-bg); }
.inp input:disabled { color: #9aa3b2; }
select { padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; width: 100%; min-width: 0; }
select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: #fff; padding: 6px 8px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.seg.small button { padding: 3px 8px; font-size: 12px; }

.row { display: flex; align-items: center; gap: 6px; }
.row > .field { flex: 1; }
.iconbtn {
  border: 1px solid var(--line); background: #fff; border-radius: 5px; width: 28px; height: 28px; cursor: pointer;
  color: var(--muted); flex: none; line-height: 1;
}
.iconbtn:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); }
.iconbtn:disabled { opacity: .35; cursor: default; }
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; color: var(--accent);
}
.btn:hover { background: var(--accent-weak); border-color: #b8cbe3; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0; }
.subhead { font-weight: 600; color: #33405a; margin-top: 6px; }
.total { display: flex; justify-content: space-between; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }
.total b { color: var(--ink); }

.suprow { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; align-items: center; }
.supname b { font-size: 14px; }
.supname small { display: block; color: var(--muted); }
.dofgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; margin: -2px 0 4px 100px; }
.dofgrid label { display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); cursor: pointer; }

.props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 14px; background: #f8fafc; border: 1px solid var(--line2); border-radius: 6px; padding: 7px 10px; }
.props div { display: flex; justify-content: space-between; gap: 6px; }
.props span { color: var(--muted); }
.props .err { grid-column: 1 / -1; color: var(--err); }

.loadcard { border: 1px solid var(--line); border-left: 4px solid var(--g); border-radius: 6px; padding: 7px 9px; display: flex; flex-direction: column; gap: 6px; background: #fcfdfe; }
.loadcard.cat-q { border-left-color: var(--q); }
.loadcard.off { opacity: .55; }
.loadhead { display: flex; align-items: center; gap: 6px; }
.loadhead .ltype { font-weight: 650; font-size: 12px; white-space: nowrap; }
.loadhead .inp { flex: 1; }
.loadhead .inp input { text-align: left; padding: 3px 6px; }
.loadhead input[type=checkbox] { margin: 0 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.two .field { grid-template-columns: 30px minmax(0, 1fr); }
.checks2 { display: flex; gap: 14px; }

/* ---------- result cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.card h2 { font-size: 14px; margin: 0 0 8px; color: #22304a; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.legend { color: var(--muted); font-size: 12px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
.sw.cat-g { background: var(--g); } .sw.cat-q { background: var(--q); }
.badge { background: var(--accent-weak); color: var(--accent); border-radius: 12px; padding: 2px 10px; font-size: 12px; font-weight: 600; }

.msg { border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; border: 1px solid transparent; }
.msg.err { background: var(--err-bg); color: var(--err); border-color: #f1c1bb; font-weight: 600; }
.msg.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dca8; }
.msg.info { background: var(--info-bg); color: #3c4b66; border-color: #d6e1ef; }

.views { display: flex; flex-direction: column; gap: 4px; }
.view-h { font-size: 12px; color: var(--muted); font-weight: 600; margin: 2px 0 -2px; }
svg { display: block; max-width: 100%; height: auto; }
svg text { font-family: "Segoe UI", system-ui, Arial, sans-serif; }
#diagrams.colmode, .views.colmode { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 6px 10px; }
#diagrams.colmode .diag { width: 200px; }
#diagrams.colmode .sysplane { width: auto; }
.diag { border-top: 1px solid var(--line2); padding-top: 6px; margin-top: 4px; }
#diagrams.colmode .diag { border-top: 0; }
.diag-h { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.diag-h b { font-size: 13px; }
.diag-h .unit { color: var(--muted); font-weight: 400; }
.diag-h .ext { color: var(--muted); font-size: 12px; }
#diagrams.colmode .diag-h { flex-direction: column; gap: 0; min-height: 52px; }
.dsvg, .sys { touch-action: none; cursor: crosshair; user-select: none; }

/* SVG styles */
.member { stroke: #1c2330; stroke-width: 3.2; stroke-linecap: round; }
.base { stroke: #1c2330; stroke-width: 1.2; }
.suptick { stroke: #1c2330; stroke-width: 1; }
.f-pos { fill: var(--pos-fill); stroke: none; }
.f-neg { fill: var(--neg-fill); stroke: none; }
.f-ten { fill: rgba(200, 54, 44, .14); stroke: none; }
.f-com { fill: rgba(40, 100, 175, .14); stroke: none; }
.l-main { fill: none; stroke: #2a3550; stroke-width: 1.4; }
.l-ten { fill: none; stroke: var(--tens); stroke-width: 1.4; }
.l-com { fill: none; stroke: var(--comp); stroke-width: 1.4; }
.l-dash { stroke-dasharray: 5 3; }
.patbox { background: #fff7f0; border: 1px solid #f3d5bd; border-radius: 6px; padding: 7px 9px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 5px; }
.patbox .field { grid-template-columns: 90px minmax(0, 1fr); }
.patfields { font-size: 12px; }
.limit { stroke: var(--bad); stroke-width: 1; stroke-dasharray: 5 3; }
.limtxt { fill: var(--bad); font-size: 11px; }
.dot { fill: #2a3550; }
.vlab { font-size: 11px; fill: #1c2330; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.cursor line { stroke: #e0752d; stroke-width: 1.2; stroke-dasharray: 4 3; }
.cursor .cdot { fill: #e0752d; }
.cursor .cbg { fill: #fff3ea; stroke: #e0752d; stroke-width: .8; }
.cursor .ctxt { font-size: 11px; font-weight: 600; fill: #9a4510; }

.ld { color: var(--g); }
.ld.cat-q { color: var(--q); }
.ld line, .ld path { stroke: currentColor; stroke-width: 1.3; fill: none; }
.ld .head { fill: currentColor; stroke: none; }
.ld .ldarea { fill: currentColor; fill-opacity: .1; stroke: currentColor; stroke-width: 1; }
.ld text { fill: currentColor; font-size: 11px; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.support .tri { fill: #fff; stroke: #1c2330; stroke-width: 1.3; }
.support .hinge { fill: #fff; stroke: #1c2330; stroke-width: 1.3; }
.support .gnd { stroke: #1c2330; stroke-width: 1.6; }
.support .hatch { stroke: #1c2330; stroke-width: .8; }
.support .part { fill: #fff; stroke: #1c2330; stroke-width: 1.2; }
.supname-t { font-size: 12px; font-weight: 700; fill: #1c2330; }
.dim line { stroke: #66708a; stroke-width: .9; }
.dim text { fill: #44506a; font-size: 11px; }
.triad line { stroke: #8792a8; stroke-width: 1; }
.triad .head { fill: #8792a8; }
.triad text { fill: #66708a; font-size: 11px; font-style: italic; }

/* tables */
table.tbl { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 4px 8px; border-bottom: 1px solid var(--line2); text-align: right; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; background: #f8fafc; }
.tbl th:first-child, .tbl td:first-child, .tbl td.l, .tbl th.l { text-align: left; }
.tbl tr.sum td { border-top: 1.5px solid var(--line); font-weight: 600; }
.tblwrap { overflow-x: auto; }
.ok { color: var(--ok); font-weight: 600; }
.nok { color: var(--bad); font-weight: 600; }
.checks-grid { display: grid; gap: 14px; }
.checks-grid h3 { font-size: 13px; margin: 0 0 4px; color: #33405a; }

.assumptions { color: var(--muted); font-size: 11.5px; padding: 4px 4px 0; }

/* ---------- section panel ---------- */
.sectionpanel h2 { font-size: 14px; margin: 0 0 8px; color: #22304a; }
.cutctl { display: flex; align-items: center; gap: 10px; }
.cutctl label { display: flex; align-items: center; gap: 4px; white-space: nowrap; font-weight: 600; }
.cutctl .inp { width: 92px; }
.cutctl input[type=range] { flex: 1; accent-color: #e0752d; min-width: 0; }
.jumps { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.jumps button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 2px 9px; font-size: 12px; cursor: pointer; color: #3c4b66; }
.jumps button:hover { border-color: #e0752d; color: #9a4510; }
.jumps span { color: var(--muted); font-size: 12px; align-self: center; margin-right: 2px; }
.secsvg { margin: 4px auto 0; cursor: crosshair; }
.secshape { stroke: #1c2330; stroke-width: 1.3; }
.secshape.plain { fill: #e9edf3; }
.secaxis { stroke: #8792a8; stroke-width: .9; stroke-dasharray: 5 3; }
.secaxis-t { fill: #66708a; font-size: 11px; font-style: italic; }
.nline { stroke: #1c2330; stroke-width: 1.5; stroke-dasharray: 7 3 2 3; }
.nline-t { font-size: 11px; fill: #1c2330; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.sprof { stroke: #1c2330; stroke-width: 1; }
.sprof-base { stroke: #1c2330; stroke-width: 1.2; }
.sprof-t { font-size: 11px; fill: #1c2330; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; }
.sprof-h { font-size: 10.5px; fill: var(--muted); }
.tauline { fill: rgba(120, 80, 170, .18); stroke: #6a46a0; stroke-width: 1.2; }
.mark { stroke: #1c2330; stroke-width: 1.2; }
.cbar { height: 10px; border-radius: 3px; background: linear-gradient(90deg, rgb(40,100,175), rgb(247,247,247), rgb(200,54,44)); margin: 4px 0 2px; }
.cbar-l { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.readout { min-height: 18px; font-size: 12px; color: #3c4b66; text-align: center; font-variant-numeric: tabular-nums; }
.sectionpanel .tbl { margin-top: 8px; }
.sectionpanel .tbl td.v { font-weight: 600; }
.lr { color: var(--muted); font-weight: 400; font-size: 11px; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }

/* ---------- print ---------- */
.print-only, .print-head { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .inputs, .hint, .jumps, .cutctl input[type=range], .readout { display: none !important; }
  .layout { display: block; height: auto; }
  .results, .sectionpanel { overflow: visible; padding: 0; border: 0; }
  .card { border: 0; padding: 0; margin: 0 0 10px; break-inside: avoid; }
  .diag { break-inside: avoid; }
  .print-only, .print-head { display: block; }
  .print-head h1 { font-size: 16px; margin: 0 0 2px; }
  .print-head p { margin: 0 0 10px; color: var(--muted); }
  .sectionpanel { break-before: page; }
  .dsvg, .sys { cursor: default; }
}
