/* CivilCraft — toolbar | site/points/display · plan + profile · properties | status bar.
 * Tokens only (paper/model aware, from tokens.css); hierarchy by line weight; no shadows. */

.cv {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr) 20rem;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "tools tools tools"
    "left stage right"
    "status status status";
  height: 100%;
  min-height: 0;
}

/* ---- toolbar ---- */
.cv-tools { grid-area: tools; display: flex; flex-wrap: wrap; background: var(--sheet-2); border-bottom: var(--pen-2) solid var(--ink); }
.cv-tool-group { display: flex; flex-direction: column; padding: .25rem .35rem .3rem; border-right: var(--pen-1) solid var(--line); flex: 0 0 auto; }
.cv-tool-group:last-of-type { border-right: 0; }
.cv-tool-label { font-size: .75rem; font-weight: 600; color: var(--ink-2); padding: 0 .2rem .15rem; }
.cv-tool-row { display: flex; gap: .1rem; }
.cv-tool {
  display: flex; flex-direction: column; align-items: center; gap: .1rem; min-width: 2.9rem;
  padding: .25rem .25rem .2rem; font: inherit; font-size: .75rem; font-weight: 600; color: var(--ink);
  background: transparent; border: var(--pen-1) solid transparent; border-radius: var(--radius); cursor: pointer; white-space: nowrap;
}
.cv-tool .bi { font-size: 1.15rem; line-height: 1; color: var(--layer); }
.cv-tool:hover { border-color: var(--line); background: var(--sheet); }
.cv-tool:focus-visible { outline: var(--pen-3) solid var(--action); outline-offset: 1px; }
.cv-tool[aria-pressed="true"] { border-color: var(--ink); background: var(--sheet); }
.cv-tool:disabled { opacity: .45; cursor: default; }

body.app-shell .sp-tab { bottom: 2.6rem; }

