/* Earthwork volumes and mass haul — on top of calc.css */
main.ew .tabs { grid-template-columns: repeat(3, 1fr); }
main.ew .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.ew .stage-bar .hist { margin-left: auto; }
#view, #xs { display: block; width: 100%; height: auto; user-select: none; touch-action: none; }
.hit { fill: transparent; stroke: none; }
.handle { cursor: grab; }
.handle.hy { cursor: ns-resize; }
.handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
.handle.pvi .knob { stroke: var(--moment); stroke-width: 2; }
.handle:hover .knob, .handle:focus .knob { fill: var(--sel); }

/* long section and mass diagram */
.ew-frame { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; }
.ew-grid { fill: var(--fill-1); }
.ew-t { font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.ew-t[data-pick] { cursor: pointer; }
.ew-tsel { fill: var(--sel); font-weight: 600; }
.ew-a { font-size: 11.5px; fill: var(--text-3); }
.ew-tick { stroke: var(--line-2); stroke-width: 1; }
.ew-cutA { fill: var(--x-ead7b8, #ead7b8); stroke: none; }
.ew-fillA { fill: var(--x-d3e0ec, #d3e0ec); stroke: none; }
.ew-ground { fill: none; stroke: var(--x-5b4a33, #5b4a33); stroke-width: 1.6; stroke-linejoin: round; }
.ew-grade { fill: none; stroke: var(--moment); stroke-width: 1.8; stroke-linejoin: round; }
.ew-selln { stroke: var(--sel); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.ew-gp { fill: var(--surface); stroke: var(--x-5b4a33, #5b4a33); stroke-width: 1.2; }
.ew-mass { fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linejoin: round; }
.ew-base { stroke: var(--steel-550); stroke-width: .9; }
.ew-bal { stroke: var(--sel); stroke-width: 1.3; stroke-dasharray: 6 4; }
.ew-bp { fill: var(--surface); stroke: var(--sel); stroke-width: 1.5; }
.ew-bpt { font-size: 11px; font-weight: 600; fill: var(--sel); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.ew-loopU { fill: color-mix(in srgb, var(--x-b8864a, #b8864a) 16%, transparent); stroke: none; }
.ew-loopD { fill: color-mix(in srgb, var(--x-4f7fae, #4f7fae) 16%, transparent); stroke: none; }
.ew-loopO { fill: color-mix(in srgb, var(--steel-550) 14%, transparent); stroke: none; }
.ew-fh { stroke: var(--x-8a5a0e, #8a5a0e); stroke-width: 1.6; }
.ew-key { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); }
.ew-key i { display: inline-block; width: 12px; height: 9px; margin-left: 6px; }
.ew-key i:first-child { margin-left: 0; }
.ew-key i.c { background: var(--x-ead7b8, #ead7b8); } .ew-key i.f { background: var(--x-d3e0ec, #d3e0ec); } .ew-key i.g { height: 0; width: 18px; border-top: 2px solid var(--moment); }
.ew-name { font-size: 12.5px; font-weight: 600; fill: var(--text); }
.ew-role { font-size: 11px; fill: var(--text-3); }
.ew-nm { cursor: text; }
.ew-nm:hover .ew-name, .ew-nm:focus .ew-name { fill: var(--sel); }
.ew-nm:focus { outline: none; }

/* cross-section */
.ew-soil { fill: var(--soil-2); stroke: none; }
.ew-cutX { fill: var(--x-e2c79c, #e2c79c); stroke: none; }
.ew-fillX { fill: var(--x-bdd2e6, #bdd2e6); stroke: none; }
.ew-tpl { fill: none; stroke: var(--text); stroke-width: 1.6; stroke-linejoin: round; }
.ew-cl { stroke: var(--steel-550); stroke-width: .8; stroke-dasharray: 9 3 1.5 3; }
.ew-dim { fill: none; stroke: var(--steel-550); stroke-width: .9; }
.ew-nav { display: inline-flex; gap: 4px; margin-left: auto; }
.ew-nav button { width: 28px; height: 26px; padding: 0; font-size: 16px; }

/* pills */
svg .pill rect { fill: var(--surface); stroke: var(--steel-300); }
svg .pill text { font-size: 11.5px; font-weight: 500; fill: var(--text-2); font-variant-numeric: tabular-nums; }
svg .pill.gl text, svg .pill.fh text, svg .pill.bal text { fill: var(--text); font-weight: 600; }
svg .pill.gr text { fill: var(--x-2d4a8c, #2d4a8c); }
svg .pill.lu rect, svg .pill.cut rect { stroke: color-mix(in srgb, var(--x-b8864a, #b8864a) 60%, transparent); } svg .pill.lu text, svg .pill.cut text { fill: var(--x-7a5320, #7a5320); font-weight: 600; }
svg .pill.ld rect, svg .pill.fill rect { stroke: color-mix(in srgb, var(--x-4f7fae, #4f7fae) 60%, transparent); } svg .pill.ld text, svg .pill.fill text { fill: var(--blue-3); font-weight: 600; }
svg .pill.wb rect { stroke: rgba(23, 24, 26, .35); } svg .pill.wb text { fill: var(--text); font-weight: 600; }
svg .pill.bal rect { stroke: color-mix(in srgb, var(--sel) 50%, transparent); }
svg .pill.editable { cursor: text; }
svg .pill.editable:hover rect, svg .pill.editable:focus rect { stroke: var(--sel); stroke-width: 1.4; }
svg .pill.editable:focus { outline: none; }

/* editors in the drawings */
.stage { position: relative; }
.ew-edit { position: absolute; transform: translate(-50%, -50%); z-index: 5; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1.5px solid var(--sel); border-radius: 9px; padding: 2px 8px 2px 4px; box-shadow: 0 6px 18px rgba(20, 22, 28, .14); }
.ew-edit input { width: 90px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; background: transparent; color: var(--text); }
.ew-edit-name input { width: 200px; text-align: center; }
.ew-edit span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* live strip and flags */
.ew-live { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-height: 38px; align-items: center; }
.ew-live b { font-weight: 500; color: var(--text-3); margin-right: 5px; }
.ew-flags { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ew-flags span { display: inline-flex; align-items: center; line-height: 1; font-size: 11.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.ew-flags span.ew-err { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 35%, transparent); white-space: normal; }

/* panel */
.ew-seg { margin-bottom: 6px; }
.ew-head, .ew-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) 26px; gap: 5px; align-items: center; }
.ew-prow { grid-template-columns: 58px minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) 26px; }
.ew-head { font-size: 11px; color: var(--text-3); margin: 4px 0 3px; line-height: 1.25; }
.ew-row { margin-bottom: 3px; border-radius: 6px; }
.ew-row.on { background: var(--x-eef3fe, #eef3fe); }
.ew-row .num input { width: 100%; }
.ew-pick { border: 0; background: none; font: inherit; font-size: 12px; color: var(--text-2); text-align: left; padding: 4px 2px; cursor: pointer; font-variant-numeric: tabular-nums; }
.ew-pick:hover { color: var(--sel); }
.ew-row.on .ew-pick { color: var(--sel); font-weight: 600; }
.ew-pt { font-size: 12px; color: var(--text-3); padding-left: 4px; }
.ew-gr { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ew-x { width: 26px; height: 26px; padding: 0; font-size: 15px; color: var(--text-3); }
.ew-add { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) input { border-color: var(--bad); }
#panel.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }
#panel.fade-t { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px); mask-image: linear-gradient(to bottom, transparent, #000 28px); }
#panel.fade-t.fade-b { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); }

/* summary */
.ew-say { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; max-width: 44ch; }
.ew-bigv { color: var(--text); }
.ew-tag { display: inline-block; font-size: 10.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: 4px; white-space: nowrap; line-height: 1.5; }

/* tables */
.ew-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
table.ew-tab { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ew-tab th { font-weight: 500; font-size: 11.5px; color: var(--text-3); text-align: right; padding: 6px 7px; border-bottom: 1px solid var(--line); }
.ew-tab td { text-align: right; padding: 5px 7px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ew-tab .l { text-align: left; }
.ew-tab tr.add td { color: var(--text-3); }
.ew-tab tr.sel td { background: var(--x-eef3fe, #eef3fe); }
.ew-tab tr.tot td { font-weight: 600; color: var(--text); }
.ew-tab tr.open td { color: var(--text-2); }
.ew-haul td.l { white-space: normal; }

@media (max-width: 1100px) { .ew-two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .ew-tab thead { display: none; }
  .ew-tab, .ew-tab tbody { display: block; width: 100%; }
  .ew-tab tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .ew-tab td { display: block; border: 0; padding: 0; text-align: left; white-space: normal; }
  .ew-tab td:empty { display: none; }
  .ew-tab td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .ew-vols td:nth-child(2)::before { content: "ground "; color: var(--text-3); }
  .ew-vols td:nth-child(3)::before { content: "formation "; color: var(--text-3); }
  .ew-vols td:nth-child(4)::before { content: "A cut "; color: var(--text-3); }
  .ew-vols td:nth-child(5)::before { content: "A fill "; color: var(--text-3); }
  .ew-vols td:nth-child(6)::before { content: "V cut "; color: var(--text-3); }
  .ew-vols td:nth-child(7)::before { content: "V fill "; color: var(--text-3); }
  .ew-vols td:nth-child(8)::before { content: "mass "; color: var(--text-3); }
  .ew-haul td:nth-child(2) { grid-column: 1 / -1; }
  .ew-haul td:nth-child(3)::before { content: "volume "; color: var(--text-3); }
  .ew-haul td:nth-child(4)::before { content: "haul "; color: var(--text-3); }
  .ew-haul td:nth-child(5)::before { content: "average "; color: var(--text-3); }
  .ew-haul td:nth-child(6)::before { content: "freehaul vol. "; color: var(--text-3); }
  .ew-haul td:nth-child(7)::before { content: "overhaul vol. "; color: var(--text-3); }
  .ew-haul td:nth-child(8)::before { content: "overhaul "; color: var(--text-3); }
  .ew-haul tr.open td:nth-child(n+4), .ew-haul tr.tot td:nth-child(5), .ew-haul tr.tot td:nth-child(6), .ew-haul tr.tot td:nth-child(7) { display: none; }
}
@media print { .ew-edit { display: none !important; } }

/* hold the drawing's place until app.js draws it (no layout shift) */
#view:empty { aspect-ratio: 1000 / 560; }
@media (max-width: 640px) { #view:empty { aspect-ratio: 375 / 600; } }

/* theme-auto:start · generated by scripts/theme/hexmap.py: dark values (the rule of scripts/theme/colour.py) for
   colours that are not tokens, written as var(--x-rrggbb, #rrggbb): light is the fallback, unchanged */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --x-2d4a8c: #84a1dd; --x-4f7fae: #8db5de; --x-5b4a33: #af9f8a; --x-7a5320: #bd9a72; --x-8a5a0e: #c89e6a;
    --x-b8864a: #deb382; --x-bdd2e6: #32404d; --x-cfdcea: #303841; --x-d3e0ec: #2d363d; --x-e2c79c: #746141;
    --x-e8d3b3: #453721; --x-ead7b8: #423520; --x-eef3fe: #25282f;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-2d4a8c: #84a1dd; --x-4f7fae: #8db5de; --x-5b4a33: #af9f8a; --x-7a5320: #bd9a72; --x-8a5a0e: #c89e6a;
    --x-b8864a: #deb382; --x-bdd2e6: #32404d; --x-cfdcea: #303841; --x-d3e0ec: #2d363d; --x-e2c79c: #746141;
    --x-e8d3b3: #453721; --x-ead7b8: #423520; --x-eef3fe: #25282f;
  }
}
/* theme-auto:end */
