.workspace-topbar {
  grid-template-columns: 1fr auto;
}
.workspace-topbar nav { display: flex; align-items: center; gap: 18px; }
.workspace-topbar nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 700; font-size: .9375rem; }
.workspace-topbar nav a:hover, .workspace-sections a:hover { text-decoration: underline; }
.workspace-layout { max-width: 1510px; margin: auto; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.project-rail { align-self: start; position: sticky; top: var(--topbar); padding: 27px 18px; }
.project-control { background: var(--white); border: 1px solid var(--line); padding: 14px; border-radius: 12px; }
.project-control label { display: block; margin-bottom: 8px; font-weight: 750; }
.project-control select { max-width: 100%; }
.rail-actions { display: grid; grid-template-columns: repeat(2, auto); gap: 6px; margin-top: 9px; }
.rail-actions .button { padding-inline: 6px; font-size: .85rem; white-space: nowrap; }
#save-status { color: var(--muted); font-size: .875rem; line-height: 1.45; margin-top: 9px; }
.workspace-sections { display: grid; margin-top: 15px; }
.workspace-sections a { padding: 10px 14px; min-height: 44px; border-radius: 7px; color: #2d526b; font-size: .9375rem; font-weight: 700; }
.workspace-sections a:hover { background: #e6f0f4; }
.workspace-main { padding-top: 26px; }
.workspace-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; border-radius: 16px; background: #0c2944; color: #fff; padding: clamp(21px, 3.8vw, 40px); }
.workspace-kicker { color: #a8e5eb; font-size: .875rem; font-weight: 740; margin-bottom: 9px; }
.workspace-heading h1 { font-size: clamp(1.95rem, 4.5vw, 3.4rem); line-height: 1.04; overflow-wrap: anywhere; }
.workspace-heading p:last-child { color: #dae8f1; line-height: 1.55; margin-top: 8px; }
.workspace-heading .button { flex-shrink: 0; }
.work-panel { background: var(--white); border: 1px solid var(--line); border-radius: 14px; margin-top: 16px; padding: clamp(16px, 2.9vw, 29px); scroll-margin-top: calc(var(--topbar) + 12px); }
.panel-heading { margin-bottom: 16px; }
.panel-heading p, .context-note, .formulas p { color: var(--muted); line-height: 1.52; margin-top: 6px; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.workbench input, .workbench select, .workbench textarea {
  width: 100%;
  min-height: 44px;
  background: #f8fafc;
  border: 1px solid #bbccd8;
  border-radius: 8px;
  color: var(--ink);
  padding: 8px 9px;
}
.workbench input:user-invalid { border-color: #a52e36; }
.field-grid label, .notes-label { display: grid; align-content: start; gap: 5px; font-weight: 650; }
.field-grid small { font-size: .875rem; color: var(--muted); font-weight: 500; }
.workbench textarea { resize: vertical; }
.table-wrap { overflow-x: auto; }
.quality-table { margin-top: 19px; }
.workbench table { width: 100%; border-collapse: collapse; text-align: left; }
.workbench th, .workbench td { padding: 8px 9px; border-bottom: 1px solid var(--line); }
.workbench thead th { background: #edf4f8; color: #355269; font-size: .875rem; }
.workbench th[scope="row"] { font-weight: 700; }
.quality-table table { min-width: 460px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.metrics > div { display: grid; gap: 8px; align-content: start; padding: 14px; border: 1px solid #d2e4ea; border-radius: 9px; background: #f2f9fa; }
.metrics span { color: var(--muted); font-size: .875rem; }
.metrics strong { font-size: clamp(1rem, 2vw, 1.35rem); font-variant-numeric: tabular-nums; color: #096078; overflow-wrap: anywhere; }
.formulas { margin-top: 13px; padding: 12px; background: var(--paper); border-radius: 8px; }
.formulas summary { cursor: pointer; font-weight: 700; }
.stage-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; max-width: 620px; }
.stage-picker label { grid-column: 1 / -1; font-weight: 650; }
.stage-list { margin: 14px 0; padding: 0; list-style: none; }
.stage-list li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.stage-list .stage-empty { display: block; color: var(--muted); border: 0; }
.stage-number { display: grid; place-items: center; background: #e7f2f5; color: #185d70; border-radius: 8px; min-height: 32px; font-weight: 700; }
.stage-controls, .inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.stage-button { min-height: 44px; padding: 0 8px; background: #f4f8fb; color: #2c5771; border: 1px solid var(--line); border-radius: 6px; font-size: .875rem; }
.stage-button:hover:not(:disabled) { background: #e2f0f4; }
.workbench button:disabled { opacity: .45; cursor: default; }
.review-list { padding-left: 22px; color: var(--muted); line-height: 1.5; }
.review-list li + li { margin-top: 4px; }
.notes-label { margin-bottom: 14px; }
.context-note { margin-top: 10px; font-size: .9rem; }
@media (max-width: 880px) {
  .workspace-layout { grid-template-columns: 205px minmax(0, 1fr); }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-heading { align-items: flex-start; flex-direction: column; }
  .stage-list li { grid-template-columns: 32px minmax(0, 1fr); }
  .stage-controls { grid-column: 2; }
}
@media (max-width: 700px) {
  .workbench { --topbar: 61px; }
  .workspace-topbar nav { grid-column: 2; grid-row: 1; gap: 9px; }
  .workspace-topbar nav a { font-size: .8125rem; }
  .workspace-layout { display: block; }
  .project-rail { position: static; padding: 12px 14px 0; }
  .project-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 7px; padding: 10px; }
  .project-control label { grid-column: 1 / -1; margin: 0; }
  .rail-actions { margin: 0; }
  #save-status { grid-column: 1 / -1; margin-top: 0; }
  .workspace-sections { display: flex; overflow-x: auto; white-space: nowrap; margin-top: 4px; }
  .workspace-sections a { padding: 9px; }
  .workspace-main { padding-top: 0; }
}
@media (max-width: 405px) {
  .project-control, .field-grid { grid-template-columns: 1fr; }
}

.cloud-row { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.cloud-row label { display: grid; gap: 5px; flex: 1 1 205px; min-width: 0; font-weight: 650; }
.cloud-row select { text-overflow: ellipsis; }
.cloud-save { margin-top: 13px; }
.cloud-save label { flex-basis: 280px; }
.hydraulic-reference { grid-column: 1 / -1; }
.hydraulic-table table { min-width: 530px; }
.hydraulic-table td { min-width: 107px; }
.hydraulic-chart { margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.hydraulic-chart svg { display: block; width: 100%; }
.hydraulic-chart text { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.hydraulic-chart figcaption { color: var(--muted); font-size: .875rem; }
.profile-grid { stroke: var(--line); }
.profile-min { stroke: #a13237; stroke-width: 1.5; stroke-dasharray: 5 5; }
.profile-line { fill: none; stroke: #096078; stroke-width: 2.5; }
.profile-dot { fill: #096078; }

.workspace-topbar nav a { min-height: 44px; color: var(--muted); }
.workspace-topbar .app-nav { gap: 4px; }
.workspace-start { display: flex; flex-wrap: wrap; gap: 8px; }
.transfer-panel .inline-actions { margin-top: 12px; }
#legacy-help a { color: var(--accent); text-decoration: underline; }
.workbench input[hidden] { display: none; }
.workbench [hidden].work-panel { display: none; }
@media (max-width: 450px) {
  .workspace-topbar { grid-template-columns: minmax(0, 1fr); }
  .workspace-topbar .app-nav { grid-column: 1; grid-row: 2; justify-self: start; }
  .workbench { --topbar: 112px; }
}