/* ---- panels ---- */
.cv-panel { overflow-y: auto; min-height: 0; background: var(--sheet-2); }
.cv-left { grid-area: left; border-right: var(--pen-2) solid var(--ink); }
.cv-right { grid-area: right; border-left: var(--pen-2) solid var(--ink); }
.cv-sec { padding: .9rem 1rem; border-bottom: var(--pen-1) solid var(--line); }
.cv-sec:last-child { border-bottom: 0; }
.cv-h { font-size: var(--fs-sm); font-weight: 700; font-stretch: 112%; margin: 0 0 .5rem; }
.cv-h3 { font-size: .875rem; font-weight: 700; margin: .9rem 0 .4rem; }
.cv-note { color: var(--ink-2); font-size: .875rem; margin: .5rem 0 0; }
.cv-mt { margin-top: .75rem; }
.cv-linkbtn { font: inherit; font-weight: 600; color: var(--action); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.cv-linkbtn:hover { text-decoration-thickness: 2px; }
.cv-links { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .5rem; font-size: .875rem; }
.cv-danger { color: var(--layer-red); }

.cv-input, .cv-select {
  width: 100%; min-width: 0; font: inherit; font-size: .875rem; font-weight: 500; color: var(--ink);
  background: var(--sheet); border: var(--pen-1) solid var(--line); border-radius: var(--radius); padding: .2rem .4rem;
  font-variant-numeric: tabular-nums;
}
.cv-input:focus, .cv-select:focus { outline: var(--pen-2) solid var(--action); outline-offset: 0; border-color: var(--action); }
.cv-input[aria-invalid="true"] { border-color: var(--layer-red); }
.cv-props { display: grid; grid-template-columns: fit-content(48%) minmax(0, 1fr); gap: .35rem .6rem; align-items: center; font-size: .875rem; margin: 0; }
.cv-props label, .cv-props .k { color: var(--ink-2); font-weight: 500; }
.cv-props .v { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cv-props .span { grid-column: 1 / -1; }
.cv-row { display: flex; gap: .35rem; align-items: center; min-width: 0; }
.cv-unit { color: var(--ink-2); font-size: .8125rem; white-space: nowrap; }
.cv-dl { display: grid; grid-template-columns: fit-content(55%) minmax(0, 1fr); gap: .25rem .75rem; margin: 0; font-size: .875rem; }
.cv-dl dt { color: var(--ink-2); font-weight: 500; }
.cv-dl dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.cv-report { margin: .6rem 0 0; padding: .45rem .6rem; font-size: .875rem; border-left: var(--pen-3) solid var(--layer-ochre); background: var(--sheet); }
.cv-report.is-error { border-left-color: var(--layer-red); }
.cv-report p { margin: 0; }
.cv-report ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.cv-checks { border: 0; margin: .75rem 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .5rem; font-size: .875rem; }
.cv-checks label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.cv-checks input, .cv-groups input { accent-color: var(--action); }

/* tables (groups, PIs, PVIs, curves) */
.cv-groups, .cv-table { width: 100%; border-collapse: collapse; font-size: .8125rem; margin-top: .5rem; font-variant-numeric: tabular-nums; }
.cv-groups caption { caption-side: top; text-align: left; margin: 0 0 .35rem; }
.cv-groups th, .cv-table th { text-align: left; font-weight: 600; color: var(--ink-2); padding: .2rem .3rem .2rem 0; border-bottom: var(--pen-1) solid var(--line); }
.cv-groups td, .cv-table td { padding: .15rem .3rem .15rem 0; border-bottom: var(--pen-1) solid var(--grid); vertical-align: middle; }
.cv-groups .num, .cv-table .num { text-align: right; }
.cv-groups select { font-size: .8125rem; padding: .1rem .25rem; }
.cv-table input { width: 100%; min-width: 2.8rem; font-size: .78rem; padding: .1rem .2rem; }
.cv-table input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.cv-table input::-webkit-inner-spin-button, .cv-table input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cv-table td:first-child { width: 1.4rem; }
.cv-table td:last-child:has(.cv-x) { width: 1.6rem; }
.cv-table .cv-x { padding: .05rem .2rem; }
.cv-table tr.is-sel td { background: color-mix(in srgb, var(--action) 12%, transparent); }
.cv-table-wrap { overflow-x: auto; }
.cv-swatch { display: inline-block; width: .9rem; height: .9rem; border: var(--pen-1) solid var(--line); border-radius: var(--radius); vertical-align: -2px; margin-right: .35rem; }
.cv-legend { margin-top: .6rem; font-size: .8125rem; display: grid; gap: .1rem; font-variant-numeric: tabular-nums; }
.cv-vol { display: grid; grid-template-columns: auto 1fr; gap: .2rem .75rem; font-size: .9375rem; margin: .35rem 0 0; }
.cv-vol dt { color: var(--ink-2); }
.cv-vol dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.cv-curves { margin: 0; padding-left: 1.2rem; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.cv-curves li + li { margin-top: .35rem; }
.cv-curves span { display: block; }
.cv-curve-sta { font-weight: 600; }
.cv-check { display: flex; align-items: center; gap: .45rem; font-size: .875rem; margin: 0 0 .5rem; cursor: pointer; }
.cv-check input { accent-color: var(--action); }
.cv-plainlist { list-style: none; padding: 0; margin: .25rem 0 0; font-size: .875rem; }
.cv-plainlist li + li { margin-top: .2rem; }
.cv-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

/* ---- stage: plan over profile ---- */
.cv-stage { grid-area: stage; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--sheet); }
.cv-plan { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.cv-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cv-over { cursor: crosshair; touch-action: none; }
.cv-over:focus-visible { outline: var(--pen-3) solid var(--action); outline-offset: -3px; }
.cv-over.is-panning { cursor: grabbing; }
.cv-over.is-select { cursor: default; }
.cv-hint {
  position: absolute; z-index: 2; top: 1rem; left: 1rem; max-width: min(34rem, calc(100% - 2rem));
  padding: .75rem 1rem; font-size: .875rem; background: var(--sheet-2); border: var(--pen-2) solid var(--ink); border-radius: var(--radius);
}
.cv-hint-h { margin: 0 0 .35rem; font-weight: 700; font-stretch: 112%; }
.cv-hint ol { margin: 0; padding-left: 1.2rem; }
.cv-hint li + li { margin-top: .25rem; }
.cv-hint-foot { margin: .5rem 0 0; }
.cv kbd { font-family: inherit; font-size: .8125rem; font-weight: 700; padding: 0 .3rem; color: var(--ink); background: var(--sheet); border: var(--pen-1) solid var(--line); border-radius: var(--radius); }
.cv-drop, .cv-busy {
  position: absolute; inset: .75rem; z-index: 3; display: grid; place-items: center; font-weight: 700;
  background: color-mix(in srgb, var(--sheet) 85%, transparent); border: var(--pen-3) dashed var(--action); border-radius: var(--radius);
}
.cv-busy { border-style: solid; border-color: var(--line); }
.cv-toolhint {
  position: absolute; z-index: 2; left: 50%; bottom: .75rem; transform: translateX(-50%); max-width: calc(100% - 2rem);
  padding: .35rem .75rem; font-size: .875rem; font-weight: 600; background: var(--sheet-2); border: var(--pen-2) solid var(--ink); border-radius: var(--radius);
  pointer-events: none; text-align: center;
}

.cv-profile { flex: 0 0 34%; min-height: 11rem; display: flex; flex-direction: column; border-top: var(--pen-2) solid var(--ink); background: var(--sheet-2); }
.cv-profile[hidden] { display: none; }
.cv-profile-bar { display: flex; align-items: center; gap: .6rem; padding: .3rem .75rem; border-bottom: var(--pen-1) solid var(--line); flex-wrap: wrap; }
.cv-profile-bar .cv-h { margin: 0; }
.cv-prof-al { width: auto; max-width: 14rem; }
.cv-prof-read { margin: 0 0 0 auto; font-variant-numeric: tabular-nums; }
.cv-prof-canvas { position: relative; flex: 1 1 auto; min-height: 0; }
.cv-prof-canvas canvas { touch-action: none; }
.cv-prof-canvas canvas:focus-visible { outline: var(--pen-3) solid var(--action); outline-offset: -3px; }
.cv-toggle { font: inherit; font-size: .8125rem; font-weight: 600; padding: .1rem .55rem; color: var(--ink-2); background: transparent; border: var(--pen-1) solid var(--line); border-radius: var(--radius); cursor: pointer; }
.cv-toggle[aria-pressed="true"] { color: var(--on-action); background: var(--action); border-color: var(--action); }
.cv-x { font: inherit; background: none; border: var(--pen-1) solid transparent; border-radius: var(--radius); color: var(--ink); cursor: pointer; padding: .15rem .4rem; }
.cv-x:hover { border-color: var(--line); }

/* ---- status bar ---- */
.cv-status { grid-area: status; display: flex; align-items: center; gap: 1.1rem; padding: .25rem 1rem; font-size: .8125rem; background: var(--sheet-2); border-top: var(--pen-1) solid var(--line); min-width: 0; }
.cv-coords, .cv-elev, .cv-staoff { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.cv-status-msg { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; text-align: right; }

/* ---- dialogs ---- */
.cv-dialog { width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; color: var(--ink); background: var(--sheet-2); border: var(--pen-2) solid var(--ink); border-radius: var(--radius); }
.cv-dialog::backdrop { background: color-mix(in srgb, var(--ink) 35%, transparent); }
.cv-dlg { display: flex; flex-direction: column; max-height: calc(100vh - 2.5rem); }
.cv-dlg-head, .cv-dlg-foot { display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem; }
.cv-dlg-head { justify-content: space-between; border-bottom: var(--pen-1) solid var(--line); }
.cv-dlg-head .cv-h { margin: 0; }
.cv-dlg-foot { justify-content: flex-end; border-top: var(--pen-1) solid var(--line); flex-wrap: wrap; }
.cv-dlg-body { padding: .9rem 1rem; overflow: auto; min-height: 0; }
.cv-imp-preview { overflow-x: auto; margin-top: .6rem; }
.cv-ask { width: min(30rem, calc(100vw - 2rem)); }
.cv-ask-text { margin: 0; padding: 1rem; }

@media (max-width: 1100px) {
  .cv { grid-template-columns: 14rem minmax(0, 1fr) 16rem; }
}
@media (max-width: 760px) {
  body.app-shell .sp-tab { bottom: .75rem; }
  .cv-tools { flex-wrap: nowrap; overflow-x: auto; }
  .cv {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas: "tools" "stage" "status" "right" "left";
    height: auto;
  }
  .cv-stage { height: 78vh; }
  .cv-profile { flex-basis: 40%; }
  .cv-left, .cv-right { border: 0; border-top: var(--pen-2) solid var(--ink); }
  .cv-status { flex-wrap: wrap; gap: .25rem 1rem; }
  .cv-status-msg { text-align: left; flex-basis: 100%; }
  .cv-hint { font-size: .8125rem; top: .5rem; left: .5rem; max-width: calc(100% - 1rem); padding: .5rem .75rem; }
}
